[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16205] branches/apricot/source: Apricot Branch: bugfix: glsl materials didn't get correct lights

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Aug 21 17:44:38 CEST 2008


Revision: 16205
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16205
Author:   blendix
Date:     2008-08-21 17:44:29 +0200 (Thu, 21 Aug 2008)

Log Message:
-----------
Apricot Branch: bugfix: glsl materials didn't get correct lights
when switching between blend files. Also took advantage of this
to remove some duplicate code related to accessing blender scenes.

Modified Paths:
--------------
    branches/apricot/source/blender/gpu/intern/gpu_material.c
    branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
    branches/apricot/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    branches/apricot/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
    branches/apricot/source/gameengine/Converter/KX_BlenderSceneConverter.h
    branches/apricot/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp
    branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
    branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.h
    branches/apricot/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
    branches/apricot/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp
    branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.cpp
    branches/apricot/source/gameengine/Ketsji/KX_ISceneConverter.h
    branches/apricot/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
    branches/apricot/source/gameengine/Ketsji/KX_Scene.cpp
    branches/apricot/source/gameengine/Ketsji/KX_Scene.h

Modified: branches/apricot/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_material.c	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/blender/gpu/intern/gpu_material.c	2008-08-21 15:44:29 UTC (rev 16205)
@@ -749,7 +749,7 @@
 
 		if (ob->transflag & OB_DUPLI) {
 			DupliObject *dob;
-			ListBase *lb = object_duplilist(G.scene, ob);
+			ListBase *lb = object_duplilist(shi->gpumat->scene, ob);
 			
 			for(dob=lb->first; dob; dob=dob->next) {
 				Object *ob = dob->ob;

Modified: branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
===================================================================
--- branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp	2008-08-21 15:44:29 UTC (rev 16205)
@@ -309,7 +309,8 @@
 				mousedevice,
 				networkdevice,
 				audiodevice,
-				startscenename);
+				startscenename,
+				blscene);
 			
 			// some python things
 			PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest);
@@ -577,7 +578,9 @@
 				mousedevice,
 				networkdevice,
 				audiodevice,
-				startscenename);
+				startscenename,
+				blscene);
+
 			// some python things
 			PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest);
 			ketsjiengine->SetPythonDictionary(dictionaryobject);

Modified: branches/apricot/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- branches/apricot/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-08-21 15:44:29 UTC (rev 16205)
@@ -1613,20 +1613,6 @@
 	SG_Node* m_gamechildnode;
 };
 
-	/**
-	 * Find the specified scene by name, or the first
-	 * scene if nothing matches (shouldn't happen).
-	 */
-static struct Scene *GetSceneForName(struct Main *maggie, const STR_String& scenename) {
-	Scene *sce;
-
-	for (sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
-		if (scenename == (sce->id.name+2))
-			return sce;
-
-	return (Scene*) maggie->scene.first;
-}
-
 #include "DNA_constraint_types.h"
 #include "BIF_editconstraint.h"
 
@@ -1725,7 +1711,7 @@
 							  )
 {	
 
-	Scene *blenderscene = GetSceneForName(maggie, scenename);
+	Scene *blenderscene = converter->GetBlenderSceneForName(scenename);
 	// for SETLOOPER
 	Scene *sce;
 	Base *base;

Modified: branches/apricot/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
===================================================================
--- branches/apricot/source/gameengine/Converter/KX_BlenderSceneConverter.cpp	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/Converter/KX_BlenderSceneConverter.cpp	2008-08-21 15:44:29 UTC (rev 16205)
@@ -184,21 +184,23 @@
 	return result;
 }
 
+Scene *KX_BlenderSceneConverter::GetBlenderSceneForName(const STR_String& name)
+{
+	Scene *sce;
 
-
 	/**
 	 * Find the specified scene by name, or the first
 	 * scene if nothing matches (shouldn't happen).
 	 */
-static struct Scene *GetSceneForName2(struct Main *maggie, const STR_String& scenename) {
-	Scene *sce;
 
-	for (sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
-		if (scenename == (sce->id.name+2))
+	for (sce= (Scene*) m_maggie->scene.first; sce; sce= (Scene*) sce->id.next)
+		if (name == (sce->id.name+2))
 			return sce;
 
-	return (Scene*) maggie->scene.first;
+	return (Scene*)m_maggie->scene.first;
+
 }
+
 #include "KX_PythonInit.h"
 
 #ifdef USE_BULLET
@@ -258,7 +260,7 @@
 											class RAS_ICanvas* canvas)
 {
 	//find out which physics engine
-	Scene *blenderscene = GetSceneForName2(m_maggie, scenename);
+	Scene *blenderscene = GetBlenderSceneForName(scenename);
 
 	e_PhysicsEngine physics_engine = UseBullet;
 	// hook for registration function during conversion.

Modified: branches/apricot/source/gameengine/Converter/KX_BlenderSceneConverter.h
===================================================================
--- branches/apricot/source/gameengine/Converter/KX_BlenderSceneConverter.h	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/Converter/KX_BlenderSceneConverter.h	2008-08-21 15:44:29 UTC (rev 16205)
@@ -45,6 +45,7 @@
 struct IpoCurve;
 struct Main;
 struct SpaceIpo;
+struct Scene;
 
 class KX_BlenderSceneConverter : public KX_ISceneConverter
 {
@@ -151,6 +152,7 @@
 	virtual void SetGLSLMaterials(bool val);
 	virtual bool GetGLSLMaterials();
 
+	struct Scene* GetBlenderSceneForName(const STR_String& name);
 };
 
 #endif //__KX_BLENDERSCENECONVERTER_H

Modified: branches/apricot/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp
===================================================================
--- branches/apricot/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp	2008-08-21 15:44:29 UTC (rev 16205)
@@ -659,7 +659,8 @@
 				m_mouse,
 				m_networkdevice,
 				m_audiodevice,
-				startscenename);
+				startscenename,
+				m_gamedata->curscene);
 			
 			PyObject* m_dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Highest);
 			//PyObject* m_dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest);

