[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15967] trunk/blender/source: Added GameLogic. Mathutils so Mathutils and its types can be accessed from blenderplayer.
lguillaume
lecocqguillaume at gmail.com
Tue Aug 5 15:01:24 CEST 2008
With Cmake for creating MSVC project file, I need to modify cmakelist in
source\gameengine\Ketsji\ :
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 15969)
+++ CMakeLists.txt (working copy)
@@ -60,6 +60,7 @@
../../../extern/bullet2/src
../../../extern/solid
../../../extern/glew/include
+ ../../../source/blender/python/api2_2x
${PYTHON_INC}
${SDL_INC}
)
With, blender compiles ok.
2008/8/5 Campbell Barton <ideasman42 at gmail.com>:
> Revision: 15967
>
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15967
> Author: campbellbarton
> Date: 2008-08-05 11:35:46 +0200 (Tue, 05 Aug 2008)
>
> Log Message:
> -----------
> Added GameLogic.Mathutils so Mathutils and its types can be accessed from
> blenderplayer.
> also changed importText so it dosnt do a malloc
>
> Modified Paths:
> --------------
> trunk/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c
> trunk/blender/source/blender/python/BPY_interface.c
> trunk/blender/source/blender/python/api2_2x/Blender.c
> trunk/blender/source/blender/python/api2_2x/Mathutils.c
> trunk/blender/source/blender/python/api2_2x/Mathutils.h
> trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
> trunk/blender/source/gameengine/Ketsji/SConscript
>
> Modified:
> trunk/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c
> 2008-08-05 06:51:03 UTC (rev 15966)
> +++ trunk/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c
> 2008-08-05 09:35:46 UTC (rev 15967)
> @@ -117,10 +117,14 @@
> {
> return 0;
> }
> +
> +/*
> int EXPP_dict_set_item_str(struct PyObject *dict, char *key, struct
> PyObject *value)
> {
> return 0;
> }
> +*/
> +
> void Node_SetStack(struct BPy_Node *self, struct bNodeStack **stack, int
> type){}
> void InitNode(struct BPy_Node *self, struct bNode *node){}
> void Node_SetShi(struct BPy_Node *self, struct ShadeInput *shi){}
>
> Modified: trunk/blender/source/blender/python/BPY_interface.c
> ===================================================================
> --- trunk/blender/source/blender/python/BPY_interface.c 2008-08-05 06:51:03
> UTC (rev 15966)
> +++ trunk/blender/source/blender/python/BPY_interface.c 2008-08-05 09:35:46
> UTC (rev 15967)
> @@ -163,7 +163,7 @@
> PyObject *CreateGlobalDictionary( void );
> void ReleaseGlobalDictionary( PyObject * dict );
> void DoAllScriptsFromList( ListBase * list, short event );
> -PyObject *importText( char *name );
> +static PyObject *importText( char *name );
> void init_ourImport( void );
> void init_ourReload( void );
> PyObject *blender_import( PyObject * self, PyObject * args );
> @@ -1104,12 +1104,10 @@
>
> *****************************************************************************/
> void BPY_free_compiled_text( struct Text *text )
> {
> - if( !text->compiled )
> - return;
> - Py_DECREF( ( PyObject * ) text->compiled );
> - text->compiled = NULL;
> -
> - return;
> + if( text->compiled ) {
> + Py_DECREF( ( PyObject * ) text->compiled );
> + text->compiled = NULL;
> + }
> }
>
>
> /*****************************************************************************
> @@ -2780,48 +2778,38 @@
> return;
> }
>
> -PyObject *importText( char *name )
> +static PyObject *importText( char *name )
> {
> Text *text;
> - char *txtname;
> + char txtname[22]; /* 21+NULL */
> char *buf = NULL;
> int namelen = strlen( name );
> -
> - txtname = malloc( namelen + 3 + 1 );
> - if( !txtname )
> - return NULL;
> -
> +
> + if (namelen>21-3) return NULL; /* we know this cant be importable,
> the name is too long for blender! */
> +
> memcpy( txtname, name, namelen );
> memcpy( &txtname[namelen], ".py", 4 );
>
> - text = ( Text * ) & ( G.main->text.first );
> -
> - while( text ) {
> + for(text = G.main->text.first; text; text = text->id.next) {
> if( !strcmp( txtname, text->id.name+2 ) )
> break;
> - text = text->id.next;
> }
>
> - if( !text ) {
> - free( txtname );
> + if( !text )
> return NULL;
> - }
>
> if( !text->compiled ) {
> buf = txt_to_buf( text );
> - text->compiled =
> - Py_CompileString( buf, text->id.name+2,
> Py_file_input );
> + text->compiled = Py_CompileString( buf, text->id.name+2,
> Py_file_input );
> MEM_freeN( buf );
>
> if( PyErr_Occurred( ) ) {
> PyErr_Print( );
> BPY_free_compiled_text( text );
> - free( txtname );
> return NULL;
> }
> }
>
> - free( txtname );
> return PyImport_ExecCodeModule( name, text->compiled );
> }
>
>
> Modified: trunk/blender/source/blender/python/api2_2x/Blender.c
> ===================================================================
> --- trunk/blender/source/blender/python/api2_2x/Blender.c 2008-08-05
> 06:51:03 UTC (rev 15966)
> +++ trunk/blender/source/blender/python/api2_2x/Blender.c 2008-08-05
> 09:35:46 UTC (rev 15967)
> @@ -1074,7 +1074,7 @@
> PyDict_SetItemString(dict, "Material", Material_Init());
> PyDict_SetItemString(dict, "Mesh", Mesh_Init());
> PyDict_SetItemString(dict, "Metaball", Metaball_Init());
> - PyDict_SetItemString(dict, "Mathutils", Mathutils_Init());
> + PyDict_SetItemString(dict, "Mathutils",
> Mathutils_Init("Blender.Mathutils"));
> PyDict_SetItemString(dict, "Geometry", Geometry_Init());
> PyDict_SetItemString(dict, "Modifier", Modifier_Init());
> PyDict_SetItemString(dict, "NMesh", NMesh_Init());
>
> Modified: trunk/blender/source/blender/python/api2_2x/Mathutils.c
> ===================================================================
> --- trunk/blender/source/blender/python/api2_2x/Mathutils.c 2008-08-05
> 06:51:03 UTC (rev 15966)
> +++ trunk/blender/source/blender/python/api2_2x/Mathutils.c 2008-08-05
> 09:35:46 UTC (rev 15967)
> @@ -106,8 +106,9 @@
> {"Point", (PyCFunction) M_Mathutils_Point, METH_VARARGS,
> M_Mathutils_Point_doc},
> {NULL, NULL, 0, NULL}
> };
> -//----------------------------MODULE INIT-------------------------
> -PyObject *Mathutils_Init(void)
> +/*----------------------------MODULE INIT-------------------------*/
> +/* from can be Blender.Mathutils or GameLogic.Mathutils for the BGE */
> +PyObject *Mathutils_Init(char *from)
> {
> PyObject *submodule;
>
> @@ -125,8 +126,7 @@
> if( PyType_Ready( &quaternion_Type ) < 0 )
> return NULL;
>
> - submodule = Py_InitModule3("Blender.Mathutils",
> - M_Mathutils_methods, M_Mathutils_doc);
> + submodule = Py_InitModule3(from, M_Mathutils_methods,
> M_Mathutils_doc);
> return (submodule);
> }
> //-----------------------------METHODS----------------------------
>
> Modified: trunk/blender/source/blender/python/api2_2x/Mathutils.h
> ===================================================================
> --- trunk/blender/source/blender/python/api2_2x/Mathutils.h 2008-08-05
> 06:51:03 UTC (rev 15966)
> +++ trunk/blender/source/blender/python/api2_2x/Mathutils.h 2008-08-05
> 09:35:46 UTC (rev 15967)
> @@ -38,7 +38,7 @@
> #include "euler.h"
> #include "point.h"
>
> -PyObject *Mathutils_Init( void );
> +PyObject *Mathutils_Init( char * from );
> PyObject *row_vector_multiplication(VectorObject* vec, MatrixObject *
> mat);
> PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject*
> vec);
> PyObject *row_point_multiplication(PointObject* pt, MatrixObject * mat);
>
> Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
> ===================================================================
> --- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2008-08-05
> 06:51:03 UTC (rev 15966)
> +++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2008-08-05
> 09:35:46 UTC (rev 15967)
> @@ -62,6 +62,10 @@
>
> #include "KX_PyMath.h"
>
> +extern "C" {
> + #include "Mathutils.h" // Blender.Mathutils module copied here so
> the blenderlayer can use.
> +}
> +
> #include "PHY_IPhysicsEnvironment.h"
> // FIXME: Enable for access to blender python modules. This is disabled
> because
> // python has dependencies on a lot of other modules and is a pain to
> link.
> @@ -733,7 +737,10 @@
>
> ErrorObject = PyString_FromString("GameLogic.error");
> PyDict_SetItemString(d, "error", ErrorObject);
> -
> +
> + // Add Blender.Mathutils module, duplicate code :/
> + PyDict_SetItemString(d, "Mathutils",
> Mathutils_Init("GameLogic.Mathutils"));
> +
> // XXXX Add constants here
> /* To use logic bricks, we need some sort of constants. Here, we
> associate */
> /* constants and sumbolic names. Add them to dictionary d.
> */
>
> Modified: trunk/blender/source/gameengine/Ketsji/SConscript
> ===================================================================
> --- trunk/blender/source/gameengine/Ketsji/SConscript 2008-08-05 06:51:03
> UTC (rev 15966)
> +++ trunk/blender/source/gameengine/Ketsji/SConscript 2008-08-05 09:35:46
> UTC (rev 15967)
> @@ -5,7 +5,21 @@
>
> sources = env.Glob('*.cpp')
>
> -incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc'
> +# Mathutils C files.
> +sources.extend([\
> + '#source/blender/python/api2_2x/Mathutils.c',\
> + '#source/blender/python/api2_2x/constant.c',\
> + '#source/blender/python/api2_2x/euler.c',\
> + '#source/blender/python/api2_2x/gen_utils.c',\
> + '#source/blender/python/api2_2x/matrix.c',\
> + '#source/blender/python/api2_2x/point.c',\
> + '#source/blender/python/api2_2x/quat.c',\
> + '#source/blender/python/api2_2x/vector.c',\
> +])
> +
> +incs = '. #source/blender/python/api2_2x' # Only for Mathutils! - no other
> deps
> +
> +incs += ' #source/kernel/gen_system #intern/string #intern/guardedalloc'
> incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer
> #intern/bmfont'
> incs += ' #intern/SoundSystem #intern/SoundSystem/include
> #intern/SoundSystem/openal'
> incs += ' #intern/SoundSystem/dummy #intern/SoundSystem/intern
> #source/gameengine/Converter'
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-committers/attachments/20080805/98fa66a9/attachment-0001.htm
More information about the Bf-committers
mailing list