game engine support for recording animation back & some other minor changes.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 22 Feb 2010 12:25:58 +0000 (12:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 22 Feb 2010 12:25:58 +0000 (12:25 +0000)
16 files changed:
release/scripts/op/fcurve_euler_filter.py
release/scripts/ui/properties_game.py
release/scripts/ui/space_graph.py
release/scripts/ui/space_info.py
source/blender/editors/space_view3d/view3d_view.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c
source/blender/python/intern/bpy_rna.c
source/blender/windowmanager/intern/wm_event_system.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.h
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.h

index 225d2479950aaf6c6f4e0a3e79028fdd63afe7e9..47473be01218cae1a69d3f1a1f858eb1306ed0ee 100644 (file)
@@ -45,7 +45,7 @@ def main(context):
 
 class DiscontFilterOp(bpy.types.Operator):
     """Fixes the most common causes of gimbal lock in the fcurves of the active bone"""
-    bl_idname = "graph.discont_filter"
+    bl_idname = "graph.euler_filter"
     bl_label = "Filter out discontinuities in the active fcurves"
 
     def poll(self, context):
@@ -63,4 +63,3 @@ def unregister():
 
 if __name__ == "__main__":
     register()
-
index 52821bb6a0f78093a24bc1ec6baa8ececbc80a24..57c65402af4e7be9243fe7c6db571822b77ae419 100644 (file)
@@ -357,13 +357,13 @@ class RENDER_PT_game_performance(RenderButtonsPanel):
         col.prop(gs, "show_debug_properties", text="Debug Properties")
         col.prop(gs, "show_framerate_profile", text="Framerate and Profile")
         col.prop(gs, "show_physics_visualization", text="Physics Visualization")
-        col.prop(gs, "deprecation_warnings")
+        col.prop(gs, "use_deprecation_warnings")
 
         if wide_ui:
             col = split.column()
         col.label(text="Render:")
-        col.prop(gs, "all_frames")
-        col.prop(gs, "display_lists")
+        col.prop(gs, "use_frame_rate")
+        col.prop(gs, "use_display_lists")
 
 
 class RENDER_PT_game_sound(RenderButtonsPanel):
index c9c79a7f16bc8d4834463296f4fe17e3c347f567..138b118ea697dd24cee077a58bf9cdc8a28fc3f8 100644 (file)
@@ -148,7 +148,7 @@ class GRAPH_MT_channel(bpy.types.Menu):
         layout.operator("anim.channels_collapse")
 
         layout.separator()
-        layout.operator("graph.discont_filter", text="Discontinuity (Euler) Filter")
+        layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
 
 
 class GRAPH_MT_key(bpy.types.Menu):
index c50893a24831f9d4de51e5930970a24a3106d802..f58c8d210fc85ee6d176209081ccf0fc42bca44b 100644 (file)
@@ -253,7 +253,8 @@ class INFO_MT_game(bpy.types.Menu):
         layout.prop(gs, "show_debug_properties")
         layout.prop(gs, "show_framerate_profile")
         layout.prop(gs, "show_physics_visualization")
-        layout.prop(gs, "deprecation_warnings")
+        layout.prop(gs, "use_deprecation_warnings")
+        layout.prop(gs, "use_animation_record")
 
 
 class INFO_MT_render(bpy.types.Menu):
index 59051c7a894d8b786cdab741e7120e09fc032e2e..09d8d79f8f5c4ebd435c7e39a5fde05ac12df26e 100644 (file)
@@ -1690,8 +1690,8 @@ void game_set_commmandline_options(GameData *gm)
                test= (gm->flag & GAME_ENABLE_ALL_FRAMES);
                SYS_WriteCommandLineInt(syshandle, "fixedtime", test);
 
-//             a= (G.fileflags & G_FILE_GAME_TO_IPO);
-//             SYS_WriteCommandLineInt(syshandle, "game2ipo", a);
+               test= (gm->flag & GAME_ENABLE_ANIMATION_RECORD);
+               SYS_WriteCommandLineInt(syshandle, "animation_record", test);
 
                test= (gm->flag & GAME_IGNORE_DEPRECATION_WARNINGS);
                SYS_WriteCommandLineInt(syshandle, "ignore_deprecation_warnings", test);
index 2bea683b392e227d463628cea5320b74949ce983..928637a00475260d9a60d76262755537a37488d1 100644 (file)
@@ -487,6 +487,7 @@ typedef struct GameData {
 #define GAME_GLSL_NO_NODES                                     (1 << 10)
 #define GAME_GLSL_NO_EXTRA_TEX                         (1 << 11)
 #define GAME_IGNORE_DEPRECATION_WARNINGS       (1 << 12)
+#define GAME_ENABLE_ANIMATION_RECORD           (1 << 13)
 
 /* GameData.matmode */
 #define GAME_MAT_TEXFACE       0
index c947edd7d6d990f56c2754ea47788e063de07247..d0745e8d1596b967e438d466e17d864a5195e077 100644 (file)
@@ -1501,51 +1501,46 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
        prop= RNA_def_property(srna, "use_occlusion_culling", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", (1 << 5)); //XXX mode hardcoded // WO_DBVT_CULLING
        RNA_def_property_ui_text(prop, "DBVT culling", "Use optimized Bullet DBVT tree for view frustrum and occlusion culling");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
        
        // not used // deprecated !!!!!!!!!!!!!
        prop= RNA_def_property(srna, "activity_culling", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", (1 << 3)); //XXX mode hardcoded
        RNA_def_property_ui_text(prop, "Activity Culling", "Activity culling is enabled");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
 
        // not used // deprecated !!!!!!!!!!!!!
        prop= RNA_def_property(srna, "activity_culling_box_radius", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "activityBoxRadius");
        RNA_def_property_range(prop, 0.0, 1000.0);
        RNA_def_property_ui_text(prop, "box radius", "Radius of the activity bubble, in Manhattan length. Objects outside the box are activity-culled");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
 
        /* booleans */
-       prop= RNA_def_property(srna, "all_frames", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES);
-       RNA_def_property_ui_text(prop, "All Frames", "Render as many frames as possible, rather than respecting framerate");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
-
        prop= RNA_def_property(srna, "show_debug_properties", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_DEBUG_PROPS);
        RNA_def_property_ui_text(prop, "Show Debug Properties", "Show properties marked for debugging while the game runs");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
 
        prop= RNA_def_property(srna, "show_framerate_profile", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_FRAMERATE);
        RNA_def_property_ui_text(prop, "Show Framerate and Profile", "Show framerate and profiling information while the game runs");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
 
        prop= RNA_def_property(srna, "show_physics_visualization", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_PHYSICS);
        RNA_def_property_ui_text(prop, "Show Physics Visualization", "Show a visualization of physics bounds and interactions");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
 
-       prop= RNA_def_property(srna, "display_lists", PROP_BOOLEAN, PROP_NONE);
+       prop= RNA_def_property(srna, "use_frame_rate", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES);
+       RNA_def_property_ui_text(prop, "Use Frame Rate", "Respect the frame rate rather then rendering as many frames as possible");
+
+       prop= RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS);
        RNA_def_property_ui_text(prop, "Display Lists", "Use display lists to speed up rendering by keeping geometry on the GPU");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
 
-       prop= RNA_def_property(srna, "deprecation_warnings", PROP_BOOLEAN, PROP_NONE);
+       prop= RNA_def_property(srna, "use_deprecation_warnings", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_IGNORE_DEPRECATION_WARNINGS);
        RNA_def_property_ui_text(prop, "Deprecation Warnings", "Print warnings when using deprecated features in the python API");
-       RNA_def_property_update(prop, NC_SCENE, NULL);
+
+       prop= RNA_def_property(srna, "use_animation_record", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ANIMATION_RECORD);
+       RNA_def_property_ui_text(prop, "Record Animation", "Record animation to fcurves");
 
        /* materials */
        prop= RNA_def_property(srna, "material_mode", PROP_ENUM, PROP_NONE);
index 29c262d58156a78a3643cca52816851c6ce75e38..e9290b69265051b7441d02587fc1ef1ef1c3ab19 100644 (file)
@@ -1639,47 +1639,81 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self)
        return BPy_Wrap_GetValues(self->ptr.id.data, group);
 }
 
-static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args)
+/* internal use for insert and delete */
+int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *error_prefix,
+       char **path_full, int *index, float *cfra) /* return values */
 {
-       char *path, *path_full;
-       int index= -1; /* default to all */
-       float cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
+       char *path;
        PropertyRNA *prop;
-       PyObject *result;
 
-       if (!PyArg_ParseTuple(args, "s|if:keyframe_insert", &path, &index, &cfra))
-               return NULL;
+       if (!PyArg_ParseTuple(args, "s|if", &path, &index, &cfra)) {
+               PyErr_Format(PyExc_TypeError, "%.200s: expected a string and optionally an int and float arguments", error_prefix);
+               return -1;
+       }
 
-       if (self->ptr.data==NULL) {
-               PyErr_Format( PyExc_TypeError, "keyframe_insert, this struct has no data, cant be animated", path);
-               return NULL;
+       if (ptr->data==NULL) {
+               PyErr_Format(PyExc_TypeError, "%.200s: this struct has no data, can't be animated", error_prefix);
+               return -1;
        }
 
-       prop = RNA_struct_find_property(&self->ptr, path);
+       prop = RNA_struct_find_property(ptr, path);
 
        if (prop==NULL) {
-               PyErr_Format( PyExc_TypeError, "keyframe_insert, property \"%s\" not found", path);
-               return NULL;
+               PyErr_Format( PyExc_TypeError, "%.200s: property \"%s\" not found", error_prefix, path);
+               return -1;
        }
 
-       if (!RNA_property_animateable(&self->ptr, prop)) {
-               PyErr_Format( PyExc_TypeError, "keyframe_insert, property \"%s\" not animatable", path);
-               return NULL;
+       if (!RNA_property_animateable(ptr, prop)) {
+               PyErr_Format( PyExc_TypeError, "%.200s: property \"%s\" not animatable", error_prefix, path);
+               return -1;
        }
 
-       path_full= RNA_path_from_ID_to_property(&self->ptr, prop);
+       *path_full= RNA_path_from_ID_to_property(ptr, prop);
 
-       if (path_full==NULL) {
-               PyErr_Format( PyExc_TypeError, "keyframe_insert, could not make path to \"%s\"", path);
-               return NULL;
+       if (*path_full==NULL) {
+               PyErr_Format( PyExc_TypeError, "%.200s: could not make path to \"%s\"", error_prefix, path);
+               return -1;
        }
 
-       result= PyBool_FromLong( insert_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
+       if(*cfra==FLT_MAX)
+               *cfra= CTX_data_scene(BPy_GetContext())->r.cfra;
+
+       return 0; /* success */
+}
+
+static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args)
+{
+       PyObject *result;
+       /* args, pyrna_struct_keyframe_parse handles these */
+       char *path_full= NULL;
+       int index= -1;
+       float cfra= FLT_MAX;
+
+       if(pyrna_struct_keyframe_parse(&self->ptr, args, "keyframe_insert", &path_full, &index, &cfra) == -1)
+               return NULL;
+
+       result= PyBool_FromLong(insert_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
        MEM_freeN(path_full);
 
        return result;
 }
 
+static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args)
+{
+       PyObject *result;
+       /* args, pyrna_struct_keyframe_parse handles these */
+       char *path_full= NULL;
+       int index= -1;
+       float cfra= FLT_MAX;
+
+       if(pyrna_struct_keyframe_parse(&self->ptr, args, "keyframe_delete", &path_full, &index, &cfra) == -1)
+               return NULL;
+
+       result= PyBool_FromLong(delete_keyframe((ID *)self->ptr.id.data, NULL, NULL, path_full, index, cfra, 0));
+       MEM_freeN(path_full);
+
+       return result;
+}
 
 static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
 {
@@ -2659,6 +2693,7 @@ static struct PyMethodDef pyrna_struct_methods[] = {
 
        /* maybe this become and ID function */
        {"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS, NULL},
+//     {"keyframe_delete", (PyCFunction)pyrna_struct_keyframe_delete, METH_VARARGS, NULL}, // WIP
        {"driver_add", (PyCFunction)pyrna_struct_driver_add, METH_VARARGS, NULL},
        {"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, NULL},
        {"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, NULL},
index 92780d1b97380aac2816d0a3e7bccb99b0e36b19..b72bc02aca6d421f11b508e9f5eca333be729dad 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <math.h>
 
 #include "DNA_listBase.h"
 #include "DNA_screen_types.h"
index 9c8ccfe7380a84d46983c32e06b411774af1870b..8f626ea66a54f28e17be3a145e071222e8417107 100644 (file)
@@ -266,6 +266,7 @@ void WM_operator_bl_idname(char *to, const char *from){}
 void WM_operator_py_idname(char *to, const char *from){}
 void WM_operator_ui_popup(struct bContext *C, struct wmOperator *op, int width, int height){}
 short insert_keyframe (struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag){return 0;}
+short delete_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag){return 0;};
 char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args){return NULL;}
 struct wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value){return NULL;}
 struct wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, EnumPropertyItem *items){return NULL;}
@@ -301,7 +302,7 @@ void smoke_get_index(void) {return;}
 void smoke_step(void) {return;}
 */
 
-char blender_path(){return (char) NULL;}
+char blender_path[] = "";
 
 /* CSG */
 struct CSG_BooleanOperation * CSG_NewBooleanFunction( void ){return (struct CSG_BooleanOperation *) NULL;}
index d06fc28361394768b66ecb40457845e1d2af1314..c655a2538e8436ef50e034d37f04c94b60102bd4 100644 (file)
@@ -168,7 +168,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
                bool usefixed = (SYS_GetCommandLineInt(syshandle, "fixedtime", 0) != 0);
                bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
                bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
-               bool game2ipo = (SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0);
+               bool animation_record = (SYS_GetCommandLineInt(syshandle, "animation_record", 0) != 0);
                bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
                bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
                bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0);
@@ -322,7 +322,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
                if (blscene)
                {
                        int startFrame = blscene->r.cfra;
-                       ketsjiengine->SetGame2IpoMode(game2ipo,startFrame);
+                       ketsjiengine->SetAnimRecordMode(animation_record, startFrame);
                        
                        // Quad buffered needs a special window.
                        if(blscene->gm.stereoflag == STEREO_ENABLED){
@@ -409,7 +409,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
                                // Set the animation playback rate for ipo's and actions
                                // the framerate below should patch with FPS macro defined in blendef.h
                                // Could be in StartEngine set the framerate, we need the scene to do this
-                               ketsjiengine->SetAnimFrameRate( (((double) blscene->r.frs_sec) / blscene->r.frs_sec_base) );
+                               ketsjiengine->SetAnimFrameRate(FPS);
                                
                                // the mainloop
                                printf("\nBlender Game Engine Started\n\n");
@@ -567,224 +567,3 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
 #endif
 
 }
-
-extern "C" void StartKetsjiShellSimulation(struct wmWindow *win,
-                                                                struct ARegion *ar,
-                                                                char* scenename,
-                                                                struct Main* maggie,
-                                                                int always_use_expand_framing)
-{
-    int exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
-
-       Main* blenderdata = maggie;
-
-       RAS_Rect area_rect;
-       area_rect.SetLeft(ar->winrct.xmin);
-       area_rect.SetBottom(ar->winrct.ymin);
-       area_rect.SetRight(ar->winrct.xmax);
-       area_rect.SetTop(ar->winrct.ymax);
-
-       char* startscenename = scenename;
-       char pathname[FILE_MAXDIR+FILE_MAXFILE];
-       STR_String exitstring = "";
-
-       BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
-
-#ifndef DISABLE_PYTHON
-       // Acquire Python's GIL (global interpreter lock)
-       // so we can safely run Python code and API calls
-       PyGILState_STATE gilstate = PyGILState_Ensure();
-       PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */
-#endif
-
-       bgl::InitExtensions(true);
-
-       do
-       {
-
-               // get some preferences
-               SYS_SystemHandle syshandle = SYS_GetSystem();
-               /*
-               bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);
-               bool usefixed = (SYS_GetCommandLineInt(syshandle, "fixedtime", 0) != 0);
-               bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
-               bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
-               */
-               bool game2ipo = true;//(SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0);
-               bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
-               bool usemat = false;
-
-               // create the canvas, rasterizer and rendertools
-               RAS_ICanvas* canvas = new KX_BlenderCanvas(win, area_rect);
-               //canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
-               RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
-               RAS_IRasterizer* rasterizer = NULL;
-
-               if(displaylists) {
-                       if (GLEW_VERSION_1_1)
-                               rasterizer = new RAS_ListRasterizer(canvas, true, true);
-                       else
-                               rasterizer = new RAS_ListRasterizer(canvas);
-               }
-               else if (GLEW_VERSION_1_1)
-                       rasterizer = new RAS_VAOpenGLRasterizer(canvas, false);
-               else
-                       rasterizer = new RAS_OpenGLRasterizer(canvas);
-
-               // create the inputdevices
-               KX_BlenderKeyboardDevice* keyboarddevice = new KX_BlenderKeyboardDevice();
-               KX_BlenderMouseDevice* mousedevice = new KX_BlenderMouseDevice();
-
-               // create a networkdevice
-               NG_NetworkDeviceInterface* networkdevice = new
-                       NG_LoopBackNetworkDeviceInterface();
-
-               // create a ketsji/blendersystem (only needed for timing and stuff)
-               KX_BlenderSystem* kxsystem = new KX_BlenderSystem();
-
-               // create the ketsjiengine
-               KX_KetsjiEngine* ketsjiengine = new KX_KetsjiEngine(kxsystem);
-
-               Scene *blscene = NULL;
-
-               blscene = (Scene*) maggie->scene.first;
-               for (Scene *sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
-               {
-                       if (startscenename == (sce->id.name+2))
-                       {
-                               blscene = sce;
-                               break;
-                       }
-               }
-
-        int cframe = 1, startFrame;
-               if (blscene)
-               {
-                       cframe=blscene->r.cfra;
-                       startFrame = blscene->r.sfra;
-                       blscene->r.cfra=startFrame;
-                       // update_for_newframe(); // XXX scene_update_for_newframe wont cut it!
-                       ketsjiengine->SetGame2IpoMode(game2ipo,startFrame);
-               }
-
-               // Quad buffered needs a special window.
-               if(blscene->gm.stereoflag == STEREO_ENABLED){
-                       if (blscene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
-                               rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->gm.stereomode);
-               }
-               rasterizer->SetBackColor(blscene->gm.framing.col[0], blscene->gm.framing.col[1], blscene->gm.framing.col[2], 0.0f);
-
-               if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
-               {
-                       // create a scene converter, create and convert the startingscene
-                       KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(maggie, ketsjiengine);
-                       ketsjiengine->SetSceneConverter(sceneconverter);
-                       sceneconverter->addInitFromFrame=true;
-                       
-                       if (always_use_expand_framing)
-                               sceneconverter->SetAlwaysUseExpandFraming(true);
-
-                       if(usemat)
-                               sceneconverter->SetMaterials(true);
-
-                       KX_Scene* startscene = new KX_Scene(keyboarddevice,
-                               mousedevice,
-                               networkdevice,
-                               startscenename,
-                               blscene);
-
-#ifndef DISABLE_PYTHON
-                       // some python things
-                       PyObject *gameLogic, *gameLogic_keys;
-                       setupGamePython(ketsjiengine, startscene, blenderdata, pyGlobalDict, &gameLogic, &gameLogic_keys, 0, NULL);
-#endif // DISABLE_PYTHON
-
-                       if (sceneconverter)
-                       {
-                               // convert and add scene
-                               sceneconverter->ConvertScene(
-                                       startscene,
-                                       rendertools,
-                                       canvas);
-                               ketsjiengine->AddScene(startscene);
-
-                               // start the engine
-                               ketsjiengine->StartEngine(false);
-                               
-                               ketsjiengine->SetUseFixedTime(true);
-                               
-                               ketsjiengine->SetTicRate(
-                                       (double) blscene->r.frs_sec /
-                                       (double) blscene->r.frs_sec_base);
-
-                               // the mainloop
-                               while ((blscene->r.cfra<=blscene->r.efra)&&(!exitrequested))
-                               {
-                    printf("frame %i\n",blscene->r.cfra);
-                    // first check if we want to exit
-                                       exitrequested = ketsjiengine->GetExitCode();
-       
-                                       // kick the engine
-                                       ketsjiengine->NextFrame();
-                                   blscene->r.cfra=blscene->r.cfra+1;
-                                   // update_for_newframe(); // XXX scene_update_for_newframe wont cut it
-                                       
-                               }
-                               exitstring = ketsjiengine->GetExitString();
-                       }
-                       if (sceneconverter)
-                       {
-                               delete sceneconverter;
-                               sceneconverter = NULL;
-                       }
-               }
-               blscene->r.cfra=cframe;
-               // set the cursor back to normal
-               canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
-
-               // clean up some stuff
-               if (ketsjiengine)
-               {
-                       delete ketsjiengine;
-                       ketsjiengine = NULL;
-               }
-               if (kxsystem)
-               {
-                       delete kxsystem;
-                       kxsystem = NULL;
-               }
-               if (networkdevice)
-               {
-                       delete networkdevice;
-                       networkdevice = NULL;
-               }
-               if (keyboarddevice)
-               {
-                       delete keyboarddevice;
-                       keyboarddevice = NULL;
-               }
-               if (mousedevice)
-               {
-                       delete mousedevice;
-                       mousedevice = NULL;
-               }
-               if (rasterizer)
-               {
-                       delete rasterizer;
-                       rasterizer = NULL;
-               }
-               if (rendertools)
-               {
-                       delete rendertools;
-                       rendertools = NULL;
-                }
-
-       } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
-
-#ifndef DISABLE_PYTHON
-       Py_DECREF(pyGlobalDict);
-
-       // Release Python's GIL
-       PyGILState_Release(gilstate);
-#endif
-}
index 411ddc58c9295c9af9768efeb1674db8dddcfc53..3ee4248343cc20c1a55411f45a543fe1cd1acb16 100644 (file)
@@ -82,13 +82,16 @@ extern "C"
 #include "MEM_guardedalloc.h"
 //XXX #include "BSE_editipo.h"
 //XXX #include "BSE_editipo_types.h"
-#include "DNA_ipo_types.h"
+// #include "DNA_ipo_types.h"
 #include "BKE_global.h"
+#include "BKE_animsys.h"
 #include "BKE_library.h"
 #include "BKE_ipo.h" // eval_icu
 #include "BKE_material.h" // copy_material
 #include "BKE_mesh.h" // copy_mesh
 #include "DNA_space_types.h"
+#include "DNA_anim_types.h"
+#include "../../blender/editors/include/ED_keyframing.h"
 }
 
 /* Only for dynamic loading and merging */
@@ -621,57 +624,12 @@ void KX_BlenderSceneConverter::RegisterWorldInfo(
        m_worldinfos.push_back(pair<KX_Scene*,KX_WorldInfo*>(m_currentScene,worldinfo));
 }
 
-/*
- * When deleting an IPO curve from Python, check if the IPO is being
- * edited and if so clear the pointer to the old curve.
- */
-void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu )
-{
-#if 0 //XXX
-       if (!G.sipo)
-               return;
-
-       int i;
-       EditIpo *ei= (EditIpo *)G.sipo->editipo;
-       if (!ei) return;
-
-       for(i=0; i<G.sipo->totipo; i++, ei++) {
-                if ( ei->icu == icu ) {
-                       ei->flag &= ~(IPO_SELECT | IPO_EDIT);
-                       ei->icu= 0;
-                       return;
-               }
-       }
-#endif
-}
-
 //quick hack
 extern "C"
 {
-       Ipo *add_ipo( char *name, int idcode );
-       //XXX char *getIpoCurveName( IpoCurve * icu );
-       //XXX struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int);
-       //XXX void testhandles_ipocurve(struct IpoCurve *icu);
-       void insert_vert_icu(struct IpoCurve *, float, float, short);
-       float eval_icu(struct IpoCurve *icu, float ipotime);
-       //void mat3_to_eul( float *eul,float tmat[][3]);
        void mat3_to_compatible_eul( float *eul, float *oldrot,float mat[][3]);
 }
 
-IpoCurve* findIpoCurve(IpoCurve* first, const char* searchName)
-{
-       IpoCurve* icu1;
-       for( icu1 = first; icu1; icu1 = icu1->next ) 
-       {
-               /*XXX char* curveName = getIpoCurveName( icu1 );
-               if( !strcmp( curveName, searchName) )
-               {
-                       return icu1;
-               }*/
-       }
-       return 0;
-}
-
 void   KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
 {
 
@@ -695,6 +653,7 @@ void        KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
                                Object* blenderObject = gameObj->GetBlenderObject();
                                if (blenderObject)
                                {
+#if 0
                                        //erase existing ipo's
                                        Ipo* ipo = blenderObject->ipo;//findIpoForName(blenderObject->id.name+2);
                                        if (ipo)
@@ -728,11 +687,7 @@ void       KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
                                                blenderObject->ipo = ipo;
 
                                        }
-                               
-                                       
-
-                                       
-
+#endif
                                }
                        }
 
@@ -811,8 +766,28 @@ void       KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
                                //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
                                
                                Object* blenderObject = gameObj->GetBlenderObject();
-                               if (blenderObject && blenderObject->ipo)
+
+                               if(blenderObject->adt==NULL)
+                                       BKE_id_add_animdata(&blenderObject->id);
+
+                               if (blenderObject && blenderObject->adt)
                                {
+                                       const MT_Point3& position = gameObj->NodeGetWorldPosition();
+                                       //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
+                                       const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
+
+                                       position.getValue(blenderObject->loc);
+
+                                       float tmat[3][3];
+                                       for (int r=0;r<3;r++)
+                                               for (int c=0;c<3;c++)
+                                                       tmat[r][c] = orn[c][r];
+
+                                       mat3_to_compatible_eul(blenderObject->rot, blenderObject->rot, tmat);
+
+                                       insert_keyframe(&blenderObject->id, NULL, NULL, "location", -1, frameNumber, INSERTKEY_FAST);
+                                       insert_keyframe(&blenderObject->id, NULL, NULL, "rotation_euler", -1, frameNumber, INSERTKEY_FAST);
+
 #if 0
                                        const MT_Point3& position = gameObj->NodeGetWorldPosition();
                                        //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
index e880c8b824c6abfe06b6e4c396bcde9b1d0ce257..3dd3afb56629c9f657f37c25f5a5d777ff6e3f7f 100644 (file)
@@ -43,7 +43,6 @@ class RAS_MeshObject;
 class RAS_IPolyMaterial;
 class BL_InterpolatorList;
 class BL_Material;
-struct IpoCurve;
 struct Main;
 struct Scene;
 
@@ -74,9 +73,6 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter
        bool                                    m_usemat;
        bool                                    m_useglslmat;
 
-       void localDel_ipoCurve ( IpoCurve * icu );
-//     struct Ipo* findIpoForName(char* objName);
-
 public:
        KX_BlenderSceneConverter(
                Main* maggie,
index d39b6fbda179043dc88473d58982d03e8b5e18c5..43b26cf9a06f2a2fd90404cfa9db27fa10ec9e65 100644 (file)
@@ -710,8 +710,8 @@ bool GPG_Application::startEngine(void)
                // Set the animation playback rate for ipo's and actions
                // the framerate below should patch with FPS macro defined in blendef.h
                // Could be in StartEngine set the framerate, we need the scene to do this
-// XXX         m_ketsjiengine->SetAnimFrameRate( (((double) scene->r.frs_sec) / scene->r.frs_sec_base) );
-               
+               Scene *scene= startscene->GetBlenderScene(); // needed for macro
+               m_ketsjiengine->SetAnimFrameRate(FPS);
        }
        
        if (!m_engineRunning)
index af30d32a0aa546cc687abf30a3e092dee20bcbbd..18ae80c78c3fda36e65b5ead38166942f52498db 100644 (file)
@@ -154,7 +154,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
        m_showBackground(false),
        m_show_debug_properties(false),
 
-       m_game2ipo(false),
+       m_animation_record(false),
 
        // Default behavior is to hide the cursor every frame.
        m_hideCursor(false),
@@ -398,7 +398,7 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo)
                m_maxPhysicsFrame = 5;
        }
        
-       if (m_game2ipo)
+       if (m_animation_record)
        {
                m_sceneconverter->ResetPhysicsObjectsAnimationIpo(clearIpo);
                m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame);
@@ -657,7 +657,7 @@ else
                                scene->UpdateParents(m_frameTime);
                        
                        
-                               if (m_game2ipo)
+                               if (m_animation_record)
                                {                                       
                                        m_sceneconverter->WritePhysicsObjectToAnimationIpo(++m_currentFrame);
                                }
@@ -1334,7 +1334,7 @@ void KX_KetsjiEngine::StopEngine()
        if (m_bInitialized)
        {
 
-               if (m_game2ipo)
+               if (m_animation_record)
                {
 //                     printf("TestHandlesPhysicsObjectToAnimationIpo\n");
                        m_sceneconverter->TestHandlesPhysicsObjectToAnimationIpo();
@@ -1734,10 +1734,10 @@ void KX_KetsjiEngine::SetUseFixedTime(bool bUseFixedTime)
 }
 
 
-void   KX_KetsjiEngine::SetGame2IpoMode(bool game2ipo,int startFrame)
+void   KX_KetsjiEngine::SetAnimRecordMode(bool animation_record, int startFrame)
 {
-       m_game2ipo = game2ipo;
-       if (game2ipo)
+       m_animation_record = animation_record;
+       if (animation_record)
        {
                //when recording physics keyframes, always run at a fixed framerate
                m_bFixedTime = true;
index 96ca092c8c13beb005563c726359f9c8752d2a17..a6ca5fb6519308f5157267dcc9667bfc04c1e942 100644 (file)
@@ -170,7 +170,7 @@ private:
        bool                                    m_show_debug_properties;
 
        /** record physics into keyframes */
-       bool                                    m_game2ipo;
+       bool                                    m_animation_record;
 
        /** Hide cursor every frame? */
        bool                                    m_hideCursor;
@@ -208,7 +208,7 @@ public:
        PyObject*               GetPyNamespace(){return m_pythondictionary;};
 #endif
        void                    SetSceneConverter(KX_ISceneConverter* sceneconverter);
-       void                    SetGame2IpoMode(bool game2ipo,int startFrame);
+       void                    SetAnimRecordMode(bool animation_record, int startFrame);
 
        RAS_IRasterizer*                GetRasterizer(){return m_rasterizer;};
        RAS_ICanvas*                GetCanvas(){return m_canvas;};