Modified: branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
===================================================================
--- branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp	2008-08-21 15:44:29 UTC (rev 16205)
@@ -105,9 +105,10 @@
 static GHOST_ISystem* fSystem = 0;
 static const int kTimerFreq = 10;
 
-GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR_String startSceneName)
-	: m_startSceneName(startSceneName), 
-	  m_maggie(maggie),
+GPG_Application::GPG_Application(GHOST_ISystem* system)
+	: m_startSceneName(""), 
+	  m_startScene(0),
+	  m_maggie(0),
 	  m_exitRequested(0),
 	  m_system(system), 
 	  m_mainWindow(0), 
@@ -141,15 +142,16 @@
 
 
 
-bool GPG_Application::SetGameEngineData(struct Main* maggie, STR_String startSceneName)
+bool GPG_Application::SetGameEngineData(struct Main* maggie, Scene *scene)
 {
 	bool result = false;
 
-	if (maggie != NULL && startSceneName != "")
+	if (maggie != NULL && scene != NULL)
 	{
-		G.scene = (Scene*)maggie->scene.first;
+		G.scene = scene;
 		m_maggie = maggie;
-		m_startSceneName = startSceneName;
+		m_startSceneName = scene->id.name+2;
+		m_startScene = scene;
 		result = true;
 	}
 
@@ -645,7 +647,8 @@
 			m_mouse,
 			m_networkdevice,
 			m_audiodevice,
-			startscenename);
+			startscenename,
+			m_startScene);
 		
 		
 		// some python things

Modified: branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.h
===================================================================
--- branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.h	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.h	2008-08-21 15:44:29 UTC (rev 16205)
@@ -50,14 +50,15 @@
 class GPG_KeyboardDevice;
 class GPG_System;
 struct Main;
+struct Scene;
 
 class GPG_Application : public GHOST_IEventConsumer
 {
 public:
-	GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR_String startSceneName);
+	GPG_Application(GHOST_ISystem* system);
 	~GPG_Application(void);
 
-			bool SetGameEngineData(struct Main* maggie,STR_String startSceneName);
+			bool SetGameEngineData(struct Main* maggie, struct Scene* scene);
 			bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight,
 			const bool stereoVisual, const int stereoMode);
 			bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode);
@@ -100,6 +101,7 @@
 
 	/* The game data */
 	STR_String				m_startSceneName;
+	struct Scene*			m_startScene;
 	struct Main*			m_maggie;
 
 	/* Exit state. */

Modified: branches/apricot/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
===================================================================
--- branches/apricot/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp	2008-08-21 15:44:29 UTC (rev 16205)
@@ -559,7 +559,7 @@
 			{
 				int exitcode = KX_EXIT_REQUEST_NO_REQUEST;
 				STR_String exitstring = "";
-				GPG_Application app(system, NULL, exitstring);
+				GPG_Application app(system);
 				bool firstTimeRunning = true;
 				char *filename = get_filename(argc, argv);
 				char *titlename;
@@ -617,7 +617,6 @@
 #endif // WIN32
 						Main *maggie = bfd->main;
 						Scene *scene = bfd->curscene;
-						char *startscenename = scene->id.name + 2;
 						G.main = maggie;
 						G.fileflags  = bfd->fileflags;
 
@@ -656,7 +655,7 @@
 						}
 						
 						//					GPG_Application app (system, maggie, startscenename);
-						app.SetGameEngineData(maggie, startscenename);
+						app.SetGameEngineData(maggie, scene);
 						
 						if (firstTimeRunning)
 						{

Modified: branches/apricot/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp
===================================================================
--- branches/apricot/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp	2008-08-21 15:19:54 UTC (rev 16204)
+++ branches/apricot/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp	2008-08-21 15:44:29 UTC (rev 16205)
@@ -564,7 +564,7 @@
 			= new KX_Scene((SCA_IInputDevice*)k->keyboarddevice,
 				       (SCA_IInputDevice*)k->mousedevice, k->net_dev,
 				       k->audiodevice,
-				       startSceneName->Ptr());
+				       startSceneName->Ptr(), scene);
 		
 		initRasterizer(k->rasterizer, k->canvas_device);;
 		PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(k->kx_engine, startscene)); // Same as importing the module

Modified: branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.cpp
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list