[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50372] trunk/blender: fix for building without python, also rework python-main-loop control in the BGE to not use RNA ( use lower level BKE/BLI funcs instead)

Campbell Barton ideasman42 at gmail.com
Tue Sep 4 05:26:15 CEST 2012


Revision: 50372
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50372
Author:   campbellbarton
Date:     2012-09-04 03:26:12 +0000 (Tue, 04 Sep 2012)
Log Message:
-----------
fix for building without python, also rework python-main-loop control in the BGE to not use RNA (use lower level BKE/BLI funcs instead)

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
    trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PythonMain.cpp

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2012-09-04 02:33:37 UTC (rev 50371)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2012-09-04 03:26:12 UTC (rev 50372)
@@ -724,7 +724,7 @@
 		int r;
 		GetKeyboardState((PBYTE)state);
 
-		if (r = ToUnicodeEx(vk, 0, state, utf16, 2, 0, system->m_keylayout)) {
+		if ((r = ToUnicodeEx(vk, 0, state, utf16, 2, 0, system->m_keylayout))) {
 			if ((r > 0 && r < 3)) {
 				utf16[r] = 0;
 				conv_utf_16_to_8(utf16, utf8_char, 6);

Modified: trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
===================================================================
--- trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp	2012-09-04 02:33:37 UTC (rev 50371)
+++ trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp	2012-09-04 03:26:12 UTC (rev 50372)
@@ -439,7 +439,6 @@
 			rasterizer->SetBackColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 0.0f);
 		}
 		
-		char *python_main = NULL;
 		if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
 		{
 			if (rv3d->persp != RV3D_CAMOB)
@@ -534,18 +533,17 @@
 				// Could be in StartEngine set the framerate, we need the scene to do this
 				ketsjiengine->SetAnimFrameRate(FPS);
 				
+#ifdef WITH_PYTHON
 				char *python_main = NULL;
 				pynextframestate.state = NULL;
 				pynextframestate.func = NULL;
-#ifdef WITH_PYTHON
 				python_main = KX_GetPythonMain(scene);
-#endif // WITH_PYTHON
+
 				// the mainloop
 				printf("\nBlender Game Engine Started\n");
 				if (python_main) {
 					char *python_code = KX_GetPythonCode(blenderdata, python_main);
 					if (python_code) {
-#ifdef WITH_PYTHON			    
 						ketsjinextframestate.ketsjiengine = ketsjiengine;
 						ketsjinextframestate.C = C;
 						ketsjinextframestate.win = win;
@@ -560,11 +558,12 @@
 						printf("Yielding control to Python script '%s'...\n", python_main);
 						PyRun_SimpleString(python_code);
 						printf("Exit Python script '%s'\n", python_main);
-#endif // WITH_PYTHON				
 						MEM_freeN(python_code);
-					}				
+					}
 				}
-				else {
+				else
+#endif  /* WITH_PYTHON */
+				{
 					while (!exitrequested)
 					{
 						exitrequested = BL_KetsjiNextFrame(ketsjiengine, C, win, scene, ar, keyboarddevice, mousedevice, draw_letterbox);
@@ -572,7 +571,9 @@
 				}
 				printf("Blender Game Engine Finished\n");
 				exitstring = ketsjiengine->GetExitString();
+#ifdef WITH_PYTHON
 				if (python_main) MEM_freeN(python_main);
+#endif  /* WITH_PYTHON */
 
 				gs = *(ketsjiengine->GetGlobalSettings());
 

Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonMain.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonMain.cpp	2012-09-04 02:33:37 UTC (rev 50371)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonMain.cpp	2012-09-04 03:26:12 UTC (rev 50372)
@@ -36,43 +36,42 @@
 extern "C" {
 #endif
 
-#include "RNA_access.h"
+#include <stddef.h>
+
 #include "MEM_guardedalloc.h"
+
+#include "BLI_string.h"
+#include "BLI_listbase.h"
+
 #include "BKE_text.h"
 #include "BKE_main.h"
+#include "BKE_idprop.h"
 
+
 #ifdef __cplusplus
 }
 #endif
 
-extern "C" char *KX_GetPythonMain(struct Scene* scene)
+extern "C" char *KX_GetPythonMain(struct Scene *scene)
 {
-    //examine custom scene properties
+	/* examine custom scene properties */
+	if (scene->id.properties) {
+		IDProperty *item = IDP_GetPropertyTypeFromGroup(scene->id.properties, "__main__", IDP_STRING);
+		if (item) {
+			return BLI_strdup(IDP_String(item));
+		}
+	}
 
-    PointerRNA sceneptr;
-    RNA_id_pointer_create(&scene->id, &sceneptr);
-
-    PropertyRNA *pymain = RNA_struct_find_property(&sceneptr, "[\"__main__\"]");
-    if (pymain == NULL) return NULL;
-    char *python_main;
-    int len;
-    python_main = RNA_property_string_get_alloc(&sceneptr, pymain, NULL, 0, &len);
-    return python_main;
+	return NULL;
 }
 
-extern "C" char *KX_GetPythonCode(Main *main, char *python_main)
+extern "C" char *KX_GetPythonCode(Main *bmain, char *python_main)
 {
-    PointerRNA mainptr, txtptr;
-    PropertyRNA *texts;
+	Text *text;
 
-    RNA_main_pointer_create(main, &mainptr);
-    texts = RNA_struct_find_property(&mainptr, "texts");
-    char *python_code = NULL;
-    int ok = RNA_property_collection_lookup_string(&mainptr, texts, python_main, &txtptr);
-    if (ok) {
-        Text *text = (Text *) txtptr.data;
-        python_code = txt_to_buf(text);
-    }
-    return python_code;
-}
+	if ((text = (Text *)BLI_findstring(&bmain->text, python_main, offsetof(ID, name) + 2))) {
+		return txt_to_buf(text);
+	}
 
+	return NULL;
+}




More information about the Bf-blender-cvs mailing list