Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp155
-rw-r--r--source/gameengine/BlenderRoutines/CMakeLists.txt7
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp27
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.h10
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.cpp52
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.h7
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h27
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp4
-rw-r--r--source/gameengine/BlenderRoutines/Makefile10
-rw-r--r--source/gameengine/BlenderRoutines/SConscript19
-rw-r--r--source/gameengine/CMakeLists.txt1
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp95
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h9
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp11
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h5
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp64
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.cpp3
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.h5
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.cpp46
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.h9
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.cpp10
-rw-r--r--source/gameengine/Converter/CMakeLists.txt3
-rw-r--r--source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp52
-rw-r--r--source/gameengine/Converter/KX_BlenderScalarInterpolator.h15
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp72
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h6
-rw-r--r--source/gameengine/Converter/KX_ConvertProperties.cpp96
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp16
-rw-r--r--source/gameengine/Converter/KX_IpoConvert.cpp580
-rw-r--r--source/gameengine/Converter/Makefile7
-rw-r--r--source/gameengine/Converter/SConscript13
-rw-r--r--source/gameengine/Expressions/BoolValue.cpp3
-rw-r--r--source/gameengine/Expressions/CMakeLists.txt1
-rw-r--r--source/gameengine/Expressions/IntValue.cpp2
-rw-r--r--source/gameengine/Expressions/KX_Python.h2
-rw-r--r--source/gameengine/Expressions/ListValue.cpp61
-rw-r--r--source/gameengine/Expressions/ListValue.h4
-rw-r--r--source/gameengine/Expressions/Makefile1
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp338
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h99
-rw-r--r--source/gameengine/Expressions/SConscript7
-rw-r--r--source/gameengine/Expressions/StringValue.h2
-rw-r--r--source/gameengine/Expressions/Value.cpp124
-rw-r--r--source/gameengine/Expressions/Value.h16
-rw-r--r--source/gameengine/GameLogic/CMakeLists.txt7
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp42
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.h13
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.cpp31
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.h10
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp37
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.h7
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.cpp31
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.h12
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp40
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.h7
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.h11
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.h3
-rw-r--r--source/gameengine/GameLogic/SCA_IController.cpp47
-rw-r--r--source/gameengine/GameLogic/SCA_IController.h6
-rw-r--r--source/gameengine/GameLogic/SCA_IInputDevice.h1
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.cpp44
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.h6
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.cpp81
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.h7
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp46
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h7
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp73
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h7
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp61
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h7
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.cpp1
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp47
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.h7
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.cpp31
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.h6
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.cpp31
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.h10
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.cpp32
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.h9
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp38
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h8
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp42
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.h7
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp63
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.h6
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp48
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.h7
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp46
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.h7
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.cpp31
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.h5
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.cpp31
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.h10
-rw-r--r--source/gameengine/GameLogic/SConscript11
-rw-r--r--source/gameengine/GamePlayer/common/CMakeLists.txt1
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Engine.cpp21
-rw-r--r--source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp412
-rw-r--r--source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h89
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.cpp8
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.h4
-rw-r--r--source/gameengine/GamePlayer/common/Makefile4
-rw-r--r--source/gameengine/GamePlayer/common/SConscript9
-rw-r--r--source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp3
-rw-r--r--source/gameengine/GamePlayer/common/unix/Makefile3
-rw-r--r--source/gameengine/GamePlayer/common/windows/Makefile1
-rw-r--r--source/gameengine/GamePlayer/ghost/CMakeLists.txt2
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp10
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp29
-rw-r--r--source/gameengine/GamePlayer/ghost/Makefile2
-rw-r--r--source/gameengine/GamePlayer/ghost/SConscript11
-rw-r--r--source/gameengine/Ketsji/BL_Shader.cpp43
-rw-r--r--source/gameengine/Ketsji/BL_Shader.h6
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt23
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp37
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h7
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp43
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h7
-rw-r--r--source/gameengine/Ketsji/KXNetwork/SConscript5
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.cpp43
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.h9
-rw-r--r--source/gameengine/Ketsji/KX_CDActuator.cpp47
-rw-r--r--source/gameengine/Ketsji/KX_CDActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp65
-rw-r--r--source/gameengine/Ketsji/KX_Camera.h7
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.cpp47
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.h8
-rw-r--r--source/gameengine/Ketsji/KX_ClientObjectInfo.h12
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp59
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.cpp42
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.h5
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObject.h30
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp592
-rw-r--r--source/gameengine/Ketsji/KX_Dome.h2
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.cpp45
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp445
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h42
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.cpp37
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp56
-rw-r--r--source/gameengine/Ketsji/KX_Light.h6
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp55
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.h3
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp33
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.h5
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp46
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.h9
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp159
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.h18
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.cpp257
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.h109
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.cpp37
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp49
-rw-r--r--source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h6
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp61
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.h2
-rw-r--r--source/gameengine/Ketsji/KX_PolygonMaterial.cpp44
-rw-r--r--source/gameengine/Ketsji/KX_PolygonMaterial.h7
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.cpp92
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.h55
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp75
-rw-r--r--source/gameengine/Ketsji/KX_PythonInitTypes.cpp213
-rw-r--r--source/gameengine/Ketsji/KX_PythonSeq.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp40
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.h7
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp39
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.h8
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp50
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp48
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.h8
-rw-r--r--source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp35
-rw-r--r--source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h6
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp45
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h9
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp92
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h10
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.cpp50
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp53
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_StateActuator.cpp41
-rw-r--r--source/gameengine/Ketsji/KX_StateActuator.h9
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.cpp244
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.h122
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp44
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.h7
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp51
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.h5
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.cpp44
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.h5
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.cpp96
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.h3
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.cpp43
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.h8
-rw-r--r--source/gameengine/Ketsji/Makefile7
-rw-r--r--source/gameengine/Ketsji/SConscript48
-rw-r--r--source/gameengine/Network/LoopBackNetwork/SConscript2
-rw-r--r--source/gameengine/Network/SConscript2
-rw-r--r--source/gameengine/Physics/BlOde/Makefile48
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.cpp625
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.h164
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp277
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h94
-rw-r--r--source/gameengine/Physics/BlOde/SConscript15
-rw-r--r--source/gameengine/Physics/Bullet/SConscript5
-rw-r--r--source/gameengine/Physics/Dummy/Makefile2
-rw-r--r--source/gameengine/Physics/Dummy/SConscript2
-rw-r--r--source/gameengine/Physics/Makefile3
-rw-r--r--source/gameengine/Physics/Sumo/CMakeLists.txt46
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/Makefile34
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h11
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_ClientObjectInfo.h16
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h26
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h56
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h77
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h393
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h58
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h172
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/sample/Makefile25
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/sample/particle.cpp709
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/sample/particle0.cpp695
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/Makefile14
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp180
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp100
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp1298
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp378
-rw-r--r--source/gameengine/Physics/Sumo/Makefile50
-rw-r--r--source/gameengine/Physics/Sumo/SConscript25
-rw-r--r--source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.cpp66
-rw-r--r--source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.h28
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.cpp568
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.h218
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp265
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h110
-rw-r--r--source/gameengine/Physics/Sumo/convert.txt35
-rw-r--r--source/gameengine/Physics/Sumo/include/interpolator.h27
-rw-r--r--source/gameengine/Physics/common/Makefile2
-rw-r--r--source/gameengine/Physics/common/SConscript5
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp6
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript5
-rw-r--r--source/gameengine/Rasterizer/SConscript5
-rw-r--r--source/gameengine/SConscript10
-rw-r--r--source/gameengine/SceneGraph/SConscript7
-rw-r--r--source/gameengine/VideoTexture/CMakeLists.txt1
-rw-r--r--source/gameengine/VideoTexture/FilterBlueScreen.cpp20
-rw-r--r--source/gameengine/VideoTexture/FilterColor.cpp8
-rw-r--r--source/gameengine/VideoTexture/FilterNormal.cpp4
-rw-r--r--source/gameengine/VideoTexture/ImageRender.cpp18
-rw-r--r--source/gameengine/VideoTexture/ImageViewport.cpp18
-rw-r--r--source/gameengine/VideoTexture/Makefile2
-rw-r--r--source/gameengine/VideoTexture/SConscript15
-rw-r--r--source/gameengine/VideoTexture/Texture.cpp3
-rw-r--r--source/gameengine/VideoTexture/VideoBase.cpp4
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.cpp4
-rw-r--r--source/gameengine/VideoTexture/blendVideoTex.cpp2
262 files changed, 2448 insertions, 12965 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index ec751376d4a..6e6531c9b5f 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -65,52 +65,71 @@
#include "SYS_System.h"
- /***/
+#include "GPU_extensions.h"
+#include "Value.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ /***/
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
#include "BKE_global.h"
+#include "BKE_report.h"
+
#include "BKE_utildefines.h"
-#include "BIF_screen.h"
-#include "BIF_scrarea.h"
+//XXX #include "BIF_screen.h"
+//XXX #include "BIF_scrarea.h"
-#include "BKE_main.h"
+#include "BKE_main.h"
#include "BLI_blenlib.h"
#include "BLO_readfile.h"
#include "DNA_scene_types.h"
/***/
-#include "GPU_extensions.h"
-#include "Value.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-#include "BSE_headerbuttons.h"
-void update_for_newframe();
+//XXX #include "BSE_headerbuttons.h"
+#include "BKE_context.h"
+#include "../../blender/windowmanager/WM_types.h"
+#include "../../blender/windowmanager/wm_window.h"
+#include "../../blender/windowmanager/wm_event_system.h"
#ifdef __cplusplus
}
#endif
-static BlendFileData *load_game_data(char *filename) {
- BlendReadError error;
- BlendFileData *bfd= BLO_read_from_file(filename, &error);
+
+static BlendFileData *load_game_data(char *filename)
+{
+ ReportList reports;
+ BlendFileData *bfd;
+
+ BKE_reports_init(&reports, RPT_STORE);
+ bfd= BLO_read_from_file(filename, &reports);
+
if (!bfd) {
- printf("Loading %s failed: %s\n", filename, BLO_bre_as_string(error));
+ printf("Loading %s failed: ", filename);
+ BKE_reports_print(&reports, RPT_ERROR);
}
+
+ BKE_reports_clear(&reports);
+
return bfd;
}
-extern "C" void StartKetsjiShell(struct ScrArea *area,
- char* scenename,
- struct Main* maggie1,
- int always_use_expand_framing)
+extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int always_use_expand_framing)
{
- int exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
+ /* context values */
+ struct wmWindow *win= CTX_wm_window(C);
+ struct Scene *scene= CTX_data_scene(C);
+ struct Main* maggie1= CTX_data_main(C);
+
+ int exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
Main* blenderdata = maggie1;
- char* startscenename = scenename;
+ char* startscenename = scene->id.name+2;
char pathname[FILE_MAXDIR+FILE_MAXFILE], oldsce[FILE_MAXDIR+FILE_MAXFILE];
STR_String exitstring = "";
BlendFileData *bfd= NULL;
@@ -130,7 +149,8 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
do
{
- View3D *v3d= (View3D*) area->spacedata.first;
+ View3D *v3d= CTX_wm_view3d(C);
+ RegionView3D *rv3d= CTX_wm_region_view3d(C);
// get some preferences
SYS_SystemHandle syshandle = SYS_GetSystem();
@@ -143,7 +163,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0);
// create the canvas, rasterizer and rendertools
- RAS_ICanvas* canvas = new KX_BlenderCanvas(area);
+ RAS_ICanvas* canvas = new KX_BlenderCanvas(win, ar);
canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
RAS_IRasterizer* rasterizer = NULL;
@@ -201,34 +221,33 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
//lock frame and camera enabled - storing global values
- int tmp_lay= G.scene->lay;
- Object *tmp_camera = G.scene->camera;
+ int tmp_lay= scene->lay;
+ Object *tmp_camera = scene->camera;
- if (G.vd->scenelock==0){
- G.scene->lay= v3d->lay;
- G.scene->camera= v3d->camera;
+ if (v3d->scenelock==0){
+ scene->lay= v3d->lay;
+ scene->camera= v3d->camera;
}
-
// some blender stuff
MT_CmMatrix4x4 projmat;
MT_CmMatrix4x4 viewmat;
float camzoom;
int i;
-
+
for (i = 0; i < 16; i++)
{
- float *viewmat_linear= (float*) v3d->viewmat;
+ float *viewmat_linear= (float*) rv3d->viewmat;
viewmat.setElem(i, viewmat_linear[i]);
}
for (i = 0; i < 16; i++)
{
- float *projmat_linear = (float*) area->winmat;
+ float *projmat_linear= (float*) rv3d->winmat;
projmat.setElem(i, projmat_linear[i]);
}
- if(v3d->persp==V3D_CAMOB) {
- camzoom = (1.41421 + (v3d->camzoom / 50.0));
+ if(rv3d->persp==V3D_CAMOB) {
+ camzoom = (1.41421 + (rv3d->camzoom / 50.0));
camzoom *= camzoom;
}
else
@@ -312,16 +331,18 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
ketsjiengine->SetGame2IpoMode(game2ipo,startFrame);
// Quad buffered needs a special window.
- if (blscene->r.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
- rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->r.stereomode);
+ if(blscene->gm.stereoflag == STEREO_ENABLED){
+ if (blscene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
+ rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->gm.stereomode);
+ }
}
if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
{
- if (v3d->persp != V3D_CAMOB)
+ if (rv3d->persp != V3D_CAMOB)
{
ketsjiengine->EnableCameraOverride(startscenename);
- ketsjiengine->SetCameraOverrideUseOrtho((v3d->persp == V3D_ORTHO));
+ ketsjiengine->SetCameraOverrideUseOrtho((rv3d->persp == V3D_ORTHO));
ketsjiengine->SetCameraOverrideProjectionMatrix(projmat);
ketsjiengine->SetCameraOverrideViewMatrix(viewmat);
ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far);
@@ -376,8 +397,8 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
#endif
//initialize Dome Settings
- if(blscene->r.stereomode == RAS_IRasterizer::RAS_STEREO_DOME)
- ketsjiengine->InitDome(blscene->r.domeres, blscene->r.domemode, blscene->r.domeangle, blscene->r.domeresbuf, blscene->r.dometilt, blscene->r.dometext);
+ if(blscene->gm.stereoflag == STEREO_DOME)
+ ketsjiengine->InitDome(blscene->gm.dome.res, blscene->gm.dome.mode, blscene->gm.dome.angle, blscene->gm.dome.resbuf, blscene->gm.dome.tilt, blscene->gm.dome.warptext);
if (sceneconverter)
{
@@ -411,7 +432,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
exitrequested = ketsjiengine->GetExitCode();
// kick the engine
- bool render = ketsjiengine->NextFrame();
+ bool render = ketsjiengine->NextFrame(); // XXX 2.5 Bug, This is never true! FIXME- Campbell
if (render)
{
@@ -419,26 +440,37 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
ketsjiengine->Render();
}
+ wm_window_process_events_nosleep(C);
+
// test for the ESC key
- while (qtest())
+ //XXX while (qtest())
+ while(wmEvent *event= (wmEvent *)win->queue.first)
{
- short val;
- unsigned short event = extern_qread(&val);
+ short val = 0;
+ //unsigned short event = 0; //XXX extern_qread(&val);
- if (keyboarddevice->ConvertBlenderEvent(event,val))
+ if (keyboarddevice->ConvertBlenderEvent(event->type,event->val))
exitrequested = KX_EXIT_REQUEST_BLENDER_ESC;
/* Coordinate conversion... where
* should this really be?
*/
- if (event==MOUSEX) {
- val = val - scrarea_get_win_x(area);
- } else if (event==MOUSEY) {
- val = scrarea_get_win_height(area) - (val - scrarea_get_win_y(area)) - 1;
+ if (event->type==MOUSEMOVE) {
+ /* Note nice! XXX 2.5 event hack */
+ val = event->x - ar->winrct.xmin;
+ mousedevice->ConvertBlenderEvent(MOUSEX, val);
+
+ val = ar->winy - (event->y - ar->winrct.ymin) - 1;
+ mousedevice->ConvertBlenderEvent(MOUSEY, val);
+ }
+ else {
+ mousedevice->ConvertBlenderEvent(event->type,event->val);
}
- mousedevice->ConvertBlenderEvent(event,val);
+ BLI_remlink(&win->queue, event);
+ wm_event_free(event);
}
+
}
printf("\nBlender Game Engine Finished\n\n");
exitstring = ketsjiengine->GetExitString();
@@ -480,9 +512,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
gameLogic_keys = NULL;
}
//lock frame and camera enabled - restoring global values
- if (G.vd->scenelock==0){
- G.scene->lay= tmp_lay;
- G.scene->camera= tmp_camera;
+ if (v3d->scenelock==0){
+ scene->lay= tmp_lay;
+ scene->camera= tmp_camera;
}
// set the cursor back to normal
@@ -545,7 +577,8 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
PyGILState_Release(gilstate);
}
-extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
+extern "C" void StartKetsjiShellSimulation(struct wmWindow *win,
+ struct ARegion *ar,
char* scenename,
struct Main* maggie,
int always_use_expand_framing)
@@ -582,7 +615,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
bool usemat = false;
// create the canvas, rasterizer and rendertools
- RAS_ICanvas* canvas = new KX_BlenderCanvas(area);
+ RAS_ICanvas* canvas = new KX_BlenderCanvas(win, ar);
//canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
RAS_IRasterizer* rasterizer = NULL;
@@ -635,13 +668,15 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
cframe=blscene->r.cfra;
startFrame = blscene->r.sfra;
blscene->r.cfra=startFrame;
- update_for_newframe();
+ // update_for_newframe(); // XXX scene_update_for_newframe wont cut it!
ketsjiengine->SetGame2IpoMode(game2ipo,startFrame);
}
// Quad buffered needs a special window.
- if (blscene->r.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
- rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->r.stereomode);
+ if(blscene->gm.stereoflag == STEREO_ENABLED){
+ if (blscene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
+ rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->gm.stereomode);
+ }
if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
{
@@ -709,7 +744,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
// kick the engine
ketsjiengine->NextFrame();
blscene->r.cfra=blscene->r.cfra+1;
- update_for_newframe();
+ // update_for_newframe(); // XXX scene_update_for_newframe wont cut it
}
exitstring = ketsjiengine->GetExitString();
diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt
index d65e6a012df..2874a0273cc 100644
--- a/source/gameengine/BlenderRoutines/CMakeLists.txt
+++ b/source/gameengine/BlenderRoutines/CMakeLists.txt
@@ -7,7 +7,6 @@ SET(INC
../../../intern/string
../../../intern/guardedalloc
../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
- ../../../intern/bmfont
../../../source/gameengine/Converter
../../../source/blender/imbuf
../../../intern/ghost/include
@@ -15,9 +14,13 @@ SET(INC
../../../source/gameengine/Ketsji
../../../source/blender/blenlib
../../../source/blender/blenkernel
+ ../../../source/blender/blenfont
+ ../../../source/blender/editors/include
+ ../../../source/blender/windowmanager
../../../source/blender
../../../source/blender/include
- ../../../source/blender/makesdna
+ ../../../source/blender/makesdna
+ ../../../source/blender/makesrna
../../../source/gameengine/Rasterizer
../../../source/gameengine/GameLogic
../../../source/gameengine/Expressions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index 1604dfe5cce..360794ceb33 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
@@ -26,15 +26,18 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#include "BIF_scrarea.h"
#include "KX_BlenderCanvas.h"
+#include "DNA_screen_types.h"
+#include "stdio.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-KX_BlenderCanvas::KX_BlenderCanvas(struct ScrArea *area) :
-m_area(area)
+
+KX_BlenderCanvas::KX_BlenderCanvas(struct wmWindow *win, ARegion *ar) :
+m_win(win),
+m_ar(ar)
{
}
@@ -50,7 +53,7 @@ void KX_BlenderCanvas::Init()
void KX_BlenderCanvas::SwapBuffers()
{
- BL_SwapBuffers();
+ BL_SwapBuffers(m_win);
}
void KX_BlenderCanvas::BeginFrame()
@@ -93,12 +96,12 @@ void KX_BlenderCanvas::ClearBuffer(int type)
int KX_BlenderCanvas::GetWidth(
) const {
- return scrarea_get_win_width(m_area);
+ return m_ar->winx;
}
int KX_BlenderCanvas::GetHeight(
) const {
- return scrarea_get_win_height(m_area);
+ return m_ar->winy;
}
RAS_Rect &
@@ -116,8 +119,8 @@ SetViewPort(
){
int vp_width = (x2 - x1) + 1;
int vp_height = (y2 - y1) + 1;
- int minx = scrarea_get_win_x(m_area);
- int miny = scrarea_get_win_y(m_area);
+ int minx = m_ar->winrct.xmin;
+ int miny = m_ar->winrct.ymin;
m_area_rect.SetLeft(minx + x1);
m_area_rect.SetBottom(miny + y1);
@@ -159,9 +162,9 @@ void KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate)
// (0,0) is top left, (width,height) is bottom right
void KX_BlenderCanvas::SetMousePosition(int x,int y)
{
- int winX = scrarea_get_win_x(m_area);
- int winY = scrarea_get_win_y(m_area);
- int winH = scrarea_get_win_height(m_area);
+ int winX = m_ar->winrct.xmin;
+ int winY = m_ar->winrct.ymin;
+ int winH = m_ar->winy;
BL_warp_pointer(winX + x, winY + (winH-y-1));
}
@@ -170,5 +173,5 @@ void KX_BlenderCanvas::SetMousePosition(int x,int y)
void KX_BlenderCanvas::MakeScreenShot(const char* filename)
{
- BL_MakeScreenShot(m_area, filename);
+ BL_MakeScreenShot(m_ar, filename);
}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
index bc202a8558c..fd41fb90f2f 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
@@ -40,7 +40,8 @@
#include "KX_BlenderGL.h"
-struct ScrArea;
+struct ARegion;
+struct wmWindow;
/**
* 2D Blender device context abstraction.
@@ -57,9 +58,9 @@ private:
public:
/* Construct a new canvas.
*
- * @param area The Blender ScrArea to run the game within.
+ * @param area The Blender ARegion to run the game within.
*/
- KX_BlenderCanvas(struct ScrArea* area);
+ KX_BlenderCanvas(struct wmWindow* win, struct ARegion* ar);
~KX_BlenderCanvas();
void
@@ -162,7 +163,8 @@ public:
private:
/** Blender area the game engine is running within */
- struct ScrArea* m_area;
+ struct ARegion* m_ar;
+ struct wmWindow* m_win;
RAS_Rect m_area_rect;
};
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
index 54d1eb7e011..5cf696fe146 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
@@ -28,6 +28,14 @@
#include "KX_BlenderGL.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "BLF_api.h"
+#ifdef __cplusplus
+}
+#endif
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -42,9 +50,7 @@
#include <stdlib.h>
#include <string.h>
-#include "BMF_Api.h"
-
-#include "BIF_gl.h"
+#include "GL/glew.h"
#include "BL_Material.h" // MAXTEX
@@ -59,17 +65,18 @@
#include "DNA_image_types.h"
#include "DNA_view3d_types.h"
#include "DNA_material_types.h"
+#include "DNA_windowmanager_types.h"
#include "BKE_global.h"
#include "BKE_bmfont.h"
#include "BKE_image.h"
extern "C" {
-#include "BDR_drawmesh.h"
-#include "BIF_mywindow.h"
-#include "BIF_toolbox.h"
-#include "BIF_graphics.h" /* For CURSOR_NONE CURSOR_WAIT CURSOR_STD */
-
+//XXX #include "BDR_drawmesh.h"
+//XXX #include "BIF_mywindow.h"
+//XXX #include "BIF_toolbox.h"
+//XXX #include "BIF_graphics.h" /* For CURSOR_NONE CURSOR_WAIT CURSOR_STD */
+void wm_window_swap_buffers(wmWindow *win); // wm_window.h
}
/* end of blender block */
@@ -84,12 +91,14 @@ void spack(unsigned int ucol)
void BL_warp_pointer(int x,int y)
{
- warp_pointer(x,y);
+ //XXX warp_pointer(x,y);
}
-void BL_SwapBuffers()
+void BL_SwapBuffers(wmWindow *win)
{
- myswapbuffers();
+ //wmWindow *window= CTX_wm_window(C);
+ wm_window_swap_buffers(win);
+ //XXX myswapbuffers();
}
void DisableForText()
@@ -148,8 +157,7 @@ void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height
/* the actual drawing */
glColor3ub(255, 255, 255);
- glRasterPos2s(xco, height-yco);
- BMF_DrawString(G.fonts, text);
+ BLF_draw_default(xco, height-yco, 0.0f, text);
glMatrixMode(GL_TEXTURE);
glPopMatrix();
@@ -184,11 +192,9 @@ void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int
/* draw in black first*/
glColor3ub(0, 0, 0);
- glRasterPos2s(xco+1, height-yco-1);
- BMF_DrawString(G.fonts, text);
+ BLF_draw_default(xco+1, height-yco-1, 0.0f, text);
glColor3ub(255, 255, 255);
- glRasterPos2s(xco, height-yco);
- BMF_DrawString(G.fonts, text);
+ BLF_draw_default(xco, height-yco, 0.0f, text);
glMatrixMode(GL_TEXTURE);
glPopMatrix();
@@ -201,24 +207,24 @@ void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int
void BL_HideMouse()
{
- set_cursor(CURSOR_NONE);
+ //XXX set_cursor(CURSOR_NONE);
}
void BL_WaitMouse()
{
- set_cursor(CURSOR_WAIT);
+ //XXX set_cursor(CURSOR_WAIT);
}
void BL_NormalMouse()
{
- set_cursor(CURSOR_STD);
+ //XXX set_cursor(CURSOR_STD);
}
#define MAX_FILE_LENGTH 512
-void BL_MakeScreenShot(struct ScrArea *area, const char* filename)
+void BL_MakeScreenShot(struct ARegion *ar, const char* filename)
{
char copyfilename[MAX_FILE_LENGTH];
strcpy(copyfilename,filename);
@@ -226,9 +232,9 @@ void BL_MakeScreenShot(struct ScrArea *area, const char* filename)
// filename read - only
/* XXX will need to change at some point */
- BIF_screendump(0);
+ //XXX BIF_screendump(0);
// write+read filename
- write_screendump((char*) copyfilename);
+ //XXX write_screendump((char*) copyfilename);
}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
index b891a7343c2..1e65f29d87c 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
@@ -33,14 +33,15 @@
extern "C" {
#endif //__cplusplus
-struct ScrArea;
+struct wmWindow;
+struct ARegion;
// special swapbuffers, that takes care of which area (viewport) needs to be swapped
-void BL_SwapBuffers();
+void BL_SwapBuffers(struct wmWindow *win);
void BL_warp_pointer(int x,int y);
-void BL_MakeScreenShot(struct ScrArea *area, const char* filename);
+void BL_MakeScreenShot(struct ARegion *ar, const char* filename);
void BL_HideMouse();
void BL_NormalMouse();
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
index 8e5d508f8cb..32391e63264 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
@@ -35,14 +35,12 @@
#include <map>
-/* need to be here for conversion purposes */
-#ifdef FREE_WINDOWS
-#undef HKEY
-#endif
-
-#include "mydevice.h"
+#include "wm_event_types.h"
+#include "WM_types.h"
#include "SCA_IInputDevice.h"
+
+
/**
Base Class for Blender specific inputdevices. Blender specific inputdevices are used when the gameengine is running in embedded mode instead of standalone mode.
*/
@@ -69,10 +67,10 @@ public:
m_reverseKeyTranslateTable[TIMER0 ] = KX_TIMER0 ;
m_reverseKeyTranslateTable[TIMER1 ] = KX_TIMER1 ;
m_reverseKeyTranslateTable[TIMER2 ] = KX_TIMER2 ;
- m_reverseKeyTranslateTable[TIMER3 ] = KX_TIMER3 ;
-
- // SYSTEM
+ // SYSTEM
+#if 0
+ /* **** XXX **** */
m_reverseKeyTranslateTable[KEYBD ] = KX_KEYBD ;
m_reverseKeyTranslateTable[RAWKEYBD ] = KX_RAWKEYBD ;
m_reverseKeyTranslateTable[REDRAW ] = KX_REDRAW ;
@@ -83,7 +81,8 @@ public:
m_reverseKeyTranslateTable[WINCLOSE ] = KX_WINCLOSE ;
m_reverseKeyTranslateTable[WINQUIT ] = KX_WINQUIT ;
m_reverseKeyTranslateTable[Q_FIRSTTIME ] = KX_Q_FIRSTTIME ;
-
+ /* **** XXX **** */
+#endif
// standard keyboard
m_reverseKeyTranslateTable[AKEY ] = KX_AKEY ;
@@ -93,7 +92,15 @@ public:
m_reverseKeyTranslateTable[EKEY ] = KX_EKEY ;
m_reverseKeyTranslateTable[FKEY ] = KX_FKEY ;
m_reverseKeyTranslateTable[GKEY ] = KX_GKEY ;
+//XXX clean up
+#ifdef WIN32
+#define HKEY 'h'
+#endif
m_reverseKeyTranslateTable[HKEY ] = KX_HKEY ;
+//XXX clean up
+#ifdef WIN32
+#undef HKEY
+#endif
m_reverseKeyTranslateTable[IKEY ] = KX_IKEY ;
m_reverseKeyTranslateTable[JKEY ] = KX_JKEY ;
m_reverseKeyTranslateTable[KKEY ] = KX_KKEY ;
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
index 877a0d39acf..58af94854e6 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
@@ -104,7 +104,7 @@ bool KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode,short v
{
int previousTable = 1-m_currentTable;
- if (val > 0)
+ if (val == KM_PRESS)
{
if (kxevent == KX_ESCKEY && val != 0 && !m_hookesc)
result = true;
@@ -138,7 +138,7 @@ bool KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode,short v
}
}
- } else
+ } else if (val == KM_RELEASE)
{
// blender eventval == 0
switch (m_eventStatusTables[previousTable][kxevent].m_status)
diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile
index e77d8e8380e..ffa99a0c1b2 100644
--- a/source/gameengine/BlenderRoutines/Makefile
+++ b/source/gameengine/BlenderRoutines/Makefile
@@ -36,26 +36,25 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_GLEW)/include
-CPPFLAGS += -I$(NAN_SUMO)/include -I$(NAN_SOLID)/include
-CPPFLAGS += -I$(NAN_SOLID)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_BMFONT)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
# because of kernel dependency on makesdna
CPPFLAGS += -I../../blender/makesdna
-CPPFLAGS += -I../../blender/include
+CPPFLAGS += -I../../blender/editors/include
# because of kernel dependency on imbuf
+CPPFLAGS += -I../../blender/windowmanager
CPPFLAGS += -I../../blender/imbuf
CPPFLAGS += -I../../blender/blenlib
CPPFLAGS += -I../../blender/blenkernel
CPPFLAGS += -I../../blender/render/extern/include
CPPFLAGS += -I../../blender/blenloader
-CPPFLAGS += -I../../blender/blenkernel
+CPPFLAGS += -I../../blender/blenfont
CPPFLAGS += -I../../blender/gpu
+CPPFLAGS += -I../../blender/makesrna
CPPFLAGS += -I../Converter
CPPFLAGS += -I../Expressions
CPPFLAGS += -I../GameLogic
@@ -67,7 +66,6 @@ CPPFLAGS += -I../../kernel/gen_system
CPPFLAGS += -I../Network
CPPFLAGS += -I../Network/LoopBackNetwork
CPPFLAGS += -I../Physics/common
-CPPFLAGS += -I../Physics/Sumo
CPPFLAGS += -I.
ifeq ($(OS),windows)
diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript
index 4a9c0e1286b..0239af22b8c 100644
--- a/source/gameengine/BlenderRoutines/SConscript
+++ b/source/gameengine/BlenderRoutines/SConscript
@@ -5,23 +5,21 @@ sources = env.Glob('*.cpp')
defs = []
incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc'
-incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #intern/bmfont'
+incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer'
incs += ' #source/gameengine/Converter #source/blender/imbuf'
incs += ' #intern/ghost/include'
incs += ' #intern/moto/include #source/gameengine/Ketsji #source/blender/blenlib'
-incs += ' #source/blender/blenkernel #source/blender #source/blender/include'
-incs += ' #source/blender/makesdna #source/gameengine/Rasterizer #source/gameengine/GameLogic'
+incs += ' #source/blender/blenkernel #source/blender'
+incs += ' #source/blender/blenfont #source/blender/editors/include'
+incs += ' #source/blender/makesdna #source/blender/makesrna'
+incs += ' #source/gameengine/Rasterizer #source/gameengine/GameLogic'
incs += ' #source/gameengine/Expressions #source/gameengine/Network'
incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common'
incs += ' #source/gameengine/Physics/Bullet'
incs += ' #source/gameengine/Network/LoopBackNetwork'
incs += ' #intern/SoundSystem #source/blender/misc #source/blender/blenloader'
incs += ' #extern/glew/include #source/blender/gpu'
-
-if env['WITH_BF_SOLID']:
- incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/Fuzzics/include'
- incs += ' ' + env['BF_SOLID_INC']
- defs.append('USE_SUMO_SOLID')
+incs += ' #source/blender/windowmanager'
if env['WITH_BF_FFMPEG']:
defs.append('WITH_FFMPEG')
@@ -31,8 +29,9 @@ incs += ' ' + env['BF_BULLET_INC']
incs += ' ' + env['BF_OPENGL_INC']
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
-env.BlenderLib ( 'bf_bloutines', sources, Split(incs), defs, libtype=['game', 'game2', 'player'], priority=[0, 0, 55] , cxx_compileflags=cxxflags)
+env.BlenderLib ( 'bf_bloutines', sources, Split(incs), defs, libtype=['core', 'player'], priority=[300, 45] , cxx_compileflags=cxxflags)
diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt
index fd05858710d..f546a31fb2e 100644
--- a/source/gameengine/CMakeLists.txt
+++ b/source/gameengine/CMakeLists.txt
@@ -38,7 +38,6 @@ ADD_SUBDIRECTORY(Rasterizer)
ADD_SUBDIRECTORY(Rasterizer/RAS_OpenGLRasterizer)
ADD_SUBDIRECTORY(SceneGraph)
ADD_SUBDIRECTORY(Physics/Bullet)
-ADD_SUBDIRECTORY(Physics/Sumo)
ADD_SUBDIRECTORY(VideoTexture)
IF(WITH_PLAYER)
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index 88d6d294dc0..30055a717e3 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -43,6 +43,7 @@
#include "BKE_action.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
+#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
@@ -51,12 +52,18 @@
#include "FloatValue.h"
#include "PyObjectPlus.h"
#include "KX_PyMath.h"
-#include "blendef.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+extern "C" {
+#include "BKE_animsys.h"
+#include "BKE_action.h"
+#include "RNA_access.h"
+#include "RNA_define.h"
+}
+
BL_ActionActuator::~BL_ActionActuator()
{
if (m_pose)
@@ -360,10 +367,31 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
/* Get the underlying pose from the armature */
obj->GetPose(&m_pose);
-
+
+// 2.4x function,
/* Override the necessary channels with ones from the action */
- extract_pose_from_action(m_pose, m_action, m_localtime);
+ // XXX extract_pose_from_action(m_pose, m_action, m_localtime);
+
+
+// 2.5x - replacement for extract_pose_from_action(...) above.
+ {
+ struct PointerRNA id_ptr;
+ Object *arm= obj->GetArmatureObject();
+ bPose *pose_back= arm->pose;
+
+ arm->pose= m_pose;
+ RNA_id_pointer_create((ID *)arm, &id_ptr);
+ animsys_evaluate_action(&id_ptr, m_action, NULL, m_localtime);
+
+ arm->pose= pose_back;
+
+// 2.5x - could also do this but looks too high level, constraints use this, it works ok.
+// Object workob; /* evaluate using workob */
+// what_does_obaction((Scene *)obj->GetScene(), obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime);
+ }
+ // done getting the pose from the action
+
/* Perform the user override (if any) */
if (m_userpose){
extract_pose_from_pose(m_pose, m_userpose);
@@ -381,7 +409,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
/* Find percentages */
newweight = (m_blendframe/(float)m_blendin);
- blend_poses(m_pose, m_blendpose, 1.0 - newweight, ACTSTRIPMODE_BLEND);
+ game_blend_poses(m_pose, m_blendpose, 1.0 - newweight);
/* Increment current blending percentage */
m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
@@ -418,7 +446,7 @@ PyObject* BL_ActionActuator::PyGetAction(PyObject* args,
ShowDeprecationWarning("getAction()", "the action property");
if (m_action){
- return PyString_FromString(m_action->id.name+2);
+ return PyUnicode_FromString(m_action->id.name+2);
}
Py_RETURN_NONE;
}
@@ -768,7 +796,7 @@ PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* args,
}
PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) {
- char *string= PyString_AsString(value);
+ char *string= _PyUnicode_AsString(value);
if (!string) {
PyErr_SetString(PyExc_TypeError, "expected a single string");
@@ -864,7 +892,7 @@ PyObject* BL_ActionActuator::PySetType(PyObject* args,
PyObject* BL_ActionActuator::PyGetContinue() {
ShowDeprecationWarning("getContinue()", "the continue property");
- return PyInt_FromLong((long)(m_end_reset==0));
+ return PyLong_FromSsize_t((long)(m_end_reset==0));
}
PyObject* BL_ActionActuator::PySetContinue(PyObject* value) {
@@ -930,10 +958,10 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
game_copy_pose(&m_userpose, m_pose);
}
- //pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there.
+ // pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there.
pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there.
- if (pchan) {
+ if(pchan) {
VECCOPY (pchan->loc, matrix[3]);
Mat4ToSize(matrix, pchan->size);
Mat4ToQuat(matrix, pchan->quat);
@@ -942,9 +970,9 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
else {
MT_Vector3 loc;
MT_Vector3 size;
- MT_Vector4 quat;
+ MT_Quaternion quat;
- if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyVecTo(pyquat, quat))
+ if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyQuatTo(pyquat, quat))
return NULL;
// same as above
@@ -953,14 +981,14 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
game_copy_pose(&m_userpose, m_pose);
}
- //pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there.
- pchan= get_pose_channel(m_userpose, string);
+ // pchan= verify_pose_channel(m_userpose, string);
+ pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there.
// for some reason loc.setValue(pchan->loc) fails
if(pchan) {
pchan->loc[0]= loc[0]; pchan->loc[1]= loc[1]; pchan->loc[2]= loc[2];
pchan->size[0]= size[0]; pchan->size[1]= size[1]; pchan->size[2]= size[2];
- pchan->quat[0]= quat[0]; pchan->quat[1]= quat[1]; pchan->quat[2]= quat[2]; pchan->quat[3]= quat[3];
+ pchan->quat[0]= quat[3]; pchan->quat[1]= quat[0]; pchan->quat[2]= quat[1]; pchan->quat[3]= quat[2]; /* notice xyzw -> wxyz is intentional */
}
}
@@ -994,19 +1022,15 @@ PyTypeObject BL_ActionActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject BL_ActionActuator::Parents[] = {
- &BL_ActionActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef BL_ActionActuator::Methods[] = {
@@ -1055,37 +1079,24 @@ PyAttributeDef BL_ActionActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* BL_ActionActuator::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* BL_ActionActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int BL_ActionActuator::py_setattro(PyObject *attr, PyObject* value) {
- py_setattro_up(SCA_IActuator);
-}
-
-
PyObject* BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
- return PyString_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
+ return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
}
int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
- if (!PyString_Check(value))
+ if (!PyUnicode_Check(value))
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
return PY_SET_ATTR_FAIL;
}
bAction *action= NULL;
- STR_String val = PyString_AsString(value);
+ STR_String val = _PyUnicode_AsString(value);
if (val != "")
{
@@ -1113,7 +1124,7 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA
if(pose) {
bPoseChannel *pchan;
for(pchan= (bPoseChannel *)pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) {
- item= PyString_FromString(pchan->name);
+ item= PyUnicode_FromString(pchan->name);
PyList_Append(ret, item);
Py_DECREF(item);
}
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index 088e7e3f4a8..6003e23e315 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -49,9 +49,8 @@ public:
short blendin,
short priority,
short end_reset,
- float stride,
- PyTypeObject* T=&Type)
- : SCA_IActuator(gameobj,T),
+ float stride)
+ : SCA_IActuator(gameobj),
m_lastpos(0, 0, 0),
m_blendframe(0),
@@ -113,10 +112,6 @@ public:
KX_PYMETHOD_DOC(BL_ActionActuator,setChannel);
- virtual PyObject* py_getattro(PyObject* attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject* attr, PyObject* value);
-
static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index b00b493193d..f8a9b1b637f 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -38,6 +38,7 @@
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "MT_Matrix4x4.h"
@@ -48,17 +49,19 @@
BL_ArmatureObject::BL_ArmatureObject(
void* sgReplicationInfo,
SG_Callbacks callbacks,
- Object *armature )
+ Object *armature,
+ Scene *scene)
: KX_GameObject(sgReplicationInfo,callbacks),
m_objArma(armature),
+ m_scene(scene), // maybe remove later. needed for where_is_pose
m_framePose(NULL),
m_lastframe(0.0),
m_activeAct(NULL),
m_activePriority(999),
m_lastapplyframe(0.0)
{
- m_armature = get_armature(m_objArma);
+ m_armature = (bArmature *)armature->data;
/* we make a copy of blender object's pose, and then always swap it with
* the original pose before calling into blender functions, to deal with
@@ -93,9 +96,9 @@ void BL_ArmatureObject::ApplyPose()
{
m_armpose = m_objArma->pose;
m_objArma->pose = m_pose;
-
+ //m_scene->r.cfra++;
if(m_lastapplyframe != m_lastframe) {
- where_is_pose(m_objArma);
+ where_is_pose(m_scene, m_objArma); // XXX
m_lastapplyframe = m_lastframe;
}
}
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
index fdf961d5694..684d89d492b 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ b/source/gameengine/Converter/BL_ArmatureObject.h
@@ -51,7 +51,8 @@ public:
BL_ArmatureObject(
void* sgReplicationInfo,
SG_Callbacks callbacks,
- Object *armature
+ Object *armature,
+ Scene *scene
);
virtual ~BL_ArmatureObject();
@@ -68,6 +69,7 @@ public:
struct bArmature * GetArmature() { return m_armature; }
const struct bArmature * GetArmature() const { return m_armature; }
+ const struct Scene * GetScene() const { return m_scene; }
Object* GetArmatureObject() {return m_objArma;}
@@ -85,6 +87,7 @@ protected:
struct bPose *m_pose;
struct bPose *m_armpose;
struct bPose *m_framePose;
+ struct Scene *m_scene; // need for where_is_pose
double m_lastframe;
class BL_ActionActuator *m_activeAct;
short m_activePriority;
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index caa76263b25..4309ca6c1ff 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -163,7 +163,6 @@ extern "C" {
#include "SG_BBox.h"
#include "SG_Tree.h"
-// defines USE_ODE to choose physics engine
#include "KX_ConvertPhysicsObject.h"
#ifdef USE_BULLET
#include "CcdPhysicsEnvironment.h"
@@ -183,8 +182,8 @@ extern "C" {
#ifdef __cplusplus
extern "C" {
#endif
-#include "BSE_headerbuttons.h"
-void update_for_newframe();
+//XXX #include "BSE_headerbuttons.h"
+//XXX void update_for_newframe();
//void scene_update_for_newframe(struct Scene *sce, unsigned int lay);
//#include "BKE_ipo.h"
//void do_all_data_ipos(void);
@@ -560,7 +559,7 @@ bool ConvertMaterial(
material->ref = mat->ref;
material->amb = mat->amb;
- material->ras_mode |= (mat->mode & MA_WIRE)? WIRE: 0;
+ material->ras_mode |= (mat->material_type == MA_TYPE_WIRE)? WIRE: 0;
}
else {
int valid = 0;
@@ -1613,18 +1612,6 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
break;
#endif
-#ifdef USE_SUMO_SOLID
- case UseSumo:
- KX_ConvertSumoObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop);
- break;
-#endif
-
-#ifdef USE_ODE
- case UseODE:
- KX_ConvertODEEngineObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop);
- break;
-#endif //USE_ODE
-
case UseDynamo:
//KX_ConvertDynamoObject(gameobj,meshobj,kxscene,shapeprops, smmaterial, &objprop);
break;
@@ -1760,7 +1747,7 @@ static KX_GameObject *gameobject_from_blenderobject(
if (bHasModifier) {
BL_ModifierDeformer *dcont = new BL_ModifierDeformer((BL_DeformableGameObject *)gameobj,
- ob, (BL_SkinMeshObject *)meshobj);
+ blenderscene, ob, (BL_SkinMeshObject *)meshobj);
((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
if (bHasShapeKey && bHasArmature)
dcont->LoadShapeDrivers(ob->parent);
@@ -1798,7 +1785,8 @@ static KX_GameObject *gameobject_from_blenderobject(
gameobj = new BL_ArmatureObject(
kxscene,
KX_Scene::m_callbacks,
- ob // handle
+ ob,
+ blenderscene // handle
);
/* Get the current pose from the armature object and apply it as the rest pose */
break;
@@ -1828,7 +1816,7 @@ struct parentChildLink {
};
#include "DNA_constraint_types.h"
-#include "BIF_editconstraint.h"
+//XXX #include "BIF_editconstraint.h"
bPoseChannel *get_active_posechannel2 (Object *ob)
{
@@ -1946,39 +1934,35 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
aspect_width = canvas->GetWidth();
aspect_height = canvas->GetHeight();
} else {
- if (blenderscene->framing.type == SCE_GAMEFRAMING_BARS) {
+ if (blenderscene->gm.framing.type == SCE_GAMEFRAMING_BARS) {
frame_type = RAS_FrameSettings::e_frame_bars;
- } else if (blenderscene->framing.type == SCE_GAMEFRAMING_EXTEND) {
+ } else if (blenderscene->gm.framing.type == SCE_GAMEFRAMING_EXTEND) {
frame_type = RAS_FrameSettings::e_frame_extend;
} else {
frame_type = RAS_FrameSettings::e_frame_scale;
}
- aspect_width = blenderscene->r.xsch;
- aspect_height = blenderscene->r.ysch;
+ aspect_width = blenderscene->gm.xsch;
+ aspect_height = blenderscene->gm.ysch;
}
RAS_FrameSettings frame_settings(
frame_type,
- blenderscene->framing.col[0],
- blenderscene->framing.col[1],
- blenderscene->framing.col[2],
+ blenderscene->gm.framing.col[0],
+ blenderscene->gm.framing.col[1],
+ blenderscene->gm.framing.col[2],
aspect_width,
aspect_height
);
kxscene->SetFramingType(frame_settings);
- kxscene->SetGravity(MT_Vector3(0,0,(blenderscene->world != NULL) ? -blenderscene->world->gravity : -9.8));
+ kxscene->SetGravity(MT_Vector3(0,0, -blenderscene->gm.gravity));
/* set activity culling parameters */
- if (blenderscene->world) {
- kxscene->SetActivityCulling( (blenderscene->world->mode & WO_ACTIVITY_CULLING) != 0);
- kxscene->SetActivityCullingRadius(blenderscene->world->activityBoxRadius);
- kxscene->SetDbvtCulling((blenderscene->world->mode & WO_DBVT_CULLING) != 0);
- } else {
- kxscene->SetActivityCulling(false);
- kxscene->SetDbvtCulling(false);
- }
+ kxscene->SetActivityCulling( (blenderscene->gm.mode & WO_ACTIVITY_CULLING) != 0);
+ kxscene->SetActivityCullingRadius(blenderscene->gm.activityBoxRadius);
+ kxscene->SetDbvtCulling((blenderscene->gm.mode & WO_DBVT_CULLING) != 0);
+
// no occlusion culling by default
kxscene->SetDbvtOcclusionRes(0);
@@ -2048,7 +2032,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
if (converter->addInitFromFrame){//rcruiz
float eulxyzPrev[3];
blenderscene->r.cfra=blenderscene->r.sfra-1;
- update_for_newframe();
+ //XXX update_for_newframe();
MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0],
blenderobject->loc[1]+blenderobject->dloc[1],
blenderobject->loc[2]+blenderobject->dloc[2]
@@ -2066,7 +2050,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
tmp.scale(fps, fps, fps);
iniang.push_back(tmp);
blenderscene->r.cfra=blenderscene->r.sfra;
- update_for_newframe();
+ //XXX update_for_newframe();
}
gameobj->NodeSetLocalPosition(pos);
@@ -2240,7 +2224,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
if (converter->addInitFromFrame){//rcruiz
float eulxyzPrev[3];
blenderscene->r.cfra=blenderscene->r.sfra-1;
- update_for_newframe();
+ //XXX update_for_newframe();
MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0],
blenderobject->loc[1]+blenderobject->dloc[1],
blenderobject->loc[2]+blenderobject->dloc[2]
@@ -2258,7 +2242,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
tmp.scale(fps, fps, fps);
iniang.push_back(tmp);
blenderscene->r.cfra=blenderscene->r.sfra;
- update_for_newframe();
+ //XXX update_for_newframe();
}
gameobj->NodeSetLocalPosition(pos);
@@ -2458,7 +2442,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
case PARBONE:
{
// parent this to a bone
- Bone *parent_bone = get_named_bone(get_armature(blenderchild->parent), blenderchild->parsubstr);
+ Bone *parent_bone = get_named_bone( (bArmature *)(blenderchild->parent)->data, blenderchild->parsubstr);
if(parent_bone) {
KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone);
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp
index fe539f9a6c5..80165548ff2 100644
--- a/source/gameengine/Converter/BL_ModifierDeformer.cpp
+++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp
@@ -48,6 +48,7 @@
#include "DNA_ipo_types.h"
#include "DNA_curve_types.h"
#include "DNA_modifier_types.h"
+#include "DNA_scene_types.h"
#include "BKE_armature.h"
#include "BKE_action.h"
#include "BKE_key.h"
@@ -132,7 +133,7 @@ bool BL_ModifierDeformer::Update(void)
Mesh *oldmesh = (Mesh*)blendobj->data;
blendobj->data = m_bmesh;
/* execute the modifiers */
- DerivedMesh *dm = mesh_create_derived_no_virtual(blendobj, m_transverts, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_create_derived_no_virtual(m_scene, blendobj, m_transverts, CD_MASK_MESH);
/* restore object data */
blendobj->data = oldmesh;
/* free the current derived mesh and replace, (dm should never be NULL) */
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h
index d5a1caeb91f..b09cc2087ca 100644
--- a/source/gameengine/Converter/BL_ModifierDeformer.h
+++ b/source/gameengine/Converter/BL_ModifierDeformer.h
@@ -48,11 +48,13 @@ public:
BL_ModifierDeformer(BL_DeformableGameObject *gameobj,
+ Scene *scene,
Object *bmeshobj,
BL_SkinMeshObject *mesh)
:
BL_ShapeDeformer(gameobj,bmeshobj, mesh),
m_lastModifierUpdate(-1),
+ m_scene(scene),
m_dm(NULL)
{
m_recalcNormal = false;
@@ -60,6 +62,7 @@ public:
/* this second constructor is needed for making a mesh deformable on the fly. */
BL_ModifierDeformer(BL_DeformableGameObject *gameobj,
+ struct Scene *scene,
struct Object *bmeshobj_old,
struct Object *bmeshobj_new,
class BL_SkinMeshObject *mesh,
@@ -68,6 +71,7 @@ public:
:
BL_ShapeDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, false, arma),
m_lastModifierUpdate(-1),
+ m_scene(scene),
m_dm(NULL)
{
};
@@ -94,6 +98,7 @@ public:
protected:
double m_lastModifierUpdate;
+ Scene *m_scene;
DerivedMesh *m_dm;
};
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
index bf7edb5f641..970539777f4 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
@@ -40,6 +40,7 @@
#include "STR_HashedString.h"
#include "DNA_nla_types.h"
#include "DNA_action_types.h"
+#include "DNA_scene_types.h"
#include "BKE_action.h"
#include "DNA_armature_types.h"
#include "MEM_guardedalloc.h"
@@ -49,7 +50,6 @@
#include "BKE_utildefines.h"
#include "FloatValue.h"
#include "PyObjectPlus.h"
-#include "blendef.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -370,9 +370,9 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame)
m_blendstart = curtime;
}
// only interested in shape channel
- extract_ipochannels_from_action(&tchanbase, &key->id, m_action, "Shape", m_localtime);
+ // XXX extract_ipochannels_from_action(&tchanbase, &key->id, m_action, "Shape", m_localtime);
- if (!execute_ipochannels(&tchanbase)) {
+ if (0) { // XXX !execute_ipochannels(&tchanbase)) {
// no update, this is possible if action does not match the keys, stop the action
keepgoing = false;
}
@@ -427,21 +427,18 @@ PyTypeObject BL_ShapeActionActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject BL_ShapeActionActuator::Parents[] = {
- &BL_ShapeActionActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
+
PyMethodDef BL_ShapeActionActuator::Methods[] = {
{"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
{"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
@@ -480,19 +477,6 @@ PyAttributeDef BL_ShapeActionActuator::Attributes[] = {
{ NULL } //Sentinel
};
-
-PyObject* BL_ShapeActionActuator::py_getattro(PyObject* attr) {
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* BL_ShapeActionActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int BL_ShapeActionActuator::py_setattro(PyObject *attr, PyObject* value) {
- py_setattro_up(SCA_IActuator);
-}
-
/* setStart */
const char BL_ShapeActionActuator::GetAction_doc[] =
"getAction()\n"
@@ -501,7 +485,7 @@ const char BL_ShapeActionActuator::GetAction_doc[] =
PyObject* BL_ShapeActionActuator::PyGetAction() {
ShowDeprecationWarning("getAction()", "the action property");
if (m_action){
- return PyString_FromString(m_action->id.name+2);
+ return PyUnicode_FromString(m_action->id.name+2);
}
Py_RETURN_NONE;
}
@@ -860,21 +844,21 @@ PyObject* BL_ShapeActionActuator::PySetType(PyObject* args) {
PyObject* BL_ShapeActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
BL_ShapeActionActuator* self= static_cast<BL_ShapeActionActuator*>(self_v);
- return PyString_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
+ return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
}
int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
BL_ShapeActionActuator* self= static_cast<BL_ShapeActionActuator*>(self_v);
/* exact copy of BL_ActionActuator's function from here down */
- if (!PyString_Check(value))
+ if (!PyUnicode_Check(value))
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, expected the string name of the action");
return PY_SET_ATTR_FAIL;
}
bAction *action= NULL;
- STR_String val = PyString_AsString(value);
+ STR_String val = _PyUnicode_AsString(value);
if (val != "")
{
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h
index d268eef6d23..890fe3f9de9 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.h
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.h
@@ -50,9 +50,8 @@ public:
short playtype,
short blendin,
short priority,
- float stride,
- PyTypeObject* T=&Type)
- : SCA_IActuator(gameobj,T),
+ float stride)
+ : SCA_IActuator(gameobj),
m_lastpos(0, 0, 0),
m_blendframe(0),
@@ -106,10 +105,6 @@ public:
KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType);
KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetType);
- virtual PyObject* py_getattro(PyObject* attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject* attr, PyObject* value);
-
static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp
index 12ef3ff84f1..d39917b0e5c 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.cpp
+++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp
@@ -118,11 +118,11 @@ bool BL_ShapeDeformer::ExecuteShapeDrivers(void)
for (it=m_shapeDrivers.begin(); it!=m_shapeDrivers.end(); it++) {
// no need to set a specific time: this curve has a driver
- IpoCurve *icu = *it;
- calc_icu(icu, 1.0f);
- poin = get_ipo_poin((ID*)m_bmesh->key, icu, &type);
- if (poin)
- write_ipo_poin(poin, type, icu->curval);
+ // XXX IpoCurve *icu = *it;
+ //calc_icu(icu, 1.0f);
+ //poin = get_ipo_poin((ID*)m_bmesh->key, icu, &type);
+ //if (poin)
+ // write_ipo_poin(poin, type, icu->curval);
}
ForceUpdate();
diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt
index 217bdb30907..031c2234ea8 100644
--- a/source/gameengine/Converter/CMakeLists.txt
+++ b/source/gameengine/Converter/CMakeLists.txt
@@ -32,7 +32,6 @@ SET(INC
../../../intern/string
../../../intern/guardedalloc
../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
- ../../../intern/bmfont
../../../intern/SoundSystem
../../../intern/SoundSystem/include
../../../intern/SoundSystem/openal
@@ -46,9 +45,11 @@ SET(INC
../../../source/gameengine/Ketsji/KXNetwork
../../../source/blender/blenlib
../../../source/blender/blenkernel
+ ../../../source/blender/windowmanager
../../../source/blender
../../../source/blender/include
../../../source/blender/makesdna
+ ../../../source/blender/makesrna
../../../source/gameengine/Rasterizer
../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
../../../source/gameengine/GameLogic
diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
index 4d79febb7b4..c3264a2bc37 100644
--- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
+++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
@@ -28,32 +28,30 @@
#include "KX_BlenderScalarInterpolator.h"
+#include <cstring>
+
extern "C" {
#include "DNA_ipo_types.h"
-#include "BKE_ipo.h"
+#include "DNA_action_types.h"
+#include "DNA_anim_types.h"
+#include "BKE_fcurve.h"
}
-static const int BL_MAX_CHANNELS = 32;
-
float BL_ScalarInterpolator::GetValue(float currentTime) const {
- return IPO_GetFloatValue(m_blender_ipo, m_channel, currentTime);
+ // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime);
+ return evaluate_fcurve(m_fcu, currentTime);
}
-
-
-BL_InterpolatorList::BL_InterpolatorList(struct Ipo *ipo) {
- IPO_Channel channels[BL_MAX_CHANNELS];
-
- int num_channels = IPO_GetChannels(ipo, channels);
-
- int i;
-
- for (i = 0; i != num_channels; ++i) {
- BL_ScalarInterpolator *new_ipo =
- new BL_ScalarInterpolator(ipo, channels[i]);
-
- //assert(new_ipo);
- push_back(new_ipo);
+BL_InterpolatorList::BL_InterpolatorList(struct AnimData *adt) {
+ if(adt->action==NULL)
+ return;
+
+ for(FCurve *fcu= (FCurve *)adt->action->curves.first; fcu; fcu= (FCurve *)fcu->next) {
+ if(fcu->rna_path) {
+ BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu);
+ //assert(new_ipo);
+ push_back(new_ipo);
+ }
}
}
@@ -64,15 +62,13 @@ BL_InterpolatorList::~BL_InterpolatorList() {
}
}
-
-KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(BL_IpoChannel channel) {
- BL_InterpolatorList::iterator i = begin();
- while (!(i == end()) &&
- (static_cast<BL_ScalarInterpolator *>(*i))->GetChannel() !=
- channel) {
- ++i;
+KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(char *rna_path, int array_index) {
+ for(BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ )
+ {
+ FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve();
+ if(array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0)
+ return *i;
}
-
- return (i == end()) ? 0 : *i;
+ return NULL;
}
diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
index 94d15aff6be..396a7d197df 100644
--- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
+++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
@@ -38,29 +38,26 @@ typedef unsigned short BL_IpoChannel;
class BL_ScalarInterpolator : public KX_IScalarInterpolator {
public:
BL_ScalarInterpolator() {} // required for use in STL list
- BL_ScalarInterpolator(struct Ipo *ipo, BL_IpoChannel channel) :
- m_blender_ipo(ipo),
- m_channel(channel)
+ BL_ScalarInterpolator(struct FCurve* fcu) :
+ m_fcu(fcu)
{}
virtual ~BL_ScalarInterpolator() {}
virtual float GetValue(float currentTime) const;
-
- BL_IpoChannel GetChannel() const { return m_channel; }
+ struct FCurve *GetFCurve() { return m_fcu;};
private:
- struct Ipo *m_blender_ipo;
- BL_IpoChannel m_channel;
+ struct FCurve *m_fcu;
};
class BL_InterpolatorList : public std::vector<KX_IScalarInterpolator *> {
public:
- BL_InterpolatorList(struct Ipo *ipo);
+ BL_InterpolatorList(struct AnimData *adt);
~BL_InterpolatorList();
- KX_IScalarInterpolator *GetScalarInterpolator(BL_IpoChannel channel);
+ KX_IScalarInterpolator *GetScalarInterpolator(char *rna_path, int array_index);
};
#endif //__KX_SCALARINTERPOLATOR_H
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 42b96d65622..9e0a710f44f 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -44,21 +44,12 @@
#include "DummyPhysicsEnvironment.h"
-//to decide to use sumo/ode or dummy physics - defines USE_ODE
#include "KX_ConvertPhysicsObject.h"
#ifdef USE_BULLET
#include "CcdPhysicsEnvironment.h"
#endif
-#ifdef USE_ODE
-#include "OdePhysicsEnvironment.h"
-#endif //USE_ODE
-
-#ifdef USE_SUMO_SOLID
-#include "SumoPhysicsEnvironment.h"
-#endif
-
#include "KX_BlenderSceneConverter.h"
#include "KX_BlenderScalarInterpolator.h"
#include "BL_BlenderDataConversion.h"
@@ -83,8 +74,8 @@ extern "C"
#include "DNA_curve_types.h"
#include "BLI_blenlib.h"
#include "MEM_guardedalloc.h"
-#include "BSE_editipo.h"
-#include "BSE_editipo_types.h"
+//XXX #include "BSE_editipo.h"
+//XXX #include "BSE_editipo_types.h"
#include "DNA_ipo_types.h"
#include "BKE_global.h"
#include "BKE_ipo.h" // eval_icu
@@ -113,11 +104,11 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter()
// delete sumoshapes
- int numipolists = m_map_blender_to_gameipolist.size();
- for (i=0; i<numipolists; i++) {
- BL_InterpolatorList *ipoList= *m_map_blender_to_gameipolist.at(i);
+ int numAdtLists = m_map_blender_to_gameAdtList.size();
+ for (i=0; i<numAdtLists; i++) {
+ BL_InterpolatorList *adtList= *m_map_blender_to_gameAdtList.at(i);
- delete (ipoList);
+ delete (adtList);
}
vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator itw = m_worldinfos.begin();
@@ -145,10 +136,6 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter()
delete (*itm).second;
itm++;
}
-
-#ifdef USE_SUMO_SOLID
- KX_ClearSumoSharedShapes();
-#endif
#ifdef USE_BULLET
KX_ClearBulletSharedShapes();
@@ -331,20 +318,7 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
destinationscene->SetPhysicsEnvironment(ccdPhysEnv);
break;
}
-#endif
-
-#ifdef USE_SUMO_SOLID
- case UseSumo:
- destinationscene ->SetPhysicsEnvironment(new SumoPhysicsEnvironment());
- break;
-#endif
-#ifdef USE_ODE
-
- case UseODE:
- destinationscene ->SetPhysicsEnvironment(new ODEPhysicsEnvironment());
- break;
-#endif //USE_ODE
-
+#endif
case UseDynamo:
{
}
@@ -573,18 +547,18 @@ void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat)
void KX_BlenderSceneConverter::RegisterInterpolatorList(
- BL_InterpolatorList *ipoList,
- struct Ipo *for_ipo)
+ BL_InterpolatorList *adtList,
+ struct AnimData *for_adt)
{
- m_map_blender_to_gameipolist.insert(CHashedPtr(for_ipo), ipoList);
+ m_map_blender_to_gameAdtList.insert(CHashedPtr(for_adt), adtList);
}
BL_InterpolatorList *KX_BlenderSceneConverter::FindInterpolatorList(
- struct Ipo *for_ipo)
+ struct AnimData *for_adt)
{
- BL_InterpolatorList **listp = m_map_blender_to_gameipolist[CHashedPtr(for_ipo)];
+ BL_InterpolatorList **listp = m_map_blender_to_gameAdtList[CHashedPtr(for_adt)];
return listp?*listp:NULL;
}
@@ -639,8 +613,9 @@ void KX_BlenderSceneConverter::RegisterWorldInfo(
* 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)
+void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu )
{
+#if 0 //XXX
if (!G.sipo)
return;
@@ -655,15 +630,16 @@ void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu)
return;
}
}
+#endif
}
//quick hack
extern "C"
{
Ipo *add_ipo( char *name, int idcode );
- char *getIpoCurveName( IpoCurve * icu );
- struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int, short);
- void testhandles_ipocurve(struct IpoCurve *icu);
+ //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 Mat3ToEul(float tmat[][3], float *eul);
@@ -675,11 +651,11 @@ IpoCurve* findIpoCurve(IpoCurve* first, const char* searchName)
IpoCurve* icu1;
for( icu1 = first; icu1; icu1 = icu1->next )
{
- char* curveName = getIpoCurveName( icu1 );
+ /*XXX char* curveName = getIpoCurveName( icu1 );
if( !strcmp( curveName, searchName) )
{
return icu1;
- }
+ }*/
}
return 0;
}
@@ -753,7 +729,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
}
}
} else
- { ipo = add_ipo(blenderObject->id.name+2, ID_OB);
+ { ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB);
blenderObject->ipo = ipo;
}
@@ -850,6 +826,8 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f};
float tmat[3][3];
+ // XXX animato
+#if 0
Ipo* ipo = blenderObject->ipo;
//create the curves, if not existing, set linear if new
@@ -910,6 +888,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1);
// Handles are corrected at the end, testhandles_ipocurve isnt needed yet
+#endif
}
}
}
@@ -940,6 +919,8 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
Object* blenderObject = FindBlenderObject(gameObj);
if (blenderObject && blenderObject->ipo)
{
+ // XXX animato
+#if 0
Ipo* ipo = blenderObject->ipo;
//create the curves, if not existing
@@ -950,6 +931,7 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotX"));
testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotY"));
testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ"));
+#endif
}
}
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h
index cf8dd5b339a..b65f49c2b59 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h
@@ -65,7 +65,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter
GEN_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator;
GEN_Map<CHashedPtr,SCA_IController*> m_map_blender_to_gamecontroller;
- GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameipolist;
+ GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameAdtList;
Main* m_maggie;
@@ -121,8 +121,8 @@ public:
void RegisterBlenderMaterial(BL_Material *mat);
- void RegisterInterpolatorList(BL_InterpolatorList *ipoList, struct Ipo *for_ipo);
- BL_InterpolatorList *FindInterpolatorList(struct Ipo *for_ipo);
+ void RegisterInterpolatorList(BL_InterpolatorList *adtList, struct AnimData *for_adt);
+ BL_InterpolatorList *FindInterpolatorList(struct AnimData *for_adt);
void RegisterGameActuator(SCA_IActuator *act, struct bActuator *for_actuator);
SCA_IActuator *FindGameActuator(struct bActuator *for_actuator);
diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp
index e9984ee0525..5e8d6f3cbf0 100644
--- a/source/gameengine/Converter/KX_ConvertProperties.cpp
+++ b/source/gameengine/Converter/KX_ConvertProperties.cpp
@@ -66,58 +66,58 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan
show_debug_info = bool (prop->flag & PROP_DEBUG);
switch(prop->type) {
- case PROP_BOOL:
- {
- propval = new CBoolValue((bool)(prop->data != 0));
- gameobj->SetProperty(prop->name,propval);
- //promp->poin= &prop->data;
- break;
- }
- case PROP_INT:
- {
- propval = new CIntValue((int)prop->data);
- gameobj->SetProperty(prop->name,propval);
- break;
- }
- case PROP_FLOAT:
- {
- //prop->poin= &prop->data;
- float floatprop = *((float*)&prop->data);
- propval = new CFloatValue(floatprop);
- gameobj->SetProperty(prop->name,propval);
- }
- break;
- case PROP_STRING:
- {
- //prop->poin= callocN(MAX_PROPSTRING, "property string");
- propval = new CStringValue((char*)prop->poin,"");
- gameobj->SetProperty(prop->name,propval);
+ case GPROP_BOOL:
+ {
+ propval = new CBoolValue((bool)(prop->data != 0));
+ gameobj->SetProperty(prop->name,propval);
+ //promp->poin= &prop->data;
+ break;
+ }
+ case GPROP_INT:
+ {
+ propval = new CIntValue((int)prop->data);
+ gameobj->SetProperty(prop->name,propval);
+ break;
+ }
+ case GPROP_FLOAT:
+ {
+ //prop->poin= &prop->data;
+ float floatprop = *((float*)&prop->data);
+ propval = new CFloatValue(floatprop);
+ gameobj->SetProperty(prop->name,propval);
+ }
break;
- }
- case PROP_TIME:
- {
- float floatprop = *((float*)&prop->data);
-
- CValue* timeval = new CFloatValue(floatprop);
- // set a subproperty called 'timer' so that
- // we can register the replica of this property
- // at the time a game object is replicated (AddObjectActuator triggers this)
- CValue *bval = new CBoolValue(true);
- timeval->SetProperty("timer",bval);
- bval->Release();
- if (isInActiveLayer)
+ case GPROP_STRING:
{
- timemgr->AddTimeProperty(timeval);
+ //prop->poin= callocN(MAX_PROPSTRING, "property string");
+ propval = new CStringValue((char*)prop->poin,"");
+ gameobj->SetProperty(prop->name,propval);
+ break;
}
-
- propval = timeval;
- gameobj->SetProperty(prop->name,timeval);
+ case GPROP_TIME:
+ {
+ float floatprop = *((float*)&prop->data);
- }
- default:
- {
- // todo make an assert etc.
- }
+ CValue* timeval = new CFloatValue(floatprop);
+ // set a subproperty called 'timer' so that
+ // we can register the replica of this property
+ // at the time a game object is replicated (AddObjectActuator triggers this)
+ CValue *bval = new CBoolValue(true);
+ timeval->SetProperty("timer",bval);
+ bval->Release();
+ if (isInActiveLayer)
+ {
+ timemgr->AddTimeProperty(timeval);
+ }
+
+ propval = timeval;
+ gameobj->SetProperty(prop->name,timeval);
+
+ }
+ default:
+ {
+ // todo make an assert etc.
+ }
}
if (propval)
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 37631a0523d..0b395cfd402 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -36,6 +36,7 @@
#pragma warning (disable : 4786)
#endif //WIN32
+#include "wm_event_types.h"
#include "KX_BlenderSceneConverter.h"
#include "KX_ConvertSensors.h"
@@ -121,10 +122,11 @@ void BL_ConvertSensors(struct Object* blenderobject,
gReverseKeyTranslateTable[TIMER0 ] = SCA_IInputDevice::KX_TIMER0;
gReverseKeyTranslateTable[TIMER1 ] = SCA_IInputDevice::KX_TIMER1;
gReverseKeyTranslateTable[TIMER2 ] = SCA_IInputDevice::KX_TIMER2;
- gReverseKeyTranslateTable[TIMER3 ] = SCA_IInputDevice::KX_TIMER3;
// SYSTEM
+#if 0
+ /* **** XXX **** */
gReverseKeyTranslateTable[KEYBD ] = SCA_IInputDevice::KX_KEYBD;
gReverseKeyTranslateTable[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD;
gReverseKeyTranslateTable[REDRAW ] = SCA_IInputDevice::KX_REDRAW;
@@ -135,6 +137,8 @@ void BL_ConvertSensors(struct Object* blenderobject,
gReverseKeyTranslateTable[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE;
gReverseKeyTranslateTable[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT;
gReverseKeyTranslateTable[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME;
+ /* **** XXX **** */
+#endif
// standard keyboard
@@ -145,7 +149,17 @@ void BL_ConvertSensors(struct Object* blenderobject,
gReverseKeyTranslateTable[EKEY ] = SCA_IInputDevice::KX_EKEY;
gReverseKeyTranslateTable[FKEY ] = SCA_IInputDevice::KX_FKEY;
gReverseKeyTranslateTable[GKEY ] = SCA_IInputDevice::KX_GKEY;
+
+//XXX clean up
+#ifdef WIN32
+#define HKEY 'h'
+#endif
gReverseKeyTranslateTable[HKEY ] = SCA_IInputDevice::KX_HKEY;
+//XXX clean up
+#ifdef WIN32
+#undef HKEY
+#endif
+
gReverseKeyTranslateTable[IKEY ] = SCA_IInputDevice::KX_IKEY;
gReverseKeyTranslateTable[JKEY ] = SCA_IInputDevice::KX_JKEY;
gReverseKeyTranslateTable[KKEY ] = SCA_IInputDevice::KX_KKEY;
diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp
index f19390db8a9..d3a2e1a9ba4 100644
--- a/source/gameengine/Converter/KX_IpoConvert.cpp
+++ b/source/gameengine/Converter/KX_IpoConvert.cpp
@@ -71,20 +71,20 @@
#include "STR_HashedString.h"
-static BL_InterpolatorList *GetIpoList(struct Ipo *for_ipo, KX_BlenderSceneConverter *converter) {
- BL_InterpolatorList *ipoList= converter->FindInterpolatorList(for_ipo);
+static BL_InterpolatorList *GetAdtList(struct AnimData *for_adt, KX_BlenderSceneConverter *converter) {
+ BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_adt);
- if (!ipoList) {
- ipoList = new BL_InterpolatorList(for_ipo);
- converter->RegisterInterpolatorList(ipoList, for_ipo);
+ if (!adtList) {
+ adtList = new BL_InterpolatorList(for_adt);
+ converter->RegisterInterpolatorList(adtList, for_adt);
}
- return ipoList;
+ return adtList;
}
void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_BlenderSceneConverter *converter)
{
- if (blenderobject->ipo) {
+ if (blenderobject->adt) {
KX_IpoSGController* ipocontr = new KX_IpoSGController();
gameobj->GetSGNode()->AddSGController(ipocontr);
@@ -120,271 +120,79 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
)
);
- BL_InterpolatorList *ipoList= GetIpoList(blenderobject->ipo, converter);
+ BL_InterpolatorList *adtList= GetAdtList(blenderobject->adt, converter);
- // For each active channel in the ipoList add an
+ // For each active channel in the adtList add an
// interpolator to the game object.
- KX_IScalarInterpolator *ipo;
+ KX_IInterpolator *interpolator;
+ KX_IScalarInterpolator *interp;
- ipo = ipoList->GetScalarInterpolator(OB_LOC_X);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetPosition()[0]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_LOC_X, true);
-
- }
-
- ipo = ipoList->GetScalarInterpolator(OB_LOC_Y);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetPosition()[1]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_LOC_Y, true);
- }
-
- ipo = ipoList->GetScalarInterpolator(OB_LOC_Z);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetPosition()[2]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_LOC_Z, true);
- }
-
- // Master the art of cut & paste programming...
-
- ipo = ipoList->GetScalarInterpolator(OB_DLOC_X);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaPosition()[0]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DLOC_X, true);
- }
-
- ipo = ipoList->GetScalarInterpolator(OB_DLOC_Y);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaPosition()[1]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DLOC_Y, true);
- }
-
- ipo = ipoList->GetScalarInterpolator(OB_DLOC_Z);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaPosition()[2]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DLOC_Z, true);
- }
-
- // Explore the finesse of reuse and slight modification
-
- ipo = ipoList->GetScalarInterpolator(OB_ROT_X);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetEulerAngles()[0]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_ROT_X, true);
- }
- ipo = ipoList->GetScalarInterpolator(OB_ROT_Y);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetEulerAngles()[1]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_ROT_Y, true);
- }
- ipo = ipoList->GetScalarInterpolator(OB_ROT_Z);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetEulerAngles()[2]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_ROT_Z, true);
- }
-
- // Hmmm, the need for a macro comes to mind...
-
- ipo = ipoList->GetScalarInterpolator(OB_DROT_X);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[0]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DROT_X, true);
- }
- ipo = ipoList->GetScalarInterpolator(OB_DROT_Y);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[1]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DROT_Y, true);
- }
- ipo = ipoList->GetScalarInterpolator(OB_DROT_Z);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[2]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DROT_Z, true);
- }
-
- // Hang on, almost there...
-
- ipo = ipoList->GetScalarInterpolator(OB_SIZE_X);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetScaling()[0]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_SIZE_X, true);
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("location", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetPosition()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_LOC_X+i, true);
+ }
}
- ipo = ipoList->GetScalarInterpolator(OB_SIZE_Y);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetScaling()[1]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_SIZE_Y, true);
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("delta_location", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaPosition()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_DLOC_X+i, true);
+ }
}
- ipo = ipoList->GetScalarInterpolator(OB_SIZE_Z);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetScaling()[2]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_SIZE_Z, true);
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("rotation", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetEulerAngles()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_ROT_X+i, true);
+ }
}
-
- // The last few...
-
- ipo = ipoList->GetScalarInterpolator(OB_DSIZE_X);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaScaling()[0]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DSIZE_X, true);
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("delta_rotation", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_DROT_X+i, true);
+ }
}
- ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Y);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaScaling()[1]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DSIZE_Y, true);
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("scale", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetScaling()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_SIZE_X+i, true);
+ }
}
- ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Z);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &(ipocontr->GetIPOTransform().GetDeltaScaling()[2]),
- ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DSIZE_Z, true);
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("delta_scale", i))) {
+ interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaScaling()[i]), interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetIPOChannelActive(OB_DSIZE_X+i, true);
+ }
}
{
KX_ObColorIpoSGController* ipocontr_obcol=NULL;
-
- ipo = ipoList->GetScalarInterpolator(OB_COL_R);
- if (ipo)
- {
- if (!ipocontr_obcol)
- {
- ipocontr_obcol = new KX_ObColorIpoSGController();
- gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
- ipocontr_obcol->SetObject(gameobj->GetSGNode());
- }
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr_obcol->m_rgba[0],
- ipo);
- ipocontr_obcol->AddInterpolator(interpolator);
- }
- ipo = ipoList->GetScalarInterpolator(OB_COL_G);
- if (ipo)
- {
- if (!ipocontr_obcol)
- {
- ipocontr_obcol = new KX_ObColorIpoSGController();
- gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
- ipocontr_obcol->SetObject(gameobj->GetSGNode());
- }
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr_obcol->m_rgba[1],
- ipo);
- ipocontr_obcol->AddInterpolator(interpolator);
- }
- ipo = ipoList->GetScalarInterpolator(OB_COL_B);
- if (ipo)
- {
- if (!ipocontr_obcol)
- {
- ipocontr_obcol = new KX_ObColorIpoSGController();
- gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
- ipocontr_obcol->SetObject(gameobj->GetSGNode());
- }
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr_obcol->m_rgba[2],
- ipo);
- ipocontr_obcol->AddInterpolator(interpolator);
- }
- ipo = ipoList->GetScalarInterpolator(OB_COL_A);
- if (ipo)
- {
- if (!ipocontr_obcol)
- {
- ipocontr_obcol = new KX_ObColorIpoSGController();
- gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
- ipocontr_obcol->SetObject(gameobj->GetSGNode());
+
+ for(int i=0; i<4; i++) {
+ if (interp = adtList->GetScalarInterpolator("color", i)) {
+ if (!ipocontr_obcol) {
+ ipocontr_obcol = new KX_ObColorIpoSGController();
+ gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
+ ipocontr_obcol->SetObject(gameobj->GetSGNode());
+ }
+ interpolator= new KX_ScalarInterpolator(&ipocontr_obcol->m_rgba[i], interp);
+ ipocontr_obcol->AddInterpolator(interpolator);
}
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr_obcol->m_rgba[3],
- ipo);
- ipocontr_obcol->AddInterpolator(interpolator);
}
}
-
-
}
-
-
}
void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_BlenderSceneConverter *converter)
{
- if (blenderlamp->ipo) {
+ if (blenderlamp->adt) {
KX_LightIpoSGController* ipocontr = new KX_LightIpoSGController();
lightobj->GetSGNode()->AddSGController(ipocontr);
@@ -396,51 +204,32 @@ void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_Ble
ipocontr->m_col_rgb[2] = blenderlamp->b;
ipocontr->m_dist = blenderlamp->dist;
- BL_InterpolatorList *ipoList= GetIpoList(blenderlamp->ipo, converter);
+ BL_InterpolatorList *adtList= GetAdtList(blenderlamp->adt, converter);
- // For each active channel in the ipoList add an
+ // For each active channel in the adtList add an
// interpolator to the game object.
- KX_IScalarInterpolator *ipo;
+ KX_IInterpolator *interpolator;
+ KX_IScalarInterpolator *interp;
- ipo = ipoList->GetScalarInterpolator(LA_ENERGY);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_energy, ipo);
+ if ((interp= adtList->GetScalarInterpolator("energy", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp);
ipocontr->AddInterpolator(interpolator);
ipocontr->SetModifyEnergy(true);
}
- ipo = ipoList->GetScalarInterpolator(LA_DIST);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_dist, ipo);
+ if ((interp = adtList->GetScalarInterpolator("distance", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_dist, interp);
ipocontr->AddInterpolator(interpolator);
ipocontr->SetModifyDist(true);
}
-
- ipo = ipoList->GetScalarInterpolator(LA_COL_R);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_col_rgb[0], ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyColor(true);
- }
-
- ipo = ipoList->GetScalarInterpolator(LA_COL_G);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_col_rgb[1], ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyColor(true);
- }
-
- ipo = ipoList->GetScalarInterpolator(LA_COL_B);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_col_rgb[2], ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyColor(true);
+
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("color", i))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetModifyColor(true);
+ }
}
}
}
@@ -451,7 +240,7 @@ void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_Ble
void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj,KX_BlenderSceneConverter *converter)
{
- if (blendercamera->ipo) {
+ if (blendercamera->adt) {
KX_CameraIpoSGController* ipocontr = new KX_CameraIpoSGController();
cameraobj->GetSGNode()->AddSGController(ipocontr);
@@ -461,33 +250,28 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj
ipocontr->m_clipstart = blendercamera->clipsta;
ipocontr->m_clipend = blendercamera->clipend;
- BL_InterpolatorList *ipoList= GetIpoList(blendercamera->ipo, converter);
+ BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt, converter);
- // For each active channel in the ipoList add an
+ // For each active channel in the adtList add an
// interpolator to the game object.
- KX_IScalarInterpolator *ipo;
+ KX_IInterpolator *interpolator;
+ KX_IScalarInterpolator *interp;
- ipo = ipoList->GetScalarInterpolator(CAM_LENS);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_lens, ipo);
+ if ((interp = adtList->GetScalarInterpolator("lens", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp);
ipocontr->AddInterpolator(interpolator);
ipocontr->SetModifyLens(true);
}
- ipo = ipoList->GetScalarInterpolator(CAM_STA);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_clipstart, ipo);
+ if ((interp = adtList->GetScalarInterpolator("clip_start", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipstart, interp);
ipocontr->AddInterpolator(interpolator);
ipocontr->SetModifyClipStart(true);
}
- ipo = ipoList->GetScalarInterpolator(CAM_END);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_clipend, ipo);
+ if ((interp = adtList->GetScalarInterpolator("clip_end", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipend, interp);
ipocontr->AddInterpolator(interpolator);
ipocontr->SetModifyClipEnd(true);
}
@@ -499,7 +283,7 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj
void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *converter)
{
- if (blenderworld->ipo) {
+ if (blenderworld->adt) {
KX_WorldIpoController* ipocontr = new KX_WorldIpoController();
@@ -514,49 +298,30 @@ void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *co
ipocontr->m_mist_rgb[1] = blenderworld->horg;
ipocontr->m_mist_rgb[2] = blenderworld->horb;
- BL_InterpolatorList *ipoList= GetIpoList(blenderworld->ipo, converter);
+ BL_InterpolatorList *adtList= GetAdtList(blenderworld->adt, converter);
- // For each active channel in the ipoList add an
+ // For each active channel in the adtList add an
// interpolator to the game object.
- KX_IScalarInterpolator *ipo;
+ KX_IInterpolator *interpolator;
+ KX_IScalarInterpolator *interp;
- ipo = ipoList->GetScalarInterpolator(WO_HOR_R);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[0], ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyMistColor(true);
- }
-
- ipo = ipoList->GetScalarInterpolator(WO_HOR_G);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[1], ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyMistColor(true);
- }
-
- ipo = ipoList->GetScalarInterpolator(WO_HOR_B);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[2], ipo);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyMistColor(true);
+ for(int i=0; i<3; i++) {
+ if ((interp = adtList->GetScalarInterpolator("horizon_color", i))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[i], interp);
+ ipocontr->AddInterpolator(interpolator);
+ ipocontr->SetModifyMistColor(true);
+ }
}
- ipo = ipoList->GetScalarInterpolator(WO_MISTDI);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_mist_dist, ipo);
+ if ((interp = adtList->GetScalarInterpolator("mist.depth", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_dist, interp);
ipocontr->AddInterpolator(interpolator);
ipocontr->SetModifyMistDist(true);
}
- ipo = ipoList->GetScalarInterpolator(WO_MISTSTA);
- if (ipo) {
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(&ipocontr->m_mist_start, ipo);
+ if ((interp = adtList->GetScalarInterpolator("mist.start", 0))) {
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_start, interp);
ipocontr->AddInterpolator(interpolator);
ipocontr->SetModifyMistStart(true);
}
@@ -570,12 +335,12 @@ static void ConvertMaterialIpos(
KX_BlenderSceneConverter *converter
)
{
- if (blendermaterial->ipo) {
+ if (blendermaterial->adt) {
KX_MaterialIpoController* ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
- BL_InterpolatorList *ipoList= GetIpoList(blendermaterial->ipo, converter);
+ BL_InterpolatorList *adtList= GetAdtList(blendermaterial->adt, converter);
ipocontr->m_rgba[0] = blendermaterial->r;
@@ -592,163 +357,82 @@ static void ConvertMaterialIpos(
ipocontr->m_ref = blendermaterial->ref;
ipocontr->m_emit = blendermaterial->emit;
ipocontr->m_alpha = blendermaterial->alpha;
- KX_IScalarInterpolator *ipo;
- // --
- ipo = ipoList->GetScalarInterpolator(MA_COL_R);
- if (ipo) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- gameobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(gameobj->GetSGNode());
- }
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_rgba[0],
- ipo);
- ipocontr->AddInterpolator(interpolator);
- }
-
- ipo = ipoList->GetScalarInterpolator(MA_COL_G);
- if (ipo) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- gameobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(gameobj->GetSGNode());
- }
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_rgba[1],
- ipo);
- ipocontr->AddInterpolator(interpolator);
- }
+ KX_IInterpolator *interpolator;
+ KX_IScalarInterpolator *sinterp;
- ipo = ipoList->GetScalarInterpolator(MA_COL_B);
- if (ipo) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- gameobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(gameobj->GetSGNode());
+ // --
+ for(int i=0; i<3; i++) {
+ if ((sinterp = adtList->GetScalarInterpolator("diffuse_color", i))) {
+ if (!ipocontr) {
+ ipocontr = new KX_MaterialIpoController(matname_hash);
+ gameobj->GetSGNode()->AddSGController(ipocontr);
+ ipocontr->SetObject(gameobj->GetSGNode());
+ }
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_rgba[i], sinterp);
+ ipocontr->AddInterpolator(interpolator);
}
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_rgba[2],
- ipo);
- ipocontr->AddInterpolator(interpolator);
}
- ipo = ipoList->GetScalarInterpolator(MA_ALPHA);
- if (ipo) {
+ if ((sinterp = adtList->GetScalarInterpolator("alpha", 0))) {
if (!ipocontr) {
ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_rgba[3],
- ipo);
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_rgba[3], sinterp);
ipocontr->AddInterpolator(interpolator);
}
- // --
- ipo = ipoList->GetScalarInterpolator(MA_SPEC_R );
- if (ipo) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- gameobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(gameobj->GetSGNode());
- }
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_specrgb[0],
- ipo);
- ipocontr->AddInterpolator(interpolator);
- }
-
- ipo = ipoList->GetScalarInterpolator(MA_SPEC_G);
- if (ipo) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- gameobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(gameobj->GetSGNode());
+ for(int i=0; i<3; i++) {
+ if ((sinterp = adtList->GetScalarInterpolator("specular_color", i))) {
+ if (!ipocontr) {
+ ipocontr = new KX_MaterialIpoController(matname_hash);
+ gameobj->GetSGNode()->AddSGController(ipocontr);
+ ipocontr->SetObject(gameobj->GetSGNode());
+ }
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_specrgb[i], sinterp);
+ ipocontr->AddInterpolator(interpolator);
}
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_specrgb[1],
- ipo);
- ipocontr->AddInterpolator(interpolator);
}
- ipo = ipoList->GetScalarInterpolator(MA_SPEC_B);
- if (ipo) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- gameobj->GetSGNode()->AddSGController(ipocontr);
- ipocontr->SetObject(gameobj->GetSGNode());
- }
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_specrgb[2],
- ipo);
- ipocontr->AddInterpolator(interpolator);
- }
-
- // --
- ipo = ipoList->GetScalarInterpolator(MA_HARD);
- if (ipo) {
+ if ((sinterp = adtList->GetScalarInterpolator("specular_hardness", 0))) {
if (!ipocontr) {
ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_hard,
- ipo);
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_hard, sinterp);
ipocontr->AddInterpolator(interpolator);
}
- ipo = ipoList->GetScalarInterpolator(MA_SPEC);
- if (ipo) {
+ if ((sinterp = adtList->GetScalarInterpolator("specularity", 0))) {
if (!ipocontr) {
ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_spec,
- ipo);
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_spec, sinterp);
ipocontr->AddInterpolator(interpolator);
}
-
- ipo = ipoList->GetScalarInterpolator(MA_REF);
- if (ipo) {
+ if ((sinterp = adtList->GetScalarInterpolator("diffuse_reflection", 0))) {
if (!ipocontr) {
ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_ref,
- ipo);
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_ref, sinterp);
ipocontr->AddInterpolator(interpolator);
}
- ipo = ipoList->GetScalarInterpolator(MA_EMIT);
- if (ipo) {
+ if ((sinterp = adtList->GetScalarInterpolator("emit", 0))) {
if (!ipocontr) {
ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
- KX_IInterpolator *interpolator =
- new KX_ScalarInterpolator(
- &ipocontr->m_emit,
- ipo);
+ interpolator= new KX_ScalarInterpolator(&ipocontr->m_emit, sinterp);
ipocontr->AddInterpolator(interpolator);
}
}
diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile
index 4dd63e428bd..ed95aa968c7 100644
--- a/source/gameengine/Converter/Makefile
+++ b/source/gameengine/Converter/Makefile
@@ -39,15 +39,16 @@ CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_SOLID)/include
+CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_BULLET2)/include
CPPFLAGS += -I../../blender
# these two needed because of blenkernel
+CPPFLAGS += -I../../blender/windowmanager
CPPFLAGS += -I../../blender/imbuf
CPPFLAGS += -I../../blender/makesdna
-CPPFLAGS += -I../../blender/include
+CPPFLAGS += -I../../blender/makesrna
+CPPFLAGS += -I../../blender/editors/include
CPPFLAGS += -I../../blender/blenlib
CPPFLAGS += -I../../blender/blenkernel
CPPFLAGS += -I../../blender/render/extern/include
diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript
index 361dca58005..05ea01c902a 100644
--- a/source/gameengine/Converter/SConscript
+++ b/source/gameengine/Converter/SConscript
@@ -5,26 +5,23 @@ sources = env.Glob('*.cpp')
defs = []
incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc'
-incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #intern/bmfont'
+incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer'
incs += ' #intern/SoundSystem #intern/SoundSystem/include #intern/SoundSystem/openal'
incs += ' #intern/SoundSystem/dummy #intern/SoundSystem/intern #source/gameengine/Converter'
incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf'
incs += ' #intern/moto/include #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork'
incs += ' #source/blender/blenlib #source/blender/blenkernel #source/blender'
-incs += ' #source/blender/include #source/blender/makesdna #source/gameengine/Rasterizer'
+incs += ' #source/blender/editors/include #source/blender/makesdna #source/gameengine/Rasterizer'
incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #source/gameengine/GameLogic'
incs += ' #source/gameengine/Expressions #source/gameengine/Network #source/gameengine/SceneGraph'
incs += ' #source/gameengine/Physics/common #source/gameengine/Physics/Bullet #source/gameengine/Physics/BlOde'
incs += ' #source/gameengine/Physics/Dummy'
incs += ' #source/gameengine/Network/LoopBackNetwork'
incs += ' #source/blender/misc #source/blender/blenloader #source/blender/gpu'
-
-if env['WITH_BF_SOLID']:
- incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/Fuzzics/include'
- incs += ' ' + env['BF_SOLID_INC']
- defs.append('USE_SUMO_SOLID')
+incs += ' #source/blender/windowmanager'
+incs += ' #source/blender/makesrna'
incs += ' ' + env['BF_PYTHON_INC']
incs += ' ' + env['BF_BULLET_INC']
-env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['game','player'], priority=[5,70] )
+env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['core','player'], priority=[305,50] )
diff --git a/source/gameengine/Expressions/BoolValue.cpp b/source/gameengine/Expressions/BoolValue.cpp
index d90da8b3a92..6779c2ea780 100644
--- a/source/gameengine/Expressions/BoolValue.cpp
+++ b/source/gameengine/Expressions/BoolValue.cpp
@@ -29,7 +29,6 @@
const STR_String CBoolValue::sTrueString = "TRUE";
const STR_String CBoolValue::sFalseString = "FALSE";
-
CBoolValue::CBoolValue()
/*
pre: false
@@ -210,5 +209,5 @@ CValue* CBoolValue::GetReplica()
PyObject* CBoolValue::ConvertValueToPython()
{
- return PyInt_FromLong(m_bool != 0);
+ return PyBool_FromLong(m_bool != 0);
}
diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt
index e3942b46557..dffd13f64ff 100644
--- a/source/gameengine/Expressions/CMakeLists.txt
+++ b/source/gameengine/Expressions/CMakeLists.txt
@@ -32,6 +32,7 @@ SET(INC
../../../intern/string
../../../intern/moto/include
../../../source/gameengine/SceneGraph
+ ../../../source/blender/blenloader
${PYTHON_INC}
)
diff --git a/source/gameengine/Expressions/IntValue.cpp b/source/gameengine/Expressions/IntValue.cpp
index 227518e9439..b782de4bef6 100644
--- a/source/gameengine/Expressions/IntValue.cpp
+++ b/source/gameengine/Expressions/IntValue.cpp
@@ -330,7 +330,7 @@ void CIntValue::SetValue(CValue* newval)
PyObject* CIntValue::ConvertValueToPython()
{
if((m_int > INT_MIN) && (m_int < INT_MAX))
- return PyInt_FromLong(m_int);
+ return PyLong_FromSsize_t(m_int);
else
return PyLong_FromLongLong(m_int);
}
diff --git a/source/gameengine/Expressions/KX_Python.h b/source/gameengine/Expressions/KX_Python.h
index b8006fdf0ed..61f7ef05042 100644
--- a/source/gameengine/Expressions/KX_Python.h
+++ b/source/gameengine/Expressions/KX_Python.h
@@ -32,6 +32,8 @@
//#define USE_DL_EXPORT
#include "Python.h"
+#define USE_MATHUTILS // Blender 2.5x api will use mathutils, for a while we might want to test without it
+
#ifdef __FreeBSD__
#include <osreldate.h>
#if __FreeBSD_version > 500039
diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp
index ea097ddff5b..38b00dcc8fb 100644
--- a/source/gameengine/Expressions/ListValue.cpp
+++ b/source/gameengine/Expressions/ListValue.cpp
@@ -20,6 +20,8 @@
#include <algorithm>
#include "BoolValue.h"
+#include "BLO_sys_types.h" /* for intptr_t support */
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -74,9 +76,9 @@ PyObject* listvalue_mapping_subscript(PyObject* self, PyObject* pyindex)
return NULL;
}
- if (PyString_Check(pyindex))
+ if (PyUnicode_Check(pyindex))
{
- CValue *item = ((CListValue*) list)->FindValue(PyString_AsString(pyindex));
+ CValue *item = ((CListValue*) list)->FindValue(_PyUnicode_AsString(pyindex));
if (item) {
PyObject* pyobj = item->ConvertValueToPython();
if(pyobj)
@@ -85,14 +87,14 @@ PyObject* listvalue_mapping_subscript(PyObject* self, PyObject* pyindex)
return item->GetProxy();
}
}
- else if (PyInt_Check(pyindex))
+ else if (PyLong_Check(pyindex))
{
- int index = PyInt_AsLong(pyindex);
+ int index = PyLong_AsSsize_t(pyindex);
return listvalue_buffer_item(self, index); /* wont add a ref */
}
PyObject *pyindex_str = PyObject_Repr(pyindex); /* new ref */
- PyErr_Format(PyExc_KeyError, "CList[key]: '%s' key not in list", PyString_AsString(pyindex_str));
+ PyErr_Format(PyExc_KeyError, "CList[key]: '%s' key not in list", _PyUnicode_AsString(pyindex_str));
Py_DECREF(pyindex_str);
return NULL;
}
@@ -218,12 +220,12 @@ static int listvalue_buffer_contains(PyObject *self_v, PyObject *value)
return -1;
}
- if (PyString_Check(value)) {
- if (self->FindValue((const char *)PyString_AsString(value))) {
+ if (PyUnicode_Check(value)) {
+ if (self->FindValue((const char *)_PyUnicode_AsString(value))) {
return 1;
}
}
- else if (BGE_PROXY_CHECK_TYPE(value)) { /* not dict like at all but this worked before __contains__ was used */
+ else if (PyObject_TypeCheck(value, &CValue::Type)) { /* not dict like at all but this worked before __contains__ was used */
CValue *item= static_cast<CValue *>(BGE_PROXY_REF(value));
for (int i=0; i < self->GetCount(); i++)
if (self->GetValue(i) == item) // Com
@@ -287,25 +289,19 @@ PyTypeObject CListValue::Type = {
0, /*tp_hash*/
0, /*tp_call */
0,
- py_base_getattro,
- py_base_setattro,
+ NULL,
+ NULL,
0,
- Py_TPFLAGS_DEFAULT,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject CListValue::Parents[] = {
- &CListValue::Type,
+ Methods,
+ 0,
+ 0,
&CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
-
PyMethodDef CListValue::Methods[] = {
/* List style access */
{"append", (PyCFunction)CListValue::sPyappend,METH_O},
@@ -327,21 +323,12 @@ PyAttributeDef CListValue::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* CListValue::py_getattro(PyObject* attr) {
- py_getattro_up(CValue);
-}
-
-PyObject* CListValue::py_getattro_dict() {
- py_getattro_dict_up(CValue);
-}
-
-
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
-CListValue::CListValue(PyTypeObject *T )
-: CPropValue(T)
+CListValue::CListValue()
+: CPropValue()
{
m_bReleaseContents=true;
}
@@ -557,7 +544,7 @@ PyObject* CListValue::Pyindex(PyObject *value)
CValue* elem = GetValue(i);
if (checkobj==elem || CheckEqual(checkobj,elem))
{
- result = PyInt_FromLong(i);
+ result = PyLong_FromSsize_t(i);
break;
}
}
@@ -580,7 +567,7 @@ PyObject* CListValue::Pycount(PyObject* value)
if (checkobj==NULL) { /* in this case just return that there are no items in the list */
PyErr_Clear();
- return PyInt_FromLong(0);
+ return PyLong_FromSsize_t(0);
}
int numelem = GetCount();
@@ -594,7 +581,7 @@ PyObject* CListValue::Pycount(PyObject* value)
}
checkobj->Release();
- return PyInt_FromLong(numfound);
+ return PyLong_FromSsize_t(numfound);
}
/* Matches python dict.get(key, [default]) */
@@ -621,7 +608,7 @@ PyObject* CListValue::Pyget(PyObject *args)
/* Matches python dict.has_key() */
PyObject* CListValue::Pyhas_key(PyObject* value)
{
- if (PyString_Check(value) && FindValue((const char *)PyString_AsString(value)))
+ if (PyUnicode_Check(value) && FindValue((const char *)_PyUnicode_AsString(value)))
Py_RETURN_TRUE;
Py_RETURN_FALSE;
diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h
index 68e900e25e0..98e6f216f11 100644
--- a/source/gameengine/Expressions/ListValue.h
+++ b/source/gameengine/Expressions/ListValue.h
@@ -24,7 +24,7 @@ class CListValue : public CPropValue
//PLUGIN_DECLARE_SERIAL (CListValue,CValue)
public:
- CListValue(PyTypeObject *T = &Type);
+ CListValue();
virtual ~CListValue();
void AddConfigurationData(CValue* menuvalue);
@@ -60,8 +60,6 @@ public:
bool CheckEqual(CValue* first,CValue* second);
- virtual PyObject* py_getattro(PyObject* attr);
- virtual PyObject* py_getattro_dict();
virtual PyObject* py_repr(void) {
PyObject *py_proxy= this->GetProxy();
PyObject *py_list= PySequence_List(py_proxy);
diff --git a/source/gameengine/Expressions/Makefile b/source/gameengine/Expressions/Makefile
index f46c0037200..09512c3ae87 100644
--- a/source/gameengine/Expressions/Makefile
+++ b/source/gameengine/Expressions/Makefile
@@ -37,6 +37,7 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I../../blender/makesdna
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index defb6853e67..729fff31052 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -74,11 +74,13 @@ PyTypeObject PyObjectPlus::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ NULL // no subtype
};
@@ -91,6 +93,88 @@ PyObjectPlus::~PyObjectPlus()
// assert(ob_refcnt==0);
}
+
+PyObject *PyObjectPlus::py_base_repr(PyObject *self) // This should be the entry in Type.
+{
+ PyObjectPlus *self_plus= BGE_PROXY_REF(self);
+ if(self_plus==NULL) {
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
+ return NULL;
+ }
+
+ return self_plus->py_repr();
+}
+
+
+PyObject * PyObjectPlus::py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyTypeObject *base_type;
+ PyObjectPlus_Proxy *base = NULL;
+
+ if (!PyArg_ParseTuple(args, "O:Base PyObjectPlus", &base))
+ return NULL;
+
+ /* the 'base' PyObject may be subclassed (multiple times even)
+ * we need to find the first C++ defined class to check 'type'
+ * is a subclass of the base arguments type.
+ *
+ * This way we can share one tp_new function for every PyObjectPlus
+ *
+ * eg.
+ *
+ * # CustomOb is called 'type' in this C code
+ * class CustomOb(GameTypes.KX_GameObject):
+ * pass
+ *
+ * # this calls py_base_new(...), the type of 'CustomOb' is checked to be a subclass of the 'cont.owner' type
+ * ob = CustomOb(cont.owner)
+ *
+ * */
+ base_type= Py_TYPE(base);
+ while(base_type && !BGE_PROXY_CHECK_TYPE(base_type))
+ base_type= base_type->tp_base;
+
+ if(base_type==NULL || !BGE_PROXY_CHECK_TYPE(base_type)) {
+ PyErr_SetString(PyExc_TypeError, "can't subclass from a blender game type because the argument given is not a game class or subclass");
+ return NULL;
+ }
+
+ /* use base_type rather then Py_TYPE(base) because we could alredy be subtyped */
+ if(!PyType_IsSubtype(type, base_type)) {
+ PyErr_Format(PyExc_TypeError, "can't subclass blender game type <%s> from <%s> because it is not a subclass", base_type->tp_name, type->tp_name);
+ return NULL;
+ }
+
+ /* invalidate the existing base and return a new subclassed one,
+ * this is a bit dodgy in that it also attaches its self to the existing object
+ * which is not really 'correct' python OO but for our use its OK. */
+
+ PyObjectPlus_Proxy *ret = (PyObjectPlus_Proxy *) type->tp_alloc(type, 0); /* starts with 1 ref, used for the return ref' */
+ ret->ref= base->ref;
+ base->ref= NULL; /* invalidate! disallow further access */
+
+ ret->py_owns= base->py_owns;
+
+ ret->ref->m_proxy= NULL;
+
+ /* 'base' may be free'd after this func finished but not necessarily
+ * there is no reference to the BGE data now so it will throw an error on access */
+ Py_DECREF(base);
+
+ ret->ref->m_proxy= (PyObject *)ret; /* no need to add a ref because one is added when creating. */
+ Py_INCREF(ret); /* we return a new ref but m_proxy holds a ref so we need to add one */
+
+
+ /* 'ret' will have 2 references.
+ * - One ref is needed because ret->ref->m_proxy holds a refcount to the current proxy.
+ * - Another is needed for returning the value.
+ *
+ * So we should be ok with 2 refs, but for some reason this crashes. so adding a new ref...
+ * */
+
+ return (PyObject *)ret;
+}
+
void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper
{
PyObjectPlus *self_plus= BGE_PROXY_REF(self);
@@ -99,143 +183,56 @@ void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper
self_plus->m_proxy = NULL; /* Need this to stop ~PyObjectPlus from decrefing m_proxy otherwise its decref'd twice and py-debug crashes */
delete self_plus;
}
-
+
BGE_PROXY_REF(self)= NULL; // not really needed
}
+
+#if 0
+ /* is ok normally but not for subtyping, use tp_free instead. */
PyObject_DEL( self );
+#else
+ Py_TYPE(self)->tp_free(self);
+#endif
};
-PyObjectPlus::PyObjectPlus(PyTypeObject *T) : SG_QList() // constructor
+PyObjectPlus::PyObjectPlus() : SG_QList() // constructor
{
- MT_assert(T != NULL);
m_proxy= NULL;
};
-
+
/*------------------------------
* PyObjectPlus Methods -- Every class, even the abstract one should have a Methods
------------------------------*/
PyMethodDef PyObjectPlus::Methods[] = {
- {"isA", (PyCFunction) sPyisA, METH_O},
{NULL, NULL} /* Sentinel */
};
+#define attr_invalid (&(PyObjectPlus::Attributes[0]))
PyAttributeDef PyObjectPlus::Attributes[] = {
KX_PYATTRIBUTE_RO_FUNCTION("invalid", PyObjectPlus, pyattr_get_invalid),
{NULL} //Sentinel
};
-PyObject* PyObjectPlus::pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- Py_RETURN_FALSE;
-}
-/*------------------------------
- * PyObjectPlus Parents -- Every class, even the abstract one should have parents
-------------------------------*/
-PyParentObject PyObjectPlus::Parents[] = {&PyObjectPlus::Type, NULL};
-/*------------------------------
- * PyObjectPlus attributes -- attributes
-------------------------------*/
-
-
-/* This should be the entry in Type since it takes the C++ class from PyObjectPlus_Proxy */
-PyObject *PyObjectPlus::py_base_getattro(PyObject * self, PyObject *attr)
+PyObject* PyObjectPlus::pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
- PyObjectPlus *self_plus= BGE_PROXY_REF(self);
- if(self_plus==NULL) {
- if(!strcmp("invalid", PyString_AsString(attr))) {
- Py_RETURN_TRUE;
- }
- PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- PyObject *ret= self_plus->py_getattro(attr);
-
- /* Attribute not found, was this a __dict__ lookup?, otherwise set an error if none is set */
- if(ret==NULL) {
- char *attr_str= PyString_AsString(attr);
-
- if (strcmp(attr_str, "__dict__")==0)
- {
- /* the error string will probably not
- * be set but just incase clear it */
- PyErr_Clear();
- ret= self_plus->py_getattro_dict();
- }
- else if (!PyErr_Occurred()) {
- /* We looked for an attribute but it wasnt found
- * since py_getattro didnt set the error, set it here */
- PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%s'", self->ob_type->tp_name, attr_str);
- }
- }
- return ret;
+ return PyBool_FromLong(self_v ? 1:0);
}
-/* This should be the entry in Type since it takes the C++ class from PyObjectPlus_Proxy */
-int PyObjectPlus::py_base_setattro(PyObject *self, PyObject *attr, PyObject *value)
+/* note, this is called as a python 'getset, where the PyAttributeDef is the closure */
+PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef *attrdef)
{
- PyObjectPlus *self_plus= BGE_PROXY_REF(self);
- if(self_plus==NULL) {
- PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (value==NULL)
- return self_plus->py_delattro(attr);
-
- return self_plus->py_setattro(attr, value);
-}
+ void *self= (void *)(BGE_PROXY_REF(self_py));
+ if(self==NULL) {
+ if(attrdef == attr_invalid)
+ Py_RETURN_TRUE; // dont bother running the function
-PyObject *PyObjectPlus::py_base_repr(PyObject *self) // This should be the entry in Type.
-{
-
- PyObjectPlus *self_plus= BGE_PROXY_REF(self);
- if(self_plus==NULL) {
PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
return NULL;
}
-
- return self_plus->py_repr();
-}
-PyObject *PyObjectPlus::py_getattro(PyObject* attr)
-{
- PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
- if (descr == NULL) {
- return NULL; /* py_base_getattro sets the error, this way we can avoid setting the error at many levels */
- } else {
- /* Copied from py_getattro_up */
- if (PyCObject_Check(descr)) {
- return py_get_attrdef((void *)this, (const PyAttributeDef*)PyCObject_AsVoidPtr(descr));
- } else if (descr->ob_type->tp_descr_get) {
- return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, this->m_proxy);
- } else {
- return NULL;
- }
- /* end py_getattro_up copy */
- }
-}
-
-PyObject* PyObjectPlus::py_getattro_dict() {
- return py_getattr_dict(NULL, Type.tp_dict);
-}
-int PyObjectPlus::py_delattro(PyObject* attr)
-{
- PyErr_SetString(PyExc_AttributeError, "attribute cant be deleted");
- return 1;
-}
-
-int PyObjectPlus::py_setattro(PyObject *attr, PyObject* value)
-{
- PyErr_SetString(PyExc_AttributeError, "attribute cant be set");
- return PY_SET_ATTR_MISSING;
-}
-
-PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef)
-{
if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
{
// fake attribute, ignore
@@ -259,14 +256,14 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
{
bool *val = reinterpret_cast<bool*>(ptr);
ptr += sizeof(bool);
- PyList_SET_ITEM(resultlist,i,PyInt_FromLong(*val));
+ PyList_SET_ITEM(resultlist,i,PyLong_FromSsize_t(*val));
break;
}
case KX_PYATTRIBUTE_TYPE_SHORT:
{
short int *val = reinterpret_cast<short int*>(ptr);
ptr += sizeof(short int);
- PyList_SET_ITEM(resultlist,i,PyInt_FromLong(*val));
+ PyList_SET_ITEM(resultlist,i,PyLong_FromSsize_t(*val));
break;
}
case KX_PYATTRIBUTE_TYPE_ENUM:
@@ -281,7 +278,7 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
{
int *val = reinterpret_cast<int*>(ptr);
ptr += sizeof(int);
- PyList_SET_ITEM(resultlist,i,PyInt_FromLong(*val));
+ PyList_SET_ITEM(resultlist,i,PyLong_FromSsize_t(*val));
break;
}
case KX_PYATTRIBUTE_TYPE_FLOAT:
@@ -305,12 +302,12 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
case KX_PYATTRIBUTE_TYPE_BOOL:
{
bool *val = reinterpret_cast<bool*>(ptr);
- return PyInt_FromLong(*val);
+ return PyLong_FromSsize_t(*val);
}
case KX_PYATTRIBUTE_TYPE_SHORT:
{
short int *val = reinterpret_cast<short int*>(ptr);
- return PyInt_FromLong(*val);
+ return PyLong_FromSsize_t(*val);
}
case KX_PYATTRIBUTE_TYPE_ENUM:
// enum are like int, just make sure the field size is the same
@@ -322,7 +319,7 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
case KX_PYATTRIBUTE_TYPE_INT:
{
int *val = reinterpret_cast<int*>(ptr);
- return PyInt_FromLong(*val);
+ return PyLong_FromSsize_t(*val);
}
case KX_PYATTRIBUTE_TYPE_FLOAT:
{
@@ -331,18 +328,23 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
}
case KX_PYATTRIBUTE_TYPE_VECTOR:
{
- PyObject* resultlist = PyList_New(3);
MT_Vector3 *val = reinterpret_cast<MT_Vector3*>(ptr);
+#ifdef USE_MATHUTILS
+ float fval[3]= {(*val)[0], (*val)[1], (*val)[2]};
+ return newVectorObject(fval, 3, Py_NEW, NULL);
+#else
+ PyObject* resultlist = PyList_New(3);
for (unsigned int i=0; i<3; i++)
{
PyList_SET_ITEM(resultlist,i,PyFloat_FromDouble((*val)[i]));
}
return resultlist;
+#endif
}
case KX_PYATTRIBUTE_TYPE_STRING:
{
STR_String *val = reinterpret_cast<STR_String*>(ptr);
- return PyString_FromString(*val);
+ return PyUnicode_FromString(*val);
}
default:
return NULL;
@@ -350,8 +352,15 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
}
}
-int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyObject *value)
+/* note, this is called as a python getset */
+int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAttributeDef *attrdef)
{
+ void *self= (void *)(BGE_PROXY_REF(self_py));
+ if(self==NULL) {
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
+ return PY_SET_ATTR_FAIL;
+ }
+
void *undoBuffer = NULL;
void *sourceBuffer = NULL;
size_t bufferSize = 0;
@@ -416,9 +425,9 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
{
bool *var = reinterpret_cast<bool*>(ptr);
ptr += sizeof(bool);
- if (PyInt_Check(item))
+ if (PyLong_Check(item))
{
- *var = (PyInt_AsLong(item) != 0);
+ *var = (PyLong_AsSsize_t(item) != 0);
}
else if (PyBool_Check(item))
{
@@ -435,9 +444,9 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
{
short int *var = reinterpret_cast<short int*>(ptr);
ptr += sizeof(short int);
- if (PyInt_Check(item))
+ if (PyLong_Check(item))
{
- long val = PyInt_AsLong(item);
+ long val = PyLong_AsSsize_t(item);
if (attrdef->m_clamp)
{
if (val < attrdef->m_imin)
@@ -471,9 +480,9 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
{
int *var = reinterpret_cast<int*>(ptr);
ptr += sizeof(int);
- if (PyInt_Check(item))
+ if (PyLong_Check(item))
{
- long val = PyInt_AsLong(item);
+ long val = PyLong_AsSsize_t(item);
if (attrdef->m_clamp)
{
if (val < attrdef->m_imin)
@@ -606,9 +615,9 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
case KX_PYATTRIBUTE_TYPE_BOOL:
{
bool *var = reinterpret_cast<bool*>(ptr);
- if (PyInt_Check(value))
+ if (PyLong_Check(value))
{
- *var = (PyInt_AsLong(value) != 0);
+ *var = (PyLong_AsSsize_t(value) != 0);
}
else if (PyBool_Check(value))
{
@@ -624,9 +633,9 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
case KX_PYATTRIBUTE_TYPE_SHORT:
{
short int *var = reinterpret_cast<short int*>(ptr);
- if (PyInt_Check(value))
+ if (PyLong_Check(value))
{
- long val = PyInt_AsLong(value);
+ long val = PyLong_AsSsize_t(value);
if (attrdef->m_clamp)
{
if (val < attrdef->m_imin)
@@ -659,9 +668,9 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
case KX_PYATTRIBUTE_TYPE_INT:
{
int *var = reinterpret_cast<int*>(ptr);
- if (PyInt_Check(value))
+ if (PyLong_Check(value))
{
- long val = PyInt_AsLong(value);
+ long val = PyLong_AsSsize_t(value);
if (attrdef->m_clamp)
{
if (val < attrdef->m_imin)
@@ -746,9 +755,9 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
case KX_PYATTRIBUTE_TYPE_STRING:
{
STR_String *var = reinterpret_cast<STR_String*>(ptr);
- if (PyString_Check(value))
+ if (PyUnicode_Check(value))
{
- char *val = PyString_AsString(value);
+ char *val = _PyUnicode_AsString(value);
if (attrdef->m_clamp)
{
if (strlen(val) < attrdef->m_imin)
@@ -829,48 +838,6 @@ PyObject *PyObjectPlus::py_repr(void)
return NULL;
}
-/*------------------------------
- * PyObjectPlus isA -- the isA functions
-------------------------------*/
-bool PyObjectPlus::isA(PyTypeObject *T) // if called with a Type, use "typename"
-{
- int i;
- PyParentObject P;
- PyParentObject *Ps = GetParents();
-
- for (P = Ps[i=0]; P != NULL; P = Ps[i++])
- if (P==T)
- return true;
-
- return false;
-}
-
-
-bool PyObjectPlus::isA(const char *mytypename) // check typename of each parent
-{
- int i;
- PyParentObject P;
- PyParentObject *Ps = GetParents();
-
- for (P = Ps[i=0]; P != NULL; P = Ps[i++])
- if (strcmp(P->tp_name, mytypename)==0)
- return true;
-
- return false;
-}
-
-PyObject *PyObjectPlus::PyisA(PyObject *value) // Python wrapper for isA
-{
- if (PyType_Check(value)) {
- return PyBool_FromLong(isA((PyTypeObject *)value));
- } else if (PyString_Check(value)) {
- return PyBool_FromLong(isA(PyString_AsString(value)));
- }
- PyErr_SetString(PyExc_TypeError, "object.isA(value): expected a type or a string");
- return NULL;
-}
-
-
void PyObjectPlus::ProcessReplica()
{
/* Clear the proxy, will be created again if needed with GetProxy()
@@ -895,27 +862,6 @@ void PyObjectPlus::InvalidateProxy() // check typename of each parent
}
}
-/* Utility function called by the macro py_getattro_up()
- * for getting ob.__dict__() values from our PyObject
- * this is used by python for doing dir() on an object, so its good
- * if we return a list of attributes and methods.
- *
- * Other then making dir() useful the value returned from __dict__() is not useful
- * since every value is a Py_None
- * */
-PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict)
-{
- if(pydict==NULL) { /* incase calling __dict__ on the parent of this object raised an error */
- PyErr_Clear();
- pydict = PyDict_New();
- }
-
- PyDict_Update(pydict, tp_dict);
- return pydict;
-}
-
-
-
PyObject *PyObjectPlus::GetProxy_Ext(PyObjectPlus *self, PyTypeObject *tp)
{
if (self->m_proxy==NULL)
@@ -986,7 +932,7 @@ void PyObjectPlus::ShowDeprecationWarning_func(const char* old_way,const char* n
co_filename= PyObject_GetAttrString(f_code, "co_filename");
if (co_filename) {
- printf("\t%s:%d\n", PyString_AsString(co_filename), (int)PyInt_AsLong(f_lineno));
+ printf("\t%s:%d\n", _PyUnicode_AsString(co_filename), (int)PyLong_AsSsize_t(f_lineno));
Py_DECREF(f_lineno);
Py_DECREF(f_code);
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index c002dccefe4..a18df9d36a9 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -45,21 +45,15 @@
* Python defines
------------------------------*/
-
-
-#if PY_VERSION_HEX > 0x03000000
-#define PyString_FromString PyUnicode_FromString
-#define PyString_FromFormat PyUnicode_FromFormat
-#define PyString_Check PyUnicode_Check
-#define PyString_Size PyUnicode_GetSize
-
-#define PyInt_FromLong PyLong_FromSsize_t
-#define PyInt_AsLong PyLong_AsSsize_t
-#define PyString_AsString _PyUnicode_AsString
-#define PyInt_Check PyLong_Check
-#define PyInt_AS_LONG PyLong_AsLong // TODO - check this one
+#ifdef USE_MATHUTILS
+extern "C" {
+#include "../../blender/python/generic/Mathutils.h" /* so we can have mathutils callbacks */
+}
#endif
+extern "C" {
+#include "../../blender/python/intern/bpy_compat.h"
+}
/*
@@ -141,7 +135,7 @@ typedef struct {
#define BGE_PROXY_PYOWNS(_self) (((PyObjectPlus_Proxy *)_self)->py_owns)
/* Note, sometimes we dont care what BGE type this is as long as its a proxy */
-#define BGE_PROXY_CHECK_TYPE(_self) ((_self)->ob_type->tp_dealloc == PyObjectPlus::py_base_dealloc)
+#define BGE_PROXY_CHECK_TYPE(_type) ((_type)->tp_dealloc == PyObjectPlus::py_base_dealloc)
// This must be the first line of each
@@ -151,41 +145,10 @@ typedef struct {
static PyTypeObject Type; \
static PyMethodDef Methods[]; \
static PyAttributeDef Attributes[]; \
- static PyParentObject Parents[]; \
virtual PyTypeObject *GetType(void) {return &Type;}; \
- virtual PyParentObject *GetParents(void) {return Parents;} \
virtual PyObject *GetProxy() {return GetProxy_Ext(this, &Type);}; \
virtual PyObject *NewProxy(bool py_owns) {return NewProxy_Ext(this, &Type, py_owns);}; \
-
-
-
- // This defines the py_getattro_up macro
- // which allows attribute and method calls
- // to be properly passed up the hierarchy.
- //
- // Note, PyDict_GetItem() WONT set an exception!
- // let the py_base_getattro function do this.
-
-#define py_getattro_up(Parent) \
- \
- PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
- \
- if(descr) { \
- if (PyCObject_Check(descr)) { \
- return py_get_attrdef((void *)this, (const PyAttributeDef*)PyCObject_AsVoidPtr(descr)); \
- } else if (descr->ob_type->tp_descr_get) { \
- return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, this->m_proxy); \
- } else { \
- return NULL; \
- } \
- } else { \
- return Parent::py_getattro(attr); \
- }
-
-#define py_getattro_dict_up(Parent) \
- return py_getattr_dict(Parent::py_getattro_dict(), Type.tp_dict);
-
/*
* nonzero values are an error for setattr
* however because of the nested lookups we need to know if the errors
@@ -197,29 +160,6 @@ typedef struct {
#define PY_SET_ATTR_MISSING -1
#define PY_SET_ATTR_SUCCESS 0
-#define py_setattro_up(Parent) \
- PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
- \
- if(descr) { \
- if (PyCObject_Check(descr)) { \
- const PyAttributeDef* attrdef= reinterpret_cast<const PyAttributeDef *>(PyCObject_AsVoidPtr(descr)); \
- if (attrdef->m_access == KX_PYATTRIBUTE_RO) { \
- PyErr_Format(PyExc_AttributeError, "\"%s\" is read only", PyString_AsString(attr)); \
- return PY_SET_ATTR_FAIL; \
- } \
- else { \
- return py_set_attrdef((void *)this, attrdef, value); \
- } \
- } else { \
- PyErr_Format(PyExc_AttributeError, "\"%s\" cannot be set", PyString_AsString(attr)); \
- return PY_SET_ATTR_FAIL; \
- } \
- } else { \
- PyErr_Clear(); \
- return Parent::py_setattro(attr, value); \
- }
-
-
/**
* These macros are helpfull when embedding Python routines. The second
* macro is one that also requires a documentation string
@@ -489,7 +429,7 @@ class PyObjectPlus : public SG_QList
Py_Header; // Always start with Py_Header
public:
- PyObjectPlus(PyTypeObject *T);
+ PyObjectPlus();
PyObject *m_proxy; /* actually a PyObjectPlus_Proxy */
@@ -497,30 +437,19 @@ public:
/* These static functions are referenced by ALL PyObjectPlus_Proxy types
* they take the C++ reference from the PyObjectPlus_Proxy and call
- * its own virtual py_getattro, py_setattro etc. functions.
+ * its own virtual py_repr, py_base_dealloc ,etc. functions.
*/
+
+ static PyObject* py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* allows subclassing */
static void py_base_dealloc(PyObject *self);
- static PyObject* py_base_getattro(PyObject * self, PyObject *attr);
- static int py_base_setattro(PyObject *self, PyObject *attr, PyObject *value);
static PyObject* py_base_repr(PyObject *self);
/* These are all virtual python methods that are defined in each class
* Our own fake subclassing calls these on each class, then calls the parent */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_delattro(PyObject *attr);
- virtual int py_setattro(PyObject *attr, PyObject *value);
virtual PyObject* py_repr(void);
- static PyObject* py_get_attrdef(void *self, const PyAttributeDef *attrdef);
- static int py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyObject *value);
-
- /* isA() methods, shonky replacement for pythons issubclass()
- * which we cant use because we have our own subclass system */
- bool isA(PyTypeObject *T);
- bool isA(const char *mytypename);
-
- KX_PYMETHOD_O(PyObjectPlus,isA);
+ static PyObject* py_get_attrdef(PyObject *self_py, const PyAttributeDef *attrdef);
+ static int py_set_attrdef(PyObject *self_py, PyObject *value, const PyAttributeDef *attrdef);
/* Kindof dumb, always returns True, the false case is checked for, before this function gets accessed */
static PyObject* pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Expressions/SConscript b/source/gameengine/Expressions/SConscript
index 12d4a163c86..69f87ffbb90 100644
--- a/source/gameengine/Expressions/SConscript
+++ b/source/gameengine/Expressions/SConscript
@@ -3,12 +3,13 @@ Import ('env')
sources = env.Glob('*.cpp')
-incs ='. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/SceneGraph'
+incs ='. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/SceneGraph #source/blender/blenloader'
incs += ' ' + env['BF_PYTHON_INC']
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
-env.BlenderLib ( 'bf_expressions', sources, Split(incs), [], libtype=['game','player'], priority = [45,125], cxx_compileflags=cxxflags)
+env.BlenderLib ( 'bf_expressions', sources, Split(incs), [], libtype=['core','player'], priority = [360,120], cxx_compileflags=cxxflags)
diff --git a/source/gameengine/Expressions/StringValue.h b/source/gameengine/Expressions/StringValue.h
index 52f8a580f4d..c580e8fd23a 100644
--- a/source/gameengine/Expressions/StringValue.h
+++ b/source/gameengine/Expressions/StringValue.h
@@ -40,7 +40,7 @@ public:
virtual void SetValue(CValue* newval) { m_strString = newval->GetText(); SetModified(true); };
virtual CValue* GetReplica();
virtual PyObject* ConvertValueToPython() {
- return PyString_FromString(m_strString.Ptr());
+ return PyUnicode_FromString(m_strString.Ptr());
}
private:
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index 61dabff510b..d8c81f56f66 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -54,15 +54,17 @@ PyTypeObject CValue::Type = {
py_base_repr,
0,
0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
- 0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject CValue::Parents[] = {
- &CValue::Type,
- NULL
+ NULL,
+ NULL,
+ 0,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &PyObjectPlus::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef CValue::Methods[] = {
@@ -74,7 +76,7 @@ PyObject* CValue::PyGetName()
{
ShowDeprecationWarning("getName()", "the name property");
- return PyString_FromString(this->GetName());
+ return PyUnicode_FromString(this->GetName());
}
/*#define CVALUE_DEBUG*/
@@ -100,8 +102,8 @@ std::vector<SmartCValueRef> gRefList;
//int gRefCountValue;
#endif
-CValue::CValue(PyTypeObject *T)
- : PyObjectPlus(T),
+CValue::CValue()
+ : PyObjectPlus(),
#else
CValue::CValue()
:
@@ -553,33 +555,9 @@ PyAttributeDef CValue::Attributes[] = {
{ NULL } //Sentinel
};
-
-PyObject* CValue::py_getattro(PyObject *attr)
-{
- char *attr_str= PyString_AsString(attr);
- CValue* resultattr = GetProperty(attr_str);
- if (resultattr)
- {
- /* only show the wanting here because python inspects for __class__ and KX_MeshProxy uses CValues name attr */
- ShowDeprecationWarning("val = ob.attr", "val = ob['attr']");
-
- PyObject* pyconvert = resultattr->ConvertValueToPython();
-
- if (pyconvert)
- return pyconvert;
- else
- return resultattr->GetProxy();
- }
- py_getattro_up(PyObjectPlus);
-}
-
-PyObject* CValue::py_getattro_dict() {
- py_getattro_dict_up(PyObjectPlus);
-}
-
PyObject * CValue::pyattr_get_name(void * self_v, const KX_PYATTRIBUTE_DEF * attrdef) {
CValue * self = static_cast<CValue *> (self_v);
- return PyString_FromString(self->GetName());
+ return PyUnicode_FromString(self->GetName());
}
CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix)
@@ -623,30 +601,23 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix)
{
vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) );
} else
+#if PY_VERSION_HEX < 0x03000000
if (PyInt_Check(pyobj))
{
vallie = new CIntValue( (cInt)PyInt_AS_LONG(pyobj) );
} else
+#endif
if (PyLong_Check(pyobj))
{
vallie = new CIntValue( (cInt)PyLong_AsLongLong(pyobj) );
} else
- if (PyString_Check(pyobj))
+ if (PyUnicode_Check(pyobj))
{
- vallie = new CStringValue(PyString_AsString(pyobj),"");
+ vallie = new CStringValue(_PyUnicode_AsString(pyobj),"");
} else
- if (BGE_PROXY_CHECK_TYPE(pyobj)) /* Note, dont let these get assigned to GameObject props, must check elsewhere */
+ if (PyObject_TypeCheck(pyobj, &CValue::Type)) /* Note, dont let these get assigned to GameObject props, must check elsewhere */
{
- if (BGE_PROXY_REF(pyobj) && (BGE_PROXY_REF(pyobj))->isA(&CValue::Type))
- {
- vallie = (static_cast<CValue *>(BGE_PROXY_REF(pyobj)))->AddRef();
- } else {
-
- if(BGE_PROXY_REF(pyobj)) /* this is not a CValue */
- PyErr_Format(PyExc_TypeError, "%sgame engine python type cannot be used as a property", error_prefix);
- else /* PyObjectPlus_Proxy has been removed, cant use */
- PyErr_Format(PyExc_SystemError, "%s"BGE_PROXY_ERROR_MSG, error_prefix);
- }
+ vallie = (static_cast<CValue *>(BGE_PROXY_REF(pyobj)))->AddRef();
} else
{
/* return an error value from the caller */
@@ -656,57 +627,6 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix)
}
-int CValue::py_delattro(PyObject *attr)
-{
- ShowDeprecationWarning("del ob.attr", "del ob['attr']");
-
- char *attr_str= PyString_AsString(attr);
- if (RemoveProperty(attr_str))
- return 0;
-
- PyErr_Format(PyExc_AttributeError, "attribute \"%s\" dosnt exist", attr_str);
- return PY_SET_ATTR_MISSING;
-}
-
-int CValue::py_setattro(PyObject *attr, PyObject* pyobj)
-{
- ShowDeprecationWarning("ob.attr = val", "ob['attr'] = val");
-
- char *attr_str= PyString_AsString(attr);
- CValue* oldprop = GetProperty(attr_str);
- CValue* vallie;
-
- /* Dissallow python to assign GameObjects, Scenes etc as values */
- if ((BGE_PROXY_CHECK_TYPE(pyobj)==0) && (vallie = ConvertPythonToValue(pyobj, "cvalue.attr = value: ")))
- {
- if (oldprop)
- oldprop->SetValue(vallie);
- else
- SetProperty(attr_str, vallie);
-
- vallie->Release();
- }
- else {
- // ConvertPythonToValue sets the error message
- // must return missing so KX_GameObect knows this
- // attribute was not a function or bult in attribute,
- //
- // CValue attributes override internal attributes
- // so if it exists as a CValue attribute already,
- // assume your trying to set it to a differnt CValue attribute
- // otherwise return PY_SET_ATTR_MISSING so children
- // classes know they can set it without conflict
-
- if (GetProperty(attr_str))
- return PY_SET_ATTR_COERCE_FAIL; /* failed to set an existing attribute */
- else
- return PY_SET_ATTR_MISSING; /* allow the KX_GameObject dict to set */
- }
-
- //PyObjectPlus::py_setattro(attr,value);
- return PY_SET_ATTR_SUCCESS;
-};
-
PyObject* CValue::ConvertKeysToPython( void )
{
PyObject *pylist = PyList_New( 0 );
@@ -717,7 +637,7 @@ PyObject* CValue::ConvertKeysToPython( void )
std::map<STR_String,CValue*>::iterator it;
for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++)
{
- pystr = PyString_FromString( (*it).first );
+ pystr = PyUnicode_FromString( (*it).first );
PyList_Append(pylist, pystr);
Py_DECREF( pystr );
}
diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h
index 29ef19b46c9..8c9f99b335e 100644
--- a/source/gameengine/Expressions/Value.h
+++ b/source/gameengine/Expressions/Value.h
@@ -215,26 +215,18 @@ public:
// Construction / Destruction
#ifndef NO_EXP_PYTHON_EMBEDDING
- CValue(PyTypeObject *T = &Type);
+ CValue();
//static PyObject* PyMake(PyObject*,PyObject*);
virtual PyObject *py_repr(void)
{
- return PyString_FromString((const char*)GetText());
+ return PyUnicode_FromString((const char*)GetText());
}
-
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
virtual PyObject* ConvertValueToPython() {
return NULL;
}
virtual CValue* ConvertPythonToValue(PyObject* pyobj, const char *error_prefix);
-
-
- virtual int py_delattro(PyObject *attr);
- virtual int py_setattro(PyObject *attr, PyObject* value);
static PyObject * pyattr_get_name(void * self, const KX_PYATTRIBUTE_DEF * attrdef);
@@ -417,8 +409,8 @@ class CPropValue : public CValue
public:
#ifndef NO_EXP_PYTHON_EMBEDDING
- CPropValue(PyTypeObject* T=&Type) :
- CValue(T),
+ CPropValue() :
+ CValue(),
#else
CPropValue() :
#endif //NO_EXP_PYTHON_EMBEDDING
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt
index 7e2bc85bd1f..530664dce55 100644
--- a/source/gameengine/GameLogic/CMakeLists.txt
+++ b/source/gameengine/GameLogic/CMakeLists.txt
@@ -35,8 +35,13 @@ SET(INC
../../../intern/moto/include
../../../source/gameengine/Rasterizer
${PYTHON_INC}
- ${SDL_INC}
)
+IF(WITH_SDL)
+ SET(INC ${INC} ${SDL_INC})
+ELSE(WITH_SDL)
+ ADD_DEFINITIONS(-DDISABLE_SDL)
+ENDIF(WITH_SDL)
+
BLENDERLIB(bf_logic "${SRC}" "${INC}")
#env.BlenderLib ( 'bf_logic', sources, Split(incs), [], libtype=['game','player'], priority=[30, 110] )
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
index caed85b9938..04d46e259d3 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
@@ -42,9 +42,8 @@ SCA_2DFilterActuator::SCA_2DFilterActuator(
float float_arg,
int int_arg,
RAS_IRasterizer* rasterizer,
- RAS_IRenderTools* rendertools,
- PyTypeObject* T)
- : SCA_IActuator(gameobj, T),
+ RAS_IRenderTools* rendertools)
+ : SCA_IActuator(gameobj),
m_type(type),
m_disableMotionBlur(flag),
m_float_arg(float_arg),
@@ -124,23 +123,17 @@ PyTypeObject SCA_2DFilterActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-PyParentObject SCA_2DFilterActuator::Parents[] = {
- &SCA_2DFilterActuator::Type,
- &SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &SCA_IActuator::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-
PyMethodDef SCA_2DFilterActuator::Methods[] = {
/* add python functions to deal with m_msg... */
{NULL,NULL}
@@ -154,18 +147,3 @@ PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg),
{ NULL } //Sentinel
};
-
-PyObject* SCA_2DFilterActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* SCA_2DFilterActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int SCA_2DFilterActuator::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
index 13b9997a010..c357c4f3e37 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
@@ -56,23 +56,12 @@ public:
float float_arg,
int int_arg,
RAS_IRasterizer* rasterizer,
- RAS_IRenderTools* rendertools,
- PyTypeObject* T=&Type
- );
+ RAS_IRenderTools* rendertools);
void SetShaderText(const char *text);
virtual ~SCA_2DFilterActuator();
virtual bool Update();
virtual CValue* GetReplica();
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
-
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp
index 87f7c612e7c..78e1350428e 100644
--- a/source/gameengine/GameLogic/SCA_ANDController.cpp
+++ b/source/gameengine/GameLogic/SCA_ANDController.cpp
@@ -42,10 +42,9 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
-SCA_ANDController::SCA_ANDController(SCA_IObject* gameobj,
- PyTypeObject* T)
+SCA_ANDController::SCA_ANDController(SCA_IObject* gameobj)
:
- SCA_IController(gameobj,T)
+ SCA_IController(gameobj)
{
}
@@ -116,19 +115,15 @@ PyTypeObject SCA_ANDController::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_ANDController::Parents[] = {
- &SCA_ANDController::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IController::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_ANDController::Methods[] = {
@@ -139,12 +134,4 @@ PyAttributeDef SCA_ANDController::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_ANDController::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IController);
-}
-
-PyObject* SCA_ANDController::py_getattro_dict() {
- py_getattro_dict_up(SCA_IController);
-}
-
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ANDController.h b/source/gameengine/GameLogic/SCA_ANDController.h
index 9a359d57cb4..cb16d7fca01 100644
--- a/source/gameengine/GameLogic/SCA_ANDController.h
+++ b/source/gameengine/GameLogic/SCA_ANDController.h
@@ -39,18 +39,10 @@ class SCA_ANDController : public SCA_IController
Py_Header;
//virtual void Trigger(class SCA_LogicManager* logicmgr);
public:
- SCA_ANDController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ SCA_ANDController(SCA_IObject* gameobj);
virtual ~SCA_ANDController();
virtual CValue* GetReplica();
virtual void Trigger(SCA_LogicManager* logicmgr);
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
-
};
#endif //__KX_ANDCONTROLLER
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
index 4dad65c5a25..bdcc923e1d9 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
@@ -40,9 +40,8 @@
SCA_ActuatorSensor::SCA_ActuatorSensor(SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
- const STR_String& actname,
- PyTypeObject* T )
- : SCA_ISensor(gameobj,eventmgr,T),
+ const STR_String& actname)
+ : SCA_ISensor(gameobj,eventmgr),
m_checkactname(actname)
{
m_actuator = GetParent()->FindActuator(m_checkactname);
@@ -138,19 +137,15 @@ PyTypeObject SCA_ActuatorSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_ActuatorSensor::Parents[] = {
- &SCA_ActuatorSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_ActuatorSensor::Methods[] = {
@@ -166,18 +161,6 @@ PyAttributeDef SCA_ActuatorSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_ActuatorSensor::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* SCA_ActuatorSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int SCA_ActuatorSensor::py_setattro(PyObject *attr, PyObject *value) {
- py_setattro_up(SCA_ISensor);
-}
-
int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
{
SCA_ActuatorSensor* sensor = reinterpret_cast<SCA_ActuatorSensor*>(self);
@@ -197,7 +180,7 @@ const char SCA_ActuatorSensor::GetActuator_doc[] =
PyObject* SCA_ActuatorSensor::PyGetActuator()
{
ShowDeprecationWarning("getActuator()", "the actuator property");
- return PyString_FromString(m_checkactname);
+ return PyUnicode_FromString(m_checkactname);
}
/* 4. setActuator */
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
index 6655e08dc70..cf8e735cad4 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
@@ -46,8 +46,7 @@ class SCA_ActuatorSensor : public SCA_ISensor
public:
SCA_ActuatorSensor(class SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
- const STR_String& actname,
- PyTypeObject* T=&Type );
+ const STR_String& actname);
virtual ~SCA_ActuatorSensor();
virtual CValue* GetReplica();
@@ -61,10 +60,6 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
/* 3. setProperty */
KX_PYMETHOD_DOC_VARARGS(SCA_ActuatorSensor,SetActuator);
/* 4. getProperty */
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
index ff02680f191..ddb54c580b8 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
@@ -48,9 +48,8 @@
/* ------------------------------------------------------------------------- */
SCA_AlwaysSensor::SCA_AlwaysSensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- PyTypeObject* T)
- : SCA_ISensor(gameobj,eventmgr, T)
+ SCA_IObject* gameobj)
+ : SCA_ISensor(gameobj,eventmgr)
{
//SetDrawColor(255,0,0);
Init();
@@ -121,19 +120,15 @@ PyTypeObject SCA_AlwaysSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_AlwaysSensor::Parents[] = {
- &SCA_AlwaysSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_AlwaysSensor::Methods[] = {
@@ -144,12 +139,4 @@ PyAttributeDef SCA_AlwaysSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_AlwaysSensor::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* SCA_AlwaysSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.h b/source/gameengine/GameLogic/SCA_AlwaysSensor.h
index 0f85a641ef1..d58e05564d1 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.h
@@ -39,22 +39,12 @@ class SCA_AlwaysSensor : public SCA_ISensor
bool m_alwaysresult;
public:
SCA_AlwaysSensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- PyTypeObject* T =&Type);
+ SCA_IObject* gameobj);
virtual ~SCA_AlwaysSensor();
virtual CValue* GetReplica();
virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
-
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
-
};
#endif //__KX_ALWAYSSENSOR
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
index dcdae0b4e75..11c6996a0a1 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
@@ -51,9 +51,8 @@ SCA_DelaySensor::SCA_DelaySensor(class SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
int delay,
int duration,
- bool repeat,
- PyTypeObject* T)
- : SCA_ISensor(gameobj,eventmgr, T),
+ bool repeat)
+ : SCA_ISensor(gameobj,eventmgr),
m_repeat(repeat),
m_delay(delay),
m_duration(duration)
@@ -147,19 +146,15 @@ PyTypeObject SCA_DelaySensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_DelaySensor::Parents[] = {
- &SCA_DelaySensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_DelaySensor::Methods[] = {
@@ -183,19 +178,6 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_DelaySensor::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* SCA_DelaySensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int SCA_DelaySensor::py_setattro(PyObject *attr, PyObject *value) {
- py_setattro_up(SCA_ISensor);
-}
-
-
const char SCA_DelaySensor::SetDelay_doc[] =
"setDelay(delay)\n"
"\t- delay: length of the initial OFF period as number of frame\n"
@@ -262,7 +244,7 @@ const char SCA_DelaySensor::GetDelay_doc[] =
PyObject* SCA_DelaySensor::PyGetDelay()
{
ShowDeprecationWarning("getDelay()", "the delay property");
- return PyInt_FromLong(m_delay);
+ return PyLong_FromSsize_t(m_delay);
}
const char SCA_DelaySensor::GetDuration_doc[] =
@@ -271,7 +253,7 @@ const char SCA_DelaySensor::GetDuration_doc[] =
PyObject* SCA_DelaySensor::PyGetDuration()
{
ShowDeprecationWarning("getDuration()", "the duration property");
- return PyInt_FromLong(m_duration);
+ return PyLong_FromSsize_t(m_duration);
}
const char SCA_DelaySensor::GetRepeat_doc[] =
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h
index 5ccb33f8a16..8270e8959b7 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.h
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.h
@@ -47,8 +47,7 @@ public:
SCA_IObject* gameobj,
int delay,
int duration,
- bool repeat,
- PyTypeObject* T =&Type);
+ bool repeat);
virtual ~SCA_DelaySensor();
virtual CValue* GetReplica();
virtual bool Evaluate();
@@ -59,10 +58,6 @@ public:
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
/* setProperty */
KX_PYMETHOD_DOC_VARARGS(SCA_DelaySensor,SetDelay);
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
index 8e044b89c71..60969300474 100644
--- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp
+++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
@@ -46,9 +46,8 @@
/* ------------------------------------------------------------------------- */
SCA_ExpressionController::SCA_ExpressionController(SCA_IObject* gameobj,
- const STR_String& exprtext,
- PyTypeObject* T)
- :SCA_IController(gameobj,T),
+ const STR_String& exprtext)
+ :SCA_IController(gameobj),
m_exprText(exprtext),
m_exprCache(NULL)
{
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h
index 6a34d7b2dff..705f6dfc415 100644
--- a/source/gameengine/GameLogic/SCA_ExpressionController.h
+++ b/source/gameengine/GameLogic/SCA_ExpressionController.h
@@ -42,8 +42,7 @@ class SCA_ExpressionController : public SCA_IController
public:
SCA_ExpressionController(SCA_IObject* gameobj,
- const STR_String& exprtext,
- PyTypeObject* T=&Type );
+ const STR_String& exprtext);
virtual ~SCA_ExpressionController();
virtual CValue* GetReplica();
@@ -54,14 +53,6 @@ public:
* so that self references are removed before the controller itself is released
*/
virtual void Delete();
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
-// virtual PyObject* py_getattro(PyObject *attr);
-// virtual PyObject* py_getattro_dict();
-
};
#endif //__KX_EXPRESSIONCONTROLLER
diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp
index be7c2651686..0fda75590c1 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_IActuator.cpp
@@ -34,9 +34,8 @@
using namespace std;
-SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj,
- PyTypeObject* T) :
- SCA_ILogicBrick(gameobj,T),
+SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj) :
+ SCA_ILogicBrick(gameobj),
m_links(0),
m_posevent(false),
m_negevent(false)
diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h
index 27afcbc386b..13c718ee837 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.h
+++ b/source/gameengine/GameLogic/SCA_IActuator.h
@@ -61,8 +61,7 @@ public:
* This class also inherits the default copy constructors
*/
- SCA_IActuator(SCA_IObject* gameobj,
- PyTypeObject* T =&Type);
+ SCA_IActuator(SCA_IObject* gameobj);
/**
* UnlinkObject(...)
diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp
index f2c3c83a2d9..7cbb728753a 100644
--- a/source/gameengine/GameLogic/SCA_IController.cpp
+++ b/source/gameengine/GameLogic/SCA_IController.cpp
@@ -37,10 +37,9 @@
#include <config.h>
#endif
-SCA_IController::SCA_IController(SCA_IObject* gameobj,
- PyTypeObject* T)
+SCA_IController::SCA_IController(SCA_IObject* gameobj)
:
- SCA_ILogicBrick(gameobj,T),
+ SCA_ILogicBrick(gameobj),
m_statemask(0),
m_justActivated(false)
{
@@ -216,17 +215,15 @@ PyTypeObject SCA_IController::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_IController::Parents[] = {
- &SCA_IController::Type,
- &CValue::Type,
- NULL
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &SCA_ILogicBrick::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_IController::Methods[] = {
@@ -248,22 +245,6 @@ PyAttributeDef SCA_IController::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_IController::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_ILogicBrick);
-}
-
-PyObject* SCA_IController::py_getattro_dict() {
- py_getattro_dict_up(SCA_ILogicBrick);
-}
-
-int SCA_IController::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_ILogicBrick);
-}
-
-
-
PyObject* SCA_IController::PyGetActuators()
{
ShowDeprecationWarning("getActuators()", "the actuators property");
@@ -281,7 +262,7 @@ PyObject* SCA_IController::PyGetSensor(PyObject* value)
{
ShowDeprecationWarning("getSensor(string)", "the sensors[string] property");
- char *scriptArg = PyString_AsString(value);
+ char *scriptArg = _PyUnicode_AsString(value);
if (scriptArg==NULL) {
PyErr_SetString(PyExc_TypeError, "controller.getSensor(string): Python Controller, expected a string (sensor name)");
return NULL;
@@ -305,7 +286,7 @@ PyObject* SCA_IController::PyGetActuator(PyObject* value)
{
ShowDeprecationWarning("getActuator(string)", "the actuators[string] property");
- char *scriptArg = PyString_AsString(value);
+ char *scriptArg = _PyUnicode_AsString(value);
if (scriptArg==NULL) {
PyErr_SetString(PyExc_TypeError, "controller.getActuator(string): Python Controller, expected a string (actuator name)");
return NULL;
@@ -340,13 +321,13 @@ PyObject* SCA_IController::PyGetSensors()
PyObject* SCA_IController::PyGetState()
{
ShowDeprecationWarning("getState()", "the state property");
- return PyInt_FromLong(m_statemask);
+ return PyLong_FromSsize_t(m_statemask);
}
PyObject* SCA_IController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_IController* self= static_cast<SCA_IController*>(self_v);
- return PyInt_FromLong(self->m_statemask);
+ return PyLong_FromSsize_t(self->m_statemask);
}
PyObject* SCA_IController::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h
index a52c57ab3ed..523878bee26 100644
--- a/source/gameengine/GameLogic/SCA_IController.h
+++ b/source/gameengine/GameLogic/SCA_IController.h
@@ -47,7 +47,7 @@ protected:
bool m_justActivated;
bool m_bookmark;
public:
- SCA_IController(SCA_IObject* gameobj,PyTypeObject* T);
+ SCA_IController(SCA_IObject* gameobj);
virtual ~SCA_IController();
virtual void Trigger(class SCA_LogicManager* logicmgr)=0;
void LinkToSensor(SCA_ISensor* sensor);
@@ -98,10 +98,6 @@ public:
}
}
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
KX_PYMETHOD_NOARGS(SCA_IController,GetSensors);
KX_PYMETHOD_NOARGS(SCA_IController,GetActuators);
KX_PYMETHOD_O(SCA_IController,GetSensor);
diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h
index 66ad457aa03..a0d77ed3c03 100644
--- a/source/gameengine/GameLogic/SCA_IInputDevice.h
+++ b/source/gameengine/GameLogic/SCA_IInputDevice.h
@@ -75,7 +75,6 @@ public:
KX_TIMER0,
KX_TIMER1,
KX_TIMER2,
- KX_TIMER3,
// SYSTEM
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
index 2dc80f54568..ccb79a2d49f 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
@@ -35,10 +35,9 @@
SCA_LogicManager* SCA_ILogicBrick::m_sCurrentLogicManager = NULL;
-SCA_ILogicBrick::SCA_ILogicBrick(SCA_IObject* gameobj,
- PyTypeObject* T)
+SCA_ILogicBrick::SCA_ILogicBrick(SCA_IObject* gameobj)
:
- CValue(T),
+ CValue(),
m_gameobj(gameobj),
m_Execute_Priority(0),
m_Execute_Ueber_Priority(0),
@@ -194,23 +193,17 @@ PyTypeObject SCA_ILogicBrick::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject SCA_ILogicBrick::Parents[] = {
- &SCA_ILogicBrick::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef SCA_ILogicBrick::Methods[] = {
// --> Deprecated
{"getOwner", (PyCFunction) SCA_ILogicBrick::sPyGetOwner, METH_NOARGS},
@@ -245,21 +238,6 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
return 0;
}
-PyObject* SCA_ILogicBrick::py_getattro(PyObject *attr)
-{
- py_getattro_up(CValue);
-}
-
-PyObject* SCA_ILogicBrick::py_getattro_dict() {
- py_getattro_dict_up(CValue);
-}
-
-int SCA_ILogicBrick::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(CValue);
-}
-
-
PyObject* SCA_ILogicBrick::PyGetOwner()
{
ShowDeprecationWarning("getOwner()", "the owner property");
@@ -296,7 +274,7 @@ PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* args)
PyObject* SCA_ILogicBrick::PyGetExecutePriority()
{
ShowDeprecationWarning("getExecutePriority()", "the executePriority property");
- return PyInt_FromLong(m_Execute_Priority);
+ return PyLong_FromSsize_t(m_Execute_Priority);
}
@@ -326,5 +304,5 @@ bool SCA_ILogicBrick::PyArgToBool(int boolArg)
PyObject* SCA_ILogicBrick::BoolToPyArg(bool boolarg)
{
- return PyInt_FromLong(boolarg? KX_TRUE: KX_FALSE);
+ return PyLong_FromSsize_t(boolarg? KX_TRUE: KX_FALSE);
}
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h
index 779e5397a6a..50679856802 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.h
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h
@@ -53,7 +53,7 @@ protected:
CValue* GetEvent();
public:
- SCA_ILogicBrick(SCA_IObject* gameobj,PyTypeObject* T );
+ SCA_ILogicBrick(SCA_IObject* gameobj);
virtual ~SCA_ILogicBrick();
void SetExecutePriority(int execute_Priority);
@@ -121,10 +121,6 @@ public:
}
virtual bool LessComparedTo(SCA_ILogicBrick* other);
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
static class SCA_LogicManager* m_sCurrentLogicManager;
diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp
index 9876f2512c0..6cd11f9e553 100644
--- a/source/gameengine/GameLogic/SCA_IObject.cpp
+++ b/source/gameengine/GameLogic/SCA_IObject.cpp
@@ -41,8 +41,11 @@
MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0);
SG_QList SCA_IObject::m_activeBookmarkedControllers;
-SCA_IObject::SCA_IObject(PyTypeObject* T): CValue(T), m_initState(0), m_state(0), m_firstState(NULL)
-
+SCA_IObject::SCA_IObject():
+ CValue(),
+ m_initState(0),
+ m_state(0),
+ m_firstState(NULL)
{
m_suspended = false;
}
@@ -218,51 +221,6 @@ SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname)
}
-
-#if 0
-const MT_Point3& SCA_IObject::ConvertPythonPylist(PyObject* pylist)
-{
- bool error = false;
- m_sDummy = MT_Vector3(0,0,0);
- if (pylist->ob_type == &CListValue::Type)
- {
- CListValue* listval = (CListValue*) pylist;
- int numelem = listval->GetCount();
- if ( numelem <= 3)
- {
- int index;
- for (index = 0;index<numelem;index++)
- {
- m_sDummy[index] = listval->GetValue(index)->GetNumber();
- }
- } else
- {
- error = true;
- }
-
- } else
- {
-
- // assert the list is long enough...
- int numitems = PyList_Size(pylist);
- if (numitems <= 3)
- {
- int index;
- for (index=0;index<numitems;index++)
- {
- m_sDummy[index] = PyFloat_AsDouble(PyList_GetItem(pylist,index));
- }
- }
- else
- {
- error = true;
- }
-
- }
- return m_sDummy;
-}
-#endif
-
void SCA_IObject::Suspend()
{
if ((!m_ignore_activity_culling)
@@ -346,23 +304,17 @@ PyTypeObject SCA_IObject::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject SCA_IObject::Parents[] = {
- &SCA_IObject::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef SCA_IObject::Methods[] = {
//{"setOrientation", (PyCFunction) SCA_IObject::sPySetOrientation, METH_VARARGS},
//{"getOrientation", (PyCFunction) SCA_IObject::sPyGetOrientation, METH_VARARGS},
@@ -372,12 +324,3 @@ PyMethodDef SCA_IObject::Methods[] = {
PyAttributeDef SCA_IObject::Attributes[] = {
{ NULL } //Sentinel
};
-
-
-PyObject* SCA_IObject::py_getattro(PyObject *attr) {
- py_getattro_up(CValue);
-}
-
-PyObject* SCA_IObject::py_getattro_dict() {
- py_getattro_dict_up(CValue);
-}
diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h
index eae427741ca..3060410dc6b 100644
--- a/source/gameengine/GameLogic/SCA_IObject.h
+++ b/source/gameengine/GameLogic/SCA_IObject.h
@@ -105,7 +105,7 @@ protected:
public:
- SCA_IObject(PyTypeObject* T=&Type);
+ SCA_IObject();
virtual ~SCA_IObject();
SCA_ControllerList& GetControllers()
@@ -199,15 +199,12 @@ public:
unsigned int GetState(void) { return m_state; }
// const class MT_Point3& ConvertPythonPylist(PyObject* pylist);
-
- // here come the python forwarded methods
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
virtual int GetGameObjectType() {return -1;}
typedef enum ObjectTypes {
OBJ_ARMATURE=0,
+ OBJ_CAMERA=1,
}ObjectTypes;
};
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
index 2783bf14600..4c1e0bd01c4 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ISensor.cpp
@@ -50,9 +50,8 @@ void SCA_ISensor::ReParent(SCA_IObject* parent)
SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj,
- class SCA_EventManager* eventmgr,
- PyTypeObject* T ) :
- SCA_ILogicBrick(gameobj,T)
+ class SCA_EventManager* eventmgr) :
+ SCA_ILogicBrick(gameobj)
{
m_links = 0;
m_suspended = false;
@@ -301,7 +300,7 @@ PyObject* SCA_ISensor::PyIsPositive()
{
ShowDeprecationWarning("isPositive()", "the read-only positive property");
int retval = GetState();
- return PyInt_FromLong(retval);
+ return PyLong_FromSsize_t(retval);
}
const char SCA_ISensor::IsTriggered_doc[] =
@@ -314,7 +313,7 @@ PyObject* SCA_ISensor::PyIsTriggered()
int retval = 0;
if (SCA_PythonController::m_sCurrentController)
retval = SCA_PythonController::m_sCurrentController->IsTriggered(this);
- return PyInt_FromLong(retval);
+ return PyLong_FromSsize_t(retval);
}
/**
@@ -355,7 +354,7 @@ const char SCA_ISensor::GetFrequency_doc[] =
PyObject* SCA_ISensor::PyGetFrequency()
{
ShowDeprecationWarning("getFrequency()", "the frequency property");
- return PyInt_FromLong(m_pulse_frequency);
+ return PyLong_FromSsize_t(m_pulse_frequency);
}
/**
@@ -489,19 +488,17 @@ PyTypeObject SCA_ISensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_ISensor::Parents[] = {
- &SCA_ISensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
+
PyMethodDef SCA_ISensor::Methods[] = {
//Deprecated functions ----->
{"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive,
@@ -548,19 +545,6 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_ISensor::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_ILogicBrick);
-}
-
-PyObject* SCA_ISensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ILogicBrick);
-}
-
-int SCA_ISensor::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_ILogicBrick);
-}
PyObject* SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
@@ -568,13 +552,13 @@ PyObject* SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_D
int retval = 0;
if (SCA_PythonController::m_sCurrentController)
retval = SCA_PythonController::m_sCurrentController->IsTriggered(self);
- return PyInt_FromLong(retval);
+ return PyLong_FromSsize_t(retval);
}
PyObject* SCA_ISensor::pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);
- return PyInt_FromLong(self->GetState());
+ return PyLong_FromSsize_t(self->GetState());
}
int SCA_ISensor::pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
index 9bbd6ed41e4..81864ab6a34 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ b/source/gameengine/GameLogic/SCA_ISensor.h
@@ -101,8 +101,7 @@ public:
};
SCA_ISensor(SCA_IObject* gameobj,
- class SCA_EventManager* eventmgr,
- PyTypeObject* T );;
+ class SCA_EventManager* eventmgr);;
~SCA_ISensor();
virtual void ReParent(SCA_IObject* parent);
@@ -173,10 +172,6 @@ public:
{ return !m_links; }
/* Python functions: */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
//Deprecated functions ----->
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive);
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 336529667d7..f55921e648b 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -46,9 +46,8 @@ SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr,
short int joymode,
int axis, int axisf,int prec,
int button,
- int hat, int hatf, bool allevents,
- PyTypeObject* T )
- :SCA_ISensor(gameobj,eventmgr,T),
+ int hat, int hatf, bool allevents)
+ :SCA_ISensor(gameobj,eventmgr),
m_pJoystickMgr(eventmgr),
m_axis(axis),
m_axisf(axisf),
@@ -269,23 +268,17 @@ PyTypeObject SCA_JoystickSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-PyParentObject SCA_JoystickSensor::Parents[] = {
- &SCA_JoystickSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
PyMethodDef SCA_JoystickSensor::Methods[] = {
//Deprecated functions ------>
{"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, (PY_METHODCHAR)GetIndex_doc},
@@ -328,20 +321,6 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_JoystickSensor::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* SCA_JoystickSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int SCA_JoystickSensor::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_ISensor);
-}
-
/* get index ---------------------------------------------------------- */
const char SCA_JoystickSensor::GetIndex_doc[] =
@@ -349,7 +328,7 @@ const char SCA_JoystickSensor::GetIndex_doc[] =
"\tReturns the joystick index to use.\n";
PyObject* SCA_JoystickSensor::PyGetIndex( ) {
ShowDeprecationWarning("getIndex()", "the index property");
- return PyInt_FromLong(m_joyindex);
+ return PyLong_FromSsize_t(m_joyindex);
}
@@ -359,7 +338,7 @@ const char SCA_JoystickSensor::SetIndex_doc[] =
"\tSets the joystick index to use.\n";
PyObject* SCA_JoystickSensor::PySetIndex( PyObject* value ) {
ShowDeprecationWarning("setIndex()", "the index property");
- int index = PyInt_AsLong( value ); /* -1 on error, will raise an error in this case */
+ int index = PyLong_AsSsize_t( value ); /* -1 on error, will raise an error in this case */
if (index < 0 || index >= JOYINDEX_MAX) {
PyErr_SetString(PyExc_ValueError, "joystick index out of range or not an int");
return NULL;
@@ -410,7 +389,7 @@ PyObject* SCA_JoystickSensor::PyGetAxisValue( ) {
PyObject *list= PyList_New(axis_index);
while(axis_index--) {
- PyList_SET_ITEM(list, axis_index, PyInt_FromLong(joy->GetAxisPosition(axis_index)));
+ PyList_SET_ITEM(list, axis_index, PyLong_FromSsize_t(joy->GetAxisPosition(axis_index)));
}
return list;
@@ -423,7 +402,7 @@ const char SCA_JoystickSensor::GetThreshold_doc[] =
"\tReturns the threshold of the axis.\n";
PyObject* SCA_JoystickSensor::PyGetThreshold( ) {
ShowDeprecationWarning("getThreshold()", "the threshold property");
- return PyInt_FromLong(m_precision);
+ return PyLong_FromSsize_t(m_precision);
}
@@ -447,7 +426,7 @@ const char SCA_JoystickSensor::GetButton_doc[] =
"\tReturns the current button this sensor is checking.\n";
PyObject* SCA_JoystickSensor::PyGetButton( ) {
ShowDeprecationWarning("getButton()", "the button property");
- return PyInt_FromLong(m_button);
+ return PyLong_FromSsize_t(m_button);
}
/* set button -------------------------------------------------------- */
@@ -456,7 +435,7 @@ const char SCA_JoystickSensor::SetButton_doc[] =
"\tSets the button the sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PySetButton( PyObject* value ) {
ShowDeprecationWarning("setButton()", "the button property");
- int button = PyInt_AsLong(value);
+ int button = PyLong_AsSsize_t(value);
if(button==-1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "expected an int");
return NULL;
@@ -487,7 +466,7 @@ PyObject* SCA_JoystickSensor::PyGetButtonActiveList( ) {
if(joy) {
for (i=0; i < joy->GetNumberOfButtons(); i++) {
if (joy->aButtonPressIsPositive(i)) {
- value = PyInt_FromLong(i);
+ value = PyLong_FromSsize_t(i);
PyList_Append(ls, value);
Py_DECREF(value);
}
@@ -549,7 +528,7 @@ PyObject* SCA_JoystickSensor::PyNumberOfAxes( ) {
ShowDeprecationWarning("getNumAxes()", "the numAxis property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
// when the joystick is null their is 0 exis still. dumb but scripters should use isConnected()
- return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
+ return PyLong_FromSsize_t( joy ? joy->GetNumberOfAxes() : 0 );
}
@@ -559,7 +538,7 @@ const char SCA_JoystickSensor::NumberOfButtons_doc[] =
PyObject* SCA_JoystickSensor::PyNumberOfButtons( ) {
ShowDeprecationWarning("getNumButtons()", "the numButtons property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
- return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
+ return PyLong_FromSsize_t( joy ? joy->GetNumberOfButtons() : 0 );
}
@@ -569,7 +548,7 @@ const char SCA_JoystickSensor::NumberOfHats_doc[] =
PyObject* SCA_JoystickSensor::PyNumberOfHats( ) {
ShowDeprecationWarning("getNumHats()", "the numHats property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
- return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
+ return PyLong_FromSsize_t( joy ? joy->GetNumberOfHats() : 0 );
}
const char SCA_JoystickSensor::Connected_doc[] =
@@ -591,7 +570,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYAT
PyObject *list= PyList_New(axis_index);
while(axis_index--) {
- PyList_SET_ITEM(list, axis_index, PyInt_FromLong(joy->GetAxisPosition(axis_index)));
+ PyList_SET_ITEM(list, axis_index, PyLong_FromSsize_t(joy->GetAxisPosition(axis_index)));
}
return list;
@@ -607,7 +586,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT
return NULL;
}
- return PyInt_FromLong(joy->GetAxisPosition(self->m_axis-1));
+ return PyLong_FromSsize_t(joy->GetAxisPosition(self->m_axis-1));
}
PyObject* SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -619,7 +598,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATT
PyObject *list= PyList_New(hat_index);
while(hat_index--) {
- PyList_SET_ITEM(list, hat_index, PyInt_FromLong(joy->GetHat(hat_index)));
+ PyList_SET_ITEM(list, hat_index, PyLong_FromSsize_t(joy->GetHat(hat_index)));
}
return list;
@@ -630,28 +609,28 @@ PyObject* SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATT
SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex);
- return PyInt_FromLong(joy->GetHat(self->m_hat-1));
+ return PyLong_FromSsize_t(joy->GetHat(self->m_hat-1));
}
PyObject* SCA_JoystickSensor::pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex);
- return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
+ return PyLong_FromSsize_t( joy ? joy->GetNumberOfAxes() : 0 );
}
PyObject* SCA_JoystickSensor::pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex);
- return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
+ return PyLong_FromSsize_t( joy ? joy->GetNumberOfButtons() : 0 );
}
PyObject* SCA_JoystickSensor::pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex);
- return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
+ return PyLong_FromSsize_t( joy ? joy->GetNumberOfHats() : 0 );
}
PyObject* SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index e6a1d2eef32..32f8ce567d2 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -106,8 +106,7 @@ public:
short int joymode,
int axis, int axisf,int prec,
int button,
- int hat, int hatf, bool allevents,
- PyTypeObject* T=&Type );
+ int hat, int hatf, bool allevents);
virtual ~SCA_JoystickSensor();
virtual CValue* GetReplica();
@@ -123,10 +122,6 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
/* Joystick Index */
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex);
KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetIndex);
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index f8ee8ed8b41..999e34dfa36 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -48,9 +48,8 @@ SCA_KeyboardSensor::SCA_KeyboardSensor(SCA_KeyboardManager* keybdmgr,
bool bAllKeys,
const STR_String& targetProp,
const STR_String& toggleProp,
- SCA_IObject* gameobj,
- PyTypeObject* T )
- :SCA_ISensor(gameobj,keybdmgr,T),
+ SCA_IObject* gameobj)
+ :SCA_ISensor(gameobj,keybdmgr),
m_pKeyboardMgr(keybdmgr),
m_hotkey(hotkey),
m_qual(qual),
@@ -418,7 +417,7 @@ const char SCA_KeyboardSensor::GetKey_doc[] =
PyObject* SCA_KeyboardSensor::PyGetKey()
{
ShowDeprecationWarning("getKey()", "the key property");
- return PyInt_FromLong(m_hotkey);
+ return PyLong_FromSsize_t(m_hotkey);
}
/** 2. SetKey: change the key to look at */
@@ -450,7 +449,7 @@ const char SCA_KeyboardSensor::GetHold1_doc[] =
PyObject* SCA_KeyboardSensor::PyGetHold1()
{
ShowDeprecationWarning("getHold1()", "the hold1 property");
- return PyInt_FromLong(m_qual);
+ return PyLong_FromSsize_t(m_qual);
}
/** 4. SetHold1: change the first bucky bit */
@@ -482,7 +481,7 @@ const char SCA_KeyboardSensor::GetHold2_doc[] =
PyObject* SCA_KeyboardSensor::PyGetHold2()
{
ShowDeprecationWarning("getHold2()", "the hold2 property");
- return PyInt_FromLong(m_qual2);
+ return PyLong_FromSsize_t(m_qual2);
}
/** 6. SetHold2: change the second bucky bit */
@@ -532,8 +531,8 @@ PyObject* SCA_KeyboardSensor::PyGetPressedKeys()
|| (inevent.m_status == SCA_InputEvent::KX_JUSTRELEASED))
{
PyObject* keypair = PyList_New(2);
- PyList_SET_ITEM(keypair,0,PyInt_FromLong(i));
- PyList_SET_ITEM(keypair,1,PyInt_FromLong(inevent.m_status));
+ PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i));
+ PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status));
PyList_SET_ITEM(resultlist,index,keypair);
index++;
@@ -572,8 +571,8 @@ PyObject* SCA_KeyboardSensor::PyGetCurrentlyPressedKeys()
|| (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED))
{
PyObject* keypair = PyList_New(2);
- PyList_SET_ITEM(keypair,0,PyInt_FromLong(i));
- PyList_SET_ITEM(keypair,1,PyInt_FromLong(inevent.m_status));
+ PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i));
+ PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status));
PyList_SET_ITEM(resultlist,index,keypair);
index++;
@@ -592,12 +591,12 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
"getKeyStatus(keycode)\n"
"\tGet the given key's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n")
{
- if (!PyInt_Check(value)) {
+ if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_ValueError, "sensor.getKeyStatus(int): Keyboard Sensor, expected an int");
return NULL;
}
- int keycode = PyInt_AsLong(value);
+ int keycode = PyLong_AsSsize_t(value);
if ((keycode < SCA_IInputDevice::KX_BEGINKEY)
|| (keycode > SCA_IInputDevice::KX_ENDKEY)){
@@ -607,7 +606,7 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) keycode);
- return PyInt_FromLong(inevent.m_status);
+ return PyLong_FromSsize_t(inevent.m_status);
}
/* ------------------------------------------------------------------------- */
@@ -631,19 +630,15 @@ PyTypeObject SCA_KeyboardSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_KeyboardSensor::Parents[] = {
- &SCA_KeyboardSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_KeyboardSensor::Methods[] = {
@@ -672,20 +667,6 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_KeyboardSensor::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* SCA_KeyboardSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int SCA_KeyboardSensor::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_ISensor);
-}
-
PyObject* SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
@@ -701,8 +682,8 @@ PyObject* SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBU
if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
{
PyObject* keypair = PyList_New(2);
- PyList_SET_ITEM(keypair,0,PyInt_FromLong(i));
- PyList_SET_ITEM(keypair,1,PyInt_FromLong(inevent.m_status));
+ PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i));
+ PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status));
PyList_Append(resultlist,keypair);
}
}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
index 033225cd9be..3185b386d41 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
@@ -94,8 +94,7 @@ public:
bool bAllKeys,
const STR_String& targetProp,
const STR_String& toggleProp,
- SCA_IObject* gameobj,
- PyTypeObject* T=&Type );
+ SCA_IObject* gameobj);
virtual ~SCA_KeyboardSensor();
virtual CValue* GetReplica();
virtual void Init();
@@ -110,10 +109,6 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
//Deprecated functions ----->
/** 1. GetKey : check which key this sensor looks at */
KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,GetKey);
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp
index 83271288154..b782c6dfb93 100644
--- a/source/gameengine/GameLogic/SCA_LogicManager.cpp
+++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp
@@ -307,6 +307,7 @@ void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_I
controller->Activate(m_triggeredControllerSet);
// so that the controller knows which sensor has activited it
// only needed for python controller
+ // Note that this is safe even if the controller is subclassed.
if (controller->GetType() == &SCA_PythonController::Type)
{
SCA_PythonController* pythonController = (SCA_PythonController*)controller;
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
index c5e1c3c0441..49fa19dce38 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
@@ -49,9 +49,8 @@
SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
int startx,int starty,
short int mousemode,
- SCA_IObject* gameobj,
- PyTypeObject* T)
- : SCA_ISensor(gameobj,eventmgr, T),
+ SCA_IObject* gameobj)
+ : SCA_ISensor(gameobj,eventmgr),
m_pMouseMgr(eventmgr),
m_x(startx),
m_y(starty)
@@ -254,7 +253,7 @@ const char SCA_MouseSensor::GetXPosition_doc[] =
"\tpixels\n";
PyObject* SCA_MouseSensor::PyGetXPosition() {
ShowDeprecationWarning("getXPosition()", "the position property");
- return PyInt_FromLong(m_x);
+ return PyLong_FromSsize_t(m_x);
}
/* get y position ---------------------------------------------------------- */
@@ -265,7 +264,7 @@ const char SCA_MouseSensor::GetYPosition_doc[] =
"\tpixels\n";
PyObject* SCA_MouseSensor::PyGetYPosition() {
ShowDeprecationWarning("getYPosition()", "the position property");
- return PyInt_FromLong(m_y);
+ return PyLong_FromSsize_t(m_y);
}
//<----- Deprecated
@@ -273,9 +272,9 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
"getButtonStatus(button)\n"
"\tGet the given button's status (KX_INPUT_NONE, KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED).\n")
{
- if (PyInt_Check(value))
+ if (PyLong_Check(value))
{
- int button = PyInt_AsLong(value);
+ int button = PyLong_AsSsize_t(value);
if ((button < SCA_IInputDevice::KX_LEFTMOUSE)
|| (button > SCA_IInputDevice::KX_RIGHTMOUSE)){
@@ -285,7 +284,7 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
const SCA_InputEvent& event = mousedev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) button);
- return PyInt_FromLong(event.m_status);
+ return PyLong_FromSsize_t(event.m_status);
}
Py_RETURN_NONE;
@@ -312,19 +311,15 @@ PyTypeObject SCA_MouseSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_MouseSensor::Parents[] = {
- &SCA_MouseSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_MouseSensor::Methods[] = {
@@ -342,18 +337,4 @@ PyAttributeDef SCA_MouseSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_MouseSensor::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* SCA_MouseSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int SCA_MouseSensor::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_ISensor);
-}
-
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h
index 6d6302b514a..47f0378bf69 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.h
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.h
@@ -92,8 +92,7 @@ class SCA_MouseSensor : public SCA_ISensor
SCA_MouseSensor(class SCA_MouseManager* keybdmgr,
int startx,int starty,
short int mousemode,
- SCA_IObject* gameobj,
- PyTypeObject* T=&Type );
+ SCA_IObject* gameobj);
virtual ~SCA_MouseSensor();
virtual CValue* GetReplica();
@@ -109,10 +108,6 @@ class SCA_MouseSensor : public SCA_ISensor
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
//Deprecated functions ----->
/* read x-coordinate */
KX_PYMETHOD_DOC_NOARGS(SCA_MouseSensor,GetXPosition);
diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp
index d27aea5e6f7..c00e5d6e617 100644
--- a/source/gameengine/GameLogic/SCA_NANDController.cpp
+++ b/source/gameengine/GameLogic/SCA_NANDController.cpp
@@ -42,10 +42,9 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
-SCA_NANDController::SCA_NANDController(SCA_IObject* gameobj,
- PyTypeObject* T)
+SCA_NANDController::SCA_NANDController(SCA_IObject* gameobj)
:
- SCA_IController(gameobj,T)
+ SCA_IController(gameobj)
{
}
@@ -116,19 +115,15 @@ PyTypeObject SCA_NANDController::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_NANDController::Parents[] = {
- &SCA_NANDController::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IController::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_NANDController::Methods[] = {
@@ -139,12 +134,4 @@ PyAttributeDef SCA_NANDController::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_NANDController::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IController);
-}
-
-PyObject* SCA_NANDController::py_getattro_dict() {
- py_getattro_dict_up(SCA_IController);
-}
-
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_NANDController.h b/source/gameengine/GameLogic/SCA_NANDController.h
index 0ae0ff19745..36a145e5f2b 100644
--- a/source/gameengine/GameLogic/SCA_NANDController.h
+++ b/source/gameengine/GameLogic/SCA_NANDController.h
@@ -39,7 +39,7 @@ class SCA_NANDController : public SCA_IController
Py_Header;
//virtual void Trigger(class SCA_LogicManager* logicmgr);
public:
- SCA_NANDController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ SCA_NANDController(SCA_IObject* gameobj);
virtual ~SCA_NANDController();
virtual CValue* GetReplica();
virtual void Trigger(SCA_LogicManager* logicmgr);
@@ -47,10 +47,6 @@ public:
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
-
};
#endif //__KX_NANDCONTROLLER
diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp
index 6c9141636b2..9762d44fd5d 100644
--- a/source/gameengine/GameLogic/SCA_NORController.cpp
+++ b/source/gameengine/GameLogic/SCA_NORController.cpp
@@ -42,10 +42,9 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
-SCA_NORController::SCA_NORController(SCA_IObject* gameobj,
- PyTypeObject* T)
+SCA_NORController::SCA_NORController(SCA_IObject* gameobj)
:
- SCA_IController(gameobj,T)
+ SCA_IController(gameobj)
{
}
@@ -116,19 +115,15 @@ PyTypeObject SCA_NORController::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_NORController::Parents[] = {
- &SCA_NORController::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IController::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_NORController::Methods[] = {
@@ -139,12 +134,4 @@ PyAttributeDef SCA_NORController::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_NORController::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IController);
-}
-
-PyObject* SCA_NORController::py_getattro_dict() {
- py_getattro_dict_up(SCA_IController);
-}
-
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_NORController.h b/source/gameengine/GameLogic/SCA_NORController.h
index 06cbb70a489..b96232375d6 100644
--- a/source/gameengine/GameLogic/SCA_NORController.h
+++ b/source/gameengine/GameLogic/SCA_NORController.h
@@ -39,18 +39,10 @@ class SCA_NORController : public SCA_IController
Py_Header;
//virtual void Trigger(class SCA_LogicManager* logicmgr);
public:
- SCA_NORController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ SCA_NORController(SCA_IObject* gameobj);
virtual ~SCA_NORController();
virtual CValue* GetReplica();
virtual void Trigger(SCA_LogicManager* logicmgr);
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
-
};
#endif //__KX_NORCONTROLLER
diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp
index 42c0a67d657..a526dd8353c 100644
--- a/source/gameengine/GameLogic/SCA_ORController.cpp
+++ b/source/gameengine/GameLogic/SCA_ORController.cpp
@@ -42,9 +42,8 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
-SCA_ORController::SCA_ORController(SCA_IObject* gameobj,
- PyTypeObject* T)
- :SCA_IController(gameobj, T)
+SCA_ORController::SCA_ORController(SCA_IObject* gameobj)
+ :SCA_IController(gameobj)
{
}
@@ -110,19 +109,15 @@ PyTypeObject SCA_ORController::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_ORController::Parents[] = {
- &SCA_ORController::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IController::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_ORController::Methods[] = {
@@ -133,13 +128,4 @@ PyAttributeDef SCA_ORController::Attributes[] = {
{ NULL } //Sentinel
};
-
-PyObject* SCA_ORController::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IController);
-}
-
-PyObject* SCA_ORController::py_getattro_dict() {
- py_getattro_dict_up(SCA_IController);
-}
-
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ORController.h b/source/gameengine/GameLogic/SCA_ORController.h
index 66f772c739e..09d31a85190 100644
--- a/source/gameengine/GameLogic/SCA_ORController.h
+++ b/source/gameengine/GameLogic/SCA_ORController.h
@@ -39,18 +39,11 @@ class SCA_ORController : public SCA_IController
Py_Header;
//virtual void Trigger(class SCA_LogicManager* logicmgr);
public:
- SCA_ORController(SCA_IObject* gameobj, PyTypeObject* T=&Type);
+ SCA_ORController(SCA_IObject* gameobj);
virtual ~SCA_ORController();
virtual CValue* GetReplica();
virtual void Trigger(SCA_LogicManager* logicmgr);
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
};
#endif //__KX_ORCONTROLLER
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 4faa4b55d4a..215e30eceaf 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -42,8 +42,8 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
-SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,SCA_IObject* sourceObj,const STR_String& propname,const STR_String& expr,int acttype,PyTypeObject* T )
- : SCA_IActuator(gameobj,T),
+SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,SCA_IObject* sourceObj,const STR_String& propname,const STR_String& expr,int acttype)
+ : SCA_IActuator(gameobj),
m_type(acttype),
m_propname(propname),
m_exprtxt(expr),
@@ -244,19 +244,15 @@ PyTypeObject SCA_PropertyActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_PropertyActuator::Parents[] = {
- &SCA_PropertyActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_PropertyActuator::Methods[] = {
@@ -276,18 +272,6 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_PropertyActuator::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* SCA_PropertyActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int SCA_PropertyActuator::py_setattro(PyObject *attr, PyObject *value) {
- py_setattro_up(SCA_IActuator);
-}
-
/* 1. setProperty */
const char SCA_PropertyActuator::SetProperty_doc[] =
"setProperty(name)\n"
@@ -322,7 +306,7 @@ const char SCA_PropertyActuator::GetProperty_doc[] =
PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* args, PyObject* kwds)
{
ShowDeprecationWarning("getProperty()", "the 'propName' property");
- return PyString_FromString(m_propname);
+ return PyUnicode_FromString(m_propname);
}
/* 3. setValue */
@@ -352,7 +336,7 @@ const char SCA_PropertyActuator::GetValue_doc[] =
PyObject* SCA_PropertyActuator::PyGetValue(PyObject* args, PyObject* kwds)
{
ShowDeprecationWarning("getValue()", "the value property");
- return PyString_FromString(m_exprtxt);
+ return PyUnicode_FromString(m_exprtxt);
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index a8df08dfc6e..8fb2e7a7bc5 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -64,9 +64,7 @@ public:
SCA_IObject* sourceObj,
const STR_String& propname,
const STR_String& expr,
- int acttype,
- PyTypeObject* T=&Type
- );
+ int acttype);
~SCA_PropertyActuator();
@@ -86,10 +84,6 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
// python wrapped methods
KX_PYMETHOD_DOC(SCA_PropertyActuator,SetProperty);
KX_PYMETHOD_DOC(SCA_PropertyActuator,GetProperty);
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index 3b343af3cba..6d2e1a0aca5 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -48,9 +48,8 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
const STR_String& propname,
const STR_String& propval,
const STR_String& propmaxval,
- KX_PROPSENSOR_TYPE checktype,
- PyTypeObject* T )
- : SCA_ISensor(gameobj,eventmgr,T),
+ KX_PROPSENSOR_TYPE checktype)
+ : SCA_ISensor(gameobj,eventmgr),
m_checktype(checktype),
m_checkpropval(propval),
m_checkpropmaxval(propmaxval),
@@ -319,19 +318,15 @@ PyTypeObject SCA_PropertySensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_PropertySensor::Parents[] = {
- &SCA_PropertySensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_PropertySensor::Methods[] = {
@@ -353,19 +348,6 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = {
{ NULL } //Sentinel
};
-
-PyObject* SCA_PropertySensor::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* SCA_PropertySensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int SCA_PropertySensor::py_setattro(PyObject *attr, PyObject *value) {
- py_setattro_up(SCA_ISensor);
-}
-
/* 1. getType */
const char SCA_PropertySensor::GetType_doc[] =
"getType()\n"
@@ -373,7 +355,7 @@ const char SCA_PropertySensor::GetType_doc[] =
PyObject* SCA_PropertySensor::PyGetType()
{
ShowDeprecationWarning("getType()", "the mode property");
- return PyInt_FromLong(m_checktype);
+ return PyLong_FromSsize_t(m_checktype);
}
/* 2. setType */
@@ -407,7 +389,7 @@ const char SCA_PropertySensor::GetProperty_doc[] =
PyObject* SCA_PropertySensor::PyGetProperty()
{
ShowDeprecationWarning("getProperty()", "the 'propName' property");
- return PyString_FromString(m_checkpropname);
+ return PyUnicode_FromString(m_checkpropname);
}
/* 4. setProperty */
@@ -444,7 +426,7 @@ const char SCA_PropertySensor::GetValue_doc[] =
PyObject* SCA_PropertySensor::PyGetValue()
{
ShowDeprecationWarning("getValue()", "the value property");
- return PyString_FromString(m_checkpropval);
+ return PyUnicode_FromString(m_checkpropval);
}
/* 6. setValue */
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h
index 538ecd65949..3513fcdf5ae 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.h
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.h
@@ -67,8 +67,7 @@ public:
const STR_String& propname,
const STR_String& propval,
const STR_String& propmaxval,
- KX_PROPSENSOR_TYPE checktype,
- PyTypeObject* T=&Type );
+ KX_PROPSENSOR_TYPE checktype);
/**
* For property sensor, it is used to release the pre-calculated expression
@@ -89,10 +88,6 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
/* 1. getType */
KX_PYMETHOD_DOC_NOARGS(SCA_PropertySensor,GetType);
/* 2. setType */
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index 80e4f54c9c5..ffd95f00699 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -47,10 +47,8 @@
SCA_PythonController* SCA_PythonController::m_sCurrentController = NULL;
-SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj,
- int mode,
- PyTypeObject* T)
- : SCA_IController(gameobj, T),
+SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode)
+ : SCA_IController(gameobj),
m_bytecode(NULL),
m_function(NULL),
m_function_argc(0),
@@ -150,7 +148,7 @@ void SCA_PythonController::SetDictionary(PyObject* pythondictionary)
/* Without __file__ set the sys.argv[0] is used for the filename
* which ends up with lines from the blender binary being printed in the console */
- PyDict_SetItemString(m_pythondictionary, "__file__", PyString_FromString(m_scriptName.Ptr()));
+ PyDict_SetItemString(m_pythondictionary, "__file__", PyUnicode_FromString(m_scriptName.Ptr()));
}
@@ -180,16 +178,16 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
std::vector<SCA_IActuator*> lacts = m_sCurrentController->GetLinkedActuators();
std::vector<SCA_IActuator*>::iterator it;
- if (PyString_Check(value)) {
+ if (PyUnicode_Check(value)) {
/* get the actuator from the name */
- char *name= PyString_AsString(value);
+ char *name= _PyUnicode_AsString(value);
for(it = lacts.begin(); it!= lacts.end(); ++it) {
if( name == (*it)->GetName() ) {
return *it;
}
}
}
- else if (BGE_PROXY_CHECK_TYPE(value)) {
+ else if (PyObject_TypeCheck(value, &SCA_IActuator::Type)) {
PyObjectPlus *value_plus= BGE_PROXY_REF(value);
for(it = lacts.begin(); it!= lacts.end(); ++it) {
if( static_cast<SCA_IActuator*>(value_plus) == (*it) ) {
@@ -200,7 +198,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
/* set the exception */
PyObject *value_str = PyObject_Repr(value); /* new ref */
- PyErr_Format(PyExc_ValueError, "'%s' not in this python controllers actuator list", PyString_AsString(value_str));
+ PyErr_Format(PyExc_ValueError, "'%s' not in this python controllers actuator list", _PyUnicode_AsString(value_str));
Py_DECREF(value_str);
return false;
@@ -245,19 +243,17 @@ PyTypeObject SCA_PythonController::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &SCA_IController::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-PyParentObject SCA_PythonController::Parents[] = {
- &SCA_PythonController::Type,
- &SCA_IController::Type,
- &CValue::Type,
- NULL
-};
PyMethodDef SCA_PythonController::Methods[] = {
{"activate", (PyCFunction) SCA_PythonController::sPyActivate, METH_O},
{"deactivate", (PyCFunction) SCA_PythonController::sPyDeActivate, METH_O},
@@ -490,22 +486,6 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
m_sCurrentController = NULL;
}
-
-
-PyObject* SCA_PythonController::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IController);
-}
-
-PyObject* SCA_PythonController::py_getattro_dict() {
- py_getattro_dict_up(SCA_IController);
-}
-
-int SCA_PythonController::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_IController);
-}
-
PyObject* SCA_PythonController::PyActivate(PyObject *value)
{
if(m_sCurrentController != this) {
@@ -540,13 +520,13 @@ PyObject* SCA_PythonController::PyDeActivate(PyObject *value)
PyObject* SCA_PythonController::PyGetScript()
{
ShowDeprecationWarning("getScript()", "the script property");
- return PyString_FromString(m_scriptText);
+ return PyUnicode_FromString(m_scriptText);
}
/* 2. setScript */
PyObject* SCA_PythonController::PySetScript(PyObject* value)
{
- char *scriptArg = PyString_AsString(value);
+ char *scriptArg = _PyUnicode_AsString(value);
ShowDeprecationWarning("setScript()", "the script property");
@@ -565,15 +545,20 @@ PyObject* SCA_PythonController::PySetScript(PyObject* value)
PyObject* SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
+ //SCA_PythonController* self= static_cast<SCA_PythonController*>(static_cast<SCA_IController*>(static_cast<SCA_ILogicBrick*>(static_cast<CValue*>(static_cast<PyObjectPlus*>(self_v)))));
+ // static_cast<void *>(dynamic_cast<Derived *>(obj)) - static_cast<void *>(obj)
+
SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v);
- return PyString_FromString(self->m_scriptText);
+ return PyUnicode_FromString(self->m_scriptText);
}
+
+
int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v);
- char *scriptArg = PyString_AsString(value);
+ char *scriptArg = _PyUnicode_AsString(value);
if (scriptArg==NULL) {
PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text");
diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h
index 0c2af79c3a3..9311b3f355e 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.h
+++ b/source/gameengine/GameLogic/SCA_PythonController.h
@@ -72,7 +72,7 @@ class SCA_PythonController : public SCA_IController
//virtual CValue* AddRef();
//virtual int Release(); // Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
- SCA_PythonController(SCA_IObject* gameobj, int mode, PyTypeObject* T = &Type);
+ SCA_PythonController(SCA_IObject* gameobj, int mode);
virtual ~SCA_PythonController();
virtual CValue* GetReplica();
@@ -96,10 +96,6 @@ class SCA_PythonController : public SCA_IController
static PyObject* sPyAddActiveActuator(PyObject* self,
PyObject* args);
static SCA_IActuator* LinkedActuatorFromPy(PyObject *value);
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
KX_PYMETHOD_O(SCA_PythonController,Activate);
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index a722590dd10..e903d10f9a5 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -50,9 +50,8 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
SCA_RandomActuator::KX_RANDOMACT_MODE mode,
float para1,
float para2,
- const STR_String &propName,
- PyTypeObject* T)
- : SCA_IActuator(gameobj, T),
+ const STR_String &propName)
+ : SCA_IActuator(gameobj),
m_propname(propName),
m_parameter1(para1),
m_parameter2(para2),
@@ -332,19 +331,15 @@ PyTypeObject SCA_RandomActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_RandomActuator::Parents[] = {
- &SCA_RandomActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_RandomActuator::Methods[] = {
@@ -384,14 +379,14 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = {
PyObject* SCA_RandomActuator::pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self);
- return PyInt_FromLong(act->m_base->GetSeed());
+ return PyLong_FromSsize_t(act->m_base->GetSeed());
}
int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self);
- if (PyInt_Check(value)) {
- int ival = PyInt_AsLong(value);
+ if (PyLong_Check(value)) {
+ int ival = PyLong_AsSsize_t(value);
act->m_base->SetSeed(ival);
return PY_SET_ATTR_SUCCESS;
} else {
@@ -400,19 +395,6 @@ int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_
}
}
-PyObject* SCA_RandomActuator::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* SCA_RandomActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int SCA_RandomActuator::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
/* 1. setSeed */
const char SCA_RandomActuator::SetSeed_doc[] =
"setSeed(seed)\n"
@@ -439,7 +421,7 @@ const char SCA_RandomActuator::GetSeed_doc[] =
PyObject* SCA_RandomActuator::PyGetSeed()
{
ShowDeprecationWarning("getSeed()", "the seed property");
- return PyInt_FromLong(m_base->GetSeed());
+ return PyLong_FromSsize_t(m_base->GetSeed());
}
/* 4. getPara1 */
@@ -473,7 +455,7 @@ const char SCA_RandomActuator::GetDistribution_doc[] =
PyObject* SCA_RandomActuator::PyGetDistribution()
{
ShowDeprecationWarning("getDistribution()", "the distribution property");
- return PyInt_FromLong(m_distribution);
+ return PyLong_FromSsize_t(m_distribution);
}
/* 9. setProperty */
@@ -508,7 +490,7 @@ const char SCA_RandomActuator::GetProperty_doc[] =
PyObject* SCA_RandomActuator::PyGetProperty()
{
ShowDeprecationWarning("getProperty()", "the 'propName' property");
- return PyString_FromString(m_propname);
+ return PyUnicode_FromString(m_propname);
}
/* 11. setBoolConst */
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h
index 59863589b60..c7d3fe21217 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.h
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.h
@@ -85,8 +85,7 @@ class SCA_RandomActuator : public SCA_IActuator
KX_RANDOMACT_MODE mode,
float para1,
float para2,
- const STR_String &propName,
- PyTypeObject* T=&Type);
+ const STR_String &propName);
virtual ~SCA_RandomActuator();
virtual bool Update();
@@ -97,10 +96,6 @@ class SCA_RandomActuator : public SCA_IActuator
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
static PyObject* pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index d5cbeef01ae..e036a77707e 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -46,9 +46,8 @@
SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
- int startseed,
- PyTypeObject* T)
- : SCA_ISensor(gameobj,eventmgr, T)
+ int startseed)
+ : SCA_ISensor(gameobj,eventmgr)
{
m_basegenerator = new SCA_RandomNumberGenerator(startseed);
Init();
@@ -147,19 +146,15 @@ PyTypeObject SCA_RandomSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_RandomSensor::Parents[] = {
- &SCA_RandomSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_RandomSensor::Methods[] = {
@@ -177,19 +172,6 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = {
{NULL} //Sentinel
};
-PyObject* SCA_RandomSensor::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* SCA_RandomSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int SCA_RandomSensor::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_ISensor);
-}
-
/* 1. setSeed */
const char SCA_RandomSensor::SetSeed_doc[] =
"setSeed(seed)\n"
@@ -216,7 +198,7 @@ const char SCA_RandomSensor::GetSeed_doc[] =
"\tequal series.\n";
PyObject* SCA_RandomSensor::PyGetSeed() {
ShowDeprecationWarning("getSeed()", "the seed property");
- return PyInt_FromLong(m_basegenerator->GetSeed());
+ return PyLong_FromSsize_t(m_basegenerator->GetSeed());
}
/* 3. getLastDraw */
@@ -225,24 +207,24 @@ const char SCA_RandomSensor::GetLastDraw_doc[] =
"\tReturn the last value that was drawn.\n";
PyObject* SCA_RandomSensor::PyGetLastDraw() {
ShowDeprecationWarning("getLastDraw()", "the lastDraw property");
- return PyInt_FromLong(m_lastdraw);
+ return PyLong_FromSsize_t(m_lastdraw);
}
PyObject* SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v);
- return PyInt_FromLong(self->m_basegenerator->GetSeed());
+ return PyLong_FromSsize_t(self->m_basegenerator->GetSeed());
}
int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v);
- if (!PyInt_Check(value)) {
+ if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError, "sensor.seed = int: Random Sensor, expected an integer");
return PY_SET_ATTR_FAIL;
}
- self->m_basegenerator->SetSeed(PyInt_AsLong(value));
+ self->m_basegenerator->SetSeed(PyLong_AsSsize_t(value));
return PY_SET_ATTR_SUCCESS;
}
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h
index b2bf2440966..5e66c36cccf 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.h
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.h
@@ -48,8 +48,7 @@ class SCA_RandomSensor : public SCA_ISensor
public:
SCA_RandomSensor(class SCA_EventManager* rndmgr,
SCA_IObject* gameobj,
- int startseed,
- PyTypeObject* T=&Type);
+ int startseed);
virtual ~SCA_RandomSensor();
virtual CValue* GetReplica();
virtual void ProcessReplica();
@@ -61,10 +60,6 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
/* 1. setSeed */
KX_PYMETHOD_DOC_VARARGS(SCA_RandomSensor,SetSeed);
/* 2. getSeed */
diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp
index aee8e26c21a..527adc70cc6 100644
--- a/source/gameengine/GameLogic/SCA_XNORController.cpp
+++ b/source/gameengine/GameLogic/SCA_XNORController.cpp
@@ -42,10 +42,9 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
-SCA_XNORController::SCA_XNORController(SCA_IObject* gameobj,
- PyTypeObject* T)
+SCA_XNORController::SCA_XNORController(SCA_IObject* gameobj)
:
- SCA_IController(gameobj,T)
+ SCA_IController(gameobj)
{
}
@@ -120,19 +119,15 @@ PyTypeObject SCA_XNORController::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_XNORController::Parents[] = {
- &SCA_XNORController::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IController::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_XNORController::Methods[] = {
@@ -143,12 +138,4 @@ PyAttributeDef SCA_XNORController::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_XNORController::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IController);
-}
-
-PyObject* SCA_XNORController::py_getattro_dict() {
- py_getattro_dict_up(SCA_IController);
-}
-
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_XNORController.h b/source/gameengine/GameLogic/SCA_XNORController.h
index 4aad5763cb0..18e77fae665 100644
--- a/source/gameengine/GameLogic/SCA_XNORController.h
+++ b/source/gameengine/GameLogic/SCA_XNORController.h
@@ -39,7 +39,7 @@ class SCA_XNORController : public SCA_IController
Py_Header;
//virtual void Trigger(class SCA_LogicManager* logicmgr);
public:
- SCA_XNORController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ SCA_XNORController(SCA_IObject* gameobj);
virtual ~SCA_XNORController();
virtual CValue* GetReplica();
virtual void Trigger(SCA_LogicManager* logicmgr);
@@ -48,9 +48,6 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
-
};
#endif //__KX_XNORCONTROLLER
diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp
index 5afb3a750f5..c0916224fe6 100644
--- a/source/gameengine/GameLogic/SCA_XORController.cpp
+++ b/source/gameengine/GameLogic/SCA_XORController.cpp
@@ -42,10 +42,9 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
-SCA_XORController::SCA_XORController(SCA_IObject* gameobj,
- PyTypeObject* T)
+SCA_XORController::SCA_XORController(SCA_IObject* gameobj)
:
- SCA_IController(gameobj,T)
+ SCA_IController(gameobj)
{
}
@@ -120,19 +119,15 @@ PyTypeObject SCA_XORController::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject SCA_XORController::Parents[] = {
- &SCA_XORController::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IController::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef SCA_XORController::Methods[] = {
@@ -143,12 +138,4 @@ PyAttributeDef SCA_XORController::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_XORController::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IController);
-}
-
-PyObject* SCA_XORController::py_getattro_dict() {
- py_getattro_dict_up(SCA_IController);
-}
-
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_XORController.h b/source/gameengine/GameLogic/SCA_XORController.h
index feb9f2ed07c..2607a533661 100644
--- a/source/gameengine/GameLogic/SCA_XORController.h
+++ b/source/gameengine/GameLogic/SCA_XORController.h
@@ -39,18 +39,10 @@ class SCA_XORController : public SCA_IController
Py_Header;
//virtual void Trigger(class SCA_LogicManager* logicmgr);
public:
- SCA_XORController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ SCA_XORController(SCA_IObject* gameobj);
virtual ~SCA_XORController();
virtual CValue* GetReplica();
virtual void Trigger(SCA_LogicManager* logicmgr);
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
-
};
#endif //__KX_XORCONTROLLER
diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript
index aadc4154298..837769e5e78 100644
--- a/source/gameengine/GameLogic/SConscript
+++ b/source/gameengine/GameLogic/SConscript
@@ -10,16 +10,19 @@ incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph'
incs += ' ' + env['BF_PYTHON_INC']
-defs = ''
+defs = []
if env['WITH_BF_SDL']:
incs += ' ' + env['BF_SDL_INC']
else:
- defs += ' DISABLE_SDL'
+ defs.append('DISABLE_SDL')
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
+ if env['BF_DEBUG']:
+ defs.append('_DEBUG')
-env.BlenderLib ( 'bf_logic', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[30, 110], cxx_compileflags=cxxflags )
+env.BlenderLib ( 'bf_logic', sources, Split(incs), defs, libtype=['core','player'], priority=[330, 100], cxx_compileflags=cxxflags )
diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt
index 0c6c4179e2d..ce1cd217f60 100644
--- a/source/gameengine/GamePlayer/common/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/common/CMakeLists.txt
@@ -42,7 +42,6 @@ SET(INC
../../../../intern/string
../../../../intern/ghost
../../../../intern/guardedalloc
- ../../../../intern/bmfont
../../../../intern/moto/include
../../../../intern/SoundSystem
../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
diff --git a/source/gameengine/GamePlayer/common/GPC_Engine.cpp b/source/gameengine/GamePlayer/common/GPC_Engine.cpp
index 868dddb901c..a46f30c1209 100644
--- a/source/gameengine/GamePlayer/common/GPC_Engine.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_Engine.cpp
@@ -39,6 +39,7 @@
#include "BKE_blender.h" // initglobals()
#include "BKE_global.h" // Global G
+#include "BKE_report.h"
#include "DNA_scene_types.h"
#include "DNA_camera_types.h" // Camera
#include "DNA_object_types.h" // Object
@@ -135,15 +136,19 @@ GPC_Engine::~GPC_Engine()
bool GPC_Engine::Start(char *filename)
{
- BlendReadError error;
- BlendFileData *bfd= BLO_read_from_file(filename, &error);
+ ReportList reports;
+ BlendFileData *bfd;
+
+ BKE_reports_init(&reports, RPT_STORE);
+ bfd= BLO_read_from_file(filename, &reports);
+ BKE_reports_clear(&reports);
if (!bfd) {
// XXX, deal with error here
cout << "Unable to load: " << filename << endl;
return false;
}
-
+
StartKetsji();
if(bfd->type == BLENFILETYPE_PUB)
@@ -156,8 +161,12 @@ bool GPC_Engine::Start(char *filename)
bool GPC_Engine::Start(unsigned char *blenderDataBuffer,
unsigned int blenderDataBufferSize)
{
- BlendReadError error;
- BlendFileData *bfd= BLO_read_from_memory(blenderDataBuffer, blenderDataBufferSize, &error);
+ ReportList reports;
+ BlendFileData *bfd;
+
+ BKE_reports_init(&reports, RPT_STORE);
+ bfd= BLO_read_from_memory(blenderDataBuffer, blenderDataBufferSize, &reports);
+ BKE_reports_clear(&reports);
if (!bfd) {
// XXX, deal with error here
@@ -176,7 +185,7 @@ bool GPC_Engine::Start(unsigned char *blenderDataBuffer,
bool GPC_Engine::StartKetsji(void)
{
- STR_String startSceneName = G.scene->id.name + 2;
+ STR_String startSceneName = ""; // XXX scene->id.name + 2;
/*
KX_KetsjiEngine* ketsjieng = new KX_KetsjiEngine(m_system);
m_portal = new KetsjiPortal(ketsjieng);
diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
deleted file mode 100644
index b1e2b5af0e6..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "GL/glew.h"
-
-#include "GPC_PolygonMaterial.h"
-#include "MT_Vector3.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_GLExtensionManager.h"
-
-/* This list includes only data type definitions */
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_group_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_property_types.h"
-#include "DNA_text_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_world_types.h"
-
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_mesh.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "IMB_imbuf_types.h"
-/* end of blender include block */
-
-static Image *fCurpage=0;
-static int fCurtile=0, fCurmode=0, fCurTileXRep=0, fCurTileYRep=0;
-static short fTexWindx, fTexWindy, fTexWinsx, fTexWinsy;
-static int fDoMipMap = 1;
-static int fLinearMipMap=1;
-static int fAlphamode= -1;
-
- /* (n&(n-1)) zeros the least significant bit of n */
-static int is_pow2(int num) {
- return ((num)&(num-1))==0;
-}
-static int smaller_pow2(int num) {
- while (!is_pow2(num))
- num= num&(num-1);
- return num;
-}
-
-static void my_make_repbind(Image *ima)
-{
- if(ima==0 || ima->ibufs.first==0) return;
-
- if(ima->repbind) {
- glDeleteTextures(ima->totbind, (GLuint*)ima->repbind);
- delete (ima->repbind);
- ima->repbind= 0;
- }
- ima->totbind= ima->xrep*ima->yrep;
- if(ima->totbind>1) {
- ima->repbind= (unsigned int *) malloc(sizeof(int)*ima->totbind);
- for (int i=0;i<ima->totbind;i++)
- ((int*)ima->repbind)[i] = 0;
- }
-}
-
-extern "C" int set_tpage(MTFace *tface);
-
-int set_tpage(MTFace *tface)
-{
- static MTFace *lasttface= 0;
- Image *ima;
- unsigned int *rect, *bind;
- int tpx, tpy, tilemode, tileXRep,tileYRep;
-
- /* disable */
- if(tface==0) {
- if(lasttface==0) return 0;
-
- lasttface= 0;
- fCurtile= 0;
- fCurpage= 0;
- if(fCurmode!=0) {
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- }
- fCurmode= 0;
- fCurTileXRep=0;
- fCurTileYRep=0;
- fAlphamode= -1;
-
- glDisable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- return 0;
- }
- lasttface= tface;
-
- if( fAlphamode != tface->transp) {
- fAlphamode= tface->transp;
-
- if(fAlphamode) {
- if(fAlphamode==TF_ADD) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE);
- glDisable ( GL_ALPHA_TEST );
- /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
- }
- else if(fAlphamode==TF_ALPHA) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable ( GL_ALPHA_TEST );
- /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
- }
- else if (fAlphamode==TF_CLIP){
- glDisable(GL_BLEND);
- glEnable ( GL_ALPHA_TEST );
- glAlphaFunc(GL_GREATER, 0.5f);
- }
- /* else { */
- /* glBlendFunc(GL_ONE, GL_ONE); */
- /* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */
- /* } */
- }
- else glDisable(GL_BLEND);
- }
-
- ima= (struct Image *) tface->tpage;
-
- /* Enable or disable environment mapping */
- if (ima && (ima->flag & IMA_REFLECT)){
-
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
-
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
- }
- else{
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- }
-
- tilemode= tface->mode & TF_TILES;
- tileXRep = 0;
- tileYRep = 0;
- if (ima)
- {
- tileXRep = ima->xrep;
- tileYRep = ima->yrep;
- }
-
-
- if(ima==fCurpage && fCurtile==tface->tile && tilemode==fCurmode && fCurTileXRep==tileXRep && fCurTileYRep == tileYRep) return ima!=0;
-
- if(tilemode!=fCurmode || fCurTileXRep!=tileXRep || fCurTileYRep != tileYRep)
- {
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
-
- if(tilemode && ima!=0)
- glScalef(ima->xrep, ima->yrep, 1.0);
-
- glMatrixMode(GL_MODELVIEW);
- }
-
- if(ima==0 || ima->ok==0) {
- glDisable(GL_TEXTURE_2D);
-
- fCurtile= tface->tile;
- fCurpage= 0;
- fCurmode= tilemode;
- fCurTileXRep = tileXRep;
- fCurTileYRep = tileYRep;
-
- return 0;
- }
-
- ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
-
- if(ibuf==0) {
- ima->ok= 0;
-
- fCurtile= tface->tile;
- fCurpage= 0;
- fCurmode= tilemode;
- fCurTileXRep = tileXRep;
- fCurTileYRep = tileYRep;
-
- glDisable(GL_TEXTURE_2D);
- return 0;
- }
-
- if(ima->tpageflag & IMA_TWINANIM) fCurtile= ima->lastframe;
- else fCurtile= tface->tile;
-
- if(tilemode) {
-
- if(ima->repbind==0) my_make_repbind(ima);
-
- if(fCurtile>=ima->totbind) fCurtile= 0;
-
- /* this happens when you change repeat buttons */
- if(ima->repbind) bind= ima->repbind+fCurtile;
- else bind= &ima->bindcode;
-
- if(*bind==0) {
-
- fTexWindx= ibuf->x/ima->xrep;
- fTexWindy= ibuf->y/ima->yrep;
-
- if(fCurtile>=ima->xrep*ima->yrep) fCurtile= ima->xrep*ima->yrep-1;
-
- fTexWinsy= fCurtile / ima->xrep;
- fTexWinsx= fCurtile - fTexWinsy*ima->xrep;
-
- fTexWinsx*= fTexWindx;
- fTexWinsy*= fTexWindy;
-
- tpx= fTexWindx;
- tpy= fTexWindy;
-
- rect= ibuf->rect + fTexWinsy*ibuf->x + fTexWinsx;
- }
- }
- else {
- bind= &ima->bindcode;
-
- if(*bind==0) {
- tpx= ibuf->x;
- tpy= ibuf->y;
- rect= ibuf->rect;
- }
- }
-
- if(*bind==0) {
- int rectw= tpx, recth= tpy;
- unsigned int *tilerect= NULL, *scalerect= NULL;
-
- /*
- * Maarten:
- * According to Ton this code is not needed anymore. It was used only
- * in really old Blenders.
- * Reevan:
- * Actually it is needed for backwards compatibility. Simpledemo 6 does not display correctly without it.
- */
-#if 1
- if (tilemode) {
- int y;
-
- tilerect= (unsigned int*)MEM_mallocN(rectw*recth*sizeof(*tilerect), "tilerect");
- for (y=0; y<recth; y++) {
- unsigned int *rectrow= &rect[y*ibuf->x];
- unsigned int *tilerectrow= &tilerect[y*rectw];
-
- memcpy(tilerectrow, rectrow, tpx*sizeof(*rectrow));
- }
-
- rect= tilerect;
- }
-#endif
- if (!is_pow2(rectw) || !is_pow2(recth)) {
- rectw= smaller_pow2(rectw);
- recth= smaller_pow2(recth);
-
- scalerect= (unsigned int *)MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect");
- gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect);
- rect= scalerect;
- }
-
- glGenTextures(1, (GLuint*)bind);
-
- /*
- if(G.f & G_DEBUG) {
- printf("var1: %s\n", ima->id.name+2);
- printf("var1: %d, var2: %d\n", *bind, tpx);
- printf("var1: %d, var2: %d\n", fCurtile, tilemode);
- }
- */
- glBindTexture( GL_TEXTURE_2D, *bind);
-
- if (!fDoMipMap)
- {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- } else
- {
- int minfilter= fLinearMipMap?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST;
-
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
-
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- if (tilerect)
- MEM_freeN(tilerect);
- if (scalerect)
- MEM_freeN(scalerect);
- }
- else glBindTexture( GL_TEXTURE_2D, *bind);
-
-
-
- glEnable(GL_TEXTURE_2D);
-
- fCurpage= ima;
- fCurmode= tilemode;
- fCurTileXRep = tileXRep;
- fCurTileYRep = tileYRep;
-
- return 1;
-}
-
-#if 0
-GPC_PolygonMaterial::GPC_PolygonMaterial(const STR_String& texname, bool ba, const STR_String& matname,
- int tile, int tileXrep, int tileYrep, int mode, bool transparant, bool zsort,
- int lightlayer, bool bIsTriangle, void* clientobject, void* tpage) :
- RAS_IPolyMaterial(texname, ba, matname, tile, tileXrep, tileYrep, mode,
- transparant, zsort, lightlayer, bIsTriangle, clientobject), m_tface((struct MTFace*)tpage)
-{
- // clear local caching info
- my_set_tpage(0);
-}
-
-
-GPC_PolygonMaterial::~GPC_PolygonMaterial(void)
-{
-}
-
-
-void GPC_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const
-{
- if (GetCachingInfo() != cachingInfo)
- {
- if (!cachingInfo)
- {
- my_set_tpage(0);
- }
- cachingInfo = GetCachingInfo();
-
- if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) )
- {
- update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime());
- my_set_tpage(m_tface);
- rasty->EnableTextures(true);
- } else
- {
- my_set_tpage(0);
- rasty->EnableTextures(false);
- }
-
- //TF_TWOSIDE == 512, todo, make this a ketsji enum
- if(m_drawingmode & 512) {
- rasty->SetCullFace(false);
- }
-
- else
- {
- rasty->SetCullFace(true);//glEnable(GL_CULL_FACE);
- //else glDisable(GL_CULL_FACE);
- }
- }
- rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity);
- rasty->SetShinyness(m_shininess);
- rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0);
-}
-
-#endif
-void GPC_PolygonMaterial::SetMipMappingEnabled(bool enabled)
-{
- fDoMipMap = enabled ? 1 : 0;
-}
diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h
deleted file mode 100644
index 212decd078c..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __GPC_POLYGONMATERIAL
-#define __GPC_POLYGONMATERIAL
-
-#include "RAS_IPolygonMaterial.h"
-
-namespace GPC_PolygonMaterial
-{
- void SetMipMappingEnabled(bool enabled = false);
-};
-
-#if 0
-class GPC_PolygonMaterial : public RAS_IPolyMaterial
-{
- struct MTFace* m_tface;
-
-public:
- GPC_PolygonMaterial(const STR_String& texname, bool ba, const STR_String& matname,
- int tile, int tileXrep, int tileYrep, int mode, bool transparant, bool zsort,
- int lightlayer, bool bIsTriangle, void* clientobject, void* tpage);
-
- virtual ~GPC_PolygonMaterial(void);
-
- /**
- * Returns the caching information for this material,
- * This can be used to speed up the rasterizing process.
- * @return The caching information.
- */
- virtual TCachingInfo GetCachingInfo(void) const;
-
- /**
- * Activates the material in the (OpenGL) rasterizer.
- * On entry, the cachingInfo contains info about the last activated material.
- * On exit, the cachingInfo should contain updated info about this material.
- * @param rasty The rasterizer in which the material should be active.
- * @param cachingInfo The information about the material used to speed up rasterizing.
- */
- virtual void Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const;
-
- /**
- * Returns the Blender texture face structure that is used for this material.
- * @return The material's texture face.
- */
- MTFace* GetMTFace(void) const;
-
- static void SetMipMappingEnabled(bool enabled = false);
-};
-
-
-inline MTFace* GPC_PolygonMaterial::GetMTFace(void) const
-{
- return m_tface;
-}
-
-inline GPC_PolygonMaterial::TCachingInfo GPC_PolygonMaterial::GetCachingInfo(void) const
-{
- return GetMTFace();
-}
-#endif
-#endif // __GPC_POLYGONMATERIAL_H
-
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
index 96e50e651c0..24fca3feb8b 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
@@ -29,8 +29,6 @@
#include "GL/glew.h"
-#include "BMF_Api.h"
-
#include "RAS_IRenderTools.h"
#include "RAS_IRasterizer.h"
#include "RAS_LightObject.h"
@@ -60,7 +58,7 @@ unsigned int GPC_RenderTools::m_numgllights;
GPC_RenderTools::GPC_RenderTools()
{
- m_font = BMF_GetFont(BMF_kHelvetica10);
+// XXX m_font = BMF_GetFont(BMF_kHelvetica10);
glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights);
if (m_numgllights < 8)
@@ -316,12 +314,12 @@ void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
{
glColor3ub(0, 0, 0);
glRasterPos2s(xco+1, height-yco-1);
- BMF_DrawString(m_font, s);
+ // XXX BMF_DrawString(m_font, s);
}
glColor3ub(255, 255, 255);
glRasterPos2s(xco, height-yco);
- BMF_DrawString(m_font, s);
+ // XXX BMF_DrawString(m_font, s);
// Restore view settings
glMatrixMode(GL_PROJECTION);
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
index 316860a7d43..478d8b1a3c5 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
@@ -38,8 +38,6 @@
#include "RAS_IRenderTools.h"
-#include "BMF_Api.h"
-
struct KX_ClientObjectInfo;
class KX_RayCast;
@@ -57,7 +55,7 @@ class GPC_RenderTools : public RAS_IRenderTools
void *m_lastauxinfo;
static unsigned int m_numgllights;
- BMF_Font* m_font;
+// XXX BMF_Font* m_font;
public:
GPC_RenderTools();
diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile
index 6a12e659be6..4a952856739 100644
--- a/source/gameengine/GamePlayer/common/Makefile
+++ b/source/gameengine/GamePlayer/common/Makefile
@@ -50,13 +50,10 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_SUMO)/include
-CPPFLAGS += -I$(NAN_SOLID)/include
CPPFLAGS += -I$(NAN_PNG)/include
CPPFLAGS += -I$(NAN_ZLIB)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-CPPFLAGS += -I$(NAN_BMFONT)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I../../../gameengine/Converter
CPPFLAGS += -I../../../gameengine/Expressions
@@ -70,7 +67,6 @@ CPPFLAGS += -I../../../gameengine/Network/LoopBackNetwork
CPPFLAGS += -I../../../gameengine/Rasterizer
CPPFLAGS += -I../../../gameengine/SceneGraph
CPPFLAGS += -I../../../gameengine/Rasterizer/RAS_OpenGLRasterizer
-CPPFLAGS += -I../../../gameengine/Physics/Sumo
CPPFLAGS += -I../../../gameengine/Physics/common
###############################
diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript
index 23ad413350b..b7b3b9b12c4 100644
--- a/source/gameengine/GamePlayer/common/SConscript
+++ b/source/gameengine/GamePlayer/common/SConscript
@@ -18,7 +18,6 @@ incs = ['.',
'#intern/string',
'#intern/ghost',
'#intern/guardedalloc',
- '#intern/bmfont',
'#intern/moto/include',
'#intern/SoundSystem',
'#source/gameengine/Rasterizer/RAS_OpenGLRasterizer',
@@ -60,18 +59,14 @@ incs = ['.',
# 'unix/GPU_System.cpp']
# gp_common_env.Append ( CPPPATH = ['unix'])
-if env['WITH_BF_SOLID']:
- incs.append('#source/gameengine/Physics/Sumo')
- incs.append('#source/gameengine/Physics/Sumo/Fuzzics/include')
- incs += Split(env['BF_SOLID_INC'])
-
incs += Split(env['BF_PYTHON_INC'])
incs += Split(env['BF_PNG_INC'])
incs += Split(env['BF_ZLIB_INC'])
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
env.BlenderLib (libname='gp_common', sources=source_files, includes=incs, defines = [], libtype='player', priority=5, cxx_compileflags=cxxflags)
diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp b/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp
index a5dec02c753..0ef087efbfe 100644
--- a/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp
+++ b/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp
@@ -44,9 +44,6 @@
#include "NG_LoopBackNetworkDeviceInterface.h"
#include "SND_DeviceManager.h"
#include "KX_BlenderSceneConverter.h"
-#ifdef USE_SUMO_SOLID
- #include "SM_Scene.h"
-#endif
#include "KX_KetsjiEngine.h"
#include "GPC_RenderTools.h"
diff --git a/source/gameengine/GamePlayer/common/unix/Makefile b/source/gameengine/GamePlayer/common/unix/Makefile
index 3d44a41afee..08c52ddc904 100644
--- a/source/gameengine/GamePlayer/common/unix/Makefile
+++ b/source/gameengine/GamePlayer/common/unix/Makefile
@@ -57,11 +57,8 @@ CPPFLAGS += -I../../../../gameengine/Rasterizer/RAS_OpenGLRasterizer
CPPFLAGS += -I../../../../gameengine/SceneGraph
CPPFLAGS += -I$(NAN_FUZZICS)/include
-CPPFLAGS += -I$(NAN_SUMO)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_BMFONT)/include
-CPPFLAGS += -I$(NAN_SOLID)/include
# Blender stuff
CPPFLAGS += -I../../../../blender/blenkernel
diff --git a/source/gameengine/GamePlayer/common/windows/Makefile b/source/gameengine/GamePlayer/common/windows/Makefile
index f35642f9651..b622ee974c8 100644
--- a/source/gameengine/GamePlayer/common/windows/Makefile
+++ b/source/gameengine/GamePlayer/common/windows/Makefile
@@ -48,7 +48,6 @@ CPPFLAGS += -I$(SRCHOME)/gameengine/Physics/Sumo/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_STRING)/include
-CPPFLAGS += -I$(NAN_BMFONT)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_GLEW)/include
diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
index a3cd8296da3..0d4abf1e1fe 100644
--- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
@@ -37,7 +37,6 @@ SET(INC
../../../../intern/string
../../../../intern/ghost
../../../../intern/guardedalloc
- ../../../../intern/bmfont
../../../../intern/moto/include
../../../../intern/SoundSystem
../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
@@ -52,6 +51,7 @@ SET(INC
../../../../source/blender
../../../../source/blender/include
../../../../source/blender/makesdna
+ ../../../../source/blender/makesrna
../../../../source/gameengine/Rasterizer
../../../../source/gameengine/GameLogic
../../../../source/gameengine/Expressions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index bd332e8bbd7..a3805bd4317 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -157,7 +157,7 @@ bool GPG_Application::SetGameEngineData(struct Main* maggie, Scene *scene, int a
if (maggie != NULL && scene != NULL)
{
- G.scene = scene;
+// XXX G.scene = scene;
m_maggie = maggie;
m_startSceneName = scene->id.name+2;
m_startScene = scene;
@@ -650,7 +650,7 @@ bool GPG_Application::startEngine(void)
/*
m_canvas->SetBannerDisplayEnabled(true);
Camera* cam;
- cam = (Camera*)G.scene->camera->data;
+ cam = (Camera*)scene->camera->data;
if (cam) {
if (((cam->flag) & 48)==48) {
m_canvas->SetBannerDisplayEnabled(false);
@@ -700,8 +700,8 @@ bool GPG_Application::startEngine(void)
#endif
//initialize Dome Settings
- if(m_startScene->r.stereomode == RAS_IRasterizer::RAS_STEREO_DOME)
- m_ketsjiengine->InitDome(m_startScene->r.domeres, m_startScene->r.domemode, m_startScene->r.domeangle, m_startScene->r.domeresbuf, m_startScene->r.dometilt, m_startScene->r.dometext);
+ if(m_startScene->gm.stereoflag == STEREO_DOME)
+ m_ketsjiengine->InitDome(m_startScene->gm.dome.res, m_startScene->gm.dome.mode, m_startScene->gm.dome.angle, m_startScene->gm.dome.resbuf, m_startScene->gm.dome.tilt, m_startScene->gm.dome.warptext);
// Set the GameLogic.globalDict from marshal'd data, so we can
// load new blend files and keep data in GameLogic.globalDict
@@ -727,7 +727,7 @@ 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
- m_ketsjiengine->SetAnimFrameRate( (((double) G.scene->r.frs_sec) / G.scene->r.frs_sec_base) );
+// XXX m_ketsjiengine->SetAnimFrameRate( (((double) scene->r.frs_sec) / scene->r.frs_sec_base) );
}
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 7c47d2353a6..2433c587179 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -58,6 +58,7 @@ extern "C"
#include "BKE_global.h"
#include "BKE_icons.h"
#include "BKE_node.h"
+#include "BKE_report.h"
#include "BLI_blenlib.h"
#include "DNA_scene_types.h"
#include "BLO_readfile.h"
@@ -85,6 +86,8 @@ extern "C"
#include "BKE_main.h"
#include "BKE_utildefines.h"
+#include "RNA_define.h"
+
#ifdef WIN32
#include <windows.h>
#ifdef NDEBUG
@@ -259,35 +262,33 @@ static void get_filename(int argc, char **argv, char *filename)
#endif // !_APPLE
}
-static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL) {
- BlendReadError error;
+static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL)
+{
+ ReportList reports;
BlendFileData *bfd = NULL;
+
+ BKE_reports_init(&reports, RPT_STORE);
/* try to load ourself, will only work if we are a runtime */
if (blo_is_a_runtime(progname)) {
- bfd= blo_read_runtime(progname, &error);
+ bfd= blo_read_runtime(progname, &reports);
if (bfd) {
bfd->type= BLENFILETYPE_RUNTIME;
strcpy(bfd->main->name, progname);
}
} else {
- bfd= BLO_read_from_file(progname, &error);
- }
-
- /*
- if (bfd && bfd->type == BLENFILETYPE_BLEND) {
- BLO_blendfiledata_free(bfd);
- bfd = NULL;
- error = BRE_NOT_A_PUBFILE;
+ bfd= BLO_read_from_file(progname, &reports);
}
- */
if (!bfd && filename) {
bfd = load_game_data(filename);
if (!bfd) {
- printf("Loading %s failed: %s\n", filename, BLO_bre_as_string(error));
+ printf("Loading %s failed: ", filename);
+ BKE_reports_print(&reports, RPT_ERROR);
}
}
+
+ BKE_reports_clear(&reports);
return bfd;
}
@@ -345,6 +346,8 @@ int main(int argc, char** argv)
*/
#endif // __APPLE__
+ RNA_init();
+
init_nodesystem();
initglobals();
diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile
index 5f90d804611..49ad9457ee3 100644
--- a/source/gameengine/GamePlayer/ghost/Makefile
+++ b/source/gameengine/GamePlayer/ghost/Makefile
@@ -39,7 +39,6 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
-CPPFLAGS += -I$(NAN_BMFONT)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
@@ -69,6 +68,7 @@ CPPFLAGS += -I../../../blender/blenlib
CPPFLAGS += -I../../../blender/blenloader
CPPFLAGS += -I../../../blender/imbuf
CPPFLAGS += -I../../../blender/makesdna
+CPPFLAGS += -I../../../blender/makesrna
CPPFLAGS += -I../../../blender/readblenfile
CPPFLAGS += -I../../../blender/gpu
diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript
index dd8761e0a45..ca06b9ca0dd 100644
--- a/source/gameengine/GamePlayer/ghost/SConscript
+++ b/source/gameengine/GamePlayer/ghost/SConscript
@@ -12,7 +12,6 @@ incs = ['.',
'#intern/string',
'#intern/ghost',
'#intern/guardedalloc',
- '#intern/bmfont',
'#intern/moto/include',
'#intern/SoundSystem',
'#source/gameengine/Rasterizer/RAS_OpenGLRasterizer',
@@ -27,6 +26,7 @@ incs = ['.',
'#source/blender',
'#source/blender/include',
'#source/blender/makesdna',
+ '#source/blender/makesrna',
'#source/gameengine/BlenderRoutines',
'#source/gameengine/Rasterizer',
'#source/gameengine/GameLogic',
@@ -41,19 +41,16 @@ incs = ['.',
'#source/blender/gpu',
'#extern/glew/include']
-if env['WITH_BF_SOLID']:
- incs.append(['#source/gameengine/Physics/Sumo', '#source/gameengine/Physics/Sumo/Fuzzics/include'])
- incs += Split(env['BF_SOLID_INC'])
-
incs += Split(env['BF_PYTHON_INC'])
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
defs = ''
if env['WITH_BF_FFMPEG']:
defs += ' WITH_FFMPEG'
-env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = Split(defs), libtype='player',priority=0, cxx_compileflags=cxxflags)
+env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = Split(defs), libtype='player',priority=5, cxx_compileflags=cxxflags)
diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp
index c5c517c8a65..8bde5dd3a51 100644
--- a/source/gameengine/Ketsji/BL_Shader.cpp
+++ b/source/gameengine/Ketsji/BL_Shader.cpp
@@ -113,8 +113,8 @@ bool BL_Shader::Ok()const
return (mShader !=0 && mOk && mUse);
}
-BL_Shader::BL_Shader(PyTypeObject *T)
-: PyObjectPlus(T),
+BL_Shader::BL_Shader()
+: PyObjectPlus(),
mShader(0),
mPass(1),
mOk(0),
@@ -728,17 +728,6 @@ void BL_Shader::SetUniform(int uniform, const int* val, int len)
}
}
-
-PyObject* BL_Shader::py_getattro(PyObject *attr)
-{
- py_getattro_up(PyObjectPlus);
-}
-
-PyObject* BL_Shader::py_getattro_dict() {
- py_getattro_dict_up(PyObjectPlus);
-}
-
-
PyMethodDef BL_Shader::Methods[] =
{
// creation
@@ -792,21 +781,17 @@ PyTypeObject BL_Shader::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-PyParentObject BL_Shader::Parents[] = {
- &BL_Shader::Type,
- &PyObjectPlus::Type,
- NULL
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &PyObjectPlus::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-
KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProgram)" )
{
if(mShader !=0 && mOk )
@@ -848,17 +833,17 @@ KX_PYMETHODDEF_DOC( BL_Shader, delSource, "delSource( )" )
KX_PYMETHODDEF_DOC( BL_Shader, isValid, "isValid()" )
{
- return PyInt_FromLong( ( mShader !=0 && mOk ) );
+ return PyLong_FromSsize_t( ( mShader !=0 && mOk ) );
}
KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg ,"getVertexProg( )" )
{
- return PyString_FromString(vertProg?vertProg:"");
+ return PyUnicode_FromString(vertProg?vertProg:"");
}
KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" )
{
- return PyString_FromString(fragProg?fragProg:"");
+ return PyUnicode_FromString(fragProg?fragProg:"");
}
KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
@@ -1223,7 +1208,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2
for(unsigned int i=0; (i<list_size && i<4); i++)
{
PyObject *item = PySequence_GetItem(listPtr, i);
- array_data[i] = PyInt_AsLong(item);
+ array_data[i] = PyLong_AsSsize_t(item);
Py_DECREF(item);
}
diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h
index 7db40e778ae..42969996b3e 100644
--- a/source/gameengine/Ketsji/BL_Shader.h
+++ b/source/gameengine/Ketsji/BL_Shader.h
@@ -120,7 +120,7 @@ private:
void ClearUniforms();
public:
- BL_Shader(PyTypeObject *T=&Type);
+ BL_Shader();
virtual ~BL_Shader();
// Unused for now tangent is set as
@@ -202,9 +202,7 @@ public:
void SetUniform(int uniform, const int val);
// Python interface
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual PyObject* py_repr(void) { return PyString_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", vertProg, fragProg); }
+ virtual PyObject* py_repr(void) { return PyUnicode_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", vertProg, fragProg); }
// -----------------------------------
KX_PYMETHOD_DOC( BL_Shader, setSource );
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index abc2b44825e..f703841c40b 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -25,18 +25,6 @@
# ***** END GPL LICENSE BLOCK *****
FILE(GLOB SRC *.cpp)
-SET(SRC
- ${SRC}
- ../../../source/blender/python/api2_2x/Mathutils.c
- ../../../source/blender/python/api2_2x/Geometry.c
- ../../../source/blender/python/api2_2x/constant.c
- ../../../source/blender/python/api2_2x/euler.c
- ../../../source/blender/python/api2_2x/matrix.c
- ../../../source/blender/python/api2_2x/quat.c
- ../../../source/blender/python/api2_2x/vector.c
- ../../../source/blender/python/api2_2x/bpy_internal_import.c
- ../../../source/blender/python/api2_2x/BGL.c
-)
SET(INC
.
@@ -44,7 +32,6 @@ SET(INC
../../../intern/string
../../../intern/guardedalloc
../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
- ../../../intern/bmfont
../../../source/gameengine/Converter
../../../source/blender/imbuf
../../../intern/ghost/include
@@ -52,7 +39,8 @@ SET(INC
../../../source/gameengine/Ketsji
../../../source/blender/blenlib
../../../source/blender/blenkernel
- ../../../source/blender/python/api2_2x
+ ../../../source/blender/python
+ ../../../source/blender/python/generic
../../../source/blender
../../../source/blender/include
../../../source/blender/makesdna
@@ -75,8 +63,13 @@ SET(INC
../../../extern/solid
../../../extern/glew/include
${PYTHON_INC}
- ${SDL_INC}
)
+IF(WITH_SDL)
+ SET(INC ${INC} ${SDL_INC})
+ELSE(WITH_SDL)
+ ADD_DEFINITIONS(-DDISABLE_SDL)
+ENDIF(WITH_SDL)
+
BLENDERLIB(bf_ketsji "${SRC}" "${INC}")
#env.BlenderLib ( 'bf_ketsji', sources, Split(incs), [], libtype=['game','player'], priority=[25, 72], compileflags = cflags )
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
index 32f0c3611b7..de820ddaaae 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
@@ -41,9 +41,8 @@ KX_NetworkMessageActuator::KX_NetworkMessageActuator(
const STR_String &toPropName,
const STR_String &subject,
int bodyType,
- const STR_String &body,
- PyTypeObject* T) :
- SCA_IActuator(gameobj,T),
+ const STR_String &body) :
+ SCA_IActuator(gameobj),
m_networkscene(networkscene),
m_toPropName(toPropName),
m_subject(subject),
@@ -118,19 +117,15 @@ PyTypeObject KX_NetworkMessageActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_NetworkMessageActuator::Parents[] = {
- &KX_NetworkMessageActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_NetworkMessageActuator::Methods[] = {
@@ -155,18 +150,6 @@ PyAttributeDef KX_NetworkMessageActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_NetworkMessageActuator::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_NetworkMessageActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_NetworkMessageActuator::py_setattro(PyObject *attr, PyObject *value) {
- py_setattro_up(SCA_IActuator);
-}
-
// Deprecated ----->
// 1. SetToPropName
PyObject* KX_NetworkMessageActuator::PySetToPropName(
@@ -240,4 +223,4 @@ PyObject* KX_NetworkMessageActuator::PySetBody(
Py_RETURN_NONE;
}
-// <----- Deprecated \ No newline at end of file
+// <----- Deprecated
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
index cf92fd46fe0..b4f55f2a466 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
@@ -50,8 +50,7 @@ public:
const STR_String &toPropName,
const STR_String &subject,
int bodyType,
- const STR_String &body,
- PyTypeObject* T=&Type);
+ const STR_String &body);
virtual ~KX_NetworkMessageActuator();
virtual bool Update();
@@ -61,10 +60,6 @@ public:
/* Python interface ------------------------------------------- */
/* ------------------------------------------------------------ */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
// Deprecated ----->
KX_PYMETHOD(KX_NetworkMessageActuator, SetToPropName);
KX_PYMETHOD(KX_NetworkMessageActuator, SetSubject);
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
index 8ddcd87b66f..78dda1f6db7 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
@@ -50,10 +50,9 @@ KX_NetworkMessageSensor::KX_NetworkMessageSensor(
class KX_NetworkEventManager* eventmgr, // our eventmanager
class NG_NetworkScene *NetworkScene, // our scene
SCA_IObject* gameobj, // the sensor controlling object
- const STR_String &subject,
- PyTypeObject* T
+ const STR_String &subject
) :
- SCA_ISensor(gameobj,eventmgr,T),
+ SCA_ISensor(gameobj,eventmgr),
m_Networkeventmgr(eventmgr),
m_NetworkScene(NetworkScene),
m_subject(subject),
@@ -182,19 +181,15 @@ PyTypeObject KX_NetworkMessageSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_NetworkMessageSensor::Parents[] = {
- &KX_NetworkMessageSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_NetworkMessageSensor::Methods[] = {
@@ -226,18 +221,6 @@ PyAttributeDef KX_NetworkMessageSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_NetworkMessageSensor::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* KX_NetworkMessageSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int KX_NetworkMessageSensor::py_setattro(PyObject *attr, PyObject *value) {
- return SCA_ISensor::py_setattro(attr, value);
-}
-
PyObject* KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_NetworkMessageSensor *self = static_cast<KX_NetworkMessageSensor*>(self_v);
@@ -267,7 +250,7 @@ const char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] =
PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText(PyObject* value)
{
ShowDeprecationWarning("setSubjectFilterText()", "subject");
- char* Subject = PyString_AsString(value);
+ char* Subject = _PyUnicode_AsString(value);
if (Subject==NULL) {
PyErr_SetString(PyExc_TypeError, "sensor.tsetSubjectFilterText(string): KX_NetworkMessageSensor, expected a string message");
return NULL;
@@ -285,7 +268,7 @@ const char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] =
PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount()
{
ShowDeprecationWarning("getFrameMessageCount()", "frameMessageCount");
- return PyInt_FromLong(long(m_frame_message_count));
+ return PyLong_FromSsize_t(long(m_frame_message_count));
}
// 3. Get the message bodies
@@ -311,7 +294,7 @@ const char KX_NetworkMessageSensor::GetSubject_doc[] =
PyObject* KX_NetworkMessageSensor::PyGetSubject()
{
ShowDeprecationWarning("getSubject()", "subject");
- return PyString_FromString(m_subject ? m_subject : "");
+ return PyUnicode_FromString(m_subject ? m_subject : "");
}
// 5. Get the message subjects
@@ -328,4 +311,4 @@ PyObject* KX_NetworkMessageSensor::PyGetSubjects()
return (new CListValue())->NewProxy(true);
}
}
-// <----- Deprecated \ No newline at end of file
+// <----- Deprecated
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
index 53183f33826..ade87697303 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
@@ -57,8 +57,7 @@ public:
KX_NetworkEventManager* eventmgr, // our eventmanager
NG_NetworkScene *NetworkScene, // our scene
SCA_IObject* gameobj, // the sensor controlling object
- const STR_String &subject,
- PyTypeObject* T=&Type
+ const STR_String &subject
);
virtual ~KX_NetworkMessageSensor();
@@ -72,10 +71,6 @@ public:
/* Python interface -------------------------------------------- */
/* ------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
// Deprecated ----->
KX_PYMETHOD_DOC_O(KX_NetworkMessageSensor, SetSubjectFilterText);
KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetFrameMessageCount);
diff --git a/source/gameengine/Ketsji/KXNetwork/SConscript b/source/gameengine/Ketsji/KXNetwork/SConscript
index 5d9dd1464b3..e6584b55ed2 100644
--- a/source/gameengine/Ketsji/KXNetwork/SConscript
+++ b/source/gameengine/Ketsji/KXNetwork/SConscript
@@ -10,9 +10,10 @@ incs += ' #source/gameengine/Network #source/gameengine/SceneGraph'
incs += ' ' + env['BF_PYTHON_INC']
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
-env.BlenderLib ( 'kx_network', Split(sources), Split(incs), defines=[],libtype=['game2', 'player'], priority=[5, 155], cxx_compileflags=cxxflags )
+env.BlenderLib ( 'kx_network', Split(sources), Split(incs), defines=[],libtype=['core', 'player'], priority=[400, 145], cxx_compileflags=cxxflags )
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
index 30057fc039d..314becc702d 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
@@ -42,10 +42,8 @@ BL_BlenderShader *KX_BlenderMaterial::mLastBlenderShader = NULL;
//static PyObject *gTextureDict = 0;
-KX_BlenderMaterial::KX_BlenderMaterial(
- PyTypeObject *T
- )
-: PyObjectPlus(T),
+KX_BlenderMaterial::KX_BlenderMaterial()
+: PyObjectPlus(),
RAS_IPolyMaterial(),
mMaterial(NULL),
mShader(0),
@@ -813,36 +811,17 @@ PyTypeObject KX_BlenderMaterial::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-PyParentObject KX_BlenderMaterial::Parents[] = {
- &KX_BlenderMaterial::Type,
- &PyObjectPlus::Type,
- NULL
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &PyObjectPlus::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-PyObject* KX_BlenderMaterial::py_getattro(PyObject *attr)
-{
- py_getattro_up(PyObjectPlus);
-}
-
-PyObject* KX_BlenderMaterial::py_getattro_dict() {
- py_getattro_dict_up(PyObjectPlus);
-}
-
-int KX_BlenderMaterial::py_setattro(PyObject *attr, PyObject *pyvalue)
-{
- return PyObjectPlus::py_setattro(attr, pyvalue);
-}
-
-
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
{
if( !GLEW_ARB_fragment_shader) {
@@ -912,7 +891,7 @@ void KX_BlenderMaterial::SetBlenderGLSLShader(int layer)
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()")
{
- return PyInt_FromLong( GetMaterialIndex() );
+ return PyLong_FromSsize_t( GetMaterialIndex() );
}
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getTexture, "getTexture( index )" )
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h
index b29f2df98db..1f5edc1d7d1 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.h
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h
@@ -23,9 +23,7 @@ class KX_BlenderMaterial : public PyObjectPlus, public RAS_IPolyMaterial
Py_Header;
public:
// --------------------------------
- KX_BlenderMaterial(
- PyTypeObject* T=&Type
- );
+ KX_BlenderMaterial();
void Initialize(
class KX_Scene* scene,
BL_Material* mat,
@@ -83,10 +81,7 @@ public:
);
// --------------------------------
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
- virtual PyObject* py_repr(void) { return PyString_FromString(mMaterial->matname.ReadPtr()); }
+ virtual PyObject* py_repr(void) { return PyUnicode_FromString(mMaterial->matname.ReadPtr()); }
KX_PYMETHOD_DOC( KX_BlenderMaterial, getShader );
KX_PYMETHOD_DOC( KX_BlenderMaterial, getMaterialIndex );
diff --git a/source/gameengine/Ketsji/KX_CDActuator.cpp b/source/gameengine/Ketsji/KX_CDActuator.cpp
index 8511526fd5f..bfca81f45d9 100644
--- a/source/gameengine/Ketsji/KX_CDActuator.cpp
+++ b/source/gameengine/Ketsji/KX_CDActuator.cpp
@@ -48,9 +48,8 @@ KX_CDActuator::KX_CDActuator(SCA_IObject* gameobject,
KX_CDACT_TYPE type,
int track,
short start,
- short end,
- PyTypeObject* T)
- : SCA_IActuator(gameobject,T)
+ short end)
+ : SCA_IActuator(gameobject)
{
m_soundscene = soundscene;
m_type = type;
@@ -171,25 +170,17 @@ PyTypeObject KX_CDActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject KX_CDActuator::Parents[] = {
- &KX_CDActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef KX_CDActuator::Methods[] = {
// Deprecated ----->
{"setGain",(PyCFunction) KX_CDActuator::sPySetGain,METH_VARARGS,NULL},
@@ -217,22 +208,6 @@ int KX_CDActuator::pyattr_setGain(void *self, const struct KX_PYATTRIBUTE_DEF *a
return PY_SET_ATTR_SUCCESS;
}
-PyObject* KX_CDActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_CDActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_CDActuator::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
-
-
KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, startCD,
"startCD()\n"
"\tStarts the CD playing.\n")
@@ -273,8 +248,8 @@ KX_PYMETHODDEF_DOC_O(KX_CDActuator, playTrack,
"playTrack(trackNumber)\n"
"\tPlays the track selected.\n")
{
- if (PyInt_Check(value)) {
- int track = PyInt_AsLong(value);
+ if (PyLong_Check(value)) {
+ int track = PyLong_AsSsize_t(value);
SND_CDObject::Instance()->SetPlaymode(SND_CD_TRACK);
SND_CDObject::Instance()->SetTrack(track);
SND_CDObject::Instance()->SetPlaystate(SND_MUST_PLAY);
diff --git a/source/gameengine/Ketsji/KX_CDActuator.h b/source/gameengine/Ketsji/KX_CDActuator.h
index 2fd05ab72e5..b01ad73777e 100644
--- a/source/gameengine/Ketsji/KX_CDActuator.h
+++ b/source/gameengine/Ketsji/KX_CDActuator.h
@@ -68,8 +68,7 @@ public:
KX_CDACT_TYPE type,
int track,
short start,
- short end,
- PyTypeObject* T=&Type);
+ short end);
~KX_CDActuator();
@@ -81,10 +80,6 @@ public:
/* Python interface --------------------------------------------------- */
/* -------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
// Deprecated ----->
KX_PYMETHOD_VARARGS(KX_CDActuator,SetGain);
KX_PYMETHOD_VARARGS(KX_CDActuator,GetGain);
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index 40f6c99c03c..f762699f780 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -42,10 +42,9 @@ KX_Camera::KX_Camera(void* sgReplicationInfo,
SG_Callbacks callbacks,
const RAS_CameraData& camdata,
bool frustum_culling,
- bool delete_node,
- PyTypeObject *T)
+ bool delete_node)
:
- KX_GameObject(sgReplicationInfo,callbacks,T),
+ KX_GameObject(sgReplicationInfo,callbacks),
m_camdata(camdata),
m_dirty(true),
m_normalized(false),
@@ -551,41 +550,19 @@ PyTypeObject KX_Camera::Type = {
&KX_GameObject::Sequence,
&KX_GameObject::Mapping,
0,0,0,
- py_base_getattro,
- py_base_setattro,
+ NULL,
+ NULL,
0,
- Py_TPFLAGS_DEFAULT,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-
-
-
-PyParentObject KX_Camera::Parents[] = {
- &KX_Camera::Type,
- &KX_GameObject::Type,
- &SCA_IObject::Type,
- &CValue::Type,
- NULL
+ Methods,
+ 0,
+ 0,
+ &KX_GameObject::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-PyObject* KX_Camera::py_getattro(PyObject *attr)
-{
- py_getattro_up(KX_GameObject);
-}
-
-PyObject* KX_Camera::py_getattro_dict() {
- py_getattro_dict_up(KX_GameObject);
-}
-
-int KX_Camera::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(KX_GameObject);
-}
-
KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
"sphereInsideFrustum(center, radius) -> Integer\n"
"\treturns INSIDE, OUTSIDE or INTERSECT if the given sphere is\n"
@@ -611,7 +588,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
MT_Point3 center;
if (PyVecTo(pycenter, center))
{
- return PyInt_FromLong(SphereInsideFrustum(center, radius)); /* new ref */
+ return PyLong_FromSsize_t(SphereInsideFrustum(center, radius)); /* new ref */
}
}
@@ -662,7 +639,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, boxInsideFrustum,
return NULL;
}
- return PyInt_FromLong(BoxInsideFrustum(box)); /* new ref */
+ return PyLong_FromSsize_t(BoxInsideFrustum(box)); /* new ref */
}
KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum,
@@ -684,7 +661,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum,
MT_Point3 point;
if (PyVecTo(value, point))
{
- return PyInt_FromLong(PointInsideFrustum(point)); /* new ref */
+ return PyLong_FromSsize_t(PointInsideFrustum(point)); /* new ref */
}
PyErr_SetString(PyExc_TypeError, "camera.pointInsideFrustum(point): KX_Camera, expected point argument.");
@@ -952,11 +929,11 @@ PyObject* KX_Camera::pyattr_get_world_to_camera(void *self_v, const KX_PYATTRIBU
PyObject* KX_Camera::pyattr_get_INSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{ return PyInt_FromLong(INSIDE); }
+{ return PyLong_FromSsize_t(INSIDE); }
PyObject* KX_Camera::pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{ return PyInt_FromLong(OUTSIDE); }
+{ return PyLong_FromSsize_t(OUTSIDE); }
PyObject* KX_Camera::pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{ return PyInt_FromLong(INTERSECT); }
+{ return PyLong_FromSsize_t(INTERSECT); }
bool ConvertPythonToCamera(PyObject * value, KX_Camera **object, bool py_none_ok, const char *error_prefix)
@@ -978,14 +955,14 @@ bool ConvertPythonToCamera(PyObject * value, KX_Camera **object, bool py_none_ok
}
}
- if (PyString_Check(value)) {
- STR_String value_str = PyString_AsString(value);
+ if (PyUnicode_Check(value)) {
+ STR_String value_str = _PyUnicode_AsString(value);
*object = KX_GetActiveScene()->FindCamera(value_str);
if (*object) {
return true;
} else {
- PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_Camera in this scene", error_prefix, PyString_AsString(value));
+ PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_Camera in this scene", error_prefix, _PyUnicode_AsString(value));
return false;
}
}
@@ -1142,7 +1119,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenRay,
PyTuple_SET_ITEM(argValue, 0, PyObjectFrom(vect));
PyTuple_SET_ITEM(argValue, 1, PyFloat_FromDouble(dist));
if (propName)
- PyTuple_SET_ITEM(argValue, 2, PyString_FromString(propName));
+ PyTuple_SET_ITEM(argValue, 2, PyUnicode_FromString(propName));
PyObject* ret= this->PyrayCastTo(argValue,NULL);
Py_DECREF(argValue);
diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h
index aef21cd91e4..74c8e6d4e4f 100644
--- a/source/gameengine/Ketsji/KX_Camera.h
+++ b/source/gameengine/Ketsji/KX_Camera.h
@@ -143,7 +143,7 @@ public:
enum { INSIDE, INTERSECT, OUTSIDE } ;
- KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, bool delete_node = false, PyTypeObject *T = &Type);
+ KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, bool delete_node = false);
virtual ~KX_Camera();
/**
@@ -265,6 +265,7 @@ public:
*/
int GetViewportTop() const;
+ virtual int GetGameObjectType() { return OBJ_CAMERA; }
KX_PYMETHOD_DOC_VARARGS(KX_Camera, sphereInsideFrustum);
KX_PYMETHOD_DOC_O(KX_Camera, boxInsideFrustum);
@@ -282,10 +283,6 @@ public:
KX_PYMETHOD_DOC_O(KX_Camera, getScreenPosition);
KX_PYMETHOD_DOC_VARARGS(KX_Camera, getScreenVect);
KX_PYMETHOD_DOC_VARARGS(KX_Camera, getScreenRay);
-
- virtual PyObject* py_getattro(PyObject *attr); /* lens, near, far, projection_matrix */
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
static PyObject* pyattr_get_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp
index 3a6011db604..3d3b68ed85d 100644
--- a/source/gameengine/Ketsji/KX_CameraActuator.cpp
+++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp
@@ -33,10 +33,10 @@
#include "KX_CameraActuator.h"
#include <iostream>
#include <math.h>
+#include <float.h>
#include "KX_GameObject.h"
#include "PyObjectPlus.h"
-#include "blendef.h"
STR_String KX_CameraActuator::X_AXIS_STRING = "x";
STR_String KX_CameraActuator::Y_AXIS_STRING = "y";
@@ -56,10 +56,9 @@ KX_CameraActuator::KX_CameraActuator(
float hght,
float minhght,
float maxhght,
- bool xytog,
- PyTypeObject* T
+ bool xytog
):
- SCA_IActuator(gameobj, T),
+ SCA_IActuator(gameobj),
m_ob (obj),
m_height (hght),
m_minHeight (minhght),
@@ -385,19 +384,15 @@ PyTypeObject KX_CameraActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_CameraActuator::Parents[] = {
- &KX_CameraActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_CameraActuator::Methods[] = {
@@ -416,26 +411,14 @@ PyMethodDef KX_CameraActuator::Methods[] = {
};
PyAttributeDef KX_CameraActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW("min",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_minHeight),
- KX_PYATTRIBUTE_FLOAT_RW("max",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_maxHeight),
- KX_PYATTRIBUTE_FLOAT_RW("height",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_height),
+ KX_PYATTRIBUTE_FLOAT_RW("min",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_minHeight),
+ KX_PYATTRIBUTE_FLOAT_RW("max",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_maxHeight),
+ KX_PYATTRIBUTE_FLOAT_RW("height",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_height),
KX_PYATTRIBUTE_BOOL_RW("useXY",KX_CameraActuator,m_x),
KX_PYATTRIBUTE_RW_FUNCTION("object", KX_CameraActuator, pyattr_get_object, pyattr_set_object),
{NULL}
};
-PyObject* KX_CameraActuator::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_CameraActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_CameraActuator::py_setattro(PyObject *attr, PyObject* value) {
- py_setattro_up(SCA_IActuator);
-}
-
/* get obj ---------------------------------------------------------- */
const char KX_CameraActuator::GetObject_doc[] =
"getObject(name_only = 1)\n"
@@ -454,7 +437,7 @@ PyObject* KX_CameraActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_ob->GetName().ReadPtr());
+ return PyUnicode_FromString(m_ob->GetName().ReadPtr());
else
return m_ob->GetProxy();
}
@@ -579,7 +562,7 @@ const char KX_CameraActuator::GetXY_doc[] =
PyObject* KX_CameraActuator::PyGetXY()
{
ShowDeprecationWarning("getXY()", "the xy property");
- return PyInt_FromLong(m_x);
+ return PyLong_FromSsize_t(m_x);
}
PyObject* KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h
index efa4e2f38d7..057c6fed770 100644
--- a/source/gameengine/Ketsji/KX_CameraActuator.h
+++ b/source/gameengine/Ketsji/KX_CameraActuator.h
@@ -91,9 +91,7 @@ private :
float hght,
float minhght,
float maxhght,
- bool xytog,
- PyTypeObject* T=&Type
-
+ bool xytog
);
@@ -120,10 +118,6 @@ private :
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
-
/* set object to look at */
KX_PYMETHOD_DOC_O(KX_CameraActuator,SetObject);
/* get current object */
diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
index 077ac96f0ac..1898dc71ef8 100644
--- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h
+++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
@@ -30,9 +30,6 @@
#define __KX_CLIENTOBJECT_INFO_H
/* Note, the way this works with/without sumo is a bit odd */
-#ifdef USE_SUMO_SOLID
-#include <SM_Object.h>
-#endif //USE_SUMO_SOLID
#include <list>
@@ -42,9 +39,6 @@ class KX_GameObject;
* Client Type and Additional Info. This structure can be use instead of a bare void* pointer, for safeness, and additional info for callbacks
*/
struct KX_ClientObjectInfo
-#ifdef USE_SUMO_SOLID
- : public SM_ClientObject
-#endif
{
enum clienttype {
STATIC,
@@ -59,18 +53,12 @@ struct KX_ClientObjectInfo
std::list<SCA_ISensor*> m_sensors;
public:
KX_ClientObjectInfo(KX_GameObject *gameobject, clienttype type = STATIC, void *auxilary_info = NULL) :
-#ifdef USE_SUMO_SOLID
- SM_ClientObject(),
-#endif
m_type(type),
m_gameobject(gameobject),
m_auxilary_info(auxilary_info)
{}
KX_ClientObjectInfo(const KX_ClientObjectInfo &copy) :
-#ifdef USE_SUMO_SOLID
- SM_ClientObject(copy),
-#endif
m_type(copy.m_type),
m_gameobject(copy.m_gameobject),
m_auxilary_info(copy.m_auxilary_info)
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
index 6f66faaeafb..d09eae647c8 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
@@ -36,7 +36,6 @@
#include "MT_Matrix3x3.h"
#include "KX_GameObject.h"
#include "KX_RayCast.h"
-#include "blendef.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -55,9 +54,8 @@ KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj,
int locrotxyz,
int time,
int option,
- char *property,
- PyTypeObject* T) :
- SCA_IActuator(gameobj, T),
+ char *property) :
+ SCA_IActuator(gameobj),
m_refDirVector(refDir),
m_currentTime(0)
{
@@ -582,19 +580,15 @@ PyTypeObject KX_ConstraintActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_ConstraintActuator::Parents[] = {
- &KX_ConstraintActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_ConstraintActuator::Methods[] = {
@@ -628,33 +622,18 @@ PyMethodDef KX_ConstraintActuator::Methods[] = {
PyAttributeDef KX_ConstraintActuator::Attributes[] = {
KX_PYATTRIBUTE_INT_RW("damp",0,100,true,KX_ConstraintActuator,m_posDampTime),
KX_PYATTRIBUTE_INT_RW("rotDamp",0,100,true,KX_ConstraintActuator,m_rotDampTime),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RW_CHECK("direction",-MAXFLOAT,MAXFLOAT,KX_ConstraintActuator,m_refDirection,3,pyattr_check_direction),
+ KX_PYATTRIBUTE_FLOAT_ARRAY_RW_CHECK("direction",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_refDirection,3,pyattr_check_direction),
KX_PYATTRIBUTE_INT_RW("option",0,0xFFFF,false,KX_ConstraintActuator,m_option),
KX_PYATTRIBUTE_INT_RW("time",0,1000,true,KX_ConstraintActuator,m_activeTime),
KX_PYATTRIBUTE_STRING_RW("propName",0,32,true,KX_ConstraintActuator,m_property),
- KX_PYATTRIBUTE_FLOAT_RW("min",-MAXFLOAT,MAXFLOAT,KX_ConstraintActuator,m_minimumBound),
- KX_PYATTRIBUTE_FLOAT_RW("distance",-MAXFLOAT,MAXFLOAT,KX_ConstraintActuator,m_minimumBound),
- KX_PYATTRIBUTE_FLOAT_RW("max",-MAXFLOAT,MAXFLOAT,KX_ConstraintActuator,m_maximumBound),
+ KX_PYATTRIBUTE_FLOAT_RW("min",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_minimumBound),
+ KX_PYATTRIBUTE_FLOAT_RW("distance",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_minimumBound),
+ KX_PYATTRIBUTE_FLOAT_RW("max",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_maximumBound),
KX_PYATTRIBUTE_FLOAT_RW("rayLength",0,2000.f,KX_ConstraintActuator,m_maximumBound),
KX_PYATTRIBUTE_INT_RW("limit",KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF+1,KX_ConstraintActuator::KX_ACT_CONSTRAINT_MAX-1,false,KX_ConstraintActuator,m_locrot),
{ NULL } //Sentinel
};
-PyObject* KX_ConstraintActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_ConstraintActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_ConstraintActuator::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
-
int KX_ConstraintActuator::pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
{
KX_ConstraintActuator* act = static_cast<KX_ConstraintActuator*>(self);
@@ -692,7 +671,7 @@ const char KX_ConstraintActuator::GetDamp_doc[] =
"\tReturns the damping parameter.\n";
PyObject* KX_ConstraintActuator::PyGetDamp(){
ShowDeprecationWarning("getDamp()", "the damp property");
- return PyInt_FromLong(m_posDampTime);
+ return PyLong_FromSsize_t(m_posDampTime);
}
/* 2. setRotDamp */
@@ -719,7 +698,7 @@ const char KX_ConstraintActuator::GetRotDamp_doc[] =
"\tReturns the damping time for application of the constraint.\n";
PyObject* KX_ConstraintActuator::PyGetRotDamp(){
ShowDeprecationWarning("getRotDamp()", "the rotDamp property");
- return PyInt_FromLong(m_rotDampTime);
+ return PyLong_FromSsize_t(m_rotDampTime);
}
/* 2. setDirection */
@@ -792,7 +771,7 @@ const char KX_ConstraintActuator::GetOption_doc[] =
"\tReturns the option parameter.\n";
PyObject* KX_ConstraintActuator::PyGetOption(){
ShowDeprecationWarning("getOption()", "the option property");
- return PyInt_FromLong(m_option);
+ return PyLong_FromSsize_t(m_option);
}
/* 2. setTime */
@@ -821,7 +800,7 @@ const char KX_ConstraintActuator::GetTime_doc[] =
"\tReturns the time parameter.\n";
PyObject* KX_ConstraintActuator::PyGetTime(){
ShowDeprecationWarning("getTime()", "the time property");
- return PyInt_FromLong(m_activeTime);
+ return PyLong_FromSsize_t(m_activeTime);
}
/* 2. setProperty */
@@ -850,7 +829,7 @@ const char KX_ConstraintActuator::GetProperty_doc[] =
"\tReturns the property parameter.\n";
PyObject* KX_ConstraintActuator::PyGetProperty(){
ShowDeprecationWarning("getProperty()", "the 'property' property");
- return PyString_FromString(m_property.Ptr());
+ return PyUnicode_FromString(m_property.Ptr());
}
/* 4. setDistance */
@@ -979,7 +958,7 @@ const char KX_ConstraintActuator::GetLimit_doc[] =
"\tReturns the type of constraint.\n";
PyObject* KX_ConstraintActuator::PyGetLimit() {
ShowDeprecationWarning("setLimit()", "the limit property");
- return PyInt_FromLong(m_locrot);
+ return PyLong_FromSsize_t(m_locrot);
}
/* eof */
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h
index 40607b44947..677904aedc9 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.h
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h
@@ -126,8 +126,7 @@ protected:
int locrot,
int time,
int option,
- char *property,
- PyTypeObject* T=&Type);
+ char *property);
virtual ~KX_ConstraintActuator();
virtual CValue* GetReplica() {
KX_ConstraintActuator* replica = new KX_ConstraintActuator(*this);
@@ -141,10 +140,6 @@ protected:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
-
static int pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_check_min(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
index c5cf67af67d..ec7bb470235 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
@@ -38,8 +38,8 @@
KX_ConstraintWrapper::KX_ConstraintWrapper(
PHY_ConstraintType ctype,
int constraintId,
- PHY_IPhysicsEnvironment* physenv,PyTypeObject *T) :
- PyObjectPlus(T),
+ PHY_IPhysicsEnvironment* physenv) :
+ PyObjectPlus(),
m_constraintId(constraintId),
m_constraintType(ctype),
m_physenv(physenv)
@@ -51,7 +51,7 @@ KX_ConstraintWrapper::~KX_ConstraintWrapper()
PyObject* KX_ConstraintWrapper::PyGetConstraintId()
{
- return PyInt_FromLong(m_constraintId);
+ return PyLong_FromSsize_t(m_constraintId);
}
@@ -99,37 +99,17 @@ PyTypeObject KX_ConstraintWrapper::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_ConstraintWrapper::Parents[] = {
- &KX_ConstraintWrapper::Type,
- NULL
-};
-
-//here you can search for existing data members (like mass,friction etc.)
-PyObject* KX_ConstraintWrapper::py_getattro(PyObject *attr)
-{
- py_getattro_up(PyObjectPlus);
-}
-
-PyObject* KX_ConstraintWrapper::py_getattro_dict() {
- py_getattro_dict_up(PyObjectPlus);
-}
-
-int KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* value)
-{
- py_setattro_up(PyObjectPlus);
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &PyObjectPlus::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
-
-
PyMethodDef KX_ConstraintWrapper::Methods[] = {
{"getConstraintId",(PyCFunction) KX_ConstraintWrapper::sPyGetConstraintId, METH_NOARGS},
{"setParam",(PyCFunction) KX_ConstraintWrapper::sPySetParam, METH_VARARGS},
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h
index 03813e0f167..74670944415 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h
@@ -35,11 +35,8 @@
class KX_ConstraintWrapper : public PyObjectPlus
{
Py_Header;
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
public:
- KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
+ KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv);
virtual ~KX_ConstraintWrapper ();
int getConstraintId() { return m_constraintId;};
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
index cf50e0ccd06..147bd238009 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
@@ -32,11 +32,8 @@
/* These are defined by the build system... */
//but the build system is broken, because it doesn't allow for 2 or more defines at once.
//Please leave Sumo _AND_ Bullet enabled
-//#define USE_SUMO_SOLID // scons defines this
#define USE_BULLET
-//#define USE_ODE
-
//on visual studio 7/8, always enable BULLET for now
//you can have multiple physics engines running anyway, and
//the scons build system doesn't really support this at the moment.
@@ -148,20 +145,6 @@ struct KX_ObjectProperties
} m_boundobject;
};
-#ifdef USE_ODE
-
-
-void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- KX_Scene* kxscene,
- struct PHY_ShapeProps* shapeprops,
- struct PHY_MaterialProps* smmaterial,
- struct KX_ObjectProperties* objprop);
-
-
-#endif //USE_ODE
-
-
void KX_ConvertDynamoObject(KX_GameObject* gameobj,
RAS_MeshObject* meshobj,
KX_Scene* kxscene,
@@ -169,19 +152,6 @@ void KX_ConvertDynamoObject(KX_GameObject* gameobj,
struct PHY_MaterialProps* smmaterial,
struct KX_ObjectProperties* objprop);
-#ifdef USE_SUMO_SOLID
-
-void KX_ConvertSumoObject( class KX_GameObject* gameobj,
- class RAS_MeshObject* meshobj,
- class KX_Scene* kxscene,
- struct PHY_ShapeProps* shapeprops,
- struct PHY_MaterialProps* smmaterial,
- struct KX_ObjectProperties* objprop);
-
-void KX_ClearSumoSharedShapes();
-bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj);
-
-#endif
#ifdef USE_BULLET
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index cc8a00e8454..04e82d21cf4 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -32,7 +32,6 @@
#include "MT_assert.h"
-// defines USE_ODE to choose physics engine
#include "KX_ConvertPhysicsObject.h"
#include "BL_DeformableGameObject.h"
#include "RAS_MeshObject.h"
@@ -56,597 +55,6 @@ extern "C"{
#include "BKE_DerivedMesh.h"
}
-#ifdef USE_ODE
-
-#include "KX_OdePhysicsController.h"
-#include "OdePhysicsEnvironment.h"
-#endif //USE_ODE
-
-
-// USE_SUMO_SOLID is defined in headerfile KX_ConvertPhysicsObject.h
-#ifdef USE_SUMO_SOLID
-
-
-#include "SumoPhysicsEnvironment.h"
-#include "KX_SumoPhysicsController.h"
-
-
-// sumo physics specific
-#include "SM_Object.h"
-#include "SM_FhObject.h"
-#include "SM_Scene.h"
-#include "SM_ClientObjectInfo.h"
-
-#include "KX_SumoPhysicsController.h"
-
-struct KX_PhysicsInstance
-{
- DT_VertexBaseHandle m_vertexbase;
- RAS_DisplayArray* m_darray;
- RAS_IPolyMaterial* m_material;
-
- KX_PhysicsInstance(DT_VertexBaseHandle vertex_base, RAS_DisplayArray *darray, RAS_IPolyMaterial* mat)
- : m_vertexbase(vertex_base),
- m_darray(darray),
- m_material(mat)
- {
- }
-
- ~KX_PhysicsInstance()
- {
- DT_DeleteVertexBase(m_vertexbase);
- }
-};
-
-static GEN_Map<GEN_HashedPtr,DT_ShapeHandle> map_gamemesh_to_sumoshape;
-static GEN_Map<GEN_HashedPtr, KX_PhysicsInstance*> map_gamemesh_to_instance;
-
-// forward declarations
-static void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,class SM_Object* sumoObj,const STR_String& matname,bool isDynamic,bool isActor);
-static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope);
-
-void KX_ConvertSumoObject( KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- KX_Scene* kxscene,
- PHY_ShapeProps* kxshapeprops,
- PHY_MaterialProps* kxmaterial,
- struct KX_ObjectProperties* objprop)
-
-
-{
- SM_ShapeProps* smprop = new SM_ShapeProps;
-
- smprop->m_ang_drag = kxshapeprops->m_ang_drag;
- smprop->m_do_anisotropic = kxshapeprops->m_do_anisotropic;
- smprop->m_do_fh = kxshapeprops->m_do_fh;
- smprop->m_do_rot_fh = kxshapeprops->m_do_rot_fh ;
- smprop->m_friction_scaling[0] = kxshapeprops->m_friction_scaling[0];
- smprop->m_friction_scaling[1] = kxshapeprops->m_friction_scaling[1];
- smprop->m_friction_scaling[2] = kxshapeprops->m_friction_scaling[2];
- smprop->m_inertia = MT_Vector3(1., 1., 1.) * kxshapeprops->m_inertia;
- smprop->m_lin_drag = kxshapeprops->m_lin_drag;
- smprop->m_mass = kxshapeprops->m_mass;
- smprop->m_radius = objprop->m_radius;
-
-
- SM_MaterialProps* smmaterial = new SM_MaterialProps;
-
- smmaterial->m_fh_damping = kxmaterial->m_fh_damping;
- smmaterial->m_fh_distance = kxmaterial->m_fh_distance;
- smmaterial->m_fh_normal = kxmaterial->m_fh_normal;
- smmaterial->m_fh_spring = kxmaterial->m_fh_spring;
- smmaterial->m_friction = kxmaterial->m_friction;
- smmaterial->m_restitution = kxmaterial->m_restitution;
-
- SumoPhysicsEnvironment* sumoEnv =
- (SumoPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
-
- SM_Scene* sceneptr = sumoEnv->GetSumoScene();
-
- SM_Object* sumoObj=NULL;
-
- if (objprop->m_dyna && objprop->m_isactor)
- {
- DT_ShapeHandle shape = NULL;
- bool polytope = false;
- switch (objprop->m_boundclass)
- {
- case KX_BOUNDBOX:
- shape = DT_NewBox(objprop->m_boundobject.box.m_extends[0],
- objprop->m_boundobject.box.m_extends[1],
- objprop->m_boundobject.box.m_extends[2]);
- smprop->m_inertia.scale(objprop->m_boundobject.box.m_extends[0]*objprop->m_boundobject.box.m_extends[0],
- objprop->m_boundobject.box.m_extends[1]*objprop->m_boundobject.box.m_extends[1],
- objprop->m_boundobject.box.m_extends[2]*objprop->m_boundobject.box.m_extends[2]);
- smprop->m_inertia *= smprop->m_mass/MT_Vector3(objprop->m_boundobject.box.m_extends).length();
- break;
- case KX_BOUNDCYLINDER:
- shape = DT_NewCylinder(smprop->m_radius, objprop->m_boundobject.c.m_height);
- smprop->m_inertia.scale(smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
- break;
- case KX_BOUNDCONE:
- shape = DT_NewCone(objprop->m_radius, objprop->m_boundobject.c.m_height);
- smprop->m_inertia.scale(smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
- break;
- /* Dynamic mesh objects. WARNING! slow. */
- case KX_BOUNDPOLYTOPE:
- polytope = true;
- // fall through
- case KX_BOUNDMESH:
- if (meshobj && meshobj->NumPolygons() > 0)
- {
- if ((shape = CreateShapeFromMesh(meshobj, polytope)))
- {
- // TODO: calculate proper inertia
- smprop->m_inertia *= smprop->m_mass*smprop->m_radius*smprop->m_radius;
- break;
- }
- }
- /* If CreateShapeFromMesh fails, fall through and use sphere */
- default:
- case KX_BOUNDSPHERE:
- shape = DT_NewSphere(objprop->m_radius);
- smprop->m_inertia *= smprop->m_mass*smprop->m_radius*smprop->m_radius;
- break;
-
- }
-
- sumoObj = new SM_Object(shape, !objprop->m_ghost?smmaterial:NULL,smprop,NULL);
-
- sumoObj->setRigidBody(objprop->m_angular_rigidbody?true:false);
-
- BL_RegisterSumoObject(gameobj,sceneptr,sumoObj,"",true, true);
-
- }
- else {
- // non physics object
- if (meshobj)
- {
- int numpolys = meshobj->NumPolygons();
- {
-
- DT_ShapeHandle complexshape=0;
- bool polytope = false;
-
- switch (objprop->m_boundclass)
- {
- case KX_BOUNDBOX:
- complexshape = DT_NewBox(objprop->m_boundobject.box.m_extends[0], objprop->m_boundobject.box.m_extends[1], objprop->m_boundobject.box.m_extends[2]);
- break;
- case KX_BOUNDSPHERE:
- complexshape = DT_NewSphere(objprop->m_boundobject.c.m_radius);
- break;
- case KX_BOUNDCYLINDER:
- complexshape = DT_NewCylinder(objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_height);
- break;
- case KX_BOUNDCONE:
- complexshape = DT_NewCone(objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_height);
- break;
- case KX_BOUNDPOLYTOPE:
- polytope = true;
- // fall through
- default:
- case KX_BOUNDMESH:
- if (numpolys>0)
- {
- complexshape = CreateShapeFromMesh(meshobj, polytope);
- //std::cout << "Convert Physics Mesh: " << meshobj->GetName() << std::endl;
-/* if (!complexshape)
- {
- // Something has to be done here - if the object has no polygons, it will not be able to have
- // sensors attached to it.
- DT_Vector3 pt = {0., 0., 0.};
- complexshape = DT_NewSphere(1.0);
- objprop->m_ghost = evilObject = true;
- } */
- }
- break;
- }
-
- if (complexshape)
- {
- SM_Object *dynamicParent = NULL;
-
- if (objprop->m_dynamic_parent)
- {
- // problem is how to find the dynamic parent
- // in the scenegraph
- KX_SumoPhysicsController* sumoctrl =
- (KX_SumoPhysicsController*)
- objprop->m_dynamic_parent->GetPhysicsController();
-
- if (sumoctrl)
- {
- dynamicParent = sumoctrl->GetSumoObject();
- }
-
- MT_assert(dynamicParent);
- }
-
-
- sumoObj = new SM_Object(complexshape,!objprop->m_ghost?smmaterial:NULL,NULL, dynamicParent);
- const STR_String& matname=meshobj->GetMaterialName(0);
-
-
- BL_RegisterSumoObject(gameobj,sceneptr,
- sumoObj,
- matname,
- objprop->m_dyna,
- objprop->m_isactor);
- }
- }
- }
- }
-
- // physics object get updated here !
-
-
- // lazy evaluation because we might not support scaling !gameobj->UpdateTransform();
-
- if (objprop->m_in_active_layer && sumoObj)
- {
- sceneptr->add(*sumoObj);
- }
-
-}
-
-
-
-static void BL_RegisterSumoObject(
- KX_GameObject* gameobj,
- class SM_Scene* sumoScene,
- class SM_Object* sumoObj,
- const STR_String& matname,
- bool isDynamic,
- bool isActor)
-{
- PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
-
- // need easy access, not via 'node' etc.
- KX_SumoPhysicsController* physicscontroller = new KX_SumoPhysicsController(sumoScene,sumoObj,motionstate,isDynamic);
- gameobj->SetPhysicsController(physicscontroller,isDynamic);
-
-
- if (!gameobj->getClientInfo())
- std::cout << "BL_RegisterSumoObject: WARNING: Object " << gameobj->GetName() << " has no client info" << std::endl;
- physicscontroller->setNewClientInfo(gameobj->getClientInfo());
-
-
- gameobj->GetSGNode()->AddSGController(physicscontroller);
-
- gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC);
-
- // store materialname in auxinfo, needed for touchsensors
- gameobj->getClientInfo()->m_auxilary_info = (matname.Length() ? (void*)(matname.ReadPtr()+2) : NULL);
-
- physicscontroller->SetObject(gameobj->GetSGNode());
-}
-
-static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, RAS_DisplayArray *darray, RAS_IPolyMaterial *mat)
-{
- // instance a mesh from a single vertex array & material
- const RAS_TexVert *vertex_array = &darray->m_vertex[0];
- DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getXYZ(), sizeof(RAS_TexVert));
-
- DT_ShapeHandle shape = DT_NewComplexShape(vertex_base);
-
- std::vector<DT_Index> indices;
- for (int p = 0; p < meshobj->NumPolygons(); p++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- DT_Begin();
- DT_VertexIndex(poly->GetVertexOffset(0));
- DT_VertexIndex(poly->GetVertexOffset(1));
- DT_VertexIndex(poly->GetVertexOffset(2));
- DT_End();
-
- // tesselate
- if (poly->VertexCount() == 4)
- {
- DT_Begin();
- DT_VertexIndex(poly->GetVertexOffset(0));
- DT_VertexIndex(poly->GetVertexOffset(2));
- DT_VertexIndex(poly->GetVertexOffset(3));
- DT_End();
- }
- }
- }
-
- //DT_VertexIndices(indices.size(), &indices[0]);
- DT_EndComplexShape();
-
- map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, darray, mat));
- return shape;
-}
-
-static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, RAS_DisplayArray *darray, RAS_IPolyMaterial *mat)
-{
- // instance a mesh from a single vertex array & material
- const RAS_TexVert *vertex_array = &darray->m_vertex[0];
- DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getXYZ(), sizeof(RAS_TexVert));
-
- std::vector<DT_Index> indices;
- for (int p = 0; p < meshobj->NumPolygons(); p++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- indices.push_back(poly->GetVertexOffset(0));
- indices.push_back(poly->GetVertexOffset(1));
- indices.push_back(poly->GetVertexOffset(2));
-
- if (poly->VertexCount() == 4)
- indices.push_back(poly->GetVertexOffset(3));
- }
- }
-
- DT_ShapeHandle shape = DT_NewPolytope(vertex_base);
- DT_VertexIndices(indices.size(), &indices[0]);
- DT_EndPolytope();
-
- map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, darray, mat));
- return shape;
-}
-
-// This will have to be a method in a class somewhere...
-// Update SOLID with a changed physics mesh.
-// not used... yet.
-bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj)
-{
- KX_PhysicsInstance *instance = *map_gamemesh_to_instance[GEN_HashedPtr(meshobj)];
- if (instance)
- {
- const RAS_TexVert *vertex_array = &instance->m_darray->m_vertex[0];
- DT_ChangeVertexBase(instance->m_vertexbase, vertex_array[0].getXYZ());
- return true;
- }
- return false;
-}
-
-static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope)
-{
-
- DT_ShapeHandle *shapeptr = map_gamemesh_to_sumoshape[GEN_HashedPtr(meshobj)];
- // Mesh has already been converted: reuse
- if (shapeptr)
- {
- return *shapeptr;
- }
-
- // Mesh has no polygons!
- int numpolys = meshobj->NumPolygons();
- if (!numpolys)
- {
- return NULL;
- }
-
- // Count the number of collision polygons and check they all come from the same
- // vertex array
- int numvalidpolys = 0;
- RAS_DisplayArray *darray = NULL;
- RAS_IPolyMaterial *poly_material = NULL;
- bool reinstance = true;
-
- for (int p=0; p<numpolys; p++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- // check polygon is from the same vertex array
- if (poly->GetDisplayArray() != darray)
- {
- if (darray == NULL)
- darray = poly->GetDisplayArray();
- else
- {
- reinstance = false;
- darray = NULL;
- }
- }
-
- // check poly is from the same material
- if (poly->GetMaterial()->GetPolyMaterial() != poly_material)
- {
- if (poly_material)
- {
- reinstance = false;
- poly_material = NULL;
- }
- else
- poly_material = poly->GetMaterial()->GetPolyMaterial();
- }
-
- // count the number of collision polys
- numvalidpolys++;
-
- // We have one collision poly, and we can't reinstance, so we
- // might as well break here.
- if (!reinstance)
- break;
- }
- }
-
- // No collision polygons
- if (numvalidpolys < 1)
- return NULL;
-
- DT_ShapeHandle shape;
- if (reinstance)
- {
- if (polytope)
- shape = InstancePhysicsPolytope(meshobj, darray, poly_material);
- else
- shape = InstancePhysicsComplex(meshobj, darray, poly_material);
- }
- else
- {
- if (polytope)
- {
- std::cout << "CreateShapeFromMesh: " << meshobj->GetName() << " is not suitable for polytope." << std::endl;
- if (!poly_material)
- std::cout << " Check mesh materials." << std::endl;
- if (darray == NULL)
- std::cout << " Check number of vertices." << std::endl;
- }
-
- shape = DT_NewComplexShape(NULL);
-
- numvalidpolys = 0;
-
- for (int p2=0; p2<numpolys; p2++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p2);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- { /* We have to tesselate here because SOLID can only raycast triangles */
- DT_Begin();
- /* V1, V2, V3 */
- DT_Vertex(poly->GetVertex(2)->getXYZ());
- DT_Vertex(poly->GetVertex(1)->getXYZ());
- DT_Vertex(poly->GetVertex(0)->getXYZ());
-
- numvalidpolys++;
- DT_End();
-
- if (poly->VertexCount() == 4)
- {
- DT_Begin();
- /* V1, V3, V4 */
- DT_Vertex(poly->GetVertex(3)->getXYZ());
- DT_Vertex(poly->GetVertex(2)->getXYZ());
- DT_Vertex(poly->GetVertex(0)->getXYZ());
-
- numvalidpolys++;
- DT_End();
- }
-
- }
- }
-
- DT_EndComplexShape();
- }
-
- if (numvalidpolys > 0)
- {
- map_gamemesh_to_sumoshape.insert(GEN_HashedPtr(meshobj),shape);
- return shape;
- }
-
- delete shape;
- return NULL;
-}
-
-void KX_ClearSumoSharedShapes()
-{
- int numshapes = map_gamemesh_to_sumoshape.size();
- int i;
- for (i=0;i<numshapes ;i++)
- {
- DT_ShapeHandle shape = *map_gamemesh_to_sumoshape.at(i);
- DT_DeleteShape(shape);
- }
-
- map_gamemesh_to_sumoshape.clear();
-
- for (i=0; i < map_gamemesh_to_instance.size(); i++)
- delete *map_gamemesh_to_instance.at(i);
-
- map_gamemesh_to_instance.clear();
-}
-
-
-
-
-
-#endif //USE_SUMO_SOLID
-
-
-#ifdef USE_ODE
-
-void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- KX_Scene* kxscene,
- struct PHY_ShapeProps* shapeprops,
- struct PHY_MaterialProps* smmaterial,
- struct KX_ObjectProperties* objprop)
-{
-
- // not yet, future extension :)
- bool dyna=objprop->m_dyna;
- bool fullRigidBody= ( objprop->m_dyna && objprop->m_angular_rigidbody) != 0;
- bool phantom = objprop->m_ghost;
- class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
-
- class ODEPhysicsEnvironment* odeEnv =
- (ODEPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
-
- dxSpace* space = odeEnv->GetOdeSpace();
- dxWorld* world = odeEnv->GetOdeWorld();
-
- bool isSphere = false;
-
- switch (objprop->m_boundclass)
- {
- case KX_BOUNDBOX:
- {
-
- KX_OdePhysicsController* physicscontroller =
- new KX_OdePhysicsController(
- dyna,
- fullRigidBody,
- phantom,
- motionstate,
- space,
- world,
- shapeprops->m_mass,
- smmaterial->m_friction,
- smmaterial->m_restitution,
- isSphere,
- objprop->m_boundobject.box.m_center,
- objprop->m_boundobject.box.m_extends,
- objprop->m_boundobject.c.m_radius
- );
-
- gameobj->SetPhysicsController(physicscontroller);
- physicscontroller->setNewClientInfo(gameobj->getClientInfo());
- gameobj->GetSGNode()->AddSGController(physicscontroller);
-
- bool isActor = objprop->m_isactor;
- STR_String materialname;
- if (meshobj)
- materialname = meshobj->GetMaterialName(0);
-
- const char* matname = materialname.ReadPtr();
-
-
- physicscontroller->SetObject(gameobj->GetSGNode());
-
- break;
- }
- default:
- {
- }
- };
-
-}
-
-
-#endif // USE_ODE
-
-
#ifdef USE_BULLET
#include "CcdPhysicsEnvironment.h"
diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h
index 032098d38ad..20b60ef0173 100644
--- a/source/gameengine/Ketsji/KX_Dome.h
+++ b/source/gameengine/Ketsji/KX_Dome.h
@@ -33,7 +33,7 @@ Developed as part of a Research and Development project for SAT - La Société des
#include "RAS_IRenderTools.h"
#include "KX_KetsjiEngine.h"
-#include <BIF_gl.h>
+#include "GL/glew.h"
#include <vector>
#include "MEM_guardedalloc.h"
diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp
index 28bf12f5e87..560c7fa4bb4 100644
--- a/source/gameengine/Ketsji/KX_GameActuator.cpp
+++ b/source/gameengine/Ketsji/KX_GameActuator.cpp
@@ -49,9 +49,8 @@ KX_GameActuator::KX_GameActuator(SCA_IObject *gameobj,
const STR_String& filename,
const STR_String& loadinganimationname,
KX_Scene* scene,
- KX_KetsjiEngine* ketsjiengine,
- PyTypeObject* T)
- : SCA_IActuator(gameobj, T)
+ KX_KetsjiEngine* ketsjiengine)
+ : SCA_IActuator(gameobj)
{
m_mode = mode;
m_filename = filename;
@@ -224,26 +223,17 @@ PyTypeObject KX_GameActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject KX_GameActuator::Parents[] =
-{
- &KX_GameActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef KX_GameActuator::Methods[] =
{
// Deprecated ----->
@@ -259,21 +249,6 @@ PyAttributeDef KX_GameActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_GameActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_GameActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_GameActuator::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
-
// Deprecated ----->
/* getFile */
const char KX_GameActuator::GetFile_doc[] =
@@ -282,7 +257,7 @@ const char KX_GameActuator::GetFile_doc[] =
PyObject* KX_GameActuator::PyGetFile(PyObject* args, PyObject* kwds)
{
ShowDeprecationWarning("getFile()", "the fileName property");
- return PyString_FromString(m_filename);
+ return PyUnicode_FromString(m_filename);
}
/* setFile */
diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h
index b2b1d6ec2b9..cabbf827b40 100644
--- a/source/gameengine/Ketsji/KX_GameActuator.h
+++ b/source/gameengine/Ketsji/KX_GameActuator.h
@@ -65,8 +65,7 @@ protected:
const STR_String& filename,
const STR_String& loadinganimationname,
KX_Scene* scene,
- KX_KetsjiEngine* ketsjiEngine,
- PyTypeObject* T=&Type);
+ KX_KetsjiEngine* ketsjiEngine);
virtual ~KX_GameActuator();
virtual CValue* GetReplica();
@@ -77,10 +76,6 @@ protected:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
// Deprecated functions ----->
KX_PYMETHOD_DOC(KX_GameActuator,GetFile);
KX_PYMETHOD_DOC(KX_GameActuator,SetFile);
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 36a9efe5b91..75688a63530 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -87,10 +87,8 @@ static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3( 1.0, 0.0, 0.0,
KX_GameObject::KX_GameObject(
void* sgReplicationInfo,
- SG_Callbacks callbacks,
- PyTypeObject* T
-) :
- SCA_IObject(T),
+ SG_Callbacks callbacks)
+ : SCA_IObject(),
m_bDyna(false),
m_layer(0),
m_pBlenderObject(NULL),
@@ -984,7 +982,17 @@ void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot)
GetSGNode()->SetLocalOrientation(rot);
}
+void KX_GameObject::NodeSetGlobalOrientation(const MT_Matrix3x3& rot)
+{
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return;
+ if (GetSGNode()->GetSGParent())
+ GetSGNode()->SetLocalOrientation(GetSGNode()->GetSGParent()->GetWorldOrientation().inverse()*rot);
+ else
+ GetSGNode()->SetLocalOrientation(rot);
+}
void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale)
{
@@ -1063,7 +1071,13 @@ const MT_Matrix3x3& KX_GameObject::NodeGetWorldOrientation() const
return GetSGNode()->GetWorldOrientation();
}
-
+const MT_Matrix3x3& KX_GameObject::NodeGetLocalOrientation() const
+{
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return dummy_orientation;
+ return GetSGNode()->GetLocalOrientation();
+}
const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const
{
@@ -1074,7 +1088,14 @@ const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const
return GetSGNode()->GetWorldScaling();
}
+const MT_Vector3& KX_GameObject::NodeGetLocalScaling() const
+{
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return dummy_scaling;
+ return GetSGNode()->GetLocalScale();
+}
const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
{
@@ -1085,6 +1106,16 @@ const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
return dummy_point;
}
+const MT_Point3& KX_GameObject::NodeGetLocalPosition() const
+{
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (GetSGNode())
+ return GetSGNode()->GetLocalPosition();
+ else
+ return dummy_point;
+}
+
+
/* Suspend/ resume: for the dynamic behaviour, there is a simple
* method. For the residual motion, there is not. I wonder what the
* correct solution is for Sumo. Remove from the motion-update tree?
@@ -1152,6 +1183,181 @@ CListValue* KX_GameObject::GetChildrenRecursive()
return list;
}
+#ifdef USE_MATHUTILS
+
+/* These require an SGNode */
+#define MATHUTILS_VEC_CB_POS_LOCAL 1
+#define MATHUTILS_VEC_CB_POS_GLOBAL 2
+#define MATHUTILS_VEC_CB_SCALE_LOCAL 3
+#define MATHUTILS_VEC_CB_SCALE_GLOBAL 4
+#define MATHUTILS_VEC_CB_INERTIA_LOCAL 5
+
+static int mathutils_kxgameob_vector_cb_index= -1; /* index for our callbacks */
+
+static int mathutils_kxgameob_generic_check(PyObject *self_v)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
+ if(self==NULL)
+ return 0;
+
+ return 1;
+}
+
+static int mathutils_kxgameob_vector_get(PyObject *self_v, int subtype, float *vec_from)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
+ if(self==NULL)
+ return 0;
+
+ switch(subtype) {
+ case MATHUTILS_VEC_CB_POS_LOCAL:
+ self->NodeGetLocalPosition().getValue(vec_from);
+ break;
+ case MATHUTILS_VEC_CB_POS_GLOBAL:
+ self->NodeGetWorldPosition().getValue(vec_from);
+ break;
+ case MATHUTILS_VEC_CB_SCALE_LOCAL:
+ self->NodeGetLocalScaling().getValue(vec_from);
+ break;
+ case MATHUTILS_VEC_CB_SCALE_GLOBAL:
+ self->NodeGetWorldScaling().getValue(vec_from);
+ break;
+ case MATHUTILS_VEC_CB_INERTIA_LOCAL:
+ if(!self->GetPhysicsController()) return 0;
+ self->GetPhysicsController()->GetLocalInertia().getValue(vec_from);
+ break;
+ }
+
+ return 1;
+}
+
+static int mathutils_kxgameob_vector_set(PyObject *self_v, int subtype, float *vec_to)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
+ if(self==NULL)
+ return 0;
+
+ switch(subtype) {
+ case MATHUTILS_VEC_CB_POS_LOCAL:
+ self->NodeSetLocalPosition(MT_Point3(vec_to));
+ self->NodeUpdateGS(0.f);
+ break;
+ case MATHUTILS_VEC_CB_POS_GLOBAL:
+ self->NodeSetWorldPosition(MT_Point3(vec_to));
+ self->NodeUpdateGS(0.f);
+ break;
+ case MATHUTILS_VEC_CB_SCALE_LOCAL:
+ self->NodeSetLocalScale(MT_Point3(vec_to));
+ self->NodeUpdateGS(0.f);
+ break;
+ case MATHUTILS_VEC_CB_SCALE_GLOBAL:
+ break;
+ case MATHUTILS_VEC_CB_INERTIA_LOCAL:
+ /* read only */
+ break;
+ }
+
+ return 1;
+}
+
+static int mathutils_kxgameob_vector_get_index(PyObject *self_v, int subtype, float *vec_from, int index)
+{
+ float f[4];
+ /* lazy, avoid repeteing the case statement */
+ if(!mathutils_kxgameob_vector_get(self_v, subtype, f))
+ return 0;
+
+ vec_from[index]= f[index];
+ return 1;
+}
+
+static int mathutils_kxgameob_vector_set_index(PyObject *self_v, int subtype, float *vec_to, int index)
+{
+ float f= vec_to[index];
+
+ /* lazy, avoid repeteing the case statement */
+ if(!mathutils_kxgameob_vector_get(self_v, subtype, vec_to))
+ return 0;
+
+ vec_to[index]= f;
+ mathutils_kxgameob_vector_set(self_v, subtype, vec_to);
+
+ return 1;
+}
+
+Mathutils_Callback mathutils_kxgameob_vector_cb = {
+ mathutils_kxgameob_generic_check,
+ mathutils_kxgameob_vector_get,
+ mathutils_kxgameob_vector_set,
+ mathutils_kxgameob_vector_get_index,
+ mathutils_kxgameob_vector_set_index
+};
+
+/* Matrix */
+#define MATHUTILS_MAT_CB_ORI_LOCAL 1
+#define MATHUTILS_MAT_CB_ORI_GLOBAL 2
+
+static int mathutils_kxgameob_matrix_cb_index= -1; /* index for our callbacks */
+
+static int mathutils_kxgameob_matrix_get(PyObject *self_v, int subtype, float *mat_from)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
+ if(self==NULL)
+ return 0;
+
+ switch(subtype) {
+ case MATHUTILS_MAT_CB_ORI_LOCAL:
+ self->NodeGetLocalOrientation().getValue3x3(mat_from);
+ break;
+ case MATHUTILS_MAT_CB_ORI_GLOBAL:
+ self->NodeGetWorldOrientation().getValue3x3(mat_from);
+ break;
+ }
+
+ return 1;
+}
+
+
+static int mathutils_kxgameob_matrix_set(PyObject *self_v, int subtype, float *mat_to)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
+ if(self==NULL)
+ return 0;
+
+ MT_Matrix3x3 mat3x3;
+ switch(subtype) {
+ case MATHUTILS_MAT_CB_ORI_LOCAL:
+ mat3x3.setValue3x3(mat_to);
+ self->NodeSetLocalOrientation(mat3x3);
+ self->NodeUpdateGS(0.f);
+ break;
+ case MATHUTILS_MAT_CB_ORI_GLOBAL:
+ mat3x3.setValue3x3(mat_to);
+ self->NodeSetLocalOrientation(mat3x3);
+ self->NodeUpdateGS(0.f);
+ break;
+ }
+
+ return 1;
+}
+
+Mathutils_Callback mathutils_kxgameob_matrix_cb = {
+ mathutils_kxgameob_generic_check,
+ mathutils_kxgameob_matrix_get,
+ mathutils_kxgameob_matrix_set,
+ NULL,
+ NULL
+};
+
+
+void KX_GameObject_Mathutils_Callback_Init(void)
+{
+ // register mathutils callbacks, ok to run more then once.
+ mathutils_kxgameob_vector_cb_index= Mathutils_RegisterCallback(&mathutils_kxgameob_vector_cb);
+ mathutils_kxgameob_matrix_cb_index= Mathutils_RegisterCallback(&mathutils_kxgameob_matrix_cb);
+}
+
+#endif // USE_MATHUTILS
/* ------- python stuff ---------------------------------------------------*/
@@ -1314,7 +1520,7 @@ PyObject* KX_GameObject::PyGetPosition()
static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
- const char *attr_str= PyString_AsString(item);
+ const char *attr_str= _PyUnicode_AsString(item);
CValue* resultattr;
PyObject* pyconvert;
@@ -1348,7 +1554,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
- const char *attr_str= PyString_AsString(key);
+ const char *attr_str= _PyUnicode_AsString(key);
if(attr_str==NULL)
PyErr_Clear();
@@ -1380,7 +1586,7 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
int set= 0;
/* as CValue */
- if(attr_str && BGE_PROXY_CHECK_TYPE(val)==0) /* dont allow GameObjects for eg to be assigned to CValue props */
+ if(attr_str && PyObject_TypeCheck(val, &PyObjectPlus::Type)==0) /* dont allow GameObjects for eg to be assigned to CValue props */
{
CValue* vallie = self->ConvertPythonToValue(val, ""); /* error unused */
@@ -1442,7 +1648,7 @@ static int Seq_Contains(PyObject *self_v, PyObject *value)
return -1;
}
- if(PyString_Check(value) && self->GetProperty(PyString_AsString(value)))
+ if(PyUnicode_Check(value) && self->GetProperty(_PyUnicode_AsString(value)))
return 1;
if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value))
@@ -1490,30 +1696,23 @@ PyTypeObject KX_GameObject::Type = {
&Sequence,
&Mapping,
0,0,0,
- py_base_getattro,
- py_base_setattro,
+ NULL,
+ NULL,
0,
- Py_TPFLAGS_DEFAULT,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-
-
-
-PyParentObject KX_GameObject::Parents[] = {
- &KX_GameObject::Type,
+ Methods,
+ 0,
+ 0,
&SCA_IObject::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyObject* KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- return PyString_FromString(self->GetName().ReadPtr());
+ return PyUnicode_FromString(self->GetName().ReadPtr());
}
PyObject* KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1620,7 +1819,11 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at
PyObject* KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+#ifdef USE_MATHUTILS
+ return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL);
+#else
return PyObjectFrom(self->NodeGetWorldPosition());
+#endif
}
int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -1638,10 +1841,11 @@ int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_D
PyObject* KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- if (self->GetSGNode())
- return PyObjectFrom(self->GetSGNode()->GetLocalPosition());
- else
- return PyObjectFrom(dummy_point);
+#ifdef USE_MATHUTILS
+ return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL);
+#else
+ return PyObjectFrom(self->NodeGetLocalPosition());
+#endif
}
int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -1659,17 +1863,23 @@ int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_D
PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+#ifdef USE_MATHUTILS
+ return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL);
+#else
if (self->GetPhysicsController())
- {
return PyObjectFrom(self->GetPhysicsController()->GetLocalInertia());
- }
return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f);
+#endif
}
PyObject* KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
+#ifdef USE_MATHUTILS
+ return newMatrixObject_cb((PyObject *)self_v, 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL);
+#else
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
return PyObjectFrom(self->NodeGetWorldOrientation());
+#endif
}
int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -1681,12 +1891,7 @@ int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUT
if (!PyOrientationTo(value, rot, "gameOb.worldOrientation = sequence: KX_GameObject, "))
return PY_SET_ATTR_FAIL;
- if (self->GetSGNode() && self->GetSGNode()->GetSGParent()) {
- self->NodeSetLocalOrientation(self->GetSGNode()->GetSGParent()->GetWorldOrientation().inverse()*rot);
- }
- else {
- self->NodeSetLocalOrientation(rot);
- }
+ self->NodeSetGlobalOrientation(rot);
self->NodeUpdateGS(0.f);
return PY_SET_ATTR_SUCCESS;
@@ -1694,11 +1899,12 @@ int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUT
PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
+#ifdef USE_MATHUTILS
+ return newMatrixObject_cb((PyObject *)self_v, 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL);
+#else
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- if (self->GetSGNode())
- return PyObjectFrom(self->GetSGNode()->GetLocalOrientation());
- else
- return PyObjectFrom(dummy_orientation);
+ return PyObjectFrom(self->NodeGetLocalOrientation());
+#endif
}
int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -1718,16 +1924,21 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT
PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+#ifdef USE_MATHUTILS
+ return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL);
+#else
return PyObjectFrom(self->NodeGetWorldScaling());
+#endif
}
PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- if (self->GetSGNode())
- return PyObjectFrom(self->GetSGNode()->GetLocalScale());
- else
- return PyObjectFrom(dummy_scaling);
+#ifdef USE_MATHUTILS
+ return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL);
+#else
+ return PyObjectFrom(self->NodeGetLocalScaling());
+#endif
}
int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -1774,13 +1985,13 @@ PyObject* KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
int state = 0;
state |= self->GetState();
- return PyInt_FromLong(state);
+ return PyLong_FromSsize_t(state);
}
int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- int state_i = PyInt_AsLong(value);
+ int state_i = PyLong_AsSsize_t(value);
unsigned int state = 0;
if (state_i == -1 && PyErr_Occurred()) {
@@ -1851,128 +2062,6 @@ PyObject* KX_GameObject::pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_
return self->m_attr_dict;
}
-/* We need these because the macros have a return in them */
-PyObject* KX_GameObject::py_getattro__internal(PyObject *attr)
-{
- py_getattro_up(SCA_IObject);
-}
-
-int KX_GameObject::py_setattro__internal(PyObject *attr, PyObject *value) // py_setattro method
-{
- py_setattro_up(SCA_IObject);
-}
-
-
-PyObject* KX_GameObject::py_getattro(PyObject *attr)
-{
- PyObject *object= py_getattro__internal(attr);
-
- if (object==NULL && m_attr_dict)
- {
- /* backup the exception incase the attr doesnt exist in the dict either */
- PyObject *err_type, *err_value, *err_tb;
- PyErr_Fetch(&err_type, &err_value, &err_tb);
-
- object= PyDict_GetItem(m_attr_dict, attr);
- if (object) {
- Py_INCREF(object);
-
- PyErr_Clear();
- Py_XDECREF( err_type );
- Py_XDECREF( err_value );
- Py_XDECREF( err_tb );
- }
- else {
- PyErr_Restore(err_type, err_value, err_tb); /* use the error from the parent function */
- }
- }
- return object;
-}
-
-PyObject* KX_GameObject::py_getattro_dict() {
- //py_getattro_dict_up(SCA_IObject);
- PyObject *dict= py_getattr_dict(SCA_IObject::py_getattro_dict(), Type.tp_dict);
- if(dict==NULL)
- return NULL;
-
- /* normally just return this but KX_GameObject has some more items */
-
-
- /* Not super fast getting as a list then making into dict keys but its only for dir() */
- PyObject *list= ConvertKeysToPython();
- if(list)
- {
- int i;
- for(i=0; i<PyList_Size(list); i++)
- PyDict_SetItem(dict, PyList_GET_ITEM(list, i), Py_None);
- }
- else
- PyErr_Clear();
-
- Py_DECREF(list);
-
- /* Add m_attr_dict if we have it */
- if(m_attr_dict)
- PyDict_Update(dict, m_attr_dict);
-
- return dict;
-}
-
-int KX_GameObject::py_setattro(PyObject *attr, PyObject *value) // py_setattro method
-{
- int ret= py_setattro__internal(attr, value);
-
- if (ret==PY_SET_ATTR_SUCCESS) {
- /* remove attribute in our own dict to avoid double ups */
- /* NOTE: Annoying that we also do this for setting builtin attributes like mass and visibility :/ */
- if (m_attr_dict) {
- if (PyDict_DelItem(m_attr_dict, attr) != 0)
- PyErr_Clear();
- }
- }
-
- if (ret==PY_SET_ATTR_COERCE_FAIL) {
- /* CValue attribute exists, remove CValue and add PyDict value */
- RemoveProperty(PyString_AsString(attr));
- ret= PY_SET_ATTR_MISSING;
- }
-
- if (ret==PY_SET_ATTR_MISSING) {
- /* Lazy initialization */
- if (m_attr_dict==NULL)
- m_attr_dict = PyDict_New();
-
- if (PyDict_SetItem(m_attr_dict, attr, value)==0) {
- PyErr_Clear();
- ret= PY_SET_ATTR_SUCCESS;
- }
- else {
- PyErr_Format(PyExc_AttributeError, "gameOb.myAttr = value: KX_GameObject, failed assigning value to internal dictionary");
- ret= PY_SET_ATTR_FAIL;
- }
- }
-
- return ret;
-}
-
-
-int KX_GameObject::py_delattro(PyObject *attr)
-{
- ShowDeprecationWarning("del ob.attr", "del ob['attr'] for user defined properties");
-
- char *attr_str= PyString_AsString(attr);
-
- if (RemoveProperty(attr_str)) // XXX - should call CValues instead but its only 2 lines here
- return PY_SET_ATTR_SUCCESS;
-
- if (m_attr_dict && (PyDict_DelItem(m_attr_dict, attr) == 0))
- return PY_SET_ATTR_SUCCESS;
-
- PyErr_Format(PyExc_AttributeError, "del gameOb.myAttr: KX_GameObject, attribute \"%s\" dosnt exist", attr_str);
- return PY_SET_ATTR_MISSING;
-}
-
-
PyObject* KX_GameObject::PyApplyForce(PyObject* args)
{
int local = 0;
@@ -2116,7 +2205,7 @@ PyObject* KX_GameObject::PySetOcclusion(PyObject* args)
PyObject* KX_GameObject::PyGetVisible()
{
ShowDeprecationWarning("getVisible()", "the visible property");
- return PyInt_FromLong(m_bVisible);
+ return PyLong_FromSsize_t(m_bVisible);
}
PyObject* KX_GameObject::PyGetState()
@@ -2124,13 +2213,13 @@ PyObject* KX_GameObject::PyGetState()
ShowDeprecationWarning("getState()", "the state property");
int state = 0;
state |= GetState();
- return PyInt_FromLong(state);
+ return PyLong_FromSsize_t(state);
}
PyObject* KX_GameObject::PySetState(PyObject* value)
{
ShowDeprecationWarning("setState()", "the state property");
- int state_i = PyInt_AsLong(value);
+ int state_i = PyLong_AsSsize_t(value);
unsigned int state = 0;
if (state_i == -1 && PyErr_Occurred()) {
@@ -2436,7 +2525,7 @@ PyObject* KX_GameObject::PyGetPhysicsId()
{
physid= (uint_ptr)ctrl->GetUserData();
}
- return PyInt_FromLong((long)physid);
+ return PyLong_FromSsize_t((long)physid);
}
PyObject* KX_GameObject::PyGetPropertyNames()
@@ -2812,8 +2901,8 @@ PyObject* KX_GameObject::Pyget(PyObject *args)
return NULL;
- if(PyString_Check(key)) {
- CValue *item = GetProperty(PyString_AsString(key));
+ if(PyUnicode_Check(key)) {
+ CValue *item = GetProperty(_PyUnicode_AsString(key));
if (item) {
ret = item->ConvertValueToPython();
if(ret)
@@ -2882,13 +2971,13 @@ bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py
}
}
- if (PyString_Check(value)) {
- *object = (KX_GameObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( PyString_AsString(value) ));
+ if (PyUnicode_Check(value)) {
+ *object = (KX_GameObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) ));
if (*object) {
return true;
} else {
- PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_GameObject in this scene", error_prefix, PyString_AsString(value));
+ PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_GameObject in this scene", error_prefix, _PyUnicode_AsString(value));
return false;
}
}
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index d2450d342c1..118e17128f0 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -63,6 +63,10 @@ struct Object;
/* utility conversion function */
bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok, const char *error_prefix);
+#ifdef USE_MATHUTILS
+void KX_GameObject_Mathutils_Callback_Init(void);
+#endif
+
/**
* KX_GameObject is the main class for dynamic objects.
*/
@@ -185,8 +189,7 @@ public:
KX_GameObject(
void* sgReplicationInfo,
- SG_Callbacks callbacks,
- PyTypeObject* T=&Type
+ SG_Callbacks callbacks
);
virtual
@@ -393,6 +396,7 @@ public:
void NodeSetLocalPosition(const MT_Point3& trans );
void NodeSetLocalOrientation(const MT_Matrix3x3& rot );
+ void NodeSetGlobalOrientation(const MT_Matrix3x3& rot );
void NodeSetLocalScale( const MT_Vector3& scale );
@@ -406,21 +410,13 @@ public:
double time
);
- const
- MT_Matrix3x3&
- NodeGetWorldOrientation(
- ) const;
-
- const
- MT_Vector3&
- NodeGetWorldScaling(
- ) const;
-
- const
- MT_Point3&
- NodeGetWorldPosition(
- ) const;
+ const MT_Matrix3x3& NodeGetWorldOrientation( ) const;
+ const MT_Vector3& NodeGetWorldScaling( ) const;
+ const MT_Point3& NodeGetWorldPosition( ) const;
+ const MT_Matrix3x3& NodeGetLocalOrientation( ) const;
+ const MT_Vector3& NodeGetLocalScaling( ) const;
+ const MT_Point3& NodeGetLocalPosition( ) const;
/**
* @section scene graph node accessor functions.
@@ -811,22 +807,10 @@ public:
/**
* @section Python interface functions.
*/
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value); // py_setattro method
- virtual int py_delattro(PyObject *attr);
virtual PyObject* py_repr(void)
{
- return PyString_FromString(GetName().ReadPtr());
+ return PyUnicode_FromString(GetName().ReadPtr());
}
-
-
- /* quite annoying that we need these but the bloody
- * py_getattro_up and py_setattro_up macro's have a returns in them! */
- PyObject* py_getattro__internal(PyObject *attr);
- int py_setattro__internal(PyObject *attr, PyObject *value); // py_setattro method
-
KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition);
KX_PYMETHOD_O(KX_GameObject,SetPosition);
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp
index 3ec0598ac03..73a370a1681 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.cpp
+++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp
@@ -70,9 +70,8 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
int acttype,
bool ipo_as_force,
bool ipo_add,
- bool ipo_local,
- PyTypeObject* T)
- : SCA_IActuator(gameobj,T),
+ bool ipo_local)
+ : SCA_IActuator(gameobj),
m_bNegativeEvent(false),
m_startframe (starttime),
m_endframe(endtime),
@@ -429,19 +428,15 @@ PyTypeObject KX_IpoActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_IpoActuator::Parents[] = {
- &KX_IpoActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_IpoActuator::Methods[] = {
@@ -477,18 +472,6 @@ PyAttributeDef KX_IpoActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_IpoActuator::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_IpoActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_IpoActuator::py_setattro(PyObject *attr, PyObject *value) // py_setattro method
-{
- py_setattro_up(SCA_IActuator);
-}
/* set --------------------------------------------------------------------- */
const char KX_IpoActuator::Set_doc[] =
@@ -689,7 +672,7 @@ const char KX_IpoActuator::GetType_doc[] =
"\tReturns the operation mode of the actuator.\n";
PyObject* KX_IpoActuator::PyGetType() {
ShowDeprecationWarning("getType()", "the mode property");
- return PyInt_FromLong(m_type);
+ return PyLong_FromSsize_t(m_type);
}
/* 10. setForceIpoActsLocal: */
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h
index 9ea597def1e..01051ca82dc 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.h
+++ b/source/gameengine/Ketsji/KX_IpoActuator.h
@@ -121,8 +121,7 @@ public:
int acttype,
bool ipo_as_force,
bool ipo_add,
- bool ipo_local,
- PyTypeObject* T=&Type);
+ bool ipo_local);
virtual ~KX_IpoActuator() {};
virtual CValue* GetReplica() {
@@ -138,10 +137,6 @@ public:
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
//KX_PYMETHOD_DOC
KX_PYMETHOD_DOC_VARARGS(KX_IpoActuator,Set);
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index a43ea59220b..cc0f50d9e7a 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -61,10 +61,6 @@
#include "KX_PyConstraintBinding.h"
#include "PHY_IPhysicsEnvironment.h"
-#ifdef USE_SUMO_SOLID
-#include "SumoPhysicsEnvironment.h"
-#endif
-
#include "SND_Scene.h"
#include "SND_IAudioDevice.h"
@@ -400,9 +396,9 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo)
World* world = m_scenes[0]->GetBlenderScene()->world;
if (world)
{
- m_ticrate = world->ticrate;
- m_maxLogicFrame = world->maxlogicstep;
- m_maxPhysicsFrame = world->maxphystep;
+ m_ticrate = world->ticrate ? world->ticrate : DEFAULT_LOGIC_TIC_RATE;
+ m_maxLogicFrame = world->maxlogicstep ? world->maxlogicstep : 5;
+ m_maxPhysicsFrame = world->maxphystep ? world->maxlogicstep : 5;
}
else
{
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index ae9e097a96e..fb385f8a9a2 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -51,12 +51,9 @@
KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
class RAS_IRenderTools* rendertools,
const RAS_LightObject& lightobj,
- bool glsl,
- PyTypeObject* T
- )
- :
- KX_GameObject(sgReplicationInfo,callbacks,T),
- m_rendertools(rendertools)
+ bool glsl)
+ : KX_GameObject(sgReplicationInfo,callbacks),
+ m_rendertools(rendertools)
{
m_lightobj = lightobj;
m_lightobj.m_scene = sgReplicationInfo;
@@ -271,11 +268,6 @@ void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras)
/* Python Integration Hooks */
/* ------------------------------------------------------------------------- */
-PyObject* KX_LightObject::py_getattro_dict() {
- py_getattro_dict_up(KX_GameObject);
-}
-
-
PyTypeObject KX_LightObject::Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
@@ -297,20 +289,17 @@ PyTypeObject KX_LightObject::Type = {
&KX_GameObject::Sequence,
&KX_GameObject::Mapping,
0,0,0,
- py_base_getattro,
- py_base_setattro,
+ NULL,
+ NULL,
0,
- Py_TPFLAGS_DEFAULT,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_LightObject::Parents[] = {
- &KX_LightObject::Type,
- &KX_GameObject::Type,
- &SCA_IObject::Type,
- &CValue::Type,
- NULL
+ Methods,
+ 0,
+ 0,
+ &KX_GameObject::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_LightObject::Methods[] = {
@@ -362,11 +351,11 @@ PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT
const char* type = attrdef->m_name;
if(strcmp(type, "SPOT")) {
- retvalue = PyInt_FromLong(RAS_LightObject::LIGHT_SPOT);
+ retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_SPOT);
} else if (strcmp(type, "SUN")) {
- retvalue = PyInt_FromLong(RAS_LightObject::LIGHT_SUN);
+ retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_SUN);
} else if (strcmp(type, "NORMAL")) {
- retvalue = PyInt_FromLong(RAS_LightObject::LIGHT_NORMAL);
+ retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_NORMAL);
}
return retvalue;
@@ -375,13 +364,13 @@ PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT
PyObject* KX_LightObject::pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return PyInt_FromLong(self->m_lightobj.m_type);
+ return PyLong_FromSsize_t(self->m_lightobj.m_type);
}
int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value)
{
KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- int val = PyInt_AsLong(value);
+ int val = PyLong_AsSsize_t(value);
if((val==-1 && PyErr_Occurred()) || val<0 || val>2) {
PyErr_SetString(PyExc_ValueError, "light.type= val: KX_LightObject, expected an int between 0 and 2");
return PY_SET_ATTR_FAIL;
@@ -401,14 +390,3 @@ int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attr
return PY_SET_ATTR_SUCCESS;
}
-
-
-PyObject* KX_LightObject::py_getattro(PyObject *attr)
-{
- py_getattro_up(KX_GameObject);
-}
-
-int KX_LightObject::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(KX_GameObject);
-}
diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h
index 358c705080a..0b7ccbe81ab 100644
--- a/source/gameengine/Ketsji/KX_Light.h
+++ b/source/gameengine/Ketsji/KX_Light.h
@@ -49,7 +49,7 @@ protected:
Scene* m_blenderscene;
public:
- KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, bool glsl, PyTypeObject *T = &Type);
+ KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, bool glsl);
virtual ~KX_LightObject();
virtual CValue* GetReplica();
RAS_LightObject* GetLightData() { return &m_lightobj;}
@@ -64,10 +64,6 @@ public:
void BindShadowBuffer(class RAS_IRasterizer *ras, class KX_Camera *cam, class MT_Transform& camtrans);
void UnbindShadowBuffer(class RAS_IRasterizer *ras);
void Update();
-
- virtual PyObject* py_getattro(PyObject *attr); /* lens, near, far, projection_matrix */
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
/* attributes */
static PyObject* pyattr_get_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index c6989a81c6d..ea9bc3e0fbc 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -62,18 +62,15 @@ PyTypeObject KX_MeshProxy::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_MeshProxy::Parents[] = {
- &KX_MeshProxy::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&CValue::Type,
- &PyObjectPlus::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_MeshProxy::Methods[] = {
@@ -105,24 +102,8 @@ void KX_MeshProxy::SetMeshModified(bool v)
m_meshobj->SetMeshModified(v);
}
-
-PyObject* KX_MeshProxy::py_getattro(PyObject *attr)
-{
- py_getattro_up(CValue);
-}
-
-PyObject* KX_MeshProxy::py_getattro_dict() {
- py_getattro_dict_up(CValue);
-}
-
-int KX_MeshProxy::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(CValue);
-}
-
-
KX_MeshProxy::KX_MeshProxy(RAS_MeshObject* mesh)
- : CValue(&Type), m_meshobj(mesh)
+ : CValue(), m_meshobj(mesh)
{
}
@@ -149,14 +130,14 @@ PyObject* KX_MeshProxy::PyGetNumMaterials(PyObject* args, PyObject* kwds)
{
int num = m_meshobj->NumMaterials();
ShowDeprecationWarning("getNumMaterials()", "the numMaterials property");
- return PyInt_FromLong(num);
+ return PyLong_FromSsize_t(num);
}
PyObject* KX_MeshProxy::PyGetNumPolygons()
{
int num = m_meshobj->NumPolygons();
ShowDeprecationWarning("getNumPolygons()", "the numPolygons property");
- return PyInt_FromLong(num);
+ return PyLong_FromSsize_t(num);
}
PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds)
@@ -172,7 +153,7 @@ PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds)
return NULL;
}
- return PyString_FromString(matname.Ptr());
+ return PyUnicode_FromString(matname.Ptr());
}
@@ -190,7 +171,7 @@ PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds)
return NULL;
}
- return PyString_FromString(matname.Ptr());
+ return PyUnicode_FromString(matname.Ptr());
}
@@ -213,7 +194,7 @@ PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* args, PyObject* kwds)
length = m_meshobj->NumVertices(mat);
}
- return PyInt_FromLong(length);
+ return PyLong_FromSsize_t(length);
}
@@ -292,12 +273,12 @@ PyObject* KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_
PyObject * KX_MeshProxy::pyattr_get_numMaterials(void * selfv, const KX_PYATTRIBUTE_DEF * attrdef) {
KX_MeshProxy * self = static_cast<KX_MeshProxy *> (selfv);
- return PyInt_FromLong(self->m_meshobj->NumMaterials());
+ return PyLong_FromSsize_t(self->m_meshobj->NumMaterials());
}
PyObject * KX_MeshProxy::pyattr_get_numPolygons(void * selfv, const KX_PYATTRIBUTE_DEF * attrdef) {
KX_MeshProxy * self = static_cast<KX_MeshProxy *> (selfv);
- return PyInt_FromLong(self->m_meshobj->NumPolygons());
+ return PyLong_FromSsize_t(self->m_meshobj->NumPolygons());
}
/* a close copy of ConvertPythonToGameObject but for meshes */
@@ -320,13 +301,13 @@ bool ConvertPythonToMesh(PyObject * value, RAS_MeshObject **object, bool py_none
}
}
- if (PyString_Check(value)) {
- *object = (RAS_MeshObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String( PyString_AsString(value) ));
+ if (PyUnicode_Check(value)) {
+ *object = (RAS_MeshObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String( _PyUnicode_AsString(value) ));
if (*object) {
return true;
} else {
- PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_MeshProxy in this scene", error_prefix, PyString_AsString(value));
+ PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_MeshProxy in this scene", error_prefix, _PyUnicode_AsString(value));
return false;
}
}
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h
index cbdce3c2745..55684aa5ee9 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.h
+++ b/source/gameengine/Ketsji/KX_MeshProxy.h
@@ -56,9 +56,6 @@ public:
virtual CValue* GetReplica();
// stuff for python integration
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
KX_PYMETHOD(KX_MeshProxy,GetNumMaterials); // Deprecated
KX_PYMETHOD(KX_MeshProxy,GetMaterialName);
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index fde10a493db..ba4b47cb03f 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -63,9 +63,8 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr,
int focusmode,
KX_Scene* kxscene,
KX_KetsjiEngine *kxengine,
- SCA_IObject* gameobj,
- PyTypeObject* T)
- : SCA_MouseSensor(eventmgr, startx, starty, mousemode, gameobj, T),
+ SCA_IObject* gameobj)
+ : SCA_MouseSensor(eventmgr, startx, starty, mousemode, gameobj),
m_focusmode(focusmode),
m_kxscene(kxscene),
m_kxengine(kxengine)
@@ -356,20 +355,15 @@ PyTypeObject KX_MouseFocusSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_MouseFocusSensor::Parents[] = {
- &KX_MouseFocusSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_MouseSensor::Type,
- &SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_MouseFocusSensor::Methods[] = {
@@ -393,15 +387,6 @@ PyAttributeDef KX_MouseFocusSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_MouseFocusSensor::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_MouseSensor);
-}
-
-PyObject* KX_MouseFocusSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_MouseSensor);
-}
-
-
const char KX_MouseFocusSensor::GetHitObject_doc[] =
"getHitObject()\n"
"\tReturns the object that was hit by this ray.\n";
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
index 29d674eb305..dfada7a59cc 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
@@ -56,8 +56,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
int focusmode,
KX_Scene* kxscene,
KX_KetsjiEngine* kxengine,
- SCA_IObject* gameobj,
- PyTypeObject* T=&Type );
+ SCA_IObject* gameobj);
virtual ~KX_MouseFocusSensor() { ; };
virtual CValue* GetReplica() {
@@ -89,8 +88,6 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRayTarget);
KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRaySource);
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp
index 44842b7f5b3..1a211a64b35 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ b/source/gameengine/Ketsji/KX_NearSensor.cpp
@@ -48,15 +48,13 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
bool bFindMaterial,
const STR_String& touchedpropname,
class KX_Scene* scene,
- PHY_IPhysicsController* ctrl,
- PyTypeObject* T)
+ PHY_IPhysicsController* ctrl)
:KX_TouchSensor(eventmgr,
gameobj,
bFindMaterial,
false,
- touchedpropname,
- /* scene, */
- T),
+ touchedpropname
+ /*, scene */),
m_Margin(margin),
m_ResetMargin(resetmargin)
@@ -272,26 +270,17 @@ PyTypeObject KX_NearSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject KX_NearSensor::Parents[] = {
- &KX_NearSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&KX_TouchSensor::Type,
- &SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef KX_NearSensor::Methods[] = {
//No methods
{NULL,NULL} //Sentinel
@@ -302,18 +291,3 @@ PyAttributeDef KX_NearSensor::Attributes[] = {
KX_PYATTRIBUTE_FLOAT_RW_CHECK("resetDistance", 0, 100, KX_NearSensor, m_ResetMargin, CheckResetDistance),
{NULL} //Sentinel
};
-
-
-PyObject* KX_NearSensor::py_getattro(PyObject *attr)
-{
- py_getattro_up(KX_TouchSensor);
-}
-
-PyObject* KX_NearSensor::py_getattro_dict() {
- py_getattro_dict_up(KX_TouchSensor);
-}
-
-int KX_NearSensor::py_setattro(PyObject*attr, PyObject* value)
-{
- py_setattro_up(KX_TouchSensor);
-}
diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h
index 63099e181a0..f3c1d74805c 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.h
+++ b/source/gameengine/Ketsji/KX_NearSensor.h
@@ -54,8 +54,7 @@ public:
bool bFindMaterial,
const STR_String& touchedpropname,
class KX_Scene* scene,
- PHY_IPhysicsController* ctrl,
- PyTypeObject* T=&Type);
+ PHY_IPhysicsController* ctrl);
/*
public:
KX_NearSensor(class SCA_EventManager* eventmgr,
@@ -64,8 +63,7 @@ public:
double resetmargin,
bool bFindMaterial,
const STR_String& touchedpropname,
- class KX_Scene* scene,
- PyTypeObject* T=&Type);
+ class KX_Scene* scene);
*/
virtual ~KX_NearSensor();
virtual void SynchronizeTransform();
@@ -83,9 +81,6 @@ public:
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
//No methods
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
index eaae04d406d..ae340d12be4 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
@@ -53,10 +53,9 @@ KX_ObjectActuator(
const MT_Vector3& linV,
const MT_Vector3& angV,
const short damping,
- const KX_LocalFlags& flag,
- PyTypeObject* T
+ const KX_LocalFlags& flag
) :
- SCA_IActuator(gameobj,T),
+ SCA_IActuator(gameobj),
m_force(force),
m_torque(torque),
m_dloc(dloc),
@@ -342,19 +341,15 @@ PyTypeObject KX_ObjectActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_ObjectActuator::Parents[] = {
- &KX_ObjectActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_ObjectActuator::Methods[] = {
@@ -396,9 +391,14 @@ PyAttributeDef KX_ObjectActuator::Attributes[] = {
KX_PYATTRIBUTE_BOOL_RW("useLocalDLoc", KX_ObjectActuator, m_bitLocalFlag.DLoc),
KX_PYATTRIBUTE_VECTOR_RW_CHECK("dRot", -1000, 1000, false, KX_ObjectActuator, m_drot, PyUpdateFuzzyFlags),
KX_PYATTRIBUTE_BOOL_RW("useLocalDRot", KX_ObjectActuator, m_bitLocalFlag.DRot),
+#ifdef USE_MATHUTILS
+ KX_PYATTRIBUTE_RW_FUNCTION("linV", KX_ObjectActuator, pyattr_get_linV, pyattr_set_linV),
+ KX_PYATTRIBUTE_RW_FUNCTION("angV", KX_ObjectActuator, pyattr_get_angV, pyattr_set_angV),
+#else
KX_PYATTRIBUTE_VECTOR_RW_CHECK("linV", -1000, 1000, false, KX_ObjectActuator, m_linear_velocity, PyUpdateFuzzyFlags),
- KX_PYATTRIBUTE_BOOL_RW("useLocalLinV", KX_ObjectActuator, m_bitLocalFlag.LinearVelocity),
KX_PYATTRIBUTE_VECTOR_RW_CHECK("angV", -1000, 1000, false, KX_ObjectActuator, m_angular_velocity, PyUpdateFuzzyFlags),
+#endif
+ KX_PYATTRIBUTE_BOOL_RW("useLocalLinV", KX_ObjectActuator, m_bitLocalFlag.LinearVelocity),
KX_PYATTRIBUTE_BOOL_RW("useLocalAngV", KX_ObjectActuator, m_bitLocalFlag.AngularVelocity),
KX_PYATTRIBUTE_SHORT_RW("damping", 0, 1000, false, KX_ObjectActuator, m_damping),
KX_PYATTRIBUTE_RW_FUNCTION("forceLimitX", KX_ObjectActuator, pyattr_get_forceLimitX, pyattr_set_forceLimitX),
@@ -409,21 +409,130 @@ PyAttributeDef KX_ObjectActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_ObjectActuator::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IActuator);
+/* Attribute get/set functions */
+
+#ifdef USE_MATHUTILS
+
+/* These require an SGNode */
+#define MATHUTILS_VEC_CB_LINV 1
+#define MATHUTILS_VEC_CB_ANGV 2
+
+static int mathutils_kxobactu_vector_cb_index= -1; /* index for our callbacks */
+
+static int mathutils_obactu_generic_check(PyObject *self_v)
+{
+ KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(self_v);
+ if(self==NULL)
+ return 0;
+
+ return 1;
+}
+
+static int mathutils_obactu_vector_get(PyObject *self_v, int subtype, float *vec_from)
+{
+ KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(self_v);
+ if(self==NULL)
+ return 0;
+
+ switch(subtype) {
+ case MATHUTILS_VEC_CB_LINV:
+ self->m_linear_velocity.getValue(vec_from);
+ break;
+ case MATHUTILS_VEC_CB_ANGV:
+ self->m_angular_velocity.getValue(vec_from);
+ break;
+ }
+
+ return 1;
}
+static int mathutils_obactu_vector_set(PyObject *self_v, int subtype, float *vec_to)
+{
+ KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(self_v);
+ if(self==NULL)
+ return 0;
+
+ switch(subtype) {
+ case MATHUTILS_VEC_CB_LINV:
+ self->m_linear_velocity.setValue(vec_to);
+ break;
+ case MATHUTILS_VEC_CB_ANGV:
+ self->m_angular_velocity.setValue(vec_to);
+ break;
+ }
-PyObject* KX_ObjectActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
+ return 1;
}
-int KX_ObjectActuator::py_setattro(PyObject *attr, PyObject *value)
+static int mathutils_obactu_vector_get_index(PyObject *self_v, int subtype, float *vec_from, int index)
{
- py_setattro_up(SCA_IActuator);
+ float f[4];
+ /* lazy, avoid repeteing the case statement */
+ if(!mathutils_obactu_vector_get(self_v, subtype, f))
+ return 0;
+
+ vec_from[index]= f[index];
+ return 1;
}
-/* Attribute get/set functions */
+static int mathutils_obactu_vector_set_index(PyObject *self_v, int subtype, float *vec_to, int index)
+{
+ float f= vec_to[index];
+
+ /* lazy, avoid repeteing the case statement */
+ if(!mathutils_obactu_vector_get(self_v, subtype, vec_to))
+ return 0;
+
+ vec_to[index]= f;
+ mathutils_obactu_vector_set(self_v, subtype, vec_to);
+
+ return 1;
+}
+
+Mathutils_Callback mathutils_obactu_vector_cb = {
+ mathutils_obactu_generic_check,
+ mathutils_obactu_vector_get,
+ mathutils_obactu_vector_set,
+ mathutils_obactu_vector_get_index,
+ mathutils_obactu_vector_set_index
+};
+
+PyObject* KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV);
+}
+
+int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>(self_v);
+ if (!PyVecTo(value, self->m_linear_velocity))
+ return PY_SET_ATTR_FAIL;
+
+ return PY_SET_ATTR_SUCCESS;
+}
+
+PyObject* KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ return newVectorObject_cb((PyObject *)self_v, 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV);
+}
+
+int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>(self_v);
+ if (!PyVecTo(value, self->m_angular_velocity))
+ return PY_SET_ATTR_FAIL;
+
+ return PY_SET_ATTR_SUCCESS;
+}
+
+
+void KX_ObjectActuator_Mathutils_Callback_Init(void)
+{
+ // register mathutils callbacks, ok to run more then once.
+ mathutils_kxobactu_vector_cb_index= Mathutils_RegisterCallback(&mathutils_obactu_vector_cb);
+}
+
+#endif // USE_MATHUTILS
PyObject* KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
@@ -446,7 +555,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE
{
self->m_drot[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
self->m_dloc[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
- self->m_bitLocalFlag.Torque = (PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
+ self->m_bitLocalFlag.Torque = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
if (!PyErr_Occurred())
{
@@ -482,7 +591,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE
{
self->m_drot[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
self->m_dloc[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
- self->m_bitLocalFlag.DLoc = (PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
+ self->m_bitLocalFlag.DLoc = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
if (!PyErr_Occurred())
{
@@ -518,7 +627,7 @@ int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE
{
self->m_drot[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
self->m_dloc[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
- self->m_bitLocalFlag.DRot = (PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
+ self->m_bitLocalFlag.DRot = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2)) != 0);
if (!PyErr_Occurred())
{
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h
index f9bd2a0c748..20aec9e0e86 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.h
@@ -35,6 +35,10 @@
#include "SCA_IActuator.h"
#include "MT_Vector3.h"
+#ifdef USE_MATHUTILS
+void KX_ObjectActuator_Mathutils_Callback_Init(void);
+#endif
+
class KX_GameObject;
//
@@ -131,8 +135,7 @@ public:
const MT_Vector3& linV,
const MT_Vector3& angV,
const short damping,
- const KX_LocalFlags& flag,
- PyTypeObject* T=&Type
+ const KX_LocalFlags& flag
);
~KX_ObjectActuator();
CValue* GetReplica();
@@ -159,10 +162,6 @@ public:
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForce);
KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForce);
@@ -197,6 +196,13 @@ public:
static PyObject* pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+#ifdef USE_MATHUTILS
+ static PyObject* pyattr_get_linV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_linV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_angV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_angV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+#endif
+
// This lets the attribute macros use UpdateFuzzyFlags()
static int PyUpdateFuzzyFlags(void *self, const PyAttributeDef *attrdef)
{
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
deleted file mode 100644
index dc6990267d4..00000000000
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include "KX_ConvertPhysicsObject.h"
-
-#ifdef USE_ODE
-
-#include "KX_OdePhysicsController.h"
-#include "KX_GameObject.h"
-#include "KX_MotionState.h"
-
-#include "MT_assert.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-KX_OdePhysicsController::KX_OdePhysicsController(
- bool dyna,
- bool fullRigidBody,
- bool phantom,
- class PHY_IMotionState* motionstate,
- struct dxSpace* space,
- struct dxWorld* world,
- float mass,
- float friction,
- float restitution,
- bool implicitsphere,
- float center[3],
- float extends[3],
- float radius
- )
-: KX_IPhysicsController(dyna,false,(PHY_IPhysicsController*)this),
-ODEPhysicsController(
-dyna,fullRigidBody,phantom,motionstate,
-space,world,mass,friction,restitution,
-implicitsphere,center,extends,radius)
-{
-};
-
-
-bool KX_OdePhysicsController::Update(double time)
-{
- return SynchronizeMotionStates(time);
-}
-
-void KX_OdePhysicsController::SetObject (SG_IObject* object)
-{
- SG_Controller::SetObject(object);
-
- // cheating here...
- KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject();
- gameobj->SetPhysicsController(this);
-
-}
-
-
-
-void KX_OdePhysicsController::applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)
-{
- ODEPhysicsController::applyImpulse(attach[0],attach[1],attach[2],impulse[0],impulse[1],impulse[2]);
-}
-
-
-
-void KX_OdePhysicsController::RelativeTranslate(const MT_Vector3& dloc,bool local)
-{
- ODEPhysicsController::RelativeTranslate(dloc[0],dloc[1],dloc[2],local);
-
-}
-void KX_OdePhysicsController::RelativeRotate(const MT_Matrix3x3& drot,bool local)
-{
- double oldmat[12];
- drot.getValue(oldmat);
- float newmat[9];
- float *m = &newmat[0];
- double *orgm = &oldmat[0];
-
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
-
- ODEPhysicsController::RelativeRotate(newmat,local);
-
-}
-
-void KX_OdePhysicsController::ApplyTorque(const MT_Vector3& torque,bool local)
-{
- ODEPhysicsController::ApplyTorque(torque[0],torque[1],torque[2],local);
-
-}
-void KX_OdePhysicsController::ApplyForce(const MT_Vector3& force,bool local)
-{
- ODEPhysicsController::ApplyForce(force[0],force[1],force[2],local);
-
-}
-MT_Vector3 KX_OdePhysicsController::GetLinearVelocity()
-{
- return MT_Vector3(0,0,0);
-}
-
-MT_Vector3 KX_OdePhysicsController::GetVelocity(const MT_Point3& pos)
-{
- return MT_Vector3(0,0,0);
-}
-
-void KX_OdePhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
-{
-
-}
-void KX_OdePhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
- ODEPhysicsController::SetLinearVelocity(lin_vel[0],lin_vel[1],lin_vel[2],local);
-}
-
-void KX_OdePhysicsController::setOrientation(const MT_Matrix3x3& rot)
-{
- MT_Quaternion orn = rot.getRotation();
- ODEPhysicsController::setOrientation(orn[0],orn[1],orn[2],orn[3]);
-}
-
-void KX_OdePhysicsController::getOrientation(MT_Quaternion& orn)
-{
- float florn[4];
- florn[0]=orn[0];
- florn[1]=orn[1];
- florn[2]=orn[2];
- florn[3]=orn[3];
- ODEPhysicsController::getOrientation(florn[0],florn[1],florn[2],florn[3]);
- orn[0] = florn[0];
- orn[1] = florn[1];
- orn[2] = florn[2];
- orn[3] = florn[3];
-
-
-}
-
-void KX_OdePhysicsController::setPosition(const MT_Point3& pos)
-{
- ODEPhysicsController::setPosition(pos[0],pos[1],pos[2]);
-}
-
-void KX_OdePhysicsController::setScaling(const MT_Vector3& scaling)
-{
-}
-
-MT_Scalar KX_OdePhysicsController::GetMass()
-{
- return ODEPhysicsController::getMass();
-}
-
-MT_Scalar KX_OdePhysicsController::GetRadius()
-{
- return MT_Scalar(0.f);
-}
-
-MT_Vector3 KX_OdePhysicsController::getReactionForce()
-{
- return MT_Vector3(0,0,0);
-}
-void KX_OdePhysicsController::setRigidBody(bool rigid)
-{
-
-}
-
-void KX_OdePhysicsController::SuspendDynamics(bool)
-{
- ODEPhysicsController::SuspendDynamics();
-}
-void KX_OdePhysicsController::RestoreDynamics()
-{
- ODEPhysicsController::RestoreDynamics();
-}
-
-
-SG_Controller* KX_OdePhysicsController::GetReplica(class SG_Node* destnode)
-{
- PHY_IMotionState* motionstate = new KX_MotionState(destnode);
- KX_OdePhysicsController* copyctrl = new KX_OdePhysicsController(*this);
-
- // nlin: copied from KX_SumoPhysicsController.cpp. Not 100% sure what this does....
- // furthermore, the parentctrl is not used in ODEPhysicsController::PostProcessReplica, but
- // maybe it can/should be used in the future...
-
- // begin copy block ------------------------------------------------------------------
-
- //parentcontroller is here be able to avoid collisions between parent/child
-
- PHY_IPhysicsController* parentctrl = NULL;
-
- if (destnode != destnode->GetRootSGParent())
- {
- KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject();
- if (clientgameobj)
- {
- parentctrl = (KX_OdePhysicsController*)clientgameobj->GetPhysicsController();
- } else
- {
- // it could be a false node, try the children
- NodeList::const_iterator childit;
- for (
- childit = destnode->GetSGChildren().begin();
- childit!= destnode->GetSGChildren().end();
- ++childit
- ) {
- KX_GameObject* clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj)
- {
- parentctrl = (KX_OdePhysicsController*)clientgameobj->GetPhysicsController();
- }
- }
- }
- }
- // end copy block ------------------------------------------------------------------
-
- copyctrl->PostProcessReplica(motionstate, this);
-
- return copyctrl;
-
-}
-
-void KX_OdePhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
-}
-
-
-void KX_OdePhysicsController::SetSumoTransform(bool nondynaonly)
-{
-
-}
- // todo: remove next line !
-void KX_OdePhysicsController::SetSimulatedTime(double time)
-{
-
-}
-
-#endif //USE_ODE
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h
deleted file mode 100644
index 8c3974c38a3..00000000000
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __KX_ODEPHYSICSCONTROLLER_H
-#define __KX_ODEPHYSICSCONTROLLER_H
-
-#include "KX_IPhysicsController.h"
-#include "OdePhysicsController.h"
-
-/**
- Physics Controller, a special kind of Scene Graph Transformation Controller.
- It get's callbacks from Physics in case a transformation change took place.
- Each time the scene graph get's updated, the controller get's a chance
- in the 'Update' method to reflect changed.
-*/
-
-class KX_OdePhysicsController : public KX_IPhysicsController, public ODEPhysicsController
-
-{
-
-public:
- KX_OdePhysicsController(
- bool dyna,
- bool fullRigidBody,
- bool phantom,
- class PHY_IMotionState* motionstate,
- struct dxSpace* space,
- struct dxWorld* world,
- float mass,
- float friction,
- float restitution,
- bool implicitsphere,
- float center[3],
- float extends[3],
- float radius);
-
- virtual ~KX_OdePhysicsController() {};
-
- virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse);
- virtual void SetObject (SG_IObject* object);
-
- virtual void RelativeTranslate(const MT_Vector3& dloc,bool local);
- virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local);
- virtual void ApplyTorque(const MT_Vector3& torque,bool local);
- virtual void ApplyForce(const MT_Vector3& force,bool local);
- virtual MT_Vector3 GetLinearVelocity();
- virtual MT_Vector3 GetVelocity(const MT_Point3& pos);
- virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
- virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
- virtual void getOrientation(MT_Quaternion& orn);
- virtual void setOrientation(const MT_Matrix3x3& orn);
- virtual void setPosition(const MT_Point3& pos);
- virtual void setScaling(const MT_Vector3& scaling);
- virtual void SetTransform() {}
- virtual MT_Scalar GetMass();
- virtual MT_Vector3 getReactionForce();
- virtual void setRigidBody(bool rigid);
- virtual void AddCompoundChild(KX_IPhysicsController* child) { }
- virtual void RemoveCompoundChild(KX_IPhysicsController* child) { }
-
- virtual void SuspendDynamics(bool);
- virtual void RestoreDynamics();
- virtual MT_Scalar GetRadius();
-
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
-
- virtual float GetLinVelocityMin() { return ODEPhysicsController::GetLinVelocityMin(); }
- virtual void SetLinVelocityMin(float val) { ODEPhysicsController::SetLinVelocityMin(val); }
- virtual float GetLinVelocityMax() { return ODEPhysicsController::GetLinVelocityMax(); }
- virtual void SetLinVelocityMax(float val) { ODEPhysicsController::SetLinVelocityMax(val); }
-
- virtual void SetSumoTransform(bool nondynaonly);
- // todo: remove next line !
- virtual void SetSimulatedTime(double time);
-
- // call from scene graph to update
- virtual bool Update(double time);
-
- void
- SetOption(
- int option,
- int value
- ){
- // intentionally empty
- };
-
-};
-
-#endif //__KX_ODEPHYSICSCONTROLLER_H
-
diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp
index cd2ed456c48..befa2aaff56 100644
--- a/source/gameengine/Ketsji/KX_ParentActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp
@@ -50,9 +50,8 @@ KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj,
int mode,
bool addToCompound,
bool ghost,
- SCA_IObject *ob,
- PyTypeObject* T)
- : SCA_IActuator(gameobj, T),
+ SCA_IObject *ob)
+ : SCA_IActuator(gameobj),
m_mode(mode),
m_addToCompound(addToCompound),
m_ghost(ghost),
@@ -157,19 +156,15 @@ PyTypeObject KX_ParentActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_ParentActuator::Parents[] = {
- &KX_ParentActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_ParentActuator::Methods[] = {
@@ -217,18 +212,6 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE
}
-PyObject* KX_ParentActuator::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_ParentActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_ParentActuator::py_setattro(PyObject *attr, PyObject* value) {
- py_setattro_up(SCA_IActuator);
-}
-
/* Deprecated -----> */
/* 1. setObject */
const char KX_ParentActuator::SetObject_doc[] =
@@ -273,7 +256,7 @@ PyObject* KX_ParentActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_ob->GetName().ReadPtr());
+ return PyUnicode_FromString(m_ob->GetName().ReadPtr());
else
return m_ob->GetProxy();
}
diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h
index 148375e994c..aeb39eabf89 100644
--- a/source/gameengine/Ketsji/KX_ParentActuator.h
+++ b/source/gameengine/Ketsji/KX_ParentActuator.h
@@ -68,8 +68,7 @@ class KX_ParentActuator : public SCA_IActuator
int mode,
bool addToCompound,
bool ghost,
- SCA_IObject *ob,
- PyTypeObject* T=&Type);
+ SCA_IObject *ob);
virtual ~KX_ParentActuator();
virtual bool Update();
@@ -82,10 +81,6 @@ class KX_ParentActuator : public SCA_IActuator
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
-
/* These are used to get and set m_ob */
static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
index c968e50957e..7bce311f1b6 100644
--- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
@@ -39,8 +39,8 @@
KX_PhysicsObjectWrapper::KX_PhysicsObjectWrapper(
PHY_IPhysicsController* ctrl,
- PHY_IPhysicsEnvironment* physenv,PyTypeObject *T) :
- PyObjectPlus(T),
+ PHY_IPhysicsEnvironment* physenv) :
+ PyObjectPlus(),
m_ctrl(ctrl),
m_physenv(physenv)
{
@@ -129,46 +129,17 @@ PyTypeObject KX_PhysicsObjectWrapper::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_PhysicsObjectWrapper::Parents[] = {
- &KX_PhysicsObjectWrapper::Type,
- NULL
-};
-
-PyObject* KX_PhysicsObjectWrapper::py_getattro(PyObject *attr)
-{
- py_getattro_up(PyObjectPlus);
-}
-
-PyObject* KX_PhysicsObjectWrapper::py_getattro_dict() {
- py_getattro_dict_up(PyObjectPlus);
-}
-
-int KX_PhysicsObjectWrapper::py_setattro(PyObject *attr,PyObject *pyobj)
-{
- int result = 1;
-
- if (PyInt_Check(pyobj))
- {
- result = 0;
- }
- if (PyString_Check(pyobj))
- {
- result = 0;
- }
- if (result)
- result = PyObjectPlus::py_setattro(attr,pyobj);
-
- return result;
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &PyObjectPlus::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-
PyMethodDef KX_PhysicsObjectWrapper::Methods[] = {
{"setPosition",(PyCFunction) KX_PhysicsObjectWrapper::sPySetPosition, METH_VARARGS},
{"setLinearVelocity",(PyCFunction) KX_PhysicsObjectWrapper::sPySetLinearVelocity, METH_VARARGS},
diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h
index 1b59686babc..fa6fd1d1f2a 100644
--- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h
+++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h
@@ -35,12 +35,8 @@
class KX_PhysicsObjectWrapper : public PyObjectPlus
{
Py_Header;
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
public:
- KX_PhysicsObjectWrapper(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
+ KX_PhysicsObjectWrapper(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsEnvironment* physenv);
virtual ~KX_PhysicsObjectWrapper();
KX_PYMETHOD_VARARGS(KX_PhysicsObjectWrapper,SetPosition);
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
index b56b5500c39..a1571b17756 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.cpp
+++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp
@@ -55,18 +55,15 @@ PyTypeObject KX_PolyProxy::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_PolyProxy::Parents[] = {
- &KX_PolyProxy::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&CValue::Type,
- &PyObjectPlus::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_PolyProxy::Methods[] = {
@@ -98,16 +95,17 @@ PyAttributeDef KX_PolyProxy::Attributes[] = {
{ NULL } //Sentinel
};
+#if 0
PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
{
- char *attr_str= PyString_AsString(attr);
+ char *attr_str= _PyUnicode_AsString(attr);
if (!strcmp(attr_str, "matname"))
{
- return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
+ return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
}
if (!strcmp(attr_str, "texture"))
{
- return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
+ return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
}
if (!strcmp(attr_str, "material"))
{
@@ -136,38 +134,35 @@ PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
// found it
break;
}
- return PyInt_FromLong(matid);
+ return PyLong_FromSsize_t(matid);
}
if (!strcmp(attr_str, "v1"))
{
- return PyInt_FromLong(m_polygon->GetVertexOffset(0));
+ return PyLong_FromSsize_t(m_polygon->GetVertexOffset(0));
}
if (!strcmp(attr_str, "v2"))
{
- return PyInt_FromLong(m_polygon->GetVertexOffset(1));
+ return PyLong_FromSsize_t(m_polygon->GetVertexOffset(1));
}
if (!strcmp(attr_str, "v3"))
{
- return PyInt_FromLong(m_polygon->GetVertexOffset(2));
+ return PyLong_FromSsize_t(m_polygon->GetVertexOffset(2));
}
if (!strcmp(attr_str, "v4"))
{
- return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0));
+ return PyLong_FromSsize_t(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0));
}
if (!strcmp(attr_str, "visible"))
{
- return PyInt_FromLong(m_polygon->IsVisible());
+ return PyLong_FromSsize_t(m_polygon->IsVisible());
}
if (!strcmp(attr_str, "collide"))
{
- return PyInt_FromLong(m_polygon->IsCollider());
+ return PyLong_FromSsize_t(m_polygon->IsCollider());
}
- py_getattro_up(CValue);
-}
-
-PyObject* KX_PolyProxy::py_getattro_dict() {
- py_getattro_dict_up(CValue);
+ // py_getattro_up(CValue); // XXX -- todo, make all these attributes
}
+#endif
KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
: m_polygon(polygon),
@@ -204,37 +199,37 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialIndex,
// found it
break;
}
- return PyInt_FromLong(matid);
+ return PyLong_FromSsize_t(matid);
}
KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getNumVertex,
"getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n")
{
- return PyInt_FromLong(m_polygon->VertexCount());
+ return PyLong_FromSsize_t(m_polygon->VertexCount());
}
KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isVisible,
"isVisible() : returns whether the polygon is visible or not\n")
{
- return PyInt_FromLong(m_polygon->IsVisible());
+ return PyLong_FromSsize_t(m_polygon->IsVisible());
}
KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider,
"isCollider() : returns whether the polygon is receives collision or not\n")
{
- return PyInt_FromLong(m_polygon->IsCollider());
+ return PyLong_FromSsize_t(m_polygon->IsCollider());
}
KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName,
"getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n")
{
- return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
+ return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
}
KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getTextureName,
"getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n")
{
- return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
+ return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
}
KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
@@ -255,9 +250,9 @@ KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
}
if (index < m_polygon->VertexCount())
{
- return PyInt_FromLong(m_polygon->GetVertexOffset(index));
+ return PyLong_FromSsize_t(m_polygon->GetVertexOffset(index));
}
- return PyInt_FromLong(0);
+ return PyLong_FromSsize_t(0);
}
KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMesh,
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h
index d8fd36fec6c..e619617d312 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.h
+++ b/source/gameengine/Ketsji/KX_PolyProxy.h
@@ -52,8 +52,6 @@ public:
// stuff for python integration
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex)
KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex)
diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
index 506c167a905..9bc84127572 100644
--- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
@@ -51,8 +51,8 @@
#include "KX_PyMath.h"
-KX_PolygonMaterial::KX_PolygonMaterial(PyTypeObject *T)
- : PyObjectPlus(T),
+KX_PolygonMaterial::KX_PolygonMaterial()
+ : PyObjectPlus(),
RAS_IPolyMaterial(),
m_tface(NULL),
@@ -115,7 +115,7 @@ bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingI
PyObject *ret = PyObject_CallMethod(m_pymaterial, "activate", "(NNO)", pyRasty, pyCachingInfo, (PyObject*) this->m_proxy);
if (ret)
{
- bool value = PyInt_AsLong(ret);
+ bool value = PyLong_AsSsize_t(ret);
Py_DECREF(ret);
dopass = value;
}
@@ -255,33 +255,17 @@ PyTypeObject KX_PolygonMaterial::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_PolygonMaterial::Parents[] = {
- &KX_PolygonMaterial::Type,
- &PyObjectPlus::Type,
- NULL
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &PyObjectPlus::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-PyObject* KX_PolygonMaterial::py_getattro(PyObject *attr)
-{
- py_getattro_up(PyObjectPlus);
-}
-
-PyObject* KX_PolygonMaterial::py_getattro_dict() {
- py_getattro_dict_up(PyObjectPlus);
-}
-
-int KX_PolygonMaterial::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(PyObjectPlus);
-}
-
KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setCustomMaterial, "setCustomMaterial(material)")
{
PyObject *material;
@@ -347,13 +331,13 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, activate, "activate(rasty, cachingInfo)")
PyObject* KX_PolygonMaterial::pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v);
- return PyString_FromString(self->m_texturename.ReadPtr());
+ return PyUnicode_FromString(self->m_texturename.ReadPtr());
}
PyObject* KX_PolygonMaterial::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v);
- return PyString_FromString(self->m_materialname.ReadPtr());
+ return PyUnicode_FromString(self->m_materialname.ReadPtr());
}
/* this does not seem useful */
@@ -370,7 +354,7 @@ PyObject* KX_PolygonMaterial::pyattr_get_gl_texture(void *self_v, const KX_PYATT
if (self->m_tface && self->m_tface->tpage)
bindcode= self->m_tface->tpage->bindcode;
- return PyInt_FromLong(bindcode);
+ return PyLong_FromSsize_t(bindcode);
}
diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h
index 89ecb026da9..266b4d7e789 100644
--- a/source/gameengine/Ketsji/KX_PolygonMaterial.h
+++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h
@@ -57,7 +57,7 @@ private:
mutable int m_pass;
public:
- KX_PolygonMaterial(PyTypeObject *T = &Type);
+ KX_PolygonMaterial();
void Initialize(const STR_String &texname,
Material* ma,
int materialindex,
@@ -116,10 +116,7 @@ public:
KX_PYMETHOD_DOC(KX_PolygonMaterial, setCustomMaterial);
KX_PYMETHOD_DOC(KX_PolygonMaterial, loadProgram);
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
- virtual PyObject* py_repr(void) { return PyString_FromString(m_material ? ((ID *)m_material)->name+2 : ""); }
+ virtual PyObject* py_repr(void) { return PyUnicode_FromString(m_material ? ((ID *)m_material)->name+2 : ""); }
static PyObject* pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
index 4ec901a2f5e..94e8d1fd583 100644
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
@@ -640,7 +640,7 @@ PyObject* initPythonConstraintBinding()
// Add some symbolic constants to the module
d = PyModule_GetDict(m);
- ErrorObject = PyString_FromString("PhysicsConstraints.error");
+ ErrorObject = PyUnicode_FromString("PhysicsConstraints.error");
PyDict_SetItemString(d, "error", ErrorObject);
Py_DECREF(ErrorObject);
diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp
index 051d7ae7dba..6d33c38190c 100644
--- a/source/gameengine/Ketsji/KX_PyMath.cpp
+++ b/source/gameengine/Ketsji/KX_PyMath.cpp
@@ -46,35 +46,6 @@
#include "KX_Python.h"
#include "KX_PyMath.h"
-bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank)
-{
- if (!pymat)
- return false;
-
- unsigned int y;
- if (PySequence_Check(pymat))
- {
- unsigned int rows = PySequence_Size(pymat);
- if (rows != rank)
- return false;
-
- bool ismatrix = true;
- for (y = 0; y < rank && ismatrix; y++)
- {
- PyObject *pyrow = PySequence_GetItem(pymat, y); /* new ref */
- if (PySequence_Check(pyrow))
- {
- if (((unsigned int)PySequence_Size(pyrow)) != rank)
- ismatrix = false;
- } else
- ismatrix = false;
- Py_DECREF(pyrow);
- }
- return ismatrix;
- }
- return false;
-}
-
bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &rot, const char *error_prefix)
{
int size= PySequence_Size(pyval);
@@ -82,7 +53,7 @@ bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &rot, const char *error_prefi
if (size == 4)
{
MT_Quaternion qrot;
- if (PyVecTo(pyval, qrot))
+ if (PyQuatTo(pyval, qrot))
{
rot.setRotation(qrot);
return true;
@@ -108,14 +79,27 @@ bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &rot, const char *error_prefi
return false;
}
+bool PyQuatTo(PyObject* pyval, MT_Quaternion &qrot)
+{
+ if(!PyVecTo(pyval, qrot))
+ return false;
+
+ /* annoying!, Blender/Mathutils have the W axis first! */
+ MT_Scalar w= qrot[0]; /* from python, this is actually the W */
+ qrot[0]= qrot[1];
+ qrot[1]= qrot[2];
+ qrot[2]= qrot[3];
+ qrot[3]= w;
+
+ return true;
+}
+
PyObject* PyObjectFrom(const MT_Matrix4x4 &mat)
{
-#if 0
- return Py_BuildValue("[[ffff][ffff][ffff][ffff]]",
- mat[0][0], mat[0][1], mat[0][2], mat[0][3],
- mat[1][0], mat[1][1], mat[1][2], mat[1][3],
- mat[2][0], mat[2][1], mat[2][2], mat[2][3],
- mat[3][0], mat[3][1], mat[3][2], mat[3][3]);
+#ifdef USE_MATHUTILS
+ float fmat[16];
+ mat.getValue(fmat);
+ return newMatrixObject(fmat, 4, 4, Py_NEW, NULL);
#else
PyObject *list = PyList_New(4);
PyObject *sublist;
@@ -136,11 +120,10 @@ PyObject* PyObjectFrom(const MT_Matrix4x4 &mat)
PyObject* PyObjectFrom(const MT_Matrix3x3 &mat)
{
-#if 0
- return Py_BuildValue("[[fff][fff][fff]]",
- mat[0][0], mat[0][1], mat[0][2],
- mat[1][0], mat[1][1], mat[1][2],
- mat[2][0], mat[2][1], mat[2][2]);
+#ifdef USE_MATHUTILS
+ float fmat[9];
+ mat.getValue3x3(fmat);
+ return newMatrixObject(fmat, 3, 3, Py_NEW, NULL);
#else
PyObject *list = PyList_New(3);
PyObject *sublist;
@@ -158,11 +141,20 @@ PyObject* PyObjectFrom(const MT_Matrix3x3 &mat)
#endif
}
+#ifdef USE_MATHUTILS
+PyObject* PyObjectFrom(const MT_Quaternion &qrot)
+{
+ /* NOTE, were re-ordering here for Mathutils compat */
+ float fvec[4]= {qrot[3], qrot[0], qrot[1], qrot[2]};
+ return newQuaternionObject(fvec, Py_WRAP, NULL);
+}
+#endif
+
PyObject* PyObjectFrom(const MT_Tuple4 &vec)
{
-#if 0
- return Py_BuildValue("[ffff]",
- vec[0], vec[1], vec[2], vec[3]);
+#ifdef USE_MATHUTILS
+ float fvec[4]= {vec[0], vec[1], vec[2], vec[3]};
+ return newVectorObject(fvec, 4, Py_WRAP, NULL);
#else
PyObject *list = PyList_New(4);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
@@ -175,9 +167,9 @@ PyObject* PyObjectFrom(const MT_Tuple4 &vec)
PyObject* PyObjectFrom(const MT_Tuple3 &vec)
{
-#if 0
- return Py_BuildValue("[fff]",
- vec[0], vec[1], vec[2]);
+#ifdef USE_MATHUTILS
+ float fvec[3]= {vec[0], vec[1], vec[2]};
+ return newVectorObject(fvec, 3, Py_WRAP, NULL);
#else
PyObject *list = PyList_New(3);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
@@ -189,9 +181,9 @@ PyObject* PyObjectFrom(const MT_Tuple3 &vec)
PyObject* PyObjectFrom(const MT_Tuple2 &vec)
{
-#if 0
- return Py_BuildValue("[ff]",
- vec[0], vec[1]);
+#ifdef USE_MATHUTILS
+ float fvec[2]= {vec[0], vec[1]};
+ return newVectorObject(fvec, 2, Py_WRAP, NULL);
#else
PyObject *list = PyList_New(2);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h
index a7ce4bc6930..9ee11c9e745 100644
--- a/source/gameengine/Ketsji/KX_PyMath.h
+++ b/source/gameengine/Ketsji/KX_PyMath.h
@@ -42,6 +42,12 @@
#include "KX_Python.h"
#include "PyObjectPlus.h"
+#ifdef USE_MATHUTILS
+extern "C" {
+#include "../../blender/python/generic/Mathutils.h" /* so we can have mathutils callbacks */
+}
+#endif
+
inline unsigned int Size(const MT_Matrix4x4&) { return 4; }
inline unsigned int Size(const MT_Matrix3x3&) { return 3; }
inline unsigned int Size(const MT_Tuple2&) { return 2; }
@@ -98,7 +104,38 @@ bool PyMatTo(PyObject* pymat, T& mat)
template<class T>
bool PyVecTo(PyObject* pyval, T& vec)
{
-
+#ifdef USE_MATHUTILS
+ /* no need for BaseMath_ReadCallback() here, reading the sequences will do this */
+
+ if(VectorObject_Check(pyval)) {
+ VectorObject *pyvec= (VectorObject *)pyval;
+ if (pyvec->size != Size(vec)) {
+ PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", pyvec->size, Size(vec));
+ return false;
+ }
+ vec.getValue((float *) pyvec->vec);
+ return true;
+ }
+ else if(QuaternionObject_Check(pyval)) {
+ QuaternionObject *pyquat= (QuaternionObject *)pyval;
+ if (4 != Size(vec)) {
+ PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 4, Size(vec));
+ return false;
+ }
+ /* xyzw -> wxyz reordering is done by PyQuatTo */
+ vec.getValue((float *) pyquat->quat);
+ return true;
+ }
+ else if(EulerObject_Check(pyval)) {
+ EulerObject *pyeul= (EulerObject *)pyval;
+ if (3 != Size(vec)) {
+ PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 3, Size(vec));
+ return false;
+ }
+ vec.getValue((float *) pyeul->eul);
+ return true;
+ } else
+#endif
if(PyTuple_Check(pyval))
{
unsigned int numitems = PyTuple_GET_SIZE(pyval);
@@ -117,7 +154,7 @@ bool PyVecTo(PyObject* pyval, T& vec)
return true;
}
- else if (BGE_PROXY_CHECK_TYPE(pyval))
+ else if (PyObject_TypeCheck(pyval, &PyObjectPlus::Type))
{ /* note, include this check because PySequence_Check does too much introspection
* on the PyObject (like getting its __class__, on a BGE type this means searching up
* the parent list each time only to discover its not a sequence.
@@ -159,6 +196,9 @@ bool PyVecTo(PyObject* pyval, T& vec)
return false;
}
+
+bool PyQuatTo(PyObject* pyval, MT_Quaternion &qrot);
+
bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &mat, const char *error_prefix);
/**
@@ -181,15 +221,16 @@ PyObject* PyObjectFrom(const MT_Tuple2 &vec);
*/
PyObject* PyObjectFrom(const MT_Tuple3 &vec);
+#ifdef USE_MATHUTILS
/**
- * Converts an MT_Tuple4 to a python object.
+ * Converts an MT_Quaternion to a python object.
*/
-PyObject* PyObjectFrom(const MT_Tuple4 &pos);
+PyObject* PyObjectFrom(const MT_Quaternion &qrot);
+#endif
/**
- * True if the given PyObject can be converted to an MT_Matrix
- * @param rank = 3 (for MT_Matrix3x3) or 4 (for MT_Matrix4x4)
+ * Converts an MT_Tuple4 to a python object.
*/
-bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank);
+PyObject* PyObjectFrom(const MT_Tuple4 &pos);
#endif
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 75b29481e54..ac49b49c130 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -42,6 +42,13 @@
#pragma warning (disable : 4786)
#endif //WIN32
+extern "C" {
+ #include "bpy_internal_import.h" /* from the blender python api, but we want to import text too! */
+ #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use.
+ #include "Geometry.h" // Blender.Geometry module copied here so the blenderlayer can use.
+ #include "BGL.h"
+}
+
#include "KX_PythonInit.h"
//python physics binding
#include "KX_PyConstraintBinding.h"
@@ -86,16 +93,7 @@
/* we only need this to get a list of libraries from the main struct */
#include "DNA_ID.h"
-#include "BKE_main.h"
-extern "C" {
- #include "bpy_internal_import.h" /* from the blender python api, but we want to import text too! */
-#if PY_VERSION_HEX < 0x03000000
- #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use.
- #include "Geometry.h" // Blender.Geometry module copied here so the blenderlayer can use.
- #include "BGL.h"
-#endif
-}
#include "marshal.h" /* python header for loading/saving dicts */
@@ -107,6 +105,7 @@ extern "C" {
//#include "BPY_extern.h"
#endif
+#include "BKE_main.h"
#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BLI_blenlib.h"
@@ -131,10 +130,10 @@ void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,cons
}
/* Macro for building the keyboard translation */
-//#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyInt_FromLong(SCA_IInputDevice::KX_##name))
-#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, item=PyInt_FromLong(name)); Py_DECREF(item)
+//#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyLong_FromSsize_t(SCA_IInputDevice::KX_##name))
+#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, item=PyLong_FromSsize_t(name)); Py_DECREF(item)
/* For the defines for types from logic bricks, we do stuff explicitly... */
-#define KX_MACRO_addTypesToDict(dict, name, name2) PyDict_SetItemString(dict, #name, item=PyInt_FromLong(name2)); Py_DECREF(item)
+#define KX_MACRO_addTypesToDict(dict, name, name2) PyDict_SetItemString(dict, #name, item=PyLong_FromSsize_t(name2)); Py_DECREF(item)
// temporarily python stuff, will be put in another place later !
@@ -182,7 +181,7 @@ static PyObject* gPyExpandPath(PyObject*, PyObject* args)
BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE);
BLI_convertstringcode(expanded, gp_GamePythonPath);
- return PyString_FromString(expanded);
+ return PyUnicode_FromString(expanded);
}
static char gPySendMessage_doc[] =
@@ -307,7 +306,7 @@ static PyObject* gPySetMaxLogicFrame(PyObject*, PyObject* args)
static PyObject* gPyGetMaxLogicFrame(PyObject*)
{
- return PyInt_FromLong(KX_KetsjiEngine::GetMaxLogicFrame());
+ return PyLong_FromSsize_t(KX_KetsjiEngine::GetMaxLogicFrame());
}
static PyObject* gPySetMaxPhysicsFrame(PyObject*, PyObject* args)
@@ -322,7 +321,7 @@ static PyObject* gPySetMaxPhysicsFrame(PyObject*, PyObject* args)
static PyObject* gPyGetMaxPhysicsFrame(PyObject*)
{
- return PyInt_FromLong(KX_KetsjiEngine::GetMaxPhysicsFrame());
+ return PyLong_FromSsize_t(KX_KetsjiEngine::GetMaxPhysicsFrame());
}
static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args)
@@ -387,7 +386,7 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args)
while ((dirp = readdir(dp)) != NULL) {
if (BLI_testextensie(dirp->d_name, ".blend")) {
- value = PyString_FromString(dirp->d_name);
+ value = PyUnicode_FromString(dirp->d_name);
PyList_Append(list, value);
Py_DECREF(value);
}
@@ -501,7 +500,7 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
static PyObject *gEvalExpression(PyObject*, PyObject* value)
{
- char* txt= PyString_AsString(value);
+ char* txt= _PyUnicode_AsString(value);
if (txt==NULL) {
PyErr_SetString(PyExc_TypeError, "Expression.calc(text): expects a single string argument");
@@ -559,14 +558,14 @@ static struct PyMethodDef game_methods[] = {
static PyObject* gPyGetWindowHeight(PyObject*, PyObject* args)
{
- return PyInt_FromLong((gp_Canvas ? gp_Canvas->GetHeight() : 0));
+ return PyLong_FromSsize_t((gp_Canvas ? gp_Canvas->GetHeight() : 0));
}
static PyObject* gPyGetWindowWidth(PyObject*, PyObject* args)
{
- return PyInt_FromLong((gp_Canvas ? gp_Canvas->GetWidth() : 0));
+ return PyLong_FromSsize_t((gp_Canvas ? gp_Canvas->GetWidth() : 0));
}
@@ -894,7 +893,7 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*,
}
enabled = ((G.fileflags & flag) != 0);
- return PyInt_FromLong(enabled);
+ return PyLong_FromSsize_t(enabled);
}
#define KX_TEXFACE_MATERIAL 0
@@ -938,7 +937,7 @@ static PyObject* gPyGetMaterialType(PyObject*)
else
flag = KX_TEXFACE_MATERIAL;
- return PyInt_FromLong(flag);
+ return PyLong_FromSsize_t(flag);
}
static PyObject* gPyDrawLine(PyObject*, PyObject* args)
@@ -1076,7 +1075,7 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
PyDict_SetItemString(d, "globalDict", item=PyDict_New()); Py_DECREF(item);
- ErrorObject = PyString_FromString("GameLogic.error");
+ ErrorObject = PyUnicode_FromString("GameLogic.error");
PyDict_SetItemString(d, "error", ErrorObject);
Py_DECREF(ErrorObject);
@@ -1363,7 +1362,7 @@ PyObject *KXpy_import(PyObject *self, PyObject *args)
/* check for builtin modules */
m = PyImport_AddModule("sys");
l = PyObject_GetAttrString(m, "builtin_module_names");
- n = PyString_FromString(name);
+ n = PyUnicode_FromString(name);
if (PySequence_Contains(l, n)) {
return PyImport_ImportModuleEx(name, globals, locals, fromlist);
@@ -1539,7 +1538,7 @@ static void initPySysObjects__append(PyObject *sys_path, char *filename)
BLI_split_dirfile_basic(filename, expanded, NULL); /* get the dir part of filename only */
BLI_convertstringcode(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */
BLI_cleanup_file(gp_GamePythonPath, expanded); /* Dont use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */
- item= PyString_FromString(expanded);
+ item= PyUnicode_FromString(expanded);
// printf("SysPath - '%s', '%s', '%s'\n", expanded, filename, gp_GamePythonPath);
@@ -1623,10 +1622,20 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur
Py_FrozenFlag=1;
Py_Initialize();
+ if(argv && first_time) { /* browser plugins dont currently set this */
#if (PY_VERSION_HEX < 0x03000000)
- if(argv && first_time) /* browser plugins dont currently set this */
PySys_SetArgv(argc, argv);
+#else
+ int i;
+ PyObject *py_argv= PyList_New(argc);
+
+ for (i=0; i<argc; i++)
+ PyList_SET_ITEM(py_argv, i, PyUnicode_FromString(argv[i]));
+
+ PySys_SetObject("argv", py_argv);
+ Py_DECREF(py_argv);
#endif
+ }
//importBlenderModules()
setSandbox(level);
@@ -1736,7 +1745,7 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
// Add some symbolic constants to the module
d = PyModule_GetDict(m);
- ErrorObject = PyString_FromString("Rasterizer.error");
+ ErrorObject = PyUnicode_FromString("Rasterizer.error");
PyDict_SetItemString(d, "error", ErrorObject);
Py_DECREF(ErrorObject);
@@ -1814,10 +1823,10 @@ static PyObject* gPyEventToCharacter(PyObject*, PyObject* args)
if(IsPrintable(event)) {
char ch[2] = {'\0', '\0'};
ch[0] = ToCharacter(event, (bool)shift);
- return PyString_FromString(ch);
+ return PyUnicode_FromString(ch);
}
else {
- return PyString_FromString("");
+ return PyUnicode_FromString("");
}
}
@@ -1996,7 +2005,6 @@ PyObject* initGameKeys()
return d;
}
-#if PY_VERSION_HEX < 0x03000000
PyObject* initMathutils()
{
return Mathutils_Init("Mathutils"); // Use as a top level module in BGE
@@ -2011,13 +2019,6 @@ PyObject* initBGL()
{
return BGL_Init("BGL"); // Use as a top level module in BGE
}
-#else // TODO Py3k conversion
-PyObject* initMathutils() {Py_INCREF(Py_None);return Py_None;}
-PyObject* initGeometry() {Py_INCREF(Py_None);return Py_None;}
-PyObject* initBGL() {Py_INCREF(Py_None);return Py_None;}
-#endif
-
-
void KX_SetActiveScene(class KX_Scene* scene)
{
@@ -2053,7 +2054,7 @@ int saveGamePythonConfig( char **marshal_buffer)
char *marshal_cstring;
#if PY_VERSION_HEX < 0x03000000
- marshal_cstring = PyString_AsString(pyGlobalDictMarshal);
+ marshal_cstring = _PyUnicode_AsString(pyGlobalDictMarshal);
marshal_length= PyString_Size(pyGlobalDictMarshal);
#else // py3 uses byte arrays
marshal_cstring = PyBytes_AsString(pyGlobalDictMarshal);
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
index 83c4dcbb34c..8ff0bfd5379 100644
--- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
@@ -87,69 +87,54 @@
#include "SCA_RandomActuator.h"
#include "SCA_IController.h"
-
-void initPyObjectPlusType(PyTypeObject **parents)
+static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *attributes, int init_getset)
{
- int i;
-
- for (i=0; parents[i]; i++) {
- if(PyType_Ready(parents[i]) < 0) {
- /* This is very very unlikely */
- printf("Error, pytype could not initialize, Blender may crash \"%s\"\n", parents[i]->tp_name);
- return;
- }
+ PyAttributeDef *attr;
-#if 0
- PyObject_Print(reinterpret_cast<PyObject *>parents[i], stderr, 0);
- fprintf(stderr, "\n");
- PyObject_Print(parents[i]->tp_dict, stderr, 0);
- fprintf(stderr, "\n\n");
-#endif
+ if(init_getset) {
+ /* we need to do this for all types before calling PyType_Ready
+ * since they will call the parents PyType_Ready and those might not have initialized vars yet */
- }
+ //if(tp->tp_base==NULL)
+ // printf("Debug: No Parents - '%s'\n" , tp->tp_name);
- PyObject *dict= NULL;
+ if(tp->tp_getset==NULL && attributes->m_name) {
+ PyGetSetDef *attr_getset;
+ int attr_tot= 0;
- while(i) {
- i--;
+ for(attr= attributes; attr->m_name; attr++, attr_tot++) {};
- if (dict) {
- PyDict_Update(parents[i]->tp_dict, dict);
- }
- dict= parents[i]->tp_dict;
+ tp->tp_getset = attr_getset = reinterpret_cast<PyGetSetDef *>(PyMem_Malloc((attr_tot+1) * sizeof(PyGetSetDef))); // XXX - Todo, free
-#if 1
- PyObject_Print(reinterpret_cast<PyObject *>(parents[i]), stderr, 0);
- fprintf(stderr, "\n");
- PyObject_Print(parents[i]->tp_dict, stderr, 0);
- fprintf(stderr, "\n\n");
-#endif
- }
-}
+ for(attr= attributes; attr->m_name; attr++, attr_getset++) {
+ attr_getset->name= (char *)attr->m_name;
+ attr_getset->doc= NULL;
+ attr_getset->get= reinterpret_cast<getter>(PyObjectPlus::py_get_attrdef);
+ if(attr->m_access==KX_PYATTRIBUTE_RO)
+ attr_getset->set= NULL;
+ else
+ attr_getset->set= reinterpret_cast<setter>(PyObjectPlus::py_set_attrdef);
+ attr_getset->closure= reinterpret_cast<void *>(attr);
+ }
-static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *attributes)
-{
- PyAttributeDef *attr;
- PyObject *item;
-
- PyType_Ready(tp);
- PyDict_SetItemString(dict, tp->tp_name, reinterpret_cast<PyObject *>(tp));
+ memset(attr_getset, 0, sizeof(PyGetSetDef));
+ }
+ } else {
- /* store attr defs in the tp_dict for to avoid string lookups */
- for(attr= attributes; attr->m_name; attr++) {
- item= PyCObject_FromVoidPtr(attr, NULL);
- PyDict_SetItemString(tp->tp_dict, attr->m_name, item);
- Py_DECREF(item);
+ PyObject *item;
+
+ PyType_Ready(tp);
+ PyDict_SetItemString(dict, tp->tp_name, reinterpret_cast<PyObject *>(tp));
}
}
-#define PyType_Ready_Attr(d, n) PyType_Ready_ADD(d, &n::Type, n::Attributes)
+#define PyType_Ready_Attr(d, n, i) PyType_Ready_ADD(d, &n::Type, n::Attributes, i)
void initPyTypes(void)
{
@@ -165,72 +150,82 @@ void initPyTypes(void)
PyDict_SetItemString(PySys_GetObject((char *)"modules"), (char *)"GameTypes", mod);
Py_DECREF(mod);
- PyType_Ready_Attr(dict, BL_ActionActuator);
- PyType_Ready_Attr(dict, BL_Shader);
- PyType_Ready_Attr(dict, BL_ShapeActionActuator);
- PyType_Ready_Attr(dict, CListValue);
- PyType_Ready_Attr(dict, CValue);
- PyType_Ready_Attr(dict, KX_BlenderMaterial);
- PyType_Ready_Attr(dict, KX_CDActuator);
- PyType_Ready_Attr(dict, KX_Camera);
- PyType_Ready_Attr(dict, KX_CameraActuator);
- PyType_Ready_Attr(dict, KX_ConstraintActuator);
- PyType_Ready_Attr(dict, KX_ConstraintWrapper);
- PyType_Ready_Attr(dict, KX_GameActuator);
- PyType_Ready_Attr(dict, KX_GameObject);
- PyType_Ready_Attr(dict, KX_IpoActuator);
- PyType_Ready_Attr(dict, KX_LightObject);
- PyType_Ready_Attr(dict, KX_MeshProxy);
- PyType_Ready_Attr(dict, KX_MouseFocusSensor);
- PyType_Ready_Attr(dict, KX_NearSensor);
- PyType_Ready_Attr(dict, KX_NetworkMessageActuator);
- PyType_Ready_Attr(dict, KX_NetworkMessageSensor);
- PyType_Ready_Attr(dict, KX_ObjectActuator);
- PyType_Ready_Attr(dict, KX_ParentActuator);
- PyType_Ready_Attr(dict, KX_PhysicsObjectWrapper);
- PyType_Ready_Attr(dict, KX_PolyProxy);
- PyType_Ready_Attr(dict, KX_PolygonMaterial);
- PyType_Ready_Attr(dict, KX_RadarSensor);
- PyType_Ready_Attr(dict, KX_RaySensor);
- PyType_Ready_Attr(dict, KX_SCA_AddObjectActuator);
- PyType_Ready_Attr(dict, KX_SCA_DynamicActuator);
- PyType_Ready_Attr(dict, KX_SCA_EndObjectActuator);
- PyType_Ready_Attr(dict, KX_SCA_ReplaceMeshActuator);
- PyType_Ready_Attr(dict, KX_Scene);
- PyType_Ready_Attr(dict, KX_SceneActuator);
- PyType_Ready_Attr(dict, KX_SoundActuator);
- PyType_Ready_Attr(dict, KX_StateActuator);
- PyType_Ready_Attr(dict, KX_TouchSensor);
- PyType_Ready_Attr(dict, KX_TrackToActuator);
- PyType_Ready_Attr(dict, KX_VehicleWrapper);
- PyType_Ready_Attr(dict, KX_VertexProxy);
- PyType_Ready_Attr(dict, KX_VisibilityActuator);
- PyType_Ready_Attr(dict, PyObjectPlus);
- PyType_Ready_Attr(dict, SCA_2DFilterActuator);
- PyType_Ready_Attr(dict, SCA_ANDController);
- PyType_Ready_Attr(dict, SCA_ActuatorSensor);
- PyType_Ready_Attr(dict, SCA_AlwaysSensor);
- PyType_Ready_Attr(dict, SCA_DelaySensor);
- PyType_Ready_Attr(dict, SCA_ILogicBrick);
- PyType_Ready_Attr(dict, SCA_IObject);
- PyType_Ready_Attr(dict, SCA_ISensor);
- PyType_Ready_Attr(dict, SCA_JoystickSensor);
- PyType_Ready_Attr(dict, SCA_KeyboardSensor);
- PyType_Ready_Attr(dict, SCA_MouseSensor);
- PyType_Ready_Attr(dict, SCA_NANDController);
- PyType_Ready_Attr(dict, SCA_NORController);
- PyType_Ready_Attr(dict, SCA_ORController);
- PyType_Ready_Attr(dict, SCA_PropertyActuator);
- PyType_Ready_Attr(dict, SCA_PropertySensor);
- PyType_Ready_Attr(dict, SCA_PythonController);
- PyType_Ready_Attr(dict, SCA_RandomActuator);
- PyType_Ready_Attr(dict, SCA_RandomSensor);
- PyType_Ready_Attr(dict, SCA_XNORController);
- PyType_Ready_Attr(dict, SCA_XORController);
- PyType_Ready_Attr(dict, SCA_IController);
+ for(int init_getset= 1; init_getset > -1; init_getset--) { /* run twice, once to init the getsets another to run PyType_Ready */
+ PyType_Ready_Attr(dict, BL_ActionActuator, init_getset);
+ PyType_Ready_Attr(dict, BL_Shader, init_getset);
+ PyType_Ready_Attr(dict, BL_ShapeActionActuator, init_getset);
+ PyType_Ready_Attr(dict, CListValue, init_getset);
+ PyType_Ready_Attr(dict, CValue, init_getset);
+ PyType_Ready_Attr(dict, KX_BlenderMaterial, init_getset);
+ PyType_Ready_Attr(dict, KX_CDActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_Camera, init_getset);
+ PyType_Ready_Attr(dict, KX_CameraActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_ConstraintActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_ConstraintWrapper, init_getset);
+ PyType_Ready_Attr(dict, KX_GameActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_GameObject, init_getset);
+ PyType_Ready_Attr(dict, KX_IpoActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_LightObject, init_getset);
+ PyType_Ready_Attr(dict, KX_MeshProxy, init_getset);
+ PyType_Ready_Attr(dict, KX_MouseFocusSensor, init_getset);
+ PyType_Ready_Attr(dict, KX_NearSensor, init_getset);
+ PyType_Ready_Attr(dict, KX_NetworkMessageActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_NetworkMessageSensor, init_getset);
+ PyType_Ready_Attr(dict, KX_ObjectActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_ParentActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_PhysicsObjectWrapper, init_getset);
+ PyType_Ready_Attr(dict, KX_PolyProxy, init_getset);
+ PyType_Ready_Attr(dict, KX_PolygonMaterial, init_getset);
+ PyType_Ready_Attr(dict, KX_RadarSensor, init_getset);
+ PyType_Ready_Attr(dict, KX_RaySensor, init_getset);
+ PyType_Ready_Attr(dict, KX_SCA_AddObjectActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_SCA_DynamicActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_SCA_EndObjectActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_SCA_ReplaceMeshActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_Scene, init_getset);
+ PyType_Ready_Attr(dict, KX_SceneActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_SoundActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_StateActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_TouchSensor, init_getset);
+ PyType_Ready_Attr(dict, KX_TrackToActuator, init_getset);
+ PyType_Ready_Attr(dict, KX_VehicleWrapper, init_getset);
+ PyType_Ready_Attr(dict, KX_VertexProxy, init_getset);
+ PyType_Ready_Attr(dict, KX_VisibilityActuator, init_getset);
+ PyType_Ready_Attr(dict, PyObjectPlus, init_getset);
+ PyType_Ready_Attr(dict, SCA_2DFilterActuator, init_getset);
+ PyType_Ready_Attr(dict, SCA_ANDController, init_getset);
+ PyType_Ready_Attr(dict, SCA_ActuatorSensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_AlwaysSensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_DelaySensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_ILogicBrick, init_getset);
+ PyType_Ready_Attr(dict, SCA_IObject, init_getset);
+ PyType_Ready_Attr(dict, SCA_ISensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_JoystickSensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_KeyboardSensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_MouseSensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_NANDController, init_getset);
+ PyType_Ready_Attr(dict, SCA_NORController, init_getset);
+ PyType_Ready_Attr(dict, SCA_ORController, init_getset);
+ PyType_Ready_Attr(dict, SCA_PropertyActuator, init_getset);
+ PyType_Ready_Attr(dict, SCA_PropertySensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_PythonController, init_getset);
+ PyType_Ready_Attr(dict, SCA_RandomActuator, init_getset);
+ PyType_Ready_Attr(dict, SCA_RandomSensor, init_getset);
+ PyType_Ready_Attr(dict, SCA_XNORController, init_getset);
+ PyType_Ready_Attr(dict, SCA_XORController, init_getset);
+ PyType_Ready_Attr(dict, SCA_IController, init_getset);
+ }
+
+
/* Normal python type */
PyType_Ready(&KX_PythonSeq_Type);
+
+#ifdef USE_MATHUTILS
+ /* Init mathutils callbacks */
+ KX_GameObject_Mathutils_Callback_Init();
+ KX_ObjectActuator_Mathutils_Callback_Init();
+#endif
}
-#endif \ No newline at end of file
+#endif
diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp
index 524d957a80c..5b4d77156db 100644
--- a/source/gameengine/Ketsji/KX_PythonSeq.cpp
+++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp
@@ -221,11 +221,11 @@ static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key)
return NULL;
}
- if (PyInt_Check(key)) {
- return KX_PythonSeq_getIndex(self, PyInt_AS_LONG( key ));
+ if (PyLong_Check(key)) {
+ return KX_PythonSeq_getIndex(self, PyLong_AsSsize_t( key ));
}
- else if ( PyString_Check(key) ) {
- char *name = PyString_AsString(key);
+ else if ( PyUnicode_Check(key) ) {
+ char *name = _PyUnicode_AsString(key);
PyObjectPlus *ret = KX_PythonSeq_subscript__internal(self, name);
if(ret) {
@@ -250,12 +250,12 @@ static int KX_PythonSeq_contains(PyObject *self, PyObject *key)
PyErr_SetString(PyExc_SystemError, "key in seq, KX_PythonSeq: "BGE_PROXY_ERROR_MSG);
return -1;
}
- if(!PyString_Check(key)) {
+ if(!PyUnicode_Check(key)) {
PyErr_SetString(PyExc_SystemError, "key in seq, KX_PythonSeq: key must be a string");
return -1;
}
- if(KX_PythonSeq_subscript__internal(self, PyString_AsString(key)))
+ if(KX_PythonSeq_subscript__internal(self, _PyUnicode_AsString(key)))
return 1;
return 0;
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
index 064dc9126ac..e39d3756b71 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp
@@ -49,8 +49,7 @@ KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr,
double resetmargin,
bool bFindMaterial,
const STR_String& touchedpropname,
- class KX_Scene* kxscene,
- PyTypeObject* T)
+ class KX_Scene* kxscene)
: KX_NearSensor(
eventmgr,
@@ -61,8 +60,8 @@ KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr,
bFindMaterial,
touchedpropname,
kxscene,
- physCtrl,
- T),
+ physCtrl),
+
m_coneradius(coneradius),
m_coneheight(coneheight),
m_axis(axis)
@@ -245,21 +244,15 @@ PyTypeObject KX_RadarSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_RadarSensor::Parents[] = {
- &KX_RadarSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&KX_NearSensor::Type,
- &KX_TouchSensor::Type,
- &SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_RadarSensor::Methods[] = {
@@ -283,16 +276,3 @@ PyAttributeDef KX_RadarSensor::Attributes[] = {
{NULL} //Sentinel
};
-PyObject* KX_RadarSensor::py_getattro(PyObject *attr)
-{
- py_getattro_up(KX_NearSensor);
-}
-
-PyObject* KX_RadarSensor::py_getattro_dict() {
- py_getattro_dict_up(KX_NearSensor);
-}
-
-int KX_RadarSensor::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(KX_NearSensor);
-}
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h
index 2e5a0e68bed..344be0e399f 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.h
+++ b/source/gameengine/Ketsji/KX_RadarSensor.h
@@ -70,8 +70,7 @@ public:
double resetmargin,
bool bFindMaterial,
const STR_String& touchedpropname,
- class KX_Scene* kxscene,
- PyTypeObject* T = &Type);
+ class KX_Scene* kxscene);
KX_RadarSensor();
virtual ~KX_RadarSensor();
virtual void SynchronizeTransform();
@@ -89,9 +88,7 @@ public:
KX_RADAR_AXIS_NEG_Z
};
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
+ /* python */
virtual sensortype GetSensorType() { return ST_RADAR; }
//Deprecated ----->
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 78a61e9d95e..3f27496df71 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -55,9 +55,8 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr,
bool bXRay,
double distance,
int axis,
- KX_Scene* ketsjiScene,
- PyTypeObject* T)
- : SCA_ISensor(gameobj,eventmgr, T),
+ KX_Scene* ketsjiScene)
+ : SCA_ISensor(gameobj,eventmgr),
m_propertyname(propname),
m_bFindMaterial(bFindMaterial),
m_bXRay(bXRay),
@@ -336,20 +335,16 @@ PyTypeObject KX_RaySensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-
-};
-
-PyParentObject KX_RaySensor::Parents[] = {
- &KX_RaySensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
+
};
PyMethodDef KX_RaySensor::Methods[] = {
@@ -447,18 +442,4 @@ PyObject* KX_RaySensor::PyGetHitNormal()
return retVal;
}
-
-
-PyObject* KX_RaySensor::py_getattro(PyObject *attr) {
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* KX_RaySensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int KX_RaySensor::py_setattro(PyObject *attr, PyObject *value) {
- py_setattro_up(SCA_ISensor);
-}
-
// <----- Deprecated
diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h
index 9efb046742f..530c8ce54e5 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.h
+++ b/source/gameengine/Ketsji/KX_RaySensor.h
@@ -62,8 +62,7 @@ public:
bool bXRay,
double distance,
int axis,
- class KX_Scene* ketsjiScene,
- PyTypeObject* T = &Type);
+ class KX_Scene* ketsjiScene);
virtual ~KX_RaySensor();
virtual CValue* GetReplica();
@@ -84,11 +83,6 @@ public:
KX_RAY_AXIS_NEG_Y,
KX_RAY_AXIS_NEG_Z
};
-
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
// Deprecated ----->
KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitObject);
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index dec76a75e50..239c4a0be67 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -38,7 +38,6 @@
#include "SCA_IScene.h"
#include "KX_GameObject.h"
#include "KX_IPhysicsController.h"
-#include "blendef.h"
#include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H
@@ -56,10 +55,9 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj,
const float *linvel,
bool linv_local,
const float *angvel,
- bool angv_local,
- PyTypeObject* T)
+ bool angv_local)
:
- SCA_IActuator(gameobj, T),
+ SCA_IActuator(gameobj),
m_OriginalObject(original),
m_scene(scene),
@@ -188,20 +186,17 @@ PyTypeObject KX_SCA_AddObjectActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_SCA_AddObjectActuator::Parents[] = {
- &KX_SCA_AddObjectActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
+
PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
// ---> deprecated
{"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, (PY_METHODCHAR)SetTime_doc},
@@ -222,8 +217,8 @@ PyAttributeDef KX_SCA_AddObjectActuator::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("object",KX_SCA_AddObjectActuator,pyattr_get_object,pyattr_set_object),
KX_PYATTRIBUTE_RO_FUNCTION("objectLastCreated",KX_SCA_AddObjectActuator,pyattr_get_objectLastCreated),
KX_PYATTRIBUTE_INT_RW("time",0,2000,true,KX_SCA_AddObjectActuator,m_timeProp),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RW("linearVelocity",-MAXFLOAT,MAXFLOAT,KX_SCA_AddObjectActuator,m_linear_velocity,3),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RW("angularVelocity",-MAXFLOAT,MAXFLOAT,KX_SCA_AddObjectActuator,m_angular_velocity,3),
+ KX_PYATTRIBUTE_FLOAT_ARRAY_RW("linearVelocity",-FLT_MAX,FLT_MAX,KX_SCA_AddObjectActuator,m_linear_velocity,3),
+ KX_PYATTRIBUTE_FLOAT_ARRAY_RW("angularVelocity",-FLT_MAX,FLT_MAX,KX_SCA_AddObjectActuator,m_angular_velocity,3),
{ NULL } //Sentinel
};
@@ -264,21 +259,6 @@ PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, con
return actuator->m_lastCreatedObject->GetProxy();
}
-
-PyObject* KX_SCA_AddObjectActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_SCA_AddObjectActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_SCA_AddObjectActuator::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
/* 1. setObject */
const char KX_SCA_AddObjectActuator::SetObject_doc[] =
"setObject(object)\n"
@@ -317,7 +297,7 @@ const char KX_SCA_AddObjectActuator::SetTime_doc[] =
PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* value)
{
ShowDeprecationWarning("setTime()", "the time property");
- int deltatime = PyInt_AsLong(value);
+ int deltatime = PyLong_AsSsize_t(value);
if (deltatime==-1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "expected an int");
return NULL;
@@ -340,7 +320,7 @@ const char KX_SCA_AddObjectActuator::GetTime_doc[] =
PyObject* KX_SCA_AddObjectActuator::PyGetTime()
{
ShowDeprecationWarning("getTime()", "the time property");
- return PyInt_FromLong(m_timeProp);
+ return PyLong_FromSsize_t(m_timeProp);
}
@@ -362,7 +342,7 @@ PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_OriginalObject->GetName().ReadPtr());
+ return PyUnicode_FromString(m_OriginalObject->GetName().ReadPtr());
else
return m_OriginalObject->GetProxy();
}
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
index 6746b7d1bc6..3151e7a89ca 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
@@ -88,8 +88,7 @@ public:
const float *linvel,
bool linv_local,
const float *angvel,
- bool angv_local,
- PyTypeObject* T=&Type
+ bool angv_local
);
~KX_SCA_AddObjectActuator(void);
@@ -110,10 +109,6 @@ public:
virtual bool
Update();
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
-
SCA_IObject*
GetLastCreatedObject(
) const ;
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
index 3d3bc1265a0..423fd0db7f2 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
@@ -36,7 +36,6 @@
// Please look here for revision history.
#include "KX_SCA_DynamicActuator.h"
-#include "blendef.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -48,9 +47,7 @@
/* Integration hooks ------------------------------------------------------- */
- PyTypeObject
-
-KX_SCA_DynamicActuator::Type = {
+PyTypeObject KX_SCA_DynamicActuator::Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
@@ -67,22 +64,17 @@ KX_SCA_DynamicActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_SCA_DynamicActuator::Parents[] = {
- &KX_SCA_DynamicActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
PyMethodDef KX_SCA_DynamicActuator::Methods[] = {
// ---> deprecated
KX_PYMETHODTABLE(KX_SCA_DynamicActuator, setOperation),
@@ -92,26 +84,11 @@ PyMethodDef KX_SCA_DynamicActuator::Methods[] = {
PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = {
KX_PYATTRIBUTE_SHORT_RW("mode",0,4,false,KX_SCA_DynamicActuator,m_dyn_operation),
- KX_PYATTRIBUTE_FLOAT_RW("mass",0.0,MAXFLOAT,KX_SCA_DynamicActuator,m_setmass),
+ KX_PYATTRIBUTE_FLOAT_RW("mass",0.0,FLT_MAX,KX_SCA_DynamicActuator,m_setmass),
{ NULL } //Sentinel
};
-PyObject* KX_SCA_DynamicActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_SCA_DynamicActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_SCA_DynamicActuator::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
-
/* 1. setOperation */
KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, setOperation,
"setOperation(operation?)\n"
@@ -143,7 +120,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, getOperation,
)
{
ShowDeprecationWarning("getOperation()", "the mode property");
- return PyInt_FromLong((long)m_dyn_operation);
+ return PyLong_FromSsize_t((long)m_dyn_operation);
}
@@ -153,10 +130,9 @@ KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, getOperation,
KX_SCA_DynamicActuator::KX_SCA_DynamicActuator(SCA_IObject *gameobj,
short dyn_operation,
- float setmass,
- PyTypeObject* T) :
+ float setmass) :
- SCA_IActuator(gameobj, T),
+ SCA_IActuator(gameobj),
m_dyn_operation(dyn_operation),
m_setmass(setmass)
{
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
index 4add707f8cd..8b598c9ecfa 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
@@ -50,8 +50,7 @@ class KX_SCA_DynamicActuator : public SCA_IActuator
KX_SCA_DynamicActuator(
SCA_IObject* gameobj,
short dyn_operation,
- float setmass,
- PyTypeObject* T=&Type
+ float setmass
);
~KX_SCA_DynamicActuator(
@@ -73,11 +72,6 @@ class KX_SCA_DynamicActuator : public SCA_IActuator
KX_DYN_SET_MASS,
};
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
/* 1. setOperation */
KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,setOperation);
KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,getOperation);
diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
index 728254e7f48..47c5c3aeeeb 100644
--- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
@@ -43,9 +43,8 @@
#endif
KX_SCA_EndObjectActuator::KX_SCA_EndObjectActuator(SCA_IObject *gameobj,
- SCA_IScene* scene,
- PyTypeObject* T):
- SCA_IActuator(gameobj, T),
+ SCA_IScene* scene):
+ SCA_IActuator(gameobj),
m_scene(scene)
{
// intentionally empty
@@ -108,24 +107,17 @@ PyTypeObject KX_SCA_EndObjectActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-PyParentObject KX_SCA_EndObjectActuator::Parents[] = {
- &KX_SCA_EndObjectActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef KX_SCA_EndObjectActuator::Methods[] = {
{NULL,NULL} //Sentinel
};
@@ -134,13 +126,4 @@ PyAttributeDef KX_SCA_EndObjectActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_SCA_EndObjectActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_SCA_EndObjectActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
/* eof */
diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
index 70d72f1f8da..782a24b1ef1 100644
--- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
@@ -47,8 +47,7 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator
public:
KX_SCA_EndObjectActuator(
SCA_IObject* gameobj,
- SCA_IScene* scene,
- PyTypeObject* T=&Type
+ SCA_IScene* scene
);
~KX_SCA_EndObjectActuator();
@@ -63,9 +62,6 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
}; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
index 00842d7012a..2884bb76565 100644
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
@@ -50,9 +50,7 @@
/* Integration hooks ------------------------------------------------------- */
- PyTypeObject
-
-KX_SCA_ReplaceMeshActuator::Type = {
+PyTypeObject KX_SCA_ReplaceMeshActuator::Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
@@ -69,23 +67,17 @@ KX_SCA_ReplaceMeshActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_SCA_ReplaceMeshActuator::Parents[] = {
- &KX_SCA_ReplaceMeshActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = {
KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh),
// Deprecated ----->
@@ -99,20 +91,6 @@ PyAttributeDef KX_SCA_ReplaceMeshActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_SCA_ReplaceMeshActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_SCA_ReplaceMeshActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_SCA_ReplaceMeshActuator::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
PyObject* KX_SCA_ReplaceMeshActuator::pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
{
KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self);
@@ -161,7 +139,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh,
if (!m_mesh)
Py_RETURN_NONE;
- return PyString_FromString(const_cast<char *>(m_mesh->GetName().ReadPtr()));
+ return PyUnicode_FromString(const_cast<char *>(m_mesh->GetName().ReadPtr()));
}
@@ -178,10 +156,9 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh,
KX_SCA_ReplaceMeshActuator::KX_SCA_ReplaceMeshActuator(SCA_IObject *gameobj,
class RAS_MeshObject *mesh,
- SCA_IScene* scene,
- PyTypeObject* T) :
+ SCA_IScene* scene) :
- SCA_IActuator(gameobj, T),
+ SCA_IActuator(gameobj),
m_mesh(mesh),
m_scene(scene)
{
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
index 0e7f7852701..6a68bd88cc5 100644
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
@@ -55,9 +55,7 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator
KX_SCA_ReplaceMeshActuator(
SCA_IObject* gameobj,
RAS_MeshObject *mesh,
- SCA_IScene* scene,
- PyTypeObject* T=&Type
- );
+ SCA_IScene* scene);
~KX_SCA_ReplaceMeshActuator(
);
@@ -71,10 +69,7 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator
void InstantReplaceMesh();
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
-
+ /* python api */
static PyObject* pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index b57a07779cb..51f5276e075 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -138,7 +138,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
class SND_IAudioDevice* adi,
const STR_String& sceneName,
Scene *scene):
- PyObjectPlus(&KX_Scene::Type),
+ PyObjectPlus(),
m_keyboardmgr(NULL),
m_mousemgr(NULL),
m_sceneConverter(NULL),
@@ -1077,6 +1077,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
{
modifierDeformer = new BL_ModifierDeformer(
newobj,
+ m_blenderScene,
oldblendobj, blendobj,
static_cast<BL_SkinMeshObject*>(mesh),
true,
@@ -1089,6 +1090,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
{
modifierDeformer = new BL_ModifierDeformer(
newobj,
+ m_blenderScene,
oldblendobj, blendobj,
static_cast<BL_SkinMeshObject*>(mesh),
false,
@@ -1627,17 +1629,15 @@ PyTypeObject KX_Scene::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_Scene::Parents[] = {
- &KX_Scene::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_Scene::Methods[] = {
@@ -1652,7 +1652,7 @@ PyMethodDef KX_Scene::Methods[] = {
PyObject* KX_Scene::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_Scene* self= static_cast<KX_Scene*>(self_v);
- return PyString_FromString(self->GetName().ReadPtr());
+ return PyUnicode_FromString(self->GetName().ReadPtr());
}
PyObject* KX_Scene::pyattr_get_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1728,72 +1728,6 @@ PyAttributeDef KX_Scene::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_Scene::py_getattro__internal(PyObject *attr)
-{
- py_getattro_up(PyObjectPlus);
-}
-
-int KX_Scene::py_setattro__internal(PyObject *attr, PyObject *value)
-{
- py_setattro_up(PyObjectPlus);
-}
-
-PyObject* KX_Scene::py_getattro(PyObject *attr)
-{
- PyObject *object = py_getattro__internal(attr);
-
- if (object==NULL)
- {
- PyErr_Clear();
- object = PyDict_GetItem(m_attr_dict, attr);
- if(object) {
- Py_INCREF(object);
- }
- else {
- PyErr_Format(PyExc_AttributeError, "value = scene.myAttr: KX_Scene, attribute \"%s\" not found", PyString_AsString(attr));
- }
- }
-
- return object;
-}
-
-PyObject* KX_Scene::py_getattro_dict() {
- //py_getattro_dict_up(PyObjectPlus);
-
- PyObject *dict= py_getattr_dict(PyObjectPlus::py_getattro_dict(), Type.tp_dict);
- if(dict==NULL)
- return NULL;
-
- /* normally just return this but KX_Scene has some more items */
-
- PyDict_Update(dict, m_attr_dict);
- return dict;
-}
-
-int KX_Scene::py_setattro(PyObject *attr, PyObject *value)
-{
- int ret= py_setattro__internal(attr, value);
-
- if (ret==PY_SET_ATTR_MISSING) {
- if (PyDict_SetItem(m_attr_dict, attr, value)==0) {
- PyErr_Clear();
- ret= PY_SET_ATTR_SUCCESS;
- }
- else {
- PyErr_SetString(PyExc_AttributeError, "scene.UserAttr = value: KX_Scenes, failed assigning value to internal dictionary");
- ret= PY_SET_ATTR_FAIL;
- }
- }
-
- return ret;
-}
-
-int KX_Scene::py_delattro(PyObject *attr)
-{
- PyDict_DelItem(m_attr_dict, attr);
- return 0;
-}
-
KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getLightList,
"getLightList() -> list [KX_Light]\n"
"Returns a list of all lights in the scene.\n"
@@ -1818,7 +1752,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getName,
)
{
ShowDeprecationWarning("getName()", "the name property");
- return PyString_FromString(GetName());
+ return PyUnicode_FromString(GetName());
}
KX_PYMETHODDEF_DOC(KX_Scene, addObject,
@@ -1844,4 +1778,4 @@ KX_PYMETHODDEF_DOC(KX_Scene, addObject,
// the object is added to the scene so we dont want python to own a reference
replica->Release();
return replica->GetProxy();
-} \ No newline at end of file
+}
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
index 79d3f7fd828..2792f1f5fe4 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -563,15 +563,7 @@ public:
static PyObject* pyattr_get_active_camera(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- virtual PyObject* py_getattro(PyObject *attr); /* name, active_camera, gravity, suspended, viewport, framing, activity_culling, activity_culling_radius */
- virtual PyObject* py_getattro_dict();
-
- virtual int py_setattro(PyObject *attr, PyObject *value);
- virtual int py_delattro(PyObject *attr);
- virtual PyObject* py_repr(void) { return PyString_FromString(GetName().ReadPtr()); }
-
- PyObject* py_getattro__internal(PyObject *attr);
- int py_setattro__internal(PyObject *attr, PyObject *pyvalue);
+ virtual PyObject* py_repr(void) { return PyUnicode_FromString(GetName().ReadPtr()); }
/**
* Sets the time the scene was suspended
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp
index 1b790ec9824..5528e58ef77 100644
--- a/source/gameengine/Ketsji/KX_SceneActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp
@@ -49,9 +49,8 @@ KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj,
KX_Scene *scene,
KX_KetsjiEngine* ketsjiEngine,
const STR_String& nextSceneName,
- KX_Camera* camera,
- PyTypeObject* T)
- : SCA_IActuator(gameobj, T)
+ KX_Camera* camera)
+ : SCA_IActuator(gameobj)
{
m_mode = mode;
m_scene = scene;
@@ -134,7 +133,7 @@ bool KX_SceneActuator::Update()
{
// if no camera is set and the parent object is a camera, use it as the camera
SCA_IObject* parent = GetParent();
- if (parent->isA(&KX_Camera::Type))
+ if (parent->GetGameObjectType()==SCA_IObject::OBJ_CAMERA)
{
m_scene->SetActiveCamera((KX_Camera*)parent);
}
@@ -239,26 +238,17 @@ PyTypeObject KX_SceneActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject KX_SceneActuator::Parents[] =
-{
- &KX_SceneActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef KX_SceneActuator::Methods[] =
{
//Deprecated functions ------>
@@ -280,20 +270,6 @@ PyAttributeDef KX_SceneActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_SceneActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_SceneActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_SceneActuator::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
PyObject* KX_SceneActuator::pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
{
KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self);
@@ -355,7 +331,7 @@ const char KX_SceneActuator::GetUseRestart_doc[] =
PyObject* KX_SceneActuator::PyGetUseRestart()
{
ShowDeprecationWarning("getUseRestart()", "the useRestart property");
- return PyInt_FromLong(!(m_restart == 0));
+ return PyLong_FromSsize_t(!(m_restart == 0));
}
@@ -391,7 +367,7 @@ const char KX_SceneActuator::GetScene_doc[] =
PyObject* KX_SceneActuator::PyGetScene()
{
ShowDeprecationWarning("getScene()", "the scene property");
- return PyString_FromString(m_nextSceneName);
+ return PyUnicode_FromString(m_nextSceneName);
}
@@ -432,7 +408,7 @@ PyObject* KX_SceneActuator::PyGetCamera()
{
ShowDeprecationWarning("getCamera()", "the camera property");
if (m_camera) {
- return PyString_FromString(m_camera->GetName());
+ return PyUnicode_FromString(m_camera->GetName());
}
else {
Py_RETURN_NONE;
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h
index 2412dd02590..86de3395d1e 100644
--- a/source/gameengine/Ketsji/KX_SceneActuator.h
+++ b/source/gameengine/Ketsji/KX_SceneActuator.h
@@ -77,8 +77,7 @@ class KX_SceneActuator : public SCA_IActuator
KX_Scene* scene,
KX_KetsjiEngine* ketsjiEngine,
const STR_String& nextSceneName,
- KX_Camera* camera,
- PyTypeObject* T=&Type);
+ KX_Camera* camera);
virtual ~KX_SceneActuator();
virtual CValue* GetReplica();
@@ -92,10 +91,6 @@ class KX_SceneActuator : public SCA_IActuator
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
/* 1. set */
/* Removed */
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index 9e005cd04bb..39381182944 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -50,9 +50,8 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
SND_Scene* sndscene,
KX_SOUNDACT_TYPE type,
short start,
- short end,
- PyTypeObject* T)
- : SCA_IActuator(gameobj,T)
+ short end)
+ : SCA_IActuator(gameobj)
{
m_soundObject = sndobj;
m_soundScene = sndscene;
@@ -260,25 +259,17 @@ PyTypeObject KX_SoundActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject KX_SoundActuator::Parents[] = {
- &KX_SoundActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef KX_SoundActuator::Methods[] = {
// Deprecated ----->
{"setFilename", (PyCFunction) KX_SoundActuator::sPySetFilename, METH_VARARGS,NULL},
@@ -350,25 +341,13 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound,
}
/* Atribute setting and getting -------------------------------------------- */
-PyObject* KX_SoundActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_SoundActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_SoundActuator::py_setattro(PyObject *attr, PyObject* value) {
- py_setattro_up(SCA_IActuator);
-}
PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
{
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
if (!actuator->m_soundObject)
{
- return PyString_FromString("");
+ return PyUnicode_FromString("");
}
STR_String objectname = actuator->m_soundObject->GetObjectName();
char* name = objectname.Ptr();
@@ -377,7 +356,7 @@ PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYAT
PyErr_SetString(PyExc_RuntimeError, "value = actuator.fileName: KX_SoundActuator, unable to get sound fileName");
return NULL;
} else
- return PyString_FromString(name);
+ return PyUnicode_FromString(name);
}
PyObject* KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
@@ -412,7 +391,7 @@ PyObject* KX_SoundActuator::pyattr_get_looping(void *self, const struct KX_PYATT
{
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
int looping = (actuator->m_soundObject) ? actuator->m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
- PyObject* result = PyInt_FromLong(looping);
+ PyObject* result = PyLong_FromSsize_t(looping);
return result;
}
@@ -590,7 +569,7 @@ PyObject* KX_SoundActuator::PyGetFilename()
ShowDeprecationWarning("getFilename()", "the fileName property");
if (!m_soundObject)
{
- return PyString_FromString("");
+ return PyUnicode_FromString("");
}
STR_String objectname = m_soundObject->GetObjectName();
char* name = objectname.Ptr();
@@ -599,7 +578,7 @@ PyObject* KX_SoundActuator::PyGetFilename()
PyErr_SetString(PyExc_RuntimeError, "Unable to get sound fileName");
return NULL;
} else
- return PyString_FromString(name);
+ return PyUnicode_FromString(name);
}
PyObject* KX_SoundActuator::PySetGain(PyObject* args)
@@ -699,7 +678,7 @@ PyObject* KX_SoundActuator::PyGetLooping()
{
ShowDeprecationWarning("getLooping()", "the looping property");
int looping = (m_soundObject) ? m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
- PyObject* result = PyInt_FromLong(looping);
+ PyObject* result = PyLong_FromSsize_t(looping);
return result;
}
@@ -787,7 +766,7 @@ PyObject* KX_SoundActuator::PySetType(PyObject* args)
PyObject* KX_SoundActuator::PyGetType()
{
ShowDeprecationWarning("getType()", "the mode property");
- return PyInt_FromLong(m_type);
+ return PyLong_FromSsize_t(m_type);
}
// <-----
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h
index a7491355667..adafee0a30b 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.h
+++ b/source/gameengine/Ketsji/KX_SoundActuator.h
@@ -66,8 +66,7 @@ public:
class SND_Scene* sndscene,
KX_SOUNDACT_TYPE type,
short start,
- short end,
- PyTypeObject* T=&Type);
+ short end);
~KX_SoundActuator();
@@ -81,10 +80,6 @@ public:
/* Python interface --------------------------------------------------- */
/* -------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
-
KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, startSound);
KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, pauseSound);
KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, stopSound);
diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp
index f6979eee0f4..9815d6274aa 100644
--- a/source/gameengine/Ketsji/KX_StateActuator.cpp
+++ b/source/gameengine/Ketsji/KX_StateActuator.cpp
@@ -38,10 +38,9 @@
KX_StateActuator::KX_StateActuator(
SCA_IObject* gameobj,
int operation,
- unsigned int mask,
- PyTypeObject* T
+ unsigned int mask
)
- : SCA_IActuator(gameobj,T),
+ : SCA_IActuator(gameobj),
m_operation(operation),
m_mask(mask)
{
@@ -154,24 +153,18 @@ PyTypeObject KX_StateActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject
-KX_StateActuator::Parents[] = {
- &KX_StateActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-PyMethodDef
-KX_StateActuator::Methods[] = {
+PyMethodDef KX_StateActuator::Methods[] = {
// deprecated -->
{"setOperation", (PyCFunction) KX_StateActuator::sPySetOperation,
METH_VARARGS, (PY_METHODCHAR)SetOperation_doc},
@@ -187,20 +180,6 @@ PyAttributeDef KX_StateActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_StateActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_StateActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_StateActuator::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
/* set operation ---------------------------------------------------------- */
const char
diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h
index a4191a4c5fd..ce86c4b44fe 100644
--- a/source/gameengine/Ketsji/KX_StateActuator.h
+++ b/source/gameengine/Ketsji/KX_StateActuator.h
@@ -66,9 +66,8 @@ class KX_StateActuator : public SCA_IActuator
KX_StateActuator(
SCA_IObject* gameobj,
int operation,
- unsigned int mask,
- PyTypeObject* T=&Type
- );
+ unsigned int mask
+ );
virtual
~KX_StateActuator(
@@ -89,10 +88,6 @@ class KX_StateActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
//KX_PYMETHOD_DOC
KX_PYMETHOD_DOC_VARARGS(KX_StateActuator,SetOperation);
KX_PYMETHOD_DOC_VARARGS(KX_StateActuator,SetMask);
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
deleted file mode 100644
index fc053f05e63..00000000000
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-#include "KX_ConvertPhysicsObject.h"
-
-#ifdef USE_SUMO_SOLID
-
-#ifdef WIN32
-#pragma warning (disable : 4786)
-#endif
-
-#include "KX_SumoPhysicsController.h"
-#include "SG_Spatial.h"
-#include "SM_Scene.h"
-#include "KX_GameObject.h"
-#include "KX_MotionState.h"
-#include "KX_ClientObjectInfo.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-void KX_SumoPhysicsController::applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)
-{
- SumoPhysicsController::applyImpulse(attach[0],attach[1],attach[2],impulse[0],impulse[1],impulse[2]);
-}
-void KX_SumoPhysicsController::RelativeTranslate(const MT_Vector3& dloc,bool local)
-{
- SumoPhysicsController::RelativeTranslate(dloc[0],dloc[1],dloc[2],local);
-
-}
-void KX_SumoPhysicsController::RelativeRotate(const MT_Matrix3x3& drot,bool local)
-{
- float oldmat[12];
- drot.getValue(oldmat);
-/* float newmat[9];
- float *m = &newmat[0];
- double *orgm = &oldmat[0];
-
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++; */
-
- SumoPhysicsController::RelativeRotate(oldmat,local);
-}
-
-void KX_SumoPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
- SumoPhysicsController::SetLinearVelocity(lin_vel[0],lin_vel[1],lin_vel[2],local);
-
-}
-
-void KX_SumoPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
-{
- SumoPhysicsController::SetAngularVelocity(ang_vel[0],ang_vel[1],ang_vel[2],local);
-}
-
-MT_Vector3 KX_SumoPhysicsController::GetVelocity(const MT_Point3& pos)
-{
-
- float linvel[3];
- SumoPhysicsController::GetVelocity(pos[0],pos[1],pos[2],linvel[0],linvel[1],linvel[2]);
-
- return MT_Vector3 (linvel);
-}
-
-MT_Vector3 KX_SumoPhysicsController::GetLinearVelocity()
-{
- return GetVelocity(MT_Point3(0,0,0));
-
-}
-
-void KX_SumoPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
- SumoPhysicsController::resolveCombinedVelocities(linvelX,linvelY,linvelZ,angVelX,angVelY,angVelZ);
-}
-
-void KX_SumoPhysicsController::ApplyTorque(const MT_Vector3& torque,bool local)
-{
- SumoPhysicsController::ApplyTorque(torque[0],torque[1],torque[2],local);
-
-}
-
-void KX_SumoPhysicsController::ApplyForce(const MT_Vector3& force,bool local)
-{
- SumoPhysicsController::ApplyForce(force[0],force[1],force[2],local);
-}
-
-bool KX_SumoPhysicsController::Update(double time)
-{
- return SynchronizeMotionStates(time);
-}
-
-void KX_SumoPhysicsController::SetSimulatedTime(double time)
-{
-
-}
-
-void KX_SumoPhysicsController::SetSumoTransform(bool nondynaonly)
-{
- SumoPhysicsController::setSumoTransform(nondynaonly);
-
-}
-
-void KX_SumoPhysicsController::SuspendDynamics(bool)
-{
- SumoPhysicsController::SuspendDynamics();
-}
-
-void KX_SumoPhysicsController::RestoreDynamics()
-{
- SumoPhysicsController::RestoreDynamics();
-}
-
-SG_Controller* KX_SumoPhysicsController::GetReplica(SG_Node* destnode)
-{
-
- PHY_IMotionState* motionstate = new KX_MotionState(destnode);
-
- KX_SumoPhysicsController* physicsreplica = new KX_SumoPhysicsController(*this);
-
- //parentcontroller is here be able to avoid collisions between parent/child
-
- PHY_IPhysicsController* parentctrl = NULL;
-
- if (destnode != destnode->GetRootSGParent())
- {
- KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject();
- if (clientgameobj)
- {
- parentctrl = (KX_SumoPhysicsController*)clientgameobj->GetPhysicsController();
- } else
- {
- // it could be a false node, try the children
- NodeList::const_iterator childit;
- for (
- childit = destnode->GetSGChildren().begin();
- childit!= destnode->GetSGChildren().end();
- ++childit
- ) {
- KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj)
- {
- parentctrl = (KX_SumoPhysicsController*)clientgameobj->GetPhysicsController();
- }
- }
- }
- }
-
- physicsreplica->PostProcessReplica(motionstate,parentctrl);
-
- return physicsreplica;
-}
-
-
-void KX_SumoPhysicsController::SetObject (SG_IObject* object)
-{
- SG_Controller::SetObject(object);
-
- // cheating here...
-//should not be necessary, is it for duplicates ?
-
-KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject();
-gameobj->SetPhysicsController(this,gameobj->IsDynamic());
-GetSumoObject()->setClientObject(gameobj->getClientInfo());
-}
-
-void KX_SumoPhysicsController::setMargin(float collisionMargin)
-{
- SumoPhysicsController::SetMargin(collisionMargin);
-}
-
-
-void KX_SumoPhysicsController::setOrientation(const MT_Matrix3x3& rot)
-{
- MT_Quaternion orn = rot.getRotation();
- SumoPhysicsController::setOrientation(
- orn[0],orn[1],orn[2],orn[3]);
-
-}
-void KX_SumoPhysicsController::getOrientation(MT_Quaternion& orn)
-{
-
- float quat[4];
-
- SumoPhysicsController::getOrientation(quat[0],quat[1],quat[2],quat[3]);
-
- orn = MT_Quaternion(quat);
-
-}
-
-void KX_SumoPhysicsController::setPosition(const MT_Point3& pos)
-{
- SumoPhysicsController::setPosition(pos[0],pos[1],pos[2]);
-
-}
-
-void KX_SumoPhysicsController::setScaling(const MT_Vector3& scaling)
-{
- SumoPhysicsController::setScaling(scaling[0],scaling[1],scaling[2]);
-
-}
-
-MT_Scalar KX_SumoPhysicsController::GetMass()
-{
- return SumoPhysicsController::getMass();
-}
-
-void KX_SumoPhysicsController::SetMass(MT_Scalar newmass)
-{
-}
-
-MT_Vector3 KX_SumoPhysicsController::GetLocalInertia()
-{
- return MT_Vector3(0.f, 0.f, 0.f); // \todo
-}
-
-MT_Scalar KX_SumoPhysicsController::GetRadius()
-{
- return SumoPhysicsController::GetRadius();
-}
-
-MT_Vector3 KX_SumoPhysicsController::getReactionForce()
-{
- float force[3];
- SumoPhysicsController::getReactionForce(force[0],force[1],force[2]);
- return MT_Vector3(force);
-
-}
-
-void KX_SumoPhysicsController::setRigidBody(bool rigid)
-{
- SumoPhysicsController::setRigidBody(rigid);
-
-}
-
-
-KX_SumoPhysicsController::~KX_SumoPhysicsController()
-{
-
-
-}
-
-
-#endif//USE_SUMO_SOLID
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
deleted file mode 100644
index 278994c6ae7..00000000000
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __KX_SUMOPHYSICSCONTROLLER_H
-#define __KX_SUMOPHYSICSCONTROLLER_H
-
-#include "PHY_IPhysicsController.h"
-
-/**
- Physics Controller, a special kind of Scene Graph Transformation Controller.
- It get's callbacks from Sumo in case a transformation change took place.
- Each time the scene graph get's updated, the controller get's a chance
- in the 'Update' method to reflect changed.
-*/
-
-#include "SumoPhysicsController.h"
-#include "KX_IPhysicsController.h"
-
-class KX_SumoPhysicsController : public KX_IPhysicsController,
- public SumoPhysicsController
-
-{
-
-
-public:
- KX_SumoPhysicsController(
- class SM_Scene* sumoScene,
- class SM_Object* sumoObj,
- class PHY_IMotionState* motionstate
- ,bool dyna)
- : KX_IPhysicsController(dyna,false,false,NULL) ,
- SumoPhysicsController(sumoScene,/*solidscene,*/sumoObj,motionstate,dyna)
- {
- };
- virtual ~KX_SumoPhysicsController();
-
- void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse);
- virtual void SetObject (SG_IObject* object);
- virtual void setMargin (float collisionMargin);
-
- void RelativeTranslate(const MT_Vector3& dloc,bool local);
- void RelativeRotate(const MT_Matrix3x3& drot,bool local);
- void ApplyTorque(const MT_Vector3& torque,bool local);
- void ApplyForce(const MT_Vector3& force,bool local);
- MT_Vector3 GetLinearVelocity();
- MT_Vector3 GetAngularVelocity() // to keep compiler happy
- { return MT_Vector3(0.0,0.0,0.0); }
- MT_Vector3 GetVelocity(const MT_Point3& pos);
- void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
- void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
- void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
-
-
- void SuspendDynamics(bool);
- void RestoreDynamics();
- virtual void AddCompoundChild(KX_IPhysicsController* child) { }
- virtual void RemoveCompoundChild(KX_IPhysicsController* child) { }
-
- virtual void getOrientation(MT_Quaternion& orn);
- virtual void setOrientation(const MT_Matrix3x3& orn);
- virtual void SetTransform() {}
-
- virtual void setPosition(const MT_Point3& pos);
- virtual void setScaling(const MT_Vector3& scaling);
- virtual MT_Scalar GetMass();
- virtual void SetMass(MT_Scalar newmass);
- virtual MT_Vector3 GetLocalInertia();
- virtual MT_Scalar GetRadius();
- virtual MT_Vector3 getReactionForce();
- virtual void setRigidBody(bool rigid);
-
- virtual float GetLinVelocityMin() { return SumoPhysicsController::GetLinVelocityMin(); }
- virtual void SetLinVelocityMin(float val) { SumoPhysicsController::SetLinVelocityMin(val); }
- virtual float GetLinVelocityMax() { return SumoPhysicsController::GetLinVelocityMax(); }
- virtual void SetLinVelocityMax(float val) { SumoPhysicsController::SetLinVelocityMax(val); }
-
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
-
-
- void SetSumoTransform(bool nondynaonly);
- // todo: remove next line !
- virtual void SetSimulatedTime(double time);
-
- // call from scene graph to update
- virtual bool Update(double time);
-
- void
- SetOption(
- int option,
- int value
- ){
- // intentionally empty
- };
-};
-
-#endif //__KX_SUMOPHYSICSCONTROLLER_H
-
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index c06acd4a873..b0cf172c27a 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -97,8 +97,8 @@ bool KX_TouchSensor::Evaluate()
return result;
}
-KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj,bool bFindMaterial,bool bTouchPulse,const STR_String& touchedpropname,PyTypeObject* T)
-:SCA_ISensor(gameobj,eventmgr,T),
+KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj,bool bFindMaterial,bool bTouchPulse,const STR_String& touchedpropname)
+:SCA_ISensor(gameobj,eventmgr),
m_touchedpropname(touchedpropname),
m_bFindMaterial(bFindMaterial),
m_bTouchPulse(bTouchPulse),
@@ -310,19 +310,15 @@ PyTypeObject KX_TouchSensor::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_TouchSensor::Parents[] = {
- &KX_TouchSensor::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_TouchSensor::Methods[] = {
@@ -348,20 +344,6 @@ PyAttributeDef KX_TouchSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_TouchSensor::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_ISensor);
-}
-
-PyObject* KX_TouchSensor::py_getattro_dict() {
- py_getattro_dict_up(SCA_ISensor);
-}
-
-int KX_TouchSensor::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_ISensor);
-}
-
/* Python API */
/* 1. setProperty */
@@ -374,7 +356,7 @@ const char KX_TouchSensor::SetProperty_doc[] =
PyObject* KX_TouchSensor::PySetProperty(PyObject* value)
{
ShowDeprecationWarning("setProperty()", "the propName property");
- char *nameArg= PyString_AsString(value);
+ char *nameArg= _PyUnicode_AsString(value);
if (nameArg==NULL) {
PyErr_SetString(PyExc_ValueError, "expected a ");
return NULL;
@@ -392,7 +374,7 @@ const char KX_TouchSensor::GetProperty_doc[] =
PyObject* KX_TouchSensor::PyGetProperty() {
ShowDeprecationWarning("getProperty()", "the propName property");
- return PyString_FromString(m_touchedpropname);
+ return PyUnicode_FromString(m_touchedpropname);
}
const char KX_TouchSensor::GetHitObject_doc[] =
@@ -433,7 +415,7 @@ const char KX_TouchSensor::GetTouchMaterial_doc[] =
PyObject* KX_TouchSensor::PyGetTouchMaterial()
{
ShowDeprecationWarning("getTouchMaterial()", "the useMaterial property");
- return PyInt_FromLong(m_bFindMaterial);
+ return PyLong_FromSsize_t(m_bFindMaterial);
}
/* 6. setTouchMaterial */
@@ -446,7 +428,7 @@ const char KX_TouchSensor::SetTouchMaterial_doc[] =
PyObject* KX_TouchSensor::PySetTouchMaterial(PyObject *value)
{
ShowDeprecationWarning("setTouchMaterial()", "the useMaterial property");
- int pulseArg = PyInt_AsLong(value);
+ int pulseArg = PyLong_AsSsize_t(value);
if(pulseArg ==-1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "expected a bool");
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h
index 476c63e89db..6cbf5b15e3b 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.h
+++ b/source/gameengine/Ketsji/KX_TouchSensor.h
@@ -79,8 +79,7 @@ public:
class KX_GameObject* gameobj,
bool bFindMaterial,
bool bTouchPulse,
- const STR_String& touchedpropname,
- PyTypeObject* T=&Type) ;
+ const STR_String& touchedpropname) ;
virtual ~KX_TouchSensor();
virtual CValue* GetReplica();
@@ -121,10 +120,6 @@ public:
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
//Deprecated ----->
/* 1. setProperty */
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index 5a50d0fb944..e8a06d8d619 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -59,10 +59,8 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
int time,
bool allow3D,
int trackflag,
- int upflag,
- PyTypeObject* T)
- :
- SCA_IActuator(gameobj, T)
+ int upflag)
+ : SCA_IActuator(gameobj)
{
m_time = time;
m_allow3D = allow3D;
@@ -74,7 +72,6 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
if (m_object)
m_object->RegisterActuator(this);
- if (gameobj->isA(&KX_GameObject::Type))
{
// if the object is vertex parented, don't check parent orientation as the link is broken
if (!((KX_GameObject*)gameobj)->IsVertexParent()){
@@ -450,25 +447,17 @@ PyTypeObject KX_TrackToActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-
-
-PyParentObject KX_TrackToActuator::Parents[] = {
- &KX_TrackToActuator::Type,
- &SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &SCA_IActuator::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-
-
PyMethodDef KX_TrackToActuator::Methods[] = {
// ---> deprecated
{"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, (PY_METHODCHAR)SetTime_doc},
@@ -518,20 +507,6 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT
}
-PyObject* KX_TrackToActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_TrackToActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_TrackToActuator::py_setattro(PyObject *attr, PyObject* value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
/* 1. setObject */
const char KX_TrackToActuator::SetObject_doc[] =
"setObject(object)\n"
@@ -576,7 +551,7 @@ PyObject* KX_TrackToActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_object->GetName());
+ return PyUnicode_FromString(m_object->GetName());
else
return m_object->GetProxy();
}
@@ -613,7 +588,7 @@ const char KX_TrackToActuator::GetTime_doc[] =
PyObject* KX_TrackToActuator::PyGetTime()
{
ShowDeprecationWarning("getTime()", "the timer property");
- return PyInt_FromLong(m_time);
+ return PyLong_FromSsize_t(m_time);
}
@@ -625,7 +600,7 @@ const char KX_TrackToActuator::GetUse3D_doc[] =
PyObject* KX_TrackToActuator::PyGetUse3D()
{
ShowDeprecationWarning("setTime()", "the use3D property");
- return PyInt_FromLong(!(m_allow3D == 0));
+ return PyLong_FromSsize_t(!(m_allow3D == 0));
}
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h
index c4cc2b1f062..801e695bb9b 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.h
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.h
@@ -56,7 +56,7 @@ class KX_TrackToActuator : public SCA_IActuator
public:
KX_TrackToActuator(SCA_IObject* gameobj, SCA_IObject *ob, int time,
- bool threedee,int trackflag,int upflag, PyTypeObject* T=&Type);
+ bool threedee,int trackflag,int upflag);
virtual ~KX_TrackToActuator();
virtual CValue* GetReplica() {
KX_TrackToActuator* replica = new KX_TrackToActuator(*this);
@@ -70,9 +70,6 @@ class KX_TrackToActuator : public SCA_IActuator
virtual bool Update(double curtime, bool frame);
/* Python part */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject* value);
/* These are used to get and set m_ob */
static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
index 8146d04a878..7001bfc8b7e 100644
--- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
@@ -16,8 +16,8 @@
KX_VehicleWrapper::KX_VehicleWrapper(
PHY_IVehicle* vehicle,
- PHY_IPhysicsEnvironment* physenv,PyTypeObject *T) :
- PyObjectPlus(T),
+ PHY_IPhysicsEnvironment* physenv) :
+ PyObjectPlus(),
m_vehicle(vehicle),
m_physenv(physenv)
{
@@ -127,13 +127,13 @@ PyObject* KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject* args)
PyObject* KX_VehicleWrapper::PyGetNumWheels(PyObject* args)
{
- return PyInt_FromLong(m_vehicle->GetNumWheels());
+ return PyLong_FromSsize_t(m_vehicle->GetNumWheels());
}
PyObject* KX_VehicleWrapper::PyGetConstraintId(PyObject* args)
{
- return PyInt_FromLong(m_vehicle->GetUserConstraintId());
+ return PyLong_FromSsize_t(m_vehicle->GetUserConstraintId());
}
@@ -264,7 +264,7 @@ PyObject* KX_VehicleWrapper::PySetSteeringValue(PyObject* args)
PyObject* KX_VehicleWrapper::PyGetConstraintType(PyObject* args)
{
- return PyInt_FromLong(m_vehicle->GetUserConstraintType());
+ return PyLong_FromSsize_t(m_vehicle->GetUserConstraintType());
}
@@ -289,35 +289,17 @@ PyTypeObject KX_VehicleWrapper::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_VehicleWrapper::Parents[] = {
- &KX_VehicleWrapper::Type,
- &PyObjectPlus::Type,
- NULL
-};
-
-PyObject* KX_VehicleWrapper::py_getattro(PyObject *attr)
-{
- //here you can search for existing data members (like mass,friction etc.)
- py_getattro_up(PyObjectPlus);
-}
-
-PyObject* KX_VehicleWrapper::py_getattro_dict() {
- py_getattro_dict_up(PyObjectPlus);
-}
-
-int KX_VehicleWrapper::py_setattro(PyObject *attr,PyObject* value)
-{
- py_setattro_up(PyObjectPlus);
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
+ &PyObjectPlus::Type,
+ 0,0,0,0,0,0,
+ py_base_new
};
-
PyMethodDef KX_VehicleWrapper::Methods[] = {
{"addWheel",(PyCFunction) KX_VehicleWrapper::sPyAddWheel, METH_VARARGS},
{"getNumWheels",(PyCFunction) KX_VehicleWrapper::sPyGetNumWheels, METH_VARARGS},
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.h b/source/gameengine/Ketsji/KX_VehicleWrapper.h
index c2b5e3d9251..d7f2da5cd7c 100644
--- a/source/gameengine/Ketsji/KX_VehicleWrapper.h
+++ b/source/gameengine/Ketsji/KX_VehicleWrapper.h
@@ -12,14 +12,11 @@ class PHY_IMotionState;
class KX_VehicleWrapper : public PyObjectPlus
{
Py_Header;
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
std::vector<PHY_IMotionState*> m_motionStates;
public:
- KX_VehicleWrapper(PHY_IVehicle* vehicle,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
+ KX_VehicleWrapper(PHY_IVehicle* vehicle,class PHY_IPhysicsEnvironment* physenv);
virtual ~KX_VehicleWrapper ();
int getConstraintId();
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp
index 4b0ad083473..cb8c891969d 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.cpp
+++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp
@@ -53,18 +53,15 @@ PyTypeObject KX_VertexProxy::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-};
-
-PyParentObject KX_VertexProxy::Parents[] = {
- &KX_VertexProxy::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&CValue::Type,
- &PyObjectPlus::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
PyMethodDef KX_VertexProxy::Methods[] = {
@@ -85,37 +82,38 @@ PyMethodDef KX_VertexProxy::Methods[] = {
PyAttributeDef KX_VertexProxy::Attributes[] = {
//KX_PYATTRIBUTE_TODO("DummyProps"),
-
+
KX_PYATTRIBUTE_DUMMY("x"),
KX_PYATTRIBUTE_DUMMY("y"),
KX_PYATTRIBUTE_DUMMY("z"),
-
+
KX_PYATTRIBUTE_DUMMY("r"),
KX_PYATTRIBUTE_DUMMY("g"),
KX_PYATTRIBUTE_DUMMY("b"),
KX_PYATTRIBUTE_DUMMY("a"),
-
+
KX_PYATTRIBUTE_DUMMY("u"),
KX_PYATTRIBUTE_DUMMY("v"),
-
+
KX_PYATTRIBUTE_DUMMY("u2"),
KX_PYATTRIBUTE_DUMMY("v2"),
-
+
KX_PYATTRIBUTE_DUMMY("XYZ"),
KX_PYATTRIBUTE_DUMMY("UV"),
-
+
KX_PYATTRIBUTE_DUMMY("color"),
KX_PYATTRIBUTE_DUMMY("colour"),
-
+
KX_PYATTRIBUTE_DUMMY("normal"),
-
+
{ NULL } //Sentinel
};
+#if 0
PyObject*
KX_VertexProxy::py_getattro(PyObject *attr)
{
- char *attr_str= PyString_AsString(attr);
+ char *attr_str= _PyUnicode_AsString(attr);
if (attr_str[1]=='\0') { // Group single letters
// pos
if (attr_str[0]=='x')
@@ -141,8 +139,8 @@ KX_VertexProxy::py_getattro(PyObject *attr)
if (attr_str[0]=='v')
return PyFloat_FromDouble(m_vertex->getUV1()[1]);
}
-
-
+
+
if (!strcmp(attr_str, "XYZ"))
return PyObjectFrom(MT_Vector3(m_vertex->getXYZ()));
@@ -156,22 +154,21 @@ KX_VertexProxy::py_getattro(PyObject *attr)
color /= 255.0;
return PyObjectFrom(color);
}
-
+
if (!strcmp(attr_str, "normal"))
{
return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
}
-
+
py_getattro_up(CValue);
}
+#endif
-PyObject* KX_VertexProxy::py_getattro_dict() {
- py_getattro_dict_up(CValue);
-}
+#if 0
int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
{
- char *attr_str= PyString_AsString(attr);
+ char *attr_str= _PyUnicode_AsString(attr);
if (PySequence_Check(pyvalue))
{
if (!strcmp(attr_str, "XYZ"))
@@ -185,7 +182,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
}
return PY_SET_ATTR_FAIL;
}
-
+
if (!strcmp(attr_str, "UV"))
{
MT_Point2 vec;
@@ -197,7 +194,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
}
return PY_SET_ATTR_FAIL;
}
-
+
if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour"))
{
MT_Vector4 vec;
@@ -209,7 +206,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
}
return PY_SET_ATTR_FAIL;
}
-
+
if (!strcmp(attr_str, "normal"))
{
MT_Vector3 vec;
@@ -222,7 +219,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
return PY_SET_ATTR_FAIL;
}
}
-
+
if (PyFloat_Check(pyvalue))
{
float val = PyFloat_AsDouble(pyvalue);
@@ -235,7 +232,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
m_mesh->SetMeshModified(true);
return PY_SET_ATTR_SUCCESS;
}
-
+
if (!strcmp(attr_str, "y"))
{
pos.y() = val;
@@ -243,7 +240,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
m_mesh->SetMeshModified(true);
return PY_SET_ATTR_SUCCESS;
}
-
+
if (!strcmp(attr_str, "z"))
{
pos.z() = val;
@@ -251,7 +248,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
m_mesh->SetMeshModified(true);
return PY_SET_ATTR_SUCCESS;
}
-
+
// uv
MT_Point2 uv = m_vertex->getUV1();
if (!strcmp(attr_str, "u"))
@@ -287,7 +284,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
m_mesh->SetMeshModified(true);
return PY_SET_ATTR_SUCCESS;
}
-
+
// col
unsigned int icol = *((const unsigned int *)m_vertex->getRGBA());
unsigned char *cp = (unsigned char*) &icol;
@@ -321,9 +318,10 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
return PY_SET_ATTR_SUCCESS;
}
}
-
+
return CValue::py_setattro(attr, pyvalue);
}
+#endif
KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
: m_vertex(vertex),
@@ -339,7 +337,7 @@ KX_VertexProxy::~KX_VertexProxy()
// stuff for cvalue related things
CValue* KX_VertexProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;}
-CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
+CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
STR_String sVertexName="vertex";
const STR_String & KX_VertexProxy::GetText() {return sVertexName;};
double KX_VertexProxy::GetNumber() { return -1;}
@@ -348,7 +346,7 @@ void KX_VertexProxy::SetName(const char *) { };
CValue* KX_VertexProxy::GetReplica() { return NULL;}
// stuff for python integration
-
+
PyObject* KX_VertexProxy::PyGetXYZ()
{
return PyObjectFrom(MT_Point3(m_vertex->getXYZ()));
@@ -359,7 +357,7 @@ PyObject* KX_VertexProxy::PySetXYZ(PyObject* value)
MT_Point3 vec;
if (!PyVecTo(value, vec))
return NULL;
-
+
m_vertex->SetXYZ(vec);
m_mesh->SetMeshModified(true);
Py_RETURN_NONE;
@@ -375,7 +373,7 @@ PyObject* KX_VertexProxy::PySetNormal(PyObject* value)
MT_Vector3 vec;
if (!PyVecTo(value, vec))
return NULL;
-
+
m_vertex->SetNormal(vec);
m_mesh->SetMeshModified(true);
Py_RETURN_NONE;
@@ -385,18 +383,18 @@ PyObject* KX_VertexProxy::PySetNormal(PyObject* value)
PyObject* KX_VertexProxy::PyGetRGBA()
{
int *rgba = (int *) m_vertex->getRGBA();
- return PyInt_FromLong(*rgba);
+ return PyLong_FromSsize_t(*rgba);
}
PyObject* KX_VertexProxy::PySetRGBA(PyObject* value)
{
- if PyInt_Check(value) {
- int rgba = PyInt_AsLong(value);
+ if PyLong_Check(value) {
+ int rgba = PyLong_AsSsize_t(value);
m_vertex->SetRGBA(rgba);
m_mesh->SetMeshModified(true);
Py_RETURN_NONE;
}
- else {
+ else {
MT_Vector4 vec;
if (PyVecTo(value, vec))
{
@@ -405,7 +403,7 @@ PyObject* KX_VertexProxy::PySetRGBA(PyObject* value)
Py_RETURN_NONE;
}
}
-
+
PyErr_SetString(PyExc_TypeError, "vert.setRGBA(value): KX_VertexProxy, expected a 4D vector or an int");
return NULL;
}
@@ -421,7 +419,7 @@ PyObject* KX_VertexProxy::PySetUV(PyObject* value)
MT_Point2 vec;
if (!PyVecTo(value, vec))
return NULL;
-
+
m_vertex->SetUV(vec);
m_mesh->SetMeshModified(true);
Py_RETURN_NONE;
@@ -436,14 +434,14 @@ PyObject* KX_VertexProxy::PySetUV2(PyObject* args)
{
MT_Point2 vec;
unsigned int unit= RAS_TexVert::SECOND_UV;
-
+
PyObject* list= NULL;
if(!PyArg_ParseTuple(args, "O|i:setUV2", &list, &unit))
return NULL;
-
+
if (!PyVecTo(list, vec))
return NULL;
-
+
m_vertex->SetFlag((m_vertex->getFlag()|RAS_TexVert::SECOND_UV));
m_vertex->SetUnit(unit);
m_vertex->SetUV2(vec);
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h
index 42db5fbc322..13c57e9f556 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.h
+++ b/source/gameengine/Ketsji/KX_VertexProxy.h
@@ -53,9 +53,6 @@ public:
// stuff for python integration
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
KX_PYMETHOD_NOARGS(KX_VertexProxy,GetXYZ);
KX_PYMETHOD_O(KX_VertexProxy,SetXYZ);
diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
index d848065ad73..3561ccde9d9 100644
--- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
+++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
@@ -39,10 +39,9 @@ KX_VisibilityActuator::KX_VisibilityActuator(
SCA_IObject* gameobj,
bool visible,
bool occlusion,
- bool recursive,
- PyTypeObject* T
+ bool recursive
)
- : SCA_IActuator(gameobj,T),
+ : SCA_IActuator(gameobj),
m_visible(visible),
m_occlusion(occlusion),
m_recursive(recursive)
@@ -108,25 +107,18 @@ PyTypeObject KX_VisibilityActuator::Type = {
0,
0,
py_base_repr,
- 0,0,0,0,0,0,
- py_base_getattro,
- py_base_setattro,
0,0,0,0,0,0,0,0,0,
- Methods
-
-};
-
-PyParentObject
-KX_VisibilityActuator::Parents[] = {
- &KX_VisibilityActuator::Type,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ 0,0,0,0,0,0,0,
+ Methods,
+ 0,
+ 0,
&SCA_IActuator::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
+ 0,0,0,0,0,0,
+ py_base_new
};
-PyMethodDef
-KX_VisibilityActuator::Methods[] = {
+PyMethodDef KX_VisibilityActuator::Methods[] = {
// Deprecated ----->
{"set", (PyCFunction) KX_VisibilityActuator::sPySetVisible, METH_VARARGS,
(PY_METHODCHAR) SetVisible_doc},
@@ -141,21 +133,6 @@ PyAttributeDef KX_VisibilityActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* KX_VisibilityActuator::py_getattro(PyObject *attr)
-{
- py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_VisibilityActuator::py_getattro_dict() {
- py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_VisibilityActuator::py_setattro(PyObject *attr, PyObject *value)
-{
- py_setattro_up(SCA_IActuator);
-}
-
-
/* set visibility ---------------------------------------------------------- */
const char
KX_VisibilityActuator::SetVisible_doc[] =
diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h
index 45aba50f645..3ad50c6cea2 100644
--- a/source/gameengine/Ketsji/KX_VisibilityActuator.h
+++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h
@@ -48,9 +48,7 @@ class KX_VisibilityActuator : public SCA_IActuator
SCA_IObject* gameobj,
bool visible,
bool occlusion,
- bool recursive,
- PyTypeObject* T=&Type
- );
+ bool recursive);
virtual
~KX_VisibilityActuator(
@@ -69,10 +67,6 @@ class KX_VisibilityActuator : public SCA_IActuator
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
- virtual PyObject* py_getattro_dict();
- virtual int py_setattro(PyObject *attr, PyObject *value);
-
// Deprecated ----->
KX_PYMETHOD_DOC_VARARGS(KX_VisibilityActuator,SetVisible);
// <-----
diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile
index 0b48ad8b8c3..8e91eb6ff9a 100644
--- a/source/gameengine/Ketsji/Makefile
+++ b/source/gameengine/Ketsji/Makefile
@@ -41,10 +41,10 @@ CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I../../blender/python
-CPPFLAGS += -I../../blender/python/api2_2x
+CPPFLAGS += -I../../blender/python/generic
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
+CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_SOLID)/include
CPPFLAGS += -I$(NAN_BULLET2)/include
CPPFLAGS += -I../Rasterizer/RAS_OpenGLRasterizer
@@ -54,14 +54,11 @@ CPPFLAGS += -I../../kernel/gen_system
CPPFLAGS += -I../Network -IKXNetwork
CPPFLAGS += -I../Physics/common
CPPFLAGS += -I../Physics/Dummy
-CPPFLAGS += -I../Physics/Sumo
-CPPFLAGS += -I../Physics/BlOde
CPPFLAGS += -I../Physics/Bullet
CPPFLAGS += -I.
CPPFLAGS += -I../Converter
CPPFLAGS += -I../../blender/blenkernel
CPPFLAGS += -I../../blender/blenlib
-CPPFLAGS += -I../../blender/include
CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I../../blender/imbuf
CPPFLAGS += -I../../blender/gpu
diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript
index 2c87c7dd78a..1edffe0e587 100644
--- a/source/gameengine/Ketsji/SConscript
+++ b/source/gameengine/Ketsji/SConscript
@@ -4,52 +4,23 @@ import sys
Import ('env')
sources = env.Glob('*.cpp')
-defs = ''
-
-# Mathutils C files.
-if not env['BF_PYTHON_VERSION'].startswith('3'):
- # TODO - py3 support
- sources.extend([\
- '#source/blender/python/api2_2x/Mathutils.c',\
- '#source/blender/python/api2_2x/Geometry.c',\
- '#source/blender/python/api2_2x/euler.c',\
- '#source/blender/python/api2_2x/matrix.c',\
- '#source/blender/python/api2_2x/quat.c',\
- '#source/blender/python/api2_2x/vector.c',\
- '#source/blender/python/api2_2x/constant.c',\
- ])
-
- sources.extend([\
- '#source/blender/python/api2_2x/BGL.c'
- ])
-
-sources.extend([\
- '#source/blender/python/api2_2x/bpy_internal_import.c'
-])
+defs = []
-
-incs = '. #source/blender/python/api2_2x' # Only for Mathutils! and bpy_internal_import.h, be very careful
+incs = '. #source/blender/python/generic' # Only for Mathutils! and bpy_internal_import.h, be very careful
incs += ' #source/kernel/gen_system #intern/string #intern/guardedalloc'
-incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #intern/bmfont'
+incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer'
incs += ' #intern/SoundSystem #intern/SoundSystem/include #intern/SoundSystem/openal'
incs += ' #intern/SoundSystem/dummy #intern/SoundSystem/intern #source/gameengine/Converter'
incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf #intern/moto/include'
incs += ' #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork #source/blender/blenlib'
-incs += ' #source/blender/blenkernel #source/blender #source/blender/include'
+incs += ' #source/blender/blenkernel #source/blender #source/blender/editors/include'
incs += ' #source/blender/makesdna #source/blender/python #source/gameengine/Rasterizer'
incs += ' #source/gameengine/GameLogic #source/gameengine/Expressions #source/gameengine/Network'
incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common #source/gameengine/Physics/Bullet'
-incs += ' #source/gameengine/Physics/BlOde #source/gameengine/Physics/Dummy'
+incs += ' #source/gameengine/Physics/Dummy'
incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include #source/blender/gpu'
-if env['WITH_BF_SOLID']:
- incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/include'
- incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork'
- incs += ' ' + env['BF_SOLID_INC']
- defs += ' USE_SUMO_SOLID'
-
-
incs += ' ' + env['BF_PYTHON_INC']
incs += ' ' + env['BF_BULLET_INC']
incs += ' ' + env['BF_OPENGL_INC']
@@ -57,11 +28,14 @@ incs += ' ' + env['BF_OPENGL_INC']
if env['WITH_BF_SDL']:
incs += ' ' + env['BF_SDL_INC']
else:
- defs += ' DISABLE_SDL'
+ defs.append('DISABLE_SDL')
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
+ if env['BF_DEBUG']:
+ defs.append('_DEBUG') # for Python
-env.BlenderLib ( 'bf_ketsji', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[25, 72], cxx_compileflags = cxxflags )
+env.BlenderLib ( 'bf_ketsji', sources, Split(incs), defs, libtype=['core','player'], priority=[320, 60], cxx_compileflags = cxxflags )
diff --git a/source/gameengine/Network/LoopBackNetwork/SConscript b/source/gameengine/Network/LoopBackNetwork/SConscript
index 987603f1a49..be6545b4fd6 100644
--- a/source/gameengine/Network/LoopBackNetwork/SConscript
+++ b/source/gameengine/Network/LoopBackNetwork/SConscript
@@ -5,4 +5,4 @@ sources = 'NG_LoopBackNetworkDeviceInterface.cpp'
incs = '. #source/kernel/gen_system #intern/string #source/gameengine/Network'
-env.BlenderLib ( 'bf_loopbacknetwork', Split(sources), Split(incs), defines=[],libtype=['game2', 'player'], priority=[25, 165] )
+env.BlenderLib ( 'bf_loopbacknetwork', Split(sources), Split(incs), defines=[],libtype=['core', 'player'], priority=[400, 155] )
diff --git a/source/gameengine/Network/SConscript b/source/gameengine/Network/SConscript
index 0778418045f..804851973af 100644
--- a/source/gameengine/Network/SConscript
+++ b/source/gameengine/Network/SConscript
@@ -5,4 +5,4 @@ sources = env.Glob('*.cpp') #'NG_NetworkMessage.cpp NG_NetworkObject.cpp NG_Netw
incs = '. #source/kernel/gen_system #intern/string #intern/moto/include'
-env.BlenderLib ( 'bf_ngnetwork', sources, Split(incs), [], libtype=['game2', 'player'], priority=[15, 160] )
+env.BlenderLib ( 'bf_ngnetwork', sources, Split(incs), [], libtype=['core', 'player'], priority=[400, 150] )
diff --git a/source/gameengine/Physics/BlOde/Makefile b/source/gameengine/Physics/BlOde/Makefile
deleted file mode 100644
index 1fbbf198377..00000000000
--- a/source/gameengine/Physics/BlOde/Makefile
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): none yet.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-#
-
-LIBNAME = blode
-DIR = $(OCGDIR)/gameengine/blphys/$(LIBNAME)
-
-include nan_compile.mk
-
-CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
-
-CPPFLAGS += -I$(OPENGL_HEADERS)
-CPPFLAGS += -I$(NAN_STRING)/include
-CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO)/include -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_ODE)/include
-CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
-CPPFLAGS += -I../../Physics/common
-CPPFLAGS += -I../../Physics/Dummy
-# nlin: fix this, should put in NAN_ODE dir
-#CPPFLAGS += -I./ode/ode/include
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
deleted file mode 100644
index 5efd0994311..00000000000
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
+++ /dev/null
@@ -1,625 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#define USE_ODE
-#ifdef USE_ODE
-
-#include "OdePhysicsController.h"
-#include "PHY_IMotionState.h"
-
-#include <ode/ode.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-///////////////////////////////////////////////////////////////////////////
-//
-// general to-do list for ODE physics. This is maintained in doxygen format.
-//
-/// \todo determine assignment time for bounding spheres.
-///
-/// it appears you have to select "sphere" for bounding volume AND "draw bounds"
-/// in order for a bounding sphere to be generated. otherwise a box is generated.
-/// determine exactly when and how the bounding volumes are generated and make
-/// this consistent.
-/// }
-///
-/// \todo bounding sphere size incorrect
-///
-/// it appears NOT to use the size of the shown bounding sphere (button "draw bounds").
-/// it appears instead to use the size of the "size" dynamic parameter in the
-/// gamebuttons but this "size" draws an incorrectly-sized circle on screen for the
-/// bounding sphere (leftover skewed size calculation from sumo?) so figure out WHERE
-/// its getting the radius from.
-///
-/// \todo ODE collisions must fire collision actuator
-///
-/// See OdePhysicsEnvironment::OdeNearCallback. If a sensor was created to check
-/// for the presence of this collision, then in the NearCallback you need to
-/// take appropriate action regarding the sensor - something like checking its
-/// controller and if needed firing its actuator. Need to find similar code in
-/// Fuzzics which fires collision controllers/actuators.
-///
-/// \todo Are ghost collisions possible?
-///
-/// How do ghost collisions work? Do they require collision detection through ODE
-/// and NON-CREATION of contact-joint in OdeNearCallback? Currently OdeNearCallback
-/// creates joints ALWAYS for collisions.
-///
-/// \todo Why is KX_GameObject::addLinearVelocity commented out?
-///
-/// Try putting this code back in.
-///
-/// \todo Too many non-dynamic actors bogs down ODE physics
-///
-/// Lots of "geoms" (ODE static geometry) probably slows down ode. Try a test file
-/// with lots of static geometry - the game performance in Blender says it is
-/// spending all its time in physics, and I bet all that time is in collision
-/// detection. It's ode's non-hierarchical collision detection.
-/// try making a separate ode test program (not within blender) with 1000 geoms and
-/// see how fast it is. if it is really slow, there is the culprit.
-/// isnt someone working on an improved ODE collision detector? check
-/// ode mailing list.
-///
-///
-/// \todo support collision of dynas with non-dynamic triangle meshes
-///
-/// ODE has trimesh-collision support but only for trimeshes without a transform
-/// matrix. update ODE tricollider to support a transform matrix. this will allow
-/// moving trimeshes non-dynamically (e.g. through Ipos). then collide trimeshes
-/// with dynas. this allows dynamic primitives (spheres, boxes) to collide with
-/// non-dynamic or kinematically controlled tri-meshes. full dynamic trimesh to
-/// dynamic trimesh support is hard because it requires (a) collision and penetration
-/// depth for trimesh to trimesh and (hard to compute) (b) an intertia tensor
-/// (easy to compute).
-///
-/// a triangle mesh collision geometry should be created when the blender
-/// bounding volume (F9, EDITBUTTONS) is set to "polyheder", since this is
-/// currently the place where sphere/box selection is made
-///
-/// \todo specify ODE ERP+CFM in blender interface
-///
-/// when ODE physics selected, have to be able to set global cfm and erp.
-/// per-joint erp/cfm could be handled in constraint window.
-///
-/// \todo moving infinite mass objects should impart extra impulse to objects they collide with
-///
-/// currently ODE's ERP pushes them apart but doesn't account for their motion.
-/// you have to detect if one body in a collision is a non-dyna. This
-/// requires adding a new accessor method to
-/// KX_IPhysicsInterfaceController to access the hidden m_isDyna variable,
-/// currently it can only be written, not read). If one of the bodies in a
-/// collision is a non-dyna, then impart an extra impulse based on the
-/// motion of the static object (using its last 2 frames as an approximation
-/// of its linear and angular velocity). Linear velocity is easy to
-/// approximate, but angular? you have orientation at this frame and
-/// orientation at previous frame. The question is what is the angular
-/// velocity which would have taken you from the previous frame's orientation
-/// to this frame's orientation?
-///
-/// \todo allow tweaking bounding volume size
-///
-/// the scene converter currently uses the blender bounding volume of the selected
-/// object as the geometry for ODE collision purposes. this is good and automatic
-/// intuitive - lets you choose between cube, sphere, mesh. but you need to be able
-/// to tweak this size for physics.
-///
-/// \todo off center meshes totally wrong for ode
-///
-/// ode uses x, y, z extents regradless of center. then places geom at center of object.
-/// but visual geom is not necessarily at center. need to detect off-center situations.
-/// then do what? treat it as an encapsulated off-center mass, or recenter it?
-///
-/// i.o.w. recalculate center, or recalculate mass distribution (using encapsulation)?
-///
-/// \todo allow off-center mass
-///
-/// using ode geometry encapsulators
-///
-/// \todo allow entering compound geoms for complex collision shapes specified as a union of simpler shapes
-///
-/// The collision shape for arbitrary triangle meshes can probably in general be
-///well approximated by a compound ODE geometry object, which is merely a combination
-///of many primitives (capsule, sphere, box). I eventually want to add the ability
-///to associate compound geometry objects with Blender gameobjects. I think one
-///way of doing this would be to add a new button in the GameButtons, "RigidBodyCompound".
-///If the object is "Dynamic" + "RigidBody", then the object's bounding volume (sphere,
-///box) is created. If an object is "Dynamic" + "RigidBodyCompound", then the object itself
-///will merely create a "wrapper" compound object, with the actual geometry objects
-///being created from the object's children in Blender. E.g. if I wanted to make a
-///compound collision object consisting of a sphere and 2 boxes, I would create a
-///parent gameobject with the actual triangle mesh, and set its GameButtons to
-///"RigidBodyCompound". I would then create 3 children of this object, 1 sphere and
-///2 boxes, and set the GameButtons for the children to be "RigidBody". Then at
-///scene conversion time, the scene converter sees "RigidBodyCompound" for the
-///top-level object, then appropriately traverses the children and creates the compound
-///collision geometry consisting of 2 boxes and a sphere. In this way, arbitrary
-///mesh-mesh collision becomes much less necessary - the artist can (or must,
-///depending on your point of view!) approximate the collision shape for arbitrary
-///meshes with a combination of one or more primitive shapes. I think using the
-///parent/child relationship in Blender and a new button "RigidBodyCompound" for the
-///parent object of a compound is a feasible way of doing this in Blender.
-///
-///See ODE demo test_boxstack and look at the code when you drop a compound object
-///with the "X" key.
-///
-/// \todo add visual specification of constraints
-///
-/// extend the armature constraint system. by using empties and constraining one empty
-/// to "copy location" of another, you can get a p2p constraint between the two empties.
-/// by making the two empties each a parent of a blender object, you effectively have
-/// a p2p constraint between 2 blender bodies. the scene converter can detect these
-/// empties, detect the constraint, and generate an ODE constraint.
-///
-/// then add a new constraint type "hinge" and "slider" to correspond to ODE joints.
-/// e.g. a slider would be a constraint which restricts the axis of its object to lie
-/// along the same line as another axis of a different object. e.g. you constrain x-axis
-/// of one empty to lie along the same line as the z-axis of another empty; this gives
-/// a slider joint.
-///
-/// open questions: how to handle powered joints? to what extent should/must constraints
-/// be enforced during modeling? use CCD-style algorithm in modeler to enforce constraints?
-/// how about ODE powered constraints e.g. motors?
-///
-/// \todo enable suspension of bodies
-/// ODE offers native support for suspending dynas. but what about suspending non-dynas
-/// (e.g. geoms)? suspending geoms is also necessary to ease the load of ODE's (simple?)
-/// collision detector. suspending dynas and geoms is important for the activity culling,
-/// which apparently works at a simple level. perhaps suspension should actually
-/// remove or insert geoms/dynas into the ODE space/world? is this operation (insertion/
-/// removal) fast enough at run-time? test it. if fast enough, then suspension=remove from
-/// ODE simulation, awakening=insertion into ODE simulation.
-///
-/// \todo python interface for tweaking constraints via python
-///
-/// \todo raytesting to support gameengine sensors that need it
-///
-/// \todo investigate compatibility issues with old Blender 2.25 physics engine (sumo/fuzzics)
-/// is it possible to have compatibility? how hard is it? how important is it?
-
-
-ODEPhysicsController::ODEPhysicsController(bool dyna, bool fullRigidBody,
- bool phantom, class PHY_IMotionState* motionstate, struct dxSpace* space,
- struct dxWorld* world, float mass,float friction,float restitution,
- bool implicitsphere,float center[3],float extents[3],float radius)
- :
- m_OdeDyna(dyna),
- m_firstTime(true),
- m_bFullRigidBody(fullRigidBody),
- m_bPhantom(phantom),
- m_bKinematic(false),
- m_bPrevKinematic(false),
- m_MotionState(motionstate),
- m_OdeSuspendDynamics(false),
- m_space(space),
- m_world(world),
- m_mass(mass),
- m_friction(friction),
- m_restitution(restitution),
- m_bodyId(0),
- m_geomId(0),
- m_implicitsphere(implicitsphere),
- m_radius(radius)
-{
- m_center[0] = center[0];
- m_center[1] = center[1];
- m_center[2] = center[2];
- m_extends[0] = extents[0];
- m_extends[1] = extents[1];
- m_extends[2] = extents[2];
-};
-
-
-ODEPhysicsController::~ODEPhysicsController()
-{
- if (m_geomId)
- {
- dGeomDestroy (m_geomId);
- }
-}
-
-float ODEPhysicsController::getMass()
-{
- dMass mass;
- dBodyGetMass(m_bodyId,&mass);
- return mass.mass;
-}
-
-//////////////////////////////////////////////////////////////////////
-/// \todo Impart some extra impulse to dynamic objects when they collide with kinematically controlled "static" objects (ODE geoms), by using last 2 frames as 1st order approximation to the linear/angular velocity, and computing an appropriate impulse. Sumo (old physics engine) did this, see for details.
-/// \todo handle scaling of static ODE geoms or fail with error message if Ipo tries to change scale of a static geom object
-
-bool ODEPhysicsController::SynchronizeMotionStates(float time)
-{
- /**
- 'Late binding' of the rigidbody, because the World Scaling is not available until the scenegraph is traversed
- */
-
-
- if (m_firstTime)
- {
- m_firstTime=false;
-
- m_MotionState->calculateWorldTransformations();
-
- dQuaternion worldquat;
- float worldpos[3];
-
-#ifdef dDOUBLE
- m_MotionState->getWorldOrientation((float)worldquat[1],
- (float)worldquat[2],(float)worldquat[3],(float)worldquat[0]);
-#else
- m_MotionState->getWorldOrientation(worldquat[1],
- worldquat[2],worldquat[3],worldquat[0]);
-#endif
- m_MotionState->getWorldPosition(worldpos[0],worldpos[1],worldpos[2]);
-
- float scaling[3];
- m_MotionState->getWorldScaling(scaling[0],scaling[1],scaling[2]);
-
- if (!m_bPhantom)
- {
- if (m_implicitsphere)
- {
- m_geomId = dCreateSphere (m_space,m_radius*scaling[0]);
- } else
- {
- m_geomId = dCreateBox (m_space, m_extends[0]*scaling[0],m_extends[1]*scaling[1],m_extends[2]*scaling[2]);
- }
- } else
- {
- m_geomId=0;
- }
-
- if (m_geomId)
- dGeomSetData(m_geomId,this);
-
- if (!this->m_OdeDyna)
- {
- if (!m_bPhantom)
- {
- dGeomSetPosition (this->m_geomId,worldpos[0],worldpos[1],worldpos[2]);
- dMatrix3 R;
- dQtoR (worldquat, R);
- dGeomSetRotation (this->m_geomId,R);
- }
- } else
- {
- //it's dynamic, so create a 'model'
- m_bodyId = dBodyCreate(this->m_world);
- dBodySetPosition (m_bodyId,worldpos[0],worldpos[1],worldpos[2]);
- dBodySetQuaternion (this->m_bodyId,worldquat);
- //this contains both scalar mass and inertia tensor
- dMass m;
- float length=1,width=1,height=1;
- dMassSetBox (&m,1,m_extends[0]*scaling[0],m_extends[1]*scaling[1],m_extends[2]*scaling[2]);
- dMassAdjust (&m,this->m_mass);
- dBodySetMass (m_bodyId,&m);
-
- if (!m_bPhantom)
- {
- dGeomSetBody (m_geomId,m_bodyId);
- }
-
-
- }
-
- if (this->m_OdeDyna && !m_bFullRigidBody)
- {
- // ?? huh? what to do here?
- }
- }
-
-
-
- if (m_OdeDyna)
- {
- if (this->m_OdeSuspendDynamics)
- {
- return false;
- }
-
- const float* worldPos = (float *)dBodyGetPosition(m_bodyId);
- m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
-
- const float* worldquat = (float *)dBodyGetQuaternion(m_bodyId);
- m_MotionState->setWorldOrientation(worldquat[1],worldquat[2],worldquat[3],worldquat[0]);
- }
- else {
- // not a dyna, so dynamics (i.e. this controller) has not updated
- // anything. BUT! an Ipo or something else might have changed the
- // position/orientation of this geometry.
- // so update the static geom position
-
- /// \todo impart some extra impulse to colliding objects!
- dQuaternion worldquat;
- float worldpos[3];
-
-#ifdef dDOUBLE
- m_MotionState->getWorldOrientation((float)worldquat[1],
- (float)worldquat[2],(float)worldquat[3],(float)worldquat[0]);
-#else
- m_MotionState->getWorldOrientation(worldquat[1],
- worldquat[2],worldquat[3],worldquat[0]);
-#endif
- m_MotionState->getWorldPosition(worldpos[0],worldpos[1],worldpos[2]);
-
- float scaling[3];
- m_MotionState->getWorldScaling(scaling[0],scaling[1],scaling[2]);
-
- /// \todo handle scaling! what if Ipo changes scale of object?
- // Must propagate to geom... is scaling geoms possible with ODE? Also
- // what about scaling trimeshes, that is certainly difficult...
- dGeomSetPosition (this->m_geomId,worldpos[0],worldpos[1],worldpos[2]);
- dMatrix3 R;
- dQtoR (worldquat, R);
- dGeomSetRotation (this->m_geomId,R);
- }
-
- return false; //it update the worldpos
-}
-
-PHY_IMotionState* ODEPhysicsController::GetMotionState()
-{
- return m_MotionState;
-}
-
-
-// kinematic methods
-void ODEPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)
-{
-
-}
-void ODEPhysicsController::RelativeRotate(const float drot[9],bool local)
-{
-}
-void ODEPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
-{
-
- dQuaternion worldquat;
- worldquat[0] = quatReal;
- worldquat[1] = quatImag0;
- worldquat[2] = quatImag1;
- worldquat[3] = quatImag2;
-
- if (!this->m_OdeDyna)
- {
- dMatrix3 R;
- dQtoR (worldquat, R);
- dGeomSetRotation (this->m_geomId,R);
- } else
- {
- dBodySetQuaternion (m_bodyId,worldquat);
- this->m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
- }
-
-}
-
-void ODEPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
-{
- float q[4];
- this->m_MotionState->getWorldOrientation(q[0],q[1],q[2],q[3]);
- quatImag0=q[0];
- quatImag1=q[1];
- quatImag2=q[2];
- quatReal=q[3];
-}
-
-void ODEPhysicsController::getPosition(PHY__Vector3& pos) const
-{
- m_MotionState->getWorldPosition(pos[0],pos[1],pos[2]);
-
-}
-
-void ODEPhysicsController::setPosition(float posX,float posY,float posZ)
-{
- if (!m_bPhantom)
- {
- if (!this->m_OdeDyna)
- {
- dGeomSetPosition (m_geomId, posX, posY, posZ);
- } else
- {
- dBodySetPosition (m_bodyId, posX, posY, posZ);
- }
- }
-}
-void ODEPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
-{
-}
-
-// physics methods
-void ODEPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)
-{
- if (m_OdeDyna) {
- if(local) {
- dBodyAddRelTorque(m_bodyId, torqueX, torqueY, torqueZ);
- } else {
- dBodyAddTorque (m_bodyId, torqueX, torqueY, torqueZ);
- }
- }
-}
-
-void ODEPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
-{
- if (m_OdeDyna) {
- if(local) {
- dBodyAddRelForce(m_bodyId, forceX, forceY, forceZ);
- } else {
- dBodyAddForce (m_bodyId, forceX, forceY, forceZ);
- }
- }
-}
-
-void ODEPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)
-{
- if (m_OdeDyna) {
- if(local) {
- // TODO: translate angular vel into local frame, then apply
- } else {
- dBodySetAngularVel (m_bodyId, ang_velX,ang_velY,ang_velZ);
- }
- }
-}
-
-void ODEPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)
-{
- if (m_OdeDyna)
- {
- dVector3 vel = {lin_velX,lin_velY,lin_velZ, 1.0};
- if (local)
- {
- dMatrix3 worldmat;
- dVector3 localvel;
- dQuaternion worldquat;
-
-#ifdef dDOUBLE
- m_MotionState->getWorldOrientation((float)worldquat[1],
- (float)worldquat[2], (float)worldquat[3],(float)worldquat[0]);
-#else
- m_MotionState->getWorldOrientation(worldquat[1],worldquat[2],
- worldquat[3],worldquat[0]);
-#endif
- dQtoR (worldquat, worldmat);
-
- dMULTIPLY0_331 (localvel,worldmat,vel);
- dBodySetLinearVel (m_bodyId, localvel[0],localvel[1],localvel[2]);
-
- } else
- {
- dBodySetLinearVel (m_bodyId, lin_velX,lin_velY,lin_velZ);
- }
- }
-}
-
-void ODEPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)
-{
- if (m_OdeDyna)
- {
- //apply linear and angular effect
- const dReal* linvel = dBodyGetLinearVel(m_bodyId);
- float mass = getMass();
- if (mass >= 0.00001f)
- {
- float massinv = 1.f/mass;
- float newvel[3];
- newvel[0]=linvel[0]+impulseX*massinv;
- newvel[1]=linvel[1]+impulseY*massinv;
- newvel[2]=linvel[2]+impulseZ*massinv;
- dBodySetLinearVel(m_bodyId,newvel[0],newvel[1],newvel[2]);
-
- const float* worldPos = (float *)dBodyGetPosition(m_bodyId);
-
- const float* angvelc = (float *)dBodyGetAngularVel(m_bodyId);
- float angvel[3];
- angvel[0]=angvelc[0];
- angvel[1]=angvelc[1];
- angvel[2]=angvelc[2];
-
- dVector3 impulse;
- impulse[0]=impulseX;
- impulse[1]=impulseY;
- impulse[2]=impulseZ;
-
- dVector3 ap;
- ap[0]=attachX-worldPos[0];
- ap[1]=attachY-worldPos[1];
- ap[2]=attachZ-worldPos[2];
-
- dCROSS(angvel,+=,ap,impulse);
- dBodySetAngularVel(m_bodyId,angvel[0],angvel[1],angvel[2]);
-
- }
-
- }
-
-}
-
-void ODEPhysicsController::SuspendDynamics()
-{
-
-}
-
-void ODEPhysicsController::RestoreDynamics()
-{
-
-}
-
-
-/**
- reading out information from physics
-*/
-void ODEPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ)
-{
- if (m_OdeDyna)
- {
- const float* vel = (float *)dBodyGetLinearVel(m_bodyId);
- linvX = vel[0];
- linvY = vel[1];
- linvZ = vel[2];
- } else
- {
- linvX = 0.f;
- linvY = 0.f;
- linvZ = 0.f;
-
- }
-}
-/**
- GetVelocity parameters are in geometric coordinates (Origin is not center of mass!).
-*/
-void ODEPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)
-{
-
-}
-
-
-void ODEPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
-{
-
-}
-void ODEPhysicsController::setRigidBody(bool rigid)
-{
-
-}
-
-
-void ODEPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)
-{
- m_MotionState = motionstate;
- m_bKinematic = false;
- m_bPrevKinematic = false;
- m_firstTime = true;
-}
-
-
-void ODEPhysicsController::SetSimulatedTime(float time)
-{
-}
-
-
-void ODEPhysicsController::WriteMotionStateToDynamics(bool nondynaonly)
-{
-
-}
-#endif
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.h b/source/gameengine/Physics/BlOde/OdePhysicsController.h
deleted file mode 100644
index 544d11da2ca..00000000000
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __ODE_PHYSICSCONTROLLER_H
-#define __ODE_PHYSICSCONTROLLER_H
-
-
-#include "PHY_IPhysicsController.h"
-
-/**
- ODE Physics Controller, a special kind of a PhysicsController.
- A Physics Controller is a special kind of Scene Graph Transformation Controller.
- Each time the scene graph get's updated, the controller get's a chance
- in the 'Update' method to reflect changes.
-*/
-
-class ODEPhysicsController : public PHY_IPhysicsController
-
-{
-
- bool m_OdeDyna;
-
-public:
- ODEPhysicsController(
- bool dyna,
- bool fullRigidBody,
- bool phantom,
- class PHY_IMotionState* motionstate,
- struct dxSpace* space,
- struct dxWorld* world,
- float mass,
- float friction,
- float restitution,
- bool implicitsphere,
- float center[3],
- float extends[3],
- float radius);
-
- virtual ~ODEPhysicsController();
-
- // kinematic methods
- virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
- virtual void RelativeRotate(const float drot[9],bool local);
- virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
- virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
- virtual void setPosition(float posX,float posY,float posZ);
- virtual void getPosition(PHY__Vector3& pos) const;
-
- virtual void setScaling(float scaleX,float scaleY,float scaleZ);
-
- // physics methods
- virtual void ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local);
- virtual void ApplyForce(float forceX,float forceY,float forceZ,bool local);
- virtual void SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local);
- virtual void SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local);
- virtual void applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ);
- virtual void SetActive(bool active){};
- virtual void SuspendDynamics();
- virtual void RestoreDynamics();
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
- {
- //todo ?
- }
-
-
- /**
- reading out information from physics
- */
- virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ);
- /**
- GetVelocity parameters are in geometric coordinates (Origin is not center of mass!).
- */
- virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ);
- virtual float getMass();
- virtual void getReactionForce(float& forceX,float& forceY,float& forceZ);
- virtual void setRigidBody(bool rigid);
-
-
- virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl);
-
- // \todo remove next line !
- virtual void SetSimulatedTime(float time);
-
-
- virtual void WriteDynamicsToMotionState() {};
- virtual void WriteMotionStateToDynamics(bool nondynaonly);
- virtual class PHY_IMotionState* GetMotionState();
-
- /**
- call from Scene Graph Node to 'update'.
- */
- virtual bool SynchronizeMotionStates(float time);
-
- virtual void calcXform(){}
- virtual void SetMargin(float margin) {}
- virtual float GetMargin() const {return 0.f;}
- virtual float GetRadius() const {return 0.f;}
- virtual void SetRadius(float margin) {}
-
- // clientinfo for raycasts for example
- virtual void* getNewClientInfo() { return m_clientInfo;}
- virtual void setNewClientInfo(void* clientinfo) {m_clientInfo = clientinfo;};
- void* m_clientInfo;
-
- struct dxBody* GetOdeBodyId() { return m_bodyId; }
-
- float getFriction() { return m_friction;}
- float getRestitution() { return m_restitution;}
-
- float GetLinVelocityMin() const { return 0.f; }
- void SetLinVelocityMin(float val) { }
- float GetLinVelocityMax() const { return 0.f; }
- void SetLinVelocityMax(float val) { }
-
-
-private:
-
- bool m_firstTime;
- bool m_bFullRigidBody;
- bool m_bPhantom; // special flag for objects that are not affected by physics 'resolver'
-
- // data to calculate fake velocities for kinematic objects (non-dynas)
- bool m_bKinematic;
- bool m_bPrevKinematic;
-
-
- float m_lastTime;
- bool m_OdeSuspendDynamics;
- class PHY_IMotionState* m_MotionState;
-
- //Ode specific members
- struct dxBody* m_bodyId;
- struct dxGeom* m_geomId;
- struct dxSpace* m_space;
- struct dxWorld* m_world;
- float m_mass;
- float m_friction;
- float m_restitution;
- bool m_implicitsphere;
- float m_center[3];
- float m_extends[3];
- float m_radius;
-};
-
-#endif //__ODE_PHYSICSCONTROLLER_H
-
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
deleted file mode 100644
index 54e97858b7f..00000000000
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include "OdePhysicsEnvironment.h"
-#include "PHY_IMotionState.h"
-#include "OdePhysicsController.h"
-
-#include <ode/ode.h>
-#include <../ode/src/joint.h>
-#include <ode/odemath.h>
-
-ODEPhysicsEnvironment::ODEPhysicsEnvironment()
-{
- m_OdeWorld = dWorldCreate();
- m_OdeSpace = dHashSpaceCreate();
- m_OdeContactGroup = dJointGroupCreate (0);
- dWorldSetCFM (m_OdeWorld,1e-5f);
-
- m_JointGroup = dJointGroupCreate(0);
-
- setFixedTimeStep(true,1.f/60.f);
-}
-
-
-
-ODEPhysicsEnvironment::~ODEPhysicsEnvironment()
-{
- dJointGroupDestroy (m_OdeContactGroup);
- dJointGroupDestroy (m_JointGroup);
-
- dSpaceDestroy (m_OdeSpace);
- dWorldDestroy (m_OdeWorld);
-}
-
-
-
-void ODEPhysicsEnvironment::setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
-{
- m_useFixedTimeStep = useFixedTimeStep;
-
- if (useFixedTimeStep)
- {
- m_fixedTimeStep = fixedTimeStep;
- } else
- {
- m_fixedTimeStep = 0.f;
- }
- m_currentTime = 0.f;
-
- //todo:implement fixed timestepping
-
-}
-float ODEPhysicsEnvironment::getFixedTimeStep()
-{
- return m_fixedTimeStep;
-}
-
-
-
-bool ODEPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep1,float interval)
-{
-
- float deltaTime = timeStep1;
- int numSteps = 1;
-
- if (m_useFixedTimeStep)
- {
- m_currentTime += timeStep1;
- // equal to subSampling (might be a little smaller).
- numSteps = (int)(m_currentTime / m_fixedTimeStep);
- m_currentTime -= m_fixedTimeStep * (float)numSteps;
- deltaTime = m_fixedTimeStep;
- //todo: experiment by smoothing the remaining time over the substeps
- }
-
- for (int i=0;i<numSteps;i++)
- {
- // ode collision update
- dSpaceCollide (m_OdeSpace,this,&ODEPhysicsEnvironment::OdeNearCallback);
-
- int m_odeContacts = GetNumOdeContacts();
-
- //physics integrator + resolver update
- //dWorldStep (m_OdeWorld,deltaTime);
- //dWorldQuickStep (m_OdeWorld,deltaTime);
- //dWorldID w, dReal stepsize)
-
- //clear collision points
- this->ClearOdeContactGroup();
- }
- return true;
-}
-
-void ODEPhysicsEnvironment::setGravity(float x,float y,float z)
-{
- dWorldSetGravity (m_OdeWorld,x,y,z);
-}
-
-
-
-int ODEPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
- float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ)
-{
-
- int constraintid = 0;
- ODEPhysicsController* dynactrl = (ODEPhysicsController*)ctrl;
- ODEPhysicsController* dynactrl2 = (ODEPhysicsController*)ctrl2;
-
- switch (type)
- {
- case PHY_POINT2POINT_CONSTRAINT:
- {
- if (dynactrl)
- {
- dJointID jointid = dJointCreateBall (m_OdeWorld,m_JointGroup);
- struct dxBody* bodyid1 = dynactrl->GetOdeBodyId();
- struct dxBody* bodyid2=0;
- const dReal* pos = dBodyGetPosition(bodyid1);
- const dReal* R = dBodyGetRotation(bodyid1);
- dReal offset[3] = {pivotX,pivotY,pivotZ};
- dReal newoffset[3];
- dMULTIPLY0_331 (newoffset,R,offset);
- newoffset[0] += pos[0];
- newoffset[1] += pos[1];
- newoffset[2] += pos[2];
-
-
- if (dynactrl2)
- bodyid2 = dynactrl2->GetOdeBodyId();
-
- dJointAttach (jointid, bodyid1, bodyid2);
-
- dJointSetBallAnchor (jointid, newoffset[0], newoffset[1], newoffset[2]);
-
- constraintid = (int) jointid;
- }
- break;
- }
- case PHY_LINEHINGE_CONSTRAINT:
- {
- if (dynactrl)
- {
- dJointID jointid = dJointCreateHinge (m_OdeWorld,m_JointGroup);
- struct dxBody* bodyid1 = dynactrl->GetOdeBodyId();
- struct dxBody* bodyid2=0;
- const dReal* pos = dBodyGetPosition(bodyid1);
- const dReal* R = dBodyGetRotation(bodyid1);
- dReal offset[3] = {pivotX,pivotY,pivotZ};
- dReal axisset[3] = {axisX,axisY,axisZ};
-
- dReal newoffset[3];
- dReal newaxis[3];
- dMULTIPLY0_331 (newaxis,R,axisset);
-
- dMULTIPLY0_331 (newoffset,R,offset);
- newoffset[0] += pos[0];
- newoffset[1] += pos[1];
- newoffset[2] += pos[2];
-
-
- if (dynactrl2)
- bodyid2 = dynactrl2->GetOdeBodyId();
-
- dJointAttach (jointid, bodyid1, bodyid2);
-
- dJointSetHingeAnchor (jointid, newoffset[0], newoffset[1], newoffset[2]);
- dJointSetHingeAxis(jointid,newaxis[0],newaxis[1],newaxis[2]);
-
- constraintid = (int) jointid;
- }
- break;
- }
- default:
- {
- //not yet
- }
- }
-
- return constraintid;
-
-}
-
-void ODEPhysicsEnvironment::removeConstraint(void *constraintid)
-{
- if (constraintid)
- {
- dJointDestroy((dJointID) constraintid);
- }
-}
-
-PHY_IPhysicsController* ODEPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
-{
-
- //m_OdeWorld
- //collision detection / raytesting
- return NULL;
-}
-
-
-void ODEPhysicsEnvironment::OdeNearCallback (void *data, dGeomID o1, dGeomID o2)
-{
- // \todo if this is a registered collision sensor
- // fire the callback
-
- int i;
- // if (o1->body && o2->body) return;
- ODEPhysicsEnvironment* env = (ODEPhysicsEnvironment*) data;
- dBodyID b1,b2;
-
- b1 = dGeomGetBody(o1);
- b2 = dGeomGetBody(o2);
- // exit without doing anything if the two bodies are connected by a joint
- if (b1 && b2 && dAreConnected (b1,b2)) return;
-
- ODEPhysicsController * ctrl1 =(ODEPhysicsController *)dGeomGetData(o1);
- ODEPhysicsController * ctrl2 =(ODEPhysicsController *)dGeomGetData(o2);
- float friction=ctrl1->getFriction();
- float restitution = ctrl1->getRestitution();
- //for friction, take minimum
-
- friction=(friction < ctrl2->getFriction() ?
- friction :ctrl2->getFriction());
-
- //restitution:take minimum
- restitution = restitution < ctrl2->getRestitution()?
- restitution : ctrl2->getRestitution();
-
- dContact contact[3]; // up to 3 contacts per box
- for (i=0; i<3; i++) {
- contact[i].surface.mode = dContactBounce; //dContactMu2;
- contact[i].surface.mu = friction;//dInfinity;
- contact[i].surface.mu2 = 0;
- contact[i].surface.bounce = restitution;//0.5;
- contact[i].surface.bounce_vel = 0.1f;
- contact[i].surface.slip1=0.0;
- }
-
- if (int numc = dCollide (o1,o2,3,&contact[0].geom,sizeof(dContact))) {
- // dMatrix3 RI;
- // dRSetIdentity (RI);
- // const dReal ss[3] = {0.02,0.02,0.02};
- for (i=0; i<numc; i++) {
- dJointID c = dJointCreateContact (env->m_OdeWorld,env->m_OdeContactGroup,contact+i);
- dJointAttach (c,b1,b2);
- }
- }
-}
-
-
-void ODEPhysicsEnvironment::ClearOdeContactGroup()
-{
- dJointGroupEmpty (m_OdeContactGroup);
-}
-
-int ODEPhysicsEnvironment::GetNumOdeContacts()
-{
- return m_OdeContactGroup->num;
-}
-
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
deleted file mode 100644
index 54e4f7f90e1..00000000000
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef _ODEPHYSICSENVIRONMENT
-#define _ODEPHYSICSENVIRONMENT
-
-
-#include "PHY_IPhysicsEnvironment.h"
-
-/**
-* Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.)
-* A derived class may be able to 'construct' entities by loading and/or converting
-*/
-class ODEPhysicsEnvironment : public PHY_IPhysicsEnvironment
-{
-
- bool m_useFixedTimeStep;
- float m_fixedTimeStep;
- float m_currentTime;
-
-public:
- ODEPhysicsEnvironment();
- virtual ~ODEPhysicsEnvironment();
- virtual void beginFrame() {}
- virtual void endFrame() {}
-
-
-// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
- virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
- virtual float getFixedTimeStep();
-
- virtual void setGravity(float x,float y,float z);
- virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
- float pivotX,float pivotY,float pivotZ,
- float axisX,float axisY,float axisZ);
-
- virtual void removeConstraint(void * constraintid);
- virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
- virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes) { return false; }
-
-
- //gamelogic callbacks
- virtual void addSensor(PHY_IPhysicsController* ctrl) {}
- virtual void removeSensor(PHY_IPhysicsController* ctrl) {}
- virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
- {
- }
- virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl) {return false;}
- virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl) {return false;}
- virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;}
- virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;}
-
-
-
- struct dxWorld* GetOdeWorld() { return m_OdeWorld; };
- struct dxSpace* GetOdeSpace() { return m_OdeSpace;};
-
-private:
-
-
- // ODE physics response
- struct dxWorld* m_OdeWorld;
- // ODE collision detection
- struct dxSpace* m_OdeSpace;
- void ClearOdeContactGroup();
- struct dxJointGroup* m_OdeContactGroup;
- struct dxJointGroup* m_JointGroup;
-
- static void OdeNearCallback(void *data, struct dxGeom* o1, struct dxGeom* o2);
- int GetNumOdeContacts();
-
-};
-
-#endif //_ODEPHYSICSENVIRONMENT
-
diff --git a/source/gameengine/Physics/BlOde/SConscript b/source/gameengine/Physics/BlOde/SConscript
deleted file mode 100644
index 90e949d2d86..00000000000
--- a/source/gameengine/Physics/BlOde/SConscript
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/python
-Import ('user_options_dict')
-Import ('library_env')
-
-phy_ode_env = library_env.Copy ()
-
-source_files = ['OdePhysicsController.cpp',
- 'OdePhysicsEnvironment.cpp']
-
-phy_ode_env.Append (CPPPATH=['.',
- '../common',
- ])
-phy_ode_env.Append (CPPPATH=user_options_dict['ODE_INCLUDE'])
-
-phy_ode_env.Library (target='#'+user_options_dict['BUILD_DIR']+'/lib/PHY_Ode', source=source_files)
diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript
index c517d8b5d9d..b6d0a75fd04 100644
--- a/source/gameengine/Physics/Bullet/SConscript
+++ b/source/gameengine/Physics/Bullet/SConscript
@@ -23,8 +23,9 @@ incs += ' ' + env['BF_BULLET_INC']
incs += ' ' + env['BF_PYTHON_INC']
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
-env.BlenderLib ( 'bf_bullet', Split(sources), Split(incs), [], libtype=['game','player'], priority=[15,90], cxx_compileflags=cxxflags )
+env.BlenderLib ( 'bf_bullet', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350,80], cxx_compileflags=cxxflags )
diff --git a/source/gameengine/Physics/Dummy/Makefile b/source/gameengine/Physics/Dummy/Makefile
index b0c1b855322..c016a0bebcb 100644
--- a/source/gameengine/Physics/Dummy/Makefile
+++ b/source/gameengine/Physics/Dummy/Makefile
@@ -39,7 +39,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO)/include -I$(NAN_MOTO)/include
+CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I../../Physics/common
CPPFLAGS += -I../../Physics/Dummy
diff --git a/source/gameengine/Physics/Dummy/SConscript b/source/gameengine/Physics/Dummy/SConscript
index e24b150531f..93d6ac36446 100644
--- a/source/gameengine/Physics/Dummy/SConscript
+++ b/source/gameengine/Physics/Dummy/SConscript
@@ -5,4 +5,4 @@ sources = 'DummyPhysicsEnvironment.cpp'
incs = '. ../common'
-env.BlenderLib ( 'bf_dummy', Split(sources), Split(incs), [], libtype=['game','player'], priority=[10,100] )
+env.BlenderLib ( 'bf_dummy', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350,95] )
diff --git a/source/gameengine/Physics/Makefile b/source/gameengine/Physics/Makefile
index b192e497f35..da0d4cafd2e 100644
--- a/source/gameengine/Physics/Makefile
+++ b/source/gameengine/Physics/Makefile
@@ -32,7 +32,6 @@ include nan_definitions.mk
SOURCEDIR = source/gameengine/Physics
DIR = $(OCGDIR)/gameengine/blphys
-DIRS = common Sumo Dummy Bullet
-#DIRS += BlOde
+DIRS = common Dummy Bullet
include nan_subdirs.mk
diff --git a/source/gameengine/Physics/Sumo/CMakeLists.txt b/source/gameengine/Physics/Sumo/CMakeLists.txt
deleted file mode 100644
index c57a4af6706..00000000000
--- a/source/gameengine/Physics/Sumo/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# $Id$
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# The Original Code is Copyright (C) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-SET(SRC
- SumoPHYCallbackBridge.cpp
- SumoPhysicsController.cpp
- SumoPhysicsEnvironment.cpp
- Fuzzics/src/SM_FhObject.cpp
- Fuzzics/src/SM_Object.cpp
- Fuzzics/src/SM_Scene.cpp
- Fuzzics/src/SM_MotionState.cpp
-)
-
-SET(INC
- .
- ../common
- Fuzzics/include
- ../../../../intern/moto/include
- ../../../../extern/solid
-)
-
-BLENDERLIB(bf_sumo "${SRC}" "${INC}")
-#env.BlenderLib ( 'bf_sumo', sources, incs, [], libtype=['game2','player'], priority=[30, 70] , compileflags=cflags)
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/Makefile b/source/gameengine/Physics/Sumo/Fuzzics/Makefile
deleted file mode 100644
index 5ed2c31a1d0..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): none yet.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-# Bounces make to subdirectories.
-
-SOURCEDIR = source/gameengine/Physics/Sumo/Fuzzics
-DIRS = src
-
-include nan_subdirs.mk
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h
deleted file mode 100644
index 42b5ab48ab6..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef SM_CALLBACK_H
-#define SM_CALLBACK_H
-
-class SM_Callback {
-public:
- virtual void do_me() = 0;
- virtual ~SM_Callback() {}
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_ClientObjectInfo.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_ClientObjectInfo.h
deleted file mode 100644
index 6749e7957ec..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_ClientObjectInfo.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __SM_CLIENTOBJECT_INFO_H
-#define __SM_CLIENTOBJECT_INFO_H
-
-/**
- * Client Type and Additional Info. This structure can be use instead of a bare void* pointer, for safeness, and additional info for callbacks
- */
-
-struct SM_ClientObjectInfo
-{
- int m_type;
- void* m_clientobject1;
- void* m_auxilary_info;
-};
-
-#endif //__SM_CLIENTOBJECT_INFO_H
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h
deleted file mode 100644
index 48d5906e53d..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-#ifndef __SM_DEBUG_H__
-#define __SM_DEBUG_H__
-
-/* Comment this to disable all SUMO debugging printfs */
-
-#define SM_DEBUG
-
-#ifdef SM_DEBUG
-
-#include <stdio.h>
-
-/* Uncomment this to printf all ray casts */
-//#define SM_DEBUG_RAYCAST
-
-/* Uncomment this to printf collision callbacks */
-//#define SM_DEBUG_BOING
-
-/* Uncomment this to printf Xform matrix calculations */
-//#define SM_DEBUG_XFORM
-
-#endif /* SM_DEBUG */
-
-#endif /* __SM_DEBUG_H__ */
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h
deleted file mode 100644
index b03612ed15e..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_FHOBJECT_H
-#define SM_FHOBJECT_H
-
-#include "SM_Object.h"
-
-class SM_FhObject : public SM_Object {
-public:
- virtual ~SM_FhObject();
- SM_FhObject(DT_ShapeHandle rayshape, MT_Vector3 ray, SM_Object *parent_object);
-
- const MT_Vector3& getRay() const { return m_ray; }
- MT_Point3 getSpot() const { return getPosition() + m_ray; }
- const MT_Vector3& getRayDirection() const { return m_ray_direction; }
- SM_Object *getParentObject() const { return m_parent_object; }
-
- static DT_Bool ray_hit(void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data);
-
-private:
- MT_Vector3 m_ray;
- MT_Vector3 m_ray_direction;
- SM_Object *m_parent_object;
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h
deleted file mode 100644
index fdc45af5225..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_MOTIONSTATE_H
-#define SM_MOTIONSTATE_H
-
-#include "MT_Transform.h"
-
-class SM_MotionState {
-public:
- SM_MotionState() :
- m_time(0.0),
- m_pos(0.0, 0.0, 0.0),
- m_orn(0.0, 0.0, 0.0, 1.0),
- m_lin_vel(0.0, 0.0, 0.0),
- m_ang_vel(0.0, 0.0, 0.0)
- {}
-
- void setPosition(const MT_Point3& pos) { m_pos = pos; }
- void setOrientation(const MT_Quaternion& orn) { m_orn = orn; }
- void setLinearVelocity(const MT_Vector3& lin_vel) { m_lin_vel = lin_vel; }
- void setAngularVelocity(const MT_Vector3& ang_vel) { m_ang_vel = ang_vel; }
- void setTime(MT_Scalar time) { m_time = time; }
-
- const MT_Point3& getPosition() const { return m_pos; }
- const MT_Quaternion& getOrientation() const { return m_orn; }
- const MT_Vector3& getLinearVelocity() const { return m_lin_vel; }
- const MT_Vector3& getAngularVelocity() const { return m_ang_vel; }
-
- MT_Scalar getTime() const { return m_time; }
-
- void integrateMidpoint(MT_Scalar timeStep, const SM_MotionState &prev_state, const MT_Vector3 &velocity, const MT_Quaternion& ang_vel);
- void integrateBackward(MT_Scalar timeStep, const MT_Vector3 &velocity, const MT_Quaternion& ang_vel);
- void integrateForward(MT_Scalar timeStep, const SM_MotionState &prev_state);
-
- void lerp(const SM_MotionState &prev, const SM_MotionState &next);
- void lerp(MT_Scalar t, const SM_MotionState &other);
-
- virtual MT_Transform getTransform() const {
- return MT_Transform(m_pos, m_orn);
- }
-
-protected:
- MT_Scalar m_time;
- MT_Point3 m_pos;
- MT_Quaternion m_orn;
- MT_Vector3 m_lin_vel;
- MT_Vector3 m_ang_vel;
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
deleted file mode 100644
index 2d748a0f251..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
+++ /dev/null
@@ -1,393 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_OBJECT_H
-#define SM_OBJECT_H
-
-#include <vector>
-
-#include <SOLID/SOLID.h>
-
-#include "SM_Callback.h"
-#include "SM_MotionState.h"
-#include <stdio.h>
-
-class SM_FhObject;
-
-/** Properties of dynamic objects */
-struct SM_ShapeProps {
- MT_Scalar m_mass; ///< Total mass
- MT_Scalar m_radius; ///< Bound sphere size
- MT_Vector3 m_inertia; ///< Inertia, should be a tensor some time
- MT_Scalar m_lin_drag; ///< Linear drag (air, water) 0 = concrete, 1 = vacuum
- MT_Scalar m_ang_drag; ///< Angular drag
- MT_Scalar m_friction_scaling[3]; ///< Scaling for anisotropic friction. Component in range [0, 1]
- bool m_do_anisotropic; ///< Should I do anisotropic friction?
- bool m_do_fh; ///< Should the object have a linear Fh spring?
- bool m_do_rot_fh; ///< Should the object have an angular Fh spring?
-};
-
-
-/** Properties of collidable objects (non-ghost objects) */
-struct SM_MaterialProps {
- MT_Scalar m_restitution; ///< restitution of energy after a collision 0 = inelastic, 1 = elastic
- MT_Scalar m_friction; ///< Coulomb friction (= ratio between the normal en maximum friction force)
- MT_Scalar m_fh_spring; ///< Spring constant (both linear and angular)
- MT_Scalar m_fh_damping; ///< Damping factor (linear and angular) in range [0, 1]
- MT_Scalar m_fh_distance; ///< The range above the surface where Fh is active.
- bool m_fh_normal; ///< Should the object slide off slopes?
-};
-
-class SM_ClientObject
-{
-public:
- SM_ClientObject() {}
- virtual ~SM_ClientObject() {}
-
- virtual bool hasCollisionCallback() = 0;
-};
-
-/**
- * SM_Object is an internal part of the Sumo physics engine.
- *
- * It encapsulates an object in the physics scene, and is responsible
- * for calculating the collision response of objects.
- */
-class SM_Object
-{
-public:
- SM_Object() ;
- SM_Object(
- DT_ShapeHandle shape,
- const SM_MaterialProps *materialProps,
- const SM_ShapeProps *shapeProps,
- SM_Object *dynamicParent
- );
- virtual ~SM_Object();
-
- bool isDynamic() const;
-
- /* nzc experimental. There seem to be two places where kinematics
- * are evaluated: proceedKinematic (called from SM_Scene) and
- * proceed() in this object. I'll just try and bunge these out for
- * now. */
-
- void suspend(void);
- void resume(void);
-
- void suspendDynamics();
-
- void restoreDynamics();
-
- bool isGhost() const;
-
- void suspendMaterial();
-
- void restoreMaterial();
-
- SM_FhObject *getFhObject() const;
-
- void registerCallback(SM_Callback& callback);
-
- void calcXform();
- void notifyClient();
- void updateInvInertiaTensor();
-
-
- // Save the current state information for use in the
- // velocity computation in the next frame.
-
- void proceedKinematic(MT_Scalar timeStep);
-
- void saveReactionForce(MT_Scalar timeStep) ;
-
- void clearForce() ;
-
- void clearMomentum() ;
-
- void setMargin(MT_Scalar margin) ;
-
- MT_Scalar getMargin() const ;
-
- const SM_MaterialProps *getMaterialProps() const ;
-
- const SM_ShapeProps *getShapeProps() const ;
-
- void setPosition(const MT_Point3& pos);
- void setOrientation(const MT_Quaternion& orn);
- void setScaling(const MT_Vector3& scaling);
-
- /**
- * set an external velocity. This velocity complements
- * the physics velocity. So setting it does not override the
- * physics velocity. It is your responsibility to clear
- * this external velocity. This velocity is not subject to
- * friction or damping.
- */
- void setExternalLinearVelocity(const MT_Vector3& lin_vel) ;
- void addExternalLinearVelocity(const MT_Vector3& lin_vel) ;
-
- /** Override the physics velocity */
- void addLinearVelocity(const MT_Vector3& lin_vel);
- void setLinearVelocity(const MT_Vector3& lin_vel);
-
- /**
- * Set an external angular velocity. This velocity complemetns
- * the physics angular velocity so does not override it. It is
- * your responsibility to clear this velocity. This velocity
- * is not subject to friction or damping.
- */
- void setExternalAngularVelocity(const MT_Vector3& ang_vel) ;
- void addExternalAngularVelocity(const MT_Vector3& ang_vel);
-
- /** Override the physics angular velocity */
- void addAngularVelocity(const MT_Vector3& ang_vel);
- void setAngularVelocity(const MT_Vector3& ang_vel);
-
- /** Clear the external velocities */
- void clearCombinedVelocities();
-
- /**
- * Tell the physics system to combine the external velocity
- * with the physics velocity.
- */
- void resolveCombinedVelocities(
- const MT_Vector3 & lin_vel,
- const MT_Vector3 & ang_vel
- ) ;
-
-
-
- MT_Scalar getInvMass() const;
-
- const MT_Vector3& getInvInertia() const ;
-
- const MT_Matrix3x3& getInvInertiaTensor() const;
-
- void applyForceField(const MT_Vector3& accel) ;
-
- void applyCenterForce(const MT_Vector3& force) ;
-
- void applyTorque(const MT_Vector3& torque) ;
-
- /**
- * Apply an impulse to the object. The impulse will be split into
- * angular and linear components.
- * @param attach point to apply the impulse to (in world coordinates)
- */
- void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse) ;
-
- /**
- * Applies an impulse through the center of this object. (ie the angular
- * velocity will not change.
- */
- void applyCenterImpulse(const MT_Vector3& impulse);
- /**
- * Applies an angular impulse.
- */
- void applyAngularImpulse(const MT_Vector3& impulse);
-
- MT_Point3 getWorldCoord(const MT_Point3& local) const;
- MT_Point3 getLocalCoord(const MT_Point3& world) const;
-
- MT_Vector3 getVelocity(const MT_Point3& local) const;
-
-
- const MT_Vector3& getReactionForce() const ;
-
- void getMatrix(double *m) const ;
-
- const double *getMatrix() const ;
-
- // Still need this???
- const MT_Transform& getScaledTransform() const;
-
- DT_ObjectHandle getObjectHandle() const ;
- DT_ShapeHandle getShapeHandle() const ;
-
- SM_Object *getDynamicParent() ;
-
- void integrateForces(MT_Scalar timeStep);
- void integrateMomentum(MT_Scalar timeSteo);
-
- void setRigidBody(bool is_rigid_body) ;
-
- bool isRigidBody() const ;
-
- // This is the callback for handling collisions of dynamic objects
- static
- DT_Bool
- boing(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
- );
-
- static
- DT_Bool
- fix(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
- );
-
-
- SM_ClientObject *getClientObject() { return m_client_object; }
- void setClientObject(SM_ClientObject *client_object) { m_client_object = client_object; }
- void setPhysicsClientObject(void* physicsClientObject)
- {
- m_physicsClientObject = physicsClientObject;
- }
- void* getPhysicsClientObject() {
- return m_physicsClientObject;
- }
- void relax();
-
- SM_MotionState &getCurrentFrame();
- SM_MotionState &getPreviousFrame();
- SM_MotionState &getNextFrame();
-
- const SM_MotionState &getCurrentFrame() const;
- const SM_MotionState &getPreviousFrame() const;
- const SM_MotionState &getNextFrame() const;
-
- // Motion state functions
- const MT_Point3& getPosition() const;
- const MT_Quaternion& getOrientation() const;
- const MT_Vector3& getLinearVelocity() const;
- const MT_Vector3& getAngularVelocity() const;
-
- MT_Scalar getTime() const;
-
- void setTime(MT_Scalar time);
-
- void interpolate(MT_Scalar timeStep);
- void endFrame();
-
-private:
- friend class Contact;
- // Tweak parameters
- static MT_Scalar ImpulseThreshold;
-
- // return the actual linear_velocity of this object this
- // is the addition of m_combined_lin_vel and m_lin_vel.
-
- const
- MT_Vector3
- actualLinVelocity(
- ) const ;
-
- const
- MT_Vector3
- actualAngVelocity(
- ) const ;
-
- void dynamicCollision(const MT_Point3 &local2,
- const MT_Vector3 &normal,
- MT_Scalar dist,
- const MT_Vector3 &rel_vel,
- MT_Scalar restitution,
- MT_Scalar friction_factor,
- MT_Scalar invMass
- );
-
- typedef std::vector<SM_Callback *> T_CallbackList;
-
-
- T_CallbackList m_callbackList; // Each object can have multiple callbacks from the client (=game engine)
- SM_Object *m_dynamicParent; // Collisions between parent and children are ignored
-
- // as the collision callback now has only information
- // on an SM_Object, there must be a way that the SM_Object client
- // can identify it's clientdata after a collision
- SM_ClientObject *m_client_object;
-
- void* m_physicsClientObject;
-
- DT_ShapeHandle m_shape; // Shape for collision detection
-
- // Material and shape properties are not owned by this class.
-
- const SM_MaterialProps *m_materialProps;
- const SM_MaterialProps *m_materialPropsBackup; // Backup in case the object temporarily becomes a ghost.
- const SM_ShapeProps *m_shapeProps;
- const SM_ShapeProps *m_shapePropsBackup; // Backup in case the object's dynamics is temporarily suspended
- DT_ObjectHandle m_object; // A handle to the corresponding object in SOLID.
- MT_Scalar m_margin; // Offset for the object's shape (also for collision detection)
- MT_Vector3 m_scaling; // Non-uniform scaling of the object's shape
-
- double m_ogl_matrix[16]; // An OpenGL-type 4x4 matrix
- MT_Transform m_xform; // The object's local coordinate system
- MT_Transform m_prev_xform; // The object's local coordinate system in the previous frame
- SM_MotionState m_prev_state; // The object's motion state in the previous frame
- MT_Scalar m_timeStep; // The duration of the last frame
-
- MT_Vector3 m_reaction_impulse; // The accumulated impulse resulting from collisions
- MT_Vector3 m_reaction_force; // The reaction force derived from the reaction impulse
-
- MT_Vector3 m_lin_mom; // Linear momentum (linear velocity times mass)
- MT_Vector3 m_ang_mom; // Angular momentum (angualr velocity times inertia)
- MT_Vector3 m_force; // Force on center of mass (afffects linear momentum)
- MT_Vector3 m_torque; // Torque around center of mass (affects angular momentum)
-
- SM_MotionState m_frames[3];
-
- MT_Vector3 m_error; // Error in position:- amount object must be moved to prevent intersection with scene
-
- // Here are the values of externally set linear and angular
- // velocity. These are updated from the outside
- // (actuators and python) each frame and combined with the
- // physics values. At the end of each frame (at the end of a
- // call to proceed) they are set to zero. This allows the
- // outside world to contribute to the velocity of an object
- // but still have it react to physics.
-
- MT_Vector3 m_combined_lin_vel;
- MT_Vector3 m_combined_ang_vel;
-
- // The force and torque are the accumulated forces and torques applied by the client (game logic, python).
-
- SM_FhObject *m_fh_object; // The ray object used for Fh
- bool m_suspended; // Is this object frozen?
-
- // Mass properties
- MT_Scalar m_inv_mass; // 1/mass
- MT_Vector3 m_inv_inertia; // [1/inertia_x, 1/inertia_y, 1/inertia_z]
- MT_Matrix3x3 m_inv_inertia_tensor; // Inverse Inertia Tensor
-
- bool m_kinematic; // Have I been displaced (translated, rotated, scaled) in this frame?
- bool m_prev_kinematic; // Have I been displaced (translated, rotated, scaled) in the previous frame?
- bool m_is_rigid_body; // Should friction give me a change in angular momentum?
- int m_static; // temporarily static.
-
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h
deleted file mode 100644
index 81b4cb55b45..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_PROPSH
-#define SM_PROPSH
-
-#include <MT_Scalar.h>
-
-// Properties of dynamic objects
-struct SM_ShapeProps {
- MT_Scalar m_mass; // Total mass
- MT_Scalar m_inertia; // Inertia, should be a tensor some time
- MT_Scalar m_lin_drag; // Linear drag (air, water) 0 = concrete, 1 = vacuum
- MT_Scalar m_ang_drag; // Angular drag
- MT_Scalar m_friction_scaling[3]; // Scaling for anisotropic friction. Component in range [0, 1]
- bool m_do_anisotropic; // Should I do anisotropic friction?
- bool m_do_fh; // Should the object have a linear Fh spring?
- bool m_do_rot_fh; // Should the object have an angular Fh spring?
-};
-
-
-// Properties of collidable objects (non-ghost objects)
-struct SM_MaterialProps {
- MT_Scalar m_restitution; // restitution of energie after a collision 0 = inelastic, 1 = elastic
- MT_Scalar m_friction; // Coulomb friction (= ratio between the normal en maximum friction force)
- MT_Scalar m_fh_spring; // Spring constant (both linear and angular)
- MT_Scalar m_fh_damping; // Damping factor (linear and angular) in range [0, 1]
- MT_Scalar m_fh_distance; // The range above the surface where Fh is active.
- bool m_fh_normal; // Should the object slide off slopes?
-};
-
-#endif //SM_PROPSH
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
deleted file mode 100644
index 3d8eef2bae0..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * $Id$
- * Copyright (C) 2001 NaN Technologies B.V.
- * The physics scene.
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_SCENE_H
-#define SM_SCENE_H
-
-#ifdef WIN32
-#pragma warning (disable : 4786)
-#endif
-
-#include <vector>
-#include <set>
-#include <utility> //needed for pair
-
-#include <SOLID/SOLID.h>
-
-#include "MT_Vector3.h"
-#include "MT_Point3.h"
-
-#include "SM_Object.h"
-
-enum
-{
- FH_RESPONSE,
- SENSOR_RESPONSE, /* Touch Sensors */
- CAMERA_RESPONSE, /* Visibility Culling */
- OBJECT_RESPONSE, /* Object Dynamic Geometry Response */
- STATIC_RESPONSE, /* Static Geometry Response */
-
- NUM_RESPONSE
-};
-
-class SM_Scene {
-public:
- SM_Scene();
-
- ~SM_Scene();
-
- DT_RespTableHandle getRespTableHandle() const {
- return m_respTable;
- }
-
- const MT_Vector3& getForceField() const {
- return m_forceField;
- }
-
- MT_Vector3& getForceField() {
- return m_forceField;
- }
-
- void setForceField(const MT_Vector3& forceField) {
- m_forceField = forceField;
- }
-
- void addTouchCallback(int response_class, DT_ResponseCallback callback, void *user);
-
- void addSensor(SM_Object& object);
- void add(SM_Object& object);
- void remove(SM_Object& object);
-
- void notifyCollision(SM_Object *obj1, SM_Object *obj2);
-
- void setSecondaryRespTable(DT_RespTableHandle secondaryRespTable);
- DT_RespTableHandle getSecondaryRespTable() { return m_secondaryRespTable; }
-
- void requestCollisionCallback(SM_Object &object);
-
- void beginFrame();
- void endFrame();
-
- // Perform an integration step of duration 'timeStep'.
- // 'subSampling' is the maximum duration of a substep, i.e.,
- // The maximum time interval between two collision checks.
- // 'subSampling' can be used to control aliasing effects
- // (fast moving objects traversing through walls and such).
- bool proceed(MT_Scalar curtime, MT_Scalar ticrate);
- void proceed(MT_Scalar subStep);
-
- /**
- * Test whether any objects lie on the line defined by from and
- * to. The search returns the first such bject starting at from,
- * or NULL if there was none.
- * @returns A reference to the object, or NULL if there was none.
- * @param ignore_client Do not look for collisions with this
- * object. This can be useful to avoid self-hits if
- * starting from the location of an object.
- * @param from The start point, in world coordinates, of the search.
- * @param to The end point, in world coordinates, of the search.
- * @param result A store to return the point where intersection
- * took place (if there was an intersection).
- * @param normal A store to return the normal of the hit object on
- * the location of the intersection, if it took place.
- */
- SM_Object *rayTest(void *ignore_client,
- const MT_Point3& from, const MT_Point3& to,
- MT_Point3& result, MT_Vector3& normal) const;
-
-private:
-
- // Clear the user set velocities.
- void clearObjectCombinedVelocities();
- // This is the callback for handling collisions of dynamic objects
- static
- DT_Bool
- boing(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
- );
-
- /** internal type */
- typedef std::vector<SM_Object *> T_ObjectList;
-
- /** Handle to the scene in SOLID */
- DT_SceneHandle m_scene;
- /** Following response table contains the callbacks for the dynmics */
- DT_RespTableHandle m_respTable;
- DT_ResponseClass m_ResponseClass[NUM_RESPONSE];
- /**
- * Following response table contains callbacks for the client (=
- * game engine) */
- DT_RespTableHandle m_secondaryRespTable; // Handle
- DT_ResponseClass m_secondaryResponseClass[NUM_RESPONSE];
-
- /**
- * Following resposne table contains callbacks for fixing the simulation
- * ie making sure colliding objects do not intersect.
- */
- DT_RespTableHandle m_fixRespTable;
- DT_ResponseClass m_fixResponseClass[NUM_RESPONSE];
-
- /** The acceleration from the force field */
- MT_Vector3 m_forceField;
-
- /**
- * The list of objects that receive motion updates and do
- * collision tests. */
- T_ObjectList m_objectList;
-
- unsigned int m_frames;
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/sample/Makefile b/source/gameengine/Physics/Sumo/Fuzzics/sample/Makefile
deleted file mode 100644
index 672dff39028..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/sample/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# $Id$
-# Copyright (C) 2001 NaN Technologies B.V.
-
-DIR = $(OCGDIR)/sumo
-ALLTARGETS = $(OBJS) $(DIR)/$(DEBUG_DIR)particle $(DIR)/$(DEBUG_DIR)particle0
-
-include nan_compile.mk
-
-CPPFLAGS = -I../../include -I../include -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(OPENGL_HEADERS)
-
-clean::
- @$(RM) $(DIR)/particle $(DIR)/particle0
- @$(RM) $(DIR)/debug/particle $(DIR)/debug/particle0
-
-LDFLAGS = -L$(DIR) -L/usr/X11R6/lib
-OGL_LDLIBS = -lglut -lGLU -lGL -pthread
-LDLIBS = -lfuzzics -lsolid $(NAN_MOTO)/lib/libmoto.a $(OGL_LDLIBS)
-
-$(DIR)/$(DEBUG_DIR)particle: particle.o $(DIR)/$(DEBUG_DIR)libfuzzics.a $(DIR)/$(DEBUG_DIR)libsolid.a
- $(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
-
-$(DIR)/$(DEBUG_DIR)particle0: particle0.o $(DIR)/$(DEBUG_DIR)libfuzzics.a $(DIR)/$(DEBUG_DIR)libsolid.a
- $(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/sample/particle.cpp b/source/gameengine/Physics/Sumo/Fuzzics/sample/particle.cpp
deleted file mode 100644
index d7aca326b42..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/sample/particle.cpp
+++ /dev/null
@@ -1,709 +0,0 @@
-//#define FAKE_IT
-#define USE_COMPLEX
-#define QUADS
-
-#include <algorithm>
-#include <new>
-#include <GL/glut.h>
-
-#include "MT_MinMax.h"
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
-#include "MT_Quaternion.h"
-#include "MT_Matrix3x3.h"
-#include "MT_Transform.h"
-
-#include "SM_Object.h"
-#include "SM_FhObject.h"
-#include "SM_Scene.h"
-
-#include <SOLID/SOLID.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-const MT_Scalar bowl_curv = 0.10;
-const MT_Scalar timeStep = 0.02;
-const MT_Scalar ground_margin = 0.0;
-const MT_Scalar sphere_radius = 0.5;
-
-const MT_Vector3 gravity(0, -9.8, 0);
-
-static MT_Scalar DISTANCE = 5;
-
-static MT_Scalar ele = 0, azi = 0;
-static MT_Point3 eye(0, 0, DISTANCE);
-static MT_Point3 center(0, 0, 0);
-
-inline double irnd() { return 2 * MT_random() - 1; }
-
-static const double SCALE_BOTTOM = 0.5;
-static const double SCALE_FACTOR = 2.0;
-
-SM_ShapeProps g_shapeProps = {
- 1.0, // mass
- 1.0, // inertia
- 0.1, // linear drag
- 0.1, // angular drag
- { 1.0, 0.0, 0.0 }, // anisotropic friction
- false, // do anisotropic friction?
- true, // do fh?
- true // do rot fh?
-};
-
-SM_MaterialProps g_materialProps = {
- 0.7, // restitution
- 0.0, // friction
- 10.0, // Fh spring constant
- 1.0, // Fh damping
- 0.5, // Fh distance
- true // Fh leveling
-};
-
-
-void toggleIdle();
-
-
-void newRandom();
-
-void coordSystem() {
- glDisable(GL_LIGHTING);
- glBegin(GL_LINES);
- glColor3f(1, 0, 0);
- glVertex3d(0, 0, 0);
- glVertex3d(10, 0, 0);
- glColor3f(0, 1, 0);
- glVertex3d(0, 0, 0);
- glVertex3d(0, 10, 0);
- glColor3f(0, 0, 1);
- glVertex3d(0, 0, 0);
- glVertex3d(0, 0, 10);
- glEnd();
- glEnable(GL_LIGHTING);
-}
-
-
-void display_bbox(const MT_Point3& min, const MT_Point3& max) {
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glColor3f(0, 1, 1);
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- glBegin(GL_QUAD_STRIP);
- glVertex3d(min[0], min[1], min[2]);
- glVertex3d(min[0], min[1], max[2]);
- glVertex3d(max[0], min[1], min[2]);
- glVertex3d(max[0], min[1], max[2]);
- glVertex3d(max[0], max[1], min[2]);
- glVertex3d(max[0], max[1], max[2]);
- glVertex3d(min[0], max[1], min[2]);
- glVertex3d(min[0], max[1], max[2]);
- glVertex3d(min[0], min[1], min[2]);
- glVertex3d(min[0], min[1], max[2]);
- glEnd();
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
-}
-
-
-
-
-class GLShape {
-public:
- virtual void paint(GLdouble *m) const = 0;
-};
-
-
-class GLSphere : public GLShape {
- MT_Scalar radius;
-public:
- GLSphere(MT_Scalar r) : radius(r) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- glutSolidSphere(radius, 20, 20);
- glPopMatrix();
- }
-};
-
-
-class GLBox : public GLShape {
- MT_Vector3 extent;
-public:
- GLBox(MT_Scalar x, MT_Scalar y, MT_Scalar z) :
- extent(x, y, z) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- glPushMatrix();
- glScaled(extent[0], extent[1], extent[2]);
- glutSolidCube(1.0);
- glPopMatrix();
- glPopMatrix();
- }
-};
-
-
-class GLCone : public GLShape {
- MT_Scalar bottomRadius;
- MT_Scalar height;
- mutable GLuint displayList;
-
-public:
- GLCone(MT_Scalar r, MT_Scalar h) :
- bottomRadius(r),
- height(h),
- displayList(0) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- if (displayList) glCallList(displayList);
- else {
- GLUquadricObj *quadObj = gluNewQuadric();
- displayList = glGenLists(1);
- glNewList(displayList, GL_COMPILE_AND_EXECUTE);
- glPushMatrix();
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- glTranslatef(0.0, 0.0, -1.0);
- gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
- gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
- gluCylinder(quadObj, bottomRadius, 0, height, 15, 10);
- glPopMatrix();
- glEndList();
- }
- glPopMatrix();
- }
-};
-
-class GLCylinder : public GLShape {
- MT_Scalar radius;
- MT_Scalar height;
- mutable GLuint displayList;
-
-public:
- GLCylinder(MT_Scalar r, MT_Scalar h) :
- radius(r),
- height(h),
- displayList(0) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- if (displayList) glCallList(displayList);
- else {
- GLUquadricObj *quadObj = gluNewQuadric();
- displayList = glGenLists(1);
- glNewList(displayList, GL_COMPILE_AND_EXECUTE);
- glPushMatrix();
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- glTranslatef(0.0, 0.0, -1.0);
- gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
- gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
- gluCylinder(quadObj, radius, radius, height, 15, 10);
- glPopMatrix ();
- glEndList();
- }
- glPopMatrix();
- }
-};
-
-class Object;
-
-class Callback : public SM_Callback {
-public:
- Callback(Object& object) : m_object(object) {}
-
- virtual void do_me();
-
-private:
- Object& m_object;
-};
-
-
-class Object {
-public:
- Object(GLShape *gl_shape, SM_Object& object) :
- m_gl_shape(gl_shape),
- m_object(object),
- m_callback(*this)
- {
- m_object.registerCallback(m_callback);
- }
-
- ~Object() {}
-
- void paint() {
- if (m_gl_shape) {
- m_gl_shape->paint(m);
- // display_bbox(m_bbox.lower(), m_bbox.upper());
- }
- }
-
- void print_reaction_force() const {
- std::cout << m_object.getReactionForce() << std::endl;
- }
-
- MT_Vector3 getAhead() {
- return MT_Vector3(&m[4]);
- }
-
- MT_Vector3 getUp() {
- return MT_Vector3(&m[8]);
- }
-
- void clearMomentum() {
- m_object.clearMomentum();
- }
-
- void setMargin(MT_Scalar margin) {
- m_object.setMargin(margin);
- }
-
- void setScaling(const MT_Vector3& scaling) {
- m_object.setScaling(scaling);
- }
-
- const MT_Point3& getPosition() {
- return m_object.getPosition();
- }
-
- void setPosition(const MT_Point3& pos) {
- m_object.setPosition(pos);
- }
-
- void setOrientation(const MT_Quaternion& orn) {
- m_object.setOrientation(orn);
- }
-
- void applyCenterForce(const MT_Vector3& force) {
- m_object.applyCenterForce(force);
- }
-
- void applyTorque(const MT_Vector3& torque) {
- m_object.applyTorque(torque);
- }
-
- MT_Point3 getWorldCoord(const MT_Point3& local) const {
- return m_object.getWorldCoord(local);
- }
-
- MT_Vector3 getLinearVelocity() const {
- return m_object.getLinearVelocity();
- }
-
- MT_Vector3 getAngularVelocity() const {
- return m_object.getAngularVelocity();
- }
-
- void setMatrix() {
- m_object.calcXform();
- m_object.getMatrix(m);
- }
-
- const double *getMatrix() {
- m_object.calcXform();
- return m_object.getMatrix();
- }
-
-private:
- GLShape *m_gl_shape;
- SM_Object& m_object;
- DT_Scalar m[16];
- Callback m_callback;
-};
-
-
-
-const MT_Scalar SPACE_SIZE = 2;
-
-static GLSphere gl_sphere(sphere_radius);
-static GLBox gl_ground(50.0, 0.0, 50.0);
-
-
-
-#ifdef USE_COMPLEX
-
-const int GRID_SCALE = 10;
-const MT_Scalar GRID_UNIT = 25.0 / GRID_SCALE;
-
-DT_ShapeHandle createComplex() {
- DT_ShapeHandle shape = DT_NewComplexShape();
- for (int i0 = -GRID_SCALE; i0 != GRID_SCALE; ++i0) {
- for (int j0 = -GRID_SCALE; j0 != GRID_SCALE; ++j0) {
- int i1 = i0 + 1;
- int j1 = j0 + 1;
-#ifdef QUADS
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, bowl_curv * i0*i0, GRID_UNIT * j0);
- DT_Vertex(GRID_UNIT * i0, bowl_curv * i0*i0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, bowl_curv * i1*i1, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, bowl_curv * i1*i1, GRID_UNIT * j0);
- DT_End();
-#else
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j0);
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j1);
- DT_End();
-
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j0);
- DT_End();
-#endif
-
- }
- }
- DT_EndComplexShape();
- return shape;
-}
-
-
-static DT_ShapeHandle ground_shape = createComplex();
-
-#else
-
-static DT_ShapeHandle ground_shape = DT_Box(50, 0, 50);
-
-#endif
-
-static SM_Object sm_ground(ground_shape, &g_materialProps, 0, 0);
-static Object ground(&gl_ground, sm_ground);
-
-static SM_Object sm_sphere(DT_Sphere(0.0), &g_materialProps, &g_shapeProps, 0);
-static Object object(&gl_sphere, sm_sphere);
-
-
-static SM_Scene g_scene;
-
-
-bool g_hit = false;
-MT_Point3 g_spot;
-MT_Vector3 g_normal;
-
-
-void Callback::do_me()
-{
- m_object.setMatrix();
- m_object.print_reaction_force();
-}
-
-void myinit(void) {
-
- GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
- GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
- GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
-
- /* light_position is NOT default value */
- GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
- GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
-
- glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
- glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
-
- glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
- glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
-
-
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnable(GL_LIGHT1);
-
- glShadeModel(GL_SMOOTH);
-
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
-
- // glEnable(GL_CULL_FACE);
- // glCullFace(GL_BACK);
-
- ground.setPosition(MT_Point3(0, -10, 0));
- ground.setOrientation(MT_Quaternion(0, 0, 0, 1));
- ground.setMatrix();
- center.setValue(0.0, 0.0, 0.0);
- sm_ground.setMargin(ground_margin);
-
- g_scene.setForceField(gravity);
- g_scene.add(sm_ground);
-
- object.setMargin(sphere_radius);
-
- g_scene.add(sm_sphere);
-
-
- newRandom();
-}
-
-
-//MT_Point3 cp1, cp2;
-//bool intersection;
-
-void display(void) {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- ground.paint();
- object.paint();
-
- if (g_hit) {
- glDisable(GL_LIGHTING);
- glColor3f(1, 0, 0);
-
- glPointSize(5);
- glBegin(GL_POINTS);
- glVertex3d(g_spot[0], g_spot[1], g_spot[2]);
- glEnd();
- glPointSize(1);
-
- glColor3f(1, 1, 0);
- glBegin(GL_LINES);
- glVertex3d(g_spot[0], g_spot[1], g_spot[2]);
- glVertex3d(g_spot[0] + g_normal[0],
- g_spot[1] + g_normal[1],
- g_spot[2] + g_normal[2]);
- glEnd();
- glEnable(GL_LIGHTING);
- }
-
-
-
-#ifdef COLLISION
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glColor3f(1, 1, 0);
- if (intersection) {
- glPointSize(5);
- glBegin(GL_POINTS);
- glVertex3d(cp1[0], cp1[1], cp1[2]);
- glEnd();
- glPointSize(1);
- }
- else {
- glBegin(GL_LINES);
- glVertex3d(cp1[0], cp1[1], cp1[2]);
- glVertex3d(cp2[0], cp2[1], cp2[2]);
- glEnd();
- }
- glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
-#endif
-
- glFlush();
- glutSwapBuffers();
-}
-
-
-
-
-
-void newRandom() {
- object.setPosition(MT_Point3(0, 0, 0));
- object.setOrientation(MT_Quaternion::random());
- object.clearMomentum();
- object.setMatrix();
-
- display();
-}
-
-void moveAndDisplay() {
- g_scene.proceed(timeStep, 0.01);
-
- display();
- g_hit = false;
-}
-
-
-void turn_left() {
- object.applyTorque(5.0 * object.getUp());
-}
-
-void turn_right() {
- object.applyTorque(-5.0 * object.getUp());
-}
-
-void forward() {
- object.applyCenterForce(10.0 * object.getAhead());
-}
-
-void backward() {
- object.applyCenterForce(-10.0 * object.getAhead());
-}
-
-void jump() {
- object.applyCenterForce(MT_Vector3(0.0, 200.0, 0.0));
-}
-
-
-void toggleIdle() {
- static bool idle = true;
- if (idle) {
- glutIdleFunc(moveAndDisplay);
- idle = false;
- }
- else {
- glutIdleFunc(NULL);
- idle = true;
- }
-}
-
-
-void setCamera() {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 200.0);
- MT_Scalar rele = MT_radians(ele);
- MT_Scalar razi = MT_radians(azi);
- eye.setValue(DISTANCE * sin(razi) * cos(rele),
- DISTANCE * sin(rele),
- DISTANCE * cos(razi) * cos(rele));
- gluLookAt(eye[0], eye[1], eye[2],
- center[0], center[1], center[2],
- 0, 1, 0);
- glMatrixMode(GL_MODELVIEW);
- display();
-}
-
-const MT_Scalar STEPSIZE = 5;
-
-void stepLeft() { azi -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
-void stepRight() { azi += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
-void stepFront() { ele += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
-void stepBack() { ele -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
-void zoomIn() { DISTANCE -= 1; setCamera(); }
-void zoomOut() { DISTANCE += 1; setCamera(); }
-
-
-void myReshape(int w, int h) {
- glViewport(0, 0, w, h);
- setCamera();
-}
-
-void myKeyboard(unsigned char key, int x, int y)
-{
- switch (key)
- {
- case 'w': forward(); break;
- case 's': backward(); break;
- case 'a': turn_left(); break;
- case 'd': turn_right(); break;
- case 'e': jump(); break;
- case 'l' : stepLeft(); break;
- case 'r' : stepRight(); break;
- case 'f' : stepFront(); break;
- case 'b' : stepBack(); break;
- case 'z' : zoomIn(); break;
- case 'x' : zoomOut(); break;
- case 'i' : toggleIdle(); break;
- case ' ' : newRandom(); break;
- default:
-// std::cout << "unused key : " << key << std::endl;
- break;
- }
-}
-
-void mySpecial(int key, int x, int y)
-{
- switch (key)
- {
- case GLUT_KEY_LEFT : stepLeft(); break;
- case GLUT_KEY_RIGHT : stepRight(); break;
- case GLUT_KEY_UP : stepFront(); break;
- case GLUT_KEY_DOWN : stepBack(); break;
- case GLUT_KEY_PAGE_UP : zoomIn(); break;
- case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
- case GLUT_KEY_HOME : toggleIdle(); break;
- default:
-// std::cout << "unused (special) key : " << key << std::endl;
- break;
- }
-}
-
-void goodbye( void)
-{
- g_scene.remove(sm_ground);
- g_scene.remove(sm_sphere);
-
- std::cout << "goodbye ..." << std::endl;
- exit(0);
-}
-
-void menu(int choice)
-{
-
- static int fullScreen = 0;
- static int px, py, sx, sy;
-
- switch(choice) {
- case 1:
- if (fullScreen == 1) {
- glutPositionWindow(px,py);
- glutReshapeWindow(sx,sy);
- glutChangeToMenuEntry(1,"Full Screen",1);
- fullScreen = 0;
- } else {
- px=glutGet((GLenum)GLUT_WINDOW_X);
- py=glutGet((GLenum)GLUT_WINDOW_Y);
- sx=glutGet((GLenum)GLUT_WINDOW_WIDTH);
- sy=glutGet((GLenum)GLUT_WINDOW_HEIGHT);
- glutFullScreen();
- glutChangeToMenuEntry(1,"Close Full Screen",1);
- fullScreen = 1;
- }
- break;
- case 2:
- toggleIdle();
- break;
- case 3:
- goodbye();
- break;
- default:
- break;
- }
-}
-
-void createMenu()
-{
- glutCreateMenu(menu);
- glutAddMenuEntry("Full Screen", 1);
- glutAddMenuEntry("Toggle Idle (Start/Stop)", 2);
- glutAddMenuEntry("Quit", 3);
- glutAttachMenu(GLUT_RIGHT_BUTTON);
-}
-
-int main(int argc, char **argv) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(500, 500);
- glutCreateWindow("Physics demo");
-
- myinit();
- glutKeyboardFunc(myKeyboard);
- glutSpecialFunc(mySpecial);
- glutReshapeFunc(myReshape);
- createMenu();
- glutIdleFunc(NULL);
-
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
-}
-
-
-
-
-
-
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/sample/particle0.cpp b/source/gameengine/Physics/Sumo/Fuzzics/sample/particle0.cpp
deleted file mode 100644
index cdf0a2d8f64..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/sample/particle0.cpp
+++ /dev/null
@@ -1,695 +0,0 @@
-//#define FAKE_IT
-#define USE_COMPLEX
-#define QUADS
-
-#include <algorithm>
-#include <new>
-#include <GL/glut.h>
-
-#include "MT_MinMax.h"
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
-#include "MT_Quaternion.h"
-#include "MT_Matrix3x3.h"
-#include "MT_Transform.h"
-
-#include "SM_Object.h"
-#include "SM_Scene.h"
-
-#include "solid.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-const MT_Scalar bowl_curv = 0.10;
-const MT_Scalar timeStep = 0.04;
-const MT_Scalar ground_margin = 0.0;
-const MT_Scalar sphere_radius = 0.5;
-
-const MT_Vector3 gravity(0, -9.8, 0);
-
-static MT_Scalar DISTANCE = 5;
-
-static MT_Scalar ele = 0, azi = 0;
-static MT_Point3 eye(0, 0, DISTANCE);
-static MT_Point3 center(0, 0, 0);
-
-inline double irnd() { return 2 * MT_random() - 1; }
-
-static const double SCALE_BOTTOM = 0.5;
-static const double SCALE_FACTOR = 2.0;
-
-SM_ShapeProps g_shapeProps = {
- 1.0, // mass
- 1.0, // inertia
- 0.9, // linear drag
- 0.9 // angular drag
-};
-
-SM_MaterialProps g_materialProps = {
- 0.7, // restitution
- 0.0, // friction
- 0.0, // spring constant
- 0.0 // damping
-};
-
-
-void toggleIdle();
-
-
-void newRandom();
-
-void coordSystem() {
- glDisable(GL_LIGHTING);
- glBegin(GL_LINES);
- glColor3f(1, 0, 0);
- glVertex3d(0, 0, 0);
- glVertex3d(10, 0, 0);
- glColor3f(0, 1, 0);
- glVertex3d(0, 0, 0);
- glVertex3d(0, 10, 0);
- glColor3f(0, 0, 1);
- glVertex3d(0, 0, 0);
- glVertex3d(0, 0, 10);
- glEnd();
- glEnable(GL_LIGHTING);
-}
-
-
-void display_bbox(const MT_Point3& min, const MT_Point3& max) {
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glColor3f(0, 1, 1);
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- glBegin(GL_QUAD_STRIP);
- glVertex3d(min[0], min[1], min[2]);
- glVertex3d(min[0], min[1], max[2]);
- glVertex3d(max[0], min[1], min[2]);
- glVertex3d(max[0], min[1], max[2]);
- glVertex3d(max[0], max[1], min[2]);
- glVertex3d(max[0], max[1], max[2]);
- glVertex3d(min[0], max[1], min[2]);
- glVertex3d(min[0], max[1], max[2]);
- glVertex3d(min[0], min[1], min[2]);
- glVertex3d(min[0], min[1], max[2]);
- glEnd();
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
-}
-
-
-
-
-class GLShape {
-public:
- virtual void paint(GLdouble *m) const = 0;
-};
-
-
-class GLSphere : public GLShape {
- MT_Scalar radius;
-public:
- GLSphere(MT_Scalar r) : radius(r) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- glutSolidSphere(radius, 20, 20);
- glPopMatrix();
- }
-};
-
-
-class GLBox : public GLShape {
- MT_Vector3 extent;
-public:
- GLBox(MT_Scalar x, MT_Scalar y, MT_Scalar z) :
- extent(x, y, z) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- glPushMatrix();
- glScaled(extent[0], extent[1], extent[2]);
- glutSolidCube(1.0);
- glPopMatrix();
- glPopMatrix();
- }
-};
-
-
-class GLCone : public GLShape {
- MT_Scalar bottomRadius;
- MT_Scalar height;
- mutable GLuint displayList;
-
-public:
- GLCone(MT_Scalar r, MT_Scalar h) :
- bottomRadius(r),
- height(h),
- displayList(0) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- if (displayList) glCallList(displayList);
- else {
- GLUquadricObj *quadObj = gluNewQuadric();
- displayList = glGenLists(1);
- glNewList(displayList, GL_COMPILE_AND_EXECUTE);
- glPushMatrix();
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- glTranslatef(0.0, 0.0, -1.0);
- gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
- gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
- gluCylinder(quadObj, bottomRadius, 0, height, 15, 10);
- glPopMatrix();
- glEndList();
- }
- glPopMatrix();
- }
-};
-
-class GLCylinder : public GLShape {
- MT_Scalar radius;
- MT_Scalar height;
- mutable GLuint displayList;
-
-public:
- GLCylinder(MT_Scalar r, MT_Scalar h) :
- radius(r),
- height(h),
- displayList(0) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- if (displayList) glCallList(displayList);
- else {
- GLUquadricObj *quadObj = gluNewQuadric();
- displayList = glGenLists(1);
- glNewList(displayList, GL_COMPILE_AND_EXECUTE);
- glPushMatrix();
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- glTranslatef(0.0, 0.0, -1.0);
- gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
- gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
- gluCylinder(quadObj, radius, radius, height, 15, 10);
- glPopMatrix ();
- glEndList();
- }
- glPopMatrix();
- }
-};
-
-class Object;
-
-class Callback : public SM_Callback {
-public:
- Callback(Object& object) : m_object(object) {}
-
- virtual void do_me();
-
-private:
- Object& m_object;
-};
-
-
-class Object {
-public:
- Object(GLShape *gl_shape, SM_Object& object) :
- m_gl_shape(gl_shape),
- m_object(object),
- m_callback(*this)
- {
- m_object.registerCallback(m_callback);
- }
-
- ~Object() {}
-
- void paint() {
- m_gl_shape->paint(m);
- // display_bbox(m_bbox.lower(), m_bbox.upper());
- }
-
- MT_Vector3 getAhead() {
- return MT_Vector3(-m[8], -m[9], -m[10]);
- }
-
- void clearMomentum() {
- m_object.clearMomentum();
- }
-
- void setMargin(MT_Scalar margin) {
- m_object.setMargin(margin);
- }
-
- void setScaling(const MT_Vector3& scaling) {
- m_object.setScaling(scaling);
- }
-
- void setPosition(const MT_Point3& pos) {
- m_object.setPosition(pos);
- }
-
- void setOrientation(const MT_Quaternion& orn) {
- m_object.setOrientation(orn);
- }
-
- void applyCenterForce(const MT_Vector3& force) {
- m_object.applyCenterForce(force);
- }
-
- void applyTorque(const MT_Vector3& torque) {
- m_object.applyTorque(torque);
- }
-
- MT_Point3 getWorldCoord(const MT_Point3& local) const {
- return m_object.getWorldCoord(local);
- }
-
- MT_Vector3 getLinearVelocity() const {
- return m_object.getLinearVelocity();
- }
-
- void setMatrix() {
- m_object.getMatrix(m);
- }
-
-private:
- GLShape *m_gl_shape;
- SM_Object& m_object;
- DT_Scalar m[16];
- Callback m_callback;
-};
-
-
-void Callback::do_me()
-{
- m_object.setMatrix();
-}
-
-
-const MT_Scalar SPACE_SIZE = 2;
-
-static GLSphere gl_sphere(sphere_radius);
-static GLBox gl_ground(50.0, 0.0, 50.0);
-
-
-
-#ifdef USE_COMPLEX
-
-const int GRID_SCALE = 10;
-const MT_Scalar GRID_UNIT = 25.0 / GRID_SCALE;
-
-DT_ShapeHandle createComplex() {
- DT_ShapeHandle shape = DT_NewComplexShape();
- for (int i0 = -GRID_SCALE; i0 != GRID_SCALE; ++i0) {
- for (int j0 = -GRID_SCALE; j0 != GRID_SCALE; ++j0) {
- int i1 = i0 + 1;
- int j1 = j0 + 1;
-#ifdef QUADS
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, bowl_curv * i0*i0, GRID_UNIT * j0);
- DT_Vertex(GRID_UNIT * i0, bowl_curv * i0*i0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, bowl_curv * i1*i1, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, bowl_curv * i1*i1, GRID_UNIT * j0);
- DT_End();
-#else
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j0);
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j1);
- DT_End();
-
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j0);
- DT_End();
-#endif
-
- }
- }
- DT_EndComplexShape();
- return shape;
-}
-
-
-static DT_ShapeHandle ground_shape = createComplex();
-
-#else
-
-static DT_ShapeHandle ground_shape = DT_Box(50, 0, 50);
-
-#endif
-
-static SM_Object sm_ground(ground_shape, &g_materialProps, 0, 0);
-static Object ground(&gl_ground, sm_ground);
-
-static SM_Object sm_sphere(DT_Sphere(0.0), &g_materialProps, &g_shapeProps, 0);
-static Object object(&gl_sphere, sm_sphere);
-
-
-static SM_Object sm_ray(DT_Ray(0.0, -1.0, 0.0), 0, 0, 0);
-
-static SM_Scene g_scene;
-
-
-void myinit(void) {
-
- GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
- GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
- GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
-
- /* light_position is NOT default value */
- GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
- GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
-
- glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
- glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
-
- glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
- glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
-
-
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnable(GL_LIGHT1);
-
- glShadeModel(GL_SMOOTH);
-
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
-
- // glEnable(GL_CULL_FACE);
- // glCullFace(GL_BACK);
-
- g_scene.setForceField(gravity);
- g_scene.add(sm_ground);
- sm_ground.setMargin(ground_margin);
-
- new(&object) Object(&gl_sphere, sm_sphere);
-
-
- object.setMargin(sphere_radius);
-
- g_scene.add(sm_sphere);
-
- ground.setPosition(MT_Point3(0, -10, 0));
- ground.setOrientation(MT_Quaternion(0, 0, 0, 1));
- ground.setMatrix();
- center.setValue(0.0, 0.0, 0.0);
-
- newRandom();
-}
-
-
-//MT_Point3 cp1, cp2;
-//bool intersection;
-
-bool g_hit = false;
-MT_Point3 g_spot;
-MT_Vector3 g_normal;
-
-
-void display(void) {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- ground.paint();
- object.paint();
-
- if (g_hit) {
- glPointSize(5);
- glBegin(GL_POINTS);
- glVertex3d(g_spot[0], g_spot[1], g_spot[2]);
- glEnd();
- glPointSize(1);
- }
-
-
-
-#ifdef COLLISION
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glColor3f(1, 1, 0);
- if (intersection) {
- glPointSize(5);
- glBegin(GL_POINTS);
- glVertex3d(cp1[0], cp1[1], cp1[2]);
- glEnd();
- glPointSize(1);
- }
- else {
- glBegin(GL_LINES);
- glVertex3d(cp1[0], cp1[1], cp1[2]);
- glVertex3d(cp2[0], cp2[1], cp2[2]);
- glEnd();
- }
- glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
-#endif
-
- glFlush();
- glutSwapBuffers();
-}
-
-
-
-
-
-void newRandom() {
- object.setPosition(MT_Point3(0, 0, 0));
- object.clearMomentum();
- object.setMatrix();
-
- display();
-}
-
-void moveAndDisplay() {
- g_scene.proceed(timeStep, 0.01);
-
- MT_Vector3 normal(0, 1, 0);
-
- MT_Point3 from = object.getWorldCoord(MT_Point3(0, 0, 0));
- MT_Point3 to = from - normal * 10.0;
-
- g_hit = DT_ObjectRayTest(sm_ground.getObjectHandle(),
- from.getValue(),
- to.getValue(), g_spot.getValue(),
- g_normal.getValue());
-
- // Scrap
-#define DO_FH
-#ifdef DO_FH
- MT_Scalar dist = MT_distance(from, g_spot);
- if (dist < 5.0) {
- MT_Vector3 lin_vel = object.getLinearVelocity();
- MT_Scalar lin_vel_normal = lin_vel.dot(normal);
-
- MT_Scalar spring_extent = dist + lin_vel_normal * (timeStep * 0.5);
-
- MT_Scalar f_spring = (5.0 - spring_extent) * 3.0;
- object.applyCenterForce(normal * f_spring);
- object.applyCenterForce(-lin_vel_normal * normal);
- }
-
-#endif
-
-
- display();
-}
-
-
-void turn_left() {
- object.applyTorque(MT_Vector3(0.0, 10.0, 0.0));
-}
-
-void turn_right() {
- object.applyTorque(MT_Vector3(0.0, -10.0, 0.0));
-}
-
-void forward() {
- object.applyCenterForce(20.0 * object.getAhead());
-}
-
-void backward() {
- object.applyCenterForce(-20.0 * object.getAhead());
-}
-
-void jump() {
- object.applyCenterForce(MT_Vector3(0.0, 200.0, 0.0));
-}
-
-
-void toggleIdle() {
- static bool idle = true;
- if (idle) {
- glutIdleFunc(moveAndDisplay);
- idle = false;
- }
- else {
- glutIdleFunc(NULL);
- idle = true;
- }
-}
-
-
-void setCamera() {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 200.0);
- MT_Scalar rele = MT_radians(ele);
- MT_Scalar razi = MT_radians(azi);
- eye.setValue(DISTANCE * sin(razi) * cos(rele),
- DISTANCE * sin(rele),
- DISTANCE * cos(razi) * cos(rele));
- gluLookAt(eye[0], eye[1], eye[2],
- center[0], center[1], center[2],
- 0, 1, 0);
- glMatrixMode(GL_MODELVIEW);
- display();
-}
-
-const MT_Scalar STEPSIZE = 5;
-
-void stepLeft() { azi -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
-void stepRight() { azi += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
-void stepFront() { ele += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
-void stepBack() { ele -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
-void zoomIn() { DISTANCE -= 1; setCamera(); }
-void zoomOut() { DISTANCE += 1; setCamera(); }
-
-
-void myReshape(int w, int h) {
- glViewport(0, 0, w, h);
- setCamera();
-}
-
-void myKeyboard(unsigned char key, int x, int y)
-{
- switch (key)
- {
- case 'w': forward(); break;
- case 's': backward(); break;
- case 'a': turn_left(); break;
- case 'd': turn_right(); break;
- case 'e': jump(); break;
- case 'l' : stepLeft(); break;
- case 'r' : stepRight(); break;
- case 'f' : stepFront(); break;
- case 'b' : stepBack(); break;
- case 'z' : zoomIn(); break;
- case 'x' : zoomOut(); break;
- case 'i' : toggleIdle(); break;
- case ' ' : newRandom(); break;
- default:
-// std::cout << "unused key : " << key << std::endl;
- break;
- }
-}
-
-void mySpecial(int key, int x, int y)
-{
- switch (key)
- {
- case GLUT_KEY_LEFT : stepLeft(); break;
- case GLUT_KEY_RIGHT : stepRight(); break;
- case GLUT_KEY_UP : stepFront(); break;
- case GLUT_KEY_DOWN : stepBack(); break;
- case GLUT_KEY_PAGE_UP : zoomIn(); break;
- case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
- case GLUT_KEY_HOME : toggleIdle(); break;
- default:
-// std::cout << "unused (special) key : " << key << std::endl;
- break;
- }
-}
-
-void goodbye( void)
-{
- g_scene.remove(sm_ground);
- g_scene.remove(sm_sphere);
-
- std::cout << "goodbye ..." << std::endl;
- exit(0);
-}
-
-void menu(int choice)
-{
-
- static int fullScreen = 0;
- static int px, py, sx, sy;
-
- switch(choice) {
- case 1:
- if (fullScreen == 1) {
- glutPositionWindow(px,py);
- glutReshapeWindow(sx,sy);
- glutChangeToMenuEntry(1,"Full Screen",1);
- fullScreen = 0;
- } else {
- px=glutGet((GLenum)GLUT_WINDOW_X);
- py=glutGet((GLenum)GLUT_WINDOW_Y);
- sx=glutGet((GLenum)GLUT_WINDOW_WIDTH);
- sy=glutGet((GLenum)GLUT_WINDOW_HEIGHT);
- glutFullScreen();
- glutChangeToMenuEntry(1,"Close Full Screen",1);
- fullScreen = 1;
- }
- break;
- case 2:
- toggleIdle();
- break;
- case 3:
- goodbye();
- break;
- default:
- break;
- }
-}
-
-void createMenu()
-{
- glutCreateMenu(menu);
- glutAddMenuEntry("Full Screen", 1);
- glutAddMenuEntry("Toggle Idle (Start/Stop)", 2);
- glutAddMenuEntry("Quit", 3);
- glutAttachMenu(GLUT_RIGHT_BUTTON);
-}
-
-int main(int argc, char **argv) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(500, 500);
- glutCreateWindow("Physics demo");
-
- myinit();
- glutKeyboardFunc(myKeyboard);
- glutSpecialFunc(mySpecial);
- glutReshapeFunc(myReshape);
- createMenu();
- glutIdleFunc(NULL);
-
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
-}
-
-
-
-
-
-
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/Makefile b/source/gameengine/Physics/Sumo/Fuzzics/src/Makefile
deleted file mode 100644
index b2744c5496a..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# $Id$
-# Copyright (C) 2001 NaN Technologies B.V.
-
-LIBNAME = fuzzics
-DIR = $(OCGDIR)/gameengine/blphys/$(LIBNAME)
-
-include nan_compile.mk
-
-CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
-
-CPPFLAGS += -I../include -I$(NAN_MOTO)/include -I../../include
-CPPFLAGS += -I$(NAN_SOLID)/include
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp
deleted file mode 100644
index d866cdb4922..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include "SM_FhObject.h"
-#include "MT_MinMax.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-SM_FhObject::SM_FhObject(DT_ShapeHandle rayshape, MT_Vector3 ray, SM_Object *parent_object) :
- SM_Object(rayshape, NULL, NULL, NULL),
- m_ray(ray),
- m_ray_direction(ray.normalized()),
- m_parent_object(parent_object)
-{
-}
-
-SM_FhObject::~SM_FhObject()
-{
- DT_DeleteShape(getShapeHandle());
-}
-
-DT_Bool SM_FhObject::ray_hit(void *client_data,
- void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data)
-{
-
- SM_FhObject *fh_object = dynamic_cast<SM_FhObject *>((SM_Object *)client_object2);
- if (!fh_object)
- {
- std::swap(client_object1, client_object2);
- fh_object = dynamic_cast<SM_FhObject *>((SM_Object *)client_object2);
- }
-
- SM_Object *hit_object = (SM_Object *)client_object1;
- const SM_MaterialProps *matProps = hit_object->getMaterialProps();
-
- if ((matProps == 0) || (matProps->m_fh_distance < MT_EPSILON)) {
- return DT_CONTINUE;
- }
-
- SM_Object *cl_object = fh_object->getParentObject();
-
- assert(fh_object);
-
- if (hit_object == cl_object) {
- // Shot myself in the foot...
- return DT_CONTINUE;
- }
-
- const SM_ShapeProps *shapeProps = cl_object->getShapeProps();
-
- // Exit if the client object is not dynamic.
- if (shapeProps == 0) {
- return DT_CONTINUE;
- }
-
- MT_Point3 lspot;
- MT_Vector3 normal;
-
- DT_Vector3 from, to, dnormal;
- DT_Scalar dlspot;
- fh_object->getPosition().getValue(from);
- fh_object->getSpot().getValue(to);
-
-
- if (DT_ObjectRayCast(hit_object->getObjectHandle(),
- from,
- to,
- 1.,
- &dlspot,
- dnormal)) {
-
- lspot = fh_object->getPosition() + (fh_object->getSpot() - fh_object->getPosition()) * dlspot;
- const MT_Vector3& ray_dir = fh_object->getRayDirection();
- MT_Scalar dist = MT_distance(fh_object->getPosition(), lspot) -
- cl_object->getMargin() - shapeProps->m_radius;
-
- normal = MT_Vector3(dnormal).safe_normalized();
-
- if (dist < matProps->m_fh_distance) {
-
- if (shapeProps->m_do_fh) {
- lspot -= hit_object->getPosition();
- MT_Vector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocity(lspot);
- MT_Scalar rel_vel_ray = ray_dir.dot(rel_vel);
- MT_Scalar spring_extent = 1.0 - dist / matProps->m_fh_distance;
-
- MT_Scalar i_spring = spring_extent * matProps->m_fh_spring;
- MT_Scalar i_damp = rel_vel_ray * matProps->m_fh_damping;
-
- cl_object->addLinearVelocity(-(i_spring + i_damp) * ray_dir);
- if (matProps->m_fh_normal) {
- cl_object->addLinearVelocity(
- (i_spring + i_damp) *
- (normal - normal.dot(ray_dir) * ray_dir));
- }
-
- MT_Vector3 lateral = rel_vel - rel_vel_ray * ray_dir;
- const SM_ShapeProps *shapeProps = cl_object->getShapeProps();
-
- if (shapeProps->m_do_anisotropic) {
- MT_Matrix3x3 lcs(cl_object->getOrientation());
- MT_Vector3 loc_lateral = lateral * lcs;
- const MT_Vector3& friction_scaling =
- shapeProps->m_friction_scaling;
-
- loc_lateral.scale(friction_scaling[0],
- friction_scaling[1],
- friction_scaling[2]);
- lateral = lcs * loc_lateral;
- }
-
-
- MT_Scalar rel_vel_lateral = lateral.length();
-
- if (rel_vel_lateral > MT_EPSILON) {
- MT_Scalar friction_factor = matProps->m_friction;
- MT_Scalar max_friction = friction_factor * MT_max(MT_Scalar(0.0), i_spring);
-
- MT_Scalar rel_mom_lateral = rel_vel_lateral /
- cl_object->getInvMass();
-
- MT_Vector3 friction =
- (rel_mom_lateral > max_friction) ?
- -lateral * (max_friction / rel_vel_lateral) :
- -lateral;
-
- cl_object->applyCenterImpulse(friction);
- }
- }
-
- if (shapeProps->m_do_rot_fh) {
- const double *ogl_mat = cl_object->getMatrix();
- MT_Vector3 up(&ogl_mat[8]);
- MT_Vector3 t_spring = up.cross(normal) * matProps->m_fh_spring;
- MT_Vector3 ang_vel = cl_object->getAngularVelocity();
-
- // only rotations that tilt relative to the normal are damped
- ang_vel -= ang_vel.dot(normal) * normal;
-
- MT_Vector3 t_damp = ang_vel * matProps->m_fh_damping;
-
- cl_object->addAngularVelocity(t_spring - t_damp);
- }
- }
- }
-
- return DT_CONTINUE;
-}
-
-
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp
deleted file mode 100644
index b8f4e0c591c..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include <MT_Scalar.h>
-#include <MT_Vector3.h>
-#include <MT_Quaternion.h>
-
-#include "SM_MotionState.h"
-
-void SM_MotionState::integrateMidpoint(MT_Scalar timeStep, const SM_MotionState &prev_state, const MT_Vector3 &velocity, const MT_Quaternion& ang_vel)
-{
- m_pos += (prev_state.getLinearVelocity() + velocity) * (timeStep * 0.5);
- m_orn += (prev_state.getAngularVelocity() * prev_state.getOrientation() + ang_vel * m_orn) * (timeStep * 0.25);
- m_orn.normalize();
-}
-
-void SM_MotionState::integrateBackward(MT_Scalar timeStep, const MT_Vector3 &velocity, const MT_Quaternion& ang_vel)
-{
- m_pos += velocity * timeStep;
- m_orn += ang_vel * m_orn * (timeStep * 0.5);
- m_orn.normalize();
-}
-
-void SM_MotionState::integrateForward(MT_Scalar timeStep, const SM_MotionState &prev_state)
-{
- m_pos += prev_state.getLinearVelocity() * timeStep;
- m_orn += prev_state.getAngularVelocity() * m_orn * (timeStep * 0.5);
- m_orn.normalize();
-}
-
-/*
-// Newtonian lerp: interpolate based on Newtonian motion
-void SM_MotionState::nlerp(const SM_MotionState &prev, const SM_MotionState &next)
-{
- MT_Scalar dt = next.getTime() - prev.getTime();
- MT_Scalar t = getTime() - prev.getTime();
- MT_Vector3 dx = next.getPosition() - prev.getPosition();
- MT_Vector3 a = dx/(dt*dt) - prev.getLinearVelocity()/dt;
-
- m_pos = prev.getPosition() + prev.getLinearVelocity()*t + a*t*t;
-}
-*/
-
-void SM_MotionState::lerp(const SM_MotionState &prev, const SM_MotionState &next)
-{
- MT_Scalar dt = next.getTime() - prev.getTime();
- if (MT_fuzzyZero(dt))
- {
- *this = next;
- return;
- }
-
- MT_Scalar x = (getTime() - prev.getTime())/dt;
-
- m_pos = x*next.getPosition() + (1-x)*prev.getPosition();
-
- m_orn = prev.getOrientation().slerp(next.getOrientation(), 1-x);
-
- m_lin_vel = x*next.getLinearVelocity() + (1-x)*prev.getLinearVelocity();
- m_ang_vel = x*next.getAngularVelocity() + (1-x)*prev.getAngularVelocity();
-}
-
-void SM_MotionState::lerp(MT_Scalar t, const SM_MotionState &other)
-{
- MT_Scalar x = (t - getTime())/(other.getTime() - getTime());
- m_pos = (1-x)*m_pos + x*other.getPosition();
-
- m_orn = other.getOrientation().slerp(m_orn, x);
-
- m_lin_vel = (1-x)*m_lin_vel + x*other.getLinearVelocity();
- m_ang_vel = (1-x)*m_ang_vel + x*other.getAngularVelocity();
-
- m_time = t;
-}
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
deleted file mode 100644
index 4b2c7cae008..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
+++ /dev/null
@@ -1,1298 +0,0 @@
-/**
- * $Id$
- * Copyright (C) 2001 NaN Technologies B.V.
- * The basic physics object.
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WIN32
-// This warning tells us about truncation of __long__ stl-generated names.
-// It can occasionally cause DevStudio to have internal compiler warnings.
-#pragma warning( disable : 4786 )
-#endif
-
-#include "MT_assert.h"
-
-#include "SM_Object.h"
-#include "SM_Scene.h"
-#include "SM_FhObject.h"
-#include "SM_Debug.h"
-
-#include "MT_MinMax.h"
-
-MT_Scalar SM_Object::ImpulseThreshold = -1.0;
-
-struct Contact
-{
- SM_Object *obj1;
- SM_Object *obj2;
- MT_Vector3 normal;
- MT_Point3 pos;
-
- // Sort objects by height
- bool operator()(const Contact *a, const Contact *b)
- {
- return a->pos[2] < b->pos[2];
- }
-
- Contact(SM_Object *o1, SM_Object *o2, const MT_Vector3 nor, const MT_Point3 p)
- : obj1(o1),
- obj2(o2),
- normal(nor),
- pos(p)
- {
- }
-
- Contact()
- {
- }
-
- void resolve()
- {
- if (obj1->m_static || obj2->m_static)
- {
- if (obj1->isDynamic())
- {
- if (obj1->m_static && obj2->m_static)
- {
- if (obj1->m_static < obj2->m_static)
- {
- obj2->m_error -= normal;
- obj2->m_static = obj1->m_static + 1;
- }
- else
- {
- obj1->m_error += normal;
- obj1->m_static = obj2->m_static + 1;
- }
- }
- else
- {
- if (obj1->m_static)
- {
- obj2->m_error -= normal;
- obj2->m_static = obj1->m_static + 1;
- }
- else
- {
- obj1->m_error += normal;
- obj1->m_static = obj2->m_static + 1;
- }
- }
- }
- else
- {
- obj2->m_error -= normal;
- obj2->m_static = 1;
- }
- }
- else
- {
- // This distinction between dynamic and non-dynamic objects should not be
- // necessary. Non-dynamic objects are assumed to have infinite mass.
- if (obj1->isDynamic()) {
- MT_Vector3 error = normal * 0.5f;
- obj1->m_error += error;
- obj2->m_error -= error;
- }
- else {
- // Same again but now obj1 is non-dynamic
- obj2->m_error -= normal;
- obj2->m_static = obj1->m_static + 1;
- }
- }
-
- }
-
-
- typedef std::set<Contact*, Contact> Set;
-};
-
-static Contact::Set contacts;
-
-SM_Object::SM_Object(
- DT_ShapeHandle shape,
- const SM_MaterialProps *materialProps,
- const SM_ShapeProps *shapeProps,
- SM_Object *dynamicParent) :
-
- m_dynamicParent(dynamicParent),
- m_client_object(0),
- m_physicsClientObject(0),
- m_shape(shape),
- m_materialProps(materialProps),
- m_materialPropsBackup(0),
- m_shapeProps(shapeProps),
- m_shapePropsBackup(0),
- m_margin(0.0),
- m_scaling(1.0, 1.0, 1.0),
- m_reaction_impulse(0.0, 0.0, 0.0),
- m_reaction_force(0.0, 0.0, 0.0),
- m_lin_mom(0.0, 0.0, 0.0),
- m_ang_mom(0.0, 0.0, 0.0),
- m_force(0.0, 0.0, 0.0),
- m_torque(0.0, 0.0, 0.0),
- m_error(0.0, 0.0, 0.0),
- m_combined_lin_vel (0.0, 0.0, 0.0),
- m_combined_ang_vel (0.0, 0.0, 0.0),
- m_fh_object(0),
- m_inv_mass(0.0),
- m_inv_inertia(0., 0., 0.),
- m_kinematic(false),
- m_prev_kinematic(false),
- m_is_rigid_body(false),
- m_static(0)
-{
- m_object = DT_CreateObject(this, shape);
- m_xform.setIdentity();
- m_xform.getValue(m_ogl_matrix);
- if (shapeProps)
- {
- if (shapeProps->m_do_fh || shapeProps->m_do_rot_fh)
- {
- DT_Vector3 zero = {0., 0., 0.}, ray = {0.0, 0.0, -10.0};
- m_fh_object = new SM_FhObject(DT_NewLineSegment(zero, ray), MT_Vector3(ray), this);
- //printf("SM_Object:: WARNING! fh disabled.\n");
- }
- m_inv_mass = 1. / shapeProps->m_mass;
- m_inv_inertia = MT_Vector3(1./shapeProps->m_inertia[0], 1./shapeProps->m_inertia[1], 1./shapeProps->m_inertia[2]);
- }
- updateInvInertiaTensor();
- m_suspended = false;
-}
-
-
- void
-SM_Object::
-integrateForces(
- MT_Scalar timeStep
-){
- if (!m_suspended) {
- m_prev_state = getNextFrame();
- m_prev_state.setLinearVelocity(actualLinVelocity());
- m_prev_state.setAngularVelocity(actualAngVelocity());
- if (isDynamic()) {
- // Integrate momentum (forward Euler)
- m_lin_mom += m_force * timeStep;
- m_ang_mom += m_torque * timeStep;
- // Drain momentum because of air/water resistance
- m_lin_mom *= pow(m_shapeProps->m_lin_drag, timeStep);
- m_ang_mom *= pow(m_shapeProps->m_ang_drag, timeStep);
- // Set velocities according momentum
- getNextFrame().setLinearVelocity(m_lin_mom * m_inv_mass);
- getNextFrame().setAngularVelocity(m_inv_inertia_tensor * m_ang_mom);
- }
- }
-
-};
-
- void
-SM_Object::
-integrateMomentum(
- MT_Scalar timeStep
-){
- // Integrate position and orientation
-
- // only do it for objects with linear and/or angular velocity
- // else clients with hierarchies may get into trouble
- if (!actualLinVelocity().fuzzyZero() || !actualAngVelocity().fuzzyZero())
- {
-
- // those MIDPOINT and BACKWARD integration methods are
- // in this form not ok with some testfiles !
- // For a release build please use forward euler unless completely tested
-
-//#define MIDPOINT
-//#define BACKWARD
-#ifdef MIDPOINT
-// Midpoint rule
- getNextFrame().integrateMidpoint(timeStep, m_prev_state, actualLinVelocity(), actualAngVelocity());
-#elif defined BACKWARD
-// Backward Euler
- getNextFrame().integrateBackward(timeStep, actualLinVelocity(), actualAngVelocity());
-#else
-// Forward Euler
- getNextFrame().integrateForward(timeStep, m_prev_state);
-#endif
-
- calcXform();
- notifyClient();
-
- }
-}
-
-/**
- * dynamicCollision computes the response to a collision.
- *
- * @param local2 the contact point in local coordinates.
- * @param normal the contact normal.
- * @param dist the penetration depth of the contact. (unused)
- * @param rel_vel the relative velocity of the objects
- * @param restitution the amount of momentum conserved in the collision. Range: 0.0 - 1.0
- * @param friction_factor the amount of friction between the two surfaces.
- * @param invMass the inverse mass of the collision objects (1.0 / mass)
- */
-void SM_Object::dynamicCollision(const MT_Point3 &local2,
- const MT_Vector3 &normal,
- MT_Scalar dist,
- const MT_Vector3 &rel_vel,
- MT_Scalar restitution,
- MT_Scalar friction_factor,
- MT_Scalar invMass
-)
-{
- /**
- * rel_vel_normal is the relative velocity in the contact normal direction.
- */
- MT_Scalar rel_vel_normal = normal.dot(rel_vel);
-
- /**
- * if rel_vel_normal > 0, the objects are moving apart!
- */
- if (rel_vel_normal < -MT_EPSILON) {
- /**
- * if rel_vel_normal < ImpulseThreshold, scale the restitution down.
- * This should improve the simulation where the object is stacked.
- */
- restitution *= MT_min(MT_Scalar(1.0), rel_vel_normal/ImpulseThreshold);
-
- MT_Scalar impulse = -(1.0 + restitution) * rel_vel_normal;
-
- if (isRigidBody())
- {
- MT_Vector3 temp = getInvInertiaTensor() * local2.cross(normal);
- impulse /= invMass + normal.dot(temp.cross(local2));
-
- /**
- * Apply impulse at the collision point.
- * Take rotational inertia into account.
- */
- applyImpulse(local2 + getNextFrame().getPosition(), impulse * normal);
- } else {
- /**
- * Apply impulse through object center. (no rotation.)
- */
- impulse /= invMass;
- applyCenterImpulse( impulse * normal );
- }
-
- MT_Vector3 external = m_combined_lin_vel + m_combined_ang_vel.cross(local2);
- MT_Vector3 lateral = rel_vel - external - normal * (rel_vel_normal - external.dot(normal));
-#if 0
- // test - only do friction on the physics part of the
- // velocity.
- vel1 -= obj1->m_combined_lin_vel;
- vel2 -= obj2->m_combined_lin_vel;
-
- // This should look familiar....
- rel_vel = vel2 - vel1;
- rel_vel_normal = normal.dot(rel_vel);
-#endif
- /**
- * The friction part starts here!!!!!!!!
- *
- * Compute the lateral component of the relative velocity
- * lateral actually points in the opposite direction, i.e.,
- * into the direction of the friction force.
- */
- if (m_shapeProps->m_do_anisotropic) {
-
- /**
- * For anisotropic friction we scale the lateral component,
- * rather than compute a direction-dependent fricition
- * factor. For this the lateral component is transformed to
- * local coordinates.
- */
-
- MT_Matrix3x3 lcs(getNextFrame().getOrientation());
-
- /**
- * We cannot use m_xform.getBasis() for the matrix, since
- * it might contain a non-uniform scaling.
- * OPT: it's a bit daft to compute the matrix since the
- * quaternion itself can be used to do the transformation.
- */
- MT_Vector3 loc_lateral = lateral * lcs;
-
- /**
- * lcs is orthogonal so lcs.inversed() == lcs.transposed(),
- * and lcs.transposed() * lateral == lateral * lcs.
- */
- const MT_Vector3& friction_scaling =
- m_shapeProps->m_friction_scaling;
-
- // Scale the local lateral...
- loc_lateral.scale(friction_scaling[0],
- friction_scaling[1],
- friction_scaling[2]);
- // ... and transform it back to global coordinates
- lateral = lcs * loc_lateral;
- }
-
- /**
- * A tiny Coulomb friction primer:
- * The Coulomb friction law states that the magnitude of the
- * maximum possible friction force depends linearly on the
- * magnitude of the normal force.
- *
- * \f[
- F_max_friction = friction_factor * F_normal
- \f]
- *
- * (NB: independent of the contact area!!)
- *
- * The friction factor depends on the material.
- * We use impulses rather than forces but let us not be
- * bothered by this.
- */
- MT_Scalar rel_vel_lateral = lateral.length();
-
- if (rel_vel_lateral > MT_EPSILON) {
- lateral /= rel_vel_lateral;
-
- // Compute the maximum friction impulse
- MT_Scalar max_friction =
- friction_factor * MT_max(MT_Scalar(0.0), impulse);
-
- // I guess the GEN_max is not necessary, so let's check it
-
- MT_assert(impulse >= 0.0);
-
- /**
- * Here's the trick. We compute the impulse to make the
- * lateral velocity zero. (Make the objects stick together
- * at the contact point. If this impulse is larger than
- * the maximum possible friction impulse, then shrink its
- * magnitude to the maximum friction.
- */
-
- if (isRigidBody()) {
-
- /**
- * For rigid bodies we take the inertia into account,
- * since the friction impulse is going to change the
- * angular momentum as well.
- */
- MT_Vector3 temp = getInvInertiaTensor() * local2.cross(lateral);
- MT_Scalar impulse_lateral = rel_vel_lateral /
- (invMass + lateral.dot(temp.cross(local2)));
-
- MT_Scalar friction = MT_min(impulse_lateral, max_friction);
- applyImpulse(local2 + getNextFrame().getPosition(), -lateral * friction);
- }
- else {
- MT_Scalar impulse_lateral = rel_vel_lateral / invMass;
-
- MT_Scalar friction = MT_min(impulse_lateral, max_friction);
- applyCenterImpulse( -friction * lateral);
- }
-
-
- }
-
- //calcXform();
- //notifyClient();
-
- }
-}
-
-static void AddCallback(SM_Scene *scene, SM_Object *obj1, SM_Object *obj2)
-{
- // If we have callbacks on either of the client objects, do a collision test
- // and add a callback if they intersect.
- DT_Vector3 v;
- if ((obj1->getClientObject() && obj1->getClientObject()->hasCollisionCallback()) ||
- (obj2->getClientObject() && obj2->getClientObject()->hasCollisionCallback()) &&
- DT_GetIntersect(obj1->getObjectHandle(), obj2->getObjectHandle(), v))
- scene->notifyCollision(obj1, obj2);
-}
-
-DT_Bool SM_Object::boing(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
-){
- SM_Scene *scene = (SM_Scene *)client_data;
- SM_Object *obj1 = (SM_Object *)object1;
- SM_Object *obj2 = (SM_Object *)object2;
-
- // at this point it is unknown whether we are really intersecting (broad phase)
-
- DT_Vector3 p1, p2;
- if (!obj2->isDynamic()) {
- std::swap(obj1, obj2);
- }
-
- // If one of the objects is a ghost then ignore it for the dynamics
- if (obj1->isGhost() || obj2->isGhost()) {
- AddCallback(scene, obj1, obj2);
- return DT_CONTINUE;
- }
-
- // Objects do not collide with parent objects
- if (obj1->getDynamicParent() == obj2 || obj2->getDynamicParent() == obj1) {
- AddCallback(scene, obj1, obj2);
- return DT_CONTINUE;
- }
-
- if (!obj2->isDynamic()) {
- AddCallback(scene, obj1, obj2);
- return DT_CONTINUE;
- }
-
- // Get collision data from SOLID
- if (!DT_GetPenDepth(obj1->getObjectHandle(), obj2->getObjectHandle(), p1, p2))
- return DT_CONTINUE;
-
- MT_Point3 local1(p1), local2(p2);
- MT_Vector3 normal(local2 - local1);
- MT_Scalar dist = normal.length();
-
- if (dist < MT_EPSILON)
- return DT_CONTINUE;
-
- // Now we are definitely intersecting.
-
- // Set callbacks for game engine.
- if ((obj1->getClientObject() && obj1->getClientObject()->hasCollisionCallback()) ||
- (obj2->getClientObject() && obj2->getClientObject()->hasCollisionCallback()))
- scene->notifyCollision(obj1, obj2);
-
- local1 -= obj1->getNextFrame().getPosition();
- local2 -= obj2->getNextFrame().getPosition();
-
- // Calculate collision parameters
- MT_Vector3 rel_vel = obj1->getVelocity(local1) - obj2->getVelocity(local2);
-
- MT_Scalar restitution =
- MT_min(obj1->getMaterialProps()->m_restitution,
- obj2->getMaterialProps()->m_restitution);
-
- MT_Scalar friction_factor =
- MT_min(obj1->getMaterialProps()->m_friction,
- obj2->getMaterialProps()->m_friction);
-
- MT_Scalar invMass = obj1->getInvMass() + obj2->getInvMass();
-
- normal /= dist;
-
- // Calculate reactions
- if (obj1->isDynamic())
- obj1->dynamicCollision(local1, normal, dist, rel_vel, restitution, friction_factor, invMass);
-
- if (obj2->isDynamic())
- {
- obj2->dynamicCollision(local2, -normal, dist, -rel_vel, restitution, friction_factor, invMass);
- if (!obj1->isDynamic() || obj1->m_static)
- obj2->m_static = obj1->m_static + 1;
- }
-
- return DT_CONTINUE;
-}
-
-DT_Bool SM_Object::fix(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
-){
- SM_Object *obj1 = (SM_Object *)object1;
- SM_Object *obj2 = (SM_Object *)object2;
-
- // If one of the objects is a ghost then ignore it for the dynamics
- if (obj1->isGhost() || obj2->isGhost()) {
- return DT_CONTINUE;
- }
-
- if (obj1->getDynamicParent() == obj2 || obj2->getDynamicParent() == obj1) {
- return DT_CONTINUE;
- }
-
- if (!obj2->isDynamic()) {
- std::swap(obj1, obj2);
- }
-
- if (!obj2->isDynamic()) {
- return DT_CONTINUE;
- }
-
- // obj1 points to a dynamic object
- DT_Vector3 p1, p2;
- if (!DT_GetPenDepth(obj1->getObjectHandle(), obj2->getObjectHandle(), p1, p2))
- return DT_CONTINUE;
- MT_Point3 local1(p1), local2(p2);
- // Get collision data from SOLID
- MT_Vector3 normal(local2 - local1);
-
- MT_Scalar dist = normal.dot(normal);
- if (dist < MT_EPSILON || dist > obj2->m_shapeProps->m_radius*obj2->m_shapeProps->m_radius)
- return DT_CONTINUE;
-
-
- if ((obj1->m_static || !obj1->isDynamic()) && obj1->m_static < obj2->m_static)
- {
- obj2->m_static = obj1->m_static + 1;
- } else if (obj2->m_static && obj2->m_static < obj1->m_static)
- {
- obj1->m_static = obj2->m_static + 1;
- }
-
- contacts.insert(new Contact(obj1, obj2, normal, MT_Point3(local1 + 0.5*(local2 - local1))));
-
-
- return DT_CONTINUE;
-}
-
-void SM_Object::relax(void)
-{
- for (Contact::Set::iterator csit = contacts.begin() ; csit != contacts.end(); ++csit)
- {
- (*csit)->resolve();
- delete (*csit);
- }
-
- contacts.clear();
- if (m_error.fuzzyZero())
- return;
- //std::cout << "SM_Object::relax: { " << m_error << " }" << std::endl;
-
- getNextFrame().setPosition(getNextFrame().getPosition() + m_error);
- m_error.setValue(0., 0., 0.);
- //calcXform();
- //notifyClient();
-}
-
-SM_Object::SM_Object() :
- m_dynamicParent(0),
- m_client_object(0),
- m_physicsClientObject(0),
- m_shape(0),
- m_materialProps(0),
- m_materialPropsBackup(0),
- m_shapeProps(0),
- m_shapePropsBackup(0),
- m_object(0),
- m_margin(0.0),
- m_scaling(1.0, 1.0, 1.0),
- m_reaction_impulse(0.0, 0.0, 0.0),
- m_reaction_force(0.0, 0.0, 0.0),
- m_lin_mom(0.0, 0.0, 0.0),
- m_ang_mom(0.0, 0.0, 0.0),
- m_force(0.0, 0.0, 0.0),
- m_torque(0.0, 0.0, 0.0),
- m_error(0.0, 0.0, 0.0),
- m_combined_lin_vel (0.0, 0.0, 0.0),
- m_combined_ang_vel (0.0, 0.0, 0.0),
- m_fh_object(0),
- m_kinematic(false),
- m_prev_kinematic(false),
- m_is_rigid_body(false)
-{
- // warning no initialization of variables done by moto.
-}
-
-SM_Object::
-~SM_Object() {
- if (m_fh_object)
- delete m_fh_object;
-
- DT_DestroyObject(m_object);
- m_object = NULL;
-}
-
- bool
-SM_Object::
-isDynamic(
-) const {
- return m_shapeProps != 0;
-}
-
-/* nzc experimental. There seem to be two places where kinematics
- * are evaluated: proceedKinematic (called from SM_Scene) and
- * proceed() in this object. I'll just try and bunge these out for
- * now. */
- void
-SM_Object::
-suspend(
-){
- if (!m_suspended) {
- m_suspended = true;
- suspendDynamics();
- }
-}
-
- void
-SM_Object::
-resume(
-) {
- if (m_suspended) {
- m_suspended = false;
- restoreDynamics();
- }
-}
-
- void
-SM_Object::
-suspendDynamics(
-) {
- if (m_shapeProps) {
- m_shapePropsBackup = m_shapeProps;
- m_shapeProps = 0;
- }
-}
-
- void
-SM_Object::
-restoreDynamics(
-) {
- if (m_shapePropsBackup) {
- m_shapeProps = m_shapePropsBackup;
- m_shapePropsBackup = 0;
- }
-}
-
- bool
-SM_Object::
-isGhost(
-) const {
- return m_materialProps == 0;
-}
-
- void
-SM_Object::
-suspendMaterial(
-) {
- if (m_materialProps) {
- m_materialPropsBackup = m_materialProps;
- m_materialProps = 0;
- }
-}
-
- void
-SM_Object::
-restoreMaterial(
-) {
- if (m_materialPropsBackup) {
- m_materialProps = m_materialPropsBackup;
- m_materialPropsBackup = 0;
- }
-}
-
- SM_FhObject *
-SM_Object::
-getFhObject(
-) const {
- return m_fh_object;
-}
-
- void
-SM_Object::
-registerCallback(
- SM_Callback& callback
-) {
- m_callbackList.push_back(&callback);
-}
-
-// Set the local coordinate system according to the current state
- void
-SM_Object::
-calcXform() {
-#ifdef SM_DEBUG_XFORM
- printf("SM_Object::calcXform m_pos = { %-0.5f, %-0.5f, %-0.5f }\n",
- m_pos[0], m_pos[1], m_pos[2]);
- printf(" m_orn = { %-0.5f, %-0.5f, %-0.5f, %-0.5f }\n",
- m_orn[0], m_orn[1], m_orn[2], m_orn[3]);
- printf(" m_scaling = { %-0.5f, %-0.5f, %-0.5f }\n",
- m_scaling[0], m_scaling[1], m_scaling[2]);
-#endif
- m_xform.setOrigin(getNextFrame().getPosition());
- m_xform.setBasis(MT_Matrix3x3(getNextFrame().getOrientation(), m_scaling));
- m_xform.getValue(m_ogl_matrix);
-
- /* Blender has been known to crash here.
- This usually means SM_Object *this has been deleted more than once. */
- DT_SetMatrixd(m_object, m_ogl_matrix);
- if (m_fh_object) {
- m_fh_object->setPosition(getNextFrame().getPosition());
- m_fh_object->calcXform();
- }
- updateInvInertiaTensor();
-#ifdef SM_DEBUG_XFORM
- printf("\n | %-0.5f %-0.5f %-0.5f %-0.5f |\n",
- m_ogl_matrix[0], m_ogl_matrix[4], m_ogl_matrix[ 8], m_ogl_matrix[12]);
- printf( " | %-0.5f %-0.5f %-0.5f %-0.5f |\n",
- m_ogl_matrix[1], m_ogl_matrix[5], m_ogl_matrix[ 9], m_ogl_matrix[13]);
- printf( "m_ogl_matrix = | %-0.5f %-0.5f %-0.5f %-0.5f |\n",
- m_ogl_matrix[2], m_ogl_matrix[6], m_ogl_matrix[10], m_ogl_matrix[14]);
- printf( " | %-0.5f %-0.5f %-0.5f %-0.5f |\n\n",
- m_ogl_matrix[3], m_ogl_matrix[7], m_ogl_matrix[11], m_ogl_matrix[15]);
-#endif
-}
-
- void
-SM_Object::updateInvInertiaTensor()
-{
- m_inv_inertia_tensor = m_xform.getBasis().scaled(m_inv_inertia[0], m_inv_inertia[1], m_inv_inertia[2]) * m_xform.getBasis().transposed();
-}
-
-// Call callbacks to notify the client of a change of placement
- void
-SM_Object::
-notifyClient() {
- T_CallbackList::iterator i;
- for (i = m_callbackList.begin(); i != m_callbackList.end(); ++i) {
- (*i)->do_me();
- }
-}
-
-
-// Save the current state information for use in the velocity computation in the next frame.
- void
-SM_Object::
-proceedKinematic(
- MT_Scalar timeStep
-) {
- /* nzc: need to bunge this for the logic bubbling as well? */
- if (!m_suspended) {
- m_prev_kinematic = m_kinematic;
- if (m_kinematic) {
- m_prev_xform = m_xform;
- m_timeStep = timeStep;
- calcXform();
- m_kinematic = false;
- }
- }
-}
-
- void
-SM_Object::
-saveReactionForce(
- MT_Scalar timeStep
-) {
- if (isDynamic()) {
- m_reaction_force = m_reaction_impulse / timeStep;
- m_reaction_impulse.setValue(0.0, 0.0, 0.0);
- }
-}
-
- void
-SM_Object::
-clearForce(
-) {
- m_force.setValue(0.0, 0.0, 0.0);
- m_torque.setValue(0.0, 0.0, 0.0);
-}
-
- void
-SM_Object::
-clearMomentum(
-) {
- m_lin_mom.setValue(0.0, 0.0, 0.0);
- m_ang_mom.setValue(0.0, 0.0, 0.0);
-}
-
- void
-SM_Object::
-setMargin(
- MT_Scalar margin
-) {
- m_margin = margin;
- DT_SetMargin(m_object, margin);
-}
-
- MT_Scalar
-SM_Object::
-getMargin(
-) const {
- return m_margin;
-}
-
-const
- SM_MaterialProps *
-SM_Object::
-getMaterialProps(
-) const {
- return m_materialProps;
-}
-
-const
- SM_ShapeProps *
-SM_Object::
-getShapeProps(
-) const {
- return m_shapeProps;
-}
-
- void
-SM_Object::
-setPosition(
- const MT_Point3& pos
-){
- m_kinematic = true;
- getNextFrame().setPosition(pos);
- endFrame();
-}
-
- void
-SM_Object::
-setOrientation(
- const MT_Quaternion& orn
-){
- MT_assert(!orn.fuzzyZero());
- m_kinematic = true;
- getNextFrame().setOrientation(orn);
- endFrame();
-}
-
- void
-SM_Object::
-setScaling(
- const MT_Vector3& scaling
-){
- m_kinematic = true;
- m_scaling = scaling;
-}
-
-/**
- * Functions to handle linear velocity
- */
-
- void
-SM_Object::
-setExternalLinearVelocity(
- const MT_Vector3& lin_vel
-) {
- m_combined_lin_vel=lin_vel;
-}
-
- void
-SM_Object::
-addExternalLinearVelocity(
- const MT_Vector3& lin_vel
-) {
- m_combined_lin_vel+=lin_vel;
-}
-
- void
-SM_Object::
-addLinearVelocity(
- const MT_Vector3& lin_vel
-){
- setLinearVelocity(getNextFrame().getLinearVelocity() + lin_vel);
-}
-
- void
-SM_Object::
-setLinearVelocity(
- const MT_Vector3& lin_vel
-){
- getNextFrame().setLinearVelocity(lin_vel);
- if (m_shapeProps) {
- m_lin_mom = getNextFrame().getLinearVelocity() * m_shapeProps->m_mass;
- }
-}
-
-/**
- * Functions to handle angular velocity
- */
-
- void
-SM_Object::
-setExternalAngularVelocity(
- const MT_Vector3& ang_vel
-) {
- m_combined_ang_vel = ang_vel;
-}
-
- void
-SM_Object::
-addExternalAngularVelocity(
- const MT_Vector3& ang_vel
-) {
- m_combined_ang_vel += ang_vel;
-}
-
- void
-SM_Object::
-setAngularVelocity(
- const MT_Vector3& ang_vel
-) {
- getNextFrame().setAngularVelocity(ang_vel);
- if (m_shapeProps) {
- m_ang_mom = getNextFrame().getAngularVelocity() * m_shapeProps->m_inertia;
- }
-}
-
- void
-SM_Object::
-addAngularVelocity(
- const MT_Vector3& ang_vel
-) {
- setAngularVelocity(getNextFrame().getAngularVelocity() + ang_vel);
-}
-
-
- void
-SM_Object::
-clearCombinedVelocities(
-) {
- m_combined_lin_vel = MT_Vector3(0,0,0);
- m_combined_ang_vel = MT_Vector3(0,0,0);
-}
-
- void
-SM_Object::
-resolveCombinedVelocities(
- const MT_Vector3 & lin_vel,
- const MT_Vector3 & ang_vel
-) {
-
- // Different behaviours for dynamic and non-dynamic
- // objects. For non-dynamic we just set the velocity to
- // zero. For dynmic the physics velocity has to be
- // taken into account. We must make an arbitrary decision
- // on how to resolve the 2 velocities. Choices are
- // Add the physics velocity to the linear velocity. Objects
- // will just keep on moving in the direction they were
- // last set in - untill external forces affect them.
- // Set the combinbed linear and physics velocity to zero.
- // Set the physics velocity in the direction of the set velocity
- // zero.
- if (isDynamic()) {
-
-#if 1
- getNextFrame().setLinearVelocity(getNextFrame().getLinearVelocity() + lin_vel);
- getNextFrame().setAngularVelocity(getNextFrame().getAngularVelocity() + ang_vel);
-#else
-
- //compute the component of the physics velocity in the
- // direction of the set velocity and set it to zero.
- MT_Vector3 lin_vel_norm = lin_vel.normalized();
-
- setLinearVelocity(getNextFrame().getLinearVelocity() - (getNextFrame().getLinearVelocity().dot(lin_vel_norm) * lin_vel_norm));
-#endif
- m_lin_mom = getNextFrame().getLinearVelocity() * m_shapeProps->m_mass;
- m_ang_mom = getNextFrame().getAngularVelocity() * m_shapeProps->m_inertia;
- clearCombinedVelocities();
-
- }
-
-}
-
-
- MT_Scalar
-SM_Object::
-getInvMass(
-) const {
- return m_inv_mass;
- // OPT: cache the result of this division rather than compute it each call
-}
-
- const MT_Vector3&
-SM_Object::
-getInvInertia(
-) const {
- return m_inv_inertia;
- // OPT: cache the result of this division rather than compute it each call
-}
-
- const MT_Matrix3x3&
-SM_Object::
-getInvInertiaTensor(
-) const {
- return m_inv_inertia_tensor;
-}
-
- void
-SM_Object::
-applyForceField(
- const MT_Vector3& accel
-) {
- if (m_shapeProps) {
- m_force += m_shapeProps->m_mass * accel; // F = m * a
- }
-}
-
- void
-SM_Object::
-applyCenterForce(
- const MT_Vector3& force
-) {
- m_force += force;
-}
-
- void
-SM_Object::
-applyTorque(
- const MT_Vector3& torque
-) {
- m_torque += torque;
-}
-
- void
-SM_Object::
-applyImpulse(
- const MT_Point3& attach, const MT_Vector3& impulse
-) {
- applyCenterImpulse(impulse); // Change in linear momentum
- applyAngularImpulse((attach - getNextFrame().getPosition()).cross(impulse)); // Change in angular momentump
-}
-
- void
-SM_Object::
-applyCenterImpulse(
- const MT_Vector3& impulse
-) {
- if (m_shapeProps) {
- m_lin_mom += impulse;
- m_reaction_impulse += impulse;
- getNextFrame().setLinearVelocity(m_lin_mom * m_inv_mass);
-
- // The linear velocity is immedialtely updated since otherwise
- // simultaneous collisions will get a double impulse.
- }
-}
-
- void
-SM_Object::
-applyAngularImpulse(
- const MT_Vector3& impulse
-) {
- if (m_shapeProps) {
- m_ang_mom += impulse;
- getNextFrame().setAngularVelocity( m_inv_inertia_tensor * m_ang_mom);
- }
-}
-
- MT_Point3
-SM_Object::
-getWorldCoord(
- const MT_Point3& local
-) const {
- return m_xform(local);
-}
-
- MT_Vector3
-SM_Object::
-getVelocity(
- const MT_Point3& local
-) const {
- if (m_prev_kinematic && !isDynamic())
- {
- // For displaced objects the velocity is faked using the previous state.
- // Dynamic objects get their own velocity, not the faked velocity.
- // (Dynamic objects shouldn't be displaced in the first place!!)
- return (m_xform(local) - m_prev_xform(local)) / m_timeStep;
- }
-
- // NB: m_xform.getBasis() * local == m_xform(local) - m_xform.getOrigin()
- return actualLinVelocity() + actualAngVelocity().cross(local);
-}
-
-
-const
- MT_Vector3&
-SM_Object::
-getReactionForce(
-) const {
- return m_reaction_force;
-}
-
- void
-SM_Object::
-getMatrix(
- double *m
-) const {
- std::copy(&m_ogl_matrix[0], &m_ogl_matrix[16], &m[0]);
-}
-
-const
- double *
-SM_Object::
-getMatrix(
-) const {
- return m_ogl_matrix;
-}
-
-// Still need this???
-const
- MT_Transform&
-SM_Object::
-getScaledTransform(
-) const {
- return m_xform;
-}
-
- DT_ObjectHandle
-SM_Object::
-getObjectHandle(
-) const {
- return m_object;
-}
-
- DT_ShapeHandle
-SM_Object::
-getShapeHandle(
-) const {
- return m_shape;
-}
-
- SM_Object *
-SM_Object::
-getDynamicParent(
-) {
- return m_dynamicParent;
-}
-
- void
-SM_Object::
-setRigidBody(
- bool is_rigid_body
-) {
- m_is_rigid_body = is_rigid_body;
-}
-
- bool
-SM_Object::
-isRigidBody(
-) const {
- return m_is_rigid_body;
-}
-
-const
- MT_Vector3
-SM_Object::
-actualLinVelocity(
-) const {
- return m_combined_lin_vel + getNextFrame().getLinearVelocity();
-};
-
-const
- MT_Vector3
-SM_Object::
-actualAngVelocity(
-) const {
- return m_combined_ang_vel + getNextFrame().getAngularVelocity();
-}
-
-
-SM_MotionState&
-SM_Object::
-getCurrentFrame()
-{
- return m_frames[1];
-}
-
-SM_MotionState&
-SM_Object::
-getPreviousFrame()
-{
- return m_frames[0];
-}
-
-SM_MotionState &
-SM_Object::
-getNextFrame()
-{
- return m_frames[2];
-}
-
-const SM_MotionState &
-SM_Object::
-getCurrentFrame() const
-{
- return m_frames[1];
-}
-
-const SM_MotionState &
-SM_Object::
-getPreviousFrame() const
-{
- return m_frames[0];
-}
-
-const SM_MotionState &
-SM_Object::
-getNextFrame() const
-{
- return m_frames[2];
-}
-
-
-const MT_Point3&
-SM_Object::
-getPosition() const
-{
- return m_frames[1].getPosition();
-}
-
-const MT_Quaternion&
-SM_Object::
-getOrientation() const
-{
- return m_frames[1].getOrientation();
-}
-
-const MT_Vector3&
-SM_Object::
-getLinearVelocity() const
-{
- return m_frames[1].getLinearVelocity();
-}
-
-const MT_Vector3&
-SM_Object::
-getAngularVelocity() const
-{
- return m_frames[1].getAngularVelocity();
-}
-
-void
-SM_Object::
-interpolate(MT_Scalar timeStep)
-{
- if (!actualLinVelocity().fuzzyZero() || !actualAngVelocity().fuzzyZero())
- {
- getCurrentFrame().setTime(timeStep);
- getCurrentFrame().lerp(getPreviousFrame(), getNextFrame());
- notifyClient();
- }
-}
-
-void
-SM_Object::
-endFrame()
-{
- getPreviousFrame() = getNextFrame();
- getCurrentFrame() = getNextFrame();
- m_static = 0;
-}
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
deleted file mode 100644
index f0791bbf89f..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-/**
- * $Id$
- * Copyright (C) 2001 NaN Technologies B.V.
- * The physics scene.
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WIN32
-#pragma warning(disable : 4786) // shut off 255 char limit debug template warning
-#endif
-
-#include "SM_Scene.h"
-#include "SM_Object.h"
-#include "SM_FhObject.h"
-
-#include "SM_Debug.h"
-
-#include <algorithm>
-
-SM_Scene::SM_Scene() :
- m_scene(DT_CreateScene()),
- m_respTable(DT_CreateRespTable()),
- m_secondaryRespTable(DT_CreateRespTable()),
- m_fixRespTable(DT_CreateRespTable()),
- m_forceField(0.0, 0.0, 0.0),
- m_frames(0)
-{
- for (int i = 0 ; i < NUM_RESPONSE; i++)
- {
- m_ResponseClass[i] = DT_GenResponseClass(m_respTable);
- m_secondaryResponseClass[i] = DT_GenResponseClass(m_secondaryRespTable);
- m_fixResponseClass[i] = DT_GenResponseClass(m_fixRespTable);
- }
-
- /* Sensor */
- DT_AddPairResponse(m_respTable, m_ResponseClass[SENSOR_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], 0, DT_NO_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[SENSOR_RESPONSE], m_ResponseClass[STATIC_RESPONSE], SM_Scene::boing, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[SENSOR_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_Scene::boing, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[SENSOR_RESPONSE], m_ResponseClass[FH_RESPONSE], 0, DT_NO_RESPONSE, this);
-
- /* Static */
- DT_AddPairResponse(m_respTable, m_ResponseClass[STATIC_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], SM_Scene::boing, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[STATIC_RESPONSE], m_ResponseClass[STATIC_RESPONSE], 0, DT_NO_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[STATIC_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_Object::boing, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[STATIC_RESPONSE], m_ResponseClass[FH_RESPONSE], SM_FhObject::ray_hit, DT_SIMPLE_RESPONSE, this);
-
- /* Object */
- DT_AddPairResponse(m_respTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], SM_Scene::boing, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[STATIC_RESPONSE], SM_Object::boing, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_Object::boing, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[FH_RESPONSE], SM_FhObject::ray_hit, DT_SIMPLE_RESPONSE, this);
-
- /* Fh Object */
- DT_AddPairResponse(m_respTable, m_ResponseClass[FH_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], 0, DT_NO_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[FH_RESPONSE], m_ResponseClass[STATIC_RESPONSE], SM_FhObject::ray_hit, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[FH_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_FhObject::ray_hit, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[FH_RESPONSE], m_ResponseClass[FH_RESPONSE], 0, DT_NO_RESPONSE, this);
-
- /* Object (Fix Pass) */
- DT_AddPairResponse(m_fixRespTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], 0, DT_NO_RESPONSE, this);
- DT_AddPairResponse(m_fixRespTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[STATIC_RESPONSE], SM_Object::fix, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_fixRespTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_Object::fix, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_fixRespTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[FH_RESPONSE], 0, DT_NO_RESPONSE, this);
-}
-
-void SM_Scene::addTouchCallback(int response_class, DT_ResponseCallback callback, void *user)
-{
- DT_AddClassResponse(m_secondaryRespTable, m_secondaryResponseClass[response_class], callback, DT_BROAD_RESPONSE, user);
-}
-
-void SM_Scene::addSensor(SM_Object& object)
-{
- T_ObjectList::iterator i =
- std::find(m_objectList.begin(), m_objectList.end(), &object);
- if (i == m_objectList.end())
- {
- object.calcXform();
- m_objectList.push_back(&object);
- DT_AddObject(m_scene, object.getObjectHandle());
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[SENSOR_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass [SENSOR_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[SENSOR_RESPONSE]);
- }
-}
-
-void SM_Scene::add(SM_Object& object) {
- object.calcXform();
- m_objectList.push_back(&object);
- DT_AddObject(m_scene, object.getObjectHandle());
- if (object.isDynamic()) {
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[OBJECT_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[OBJECT_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[OBJECT_RESPONSE]);
- } else {
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[STATIC_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[STATIC_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[STATIC_RESPONSE]);
- }
-
- SM_FhObject *fh_object = object.getFhObject();
-
- if (fh_object) {
- DT_AddObject(m_scene, fh_object->getObjectHandle());
- DT_SetResponseClass(m_respTable, fh_object->getObjectHandle(), m_ResponseClass[FH_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, fh_object->getObjectHandle(), m_secondaryResponseClass[FH_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, fh_object->getObjectHandle(), m_fixResponseClass[FH_RESPONSE]);
- }
-}
-
-void SM_Scene::requestCollisionCallback(SM_Object &object)
-{
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[OBJECT_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[OBJECT_RESPONSE]);
-// DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[OBJECT_RESPONSE]);
-}
-
-void SM_Scene::remove(SM_Object& object) {
- //std::cout << "SM_Scene::remove this =" << this << "object = " << &object << std::endl;
- T_ObjectList::iterator i =
- std::find(m_objectList.begin(), m_objectList.end(), &object);
- if (!(i == m_objectList.end()))
- {
- std::swap(*i, m_objectList.back());
- m_objectList.pop_back();
- DT_RemoveObject(m_scene, object.getObjectHandle());
-
- SM_FhObject *fh_object = object.getFhObject();
-
- if (fh_object) {
- DT_RemoveObject(m_scene, fh_object->getObjectHandle());
- }
- }
- else {
- // tried to remove an object that is not in the scene
- //assert(false);
- }
-}
-
-void SM_Scene::beginFrame()
-{
- T_ObjectList::iterator i;
- // Apply a forcefield (such as gravity)
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i)
- (*i)->applyForceField(m_forceField);
-
-}
-
-void SM_Scene::endFrame()
-{
- T_ObjectList::iterator i;
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i)
- (*i)->clearForce();
-}
-
-bool SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate)
-{
- if (!m_frames)
- {
- if (ticrate > 0.)
- m_frames = (unsigned int)(curtime*ticrate) + 1.0;
- else
- m_frames = (unsigned int)(curtime*65536.0);
- }
-
- // Divide the timeStep into a number of subsamples of size roughly
- // equal to subS (might be a little smaller).
- MT_Scalar subStep;
- int num_samples;
- int frames = m_frames;
-
- // Compute the number of steps to do this update.
- if (ticrate > 0.0)
- {
- // Fixed time step
- subStep = 1.0/ticrate;
- num_samples = (unsigned int)(curtime*ticrate + 1.0) - m_frames;
-
- if (num_samples > 4)
- {
- std::cout << "Dropping physics frames! frames:" << num_samples << " substep: " << subStep << std::endl;
- MT_Scalar tr = ticrate;
- do
- {
- frames = frames / 2;
- tr = tr / 2.0;
- num_samples = (unsigned int)(curtime*tr + 1.0) - frames;
- subStep *= 2.0;
- } while (num_samples > 8);
- std::cout << " frames:" << num_samples << " substep: " << subStep << std::endl;
- }
- }
- else
- {
- // Variable time step. (old update)
- // Integrate at least 100 Hz
- MT_Scalar timeStep = curtime - m_frames/65536.0;
- subStep = timeStep > 0.01 ? 0.01 : timeStep;
- num_samples = int(timeStep * 0.01);
- if (num_samples < 1)
- num_samples = 1;
- }
-
- // Do a physics timestep.
- T_ObjectList::iterator i;
- if (num_samples > 0)
- {
- // Do the integration steps per object.
- for (int step = 0; step != num_samples; ++step)
- {
- MT_Scalar time;
- if (ticrate > 0.)
- time = MT_Scalar(frames + step + 1) * subStep;
- else
- time = MT_Scalar(m_frames)/65536.0 + MT_Scalar(step + 1)*subStep;
-
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
- (*i)->endFrame();
- // Apply a forcefield (such as gravity)
- (*i)->integrateForces(subStep);
- // And second we update the object positions by performing
- // an integration step for each object
- (*i)->integrateMomentum(subStep);
- }
-
- // So now first we let the physics scene respond to
- // new forces, velocities set externally.
- // The collsion and friction impulses are computed here.
- // Collision phase
- DT_Test(m_scene, m_respTable);
-
- // Contact phase
- DT_Test(m_scene, m_fixRespTable);
-
- // Finish this timestep by saving al state information for the next
- // timestep and clearing the accumulated forces.
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
- (*i)->relax();
- (*i)->proceedKinematic(subStep);
- (*i)->saveReactionForce(subStep);
- (*i)->getNextFrame().setTime(time);
- //(*i)->clearForce();
- }
- }
- }
-
- if (ticrate > 0)
- {
- // Interpolate between time steps.
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i)
- (*i)->interpolate(curtime);
-
- //only update the m_frames after an actual physics timestep
- if (num_samples)
- {
- m_frames = (unsigned int)(curtime*ticrate) + 1.0;
- }
- }
- else
- {
- m_frames = (unsigned int)(curtime*65536.0);
- }
-
- return num_samples != 0;
-}
-
-void SM_Scene::notifyCollision(SM_Object *obj1, SM_Object *obj2)
-{
- // For each pair of object that collided, call the corresponding callback.
- if (m_secondaryRespTable)
- DT_CallResponse(m_secondaryRespTable, obj1->getObjectHandle(), obj2->getObjectHandle(), 0);
-}
-
-
-SM_Object *SM_Scene::rayTest(void *ignore_client,
- const MT_Point3& from, const MT_Point3& to,
- MT_Point3& result, MT_Vector3& normal) const {
-#ifdef SM_DEBUG_RAYCAST
- std::cout << "ray: { " << from << " } - { " << to << " }" << std::endl;
-#endif
-
- DT_Vector3 n, dfrom, dto;
- DT_Scalar param;
- from.getValue(dfrom);
- to.getValue(dto);
- SM_Object *hit_object = (SM_Object *)
- DT_RayCast(m_scene, ignore_client, dfrom, dto, 1., &param, n);
-
- if (hit_object) {
- //result = hit_object->getWorldCoord(from + (to - from)*param);
- result = from + (to - from) * param;
- normal.setValue(n);
-#ifdef SM_DEBUG_RAYCAST
- std::cout << "ray: { " << from << " } -> { " << to << " }: { " << result
- << " } (" << param << "), normal = { " << normal << " }" << std::endl;
-#endif
- }
-
- return hit_object;
-}
-
-void SM_Scene::clearObjectCombinedVelocities() {
-
- T_ObjectList::iterator i;
-
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
-
- (*i)->clearCombinedVelocities();
-
- }
-
-}
-
-
-void SM_Scene::setSecondaryRespTable(DT_RespTableHandle secondaryRespTable) {
- m_secondaryRespTable = secondaryRespTable;
-}
-
-
-DT_Bool SM_Scene::boing(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *
-){
- SM_Scene *scene = (SM_Scene *)client_data;
- SM_Object *obj1 = (SM_Object *)object1;
- SM_Object *obj2 = (SM_Object *)object2;
-
- scene->notifyCollision(obj1, obj2); // Record this collision for client callbacks
-
-#ifdef SM_DEBUG_BOING
- printf("SM_Scene::boing\n");
-#endif
-
- return DT_CONTINUE;
-}
-
-SM_Scene::~SM_Scene()
-{
- //std::cout << "SM_Scene::~ SM_Scene(): destroy " << this << std::endl;
-// if (m_objectList.begin() != m_objectList.end())
-// std::cout << "SM_Scene::~SM_Scene: There are still objects in the Sumo scene!" << std::endl;
- for (T_ObjectList::iterator it = m_objectList.begin() ; it != m_objectList.end() ; it++)
- delete *it;
-
- DT_DestroyRespTable(m_respTable);
- DT_DestroyRespTable(m_secondaryRespTable);
- DT_DestroyRespTable(m_fixRespTable);
- DT_DestroyScene(m_scene);
-}
diff --git a/source/gameengine/Physics/Sumo/Makefile b/source/gameengine/Physics/Sumo/Makefile
deleted file mode 100644
index 69efc4d84eb..00000000000
--- a/source/gameengine/Physics/Sumo/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): none yet.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-#
-
-SOURCEDIR = source/gameengine/Physics/Sumo
-LIBNAME = sumo
-DIR = $(OCGDIR)/gameengine/blphys/$(LIBNAME)
-DIRS = Fuzzics
-
-include nan_compile.mk
-
-CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
-
-CPPFLAGS += -I$(OPENGL_HEADERS)
-CPPFLAGS += -I$(NAN_STRING)/include
-CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_SOLID)/include
-CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
-CPPFLAGS += -I../../Physics/common
-CPPFLAGS += -I../../Physics/Dummy
-
-include nan_subdirs.mk
diff --git a/source/gameengine/Physics/Sumo/SConscript b/source/gameengine/Physics/Sumo/SConscript
deleted file mode 100644
index 86e8db5919f..00000000000
--- a/source/gameengine/Physics/Sumo/SConscript
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-Import ('env')
-
-sources = ['SumoPHYCallbackBridge.cpp',
- 'SumoPhysicsController.cpp',
- 'SumoPhysicsEnvironment.cpp',
- 'Fuzzics/src/SM_FhObject.cpp',
- 'Fuzzics/src/SM_Object.cpp',
- 'Fuzzics/src/SM_Scene.cpp',
- 'Fuzzics/src/SM_MotionState.cpp'
- ]
-
-incs =['.',
- '../common',
- 'Fuzzics/include',
- '#/intern/moto/include'
- ]
-incs += [env['BF_SOLID_INC']]
-
-cflags = []
-if env['OURPLATFORM']=='win32-vc':
- cflags.append('/GR')
- cflags.append('/O1')
-
-env.BlenderLib ( 'bf_sumo', sources, incs, [], libtype=['game2','player'], priority=[30, 70] , compileflags=cflags)
diff --git a/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.cpp b/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.cpp
deleted file mode 100644
index 1992bbe3421..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "SumoPHYCallbackBridge.h"
-#include "PHY_IPhysicsController.h"
-#include "SM_Object.h"
-
-
-SumoPHYCallbackBridge::SumoPHYCallbackBridge(void* clientData,PHY_ResponseCallback phyCallback)
-:m_orgClientData(clientData),
-m_phyCallback(phyCallback)
-{
-
-}
-DT_Bool SumoPHYCallbackBridge::StaticSolidToPHYCallback(void *client_data,
- void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data)
-{
- SumoPHYCallbackBridge* bridge = static_cast<SumoPHYCallbackBridge*>(client_data);
- bridge->SolidToPHY(client_object1,client_object2,coll_data);
- return false;
-}
-
-DT_Bool SumoPHYCallbackBridge::SolidToPHY(void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data)
-{
-
- SM_Object* smObject1 = static_cast<SM_Object*>(client_object1);
- SM_Object* smObject2 = static_cast<SM_Object*>(client_object2);
-
- PHY_IPhysicsController* ctrl1 = static_cast<PHY_IPhysicsController*>(smObject1->getPhysicsClientObject());
- PHY_IPhysicsController* ctrl2 = static_cast<PHY_IPhysicsController*>(smObject2->getPhysicsClientObject());
-
- if (!ctrl1 || !ctrl2)
- {
- //todo: check which objects are not linked up properly
- return false;
- }
- if (coll_data)
- {
- PHY_CollData phyCollData;
-
- phyCollData.m_point1[0] = coll_data->point1[0];
- phyCollData.m_point1[1] = coll_data->point1[1];
- phyCollData.m_point1[2] = coll_data->point1[2];
- phyCollData.m_point1[3] = 0.f;
-
- phyCollData.m_point2[0] = coll_data->point2[0];
- phyCollData.m_point2[1] = coll_data->point2[1];
- phyCollData.m_point2[2] = coll_data->point2[2];
- phyCollData.m_point2[3] = 0.f;
-
- phyCollData.m_normal[0] = coll_data->normal[0];
- phyCollData.m_normal[1] = coll_data->normal[1];
- phyCollData.m_normal[2] = coll_data->normal[2];
- phyCollData.m_normal[3] = 0.f;
-
-
- return m_phyCallback(m_orgClientData,
- ctrl1,ctrl2,&phyCollData);
- }
-
- return m_phyCallback(m_orgClientData,
- ctrl1,ctrl2,0);
-
-}
-
diff --git a/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.h b/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.h
deleted file mode 100644
index cc980f3961d..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef SUMO_PHY_CALLBACK_BRIDGE_H
-#define SUMO_PHY_CALLBACK_BRIDGE_H
-
-#include <SOLID/SOLID.h>
-#include "PHY_DynamicTypes.h"
-
-class SumoPHYCallbackBridge
-{
- void* m_orgClientData;
- PHY_ResponseCallback m_phyCallback;
-
-public:
-
- SumoPHYCallbackBridge(void* clientData,PHY_ResponseCallback phyCallback);
-
- static DT_Bool StaticSolidToPHYCallback(void *client_data,
- void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data);
-
- DT_Bool SolidToPHY(void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data);
-
-
-};
-
-#endif //SUMO_PHY_CALLBACK_BRIDGE_H
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
deleted file mode 100644
index 5e77567a95a..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
+++ /dev/null
@@ -1,568 +0,0 @@
-/**
- * @file $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "SumoPhysicsController.h"
-#include "PHY_IMotionState.h"
-#include "SM_Object.h"
-#include "MT_Quaternion.h"
-
-
-SumoPhysicsController::SumoPhysicsController(
- class SM_Scene* sumoScene,
- class SM_Object* sumoObj,
- class PHY_IMotionState* motionstate,
-
- bool dyna)
- :
- m_sumoObj(sumoObj) ,
- m_sumoScene(sumoScene),
- m_bFirstTime(true),
- m_bDyna(dyna),
- m_MotionState(motionstate)
-{
- if (m_sumoObj)
- {
-
- PHY__Vector3 pos1;
- getPosition(pos1);
- MT_Point3 pos(pos1);
-
- //temp debugging check
- //assert(pos.length() < 100000.f);
-
- //need this to do the upcast after the solid/sumo collision callback
- m_sumoObj->setPhysicsClientObject(this);
- //if it is a dyna, register for a callback
- m_sumoObj->registerCallback(*this);
- }
-};
-
-
-
-SumoPhysicsController::~SumoPhysicsController()
-{
- if (m_sumoObj)
- {
- m_sumoScene->remove(*m_sumoObj);
-
- delete m_sumoObj;
- m_sumoObj = NULL;
- }
-}
-
-float SumoPhysicsController::getMass()
-{
- if (m_sumoObj)
- {
- const SM_ShapeProps *shapeprops = m_sumoObj->getShapeProps();
- if(shapeprops!=NULL) return shapeprops->m_mass;
- }
- return 0.f;
-}
-
-bool SumoPhysicsController::SynchronizeMotionStates(float)
-{
- if (m_bFirstTime)
- {
- setSumoTransform(!m_bFirstTime);
- m_bFirstTime = false;
- }
- return false;
-}
-
-
-
-
-void SumoPhysicsController::GetWorldOrientation(MT_Matrix3x3& mat)
-{
- float orn[4];
- m_MotionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
- MT_Quaternion quat(orn);
- mat.setRotation(quat);
-
-}
-
-void SumoPhysicsController::getPosition(PHY__Vector3& pos) const
-{
- assert(m_sumoObj);
-
- pos[0] = m_sumoObj->getPosition()[0];
- pos[1] = m_sumoObj->getPosition()[0];
- pos[2] = m_sumoObj->getPosition()[0];
-
- //m_MotionState->getWorldPosition(pos[0],pos[1],pos[2]);
-}
-
-void SumoPhysicsController::GetWorldPosition(MT_Point3& pos)
-{
-// assert(m_sumoObj);
-
-// pos[0] = m_sumoObj->getPosition()[0];
-// pos[1] = m_sumoObj->getPosition()[0];
-// pos[2] = m_sumoObj->getPosition()[0];
-
- float worldpos[3];
- m_MotionState->getWorldPosition(worldpos[0],worldpos[1],worldpos[2]);
- pos[0]=worldpos[0];
- pos[1]=worldpos[1];
- pos[2]=worldpos[2];
-}
-
-void SumoPhysicsController::GetWorldScaling(MT_Vector3& scale)
-{
- float worldscale[3];
- m_MotionState->getWorldScaling(worldscale[0],worldscale[1],worldscale[2]);
- scale[0]=worldscale[0];
- scale[1]=worldscale[1];
- scale[2]=worldscale[2];
-}
-
-
- // kinematic methods
-void SumoPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)
-{
- if (m_sumoObj)
- {
- MT_Matrix3x3 mat;
- GetWorldOrientation(mat);
- MT_Vector3 dloc(dlocX,dlocY,dlocZ);
-
- MT_Point3 newpos = m_sumoObj->getPosition();
-
- newpos += (local ? mat * dloc : dloc);
- m_sumoObj->setPosition(newpos);
- }
-
-}
-void SumoPhysicsController::RelativeRotate(const float drot[12],bool local)
-{
- if (m_sumoObj )
- {
- MT_Matrix3x3 drotmat(drot);
- MT_Matrix3x3 currentOrn;
- GetWorldOrientation(currentOrn);
-
- m_sumoObj->setOrientation(m_sumoObj->getOrientation()*(local ?
- drotmat : (currentOrn.inverse() * drotmat * currentOrn)).getRotation());
- }
-
-}
-void SumoPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
-{
- m_sumoObj->setOrientation(MT_Quaternion(quatImag0,quatImag1,quatImag2,quatReal));
-}
-
-void SumoPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
-{
- const MT_Quaternion& q = m_sumoObj->getOrientation();
- quatImag0 = q[0];
- quatImag1 = q[1];
- quatImag2 = q[2];
- quatReal = q[3];
-}
-
-void SumoPhysicsController::setPosition(float posX,float posY,float posZ)
-{
- m_sumoObj->setPosition(MT_Point3(posX,posY,posZ));
-}
-
-void SumoPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
-{
- if (!m_bDyna)
- m_sumoObj->setScaling(MT_Vector3(scaleX,scaleY,scaleZ));
-}
-
- // physics methods
-void SumoPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)
-{
- if (m_sumoObj)
- {
- MT_Vector3 torque(torqueX,torqueY,torqueZ);
-
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
- m_sumoObj->applyTorque(local ?
- orn * torque :
- torque);
- }
-}
-
-void SumoPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
-{
- if (m_sumoObj)
- {
- MT_Vector3 force(forceX,forceY,forceZ);
-
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
-
- m_sumoObj->applyCenterForce(local ?
- orn * force :
- force);
- }
-}
-
-void SumoPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)
-{
- if (m_sumoObj)
- {
- MT_Vector3 ang_vel(ang_velX,ang_velY,ang_velZ);
-
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
-
- m_sumoObj->setExternalAngularVelocity(local ?
- orn * ang_vel :
- ang_vel);
- }
-}
-
-void SumoPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)
-{
- if (m_sumoObj )
- {
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
-
- MT_Vector3 lin_vel(lin_velX,lin_velY,lin_velZ);
- m_sumoObj->setExternalLinearVelocity(local ?
- orn * lin_vel :
- lin_vel);
- }
-}
-
-void SumoPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
- if (m_sumoObj)
- m_sumoObj->resolveCombinedVelocities(MT_Vector3(linvelX,linvelY,linvelZ),MT_Vector3(angVelX,angVelY,angVelZ));
-}
-
-
-
-
-void SumoPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)
-{
- if (m_sumoObj)
- {
- MT_Point3 attach(attachX,attachY,attachZ);
- MT_Vector3 impulse(impulseX,impulseY,impulseZ);
- m_sumoObj->applyImpulse(attach,impulse);
- }
-
-}
-
-void SumoPhysicsController::SuspendDynamics()
-{
- m_suspendDynamics=true;
-
- if (m_sumoObj)
- {
- m_sumoObj->suspendDynamics();
- m_sumoObj->setLinearVelocity(MT_Vector3(0,0,0));
- m_sumoObj->setAngularVelocity(MT_Vector3(0,0,0));
- m_sumoObj->calcXform();
- }
-}
-
-void SumoPhysicsController::RestoreDynamics()
-{
- m_suspendDynamics=false;
-
- if (m_sumoObj)
- {
- m_sumoObj->restoreDynamics();
- }
-}
-
-
-/**
- reading out information from physics
-*/
-void SumoPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ)
-{
- if (m_sumoObj)
- {
- // get velocity from the physics object (m_sumoObj)
- const MT_Vector3& vel = m_sumoObj->getLinearVelocity();
- linvX = vel[0];
- linvY = vel[1];
- linvZ = vel[2];
- }
- else
- {
- linvX = 0.f;
- linvY = 0.f;
- linvZ = 0.f;
- }
-}
-
-/**
- GetVelocity parameters are in geometric coordinates (Origin is not center of mass!).
-*/
-void SumoPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)
-{
- if (m_sumoObj)
- {
- MT_Point3 pos(posX,posY,posZ);
- // get velocity from the physics object (m_sumoObj)
- const MT_Vector3& vel = m_sumoObj->getVelocity(pos);
- linvX = vel[0];
- linvY = vel[1];
- linvZ = vel[2];
- }
- else
- {
- linvX = 0.f;
- linvY = 0.f;
- linvZ = 0.f;
-
- }
-}
-
-void SumoPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
-{
- const MT_Vector3& force = m_sumoObj->getReactionForce();
- forceX = force[0];
- forceY = force[1];
- forceZ = force[2];
-}
-
-void SumoPhysicsController::setRigidBody(bool rigid)
-{
- m_sumoObj->setRigidBody(rigid);
-}
-
-void SumoPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)
-{
- m_MotionState = motionstate;
-
- SM_Object* dynaparent=0;
- SumoPhysicsController* sumoparentctrl = (SumoPhysicsController* )parentctrl;
-
- if (sumoparentctrl)
- {
- dynaparent = sumoparentctrl->GetSumoObject();
- }
-
- SM_Object* orgsumoobject = m_sumoObj;
-
-
- m_sumoObj = new SM_Object(
- orgsumoobject->getShapeHandle(),
- orgsumoobject->getMaterialProps(),
- orgsumoobject->getShapeProps(),
- dynaparent);
-
- m_sumoObj->setRigidBody(orgsumoobject->isRigidBody());
-
- m_sumoObj->setMargin(orgsumoobject->getMargin());
- m_sumoObj->setPosition(orgsumoobject->getPosition());
- m_sumoObj->setOrientation(orgsumoobject->getOrientation());
- //if it is a dyna, register for a callback
- m_sumoObj->registerCallback(*this);
-
- m_sumoScene->add(* (m_sumoObj));
-}
-
-PHY_IMotionState* SumoPhysicsController::GetMotionState()
-{
- return m_MotionState;
-}
-
-void SumoPhysicsController::SetSimulatedTime(float)
-{
-}
-
-
-void SumoPhysicsController::WriteMotionStateToDynamics(bool)
-{
- float tmp[4];
- m_MotionState->getWorldPosition(tmp[0], tmp[1], tmp[2]);
- MT_Point3 pos(tmp);
- m_sumoObj->setPosition(pos);
- m_MotionState->getWorldOrientation(tmp[0], tmp[1], tmp[2], tmp[3]);
- MT_Quaternion quat(tmp);
- m_sumoObj->setOrientation(quat);
-}
-// this is the actual callback from sumo, and the position/orientation
-//is written to the scenegraph, using the motionstate abstraction
-
-void SumoPhysicsController::do_me()
-{
- MT_assert(m_sumoObj);
- const MT_Point3& pos = m_sumoObj->getPosition();
- const MT_Quaternion& orn = m_sumoObj->getOrientation();
-
- MT_assert(m_MotionState);
- m_MotionState->setWorldPosition(pos[0],pos[1],pos[2]);
- m_MotionState->setWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
-}
-
-
-void SumoPhysicsController::setSumoTransform(bool nondynaonly)
-{
- if (!nondynaonly || !m_bDyna)
- {
- if (m_sumoObj)
- {
- MT_Point3 pos;
- GetWorldPosition(pos);
-
- m_sumoObj->setPosition(pos);
- if (m_bDyna)
- {
- m_sumoObj->setScaling(MT_Vector3(1,1,1));
- } else
- {
- MT_Vector3 scale;
- GetWorldScaling(scale);
- m_sumoObj->setScaling(scale);
- }
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
- m_sumoObj->setOrientation(orn.getRotation());
- m_sumoObj->calcXform();
- }
- }
-}
-
-
- // clientinfo for raycasts for example
-void* SumoPhysicsController::getNewClientInfo()
-{
- if (m_sumoObj)
- return m_sumoObj->getClientObject();
- return 0;
-
-}
-void SumoPhysicsController::setNewClientInfo(void* clientinfo)
-{
- if (m_sumoObj)
- {
- SM_ClientObject* clOb = static_cast<SM_ClientObject*> (clientinfo);
- m_sumoObj->setClientObject(clOb);
- }
-
-}
-
-void SumoPhysicsController::calcXform()
-{
- if (m_sumoObj)
- m_sumoObj->calcXform();
-}
-
-void SumoPhysicsController::SetMargin(float margin)
-{
- if (m_sumoObj)
- m_sumoObj->setMargin(margin);
-}
-
-float SumoPhysicsController::GetMargin() const
-{
- if (m_sumoObj)
- m_sumoObj->getMargin();
- return 0.f;
-}
-
-float SumoPhysicsController::GetRadius() const
-{
- if (m_sumoObj && m_sumoObj->getShapeProps())
- {
- return m_sumoObj->getShapeProps()->m_radius;
- }
- return 0.f;
-
-}
-
-///////////////////////////////////////////////////////////
-///A small utility class, SumoDefaultMotionState
-///
-///////////////////////////////////////////////////////////
-
-SumoDefaultMotionState::SumoDefaultMotionState()
-{
- m_worldTransform.setIdentity();
- m_localScaling.setValue(1.f,1.f,1.f);
-}
-
-
-SumoDefaultMotionState::~SumoDefaultMotionState()
-{
-
-}
-
-void SumoDefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ)
-{
- posX = m_worldTransform.getOrigin().x();
- posY = m_worldTransform.getOrigin().y();
- posZ = m_worldTransform.getOrigin().z();
-}
-
-void SumoDefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
-{
- scaleX = m_localScaling.x();
- scaleY = m_localScaling.y();
- scaleZ = m_localScaling.z();
-}
-
-void SumoDefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
-{
- MT_Quaternion quat = m_worldTransform.getRotation();
- quatIma0 = quat.x();
- quatIma1 = quat.y();
- quatIma2 = quat.z();
- quatReal = quat.w();
-}
-
-void SumoDefaultMotionState::getWorldOrientation(float* ori)
-{
- m_worldTransform.getBasis().getValue(ori);
-}
-
-void SumoDefaultMotionState::setWorldOrientation(const float* ori)
-{
- m_worldTransform.getBasis().setValue(ori);
-}
-void SumoDefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
-{
- MT_Point3 pos(posX,posY,posZ);
- m_worldTransform.setOrigin( pos );
-}
-
-void SumoDefaultMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
-{
- MT_Quaternion orn(quatIma0,quatIma1,quatIma2,quatReal);
- m_worldTransform.setRotation( orn );
-}
-
-void SumoDefaultMotionState::calculateWorldTransformations()
-{
-
-}
-
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.h b/source/gameengine/Physics/Sumo/SumoPhysicsController.h
deleted file mode 100644
index 25d6d68f3b8..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- * @file $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __SUMO_PHYSICSCONTROLLER_H
-#define __SUMO_PHYSICSCONTROLLER_H
-
-#include "PHY_IPhysicsController.h"
-#include "PHY_IMotionState.h"
-#include "SM_Scene.h"
-#include "SM_Callback.h"
-
-/**
- * Sumo Physics Controller, a special kind of a PhysicsController.
- * A Physics Controller is a special kind of Scene Graph Transformation Controller.
- * Each time the scene graph get's updated, the controller get's a chance
- * in the 'Update' method to reflect changes.
- *
- * Sumo uses the SOLID library for collision detection.
- */
-class SumoPhysicsController : public PHY_IPhysicsController , public SM_Callback
-
-
-{
-
-
-public:
- SumoPhysicsController(
- class SM_Scene* sumoScene,
- class SM_Object* sumoObj,
- class PHY_IMotionState* motionstate,
- bool dyna);
-
- virtual ~SumoPhysicsController();
-
- /**
- * @name Kinematic Methods.
- */
- /*@{*/
- virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
- /**
- * @param drot a 3x4 matrix. This will treated as a 3x3 rotation matrix.
- * @warning RelativeRotate expects a 3x4 matrix. The fourth column is padding.
- */
- virtual void RelativeRotate(const float drot[12],bool local);
- virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
- virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
- virtual void setPosition(float posX,float posY,float posZ);
- virtual void getPosition(PHY__Vector3& pos) const;
-
- virtual void setScaling(float scaleX,float scaleY,float scaleZ);
- /*@}*/
-
- /**
- * @name Physics Methods
- */
- /*@{*/
- virtual void ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local);
- virtual void ApplyForce(float forceX,float forceY,float forceZ,bool local);
- virtual void SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local);
- virtual void SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local);
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
- virtual void applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ);
- virtual void SetActive(bool active){};
- virtual void SuspendDynamics();
- virtual void RestoreDynamics();
- /*@}*/
-
-
- /**
- * reading out information from physics
- */
- virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ);
- /**
- * GetVelocity parameters are in geometric coordinates (Origin is not center of mass!).
- */
- virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ);
- virtual float getMass();
- virtual void getReactionForce(float& forceX,float& forceY,float& forceZ);
- virtual void setRigidBody(bool rigid);
-
-
- virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl);
-
- // TODO: remove next line !
- virtual void SetSimulatedTime(float time);
-
- virtual void WriteDynamicsToMotionState() {};
- virtual void WriteMotionStateToDynamics(bool nondynaonly);
- virtual class PHY_IMotionState* GetMotionState();
-
- /**
- * call from Scene Graph Node to 'update'.
- */
- virtual bool SynchronizeMotionStates(float time);
-
- virtual void calcXform();
- virtual void SetMargin(float margin) ;
- virtual float GetMargin() const;
- virtual float GetRadius() const ;
- virtual void SetRadius(float margin) { SetMargin(margin); }
-
-
- // clientinfo for raycasts for example
- virtual void* getNewClientInfo();
- virtual void setNewClientInfo(void* clientinfo);
-
- float getFriction() { return m_friction;}
- float getRestitution() { return m_restitution;}
-
- /**
- * Sumo callback
- */
- virtual void do_me();
-
- class SM_Object* GetSumoObject ()
- {
- return m_sumoObj;
- };
-
- void GetWorldOrientation(class MT_Matrix3x3& mat);
- void GetWorldPosition(MT_Point3& pos);
- void GetWorldScaling(MT_Vector3& scale);
-
- float GetLinVelocityMin() const { return 0.f; }
- void SetLinVelocityMin(float val) { }
- float GetLinVelocityMax() const { return 0.f; }
- void SetLinVelocityMax(float val) { }
-
-
-// void SetSumoObject(class SM_Object* sumoObj) {
-// m_sumoObj = sumoObj;
-// }
-// void SetSumoScene(class SM_Scene* sumoScene) {
-// m_sumoScene = sumoScene;
-// }
-
- void setSumoTransform(bool nondynaonly);
-
-
-private:
- class SM_Object* m_sumoObj;
- class SM_Scene* m_sumoScene; // needed for replication
- bool m_bFirstTime;
- bool m_bDyna;
-
- float m_friction;
- float m_restitution;
-
-
- bool m_suspendDynamics;
-
- bool m_firstTime;
- bool m_bFullRigidBody;
- bool m_bPhantom; // special flag for objects that are not affected by physics 'resolver'
-
- // data to calculate fake velocities for kinematic objects (non-dynas)
- bool m_bKinematic;
- bool m_bPrevKinematic;
-
- float m_lastTime;
-
- class PHY_IMotionState* m_MotionState;
-
-
-};
-
-///SumoDefaultMotionState implements standard motionstate, using btTransform
-class SumoDefaultMotionState : public PHY_IMotionState
-
-{
- public:
- SumoDefaultMotionState();
-
- virtual ~SumoDefaultMotionState();
-
- virtual void getWorldPosition(float& posX,float& posY,float& posZ);
- virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ);
- virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal);
-
- virtual void setWorldPosition(float posX,float posY,float posZ);
- virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal);
- virtual void getWorldOrientation(float* ori);
- virtual void setWorldOrientation(const float* ori);
-
- virtual void calculateWorldTransformations();
-
- MT_Transform m_worldTransform;
- MT_Vector3 m_localScaling;
-
-};
-
-#endif //__SUMO_PHYSICSCONTROLLER_H
-
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
deleted file mode 100644
index 941a41b1396..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include <string.h> // memset
-#include "SumoPhysicsEnvironment.h"
-#include "PHY_IMotionState.h"
-#include "SumoPhysicsController.h"
-#include "SM_Scene.h"
-#include "SumoPHYCallbackBridge.h"
-#include <SOLID/SOLID.h>
-
-SumoPhysicsEnvironment::SumoPhysicsEnvironment()
-{
- m_fixedTimeStep = 1.f/60.f;
- m_useFixedTimeStep = true;
- m_currentTime = 0.f;
-
- m_sumoScene = new SM_Scene();
-}
-
-
-
-SumoPhysicsEnvironment::~SumoPhysicsEnvironment()
-{
- delete m_sumoScene;
-}
-
-
-
-void SumoPhysicsEnvironment::beginFrame()
-{
- m_sumoScene->beginFrame();
-}
-
-void SumoPhysicsEnvironment::endFrame()
-{
- m_sumoScene->endFrame();
-}
-
-void SumoPhysicsEnvironment::setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
-{
- m_useFixedTimeStep = useFixedTimeStep;
- if (m_useFixedTimeStep)
- {
- m_fixedTimeStep = fixedTimeStep;
- } else
- {
- m_fixedTimeStep = 0.f;
- }
- //reset current time ?
- m_currentTime = 0.f;
-}
-float SumoPhysicsEnvironment::getFixedTimeStep()
-{
- return m_fixedTimeStep;
-}
-
-
-bool SumoPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval)
-{
-
- bool result = false;
- if (m_useFixedTimeStep)
- {
- m_currentTime += timeStep;
- float ticrate = 1.f/m_fixedTimeStep;
-
- result = m_sumoScene->proceed(curTime, ticrate);
- } else
- {
- m_currentTime += timeStep;
- result = m_sumoScene->proceed(m_currentTime, timeStep);
- }
- return result;
-}
-
-void SumoPhysicsEnvironment::setGravity(float x,float y,float z)
-{
- m_sumoScene->setForceField(MT_Vector3(x,y,z));
-}
-
-int SumoPhysicsEnvironment::createConstraint(
- class PHY_IPhysicsController* ctrl,
- class PHY_IPhysicsController* ctrl2,
- PHY_ConstraintType type,
- float pivotX,float pivotY,float pivotZ,
- float axisX,float axisY,float axisZ,
- float axis1X,float axis1Y,float axis1Z,
- float axis2X,float axis2Y,float axis2Z,
- int flag
- )
-{
- int constraintid = 0;
- return constraintid;
-}
-
-void SumoPhysicsEnvironment::removeConstraint(int constraintid)
-{
- if (constraintid)
- {
- }
-}
-
-PHY_IPhysicsController* SumoPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,
- float fromX,float fromY,float fromZ,
- float toX,float toY,float toZ)
-{
- SumoPhysicsController* ignoreCtr = static_cast<SumoPhysicsController*> (filterCallback.m_ignoreController);
-
- //collision detection / raytesting
- MT_Point3 hit, normal;
- PHY_RayCastResult result;
-
- SM_Object* sm_ignore = 0;
- if (ignoreCtr)
- sm_ignore = ignoreCtr->GetSumoObject();
-
- memset(&result, 0, sizeof(result));
-
- SM_Object* smOb = m_sumoScene->rayTest(sm_ignore,MT_Point3(fromX, fromY, fromZ),MT_Point3(toX, toY, toZ), hit, normal);
- if (smOb)
- {
- result.m_controller = (PHY_IPhysicsController *) smOb->getPhysicsClientObject();
- result.m_hitPoint[0] = hit[0];
- result.m_hitPoint[1] = hit[1];
- result.m_hitPoint[2] = hit[2];
- result.m_hitNormal[0] = normal[0];
- result.m_hitNormal[1] = normal[1];
- result.m_hitNormal[2] = normal[2];
- filterCallback.reportHit(&result);
- }
- return result.m_controller;
-}
-//gamelogic callbacks
-void SumoPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
-{
- SumoPhysicsController* smctrl = dynamic_cast<SumoPhysicsController*>(ctrl);
- SM_Object* smObject = smctrl->GetSumoObject();
- assert(smObject);
- if (smObject)
- {
- m_sumoScene->addSensor(*smObject);
- }
-}
-void SumoPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl)
-{
- SumoPhysicsController* smctrl = dynamic_cast<SumoPhysicsController*>(ctrl);
- SM_Object* smObject = smctrl->GetSumoObject();
- assert(smObject);
- if (smObject)
- {
- m_sumoScene->remove(*smObject);
- }
-}
-
-
-void SumoPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
-{
-
- int sumoRespClass = 0;
-
- //map PHY_ convention into SM_ convention
- switch (response_class)
- {
- case PHY_FH_RESPONSE:
- sumoRespClass = FH_RESPONSE;
- break;
- case PHY_SENSOR_RESPONSE:
- sumoRespClass = SENSOR_RESPONSE;
- break;
- case PHY_CAMERA_RESPONSE:
- sumoRespClass =CAMERA_RESPONSE;
- break;
- case PHY_OBJECT_RESPONSE:
- sumoRespClass = OBJECT_RESPONSE;
- break;
- case PHY_STATIC_RESPONSE:
- sumoRespClass = PHY_STATIC_RESPONSE;
- break;
- case PHY_BROADPH_RESPONSE:
- return;
- default:
- assert(0);
- return;
- }
-
- SumoPHYCallbackBridge* bridge = new SumoPHYCallbackBridge(user,callback);
-
- m_sumoScene->addTouchCallback(sumoRespClass,SumoPHYCallbackBridge::StaticSolidToPHYCallback,bridge);
-}
-bool SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
-{
- SumoPhysicsController* smctrl = dynamic_cast<SumoPhysicsController*>(ctrl);
- MT_assert(smctrl);
- SM_Object* smObject = smctrl->GetSumoObject();
- MT_assert(smObject);
- if (smObject)
- {
- //assert(smObject->getPhysicsClientObject() == ctrl);
- smObject->setPhysicsClientObject(ctrl);
-
- m_sumoScene->requestCollisionCallback(*smObject);
- return true;
- }
- return false;
-}
-
-bool SumoPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
-{
- // intentionally empty
- return false;
-}
-
-PHY_IPhysicsController* SumoPhysicsEnvironment::CreateSphereController(float radius,const PHY__Vector3& position)
-{
- DT_ShapeHandle shape = DT_NewSphere(0.0);
- SM_Object* ob = new SM_Object(shape,0,0,0);
- ob->setPosition(MT_Point3(position));
- //testing
- MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
- ob->setOrientation(rotquatje);
- PHY_IMotionState* motionState = new SumoDefaultMotionState();
- PHY_IPhysicsController* ctrl = new SumoPhysicsController(m_sumoScene,ob,motionState,false);
- ctrl->SetMargin(radius);
- return ctrl;
-}
-PHY_IPhysicsController* SumoPhysicsEnvironment::CreateConeController(float coneradius,float coneheight)
-{
- DT_ShapeHandle shape = DT_NewCone(coneradius,coneheight);
- SM_Object* ob = new SM_Object(shape,0,0,0);
- ob->setPosition(MT_Point3(0.f,0.f,0.f));
- MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
- ob->setOrientation(rotquatje);
- PHY_IMotionState* motionState = new SumoDefaultMotionState();
-
- PHY_IPhysicsController* ctrl = new SumoPhysicsController(m_sumoScene,ob,motionState,false);
-
- return ctrl;
-}
-
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
deleted file mode 100644
index 5ae33eb4b0e..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef _SUMOPhysicsEnvironment
-#define _SUMOPhysicsEnvironment
-
-#include "MT_Scalar.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-class SumoPHYCallbackBridge;
-#include <vector>
-/**
-* Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.)
-* A derived class may be able to 'construct' entities by loading and/or converting
-*/
-class SumoPhysicsEnvironment : public PHY_IPhysicsEnvironment
-{
-
- class SM_Scene* m_sumoScene;
- float m_currentTime;
- float m_fixedTimeStep;
- bool m_useFixedTimeStep;
-
- std::vector<SumoPHYCallbackBridge*> m_callbacks;
-
-public:
- SumoPhysicsEnvironment();
- virtual ~SumoPhysicsEnvironment();
- virtual void beginFrame();
- virtual void endFrame();
-// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
- virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
- virtual float getFixedTimeStep();
-
- virtual void setGravity(float x,float y,float z);
- virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
- float pivotX,float pivotY,float pivotZ,
- float axisX,float axisY,float axisZ,
- float axis1X=0,float axis1Y=0,float axis1Z=0,
- float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
-
- );
-
- virtual void removeConstraint(int constraintid);
-
- //complex constraint for vehicles
- virtual PHY_IVehicle* getVehicleConstraint(int constraintId)
- {
- return 0;
- }
-
- virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
- virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4 *planes, int nplanes, int occlusionRes) { return false; }
-
-
- //gamelogic callbacks
- virtual void addSensor(PHY_IPhysicsController* ctrl);
- virtual void removeSensor(PHY_IPhysicsController* ctrl);
- virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
- virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position);
- virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
-
- virtual float getConstraintParam(int constraintId,int param)
- {
- return 0.f;
- }
- virtual void setConstraintParam(int constraintId,int param,float value,float value1)
- {
- }
- SM_Scene* GetSumoScene()
- {
- return m_sumoScene;
- }
-
-protected:
- // 60Hz (Default)
- static MT_Scalar PhysicsTicRate;
-
-};
-
-#endif //_SUMOPhysicsEnvironment
-
diff --git a/source/gameengine/Physics/Sumo/convert.txt b/source/gameengine/Physics/Sumo/convert.txt
deleted file mode 100644
index 81f8f602cde..00000000000
--- a/source/gameengine/Physics/Sumo/convert.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj)
-{
- DT_ShapeHandle shape = DT_NewComplexShape();
- int numpolys = meshobj->NumPolygons();
- int numvalidpolys = 0;
-
- for (int p=0; p<numpolys; p++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- DT_Begin();
- for (int v=0; v<poly->VertexCount(); v++) {
- MT_Point3 pt = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[v],
- poly->GetMaterial()->GetPolyMaterial())->xyz();
- DT_Vertex(pt[0],pt[1],pt[2]);
- }
- DT_End();
-
- numvalidpolys++;
- }
- }
-
- DT_EndComplexShape();
-
- if (numvalidpolys==0) {
- delete shape;
- return NULL;
- } else {
- return shape;
- }
-}
diff --git a/source/gameengine/Physics/Sumo/include/interpolator.h b/source/gameengine/Physics/Sumo/include/interpolator.h
deleted file mode 100644
index 055c242edc7..00000000000
--- a/source/gameengine/Physics/Sumo/include/interpolator.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef INTERPOLATOR_H
-#define INTERPOLATOR_H
-
-#include "solid_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-DT_DECLARE_HANDLE(IP_IpoHandle);
-
-typedef struct IP_ControlPoint {
- DT_Scalar m_key;
- DT_Scalar m_keyValue;
-} IP_ControlPoint;
-
-IP_IpoHandle IP_CreateLinear(const IP_ControlPoint *cpoints, int num_cpoints);
-
-void IP_DeleteInterpolator(IP_IpoHandle ipo);
-
-DT_Scalar IP_GetValue(IP_IpoHandle ipo, DT_Scalar key);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source/gameengine/Physics/common/Makefile b/source/gameengine/Physics/common/Makefile
index e3edd426c36..f2dd0134b71 100644
--- a/source/gameengine/Physics/common/Makefile
+++ b/source/gameengine/Physics/common/Makefile
@@ -40,7 +40,7 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO)/include -I$(NAN_MOTO)/include
+CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I../../blender
# these two needed because of blenkernel
CPPFLAGS += -I../../blender/makesdna
diff --git a/source/gameengine/Physics/common/SConscript b/source/gameengine/Physics/common/SConscript
index 05c6f17a4a0..447b0ec1bbb 100644
--- a/source/gameengine/Physics/common/SConscript
+++ b/source/gameengine/Physics/common/SConscript
@@ -6,8 +6,9 @@ sources = 'PHY_IMotionState.cpp PHY_IController.cpp PHY_IPhysicsController.cpp P
incs = '. ../Dummy #intern/moto/include'
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
-env.BlenderLib ( 'bf_common', Split(sources), Split(incs), [], libtype=['game', 'game2','player'], priority=[20, 35, 95], cxx_compileflags = cxxflags )
+env.BlenderLib ( 'bf_common', Split(sources), Split(incs), [], libtype=['core','player'], priority=[360, 90], cxx_compileflags = cxxflags )
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 83ba2778ad6..d16348defb2 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -451,10 +451,10 @@ RAS_IRasterizer::StereoMode RAS_OpenGLRasterizer::GetStereoMode()
bool RAS_OpenGLRasterizer::Stereo()
{
- if(m_stereomode == RAS_STEREO_NOSTEREO || m_stereomode == RAS_STEREO_DOME)
- return false;
- else
+ if(m_stereomode > RAS_STEREO_NOSTEREO) // > 0
return true;
+ else
+ return false;
}
bool RAS_OpenGLRasterizer::InterlacedStereo()
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
index d4b029ea34d..e206c90ea25 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
@@ -9,8 +9,9 @@ incs += ' #source/blender/gameengine/Ketsji #source/gameengine/SceneGraph #sourc
incs += ' #intern/guardedalloc #source/blender/blenlib'
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
-env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), [], libtype=['game','player'], priority=[40, 120], cxx_compileflags = cxxflags )
+env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), [], libtype=['core','player'], priority=[350, 115], cxx_compileflags = cxxflags )
diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript
index 771d3399485..255131f9a44 100644
--- a/source/gameengine/Rasterizer/SConscript
+++ b/source/gameengine/Rasterizer/SConscript
@@ -8,8 +8,9 @@ incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/
incs += ' ' + env['BF_PYTHON_INC']
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
-env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), [], libtype=['game','player'], priority=[35,115], cxx_compileflags = cxxflags )
+env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), [], libtype=['core','player'], priority=[350,115], cxx_compileflags = cxxflags )
diff --git a/source/gameengine/SConscript b/source/gameengine/SConscript
index 51a05e70a07..592b138583f 100644
--- a/source/gameengine/SConscript
+++ b/source/gameengine/SConscript
@@ -3,7 +3,7 @@ Import ('env')
SConscript(['BlenderRoutines/SConscript',
'Converter/SConscript',
- 'Expressions/SConscript',
+ 'Expressions/SConscript', #310
'GameLogic/SConscript',
'Ketsji/SConscript',
'Ketsji/KXNetwork/SConscript',
@@ -18,13 +18,5 @@ SConscript(['BlenderRoutines/SConscript',
'VideoTexture/SConscript'
])
-if env['WITH_BF_SOLID']:
- SConscript(['Physics/Sumo/SConscript'])
-
if env['WITH_BF_PLAYER']:
SConscript(['GamePlayer/SConscript'])
-
-#if user_options_dict['USE_PHYSICS'] == 'solid':
-# SConscript(['Physics/Sumo/SConscript'])
-#elif user_options_dict['USE_PHYSICS'] == 'ode':
-# SConscript(['Physics/BlOde/SConscript'])
diff --git a/source/gameengine/SceneGraph/SConscript b/source/gameengine/SceneGraph/SConscript
index 8ebf9c0b850..b3db50117f1 100644
--- a/source/gameengine/SceneGraph/SConscript
+++ b/source/gameengine/SceneGraph/SConscript
@@ -2,13 +2,14 @@
Import ('env')
-sources = env.Glob('*.cpp') #'SG_BBox.cpp SG_Controller.cpp SG_IObject.cpp SG_Node.cpp SG_Spatial.cpp SG_Tree.cpp'
+sources = env.Glob('*.cpp')
incs = '. #intern/moto/include'
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
-env.BlenderLib ( 'bf_scenegraph', sources, Split(incs), [], libtype=['game','player'], priority=[50,130], cxx_compileflags = cxxflags )
+env.BlenderLib ( 'bf_scenegraph', sources, Split(incs), [], libtype=['core','player'], priority=[325,125], cxx_compileflags = cxxflags )
diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt
index 1fca5374991..9d1bb89d2ca 100644
--- a/source/gameengine/VideoTexture/CMakeLists.txt
+++ b/source/gameengine/VideoTexture/CMakeLists.txt
@@ -39,6 +39,7 @@ SET(INC
../../../source/blender/blenlib
../../../source/blender/blenkernel
../../../source/blender/makesdna
+ ../../../source/blender/editors/include
../../../source/blender/imbuf
../../../source/blender/python
../../../source/blender/gpu
diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp
index 6b23105a278..6d26e5b6d35 100644
--- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp
+++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp
@@ -81,17 +81,17 @@ static int setColor (PyFilter * self, PyObject * value, void * closure)
{
// check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 3
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1))
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 2)))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2)))
{
PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 3 ints");
return -1;
}
// set color
- getFilter(self)->setColor((unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))),
- (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2))));
+ getFilter(self)->setColor((unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
+ (unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1))),
+ (unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2))));
// success
return 0;
}
@@ -108,15 +108,15 @@ static int setLimits (PyFilter * self, PyObject * value, void * closure)
{
// check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
{
PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
return -1;
}
// set limits
- getFilter(self)->setLimits((unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- (unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))));
+ getFilter(self)->setLimits((unsigned short)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
+ (unsigned short)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1))));
// success
return 0;
}
diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp
index 5ff1f7f11ce..eb86f520e02 100644
--- a/source/gameengine/VideoTexture/FilterColor.cpp
+++ b/source/gameengine/VideoTexture/FilterColor.cpp
@@ -147,10 +147,10 @@ static int setMatrix (PyFilter * self, PyObject * value, void * closure)
for (int c = 0; valid && c < 5; ++c)
{
// item must be int
- valid = PyInt_Check(PySequence_Fast_GET_ITEM(row, c));
+ valid = PyLong_Check(PySequence_Fast_GET_ITEM(row, c));
// if it is valid, save it in matrix
if (valid)
- mat[r][c] = short(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c)));
+ mat[r][c] = short(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(row, c)));
}
}
// if parameter is not valid, report error
@@ -286,10 +286,10 @@ static int setLevels (PyFilter * self, PyObject * value, void * closure)
for (int c = 0; valid && c < 2; ++c)
{
// item must be int
- valid = PyInt_Check(PySequence_Fast_GET_ITEM(row, c));
+ valid = PyLong_Check(PySequence_Fast_GET_ITEM(row, c));
// if it is valid, save it in matrix
if (valid)
- lev[r][c] = (unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c)));
+ lev[r][c] = (unsigned short)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(row, c)));
}
}
// if parameter is not valid, report error
diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp
index 9a2b1e90d5a..002be6c3189 100644
--- a/source/gameengine/VideoTexture/FilterNormal.cpp
+++ b/source/gameengine/VideoTexture/FilterNormal.cpp
@@ -72,13 +72,13 @@ static PyObject * getColor (PyFilter * self, void * closure)
static int setColor (PyFilter * self, PyObject * value, void * closure)
{
// check validity of parameter
- if (value == NULL || !PyInt_Check(value))
+ if (value == NULL || !PyLong_Check(value))
{
PyErr_SetString(PyExc_TypeError, "filt.colorIdx = int: VideoTexture.FilterNormal, expected the value must be a int");
return -1;
}
// set color index
- getFilter(self)->setColor((unsigned short)(PyInt_AsLong(value)));
+ getFilter(self)->setColor((unsigned short)(PyLong_AsSsize_t(value)));
// success
return 0;
}
diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp
index 7ceb9e58c7a..d8be08e0eb5 100644
--- a/source/gameengine/VideoTexture/ImageRender.cpp
+++ b/source/gameengine/VideoTexture/ImageRender.cpp
@@ -28,7 +28,7 @@ http://www.gnu.org/copyleft/lesser.txt.
#include <math.h>
-#include <BIF_gl.h>
+#include "GL/glew.h"
#include "KX_PythonInit.h"
#include "DNA_scene_types.h"
@@ -331,19 +331,19 @@ static int setBackground (PyImage * self, PyObject * value, void * closure)
{
// check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 4
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1))
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 2))
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 3)))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 3)))
{
PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 4 integer between 0 and 255");
return -1;
}
// set background color
- getImageRender(self)->setBackground((unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))),
- (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2))),
- (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 3))));
+ getImageRender(self)->setBackground((unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
+ (unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1))),
+ (unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 2))),
+ (unsigned char)(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 3))));
// success
return 0;
}
diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp
index b808b06eb2b..55b14396280 100644
--- a/source/gameengine/VideoTexture/ImageViewport.cpp
+++ b/source/gameengine/VideoTexture/ImageViewport.cpp
@@ -25,7 +25,7 @@ http://www.gnu.org/copyleft/lesser.txt.
#include <PyObjectPlus.h>
#include <structmember.h>
-#include <BIF_gl.h>
+#include "GL/glew.h"
#include "Texture.h"
#include "ImageBase.h"
@@ -218,16 +218,16 @@ static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * c
{
// check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
{
PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
return -1;
}
// set position
GLint pos [] = {
- GLint(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- GLint(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
+ GLint(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
+ GLint(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1)))
};
getImageViewport(self)->setPosition(pos);
// success
@@ -246,16 +246,16 @@ int ImageViewport_setCaptureSize (PyImage * self, PyObject * value, void * closu
{
// check validity of parameter
if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
- || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
{
PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
return -1;
}
// set capture size
short size [] = {
- short(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- short(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
+ short(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))),
+ short(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1)))
};
getImageViewport(self)->setCaptureSize(size);
// success
diff --git a/source/gameengine/VideoTexture/Makefile b/source/gameengine/VideoTexture/Makefile
index a4611937a65..8677ed5c177 100644
--- a/source/gameengine/VideoTexture/Makefile
+++ b/source/gameengine/VideoTexture/Makefile
@@ -51,7 +51,7 @@ CPPFLAGS += -I../../kernel/gen_system
CPPFLAGS += -I.
CPPFLAGS += -I../../blender/blenkernel
CPPFLAGS += -I../../blender/blenlib
-CPPFLAGS += -I../../blender/include
+CPPFLAGS += -I../../blender/editors/include
CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I../../blender/imbuf
CPPFLAGS += -I../../blender/gpu
diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript
index edd44f98783..fdf46f70ad7 100644
--- a/source/gameengine/VideoTexture/SConscript
+++ b/source/gameengine/VideoTexture/SConscript
@@ -9,25 +9,28 @@ incs = '. #source/gameengine/Ketsji #source/gameengine/Expressions'
incs += ' #source/gameengine/GameLogic #source/gameengine/SceneGraph #source/gameengine/Rasterizer'
incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer'
incs += ' #source/gameengine/BlenderRoutines'
-incs += ' #source/blender/include #source/blender/blenlib #source/blender/blenkernel'
+incs += ' #source/blender/editors/include #source/blender/blenlib #source/blender/blenkernel'
incs += ' #source/blender/makesdna #source/blender/imbuf #source/blender/python'
incs += ' #source/blender/gpu #source/kernel/gen_system #intern/string #intern/moto/include'
incs += ' #intern/guardedalloc #intern/SoundSystem'
incs += ' #extern/glew/include'
-defs = ''
+defs = []
cxxflags = []
-if env['OURPLATFORM']=='win32-vc':
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
cxxflags.append ('/GR')
cxxflags.append ('/O2')
+ cxxflags.append ('/EHsc')
+ if env['BF_DEBUG']:
+ defs.append('_DEBUG')
incs += ' ' + env['BF_PYTHON_INC']
#incs += ' ' + env['BF_OPENGL_INC']
if env['WITH_BF_FFMPEG']:
- defs += ' WITH_FFMPEG'
+ defs.append('WITH_FFMPEG')
incs += ' ' + env['BF_FFMPEG_INC'] + ' ' + env['BF_PTHREADS_INC']
- defs += ' __STDC_CONSTANT_MACROS'
+ defs.append('__STDC_CONSTANT_MACROS')
-env.BlenderLib ( 'bf_videotex', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[25, 72], cxx_compileflags = cxxflags )
+env.BlenderLib ( 'bf_videotex', sources, Split(incs), defs, libtype=['core','player'], priority=[300, 72], cxx_compileflags = cxxflags )
diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp
index 51d96d7596e..f4105652f80 100644
--- a/source/gameengine/VideoTexture/Texture.cpp
+++ b/source/gameengine/VideoTexture/Texture.cpp
@@ -31,7 +31,6 @@ http://www.gnu.org/copyleft/lesser.txt.
#include <DNA_meshdata_types.h>
#include <DNA_image_types.h>
#include <IMB_imbuf_types.h>
-#include <BDR_drawmesh.h>
#include <KX_PolygonMaterial.h>
#include <MEM_guardedalloc.h>
@@ -46,7 +45,7 @@ http://www.gnu.org/copyleft/lesser.txt.
#include "Exception.h"
#include <memory.h>
-#include <BIF_gl.h>
+#include "GL/glew.h"
// macro for exception handling and logging
diff --git a/source/gameengine/VideoTexture/VideoBase.cpp b/source/gameengine/VideoTexture/VideoBase.cpp
index 5d449a158d8..5de7a9e80a9 100644
--- a/source/gameengine/VideoTexture/VideoBase.cpp
+++ b/source/gameengine/VideoTexture/VideoBase.cpp
@@ -167,13 +167,13 @@ PyObject * Video_getRepeat (PyImage * self, void * closure)
int Video_setRepeat (PyImage * self, PyObject * value, void * closure)
{
// check validity of parameter
- if (value == NULL || !PyInt_Check(value))
+ if (value == NULL || !PyLong_Check(value))
{
PyErr_SetString(PyExc_TypeError, "The value must be an int");
return -1;
}
// set repeat
- getVideo(self)->setRepeat(int(PyInt_AsLong(value)));
+ getVideo(self)->setRepeat(int(PyLong_AsSsize_t(value)));
// success
return 0;
}
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
index 1a5481488c0..cf4ea88c1b5 100644
--- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp
+++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
@@ -1095,13 +1095,13 @@ PyObject * VideoFFmpeg_getPreseek (PyImage *self, void * closure)
int VideoFFmpeg_setPreseek (PyImage * self, PyObject * value, void * closure)
{
// check validity of parameter
- if (value == NULL || !PyInt_Check(value))
+ if (value == NULL || !PyLong_Check(value))
{
PyErr_SetString(PyExc_TypeError, "The value must be an integer");
return -1;
}
// set preseek
- getFFmpeg(self)->setPreseek(PyInt_AsLong(value));
+ getFFmpeg(self)->setPreseek(PyLong_AsSsize_t(value));
// success
return 0;
}
diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp
index dad52a426b6..22171f69321 100644
--- a/source/gameengine/VideoTexture/blendVideoTex.cpp
+++ b/source/gameengine/VideoTexture/blendVideoTex.cpp
@@ -67,7 +67,7 @@ static PyObject * getMaterialID (PyObject *self, PyObject *args)
// get last error description
static PyObject * getLastError (PyObject *self, PyObject *args)
{
- return PyString_FromString(Exception::m_lastError.c_str());
+ return PyUnicode_FromString(Exception::m_lastError.c_str());
}
// set log file