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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-09 00:08:19 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-09 00:08:19 +0400
commitc8b4cf92067ffeb625aa39003baf5d8f7c3f0025 (patch)
treec6c50dbc3d90a65fca6c1ca56a93e4a57cf7e154
parente93db433a086a3e739c0f4026cd500f0b595b0f1 (diff)
parentd76a6f5231c015c35123d22e1f5c3ffcdfbf9bbd (diff)
2.50:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19820:HEAD Notes: * Game and sequencer RNA, and sequencer header are now out of date a bit after changes in trunk. * I didn't know how to port these bugfixes, most likely they are not needed anymore. * Fix "duplicate strip" always increase the user count for ipo. * IPO pinning on sequencer strips was lost during Undo.
-rw-r--r--CMake/macros.cmake19
-rw-r--r--CMakeLists.txt28
-rw-r--r--config/irix6-config.py5
-rw-r--r--config/linux2-config.py18
-rw-r--r--extern/CMakeLists.txt11
-rw-r--r--extern/Makefile7
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp60
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h29
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h2
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp216
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h43
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp18
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp76
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h11
-rw-r--r--extern/bullet2/src/CMakeLists.txt5
-rw-r--r--extern/bullet2/src/LinearMath/btScalar.h4
-rw-r--r--extern/libopenjpeg/jp2.c1
-rw-r--r--intern/CMakeLists.txt16
-rw-r--r--intern/SoundSystem/fmod/Makefile43
-rw-r--r--intern/SoundSystem/fmod/SND_FmodDevice.cpp574
-rw-r--r--intern/SoundSystem/fmod/SND_FmodDevice.h103
-rw-r--r--intern/SoundSystem/openal/SND_OpenALDevice.cpp290
-rw-r--r--intern/SoundSystem/sdl/SND_SDLCDDevice.cpp2
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.cpp24
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.h8
-rw-r--r--intern/guardedalloc/intern/mmap_win.c1
-rw-r--r--projectfiles_vc9/gameengine/converter/KX_converter.vcproj16
-rw-r--r--projectfiles_vc9/gameengine/expression/EXP_expressions.vcproj13
-rw-r--r--projectfiles_vc9/gameengine/gamelogic/SCA_GameLogic.vcproj13
-rw-r--r--projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj3
-rw-r--r--projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj8
-rw-r--r--projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj13
-rw-r--r--projectfiles_vc9/gameengine/physics/PHY_Physics/PHY_Bullet/PHY_Bullet.vcproj12
-rw-r--r--projectfiles_vc9/gameengine/rasterizer/RAS_rasterizer.vcproj13
-rw-r--r--projectfiles_vc9/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj12
-rw-r--r--projectfiles_vc9/gameengine/scenegraph/SG_SceneGraph.vcproj9
-rw-r--r--projectfiles_vc9/gameengine/videotexture/TEX_Video.vcproj1
-rw-r--r--release/Makefile2
-rw-r--r--release/datafiles/splash.jpgbin288981 -> 196913 bytes
-rw-r--r--release/scripts/3ds_export.py12
-rw-r--r--release/scripts/3ds_import.py14
-rw-r--r--release/scripts/DirectX8Exporter.py3
-rw-r--r--release/scripts/add_mesh_torus.py8
-rw-r--r--release/scripts/animation_clean.py192
-rw-r--r--release/scripts/bpymodules/BPyMathutils.py3
-rw-r--r--release/scripts/bpymodules/BPyMesh.py6
-rw-r--r--release/scripts/bpymodules/BPyMesh_octree.py332
-rw-r--r--release/scripts/bpymodules/BPyMesh_redux.py5
-rw-r--r--release/scripts/bpymodules/BPyWindow.py2
-rw-r--r--release/scripts/bpymodules/dxfLibrary.py64
-rw-r--r--release/scripts/bpymodules/mesh_gradient.py6
-rw-r--r--release/scripts/bpymodules/paths_svg2obj.py41
-rw-r--r--release/scripts/c3d_import.py7
-rw-r--r--release/scripts/console.py75
-rw-r--r--release/scripts/envelope_symmetry.py2
-rw-r--r--release/scripts/export_dxf.py2822
-rw-r--r--release/scripts/export_fbx.py271
-rw-r--r--release/scripts/export_obj.py106
-rw-r--r--release/scripts/help_bpy_api.py12
-rw-r--r--release/scripts/help_getting_started.py12
-rw-r--r--release/scripts/help_manual.py12
-rw-r--r--release/scripts/help_release_notes.py10
-rw-r--r--release/scripts/help_tutorials.py10
-rw-r--r--release/scripts/help_web_blender.py10
-rw-r--r--release/scripts/help_web_devcomm.py10
-rw-r--r--release/scripts/help_web_eshop.py10
-rw-r--r--release/scripts/help_web_usercomm.py10
-rw-r--r--release/scripts/image_2d_cutout.py559
-rw-r--r--release/scripts/import_dxf.py87
-rw-r--r--release/scripts/import_obj.py70
-rw-r--r--release/scripts/import_web3d.py2
-rw-r--r--release/scripts/lightwave_export.py61
-rw-r--r--release/scripts/md2_export.py103
-rw-r--r--release/scripts/mesh_mirror_tool.py8
-rw-r--r--release/scripts/mesh_poly_reduce_grid.py4
-rw-r--r--release/scripts/mesh_skin.py8
-rw-r--r--release/scripts/mesh_unfolder.py6
-rw-r--r--release/scripts/object_active_to_other.py58
-rw-r--r--release/scripts/object_cookie_cutter.py24
-rw-r--r--release/scripts/object_drop.py64
-rw-r--r--release/scripts/ply_import.py2
-rw-r--r--release/scripts/rvk1_torvk2.py394
-rw-r--r--release/scripts/scripttemplate_gamelogic.py52
-rw-r--r--release/scripts/scripttemplate_gamelogic_basic.py14
-rw-r--r--release/scripts/scripttemplate_gamelogic_module.py45
-rw-r--r--release/scripts/textplugin_convert_ge.py863
-rw-r--r--release/scripts/uvcalc_quad_clickproj.py4
-rw-r--r--release/scripts/uvcalc_smart_project.py18
-rw-r--r--release/scripts/vertexpaint_selfshadow_ao.py7
-rw-r--r--release/scripts/wizard_bolt_factory.py2804
-rw-r--r--release/scripts/wizard_curve2tree.py34
-rw-r--r--release/scripts/wizard_landscape_ant.py2148
-rw-r--r--release/scripts/xfig_export.py234
-rw-r--r--release/ui/space_sequencer.py1
-rw-r--r--source/CMakeLists.txt7
-rw-r--r--source/Makefile12
-rw-r--r--source/blender/CMakeLists.txt27
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h3
-rw-r--r--source/blender/blenkernel/BKE_scene.h1
-rw-r--r--source/blender/blenkernel/BKE_sequence.h8
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c25
-rw-r--r--source/blender/blenkernel/intern/Makefile2
-rw-r--r--source/blender/blenkernel/intern/blender.c15
-rw-r--r--source/blender/blenkernel/intern/bmfont.c2
-rw-r--r--source/blender/blenkernel/intern/bullet.c1
-rw-r--r--source/blender/blenkernel/intern/cloth.c11
-rw-r--r--source/blender/blenkernel/intern/constraint.c2
-rw-r--r--source/blender/blenkernel/intern/customdata.c22
-rw-r--r--source/blender/blenkernel/intern/displist.c2
-rw-r--r--source/blender/blenkernel/intern/effect.c10
-rw-r--r--source/blender/blenkernel/intern/exotic.c18
-rw-r--r--source/blender/blenkernel/intern/font.c6
-rw-r--r--source/blender/blenkernel/intern/image.c9
-rw-r--r--source/blender/blenkernel/intern/ipo.c1
-rw-r--r--source/blender/blenkernel/intern/mball.c5
-rw-r--r--source/blender/blenkernel/intern/modifier.c98
-rw-r--r--source/blender/blenkernel/intern/node.c9
-rw-r--r--source/blender/blenkernel/intern/object.c5
-rw-r--r--source/blender/blenkernel/intern/particle.c14
-rw-r--r--source/blender/blenkernel/intern/particle_system.c11
-rw-r--r--source/blender/blenkernel/intern/sca.c11
-rw-r--r--source/blender/blenkernel/intern/scene.c20
-rw-r--r--source/blender/blenkernel/intern/sequence.c284
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c2
-rw-r--r--source/blender/blenkernel/intern/softbody.c8
-rw-r--r--source/blender/blenkernel/intern/world.c4
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c3
-rw-r--r--source/blender/blenlib/BLI_string.h1
-rw-r--r--source/blender/blenlib/BLI_vfontdata.h2
-rw-r--r--source/blender/blenlib/intern/storage.c7
-rw-r--r--source/blender/blenlib/intern/string.c48
-rw-r--r--source/blender/blenlib/intern/util.c3
-rw-r--r--source/blender/blenloader/intern/readfile.c111
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c1
-rw-r--r--source/blender/editors/armature/editarmature.c1
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c2
-rw-r--r--source/blender/editors/armature/poseobject.c27
-rw-r--r--source/blender/editors/armature/reeb.c2
-rw-r--r--source/blender/editors/curve/editfont.c4
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c12
-rw-r--r--source/blender/editors/interface/interface_layout.c2
-rw-r--r--source/blender/editors/mesh/editdeform.c61
-rw-r--r--source/blender/editors/mesh/meshtools.c12
-rw-r--r--source/blender/editors/object/object_edit.c6
-rw-r--r--source/blender/editors/physics/editparticle.c13
-rw-r--r--source/blender/editors/preview/previewrender.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c197
-rw-r--r--source/blender/editors/space_buttons/buttons_header.c2
-rw-r--r--source/blender/editors/space_file/file_ops.c2
-rw-r--r--source/blender/editors/space_file/filelist.c6
-rw-r--r--source/blender/editors/space_image/image_ops.c5
-rw-r--r--source/blender/editors/space_node/node_edit.c50
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c34
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c25
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c8
-rw-r--r--source/blender/gpu/GPU_material.h1
-rw-r--r--source/blender/gpu/intern/gpu_draw.c21
-rw-r--r--source/blender/gpu/intern/gpu_material.c10
-rw-r--r--source/blender/imbuf/IMB_imbuf.h1
-rw-r--r--source/blender/imbuf/intern/anim.c5
-rw-r--r--source/blender/imbuf/intern/imageprocess.c77
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp19
-rw-r--r--source/blender/imbuf/intern/rotate.c6
-rw-r--r--source/blender/imbuf/intern/scaling.c67
-rw-r--r--source/blender/makesdna/CMakeLists.txt2
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h9
-rw-r--r--source/blender/makesdna/DNA_controller_types.h7
-rw-r--r--source/blender/makesdna/DNA_object_force.h5
-rw-r--r--source/blender/makesdna/DNA_object_types.h4
-rw-r--r--source/blender/makesdna/DNA_scene_types.h8
-rw-r--r--source/blender/makesdna/DNA_sensor_types.h3
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h3
-rw-r--r--source/blender/makesdna/DNA_space_types.h11
-rw-r--r--source/blender/makesdna/DNA_world_types.h1
-rw-r--r--source/blender/makesrna/CMakeLists.txt2
-rw-r--r--source/blender/makesrna/RNA_access.h4
-rw-r--r--source/blender/makesrna/intern/rna_access.c4
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c4
-rw-r--r--source/blender/makesrna/intern/rna_object.c4
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c4
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_normalize.c19
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_scale.c4
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c11
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_material.c2
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_math.c2
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c2
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_bricks.c18
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_translate.c2
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h1
-rw-r--r--source/blender/render/intern/source/convertblender.c2
-rw-r--r--source/blender/render/intern/source/occlusion.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c49
-rw-r--r--source/blender/render/intern/source/rayshade.c35
-rw-r--r--source/blender/render/intern/source/rendercore.c8
-rw-r--r--source/blender/render/intern/source/shadeoutput.c5
-rw-r--r--source/blender/render/intern/source/texture.c4
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c7
-rw-r--r--source/creator/CMakeLists.txt8
-rw-r--r--source/creator/buildinfo.c10
-rw-r--r--source/creator/creator.c37
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp21
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp4
-rw-r--r--source/gameengine/CMakeLists.txt36
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp55
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h1
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp15
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h2
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp244
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.cpp31
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.h7
-rw-r--r--source/gameengine/Converter/BL_MeshDeformer.cpp19
-rw-r--r--source/gameengine/Converter/BL_MeshDeformer.h4
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.cpp183
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.h107
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.cpp48
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.h1
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.cpp20
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.h5
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.cpp71
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.h16
-rw-r--r--source/gameengine/Converter/BL_SkinMeshObject.cpp2
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp294
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h2
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp36
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.h1
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.cpp78
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.h1
-rw-r--r--source/gameengine/Converter/KX_ConvertProperties.cpp16
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp321
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.h1
-rw-r--r--source/gameengine/Expressions/BoolValue.cpp10
-rw-r--r--source/gameengine/Expressions/BoolValue.h5
-rw-r--r--source/gameengine/Expressions/CMakeLists.txt1
-rw-r--r--source/gameengine/Expressions/EmptyValue.cpp2
-rw-r--r--source/gameengine/Expressions/ErrorValue.cpp6
-rw-r--r--source/gameengine/Expressions/ErrorValue.h2
-rw-r--r--source/gameengine/Expressions/FloatValue.cpp6
-rw-r--r--source/gameengine/Expressions/FloatValue.h2
-rw-r--r--source/gameengine/Expressions/IfExpr.cpp7
-rw-r--r--source/gameengine/Expressions/InputParser.cpp45
-rw-r--r--source/gameengine/Expressions/InputParser.h10
-rw-r--r--source/gameengine/Expressions/IntValue.cpp4
-rw-r--r--source/gameengine/Expressions/IntValue.h2
-rw-r--r--source/gameengine/Expressions/ListValue.cpp274
-rw-r--r--source/gameengine/Expressions/ListValue.h4
-rw-r--r--source/gameengine/Expressions/Makefile1
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp239
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h204
-rw-r--r--source/gameengine/Expressions/SConscript2
-rw-r--r--source/gameengine/Expressions/StringValue.cpp4
-rw-r--r--source/gameengine/Expressions/StringValue.h2
-rw-r--r--source/gameengine/Expressions/Value.cpp239
-rw-r--r--source/gameengine/Expressions/Value.h103
-rw-r--r--source/gameengine/Expressions/VectorValue.cpp4
-rw-r--r--source/gameengine/Expressions/VectorValue.h2
-rw-r--r--source/gameengine/GameLogic/CMakeLists.txt1
-rw-r--r--source/gameengine/GameLogic/Joystick/Makefile2
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp63
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.h55
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h2
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp50
-rw-r--r--source/gameengine/GameLogic/Makefile1
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp21
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.h3
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.cpp28
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.h1
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp10
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.h3
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.h3
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.cpp7
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.h5
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.cpp29
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.h1
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.cpp106
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.h47
-rw-r--r--source/gameengine/GameLogic/SCA_IController.cpp249
-rw-r--r--source/gameengine/GameLogic/SCA_IController.h63
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.cpp66
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.h56
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.cpp81
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.h69
-rw-r--r--source/gameengine/GameLogic/SCA_IScene.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_IScene.h2
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp176
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h59
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.cpp11
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp75
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h20
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.cpp7
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp25
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h3
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.cpp305
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.h58
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.h3
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.cpp28
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.h1
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.cpp28
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.h1
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.cpp26
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.h1
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp25
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h1
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp48
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.h3
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp380
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.h35
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp35
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.h2
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp1
-rw-r--r--source/gameengine/GameLogic/SCA_RandomNumberGenerator.h13
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp33
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_TimeEventManager.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.cpp28
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.h1
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.cpp28
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.h1
-rw-r--r--source/gameengine/GameLogic/SConscript2
-rw-r--r--source/gameengine/GamePlayer/CMakeLists.txt5
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.cpp5
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp3
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp2
-rw-r--r--source/gameengine/Ketsji/BL_BlenderShader.cpp32
-rw-r--r--source/gameengine/Ketsji/BL_BlenderShader.h13
-rw-r--r--source/gameengine/Ketsji/BL_Material.cpp7
-rw-r--r--source/gameengine/Ketsji/BL_Material.h4
-rw-r--r--source/gameengine/Ketsji/BL_Shader.cpp13
-rw-r--r--source/gameengine/Ketsji/BL_Shader.h1
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt3
-rw-r--r--source/gameengine/Ketsji/KXNetwork/CMakeLists.txt2
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp8
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp18
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h1
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp27
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h3
-rw-r--r--source/gameengine/Ketsji/KXNetwork/Makefile2
-rw-r--r--source/gameengine/Ketsji/KXNetwork/SConscript4
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.cpp119
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.h16
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.cpp58
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.h5
-rw-r--r--source/gameengine/Ketsji/KX_CDActuator.cpp18
-rw-r--r--source/gameengine/Ketsji/KX_CDActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp453
-rw-r--r--source/gameengine/Ketsji/KX_Camera.h30
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.cpp25
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_ClientObjectInfo.h6
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp21
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.h3
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.cpp82
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.h6
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObject.h6
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp182
-rw-r--r--source/gameengine/Ketsji/KX_Dome.cpp417
-rw-r--r--source/gameengine/Ketsji/KX_Dome.h29
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.cpp27
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp556
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h50
-rw-r--r--source/gameengine/Ketsji/KX_IPO_SGController.cpp17
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.h12
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.cpp42
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.h3
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp202
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h21
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp276
-rw-r--r--source/gameengine/Ketsji/KX_Light.h8
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp59
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.h8
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.h1
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp36
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.h7
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp93
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.h8
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp337
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.h92
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.h1
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.cpp30
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h1
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp24
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.h8
-rw-r--r--source/gameengine/Ketsji/KX_PolygonMaterial.cpp108
-rw-r--r--source/gameengine/Ketsji/KX_PolygonMaterial.h15
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp65
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.h14
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp426
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.h2
-rw-r--r--source/gameengine/Ketsji/KX_PythonInitTypes.cpp7
-rw-r--r--source/gameengine/Ketsji/KX_PythonSeq.cpp382
-rw-r--r--source/gameengine/Ketsji/KX_PythonSeq.h60
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp68
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.h2
-rw-r--r--source/gameengine/Ketsji/KX_RayEventManager.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp38
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.h3
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp44
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp23
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp15
-rw-r--r--source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp20
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp288
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h63
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.cpp119
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.h3
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp82
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_StateActuator.cpp50
-rw-r--r--source/gameengine/Ketsji/KX_StateActuator.h16
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.h3
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.cpp60
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp105
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.h7
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp34
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.h3
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.cpp40
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.h1
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.cpp31
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.h8
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.cpp19
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.h1
-rw-r--r--source/gameengine/Ketsji/SConscript41
-rw-r--r--source/gameengine/Network/NG_NetworkScene.cpp4
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.cpp5
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.h1
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp2
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h6
-rw-r--r--source/gameengine/Physics/Bullet/CMakeLists.txt3
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.cpp28
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.h6
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp512
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h39
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp352
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h9
-rw-r--r--source/gameengine/Physics/Bullet/Makefile2
-rw-r--r--source/gameengine/Physics/Bullet/SConscript3
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp2
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h11
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.cpp5
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.h1
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp9
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h10
-rw-r--r--source/gameengine/Physics/common/PHY_IGraphicController.h3
-rw-r--r--source/gameengine/Physics/common/PHY_IMotionState.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h3
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h7
-rw-r--r--source/gameengine/PyDoc/API_intro.py103
-rw-r--r--source/gameengine/PyDoc/BL_ActionActuator.py230
-rw-r--r--source/gameengine/PyDoc/BL_Shader.py228
-rw-r--r--source/gameengine/PyDoc/BL_ShapeActionActuator.py199
-rw-r--r--source/gameengine/PyDoc/CListValue.py59
-rw-r--r--source/gameengine/PyDoc/GameKeys.py239
-rw-r--r--source/gameengine/PyDoc/GameLogic.py316
-rw-r--r--source/gameengine/PyDoc/GameTypes.py5863
-rw-r--r--source/gameengine/PyDoc/KX_BlenderMaterial.py38
-rw-r--r--source/gameengine/PyDoc/KX_CDActuator.py55
-rw-r--r--source/gameengine/PyDoc/KX_Camera.py209
-rw-r--r--source/gameengine/PyDoc/KX_CameraActuator.py98
-rw-r--r--source/gameengine/PyDoc/KX_ConstraintActuator.py249
-rw-r--r--source/gameengine/PyDoc/KX_ConstraintWrapper.py28
-rw-r--r--source/gameengine/PyDoc/KX_GameActuator.py29
-rw-r--r--source/gameengine/PyDoc/KX_GameObject.py504
-rw-r--r--source/gameengine/PyDoc/KX_IpoActuator.py124
-rw-r--r--source/gameengine/PyDoc/KX_LightObject.py45
-rw-r--r--source/gameengine/PyDoc/KX_MeshProxy.py132
-rw-r--r--source/gameengine/PyDoc/KX_MouseFocusSensor.py67
-rw-r--r--source/gameengine/PyDoc/KX_NearSensor.py14
-rw-r--r--source/gameengine/PyDoc/KX_NetworkMessageActuator.py49
-rw-r--r--source/gameengine/PyDoc/KX_NetworkMessageSensor.py60
-rw-r--r--source/gameengine/PyDoc/KX_ObjectActuator.py250
-rw-r--r--source/gameengine/PyDoc/KX_ParentActuator.py27
-rw-r--r--source/gameengine/PyDoc/KX_PhysicsObjectWrapper.py47
-rw-r--r--source/gameengine/PyDoc/KX_PolyProxy.py100
-rw-r--r--source/gameengine/PyDoc/KX_PolygonMaterial.py281
-rw-r--r--source/gameengine/PyDoc/KX_RadarSensor.py49
-rw-r--r--source/gameengine/PyDoc/KX_RaySensor.py58
-rw-r--r--source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py118
-rw-r--r--source/gameengine/PyDoc/KX_SCA_DynamicActuator.py30
-rw-r--r--source/gameengine/PyDoc/KX_SCA_EndObjectActuator.py11
-rw-r--r--source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py84
-rw-r--r--source/gameengine/PyDoc/KX_Scene.py85
-rw-r--r--source/gameengine/PyDoc/KX_SceneActuator.py67
-rw-r--r--source/gameengine/PyDoc/KX_SoundActuator.py195
-rw-r--r--source/gameengine/PyDoc/KX_StateActuator.py44
-rw-r--r--source/gameengine/PyDoc/KX_TouchSensor.py63
-rw-r--r--source/gameengine/PyDoc/KX_TrackToActuator.py70
-rw-r--r--source/gameengine/PyDoc/KX_VehicleWrapper.py166
-rw-r--r--source/gameengine/PyDoc/KX_VertexProxy.py148
-rw-r--r--source/gameengine/PyDoc/KX_VisibilityActuator.py22
-rw-r--r--source/gameengine/PyDoc/Rasterizer.py27
-rw-r--r--source/gameengine/PyDoc/SCA_2DFilterActuator.py44
-rw-r--r--source/gameengine/PyDoc/SCA_ANDController.py11
-rw-r--r--source/gameengine/PyDoc/SCA_ActuatorSensor.py33
-rw-r--r--source/gameengine/PyDoc/SCA_AlwaysSensor.py9
-rw-r--r--source/gameengine/PyDoc/SCA_DelaySensor.py72
-rw-r--r--source/gameengine/PyDoc/SCA_IActuator.py9
-rw-r--r--source/gameengine/PyDoc/SCA_IController.py9
-rw-r--r--source/gameengine/PyDoc/SCA_ILogicBrick.py45
-rw-r--r--source/gameengine/PyDoc/SCA_ISensor.py111
-rw-r--r--source/gameengine/PyDoc/SCA_JoystickSensor.py169
-rw-r--r--source/gameengine/PyDoc/SCA_KeyboardSensor.py116
-rw-r--r--source/gameengine/PyDoc/SCA_MouseSensor.py44
-rw-r--r--source/gameengine/PyDoc/SCA_NANDController.py11
-rw-r--r--source/gameengine/PyDoc/SCA_NORController.py11
-rw-r--r--source/gameengine/PyDoc/SCA_ORController.py11
-rw-r--r--source/gameengine/PyDoc/SCA_PropertyActuator.py49
-rw-r--r--source/gameengine/PyDoc/SCA_PropertySensor.py74
-rw-r--r--source/gameengine/PyDoc/SCA_PythonController.py77
-rw-r--r--source/gameengine/PyDoc/SCA_RandomActuator.py175
-rw-r--r--source/gameengine/PyDoc/SCA_RandomSensor.py35
-rw-r--r--source/gameengine/PyDoc/SCA_XNORController.py11
-rw-r--r--source/gameengine/PyDoc/SCA_XORController.py11
-rw-r--r--source/gameengine/PyDoc/WhatsNew.py34
-rw-r--r--source/gameengine/PyDoc/bge_api_validate_py.txt68
-rwxr-xr-xsource/gameengine/PyDoc/epy_docgen.sh9
-rw-r--r--source/gameengine/Rasterizer/CMakeLists.txt2
-rw-r--r--source/gameengine/Rasterizer/Makefile2
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.cpp4
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.cpp60
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.h1
-rw-r--r--source/gameengine/Rasterizer/RAS_CameraData.h4
-rw-r--r--source/gameengine/Rasterizer/RAS_Deformer.h28
-rw-r--r--source/gameengine/Rasterizer/RAS_FramingManager.cpp101
-rw-r--r--source/gameengine/Rasterizer/RAS_FramingManager.h22
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp98
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.h29
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h27
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.cpp73
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.h28
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.cpp63
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.h12
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt6
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile6
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp68
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h13
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp130
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h18
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp12
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript2
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.cpp19
-rw-r--r--source/gameengine/Rasterizer/SConscript2
-rw-r--r--source/gameengine/SceneGraph/SG_DList.h161
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.cpp92
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.h136
-rw-r--r--source/gameengine/SceneGraph/SG_Node.cpp66
-rw-r--r--source/gameengine/SceneGraph/SG_Node.h113
-rw-r--r--source/gameengine/SceneGraph/SG_QList.h157
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.cpp151
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.h191
-rw-r--r--source/gameengine/VideoTexture/BlendType.h6
-rw-r--r--source/gameengine/VideoTexture/FilterBlueScreen.cpp7
-rw-r--r--source/gameengine/VideoTexture/FilterColor.cpp21
-rw-r--r--source/gameengine/VideoTexture/FilterNormal.cpp7
-rw-r--r--source/gameengine/VideoTexture/FilterSource.cpp21
-rw-r--r--source/gameengine/VideoTexture/ImageBase.cpp8
-rw-r--r--source/gameengine/VideoTexture/ImageBuff.cpp10
-rw-r--r--source/gameengine/VideoTexture/ImageMix.cpp15
-rw-r--r--source/gameengine/VideoTexture/ImageRender.cpp71
-rw-r--r--source/gameengine/VideoTexture/ImageViewport.cpp7
-rw-r--r--source/gameengine/VideoTexture/PyTypeList.cpp1
-rw-r--r--source/gameengine/VideoTexture/Texture.cpp16
-rw-r--r--source/gameengine/VideoTexture/VideoBase.cpp7
-rw-r--r--source/gameengine/VideoTexture/VideoBase.h13
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.cpp86
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.h5
-rw-r--r--source/gameengine/VideoTexture/blendVideoTex.cpp46
-rw-r--r--source/kernel/gen_system/GEN_HashedPtr.cpp9
-rw-r--r--source/nan_definitions.mk8
-rw-r--r--tools/Blender.py4
-rwxr-xr-xtools/btools.py4
594 files changed, 28276 insertions, 13737 deletions
diff --git a/CMake/macros.cmake b/CMake/macros.cmake
index df8e7515e67..bc8892e4b99 100644
--- a/CMake/macros.cmake
+++ b/CMake/macros.cmake
@@ -59,7 +59,24 @@ ENDMACRO(SETUP_LIBDIRS)
MACRO(SETUP_LIBLINKS
target)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS} ")
- TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LIB} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS})
+ #TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LIB} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS})
+
+ TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS})
+
+ # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
+
+ IF(WIN32)
+
+ TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d)
+
+ TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB})
+
+ ELSE(WIN32)
+
+ TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB})
+
+ ENDIF(WIN32)
+
TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS})
TARGET_LINK_LIBRARIES(${target} ${FREETYPE_LIB})
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3efaa82e1f3..9c7ee34cc14 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,20 +99,6 @@ IF(UNIX)
ENDIF(OPENAL_FOUND)
ENDIF(WITH_OPENAL)
- FIND_LIBRARY(ALUT_LIBRARY
- NAMES alut
- PATHS
- /usr/local/lib
- /usr/lib
- /sw/lib
- /opt/local/lib
- /opt/csw/lib
- /opt/lib
- )
- IF(ALUT_LIBRARY)
- SET(OPENAL_LIB ${OPENAL_LIB} ${ALUT_LIBRARY})
- ENDIF(ALUT_LIBRARY)
-
FIND_LIBRARY(INTL_LIBRARY
NAMES intl
PATHS
@@ -288,7 +274,7 @@ IF(WIN32)
SET(FFMPEG ${LIBDIR}/ffmpeg)
SET(FFMPEG_INC ${FFMPEG}/include)
- SET(FFMPEG_LIB avcodec-51 avformat-52 avdevice-52 avutil-49 swscale-0)
+ SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
IF(CMAKE_CL_64)
@@ -468,20 +454,18 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ")
#-----------------------------------------------------------------------------
# Libraries
FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
-SUBDIRS(
- intern
- extern
- source
-)
+ADD_SUBDIRECTORY(intern)
+ADD_SUBDIRECTORY(extern)
+ADD_SUBDIRECTORY(source)
#-----------------------------------------------------------------------------
# Blender Application
-SUBDIRS(source/creator)
+ADD_SUBDIRECTORY(source/creator)
#-----------------------------------------------------------------------------
# Blender Player
IF(WITH_PLAYER)
- SUBDIRS(blenderplayer)
+ ADD_SUBDIRECTORY(blenderplayer)
ENDIF(WITH_PLAYER)
diff --git a/config/irix6-config.py b/config/irix6-config.py
index a927dfb12be..3c8fd0dece4 100644
--- a/config/irix6-config.py
+++ b/config/irix6-config.py
@@ -20,11 +20,6 @@ BF_OPENAL_LIB = 'openal'
BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
BF_OPENAL_LIBPATH = LIBDIR + '/lib'
-# some distros have a separate libalut
-# if you get linker complaints, you need to uncomment the line below
-# BF_OPENAL_LIB = 'openal alut'
-# BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a ${BF_OPENAL}/lib/libalut.a'
-
BF_CXX = '/usr'
WITH_BF_STATICCXX = 'false'
BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
diff --git a/config/linux2-config.py b/config/linux2-config.py
index f5712432794..4cea4bb8e05 100644
--- a/config/linux2-config.py
+++ b/config/linux2-config.py
@@ -1,9 +1,17 @@
LCGDIR = '../lib/linux2'
LIBDIR = "${LCGDIR}"
+def py_version_string():
+ '''
+ returns py version - "2.5", "2.6" etc
+ '''
+ import platform
+ ver = platform.python_version_tuple()
+ return '%d.%d' % (int(ver[0]), int(ver[1])) # py2.5 uses strings, 2.6 ints
+
BF_PYTHON = '/usr'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
-BF_PYTHON_VERSION = '2.5'
+BF_PYTHON_VERSION = py_version_string()
WITH_BF_STATICPYTHON = False
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
@@ -18,11 +26,6 @@ BF_OPENAL_INC = '${BF_OPENAL}/include'
BF_OPENAL_LIB = 'openal'
BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
-# some distros have a separate libalut
-# if you get linker complaints, you need to uncomment the line below
-# BF_OPENAL_LIB = 'openal alut'
-# BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a ${BF_OPENAL}/lib/libalut.a'
-
BF_CXX = '/usr'
WITH_BF_STATICCXX = False
BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
@@ -71,7 +74,8 @@ BF_GETTEXT_INC = '${BF_GETTEXT}/include'
BF_GETTEXT_LIB = 'gettextlib'
BF_GETTEXT_LIBPATH = '${BF_GETTEXT}/lib'
-WITH_BF_GAMEENGINE=False
+WITH_BF_GAMEENGINE = True
+WITH_BF_PLAYER = True
WITH_BF_ODE = False
BF_ODE = LIBDIR + '/ode'
diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt
index 45778e235cd..8dcace11e7d 100644
--- a/extern/CMakeLists.txt
+++ b/extern/CMakeLists.txt
@@ -25,19 +25,20 @@
# ***** END GPL LICENSE BLOCK *****
IF(WITH_GAMEENGINE)
- SUBDIRS(qhull solid)
+ ADD_SUBDIRECTORY(qhull)
+ ADD_SUBDIRECTORY(solid)
ENDIF(WITH_GAMEENGINE)
IF(WITH_BULLET)
- SUBDIRS(bullet2)
+ ADD_SUBDIRECTORY(bullet2)
ENDIF(WITH_BULLET)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
- SUBDIRS(binreloc)
+ ADD_SUBDIRECTORY(binreloc)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
-SUBDIRS(glew)
+ADD_SUBDIRECTORY(glew)
IF(WITH_OPENJPEG)
- SUBDIRS(libopenjpeg)
+ ADD_SUBDIRECTORY(libopenjpeg)
ENDIF(WITH_OPENJPEG)
diff --git a/extern/Makefile b/extern/Makefile
index 582d158b66f..8311006444f 100644
--- a/extern/Makefile
+++ b/extern/Makefile
@@ -41,9 +41,10 @@ ifeq ($(NAN_FFMPEG), $(LCGDIR)/gcc/ffmpeg)
endif
endif
-ifneq ($(NAN_NO_KETSJI), true)
- DIRS += bullet2
-endif
+# Cloth requires it
+#ifneq ($(NAN_NO_KETSJI), true)
+DIRS += bullet2
+#endif
ifeq ($(WITH_BINRELOC), true)
DIRS += binreloc
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp
index 29c8496c36f..50a79451f5d 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp
@@ -22,12 +22,13 @@ Written by: Marcus Hennix
#include "LinearMath/btMinMax.h"
#include <new>
-//-----------------------------------------------------------------------------
+
+//#define CONETWIST_USE_OBSOLETE_SOLVER true
#define CONETWIST_USE_OBSOLETE_SOLVER false
#define CONETWIST_DEF_FIX_THRESH btScalar(.05f)
-//-----------------------------------------------------------------------------
+
btConeTwistConstraint::btConeTwistConstraint()
:btTypedConstraint(CONETWIST_CONSTRAINT_TYPE),
@@ -63,13 +64,13 @@ void btConeTwistConstraint::init()
m_bMotorEnabled = false;
m_maxMotorImpulse = btScalar(-1);
- setLimit(btScalar(1e30), btScalar(1e30), btScalar(1e30));
+ setLimit(btScalar(BT_LARGE_FLOAT), btScalar(BT_LARGE_FLOAT), btScalar(BT_LARGE_FLOAT));
m_damping = btScalar(0.01);
m_fixThresh = CONETWIST_DEF_FIX_THRESH;
}
-//-----------------------------------------------------------------------------
+
void btConeTwistConstraint::getInfo1 (btConstraintInfo1* info)
{
@@ -99,9 +100,9 @@ void btConeTwistConstraint::getInfo1 (btConstraintInfo1* info)
info->nub--;
}
}
-} // btConeTwistConstraint::getInfo1()
+}
-//-----------------------------------------------------------------------------
+
void btConeTwistConstraint::getInfo2 (btConstraintInfo2* info)
{
@@ -230,7 +231,7 @@ void btConeTwistConstraint::getInfo2 (btConstraintInfo2* info)
}
}
-//-----------------------------------------------------------------------------
+
void btConeTwistConstraint::buildJacobian()
{
@@ -239,6 +240,7 @@ void btConeTwistConstraint::buildJacobian()
m_appliedImpulse = btScalar(0.);
m_accTwistLimitImpulse = btScalar(0.);
m_accSwingLimitImpulse = btScalar(0.);
+ m_accMotorImpulse = btVector3(0.,0.,0.);
if (!m_angularOnly)
{
@@ -277,7 +279,7 @@ void btConeTwistConstraint::buildJacobian()
}
}
-//-----------------------------------------------------------------------------
+
void btConeTwistConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep)
{
@@ -406,10 +408,10 @@ void btConeTwistConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolver
}
}
- else // no motor: do a little damping
+ else if (m_damping > SIMD_EPSILON) // no motor: do a little damping
{
- const btVector3& angVelA = getRigidBodyA().getAngularVelocity();
- const btVector3& angVelB = getRigidBodyB().getAngularVelocity();
+ btVector3 angVelA; bodyA.getAngularVelocity(angVelA);
+ btVector3 angVelB; bodyB.getAngularVelocity(angVelB);
btVector3 relVel = angVelB - angVelA;
if (relVel.length2() > SIMD_EPSILON)
{
@@ -490,7 +492,7 @@ void btConeTwistConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolver
}
-//-----------------------------------------------------------------------------
+
void btConeTwistConstraint::updateRHS(btScalar timeStep)
{
@@ -498,7 +500,7 @@ void btConeTwistConstraint::updateRHS(btScalar timeStep)
}
-//-----------------------------------------------------------------------------
+
void btConeTwistConstraint::calcAngleInfo()
{
@@ -584,12 +586,12 @@ void btConeTwistConstraint::calcAngleInfo()
m_twistAxis.normalize();
}
}
-} // btConeTwistConstraint::calcAngleInfo()
+}
static btVector3 vTwist(1,0,0); // twist axis in constraint's space
-//-----------------------------------------------------------------------------
+
void btConeTwistConstraint::calcAngleInfo2()
{
@@ -597,13 +599,34 @@ void btConeTwistConstraint::calcAngleInfo2()
m_twistLimitSign = btScalar(0.);
m_solveTwistLimit = false;
m_solveSwingLimit = false;
+ // compute rotation of A wrt B (in constraint space)
+ if (m_bMotorEnabled && (!m_useSolveConstraintObsolete))
+ { // it is assumed that setMotorTarget() was alredy called
+ // and motor target m_qTarget is within constraint limits
+ // TODO : split rotation to pure swing and pure twist
+ // compute desired transforms in world
+ btTransform trPose(m_qTarget);
+ btTransform trA = getRigidBodyA().getCenterOfMassTransform() * m_rbAFrame;
+ btTransform trB = getRigidBodyB().getCenterOfMassTransform() * m_rbBFrame;
+ btTransform trDeltaAB = trB * trPose * trA.inverse();
+ btQuaternion qDeltaAB = trDeltaAB.getRotation();
+ btVector3 swingAxis = btVector3(qDeltaAB.x(), qDeltaAB.y(), qDeltaAB.z());
+ m_swingAxis = swingAxis;
+ m_swingAxis.normalize();
+ m_swingCorrection = qDeltaAB.getAngle();
+ if(!btFuzzyZero(m_swingCorrection))
+ {
+ m_solveSwingLimit = true;
+ }
+ return;
+ }
+
{
// compute rotation of A wrt B (in constraint space)
btQuaternion qA = getRigidBodyA().getCenterOfMassTransform().getRotation() * m_rbAFrame.getRotation();
btQuaternion qB = getRigidBodyB().getCenterOfMassTransform().getRotation() * m_rbBFrame.getRotation();
btQuaternion qAB = qB.inverse() * qA;
-
// split rotation into cone and twist
// (all this is done from B's perspective. Maybe I should be averaging axes...)
btVector3 vConeNoTwist = quatRotate(qAB, vTwist); vConeNoTwist.normalize();
@@ -756,7 +779,7 @@ void btConeTwistConstraint::calcAngleInfo2()
m_twistAngle = btScalar(0.f);
}
}
-} // btConeTwistConstraint::calcAngleInfo2()
+}
@@ -982,8 +1005,5 @@ void btConeTwistConstraint::setMotorTargetInConstraintSpace(const btQuaternion &
}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h
index 84ea9e04095..8a893d4fb8c 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h
@@ -17,6 +17,22 @@ Written by: Marcus Hennix
+/*
+Overview:
+
+btConeTwistConstraint can be used to simulate ragdoll joints (upper arm, leg etc).
+It is a fixed translation, 3 degree-of-freedom (DOF) rotational "joint".
+It divides the 3 rotational DOFs into swing (movement within a cone) and twist.
+Swing is divided into swing1 and swing2 which can have different limits, giving an elliptical shape.
+(Note: the cone's base isn't flat, so this ellipse is "embedded" on the surface of a sphere.)
+
+In the contraint's frame of reference:
+twist is along the x-axis,
+and swing 1 and 2 are along the z and y axes respectively.
+*/
+
+
+
#ifndef CONETWISTCONSTRAINT_H
#define CONETWISTCONSTRAINT_H
@@ -141,7 +157,18 @@ public:
};
}
- void setLimit(btScalar _swingSpan1,btScalar _swingSpan2,btScalar _twistSpan, btScalar _softness = 1.f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f)
+ // setLimit(), a few notes:
+ // _softness:
+ // 0->1, recommend ~0.8->1.
+ // describes % of limits where movement is free.
+ // beyond this softness %, the limit is gradually enforced until the "hard" (1.0) limit is reached.
+ // _biasFactor:
+ // 0->1?, recommend 0.3 +/-0.3 or so.
+ // strength with which constraint resists zeroth order (angular, not angular velocity) limit violation.
+ // __relaxationFactor:
+ // 0->1, recommend to stay near 1.
+ // the lower the value, the less the constraint will fight velocities which violate the angular limits.
+ void setLimit(btScalar _swingSpan1,btScalar _swingSpan2,btScalar _twistSpan, btScalar _softness = 1.f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f)
{
m_swingSpan1 = _swingSpan1;
m_swingSpan2 = _swingSpan2;
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h
index e99430c00de..a11fc94ea11 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h
@@ -77,7 +77,7 @@ struct btContactSolverInfo : public btContactSolverInfoData
m_splitImpulsePenetrationThreshold = -0.02f;
m_linearSlop = btScalar(0.0);
m_warmstartingFactor=btScalar(0.85);
- m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD ;//SOLVER_RANDMIZE_ORDER
+ m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_USE_2_FRICTION_DIRECTIONS |SOLVER_SIMD | SOLVER_RANDMIZE_ORDER;
m_restingContactRestitutionThreshold = 2;//resting contact lifetime threshold to disable restitution
}
};
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp
index 6cbfe61f700..38e81688f02 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp
@@ -22,11 +22,13 @@ http://gimpact.sf.net
#include "btGeneric6DofConstraint.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
#include "LinearMath/btTransformUtil.h"
+#include "LinearMath/btTransformUtil.h"
#include <new>
+
#define D6_USE_OBSOLETE_METHOD false
-//-----------------------------------------------------------------------------
+
btGeneric6DofConstraint::btGeneric6DofConstraint()
:btTypedConstraint(D6_CONSTRAINT_TYPE),
@@ -35,7 +37,7 @@ m_useSolveConstraintObsolete(D6_USE_OBSOLETE_METHOD)
{
}
-//-----------------------------------------------------------------------------
+
btGeneric6DofConstraint::btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA)
: btTypedConstraint(D6_CONSTRAINT_TYPE, rbA, rbB)
@@ -46,12 +48,12 @@ m_useSolveConstraintObsolete(D6_USE_OBSOLETE_METHOD)
{
}
-//-----------------------------------------------------------------------------
+
#define GENERIC_D6_DISABLE_WARMSTARTING 1
-//-----------------------------------------------------------------------------
+
btScalar btGetMatrixElem(const btMatrix3x3& mat, int index);
btScalar btGetMatrixElem(const btMatrix3x3& mat, int index)
@@ -61,7 +63,7 @@ btScalar btGetMatrixElem(const btMatrix3x3& mat, int index)
return mat[i][j];
}
-//-----------------------------------------------------------------------------
+
///MatrixToEulerXYZ from http://www.geometrictools.com/LibFoundation/Mathematics/Wm4Matrix3.inl.html
bool matrixToEulerXYZ(const btMatrix3x3& mat,btVector3& xyz);
@@ -129,7 +131,7 @@ int btRotationalLimitMotor::testLimitValue(btScalar test_value)
}
-//-----------------------------------------------------------------------------
+
btScalar btRotationalLimitMotor::solveAngularLimits(
btScalar timeStep,btVector3& axis,btScalar jacDiagABInv,
@@ -191,8 +193,8 @@ btScalar btRotationalLimitMotor::solveAngularLimits(
// sort with accumulated impulses
- btScalar lo = btScalar(-1e30);
- btScalar hi = btScalar(1e30);
+ btScalar lo = btScalar(-BT_LARGE_FLOAT);
+ btScalar hi = btScalar(BT_LARGE_FLOAT);
btScalar oldaccumImpulse = m_accumulatedImpulse;
btScalar sum = oldaccumImpulse + clippedMotorImpulse;
@@ -249,9 +251,9 @@ int btTranslationalLimitMotor::testLimitValue(int limitIndex, btScalar test_valu
m_currentLimit[limitIndex] = 0;//Free from violation
m_currentLimitError[limitIndex] = btScalar(0.f);
return 0;
-} // btTranslationalLimitMotor::testLimitValue()
+}
+
-//-----------------------------------------------------------------------------
btScalar btTranslationalLimitMotor::solveLinearAxis(
btScalar timeStep,
@@ -283,8 +285,8 @@ btScalar btTranslationalLimitMotor::solveLinearAxis(
//positional error (zeroth order error)
btScalar depth = -(pointInA - pointInB).dot(axis_normal_on_a);
- btScalar lo = btScalar(-1e30);
- btScalar hi = btScalar(1e30);
+ btScalar lo = btScalar(-BT_LARGE_FLOAT);
+ btScalar hi = btScalar(BT_LARGE_FLOAT);
btScalar minLimit = m_lowerLimit[limit_index];
btScalar maxLimit = m_upperLimit[limit_index];
@@ -372,7 +374,7 @@ void btGeneric6DofConstraint::calculateAngleInfo()
}
-//-----------------------------------------------------------------------------
+
void btGeneric6DofConstraint::calculateTransforms()
{
@@ -382,7 +384,7 @@ void btGeneric6DofConstraint::calculateTransforms()
calculateAngleInfo();
}
-//-----------------------------------------------------------------------------
+
void btGeneric6DofConstraint::buildLinearJacobian(
btJacobianEntry & jacLinear,const btVector3 & normalWorld,
@@ -400,7 +402,7 @@ void btGeneric6DofConstraint::buildLinearJacobian(
m_rbB.getInvMass());
}
-//-----------------------------------------------------------------------------
+
void btGeneric6DofConstraint::buildAngularJacobian(
btJacobianEntry & jacAngular,const btVector3 & jointAxisW)
@@ -413,17 +415,18 @@ void btGeneric6DofConstraint::buildAngularJacobian(
}
-//-----------------------------------------------------------------------------
+
bool btGeneric6DofConstraint::testAngularLimitMotor(int axis_index)
{
btScalar angle = m_calculatedAxisAngleDiff[axis_index];
+ m_angularLimits[axis_index].m_currentPosition = angle;
//test limits
m_angularLimits[axis_index].testLimitValue(angle);
return m_angularLimits[axis_index].needApplyTorques();
}
-//-----------------------------------------------------------------------------
+
void btGeneric6DofConstraint::buildJacobian()
{
@@ -483,7 +486,7 @@ void btGeneric6DofConstraint::buildJacobian()
}
}
-//-----------------------------------------------------------------------------
+
void btGeneric6DofConstraint::getInfo1 (btConstraintInfo1* info)
{
@@ -519,7 +522,7 @@ void btGeneric6DofConstraint::getInfo1 (btConstraintInfo1* info)
}
}
-//-----------------------------------------------------------------------------
+
void btGeneric6DofConstraint::getInfo2 (btConstraintInfo2* info)
{
@@ -528,7 +531,7 @@ void btGeneric6DofConstraint::getInfo2 (btConstraintInfo2* info)
setAngularLimits(info, row);
}
-//-----------------------------------------------------------------------------
+
int btGeneric6DofConstraint::setLinearLimits(btConstraintInfo2* info)
{
@@ -542,6 +545,7 @@ int btGeneric6DofConstraint::setLinearLimits(btConstraintInfo2* info)
{ // re-use rotational motor code
limot.m_bounce = btScalar(0.f);
limot.m_currentLimit = m_linearLimits.m_currentLimit[i];
+ limot.m_currentPosition = m_linearLimits.m_currentLinearDiff[i];
limot.m_currentLimitError = m_linearLimits.m_currentLimitError[i];
limot.m_damping = m_linearLimits.m_damping;
limot.m_enableMotor = m_linearLimits.m_enableMotor[i];
@@ -559,7 +563,7 @@ int btGeneric6DofConstraint::setLinearLimits(btConstraintInfo2* info)
return row;
}
-//-----------------------------------------------------------------------------
+
int btGeneric6DofConstraint::setAngularLimits(btConstraintInfo2 *info, int row_offset)
{
@@ -582,7 +586,7 @@ int btGeneric6DofConstraint::setAngularLimits(btConstraintInfo2 *info, int row_o
return row;
}
-//-----------------------------------------------------------------------------
+
void btGeneric6DofConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep)
{
@@ -643,7 +647,7 @@ void btGeneric6DofConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolv
}
}
-//-----------------------------------------------------------------------------
+
void btGeneric6DofConstraint::updateRHS(btScalar timeStep)
{
@@ -651,21 +655,26 @@ void btGeneric6DofConstraint::updateRHS(btScalar timeStep)
}
-//-----------------------------------------------------------------------------
+
btVector3 btGeneric6DofConstraint::getAxis(int axis_index) const
{
return m_calculatedAxis[axis_index];
}
-//-----------------------------------------------------------------------------
-btScalar btGeneric6DofConstraint::getAngle(int axis_index) const
+btScalar btGeneric6DofConstraint::getRelativePivotPosition(int axisIndex) const
{
- return m_calculatedAxisAngleDiff[axis_index];
+ return m_calculatedLinearDiff[axisIndex];
}
-//-----------------------------------------------------------------------------
+
+btScalar btGeneric6DofConstraint::getAngle(int axisIndex) const
+{
+ return m_calculatedAxisAngleDiff[axisIndex];
+}
+
+
void btGeneric6DofConstraint::calcAnchorPos(void)
{
@@ -684,9 +693,9 @@ void btGeneric6DofConstraint::calcAnchorPos(void)
const btVector3& pB = m_calculatedTransformB.getOrigin();
m_AnchorPos = pA * weight + pB * (btScalar(1.0) - weight);
return;
-} // btGeneric6DofConstraint::calcAnchorPos()
+}
+
-//-----------------------------------------------------------------------------
void btGeneric6DofConstraint::calculateLinearInfo()
{
@@ -694,11 +703,12 @@ void btGeneric6DofConstraint::calculateLinearInfo()
m_calculatedLinearDiff = m_calculatedTransformA.getBasis().inverse() * m_calculatedLinearDiff;
for(int i = 0; i < 3; i++)
{
+ m_linearLimits.m_currentLinearDiff[i] = m_calculatedLinearDiff[i];
m_linearLimits.testLimitValue(i, m_calculatedLinearDiff[i]);
}
-} // btGeneric6DofConstraint::calculateLinearInfo()
+}
+
-//-----------------------------------------------------------------------------
int btGeneric6DofConstraint::get_limit_motor_info2(
btRotationalLimitMotor * limot,
@@ -721,7 +731,7 @@ int btGeneric6DofConstraint::get_limit_motor_info2(
J2[srow+1] = -ax1[1];
J2[srow+2] = -ax1[2];
}
- if((!rotational) && limit)
+ if((!rotational))
{
btVector3 ltd; // Linear Torque Decoupling vector
btVector3 c = m_calculatedTransformB.getOrigin() - body0->getCenterOfMassPosition();
@@ -745,7 +755,14 @@ int btGeneric6DofConstraint::get_limit_motor_info2(
info->cfm[srow] = 0.0f;
if(!limit)
{
- info->m_constraintError[srow] += limot->m_targetVelocity;
+ btScalar tag_vel = rotational ? limot->m_targetVelocity : -limot->m_targetVelocity;
+
+ btScalar mot_fact = getMotorFactor( limot->m_currentPosition,
+ limot->m_loLimit,
+ limot->m_hiLimit,
+ tag_vel,
+ info->fps * info->erp);
+ info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity;
info->m_lowerLimit[srow] = -limot->m_maxMotorForce;
info->m_upperLimit[srow] = limot->m_maxMotorForce;
}
@@ -824,6 +841,131 @@ int btGeneric6DofConstraint::get_limit_motor_info2(
else return 0;
}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
+
+
+
+btGeneric6DofSpringConstraint::btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA)
+ : btGeneric6DofConstraint(rbA, rbB, frameInA, frameInB, useLinearReferenceFrameA)
+{
+ for(int i = 0; i < 6; i++)
+ {
+ m_springEnabled[i] = false;
+ m_equilibriumPoint[i] = btScalar(0.f);
+ m_springStiffness[i] = btScalar(0.f);
+ m_springDamping[i] = btScalar(1.f);
+ }
+}
+
+
+void btGeneric6DofSpringConstraint::enableSpring(int index, bool onOff)
+{
+ btAssert((index >= 0) && (index < 6));
+ m_springEnabled[index] = onOff;
+ if(index < 3)
+ {
+ m_linearLimits.m_enableMotor[index] = onOff;
+ }
+ else
+ {
+ m_angularLimits[index - 3].m_enableMotor = onOff;
+ }
+}
+
+
+
+void btGeneric6DofSpringConstraint::setStiffness(int index, btScalar stiffness)
+{
+ btAssert((index >= 0) && (index < 6));
+ m_springStiffness[index] = stiffness;
+}
+
+
+void btGeneric6DofSpringConstraint::setDamping(int index, btScalar damping)
+{
+ btAssert((index >= 0) && (index < 6));
+ m_springDamping[index] = damping;
+}
+
+
+void btGeneric6DofSpringConstraint::setEquilibriumPoint()
+{
+ calculateTransforms();
+ for(int i = 0; i < 3; i++)
+ {
+ m_equilibriumPoint[i] = m_calculatedLinearDiff[i];
+ }
+ for(int i = 0; i < 3; i++)
+ {
+ m_equilibriumPoint[i + 3] = m_calculatedAxisAngleDiff[i];
+ }
+}
+
+
+
+void btGeneric6DofSpringConstraint::setEquilibriumPoint(int index)
+{
+ btAssert((index >= 0) && (index < 6));
+ calculateTransforms();
+ if(index < 3)
+ {
+ m_equilibriumPoint[index] = m_calculatedLinearDiff[index];
+ }
+ else
+ {
+ m_equilibriumPoint[index + 3] = m_calculatedAxisAngleDiff[index];
+ }
+}
+
+
+
+void btGeneric6DofSpringConstraint::internalUpdateSprings(btConstraintInfo2* info)
+{
+ calculateTransforms();
+ // it is assumed that calculateTransforms() have been called before this call
+ int i;
+ btVector3 relVel = m_rbB.getLinearVelocity() - m_rbA.getLinearVelocity();
+ for(i = 0; i < 3; i++)
+ {
+ if(m_springEnabled[i])
+ {
+ // get current position of constraint
+ btScalar currPos = m_calculatedLinearDiff[i];
+ // calculate difference
+ btScalar delta = currPos - m_equilibriumPoint[i];
+ // spring force is (delta * m_stiffness) according to Hooke's Law
+ btScalar force = delta * m_springStiffness[i];
+ btScalar velFactor = info->fps * m_springDamping[i];
+ m_linearLimits.m_targetVelocity[i] = velFactor * force;
+ m_linearLimits.m_maxMotorForce[i] = btFabs(force) / info->fps;
+ }
+ }
+ for(i = 0; i < 3; i++)
+ {
+ if(m_springEnabled[i + 3])
+ {
+ // get current position of constraint
+ btScalar currPos = m_calculatedAxisAngleDiff[i];
+ // calculate difference
+ btScalar delta = currPos - m_equilibriumPoint[i+3];
+ // spring force is (-delta * m_stiffness) according to Hooke's Law
+ btScalar force = -delta * m_springStiffness[i+3];
+ btScalar velFactor = info->fps * m_springDamping[i+3];
+ m_angularLimits[i].m_targetVelocity = velFactor * force;
+ m_angularLimits[i].m_maxMotorForce = btFabs(force) / info->fps;
+ }
+ }
+}
+
+
+void btGeneric6DofSpringConstraint::getInfo2(btConstraintInfo2* info)
+{
+ // this will be called by constraint solver at the constraint setup stage
+ // set current motor parameters
+ internalUpdateSprings(info);
+ // do the rest of job for constraint setup
+ btGeneric6DofConstraint::getInfo2(info);
+}
+
+
+
+
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h
index 0ae161d5bdf..8082eb1f132 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h
@@ -54,6 +54,7 @@ public:
//! temp_variables
//!@{
btScalar m_currentLimitError;//! How much is violated this limit
+ btScalar m_currentPosition; //! current value of angle
int m_currentLimit;//!< 0=free, 1=at lo limit, 2=at hi limit
btScalar m_accumulatedImpulse;
//!@}
@@ -134,6 +135,7 @@ public:
btVector3 m_targetVelocity;//!< target motor velocity
btVector3 m_maxMotorForce;//!< max force on motor
btVector3 m_currentLimitError;//! How much is violated this limit
+ btVector3 m_currentLinearDiff;//! Current relative offset of constraint frames
int m_currentLimit[3];//!< 0=free, 1=at lower limit, 2=at upper limit
btTranslationalLimitMotor()
@@ -380,14 +382,21 @@ public:
//! Get the relative Euler angle
/*!
- \pre btGeneric6DofConstraint.buildJacobian must be called previously.
+ \pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
*/
btScalar getAngle(int axis_index) const;
+ //! Get the relative position of the constraint pivot
+ /*!
+ \pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
+ */
+ btScalar getRelativePivotPosition(int axis_index) const;
+
+
//! Test angular limit.
/*!
Calculates angular correction and returns true if limit needs to be corrected.
- \pre btGeneric6DofConstraint.buildJacobian must be called previously.
+ \pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
*/
bool testAngularLimitMotor(int axis_index);
@@ -477,4 +486,34 @@ public:
};
+
+/// Generic 6 DOF constraint that allows to set spring motors to any translational and rotational DOF
+
+/// DOF index used in enableSpring() and setStiffness() means:
+/// 0 : translation X
+/// 1 : translation Y
+/// 2 : translation Z
+/// 3 : rotation X (3rd Euler rotational around new position of X axis, range [-PI+epsilon, PI-epsilon] )
+/// 4 : rotation Y (2nd Euler rotational around new position of Y axis, range [-PI/2+epsilon, PI/2-epsilon] )
+/// 5 : rotation Z (1st Euler rotational around Z axis, range [-PI+epsilon, PI-epsilon] )
+
+class btGeneric6DofSpringConstraint : public btGeneric6DofConstraint
+{
+protected:
+ bool m_springEnabled[6];
+ btScalar m_equilibriumPoint[6];
+ btScalar m_springStiffness[6];
+ btScalar m_springDamping[6]; // between 0 and 1 (1 == no damping)
+ void internalUpdateSprings(btConstraintInfo2* info);
+public:
+ btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
+ void enableSpring(int index, bool onOff);
+ void setStiffness(int index, btScalar stiffness);
+ void setDamping(int index, btScalar damping);
+ void setEquilibriumPoint(); // set the current constraint position/orientation as an equilibrium point for all DOF
+ void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF
+ virtual void getInfo2 (btConstraintInfo2* info);
+};
+
+
#endif //GENERIC_6DOF_CONSTRAINT_H
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
index 685a812d427..dbd09b39238 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
@@ -490,7 +490,7 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
///warm starting (or zero if disabled)
- if (0)//infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING)
+ if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING)
{
solverConstraint.m_appliedImpulse = cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor;
if (rb0)
@@ -539,9 +539,6 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON)
{
cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel);
- applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1);
- applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1);
- addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
{
cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
@@ -550,21 +547,26 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m
applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2);
addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
}
+
+ applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1);
+ applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1);
+ addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
cp.m_lateralFrictionInitialized = true;
} else
{
//re-calculate friction direction every frame, todo: check if this is really needed
btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2);
- applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1);
- applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1);
-
- addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
{
applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2);
applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2);
addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
}
+
+ applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1);
+ applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1);
+ addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
+
cp.m_lateralFrictionInitialized = true;
}
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp
index 50d06960379..133aed7271b 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp
@@ -18,14 +18,14 @@ Added by Roman Ponomarev (rponom@gmail.com)
April 04, 2008
*/
-//-----------------------------------------------------------------------------
+
#include "btSliderConstraint.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
#include "LinearMath/btTransformUtil.h"
#include <new>
-//-----------------------------------------------------------------------------
+
void btSliderConstraint::initParams()
{
@@ -62,9 +62,9 @@ void btSliderConstraint::initParams()
m_maxAngMotorForce = btScalar(0.);
m_accumulatedAngMotorImpulse = btScalar(0.0);
-} // btSliderConstraint::initParams()
+}
+
-//-----------------------------------------------------------------------------
btSliderConstraint::btSliderConstraint()
:btTypedConstraint(SLIDER_CONSTRAINT_TYPE),
@@ -73,9 +73,9 @@ btSliderConstraint::btSliderConstraint()
// m_useSolveConstraintObsolete(true)
{
initParams();
-} // btSliderConstraint::btSliderConstraint()
+}
+
-//-----------------------------------------------------------------------------
btSliderConstraint::btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, bool useLinearReferenceFrameA)
: btTypedConstraint(SLIDER_CONSTRAINT_TYPE, rbA, rbB)
@@ -86,9 +86,25 @@ btSliderConstraint::btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const
// m_useSolveConstraintObsolete(true)
{
initParams();
-} // btSliderConstraint::btSliderConstraint()
+}
+
+
+static btRigidBody s_fixed(0, 0, 0);
+btSliderConstraint::btSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB)
+ : btTypedConstraint(SLIDER_CONSTRAINT_TYPE, s_fixed, rbB)
+ ,
+ m_frameInB(frameInB),
+ m_useLinearReferenceFrameA(useLinearReferenceFrameB),
+ m_useSolveConstraintObsolete(false)
+// m_useSolveConstraintObsolete(true)
+{
+ ///not providing rigidbody B means implicitly using worldspace for body B
+// m_frameInA.getOrigin() = m_rbA.getCenterOfMassTransform()(m_frameInA.getOrigin());
+
+ initParams();
+}
+
-//-----------------------------------------------------------------------------
void btSliderConstraint::buildJacobian()
{
@@ -104,9 +120,9 @@ void btSliderConstraint::buildJacobian()
{
buildJacobianInt(m_rbB, m_rbA, m_frameInB, m_frameInA);
}
-} // btSliderConstraint::buildJacobian()
+}
+
-//-----------------------------------------------------------------------------
void btSliderConstraint::buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB)
{
@@ -159,9 +175,9 @@ void btSliderConstraint::buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, co
// clear accumulator for motors
m_accumulatedLinMotorImpulse = btScalar(0.0);
m_accumulatedAngMotorImpulse = btScalar(0.0);
-} // btSliderConstraint::buildJacobianInt()
+}
+
-//-----------------------------------------------------------------------------
void btSliderConstraint::getInfo1(btConstraintInfo1* info)
{
@@ -189,9 +205,9 @@ void btSliderConstraint::getInfo1(btConstraintInfo1* info)
info->nub--;
}
}
-} // btSliderConstraint::getInfo1()
+}
+
-//-----------------------------------------------------------------------------
void btSliderConstraint::getInfo2(btConstraintInfo2* info)
{
@@ -499,9 +515,9 @@ void btSliderConstraint::getInfo2(btConstraintInfo2* info)
info->m_constraintError[srow] *= getSoftnessLimAng();
} // if(limit)
} // if angular limit or powered
-} // btSliderConstraint::getInfo2()
+}
+
-//-----------------------------------------------------------------------------
void btSliderConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep)
{
@@ -517,9 +533,9 @@ void btSliderConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBod
solveConstraintInt(m_rbB,bodyB, m_rbA,bodyA);
}
}
-} // btSliderConstraint::solveConstraint()
+}
+
-//-----------------------------------------------------------------------------
void btSliderConstraint::solveConstraintInt(btRigidBody& rbA, btSolverBody& bodyA,btRigidBody& rbB, btSolverBody& bodyB)
{
@@ -703,11 +719,11 @@ void btSliderConstraint::solveConstraintInt(btRigidBody& rbA, btSolverBody& body
bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*axisA,-angImpulse);
}
}
-} // btSliderConstraint::solveConstraint()
+}
+
+
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
void btSliderConstraint::calculateTransforms(void){
if(m_useLinearReferenceFrameA || (!m_useSolveConstraintObsolete))
@@ -740,9 +756,9 @@ void btSliderConstraint::calculateTransforms(void){
normalWorld = m_calculatedTransformA.getBasis().getColumn(i);
m_depth[i] = m_delta.dot(normalWorld);
}
-} // btSliderConstraint::calculateTransforms()
+}
-//-----------------------------------------------------------------------------
+
void btSliderConstraint::testLinLimits(void)
{
@@ -769,9 +785,9 @@ void btSliderConstraint::testLinLimits(void)
{
m_depth[0] = btScalar(0.);
}
-} // btSliderConstraint::testLinLimits()
+}
+
-//-----------------------------------------------------------------------------
void btSliderConstraint::testAngLimits(void)
{
@@ -795,9 +811,9 @@ void btSliderConstraint::testAngLimits(void)
m_solveAngLim = true;
}
}
-} // btSliderConstraint::testAngLimits()
+}
-//-----------------------------------------------------------------------------
+
btVector3 btSliderConstraint::getAncorInA(void)
{
@@ -805,13 +821,13 @@ btVector3 btSliderConstraint::getAncorInA(void)
ancorInA = m_realPivotAInW + (m_lowerLinLimit + m_upperLinLimit) * btScalar(0.5) * m_sliderAxis;
ancorInA = m_rbA.getCenterOfMassTransform().inverse() * ancorInA;
return ancorInA;
-} // btSliderConstraint::getAncorInA()
+}
+
-//-----------------------------------------------------------------------------
btVector3 btSliderConstraint::getAncorInB(void)
{
btVector3 ancorInB;
ancorInB = m_frameInB.getOrigin();
return ancorInB;
-} // btSliderConstraint::getAncorInB();
+}
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h
index 70fbce5d9b2..01cef59ed31 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h
@@ -25,23 +25,23 @@ TODO:
#ifndef SLIDER_CONSTRAINT_H
#define SLIDER_CONSTRAINT_H
-//-----------------------------------------------------------------------------
+
#include "LinearMath/btVector3.h"
#include "btJacobianEntry.h"
#include "btTypedConstraint.h"
-//-----------------------------------------------------------------------------
+
class btRigidBody;
-//-----------------------------------------------------------------------------
+
#define SLIDER_CONSTRAINT_DEF_SOFTNESS (btScalar(1.0))
#define SLIDER_CONSTRAINT_DEF_DAMPING (btScalar(1.0))
#define SLIDER_CONSTRAINT_DEF_RESTITUTION (btScalar(0.7))
-//-----------------------------------------------------------------------------
+
class btSliderConstraint : public btTypedConstraint
{
@@ -126,6 +126,7 @@ protected:
public:
// constructors
btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
+ btSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB);
btSliderConstraint();
// overrides
virtual void buildJacobian();
@@ -223,7 +224,7 @@ public:
btVector3 getAncorInB(void);
};
-//-----------------------------------------------------------------------------
+
#endif //SLIDER_CONSTRAINT_H
diff --git a/extern/bullet2/src/CMakeLists.txt b/extern/bullet2/src/CMakeLists.txt
index 043fd3f6e7f..9b8a5a7e00e 100644
--- a/extern/bullet2/src/CMakeLists.txt
+++ b/extern/bullet2/src/CMakeLists.txt
@@ -1 +1,4 @@
-SUBDIRS( BulletCollision BulletDynamics LinearMath BulletSoftBody )
+ADD_SUBDIRECTORY(BulletCollision)
+ADD_SUBDIRECTORY(BulletDynamics)
+ADD_SUBDIRECTORY(LinearMath)
+ADD_SUBDIRECTORY(BulletSoftBody )
diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
index 822296164c1..08b2dee8af3 100644
--- a/extern/bullet2/src/LinearMath/btScalar.h
+++ b/extern/bullet2/src/LinearMath/btScalar.h
@@ -168,8 +168,12 @@ inline int btGetVersion()
///The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision.
#if defined(BT_USE_DOUBLE_PRECISION)
typedef double btScalar;
+//this number could be bigger in double precision
+#define BT_LARGE_FLOAT 1e30
#else
typedef float btScalar;
+//keep BT_LARGE_FLOAT*BT_LARGE_FLOAT < FLT_MAX
+#define BT_LARGE_FLOAT 1e18f
#endif
diff --git a/extern/libopenjpeg/jp2.c b/extern/libopenjpeg/jp2.c
index 14f9493c401..b2831cfb0b5 100644
--- a/extern/libopenjpeg/jp2.c
+++ b/extern/libopenjpeg/jp2.c
@@ -561,6 +561,7 @@ opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *c
image = j2k_decode(jp2->j2k, cio, cstr_info);
if(!image) {
opj_event_msg(cinfo, EVT_ERROR, "Failed to decode J2K image\n");
+ return NULL;
}
/* Set Image Color Space */
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 1c0d795448c..697d0b6b575 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -24,10 +24,20 @@
#
# ***** END GPL LICENSE BLOCK *****
-SUBDIRS(SoundSystem string ghost guardedalloc moto container memutil decimation iksolver boolop opennl)
+ADD_SUBDIRECTORY(SoundSystem)
+ADD_SUBDIRECTORY(string)
+ADD_SUBDIRECTORY(ghost)
+ADD_SUBDIRECTORY(guardedalloc)
+ADD_SUBDIRECTORY(moto)
+ADD_SUBDIRECTORY(container)
+ADD_SUBDIRECTORY(memutil)
+ADD_SUBDIRECTORY(decimation)
+ADD_SUBDIRECTORY(iksolver)
+ADD_SUBDIRECTORY(boolop)
+ADD_SUBDIRECTORY(opennl)
IF(WITH_ELBEEM)
- SUBDIRS(elbeem)
+ ADD_SUBDIRECTORY(elbeem)
ENDIF(WITH_ELBEEM)
-SUBDIRS(bsp)
+ADD_SUBDIRECTORY(bsp)
diff --git a/intern/SoundSystem/fmod/Makefile b/intern/SoundSystem/fmod/Makefile
deleted file mode 100644
index 47bc0348fe2..00000000000
--- a/intern/SoundSystem/fmod/Makefile
+++ /dev/null
@@ -1,43 +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 = FmodSoundSystem
-DIR = $(OCGDIR)/intern/$(LIBNAME)
-
-include nan_compile.mk
-
-CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
-
-CPPFLAGS += -I$(NAN_FMOD)/include
-CPPFLAGS += -I$(NAN_STRING)/include
-CPPFLAGS += -I$(NAN_MOTO)/include
-CPPFLAGS += -I../intern
-CPPFLAGS += -I..
-CPPFLAGS += -I.
diff --git a/intern/SoundSystem/fmod/SND_FmodDevice.cpp b/intern/SoundSystem/fmod/SND_FmodDevice.cpp
deleted file mode 100644
index 3ba0802a5b0..00000000000
--- a/intern/SoundSystem/fmod/SND_FmodDevice.cpp
+++ /dev/null
@@ -1,574 +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 *****
- * SND_FmodDevice derived from SND_IAudioDevice
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WIN32
-#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
-#endif //WIN32
-
-#include "SND_FmodDevice.h"
-#include "SoundDefines.h"
-#include "SND_Utils.h"
-
-SND_FmodDevice::SND_FmodDevice()
-{
- /* Removed the functionality for checking if noaudio was provided on */
- /* the commandline. */
- m_dspunit = NULL;
-
- m_audio = true;
-
- // let's check if we can get fmod to initialize...
- if (m_audio)
- {
- signed char MinHardwareChannels = FSOUND_SetMinHardwareChannels(NUM_FMOD_MIN_HW_CHANNELS);
- signed char MaxHardwareChannels = FSOUND_SetMaxHardwareChannels(NUM_FMOD_MAX_HW_CHANNELS);
-
- if (FSOUND_Init(MIXRATE, NUM_SOURCES, 0))
- {
- m_max_channels = FSOUND_GetMaxChannels();
- m_num_hardware_channels = FSOUND_GetNumHardwareChannels();
- m_num_software_channels = NUM_SOURCES;
-
- // let's get us a wavecache
- m_wavecache = new SND_WaveCache();
-
- int i;
- for (i = 0; i < NUM_BUFFERS; i++)
- m_buffers[i] = NULL;
-
- for (i = 0; i < NUM_SOURCES; i++)
- {
- m_sources[i] = NULL;
- m_frequencies[i] = 0;
- m_channels[i] = 0;
- }
- }
- else
- {
- m_audio = false;
- }
- }
-
-#ifdef ONTKEVER
- int numdrivers = FSOUND_GetNumDrivers();
- int output = FSOUND_GetOutput();
- int oputputrate = FSOUND_GetOutputRate();
- int mixer = FSOUND_GetMixer();
-
- printf("maxchannels is: %d\n", m_max_channels);
- printf("num hw channels is: %d\n", m_num_hardware_channels);
- printf("num sw channels is: %d\n", m_num_software_channels);
- printf("numdrivers is: %d\n", numdrivers);
- printf("output is: %d\n", output);
- printf("oputputrate is: %d\n", oputputrate);
- printf("mixer is: %d\n", mixer);
-#endif
-}
-
-
-
-SND_FmodDevice::~SND_FmodDevice()
-{
- // let's see if we used the cd. if not, just leave it alone
- SND_CDObject* pCD = SND_CDObject::Instance();
-
- if (pCD)
- {
- this->StopCD();
- SND_CDObject::DisposeSystem();
- }
-
- StopUsingDSP();
-
- FSOUND_Close();
-}
-
-
-
-void SND_FmodDevice::UseCD() const
-{
- // only fmod has CD support, so only create it here
- SND_CDObject::CreateSystem();
-}
-
-
-
-void SND_FmodDevice::MakeCurrent() const
-{
- // empty
-}
-
-
-
-SND_WaveSlot* SND_FmodDevice::LoadSample(const STR_String& name,
- void* memlocation,
- int size)
-{
- SND_WaveSlot* waveslot = NULL;
- STR_String samplename = name;
-
- if (m_audio)
- {
- /* first check if the sample is supported */
- if (SND_IsSampleValid(name, memlocation))
- {
- /* create the waveslot */
- waveslot = m_wavecache->GetWaveSlot(samplename);
-
- if (waveslot)
- {
- int buffer = waveslot->GetBuffer();
-
- /* load the sample from memory? */
- if (size && memlocation)
- {
- m_buffers[buffer] = FSOUND_Sample_Load(buffer, (char*)memlocation, FSOUND_LOADMEMORY, size);
-
- /* if the loading succeeded, fill the waveslot with info */
- if (m_buffers[buffer])
- {
- int sampleformat = SND_GetSampleFormat(memlocation);
- int numberofchannels = SND_GetNumberOfChannels(memlocation);
- int samplerate = SND_GetSampleRate(memlocation);
- int bitrate = SND_GetBitRate(memlocation);
- int numberofsamples = SND_GetNumberOfSamples(memlocation, size);
-
- waveslot->SetFileSize(size);
- waveslot->SetData(memlocation);
- waveslot->SetSampleFormat(sampleformat);
- waveslot->SetNumberOfChannels(numberofchannels);
- waveslot->SetSampleRate(samplerate);
- waveslot->SetBitRate(bitrate);
- waveslot->SetNumberOfSamples(numberofsamples);
- }
- }
- /* or from file? */
- else
- {
- m_buffers[buffer] = FSOUND_Sample_Load(buffer, samplename.Ptr(), FSOUND_LOOP_NORMAL, NULL);
- }
-
-#ifdef ONTKEVER
- int error = FSOUND_GetError();
- printf("sample load: errornumber is: %d\n", error);
-#endif
-
- /* if the loading succeeded, mark the waveslot */
- if (m_buffers[buffer])
- {
- waveslot->SetLoaded(true);
- }
- /* or when it failed, free the waveslot */
- else
- {
- m_wavecache->RemoveSample(waveslot->GetSampleName(), waveslot->GetBuffer());
- waveslot = NULL;
- }
- }
- }
- }
-
- return waveslot;
-}
-
-
-
-
-// listener's and general stuff //////////////////////////////////////////////////////
-
-
-
-/* sets the global dopplervelocity */
-void SND_FmodDevice::SetDopplerVelocity(MT_Scalar dopplervelocity) const
-{
- /* not supported by fmod */
- FSOUND_3D_Listener_SetDopplerFactor(dopplervelocity);
-}
-
-
-
-/* sets the global dopplerfactor */
-void SND_FmodDevice::SetDopplerFactor(MT_Scalar dopplerfactor) const
-{
- FSOUND_3D_Listener_SetDopplerFactor(dopplerfactor);
-}
-
-
-
-/* sets the global rolloff factor */
-void SND_FmodDevice::SetListenerRollOffFactor(MT_Scalar rollofffactor) const
-{
- // not implemented in openal
-}
-
-
-
-void SND_FmodDevice::NextFrame() const
-{
- FSOUND_3D_Update();
-}
-
-
-
-// set the gain for the listener
-void SND_FmodDevice::SetListenerGain(float gain) const
-{
- int fmod_gain = (int)(gain * 255);
- FSOUND_SetSFXMasterVolume(fmod_gain);
-}
-
-
-
-void SND_FmodDevice::InitListener()
-{
- // initialize the listener with these values that won't change
- // (as long as we can have only one listener)
- // now we can superimpose all listeners on each other (for they
- // have the same settings)
- float lispos[3] = {0,0,0};
- float lisvel[3] = {0,0,0};
-
- FSOUND_3D_Listener_SetAttributes(lispos, lisvel, 0, -1, 0, 0, 0, 1);
-}
-
-
-
-// source playstate stuff ////////////////////////////////////////////////////////////
-
-
-
-// check if the sound's still playing
-int SND_FmodDevice::GetPlayState(int id)
-{
- int result = SND_STOPPED;
-
- // klopt niet, fixen
- signed char isplaying = FSOUND_IsPlaying(id);
-
- if (isplaying)
- {
- result = SND_PLAYING;
- }
-
-/* hi reevan, just swap // of these 2 lines */
-// return result;
- return 0;
-}
-
-
-
-/* sets the buffer */
-void SND_FmodDevice::SetObjectBuffer(int id, unsigned int buffer)
-{
- m_sources[id] = m_buffers[buffer];
-}
-
-
-
-// make the source play
-void SND_FmodDevice::PlayObject(int id)
-{
- m_channels[id] = FSOUND_PlaySound(FSOUND_FREE, m_sources[id]);
- m_frequencies[id] = FSOUND_GetFrequency(m_channels[id]);
-// printf("fmod: play \n");
-}
-
-
-
-// make the source stop
-void SND_FmodDevice::StopObject(int id) const
-{
- FSOUND_StopSound(m_channels[id]);
-// printf("fmod: stop \n");
-}
-
-
-
-// stop all sources
-void SND_FmodDevice::StopAllObjects()
-{
- FSOUND_StopSound(FSOUND_ALL);
-}
-
-
-
-// pause the source
-void SND_FmodDevice::PauseObject(int id) const
-{
- FSOUND_StopSound(m_channels[id]);
-}
-
-
-
-// source properties stuff ////////////////////////////////////////////////////////////
-
-
-
-// give openal the object's pitch
-void SND_FmodDevice::SetObjectPitch(int id, MT_Scalar pitch) const
-{
- pitch = pitch * m_frequencies[id];
- char result = FSOUND_SetFrequency(m_channels[id], (int)pitch);
-}
-
-
-
-// give openal the object's gain
-void SND_FmodDevice::SetObjectGain(int id, MT_Scalar gain) const
-{
- int vol = (int)(gain * 255);
- FSOUND_SetVolume(m_channels[id], vol);
-}
-
-
-
-// give openal the object's looping
-void SND_FmodDevice::SetObjectLoop(int id, unsigned int loopmode) const
-{
-// printf("loopmode: %d\n", loopmode);
- switch (loopmode)
- {
- case SND_LOOP_OFF:
- {
-#ifndef __APPLE__
- char result = FSOUND_Sample_SetLoopMode(m_sources[id], FSOUND_LOOP_OFF);
-#else
- char result = FSOUND_SetLoopMode(m_sources[id], FSOUND_LOOP_OFF);
-#endif
-// char result = FSOUND_SetLoopMode(m_channels[id], FSOUND_LOOP_OFF);
- break;
- }
- case SND_LOOP_NORMAL:
- {
-#ifndef __APPLE__
- char result = FSOUND_Sample_SetLoopMode(m_sources[id], FSOUND_LOOP_NORMAL);
-#else
- char result = FSOUND_SetLoopMode(m_sources[id], FSOUND_LOOP_NORMAL);
-#endif
-// char result = FSOUND_SetLoopMode(m_channels[id], FSOUND_LOOP_NORMAL);
- break;
- }
- case SND_LOOP_BIDIRECTIONAL:
- {
-#ifndef __APPLE__
- char result = FSOUND_Sample_SetLoopMode(m_sources[id], FSOUND_LOOP_BIDI);
-#else
- char result = FSOUND_SetLoopMode(m_sources[id], FSOUND_LOOP_BIDI);
-#endif
-// char result = FSOUND_SetLoopMode(m_channels[id], FSOUND_LOOP_NORMAL);
- break;
- }
- default:
- break;
- }
-}
-
-
-
-void SND_FmodDevice::SetObjectLoopPoints(int id, unsigned int loopstart, unsigned int loopend) const
-{
- FSOUND_Sample_SetLoopPoints(m_sources[id], loopstart, loopend);
-}
-
-
-
-void SND_FmodDevice::SetObjectMinGain(int id, MT_Scalar mingain) const
-{
- /* not supported by fmod */
-}
-
-
-
-void SND_FmodDevice::SetObjectMaxGain(int id, MT_Scalar maxgain) const
-{
- /* not supported by fmod */
-}
-
-
-
-void SND_FmodDevice::SetObjectRollOffFactor(int id, MT_Scalar rollofffactor) const
-{
- /* not supported by fmod */
-}
-
-
-
-void SND_FmodDevice::SetObjectReferenceDistance(int id, MT_Scalar referencedistance) const
-{
- /* not supported by fmod */
-}
-
-
-
-// give openal the object's position
-void SND_FmodDevice::ObjectIs2D(int id) const
-{
- float obpos[3] = {0,0,0};
- float obvel[3] = {0,0,0};
-
- FSOUND_3D_SetAttributes(m_channels[id], obpos, obvel);
-}
-
-
-
-void SND_FmodDevice::SetObjectTransform(int id,
- const MT_Vector3& position,
- const MT_Vector3& velocity,
- const MT_Matrix3x3& orientation,
- const MT_Vector3& lisposition,
- const MT_Scalar& rollofffactor) const
-{
- float obpos[3];
- float obvel[3];
-
- obpos[0] = (float)position[0] * (float)rollofffactor; //x (l/r)
- obpos[1] = (float)position[1] * (float)rollofffactor;
- obpos[2] = (float)position[2] * (float)rollofffactor;
-
- velocity.getValue(obvel);
- FSOUND_3D_SetAttributes(m_channels[id], obpos, obvel);
-}
-
-
-
-// cd support stuff ////////////////////////////////////////////////////////////
-
-
-void SND_FmodDevice::PlayCD(int track) const
-{
-#ifndef __APPLE__
- signed char result = FSOUND_CD_Play(track);
-#else
- signed char result = FSOUND_CD_Play(0, track);
-#endif
-
-#ifdef ONTKEVER
- printf("SND_FmodDevice::PlayCD(): track=%d, result=%d\n", track, (int)result);
-#endif
-}
-
-
-
-void SND_FmodDevice::PauseCD(bool pause) const
-{
-#ifndef __APPLE__
- signed char result = FSOUND_CD_SetPaused(pause);
-#else
- signed char result = FSOUND_CD_SetPaused(0, pause);
-#endif
-
-#ifdef ONTKEVER
- printf("SND_FmodDevice::PauseCD(): pause=%d, result=%d\n", pause, (int)result);
-#endif
-}
-
-
-
-void SND_FmodDevice::StopCD() const
-{
- SND_CDObject* pCD = SND_CDObject::Instance();
-
- if (pCD)
- {
- if (pCD->GetUsed())
- {
-#ifndef __APPLE__
- signed char result = FSOUND_CD_Stop();
-#else
- signed char result = FSOUND_CD_Stop(0);
-#endif
-
-#ifdef ONTKEVER
- printf("SND_FmodDevice::StopCD(): result=%d\n", (int)result);
-#endif
- }
- }
-}
-
-
-
-void SND_FmodDevice::SetCDPlaymode(int playmode) const
-{
-#ifndef __APPLE__
- FSOUND_CD_SetPlayMode(playmode);
-#else
- FSOUND_CD_SetPlayMode(0, playmode);
-#endif
-
-#ifdef ONTKEVER
- printf("SND_FmodDevice::SetCDPlaymode(): playmode=%d,\n", playmode);
-#endif
-}
-
-
-
-void SND_FmodDevice::SetCDGain(MT_Scalar gain) const
-{
- int volume = gain * 255;
-#ifndef __APPLE__
- signed char result = FSOUND_CD_SetVolume(volume);
-#else
- signed char result = FSOUND_CD_SetVolume(0, volume);
-#endif
-
-#ifdef ONTKEVER
- printf("SND_FmodDevice::SetCDGain(): gain=%f, volume=%d, result=%d\n", gain, volume, (int)result);
-#endif
-}
-
-
-
-void SND_FmodDevice::StartUsingDSP()
-{
- m_dspunit = FSOUND_DSP_GetFFTUnit();
-
- FSOUND_DSP_SetActive(m_dspunit, true);
-}
-
-
-
-float* SND_FmodDevice::GetSpectrum()
-{
- m_spectrum = FSOUND_DSP_GetSpectrum();
-
- return m_spectrum;
-}
-
-
-
-void SND_FmodDevice::StopUsingDSP()
-{
- if (m_dspunit)
- FSOUND_DSP_SetActive(m_dspunit, false);
-}
diff --git a/intern/SoundSystem/fmod/SND_FmodDevice.h b/intern/SoundSystem/fmod/SND_FmodDevice.h
deleted file mode 100644
index 294ee4e3a72..00000000000
--- a/intern/SoundSystem/fmod/SND_FmodDevice.h
+++ /dev/null
@@ -1,103 +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 SND_FMODDEVICE
-#define SND_FMODDEVICE
-
-#include "fmod.h"
-#include "SND_AudioDevice.h"
-#include "SoundDefines.h"
-
-class SND_FmodDevice : public SND_AudioDevice
-{
-public:
- SND_FmodDevice();
- ~SND_FmodDevice();
-
- SND_WaveSlot* LoadSample(const STR_String& samplename,
- void* memlocation,
- int size);
-
- void InitListener();
- void SetListenerGain(float gain) const;
- void SetDopplerVelocity(MT_Scalar dopplervelocity) const;
- void SetDopplerFactor(MT_Scalar dopplerfactor) const;
- void SetListenerRollOffFactor(MT_Scalar rollofffactor) const;
-
- void MakeCurrent() const;
- void NextFrame() const;
- void UseCD() const;
-
- void SetObjectBuffer(int id, unsigned int buffer);
- int GetPlayState(int id);
- void PlayObject(int id);
- void StopObject(int id) const;
- void StopAllObjects();
- void PauseObject(int id) const;
-
- void SetObjectLoop(int id, unsigned int loopmode) const;
- void SetObjectLoopPoints(int id, unsigned int loopstart, unsigned int loopend) const;
- void SetObjectPitch(int id, MT_Scalar pitch) const;
- void SetObjectGain(int id, MT_Scalar gain) const;
- void SetObjectMinGain(int id, MT_Scalar mingain) const;
- void SetObjectMaxGain(int id, MT_Scalar maxgain) const;
- void SetObjectRollOffFactor(int id, MT_Scalar rolloff) const;
- void SetObjectReferenceDistance(int id, MT_Scalar distance) const;
-
- void SetObjectTransform(int id,
- const MT_Vector3& position,
- const MT_Vector3& velocity,
- const MT_Matrix3x3& orientation,
- const MT_Vector3& lisposition,
- const MT_Scalar& rollofffactor) const;
- void ObjectIs2D(int id) const;
-
- void PlayCD(int track) const;
- void PauseCD(bool pause) const;
- void StopCD() const;
- void SetCDPlaymode(int playmode) const;
- void SetCDGain(MT_Scalar gain) const;
-
- void StartUsingDSP();
- float* GetSpectrum();
- void StopUsingDSP();
-
-private:
- FSOUND_SAMPLE* m_buffers[NUM_BUFFERS];
- FSOUND_SAMPLE* m_sources[NUM_SOURCES];
- FSOUND_DSPUNIT* m_dspunit;
- int m_frequencies[NUM_SOURCES];
- int m_max_channels;
- int m_num_hardware_channels;
- int m_num_software_channels;
- int m_channels[NUM_SOURCES];
- float* m_spectrum;
-};
-
-#endif //SND_FMODDEVICE
-
diff --git a/intern/SoundSystem/openal/SND_OpenALDevice.cpp b/intern/SoundSystem/openal/SND_OpenALDevice.cpp
index 3649cf6de5a..424a05246ac 100644
--- a/intern/SoundSystem/openal/SND_OpenALDevice.cpp
+++ b/intern/SoundSystem/openal/SND_OpenALDevice.cpp
@@ -43,11 +43,9 @@
#ifdef APPLE_FRAMEWORK_FIX
#include <al.h>
#include <alc.h>
-#include <alut.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
-#include <AL/alut.h>
#endif
#include <stdio.h>
@@ -61,13 +59,12 @@
#include <signal.h>
-/* untill openal gets unified we need this hack for non-windows systems */
-#if !defined(WIN32) && !defined(ALC_MAJOR_VERSION)
+/*************************** ALUT replacement *****************************/
-#include <malloc.h>
+/* instead of relying on alut, we just implement our own
+ * WAV loading functions, hopefully more reliable */
-ALvoid alutLoadWAVMemory(ALbyte *memory,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq,ALboolean *loop);
-ALvoid alutUnloadWAV(ALenum format,ALvoid *data,ALsizei size,ALsizei freq);
+#include <stdlib.h>
typedef struct /* WAV File-header */
{
@@ -120,93 +117,189 @@ typedef struct /* WAV Chunk-header */
ALuint Size;
} WAVChunkHdr_Struct;
-ALvoid alutLoadWAVMemory(ALbyte *memory,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq,ALboolean *loop)
+static void *SND_loadFileIntoMemory(const char *filename, int *len_r)
+{
+ FILE *fp= fopen(filename, "rb");
+ void *data;
+
+ if (!fp) {
+ *len_r= -1;
+ return NULL;
+ }
+
+ fseek(fp, 0L, SEEK_END);
+ *len_r= ftell(fp);
+ fseek(fp, 0L, SEEK_SET);
+
+ data= malloc(*len_r);
+ if (!data) {
+ *len_r= -1;
+ return NULL;
+ }
+
+ if (fread(data, *len_r, 1, fp)!=1) {
+ *len_r= -1;
+ free(data);
+ return NULL;
+ }
+
+ return data;
+}
+
+#define TEST_SWITCH_INT(a) if(big_endian) { \
+ char s_i, *p_i; \
+ p_i= (char *)&(a); \
+ s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
+ s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
+
+#define TEST_SWITCH_SHORT(a) if(big_endian) { \
+ char s_i, *p_i; \
+ p_i= (char *)&(a); \
+ s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; }
+
+static int stream_read(void *out, ALbyte **stream, ALsizei size, ALsizei *memsize)
+{
+ if(size <= *memsize) {
+ memcpy(out, *stream, size);
+ return 1;
+ }
+ else {
+ memset(out, 0, size);
+ return 0;
+ }
+}
+
+static int stream_skip(ALbyte **stream, ALsizei size, ALsizei *memsize)
+{
+ if(size <= *memsize) {
+ *stream += size;
+ *memsize -= size;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+ALvoid SND_alutLoadWAVMemory(ALbyte *memory,ALsizei memsize,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq,ALboolean *loop)
{
WAVChunkHdr_Struct ChunkHdr;
WAVFmtExHdr_Struct FmtExHdr;
WAVFileHdr_Struct FileHdr;
WAVSmplHdr_Struct SmplHdr;
WAVFmtHdr_Struct FmtHdr;
- ALbyte *Stream;
+ ALbyte *Stream= memory;
+ int test_endian= 1;
+ int big_endian= !((char*)&test_endian)[0];
*format=AL_FORMAT_MONO16;
*data=NULL;
*size=0;
*freq=22050;
*loop=AL_FALSE;
- if (memory)
+
+ if(!Stream)
+ return;
+
+ stream_read(&FileHdr,&Stream,sizeof(WAVFileHdr_Struct),&memsize);
+ stream_skip(&Stream,sizeof(WAVFileHdr_Struct),&memsize);
+
+ TEST_SWITCH_INT(FileHdr.Size);
+ FileHdr.Size=((FileHdr.Size+1)&~1)-4;
+
+ while((FileHdr.Size!=0) && stream_read(&ChunkHdr,&Stream,sizeof(WAVChunkHdr_Struct),&memsize))
{
- Stream=memory;
- if (Stream)
+ TEST_SWITCH_INT(ChunkHdr.Size);
+ stream_skip(&Stream,sizeof(WAVChunkHdr_Struct),&memsize);
+
+ if (!memcmp(ChunkHdr.Id,"fmt ",4))
{
- memcpy(&FileHdr,Stream,sizeof(WAVFileHdr_Struct));
- Stream+=sizeof(WAVFileHdr_Struct);
- FileHdr.Size=((FileHdr.Size+1)&~1)-4;
- while ((FileHdr.Size!=0)&&(memcpy(&ChunkHdr,Stream,sizeof(WAVChunkHdr_Struct))))
+ stream_read(&FmtHdr,&Stream,sizeof(WAVFmtHdr_Struct),&memsize);
+
+ TEST_SWITCH_SHORT(FmtHdr.Format);
+ TEST_SWITCH_SHORT(FmtHdr.Channels);
+ TEST_SWITCH_INT(FmtHdr.SamplesPerSec);
+ TEST_SWITCH_INT(FmtHdr.BytesPerSec);
+ TEST_SWITCH_SHORT(FmtHdr.BlockAlign);
+ TEST_SWITCH_SHORT(FmtHdr.BitsPerSample);
+
+ if (FmtHdr.Format==0x0001)
{
- Stream+=sizeof(WAVChunkHdr_Struct);
- if (!memcmp(ChunkHdr.Id,"fmt ",4))
- {
- memcpy(&FmtHdr,Stream,sizeof(WAVFmtHdr_Struct));
- if (FmtHdr.Format==0x0001)
- {
- *format=(FmtHdr.Channels==1?
- (FmtHdr.BitsPerSample==8?AL_FORMAT_MONO8:AL_FORMAT_MONO16):
- (FmtHdr.BitsPerSample==8?AL_FORMAT_STEREO8:AL_FORMAT_STEREO16));
- *freq=FmtHdr.SamplesPerSec;
- Stream+=ChunkHdr.Size;
- }
- else
- {
- memcpy(&FmtExHdr,Stream,sizeof(WAVFmtExHdr_Struct));
- Stream+=ChunkHdr.Size;
- }
- }
- else if (!memcmp(ChunkHdr.Id,"data",4))
+ *format=(FmtHdr.Channels==1?
+ (FmtHdr.BitsPerSample==8?AL_FORMAT_MONO8:AL_FORMAT_MONO16):
+ (FmtHdr.BitsPerSample==8?AL_FORMAT_STEREO8:AL_FORMAT_STEREO16));
+ *freq=FmtHdr.SamplesPerSec;
+ }
+ else
+ {
+ stream_read(&FmtExHdr,&Stream,sizeof(WAVFmtExHdr_Struct),&memsize);
+ TEST_SWITCH_SHORT(FmtExHdr.Size);
+ TEST_SWITCH_SHORT(FmtExHdr.SamplesPerBlock);
+ }
+ }
+ else if (!memcmp(ChunkHdr.Id,"data",4))
+ {
+ if (FmtHdr.Format==0x0001)
+ {
+ if((ALsizei)ChunkHdr.Size <= memsize)
{
- if (FmtHdr.Format==0x0001)
- {
- *size=ChunkHdr.Size;
- *data=malloc(ChunkHdr.Size+31);
- if (*data) memcpy(*data,Stream,ChunkHdr.Size);
+ *size=ChunkHdr.Size;
+ *data=malloc(ChunkHdr.Size+31);
+
+ if (*data) {
+ stream_read(*data,&Stream,ChunkHdr.Size,&memsize);
memset(((char *)*data)+ChunkHdr.Size,0,31);
- Stream+=ChunkHdr.Size;
- }
- else if (FmtHdr.Format==0x0011)
- {
- //IMA ADPCM
- }
- else if (FmtHdr.Format==0x0055)
- {
- //MP3 WAVE
+
+ if(FmtHdr.BitsPerSample == 16 && big_endian) {
+ int a, len= *size/2;
+ short *samples= (short*)*data;
+
+ for(a=0; a<len; a++) {
+ TEST_SWITCH_SHORT(samples[a])
+ }
+ }
}
}
- else if (!memcmp(ChunkHdr.Id,"smpl",4))
- {
- memcpy(&SmplHdr,Stream,sizeof(WAVSmplHdr_Struct));
- *loop = (SmplHdr.Loops ? AL_TRUE : AL_FALSE);
- Stream+=ChunkHdr.Size;
- }
- else Stream+=ChunkHdr.Size;
- Stream+=ChunkHdr.Size&1;
- FileHdr.Size-=(((ChunkHdr.Size+1)&~1)+8);
+ }
+ else if (FmtHdr.Format==0x0011)
+ {
+ //IMA ADPCM
+ }
+ else if (FmtHdr.Format==0x0055)
+ {
+ //MP3 WAVE
}
}
+ else if (!memcmp(ChunkHdr.Id,"smpl",4))
+ {
+ stream_read(&SmplHdr,&Stream,sizeof(WAVSmplHdr_Struct),&memsize);
+
+ TEST_SWITCH_INT(SmplHdr.Manufacturer);
+ TEST_SWITCH_INT(SmplHdr.Product);
+ TEST_SWITCH_INT(SmplHdr.SamplePeriod);
+ TEST_SWITCH_INT(SmplHdr.Note);
+ TEST_SWITCH_INT(SmplHdr.FineTune);
+ TEST_SWITCH_INT(SmplHdr.SMPTEFormat);
+ TEST_SWITCH_INT(SmplHdr.SMPTEOffest);
+ TEST_SWITCH_INT(SmplHdr.Loops);
+ TEST_SWITCH_INT(SmplHdr.SamplerData);
+
+ *loop = (SmplHdr.Loops ? AL_TRUE : AL_FALSE);
+ }
+
+ if(!stream_skip(&Stream, ChunkHdr.Size + (ChunkHdr.Size&1), &memsize))
+ break;
+
+ FileHdr.Size-=(((ChunkHdr.Size+1)&~1)+8);
}
}
-ALvoid alutUnloadWAV(ALenum format,ALvoid *data,ALsizei size,ALsizei freq)
+ALvoid SND_alutUnloadWAV(ALenum format,ALvoid *data,ALsizei size,ALsizei freq)
{
if (data)
free(data);
}
-#endif /* WIN32 */
-
-#ifdef __APPLE__
-#define OUDE_OPENAL 1
-#endif
-
+/************************ Device Implementation ****************************/
SND_OpenALDevice::SND_OpenALDevice()
: SND_AudioDevice(),
@@ -223,10 +316,6 @@ SND_OpenALDevice::SND_OpenALDevice()
// let's check if we can get openal to initialize...
if (m_audio)
{
-#ifdef OUDE_OPENAL
- m_audio = true; // openal_2.12
- alutInit(NULL, NULL); // openal_2.12
-#else
m_audio = false;
ALCdevice *dev = alcOpenDevice(NULL);
@@ -236,7 +325,6 @@ SND_OpenALDevice::SND_OpenALDevice()
if (m_context) {
#ifdef AL_VERSION_1_1
alcMakeContextCurrent((ALCcontext*)m_context);
- alutInitWithoutContext(NULL, NULL); /* in this case we dont want alut to initialize the context, see above */
#else
alcMakeContextCurrent(m_context);
#endif
@@ -259,7 +347,6 @@ SND_OpenALDevice::SND_OpenALDevice()
}
}
-#endif
}
// then try to generate some buffers
@@ -283,7 +370,7 @@ SND_OpenALDevice::SND_OpenALDevice()
// next: the sources
if (m_audio)
{
-#ifdef OUDE_OPENAL
+#ifdef __APPLE__
ALenum alc_error = ALC_NO_ERROR; // openal_2.12
#elif defined(_WIN32)
// alcGetError has no arguments on windows
@@ -375,20 +462,11 @@ SND_OpenALDevice::~SND_OpenALDevice()
if (m_cdrom)
delete m_cdrom;
#endif
-#ifdef OUDE_OPENAL
- if (m_audio)
- alutExit();
-#else
if (m_device)
alcCloseDevice((ALCdevice*) m_device);
-#ifdef AL_VERSION_1_1
- alutExit();
-#endif
-#endif
}
-
SND_WaveSlot* SND_OpenALDevice::LoadSample(const STR_String& name,
void* memlocation,
int size)
@@ -406,23 +484,22 @@ SND_WaveSlot* SND_OpenALDevice::LoadSample(const STR_String& name,
{
if (waveslot)
{
+ bool freemem = false;
int buffer = waveslot->GetBuffer();
void* data = NULL;
-#ifndef __APPLE__
char loop = 'a';
-#endif
int sampleformat, bitrate, numberofchannels;
ALenum al_error = alGetError();
-
-#ifdef OUDE_OPENAL
- ALsizei samplerate, numberofsamples; // openal_2.12
-#else
- int samplerate, numberofsamples; // openal_2.14+
-#endif
+ ALsizei samplerate, numberofsamples; // openal_2.14+
/* Give them some safe defaults just incase */
bitrate = numberofchannels = 0;
+ if (!(size && memlocation)) {
+ memlocation = SND_loadFileIntoMemory(samplename.Ptr(), &size);
+ freemem = true;
+ }
+
/* load the sample from memory? */
if (size && memlocation)
{
@@ -437,33 +514,14 @@ SND_WaveSlot* SND_OpenALDevice::LoadSample(const STR_String& name,
bitrate = SND_GetBitRate(memlocation);
/* load the sample into openal */
-#if defined(OUDE_OPENAL) || defined (__APPLE__)
- alutLoadWAVMemory((char*)memlocation, &sampleformat, &data, &numberofsamples, &samplerate); // openal_2.12
-#else
-#ifdef AL_VERSION_1_1
- float frequency = 0.0f;
- data = alutLoadMemoryFromFileImage(memlocation, size, &sampleformat, &numberofsamples, &frequency);
- samplerate = (int)frequency;
-#else
- alutLoadWAVMemory((signed char*)memlocation, &sampleformat, &data, &numberofsamples, &samplerate, &loop);// openal_2.14+
-
-#endif
-#endif
- /* put it in the buffer */
- alBufferData(m_buffers[buffer], sampleformat, data, numberofsamples, samplerate);
- }
- /* or from file? */
- else
- {
-#ifdef __APPLE__
- alutLoadWAVFile((ALbyte *)samplename.Ptr(), &sampleformat, &data, &numberofsamples, &samplerate);
-#else
- alutLoadWAVFile((ALbyte *)samplename.Ptr(), &sampleformat, &data, &numberofsamples, &samplerate, &loop);
-#endif
+ SND_alutLoadWAVMemory((ALbyte*)memlocation, size, &sampleformat, &data, &numberofsamples, &samplerate, &loop);
/* put it in the buffer */
alBufferData(m_buffers[buffer], sampleformat, data, numberofsamples, samplerate);
}
+ if(freemem)
+ free(memlocation);
+
/* fill the waveslot with info */
al_error = alGetError();
if (al_error == AL_NO_ERROR && m_buffers[buffer])
@@ -486,11 +544,7 @@ SND_WaveSlot* SND_OpenALDevice::LoadSample(const STR_String& name,
}
/* and free the original stuff (copy was made in openal) */
-#if defined(OUDE_OPENAL) || defined (__APPLE__) || !defined(AL_VERSION_1_1)
- alutUnloadWAV(sampleformat, data, numberofsamples, samplerate);
-#else
- free(data);
-#endif
+ SND_alutUnloadWAV(sampleformat, data, numberofsamples, samplerate);
}
}
else
@@ -594,7 +648,7 @@ int SND_OpenALDevice::GetPlayState(int id)
#ifdef __APPLE__
alGetSourcei(m_sources[id], AL_SOURCE_STATE, &alstate);
#else
- alGetSourceiv(m_sources[id], AL_SOURCE_STATE, &alstate);
+ alGetSourceiv(m_sources[id], AL_SOURCE_STATE, &alstate);
#endif
switch(alstate)
diff --git a/intern/SoundSystem/sdl/SND_SDLCDDevice.cpp b/intern/SoundSystem/sdl/SND_SDLCDDevice.cpp
index b1bac964c61..5054c39e8a1 100644
--- a/intern/SoundSystem/sdl/SND_SDLCDDevice.cpp
+++ b/intern/SoundSystem/sdl/SND_SDLCDDevice.cpp
@@ -43,6 +43,8 @@
#ifndef DISABLE_SDL
#include <SDL.h>
+#else
+#include <stdio.h>
#endif
SND_SDLCDDevice::SND_SDLCDDevice() :
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp
index 1043d0938b4..fb1b96fcbc7 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.cpp
+++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp
@@ -34,7 +34,6 @@
* @date May 7, 2001
*/
-
#include <Carbon/Carbon.h>
#include <ApplicationServices/ApplicationServices.h>
#include "GHOST_SystemCarbon.h"
@@ -430,6 +429,29 @@ GHOST_IWindow* GHOST_SystemCarbon::createWindow(
return window;
}
+GHOST_TSuccess GHOST_SystemCarbon::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, const bool stereoVisual)
+{
+ GHOST_TSuccess success = GHOST_kFailure;
+
+ // need yo make this Carbon all on 10.5 for fullscreen to work correctly
+ CGCaptureAllDisplays();
+
+ success = GHOST_System::beginFullScreen( setting, window, stereoVisual);
+
+ if( success != GHOST_kSuccess ) {
+ // fullscreen failed for other reasons, release
+ CGReleaseAllDisplays();
+ }
+
+ return success;
+}
+
+GHOST_TSuccess GHOST_SystemCarbon::endFullScreen(void)
+{
+ CGReleaseAllDisplays();
+ return GHOST_System::endFullScreen();
+}
+
/* this is an old style low level event queue.
As we want to handle our own timers, this is ok.
the full screen hack should be removed */
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.h b/intern/ghost/intern/GHOST_SystemCarbon.h
index 62d45ee769d..5b3b786a5ac 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.h
+++ b/intern/ghost/intern/GHOST_SystemCarbon.h
@@ -118,6 +118,14 @@ public:
const GHOST_TEmbedderWindowID parentWindow = 0
);
+ virtual GHOST_TSuccess beginFullScreen(
+ const GHOST_DisplaySetting& setting,
+ GHOST_IWindow** window,
+ const bool stereoVisual
+ );
+
+ virtual GHOST_TSuccess endFullScreen( void );
+
/***************************************************************************************
** Event management functionality
***************************************************************************************/
diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c
index 5c59640200f..979e77ebbed 100644
--- a/intern/guardedalloc/intern/mmap_win.c
+++ b/intern/guardedalloc/intern/mmap_win.c
@@ -162,6 +162,7 @@ intptr_t munmap(void *ptr, intptr_t size)
CloseHandle( mm->maphandle );
CloseHandle( mm->fhandle);
mmap_remlink(mmapbase, mm);
+ free(mm);
return 0;
}
diff --git a/projectfiles_vc9/gameengine/converter/KX_converter.vcproj b/projectfiles_vc9/gameengine/converter/KX_converter.vcproj
index b759aae1c9e..a085a7eac2a 100644
--- a/projectfiles_vc9/gameengine/converter/KX_converter.vcproj
+++ b/projectfiles_vc9/gameengine/converter/KX_converter.vcproj
@@ -480,10 +480,6 @@
>
</File>
<File
- RelativePath="..\..\..\source\gameengine\Converter\BL_ArmatureObject.cpp"
- >
- </File>
- <File
RelativePath="..\..\..\source\gameengine\Converter\BL_BlenderDataConversion.cpp"
>
</File>
@@ -496,6 +492,10 @@
>
</File>
<File
+ RelativePath="..\..\..\source\gameengine\Converter\BL_ModifierDeformer.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\gameengine\Converter\BL_ShapeActionActuator.cpp"
>
</File>
@@ -553,6 +553,10 @@
>
</File>
<File
+ RelativePath="..\..\..\source\gameengine\Converter\BL_ArmatureObject.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\gameengine\Converter\BL_ArmatureObject.h"
>
</File>
@@ -569,6 +573,10 @@
>
</File>
<File
+ RelativePath="..\..\..\source\gameengine\Converter\BL_ModifierDeformer.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\gameengine\Converter\BL_ShapeActionActuator.h"
>
</File>
diff --git a/projectfiles_vc9/gameengine/expression/EXP_expressions.vcproj b/projectfiles_vc9/gameengine/expression/EXP_expressions.vcproj
index 436a007dffb..a8b94c3f4a0 100644
--- a/projectfiles_vc9/gameengine/expression/EXP_expressions.vcproj
+++ b/projectfiles_vc9/gameengine/expression/EXP_expressions.vcproj
@@ -4,6 +4,7 @@
Version="9,00"
Name="EXP_expressions"
ProjectGUID="{EADC3C5A-6C51-4F03-8038-1553E7D7F740}"
+ RootNamespace="EXP_expressions"
TargetFrameworkVersion="131072"
>
<Platforms>
@@ -42,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\SceneGraph"
PreprocessorDefinitions="WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -117,7 +118,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\SceneGraph"
PreprocessorDefinitions="WIN32,_LIB,EXP_PYTHON_EMBEDDING,_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -192,7 +193,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\SceneGraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,EXP_PYTHON_EMBEDDING"
StringPooling="true"
RuntimeLibrary="2"
@@ -267,7 +268,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\SceneGraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,EXP_PYTHON_EMBEDDING"
StringPooling="true"
RuntimeLibrary="0"
@@ -342,7 +343,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\SceneGraph"
PreprocessorDefinitions="WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -417,7 +418,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\SceneGraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,EXP_PYTHON_EMBEDDING"
StringPooling="true"
RuntimeLibrary="0"
diff --git a/projectfiles_vc9/gameengine/gamelogic/SCA_GameLogic.vcproj b/projectfiles_vc9/gameengine/gamelogic/SCA_GameLogic.vcproj
index e350db5dad8..e4d41824fb1 100644
--- a/projectfiles_vc9/gameengine/gamelogic/SCA_GameLogic.vcproj
+++ b/projectfiles_vc9/gameengine/gamelogic/SCA_GameLogic.vcproj
@@ -4,6 +4,7 @@
Version="9,00"
Name="SCA_GameLogic"
ProjectGUID="{32CC75E2-EE85-45E6-8E3D-513F58464F43}"
+ RootNamespace="SCA_GameLogic"
TargetFrameworkVersion="131072"
>
<Platforms>
@@ -42,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -117,7 +118,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,EXP_PYTHON_EMBEDDING"
StringPooling="true"
RuntimeLibrary="0"
@@ -192,7 +193,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,EXP_PYTHON_EMBEDDING"
StringPooling="true"
RuntimeLibrary="2"
@@ -267,7 +268,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="WIN32,_LIB,EXP_PYTHON_EMBEDDING,_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -342,7 +343,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -417,7 +418,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Rasterizer;..\..\..\source\blender\makesdna;..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,EXP_PYTHON_EMBEDDING"
StringPooling="true"
RuntimeLibrary="0"
diff --git a/projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj b/projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj
index 01ccd916edb..5cd8a9c469b 100644
--- a/projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj
+++ b/projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj
@@ -166,12 +166,13 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="odelib.lib fmodvc.lib ws2_32.lib vfw32.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib openal_static.lib libjpeg.lib dxguid.lib libeay32.lib libpng.lib libz.lib qtmlClient.lib SDL.lib freetype2ST.lib python25.lib pthreadVSE2.lib pthreadVC2.lib Half.lib Iex.lib IlmImf.lib IlmThread.lib Imath.lib avcodec-52.lib avformat-52.lib avutil-50.lib swscale-0.lib avdevice-52.lib"
+ AdditionalDependencies="odelib.lib ws2_32.lib vfw32.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib openal_static.lib libjpeg.lib dxguid.lib libeay32.lib libpng.lib libz.lib qtmlClient.lib SDL.lib freetype2ST.lib python25.lib pthreadVSE2.lib pthreadVC2.lib Half.lib Iex.lib IlmImf.lib IlmThread.lib Imath.lib avcodec-52.lib avformat-52.lib avutil-50.lib swscale-0.lib avdevice-52.lib"
OutputFile="..\..\..\..\bin\blenderplayer.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\..\..\lib\windows\sdl\lib;..\..\..\..\..\lib\windows\zlib\lib;..\..\..\..\..\lib\windows\ode\lib;..\..\..\..\..\lib\windows\png\lib;..\..\..\..\..\lib\windows\jpeg\lib;..\..\..\..\..\lib\windows\fmod\lib;..\..\..\..\..\lib\windows\openal\lib;..\..\..\..\..\lib\windows\freetype\lib;..\..\..\..\..\lib\windows\openexr\lib_vs2008;..\..\..\..\..\lib\windows\python\lib\lib25_vs2008;..\..\..\..\..\lib\windows\openssl\lib;..\..\..\..\..\lib\windows\QTDevWin\Libraries;..\..\..\..\..\lib\windows\pthreads\lib;..\..\..\..\..\lib\windows\ffmpeg\lib"
IgnoreDefaultLibraryNames="libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib"
+ GenerateDebugInformation="true"
ProgramDatabaseFile="..\..\..\..\..\build\msvc_9\libs\blenderplayer.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
diff --git a/projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj b/projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj
index 80c34bef223..fb812c02f44 100644
--- a/projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj
+++ b/projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj
@@ -582,6 +582,10 @@
>
</File>
<File
+ RelativePath="..\..\..\source\gameengine\Ketsji\KX_PythonSeq.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\gameengine\Ketsji\KX_RayCast.cpp"
>
</File>
@@ -891,6 +895,10 @@
>
</File>
<File
+ RelativePath="..\..\..\source\gameengine\Ketsji\KX_PythonSeq.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\gameengine\Ketsji\KX_RayCast.h"
>
</File>
diff --git a/projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj b/projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj
index a3f43b01763..fc197d0d1f4 100644
--- a/projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj
+++ b/projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj
@@ -4,6 +4,7 @@
Version="9,00"
Name="KX_network"
ProjectGUID="{6E24BF09-9653-4166-A871-F65CC9E98A9B}"
+ RootNamespace="KX_network"
TargetFrameworkVersion="131072"
>
<Platforms>
@@ -42,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic;..\..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB"
StringPooling="true"
RuntimeLibrary="0"
@@ -117,7 +118,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic;..\..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="WIN32,_LIB,_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -192,7 +193,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic;..\..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB"
StringPooling="true"
RuntimeLibrary="2"
@@ -267,7 +268,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic;..\..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="WIN32,_LIB,_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -342,7 +343,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic;..\..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="WIN32,_LIB,_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -417,7 +418,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\ketsji;..\..\..\..\source\gameengine\Network;..\..\..\..\source\gameengine\expressions;..\..\..\..\source\gameengine\GameLogic;..\..\..\..\source\gameengine\Scenegraph"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB"
StringPooling="true"
RuntimeLibrary="0"
diff --git a/projectfiles_vc9/gameengine/physics/PHY_Physics/PHY_Bullet/PHY_Bullet.vcproj b/projectfiles_vc9/gameengine/physics/PHY_Physics/PHY_Bullet/PHY_Bullet.vcproj
index e6991592d40..9f16283e1cd 100644
--- a/projectfiles_vc9/gameengine/physics/PHY_Physics/PHY_Bullet/PHY_Bullet.vcproj
+++ b/projectfiles_vc9/gameengine/physics/PHY_Physics/PHY_Bullet/PHY_Bullet.vcproj
@@ -42,7 +42,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna;..\..\..\..\..\source\blender\blenkernel;..\..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="false"
BasicRuntimeChecks="3"
@@ -110,7 +110,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna;..\..\..\..\..\source\blender\blenkernel;..\..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@@ -176,7 +176,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna;..\..\..\..\..\source\blender\blenkernel;..\..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@@ -243,7 +243,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna;..\..\..\..\..\source\blender\blenkernel;..\..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="false"
BasicRuntimeChecks="3"
@@ -312,7 +312,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna;..\..\..\..\..\source\blender\blenkernel;..\..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="false"
BasicRuntimeChecks="3"
@@ -380,7 +380,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna"
+ AdditionalIncludeDirectories="..\..\..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\..\..\build\msvc_9\intern\SoundSystem\include;..\..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\gameengine\Ketsji;..\..\..\..\..\source\gameengine\Expressions;..\..\..\..\..\source\gameengine\GameLogic;..\..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\blender\makesdna;..\..\..\..\..\source\blender\blenkernel;..\..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
diff --git a/projectfiles_vc9/gameengine/rasterizer/RAS_rasterizer.vcproj b/projectfiles_vc9/gameengine/rasterizer/RAS_rasterizer.vcproj
index 924babfbd21..dde8714507a 100644
--- a/projectfiles_vc9/gameengine/rasterizer/RAS_rasterizer.vcproj
+++ b/projectfiles_vc9/gameengine/rasterizer/RAS_rasterizer.vcproj
@@ -4,6 +4,7 @@
Version="9,00"
Name="RAS_rasterizer"
ProjectGUID="{51FB3D48-2467-4BFA-A321-D848252B437E}"
+ RootNamespace="RAS_rasterizer"
TargetFrameworkVersion="131072"
>
<Platforms>
@@ -42,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\source\gameengine\SceneGraph;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\makesdna"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -117,7 +118,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\source\gameengine\SceneGraph;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\makesdna"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB"
StringPooling="true"
RuntimeLibrary="2"
@@ -192,7 +193,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\source\gameengine\SceneGraph;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\makesdna"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT"
StringPooling="true"
RuntimeLibrary="0"
@@ -267,7 +268,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\source\gameengine\SceneGraph;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\makesdna"
PreprocessorDefinitions="_DEBUG,WIN32,_LIB"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -342,7 +343,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\source\gameengine\SceneGraph;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\makesdna"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -417,7 +418,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\source\gameengine\SceneGraph;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\makesdna"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT"
StringPooling="true"
RuntimeLibrary="0"
diff --git a/projectfiles_vc9/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj b/projectfiles_vc9/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj
index d4cb1e465e6..09b87f41ddf 100644
--- a/projectfiles_vc9/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj
+++ b/projectfiles_vc9/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj
@@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\source\blender\gpu;..\..\..\..\source\gameengine\Ketsji;..\..\..\..\source\blender\makesdna;..\..\..\..\source\blender\blenkernel;..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="_DEBUG,WIN32,_LIB"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -118,7 +118,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\source\blender\gpu;..\..\..\..\source\gameengine\Ketsji;..\..\..\..\source\blender\makesdna;..\..\..\..\source\blender\blenkernel;..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -193,7 +193,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\source\blender\gpu;..\..\..\..\source\gameengine\Ketsji;..\..\..\..\source\blender\makesdna;..\..\..\..\source\blender\blenkernel;..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB"
StringPooling="true"
RuntimeLibrary="2"
@@ -268,7 +268,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\source\blender\gpu;..\..\..\..\source\gameengine\Ketsji;..\..\..\..\source\blender\makesdna;..\..\..\..\source\blender\blenkernel;..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT"
StringPooling="true"
RuntimeLibrary="0"
@@ -343,7 +343,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\source\blender\gpu;..\..\..\..\source\gameengine\Ketsji;..\..\..\..\source\blender\makesdna;..\..\..\..\source\blender\blenkernel;..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -418,7 +418,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\source\gameengine\SceneGraph;..\..\..\..\source\blender\gpu;..\..\..\..\source\gameengine\Ketsji;..\..\..\..\source\blender\makesdna;..\..\..\..\source\blender\blenkernel;..\..\..\..\source\blender\blenlib"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT"
StringPooling="true"
RuntimeLibrary="0"
diff --git a/projectfiles_vc9/gameengine/scenegraph/SG_SceneGraph.vcproj b/projectfiles_vc9/gameengine/scenegraph/SG_SceneGraph.vcproj
index 9c63f625820..95e61cc4af8 100644
--- a/projectfiles_vc9/gameengine/scenegraph/SG_SceneGraph.vcproj
+++ b/projectfiles_vc9/gameengine/scenegraph/SG_SceneGraph.vcproj
@@ -4,6 +4,7 @@
Version="9,00"
Name="SG_SceneGraph"
ProjectGUID="{09222F5E-1625-4FF3-A89A-384D16875EE5}"
+ RootNamespace="SG_SceneGraph"
TargetFrameworkVersion="131072"
>
<Platforms>
@@ -510,6 +511,10 @@
>
</File>
<File
+ RelativePath="..\..\..\source\gameengine\SceneGraph\SG_DList.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\gameengine\SceneGraph\SG_IObject.h"
>
</File>
@@ -522,6 +527,10 @@
>
</File>
<File
+ RelativePath="..\..\..\source\gameengine\SceneGraph\SG_QList.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\gameengine\SceneGraph\SG_Spatial.h"
>
</File>
diff --git a/projectfiles_vc9/gameengine/videotexture/TEX_Video.vcproj b/projectfiles_vc9/gameengine/videotexture/TEX_Video.vcproj
index 2982f4ab820..16ef3a4cc52 100644
--- a/projectfiles_vc9/gameengine/videotexture/TEX_Video.vcproj
+++ b/projectfiles_vc9/gameengine/videotexture/TEX_Video.vcproj
@@ -126,7 +126,6 @@
ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\gameengine\videotexture\"
WarningLevel="2"
Detect64BitPortabilityProblems="false"
- DebugInformationFormat="0"
CompileAs="0"
ShowIncludes="false"
/>
diff --git a/release/Makefile b/release/Makefile
index b2066d0e8d6..2d688211b9c 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -180,7 +180,7 @@ endif
else
@strip -x $(DISTDIR)/blender$(EXT0)
@if [ -f $(DISTDIR)/blenderplayer$(EXTO) ]; then \
- strip -x $(DISTDIR)/blender$(EXT0) ; \
+ strip -x $(DISTDIR)/blenderplayer$(EXT0) ; \
fi
endif
endif
diff --git a/release/datafiles/splash.jpg b/release/datafiles/splash.jpg
index c65b2f37e87..deae8155ff4 100644
--- a/release/datafiles/splash.jpg
+++ b/release/datafiles/splash.jpg
Binary files differ
diff --git a/release/scripts/3ds_export.py b/release/scripts/3ds_export.py
index 54e1ea3db33..87680bce1b0 100644
--- a/release/scripts/3ds_export.py
+++ b/release/scripts/3ds_export.py
@@ -7,7 +7,7 @@ Group: 'Export'
Tooltip: 'Export to 3DS file format (.3ds).'
"""
-__author__ = ["Campbell Barton", "Bob Holcomb", "Richard Lärkäng", "Damien McGinnes", "Mark Stijnman"]
+__author__ = ["Campbell Barton", "Bob Holcomb", "Richard Lärkäng", "Damien McGinnes", "Mark Stijnman"]
__url__ = ("blenderartists.org", "www.blender.org", "www.gametutorials.com", "lib3ds.sourceforge.net/")
__version__ = "0.90a"
__bpydoc__ = """\
@@ -50,7 +50,10 @@ import Blender
import bpy
from BPyMesh import getMeshFromObject
from BPyObject import getDerivedObjects
-import struct
+try:
+ import struct
+except:
+ struct = None
# So 3ds max can open files, limit names to 12 in length
# this is verry annoying for filenames!
@@ -1009,5 +1012,8 @@ def save_3ds(filename):
if __name__=='__main__':
- Blender.Window.FileSelector(save_3ds, "Export 3DS", Blender.sys.makename(ext='.3ds'))
+ if struct:
+ Blender.Window.FileSelector(save_3ds, "Export 3DS", Blender.sys.makename(ext='.3ds'))
+ else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
# save_3ds('/test_b.3ds')
diff --git a/release/scripts/3ds_import.py b/release/scripts/3ds_import.py
index 1963d2e7433..bcde82c4869 100644
--- a/release/scripts/3ds_import.py
+++ b/release/scripts/3ds_import.py
@@ -133,10 +133,12 @@ import BPyImage
import BPyMessages
-import struct
-from struct import calcsize, unpack
+try:
+ from struct import calcsize, unpack
+except:
+ calcsize= unpack= None
+
-import os
# If python version is less than 2.4, try to get set stuff from module
try:
@@ -958,7 +960,10 @@ def load_3ds(filename, PREF_UI= True):
DEBUG= False
if __name__=='__main__' and not DEBUG:
- Blender.Window.FileSelector(load_3ds, 'Import 3DS', '*.3ds')
+ if calcsize==None:
+ Blender.Draw.PupMenu('Error%t|a full python installation not found')
+ else:
+ Blender.Window.FileSelector(load_3ds, 'Import 3DS', '*.3ds')
# For testing compatibility
#load_3ds('/metavr/convert/vehicle/truck_002/TruckTanker1.3DS', False)
@@ -966,6 +971,7 @@ if __name__=='__main__' and not DEBUG:
'''
else:
+ import os
# DEBUG ONLY
TIME= Blender.sys.time()
import os
diff --git a/release/scripts/DirectX8Exporter.py b/release/scripts/DirectX8Exporter.py
index b8bdae4de2b..8a0ecaf0eb7 100644
--- a/release/scripts/DirectX8Exporter.py
+++ b/release/scripts/DirectX8Exporter.py
@@ -45,7 +45,8 @@ from Blender import Types, Object, NMesh, Material,Armature,Mesh
from Blender.Mathutils import *
from Blender import Draw, BGL
from Blender.BGL import *
-import math
+try: import math
+except: math = None
global mat_flip,index_list,space,bone_list,mat_dict
global anim,flip_norm,swap_zy,flip_z,speed,ticks,no_light,recalc_norm,Bl_norm
diff --git a/release/scripts/add_mesh_torus.py b/release/scripts/add_mesh_torus.py
index 4f759256497..2941c56420e 100644
--- a/release/scripts/add_mesh_torus.py
+++ b/release/scripts/add_mesh_torus.py
@@ -6,7 +6,8 @@ Group: 'AddMesh'
"""
import BPyAddMesh
import Blender
-from math import cos, sin, pi
+try: from math import cos, sin, pi
+except: math = None
def add_torus(PREF_MAJOR_RAD, PREF_MINOR_RAD, PREF_MAJOR_SEG, PREF_MINOR_SEG):
Vector = Blender.Mathutils.Vector
@@ -61,5 +62,8 @@ def main():
BPyAddMesh.add_mesh_simple('Torus', verts, [], faces)
-main()
+if cos and sin and pi:
+ main()
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
diff --git a/release/scripts/animation_clean.py b/release/scripts/animation_clean.py
new file mode 100644
index 00000000000..fc44f264ac1
--- /dev/null
+++ b/release/scripts/animation_clean.py
@@ -0,0 +1,192 @@
+#!BPY
+
+"""
+Name: 'Clean Animation Curves'
+Blender: 249
+Group: 'Animation'
+Tooltip: 'Remove unused keyframes for ipo curves'
+"""
+
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Copyright (C) 2008-2009: Blender Foundation
+#
+# 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,
+# --------------------------------------------------------------------------
+
+import bpy
+from Blender import IpoCurve, Draw, Window
+
+def clean_ipos(ipos):
+ eul = 0.001
+
+ def isflat(vec):
+ prev_y = vec[0][1]
+ mid_y = vec[1][1]
+ next_y = vec[2][1]
+
+ # flat status for prev and next
+ return abs(mid_y-prev_y) < eul, abs(mid_y-next_y) < eul
+
+
+
+ X=0
+ Y=1
+ PREV=0
+ MID=1
+ NEXT=2
+
+ LEFT = 0
+ RIGHT = 1
+
+ TOT = 0
+ TOTBEZ = 0
+ # for ipo in bpy.data.ipos:
+ for ipo in ipos:
+ if ipo.lib:
+ continue
+ # print ipo
+ for icu in ipo:
+ interp = icu.interpolation
+ extend = icu.extend
+
+ bezierPoints = icu.bezierPoints
+ bezierVecs = [bez.vec for bez in bezierPoints]
+
+ l = len(bezierPoints)
+
+ TOTBEZ += l
+
+ # our aim is to simplify this ipo as much as possible!
+ if interp == IpoCurve.InterpTypes.BEZIER or interp == interp == IpoCurve.InterpTypes.LINEAR:
+ #print "Not yet supported"
+
+ if interp == IpoCurve.InterpTypes.BEZIER:
+ flats = [isflat(bez) for bez in bezierVecs]
+ else:
+ # A bit of a waste but fake the locations for these so they will always be flats
+ # IS better then too much duplicate code.
+ flats = [(True, True)] * l
+ for v in bezierVecs:
+ v[PREV][Y] = v[NEXT][Y] = v[MID][Y]
+
+
+ # remove middle points
+ if l>2:
+ done_nothing = False
+
+ while not done_nothing and len(bezierVecs) > 2:
+ done_nothing = True
+ i = l-2
+
+ while i > 0:
+ #print i
+ #print i, len(bezierVecs)
+ if flats[i]==(True,True) and flats[i-1][RIGHT] and flats[i+1][LEFT]:
+
+ if abs(bezierVecs[i][MID][Y] - bezierVecs[i-1][MID][Y]) < eul and abs(bezierVecs[i][MID][Y] - bezierVecs[i+1][MID][Y]) < eul:
+ done_nothing = False
+
+ del flats[i]
+ del bezierVecs[i]
+ icu.delBezier(i)
+ TOT += 1
+ l-=1
+ i-=1
+
+ # remove endpoints
+ if extend == IpoCurve.ExtendTypes.CONST and len(bezierVecs) > 1:
+ #print l, len(bezierVecs)
+ # start
+
+ while l > 2 and (flats[0][RIGHT] and flats[1][LEFT] and (abs(bezierVecs[0][MID][Y] - bezierVecs[1][MID][Y]) < eul)):
+ print "\tremoving 1 point from start of the curve"
+ del flats[0]
+ del bezierVecs[0]
+ icu.delBezier(0)
+ TOT += 1
+ l-=1
+
+
+ # End
+ while l > 2 and flats[-2][RIGHT] and flats[-1][LEFT] and (abs(bezierVecs[-2][MID][Y] - bezierVecs[-1][MID][Y]) < eul):
+ print "\tremoving 1 point from end of the curve", l
+ del flats[l-1]
+ del bezierVecs[l-1]
+ icu.delBezier(l-1)
+ TOT += 1
+ l-=1
+
+
+
+ if l==2:
+ if isflat( bezierVecs[0] )[RIGHT] and isflat( bezierVecs[1] )[LEFT] and abs(bezierVecs[0][MID][Y] - bezierVecs[1][MID][Y]) < eul:
+ # remove the second point
+ print "\tremoving 1 point from 2 point bez curve"
+ # remove the second point
+ del flats[1]
+ del bezierVecs[1]
+ icu.delBezier(1)
+ TOT+=1
+ l-=1
+
+ # Change to linear for faster evaluation
+ '''
+ if l==1:
+ print 'Linear'
+ icu.interpolation = IpoCurve.InterpTypes.LINEAR
+ '''
+
+
+
+
+ if interp== IpoCurve.InterpTypes.CONST:
+ print "Not yet supported"
+
+ print 'total', TOT, TOTBEZ
+ return TOT, TOTBEZ
+
+def main():
+ ret = Draw.PupMenu('Clean Selected Objects Ipos%t|Object IPO%x1|Object Action%x2|%l|All IPOs (be careful!)%x3')
+
+ sce = bpy.data.scenes.active
+ ipos = []
+
+ if ret == 3:
+ ipos.extend(list(bpy.data.ipos))
+ else:
+ for ob in sce.objects.context:
+ if ret == 1:
+ ipo = ob.ipo
+ if ipo:
+ ipos.append(ipo)
+
+ elif ret == 2:
+ action = ob.action
+ if action:
+ ipos.extend([ipo for ipo in action.getAllChannelIpos().values() if ipo])
+
+
+
+ if not ipos:
+ Draw.PupMenu('Error%t|No ipos found')
+ else:
+ total_removed, total = clean_ipos(ipos)
+ Draw.PupMenu('Done!%t|Removed ' + str(total_removed) + ' of ' + str(total) + ' points')
+
+ Window.RedrawAll()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/release/scripts/bpymodules/BPyMathutils.py b/release/scripts/bpymodules/BPyMathutils.py
index bfa1dcc3c61..4882e9aaf21 100644
--- a/release/scripts/bpymodules/BPyMathutils.py
+++ b/release/scripts/bpymodules/BPyMathutils.py
@@ -132,7 +132,6 @@ modified for Blender/Mathutils by Campell Barton
######################################################################
# Public interface
######################################################################
-from Blender.Mathutils import DotVecs
def convexHull(point_list_2d):
"""Calculate the convex hull of a set of vectors
The vectors can be 3 or 4d but only the Xand Y are used.
@@ -197,7 +196,7 @@ def plane2mat(plane, normalize= False):
up= cent - ((plane[0]+plane[1])/2.0)
right= cent - ((plane[1]+plane[2])/2.0)
- z= CrossVecs(up, right)
+ z= up.cross(right)
if normalize:
up.normalize()
diff --git a/release/scripts/bpymodules/BPyMesh.py b/release/scripts/bpymodules/BPyMesh.py
index 6bbfaa463d0..292f7a4b91e 100644
--- a/release/scripts/bpymodules/BPyMesh.py
+++ b/release/scripts/bpymodules/BPyMesh.py
@@ -569,12 +569,11 @@ def face_edges(me):
def facesPlanerIslands(me):
- DotVecs= Blender.Mathutils.DotVecs
def roundvec(v):
return round(v[0], 4), round(v[1], 4), round(v[2], 4)
- face_props= [(cent, no, roundvec(no), DotVecs(cent, no)) for f in me.faces for no, cent in ((f.no, f.cent),)]
+ face_props= [(cent, no, roundvec(no), cent.dot(no)) for f in me.faces for no, cent in ((f.no, f.cent),)]
face_edge_users= face_edges(me)
islands= []
@@ -607,7 +606,7 @@ def facesPlanerIslands(me):
face_prop2= face_props[fidx2]
# normals are the same?
if face_prop1[2]==face_prop2[2]:
- if abs(face_prop1[3] - DotVecs(face_prop1[1], face_prop2[0])) < 0.000001:
+ if abs(face_prop1[3] - face_prop1[1].dot(face_prop2[0])) < 0.000001:
used_faces[fidx2]= 1
island.append(fidx2)
islands.append([me.faces[i] for i in island])
@@ -616,7 +615,6 @@ def facesPlanerIslands(me):
def facesUvIslands(me, PREF_IMAGE_DELIMIT=True):
- DotVecs= Blender.Mathutils.DotVecs
def roundvec(v):
return round(v[0], 4), round(v[1], 4)
diff --git a/release/scripts/bpymodules/BPyMesh_octree.py b/release/scripts/bpymodules/BPyMesh_octree.py
deleted file mode 100644
index 368a33496eb..00000000000
--- a/release/scripts/bpymodules/BPyMesh_octree.py
+++ /dev/null
@@ -1,332 +0,0 @@
-from Blender import *
-
-try:
- import psyco
- psyco.full()
-except:
- print 'no psyco for you!'
-
-DotVecs= Mathutils.DotVecs
-#========================================================
-# SPACIAL TREE - Seperate Class - use if you want to
-# USed for getting vert is a proximity
-LEAF_SIZE = 128
-class octreeNode:
- def __init__(self, verts, parent):
-
- # Assunme we are a leaf node, until split is run.
- self.verts = verts
- self.children = []
-
- if parent == None: # ROOT NODE, else set bounds when making children,
- # BOUNDS
- v= verts[0]
- maxx,maxy,maxz= v.co
- minx,miny,minz= maxx,maxy,maxz
-
- for v in verts:
- x,y,z= v.co
- if x>maxx: maxx= x
- if y>maxy: maxy= y
- if z>maxz: maxz= z
-
- if x<minx: minx= x
- if y<miny: miny= y
- if z<minz: minz= z
-
- self.minx= minx
- self.miny= miny
- self.minz= minz
-
- self.maxx= maxx
- self.maxy= maxy
- self.maxz= maxz
-
- # We have no parent to split us so split ourselves.
- #self.setCornerPoints()
- self.splitNode()
-
- def splitNode(self):
- if len(self.verts) > LEAF_SIZE:
- self.makeChildren() # 8 new children,
- self.verts = None
- # Alredy assumed a leaf not so dont do anything here.
-
- def makeChildren(self):
- verts= self.verts
- # Devide into 8 children.
- axisDividedVerts = [[],[],[],[],[],[],[],[]] # Verts Only
-
-
- divx = (self.maxx + self.minx) / 2
- divy = (self.maxy + self.miny) / 2
- divz = (self.maxz + self.minz) / 2
-
- # Sort into 8
- for v in verts:
- x,y,z = v.co
-
- if x > divx:
- if y > divy:
- if z > divz:
- axisDividedVerts[0].append(v)
- else:
- axisDividedVerts[1].append(v)
- else:
- if z > divz:
- axisDividedVerts[2].append(v)
- else:
- axisDividedVerts[3].append(v)
- else:
- if y > divy:
- if z > divz:
- axisDividedVerts[4].append(v)
- else:
- axisDividedVerts[5].append(v)
- else:
- if z > divz:
- axisDividedVerts[6].append(v)
- else:
- axisDividedVerts[7].append(v)
-
- # populate self.children
- for i in xrange(8):
- octNode = octreeNode(axisDividedVerts[i], self)
- # Set bounds manually
- if i == 0:
- octNode.minx = divx
- octNode.maxx = self.maxx
- octNode.miny = divy
- octNode.maxy = self.maxy
- octNode.minz = divz
- octNode.maxz = self.maxz
- elif i == 1:
- octNode.minx = divx
- octNode.maxx = self.maxx
- octNode.miny = divy
- octNode.maxy = self.maxy
- octNode.minz = self.minz #
- octNode.maxz = divz #
- elif i == 2:
- octNode.minx = divx
- octNode.maxx = self.maxx
- octNode.miny = self.miny #
- octNode.maxy = divy #
- octNode.minz = divz
- octNode.maxz = self.maxz
- elif i == 3:
- octNode.minx = divx
- octNode.maxx = self.maxx
- octNode.miny = self.miny #
- octNode.maxy = divy #
- octNode.minz = self.minz #
- octNode.maxz = divz #
- elif i == 4:
- octNode.minx = self.minx #
- octNode.maxx = divx #
- octNode.miny = divy
- octNode.maxy = self.maxy
- octNode.minz = divz
- octNode.maxz = self.maxz
- elif i == 5:
- octNode.minx = self.minx #
- octNode.maxx = divx #
- octNode.miny = divy
- octNode.maxy = self.maxy
- octNode.minz = self.minz #
- octNode.maxz = divz #
- elif i == 6:
- octNode.minx = self.minx #
- octNode.maxx = divx #
- octNode.miny = self.miny #
- octNode.maxy = divy #
- octNode.minz = divz
- octNode.maxz = self.maxz
- elif i == 7:
- octNode.minx = self.minx #
- octNode.maxx = divx #
- octNode.miny = self.miny #
- octNode.maxy = divy #
- octNode.minz = self.minz #
- octNode.maxz = divz #
- #octNode.setCornerPoints()
- octNode.splitNode() # Splits the node if it can.
- self.children.append(octNode)
-
- # GETS VERTS IN A Distance RANGE-
- def getVertsInRange(self, loc, normal, range_val, vertList):
- #loc= Mathutils.Vector(loc) # MUST BE VECTORS
- #normal= Mathutils.Vector(normal)
-
- '''
- loc: Vector of the location to search from
- normal: None or Vector - if a vector- will only get verts on this side of the vector
- range_val: maximum distance. A negative value will fill the list with teh closest vert only.
- vertList: starts as an empty list
- list that this function fills with verts that match
- '''
- xloc,yloc,zloc= loc
-
- if range_val<0:
- range_val= -range_val
- FIND_CLOSEST= True
- vertList.append(None) # just update the 1 vertex
- else:
- FIND_CLOSEST= False
-
- if self.children:
- # Check if the bounds are in range_val,
- for childNode in self.children:
- # First test if we are surrounding the point.
- if\
- childNode.minx - range_val < xloc and\
- childNode.maxx + range_val > xloc and\
- childNode.miny - range_val < yloc and\
- childNode.maxy + range_val > yloc and\
- childNode.minz - range_val < zloc and\
- childNode.maxz + range_val > zloc:
- # Recurse down or get virts.
- childNode.getVertsInRange(loc, normal, range_val, vertList)
- #continue # Next please
-
- else: # we are a leaf node. Test vert locations.
- if not normal:
- # Length only check
- for v in self.verts:
- length = (loc - v.co).length
- if length < range_val:
- if FIND_CLOSEST:
- # Just update the 1 vert
- vertList[0]= (v, length)
- range_val= length # Shink the length so we only get verts from their.
- else:
- vertList.append((v, length))
- else:
- # Lengh and am I infront of the vert.
- for v in self.verts:
- length = (loc - v.co).length
- if length < range_val:
- # Check if the points in front
- dot= DotVecs(normal, loc) - DotVecs(normal, v.co)
- if dot<0:
- vertList.append((v, length))
-
-# END TREE
-
-
-
-
-# EXAMPLE RADIO IN PYTHON USING THE ABOVE FUNCTION
-"""
-import BPyMesh
-# Radio bake
-def bake():
-
- _AngleBetweenVecs_= Mathutils.AngleBetweenVecs
- def AngleBetweenVecs(a1,a2):
- try:
- return _AngleBetweenVecs_(a1,a2)
- except:
- return 180
-
-
-
- scn = Scene.GetCurrent()
- ob = scn.getActiveObject()
- me = ob.getData(mesh=1)
-
- dist= Draw.PupFloatInput('MaxDist:', 2.0, 0.1, 20.0, 0.1, 3)
- if dist==None:
- return
-
- # Make nice normals
- BPyMesh.meshCalcNormals(me)
-
-
- len_verts= len(me.verts)
- #me.sel= False
- meshOctTree = octreeNode(me.verts, None)
-
-
-
- # Store face areas
- vertex_areas= [0.0] * len_verts
-
- # Get vertex areas - all areas of face users
- for f in me.faces:
- a= f.area
- for v in f.v:
- vertex_areas[v.index] += a
-
-
-
- bias= 0.001
-
- t= sys.time()
-
- # Tone for the verts
- vert_tones= [0.0] * len_verts
- maxtone= 0.0
- mintone= 100000000
- for i, v in enumerate(me.verts):
- if not i%10:
- print 'verts to go', len_verts-i
- v_co= v.co
- v_no= v.no
- verts_in_range= []
- meshOctTree.getVertsInRange(v_co, v_no, dist, verts_in_range)
-
- tone= 0.0
- # These are verts in our range
- for test_v, length in verts_in_range:
- if bias<length:
- try:
- # Make sure this isnt a back facing vert
- normal_diff= AngleBetweenVecs(test_v.no, v_no)
- except:
- continue
-
- if normal_diff > 90: # were facing this vert
- #if 1:
- # Current value us between zz90 and 180
- # make between 0 and 90
- # so 0 is right angles and 90 is direct opposite vertex normal
- normal_diff= (normal_diff-90)
-
- # Vertex area needs to be taken into account so we dont have small faces over influencing.
- vertex_area= vertex_areas[test_v.index]
-
- # Get the angle the vertex is in location from the location and normal of the vert.
- above_diff= AngleBetweenVecs(test_v.co-v.co, v_no)
- ## Result will be between 0 :above and 90: horizon.. invert this so horizon has littel effect
- above_diff= 90-above_diff
- # dist-length or 1.0/length both work well
- tone= (dist-length) * vertex_area * above_diff * normal_diff
- vert_tones[i] += tone
-
- if maxtone<vert_tones[i]:
- maxtone= vert_tones[i]
- if mintone>vert_tones[i]:
- mintone= vert_tones[i]
-
-
- if not maxtone:
- Draw.PupMenu('No verts in range, use a larger range')
- return
-
- # Apply tones
- for f in me.faces:
- f_col= f.col
- for i, v in enumerate(f.v):
- c= f_col[i]
- v_index= v.index
- tone= int(((maxtone - vert_tones[v.index]) / maxtone) * 255 )
- #print tone
- c.r= c.g= c.b= tone
-
- print 'time', sys.time()-t
-
-
-if __name__=="__main__":
- bake()
-""" \ No newline at end of file
diff --git a/release/scripts/bpymodules/BPyMesh_redux.py b/release/scripts/bpymodules/BPyMesh_redux.py
index 1bcc6e9f7c8..5955d696fbd 100644
--- a/release/scripts/bpymodules/BPyMesh_redux.py
+++ b/release/scripts/bpymodules/BPyMesh_redux.py
@@ -25,7 +25,6 @@ import Blender
import bpy
Vector= Blender.Mathutils.Vector
Ang= Blender.Mathutils.AngleBetweenVecs
-CrossVecs= Blender.Mathutils.CrossVecs
MidpointVecs= Blender.Mathutils.MidpointVecs
import BPyMesh
@@ -198,8 +197,8 @@ def redux(ob, REDUX=0.5, BOUNDRY_WEIGHT=2.0, REMOVE_DOUBLES=False, FACE_AREA_WEI
# the point of collapsing.
# Enlarge so we know they intersect: self.length*2
- cv1= CrossVecs(v1no, CrossVecs(v1no, v1co-v2co))
- cv2= CrossVecs(v2no, CrossVecs(v2no, v2co-v1co))
+ cv1= v1no.cross(v1no.cross(v1co-v2co))
+ cv2= v2no.cross(v2no.cross(v2co-v1co))
# Scale to be less then the edge lengths.
cv2.length = cv1.length = 1
diff --git a/release/scripts/bpymodules/BPyWindow.py b/release/scripts/bpymodules/BPyWindow.py
index f48f5dfc0ad..d3fd4fa88b5 100644
--- a/release/scripts/bpymodules/BPyWindow.py
+++ b/release/scripts/bpymodules/BPyWindow.py
@@ -1,6 +1,6 @@
import Blender
from Blender import Mathutils, Window, Scene, Draw, Mesh
-from Blender.Mathutils import CrossVecs, Matrix, Vector, Intersect
+from Blender.Mathutils import Matrix, Vector, Intersect
# DESCRIPTION:
# screen_x, screen_y the origin point of the pick ray
diff --git a/release/scripts/bpymodules/dxfLibrary.py b/release/scripts/bpymodules/dxfLibrary.py
index 5390be084ee..67528f778e0 100644
--- a/release/scripts/bpymodules/dxfLibrary.py
+++ b/release/scripts/bpymodules/dxfLibrary.py
@@ -1,6 +1,6 @@
#dxfLibrary.py : provides functions for generating DXF files
# --------------------------------------------------------------------------
-__version__ = "v1.29beta - 2008.12.28"
+__version__ = "v1.32 - 2009.06.06"
__author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)"
__license__ = "GPL"
__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
@@ -18,31 +18,39 @@ IDEAs:
-
TODO:
-- add support for SPLINEs, (bad idea, cause DXF r14 object :(
+- add support for DXFr14 (needs extended file header)
+- add support for SPLINEs (possible first in DXFr14 version)
History
+v1.32 - 2009.06.06 by migius
+ - modif Style class: changed defaults to widthFactor=1.0, obliqueAngle=0.0
+ - modif Text class: alignment parameter reactivated
+v1.31 - 2009.06.02 by migius
+ - modif _Entity class: added paperspace,elevation
+v1.30 - 2009.05.28 by migius
+ - bugfix 3dPOLYLINE/POLYFACE: VERTEX needs x,y,z coordinates, index starts with 1 not 0
v1.29 - 2008.12.28 by Yorik
-- modif POLYLINE to support bulge segments
+ - modif POLYLINE to support bulge segments
v1.28 - 2008.12.13 by Steeve/BlenderArtists
-- bugfix for EXTMIN/EXTMAX to suit Cycas-CAD
+ - bugfix for EXTMIN/EXTMAX to suit Cycas-CAD
v1.27 - 2008.10.07 by migius
-- beautifying output code: keys whitespace prefix
-- refactoring DXF-strings format: NewLine moved to the end of
+ - beautifying output code: keys whitespace prefix
+ - refactoring DXF-strings format: NewLine moved to the end of
v1.26 - 2008.10.05 by migius
-- modif POLYLINE to support POLYFACE
+ - modif POLYLINE to support POLYFACE
v1.25 - 2008.09.28 by migius
-- modif FACE class for r12
+ - modif FACE class for r12
v1.24 - 2008.09.27 by migius
-- modif POLYLINE class for r12
-- changing output format from r9 to r12(AC1009)
+ - modif POLYLINE class for r12
+ - changing output format from r9 to r12(AC1009)
v1.1 (20/6/2005) by www.stani.be/python/sdxf
-- Python library to generate dxf drawings
+ - Python library to generate dxf drawings
______________________________________________________________
""" % (__author__,__version__,__license__,__url__)
# --------------------------------------------------------------------------
# DXF Library: copyright (C) 2005 by Stani Michiels (AKA Stani)
-# 2008 modif by Remigiusz Fiedler (AKA migius)
+# 2008/2009 modif by Remigiusz Fiedler (AKA migius)
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
@@ -85,7 +93,6 @@ def _point(x,index=0):
def _points(plist):
"""Convert a list of tuples to dxf points"""
out = '\n'.join([_point(plist[i],i)for i in range(len(plist))])
- #print 'deb: points=\n', out #-------------------
return out
#---base classes----------------------------------------
@@ -104,17 +111,21 @@ class _Call:
#-------------------------------------------------------
class _Entity(_Call):
"""Base class for _common group codes for entities."""
- def __init__(self,color=None,extrusion=None,layer='0',
+ def __init__(self,paperspace=None,color=None,layer='0',
lineType=None,lineTypeScale=None,lineWeight=None,
- thickness=None,parent=None):
+ extrusion=None,elevation=None,thickness=None,
+ parent=None):
"""None values will be omitted."""
+ self.paperspace = paperspace
self.color = color
- self.extrusion = extrusion
self.layer = layer
self.lineType = lineType
self.lineTypeScale = lineTypeScale
self.lineWeight = lineWeight
+ self.extrusion = extrusion
+ self.elevation = elevation
self.thickness = thickness
+ #self.visible = visible
self.parent = parent
def _common(self):
@@ -122,13 +133,16 @@ class _Entity(_Call):
if self.parent:parent=self.parent
else:parent=self
result =''
+ if parent.paperspace==1: result+=' 67\n1\n'
if parent.layer!=None: result+=' 8\n%s\n'%parent.layer
if parent.color!=None: result+=' 62\n%s\n'%parent.color
- if parent.extrusion!=None: result+='%s\n'%_point(parent.extrusion,200)
if parent.lineType!=None: result+=' 6\n%s\n'%parent.lineType
#TODO: if parent.lineWeight!=None: result+='370\n%s\n'%parent.lineWeight
+ #TODO: if parent.visible!=None: result+='60\n%s\n'%parent.visible
if parent.lineTypeScale!=None: result+=' 48\n%s\n'%parent.lineTypeScale
+ if parent.elevation!=None: result+=' 38\n%s\n'%parent.elevation
if parent.thickness!=None: result+=' 39\n%s\n'%parent.thickness
+ if parent.extrusion!=None: result+='%s\n'%_point(parent.extrusion,200)
return result
#--------------------------
@@ -307,6 +321,10 @@ class PolyLine(_Entity):
self.points=points
self.org_point=org_point
self.flag=flag
+ self.polyface = False
+ self.polyline2d = False
+ self.faces = [] # dummy value
+ self.width= None # dummy value
if self.flag & POLYFACE_MESH:
self.polyface=True
self.points=points[0]
@@ -322,21 +340,21 @@ class PolyLine(_Entity):
def __str__(self):
result= ' 0\nPOLYLINE\n%s 70\n%s\n' %(self._common(),self.flag)
- #print 'deb: self._common()', self._common() #----------
result+=' 66\n1\n'
result+='%s\n' %_point(self.org_point)
if self.polyface:
result+=' 71\n%s\n' %self.p_count
result+=' 72\n%s\n' %self.f_count
elif self.polyline2d:
- if self.width: result+=' 40\n%s\n 41\n%s\n' %(self.width[0],self.width[1])
+ if self.width!=None: result+=' 40\n%s\n 41\n%s\n' %(self.width[0],self.width[1])
for point in self.points:
result+=' 0\nVERTEX\n'
result+=' 8\n%s\n' %self.layer
- result+='%s\n' %_point(point[0:2])
if self.polyface:
+ result+='%s\n' %_point(point[0:3])
result+=' 70\n192\n'
elif self.polyline2d:
+ result+='%s\n' %_point(point[0:2])
if len(point)>4:
width1, width2 = point[3], point[4]
if width1!=None: result+=' 40\n%s\n' %width1
@@ -344,6 +362,8 @@ class PolyLine(_Entity):
if len(point)==6:
bulge = point[5]
if bulge: result+=' 42\n%s\n' %bulge
+ else:
+ result+='%s\n' %_point(point[0:3])
for face in self.faces:
result+=' 0\nVERTEX\n'
result+=' 8\n%s\n' %self.layer
@@ -407,7 +427,7 @@ class Text(_Entity):
if self.style: result+=' 7\n%s\n'%self.style
if self.flag: result+=' 71\n%s\n'%self.flag
if self.justifyhor: result+=' 72\n%s\n'%self.justifyhor
- #TODO: if self.alignment: result+='%s\n'%_point(self.alignment,1)
+ if self.alignment: result+='%s\n'%_point(self.alignment,1)
if self.justifyver: result+=' 73\n%s\n'%self.justifyver
return result
@@ -528,7 +548,7 @@ class LineType(_Call):
#-----------------------------------------------
class Style(_Call):
"""Text style"""
- def __init__(self,name='standard',flag=0,height=0,widthFactor=40,obliqueAngle=50,
+ def __init__(self,name='standard',flag=0,height=0,widthFactor=1.0,obliqueAngle=0.0,
mirror=0,lastHeight=1,font='arial.ttf',bigFont=''):
self.name=name
self.flag=flag
diff --git a/release/scripts/bpymodules/mesh_gradient.py b/release/scripts/bpymodules/mesh_gradient.py
index 936f4958467..e582a30152b 100644
--- a/release/scripts/bpymodules/mesh_gradient.py
+++ b/release/scripts/bpymodules/mesh_gradient.py
@@ -6,7 +6,7 @@ import BPyWindow
mouseViewRay= BPyWindow.mouseViewRay
from Blender import Mathutils, Window, Scene, Draw, sys
-from Blender.Mathutils import CrossVecs, Vector, Intersect, LineIntersect, AngleBetweenVecs
+from Blender.Mathutils import Vector, Intersect, LineIntersect, AngleBetweenVecs
LMB= Window.MButs['L']
def mouseup():
@@ -101,11 +101,11 @@ def vertexGradientPick(ob, MODE):
# make a line 90d to the grad in screenspace.
if (OriginA-OriginB).length <= eps: # Persp view. same origin different direction
- cross_grad= CrossVecs(DirectionA, DirectionB)
+ cross_grad= DirectionA.cross(DirectionB)
ORTHO= False
else: # Ortho - Same direction, different origin
- cross_grad= CrossVecs(DirectionA, OriginA-OriginB)
+ cross_grad= DirectionA.cross(OriginA-OriginB)
ORTHO= True
cross_grad.normalize()
diff --git a/release/scripts/bpymodules/paths_svg2obj.py b/release/scripts/bpymodules/paths_svg2obj.py
index d51fe74190d..6bab6dcbfd8 100644
--- a/release/scripts/bpymodules/paths_svg2obj.py
+++ b/release/scripts/bpymodules/paths_svg2obj.py
@@ -1,7 +1,7 @@
# -*- coding: latin-1 -*-
"""
-SVG 2 OBJ translater, 0.5.9n
-Copyright (c) jm soler juillet/novembre 2004-february 2009,
+SVG 2 OBJ translater, 0.5.9o
+Copyright (c) jm soler juillet/novembre 2004-april 2009,
# ---------------------------------------------------------------
released under GNU Licence
for the Blender 2.42 Python Scripts Bundle.
@@ -255,7 +255,7 @@ Changelog:
- removed all debug statements
- correction of a zero division error in the calc_arc function.
- 0.5.9f: - 2007/15/7
+ 0.5.9f: - 2007/15/7
- Correction de plusieurs bugs sur l'attributions des couleurs et le nommage
des courbes
@@ -266,6 +266,8 @@ Changelog:
0.5.9k : - 14/01/2009
0.5.9l : - 31/01/2009
0.5.9n : - 01/02/2009
+ 0.5.9o : - 04/04/2009, remove pattern if it made with path.
+
==================================================================================
=================================================================================="""
@@ -280,6 +282,7 @@ LAST_ID=''
LAST_COLOR=[0.0,0.0,0.0,0.0]
SEPARATE_CURVES=0
USE_COLORS=0
+PATTERN=0
SVGCOLORNAMELIST={ 'aliceblue':[240, 248, 255] ,'antiquewhite':[250, 235, 215]
,'aqua':[ 0, 255, 255], 'aquamarine':[127, 255, 212]
@@ -787,6 +790,7 @@ def polygon(prp):
D.append('Z')
return D
+
#--------------------
# 0.5.8, to remove exec
#--------------------
@@ -1462,13 +1466,13 @@ def collect_ATTRIBUTS(data):
# --------------------------------------------
def build_HIERARCHY(t):
global CP, curves, SCALE, DEBUG, BOUNDINGBOX, scale_, tagTRANSFORM
- global LAST_ID
+ global LAST_ID, PATTERN
TRANSFORM=0
t=t.replace('\t',' ')
while t.find(' ')!=-1: t=t.replace(' ',' ')
n0=0
t0=t1=0
- baliste=[]
+ #baliste=[]
balisetype=['?','?','/','/','!','!']
BALISES=['D', #DECL_TEXTE',
'D', #DECL_TEXTE',
@@ -1490,26 +1494,37 @@ def build_HIERARCHY(t):
if t0>-1 and t1>-1:
if t[t0+1] in balisetype:
b=balisetype.index(t[t0+1])
+
if t[t0+2]=='-':
b=balisetype.index(t[t0+1])+1
+
balise=BALISES[b]
+
if b==2:
parent=STACK.pop(-1)
if parent!=None and TRANSFORM>0:
TRANSFORM-=1
+
elif t[t1-1] in balisetype:
balise=BALISES[balisetype.index(t[t1-1])+1]
+
else:
t2=t.find(' ',t0)
if t2>t1: t2=t1
ouvrante=1
NOM=t[t0+1:t2]
+
+
if '</'+NOM in t: #.find('</'+NOM)>-1:
balise=BALISES[-1]
+ if NOM=='pattern' and not PATTERN:
+ t1=t.find('</'+NOM+'>',t0)+len('</'+NOM+'>')
+ balise=BALISES[-3]
else:
balise=BALISES[-2]
if balise=='E' or balise=='O':
+
proprietes=collect_ATTRIBUTS(t[t0:t1+ouvrante])
if 'id' in proprietes:
@@ -1532,6 +1547,11 @@ def build_HIERARCHY(t):
# 0.5.8, to remove exec
#--------------------
D=OTHERSSHAPES[proprietes['TYPE']](proprietes)
+
+ #elif proprietes['TYPE'] in ['pattern']:
+ # print 'pattern'
+ # D=''
+
CP=[0.0,0.0]
if len(D)>0:
cursor=0
@@ -1567,7 +1587,7 @@ def build_HIERARCHY(t):
def scan_FILE(nom):
global CP, curves, SCALE, DEBUG, BOUNDINGBOX, scale_, tagTRANSFORM
- global SEPARATE_CURVES, USE_COLORS
+ global SEPARATE_CURVES, USE_COLORS, PATTERN
dir,name=split(nom)
name=name.split('.')
@@ -1583,13 +1603,14 @@ def scan_FILE(nom):
togAS = Blender.Draw.Create(0)
togSP = Blender.Draw.Create(0)
togCOL = Blender.Draw.Create(0)
+ Pattern= Blender.Draw.Create(0)
block=[\
("Clamp Width 1", togW, "Rescale the import with a Width of one unit"),\
("Clamp Height 1", togH, "Rescale the import with a Heightof one unit"),\
("No Rescaling", togAS, "No rescaling, the result can be very large"),\
("Separate Curves", togSP, "Create an object for each curve, Slower. May manage colors"),\
- ("Import Colors", togCOL, "try to import color if the path is set as 'fill'. Only With separate option")]
-
+ ("Import Colors", togCOL, "try to import color if the path is set as 'fill'. Only With separate option"),\
+ ("Import Patterns", Pattern, "import pattern content if it is made with paths.")]
retval = Blender.Draw.PupBlock("Import Options", block)
if togW.val: scale_=1
elif togH.val: scale_=2
@@ -1598,6 +1619,8 @@ def scan_FILE(nom):
if togSP.val: SEPARATE_CURVES=1
if togCOL.val and SEPARATE_CURVES : USE_COLORS=1
+
+ if Pattern.val : PATTERN =1
t1=Blender.sys.time()
# 0.4.1 : to avoid to use sax and the xml
@@ -1625,4 +1648,4 @@ def functionSELECT(nom):
if __name__=='__main__':
- Blender.Window.FileSelector (functionSELECT, 'SELECT an .SVG FILE', '*.svg')
+ Blender.Window.FileSelector (functionSELECT, 'SELECT an .SVG FILE', '*.svg') \ No newline at end of file
diff --git a/release/scripts/c3d_import.py b/release/scripts/c3d_import.py
index bfe691c394c..98f643cbab9 100644
--- a/release/scripts/c3d_import.py
+++ b/release/scripts/c3d_import.py
@@ -527,9 +527,10 @@ def setupAnim(StartFrame, EndFrame, VideoFrameRate):
if VideoFrameRate>120: VideoFrameRate=120
# set up anim panel for them
context=scn.getRenderingContext()
- context.startFrame(StartFrame)
- context.endFrame(EndFrame)
- context.framesPerSec(int(VideoFrameRate))
+ context.sFrame=StartFrame
+ context.eFrame=EndFrame
+ context.fps=int(VideoFrameRate)
+
Blender.Set("curframe",StartFrame)
Blender.Redraw()
return
diff --git a/release/scripts/console.py b/release/scripts/console.py
index 0e46f41f581..c6ae22a86f5 100644
--- a/release/scripts/console.py
+++ b/release/scripts/console.py
@@ -708,20 +708,23 @@ def draw_gui():
# Fixed margin. use a margin since 0 margin can be hard to seewhen close to a crt's edge.
margin = 4
+ # Convenience
+ FNT_NAME, FNT_HEIGHT = __FONT_SIZES__[__FONT_SIZE__]
+
# Draw cursor location colour
if __CONSOLE_LINE_OFFSET__ == 0:
- cmd2curWidth = Draw.GetStringWidth(cmdBuffer[-1].cmd[:cursor], __FONT_SIZES__[__FONT_SIZE__][0])
+ cmd2curWidth = Draw.GetStringWidth(cmdBuffer[-1].cmd[:cursor], FNT_NAME)
BGL.glColor3f(0.8, 0.2, 0.2)
if cmd2curWidth == 0:
- BGL.glRecti(margin,2,margin+2, __FONT_SIZES__[__FONT_SIZE__][1]+2)
+ BGL.glRecti(margin,2,margin+2, FNT_HEIGHT+2)
else:
- BGL.glRecti(margin + cmd2curWidth-2,2, margin+cmd2curWidth, __FONT_SIZES__[__FONT_SIZE__][1]+2)
+ BGL.glRecti(margin + cmd2curWidth-2,2, margin+cmd2curWidth, FNT_HEIGHT+2)
BGL.glColor3f(1,1,1)
# Draw the set of cammands to the buffer
consoleLineIdx = __CONSOLE_LINE_OFFSET__ + 1
wrapLineIndex = 0
- while consoleLineIdx < len(cmdBuffer) and __CONSOLE_RECT__[3] > (consoleLineIdx - __CONSOLE_LINE_OFFSET__) * __FONT_SIZES__[__FONT_SIZE__][1]:
+ while consoleLineIdx < len(cmdBuffer) and __CONSOLE_RECT__[3] > (consoleLineIdx - __CONSOLE_LINE_OFFSET__) * FNT_HEIGHT:
if cmdBuffer[-consoleLineIdx].type == 0:
BGL.glColor3f(1, 1, 1)
elif cmdBuffer[-consoleLineIdx].type == 1:
@@ -734,53 +737,41 @@ def draw_gui():
BGL.glColor3f(1, 1, 0)
if consoleLineIdx == 1: # user input
- BGL.glRasterPos2i(margin, (__FONT_SIZES__[__FONT_SIZE__][1] * (consoleLineIdx-__CONSOLE_LINE_OFFSET__)) - 8)
- Draw.Text(cmdBuffer[-consoleLineIdx].cmd, __FONT_SIZES__[__FONT_SIZE__][0])
- else:
- BGL.glRasterPos2i(margin, (__FONT_SIZES__[__FONT_SIZE__][1] * ((consoleLineIdx-__CONSOLE_LINE_OFFSET__)+wrapLineIndex)) - 8)
- Draw.Text(cmdBuffer[-consoleLineIdx].cmd, __FONT_SIZES__[__FONT_SIZE__][0])
-
- # Wrapping is totally slow, can even hang blender - dont do it!
- '''
- if consoleLineIdx == 1: # NEVER WRAP THE USER INPUT
- BGL.glRasterPos2i(margin, (__FONT_SIZES__[__FONT_SIZE__][1] * (consoleLineIdx-__CONSOLE_LINE_OFFSET__)) - 8)
- # BUG, LARGE TEXT DOSENT DISPLAY
- Draw.Text(cmdBuffer[-consoleLineIdx].cmd, __FONT_SIZES__[__FONT_SIZE__][0])
-
-
- else: # WRAP?
- # LINE WRAP
- if Draw.GetStringWidth(cmdBuffer[-consoleLineIdx].cmd, __FONT_SIZES__[__FONT_SIZE__][0]) > __CONSOLE_RECT__[2]:
+ BGL.glRasterPos2i(margin, (FNT_HEIGHT * (consoleLineIdx-__CONSOLE_LINE_OFFSET__)) - 8)
+ Draw.Text(cmdBuffer[-consoleLineIdx].cmd, FNT_NAME)
+ else: # WRAP
+ lwid = Draw.GetStringWidth(cmdBuffer[-consoleLineIdx].cmd, FNT_NAME)
+ if margin + lwid > __CONSOLE_RECT__[2]:
wrapLineList = []
- copyCmd = [cmdBuffer[-consoleLineIdx].cmd, '']
- while copyCmd != ['','']:
- while margin + Draw.GetStringWidth(copyCmd[0], __FONT_SIZES__[__FONT_SIZE__][0]) > __CONSOLE_RECT__[2]:
- #print copyCmd
- copyCmd[1] = '%s%s'% (copyCmd[0][-1], copyCmd[1]) # Add the char on the end
- copyCmd[0] = copyCmd[0][:-1]# remove last chat
-
- # Now we have copyCmd[0] at a good length we can print it.
- if copyCmd[0] != '':
- wrapLineList.append(copyCmd[0])
-
- copyCmd[0]=''
- copyCmd = [copyCmd[1], copyCmd[0]]
-
+ wtext = cmdBuffer[-consoleLineIdx].cmd
+ wlimit = len(wtext)
+ chunksz = int(( __CONSOLE_RECT__[2] - margin ) / (lwid / len(wtext)))
+ lstart = 0
+ fsize = FNT_NAME
+ while lstart < wlimit:
+ lend = min(lstart+chunksz,wlimit)
+ ttext = wtext[lstart:lend]
+ while lend < wlimit and Draw.GetStringWidth(ttext, fsize) + margin < __CONSOLE_RECT__[2]:
+ lend += 1
+ ttext = wtext[lstart:lend]
+ while lend > lstart+1 and Draw.GetStringWidth(ttext, fsize) + margin > __CONSOLE_RECT__[2]:
+ lend -= 1
+ ttext = wtext[lstart:lend]
+ wrapLineList.append(ttext)
+ lstart = lend
# Now we have a list of lines, draw them (OpenGLs reverse ordering requires this odd change)
wrapLineList.reverse()
for wline in wrapLineList:
- BGL.glRasterPos2i(margin, (__FONT_SIZES__[__FONT_SIZE__][1]*((consoleLineIdx-__CONSOLE_LINE_OFFSET__) + wrapLineIndex)) - 8)
- Draw.Text(wline, __FONT_SIZES__[__FONT_SIZE__][0])
+ BGL.glRasterPos2i(margin, (FNT_HEIGHT*((consoleLineIdx-__CONSOLE_LINE_OFFSET__) + wrapLineIndex)) - 8)
+ Draw.Text(wline, FNT_NAME)
wrapLineIndex += 1
- wrapLineIndex-=1 # otherwise we get a silly extra line.
+ wrapLineIndex-=1 # otherwise we get a silly extra line.
else: # no wrapping.
- BGL.glRasterPos2i(margin, (__FONT_SIZES__[__FONT_SIZE__][1] * ((consoleLineIdx-__CONSOLE_LINE_OFFSET__)+wrapLineIndex)) - 8)
- Draw.Text(cmdBuffer[-consoleLineIdx].cmd, __FONT_SIZES__[__FONT_SIZE__][0])
- '''
+ BGL.glRasterPos2i(margin, (FNT_HEIGHT * ((consoleLineIdx-__CONSOLE_LINE_OFFSET__)+wrapLineIndex)) - 8)
+ Draw.Text(cmdBuffer[-consoleLineIdx].cmd, FNT_NAME)
consoleLineIdx += 1
-
# This recieves the event index, call a function from here depending on the event.
def handle_button_event(evt):
diff --git a/release/scripts/envelope_symmetry.py b/release/scripts/envelope_symmetry.py
index a52e622a65b..a72e8c060b4 100644
--- a/release/scripts/envelope_symmetry.py
+++ b/release/scripts/envelope_symmetry.py
@@ -4,7 +4,7 @@
Name: 'Envelope Symmetry'
Blender: 234
Group: 'Animation'
-Tooltip: 'Make envelope symetrical'
+Tooltip: 'Make envelope symmetrical'
"""
__author__ = "Jonas Petersen"
diff --git a/release/scripts/export_dxf.py b/release/scripts/export_dxf.py
index 99c6acaceab..b32962241cc 100644
--- a/release/scripts/export_dxf.py
+++ b/release/scripts/export_dxf.py
@@ -1,47 +1,89 @@
#!BPY
"""
- Name: 'Autodesk (.dxf .dwg)'
- Blender: 247
+ Name: 'Autodesk DXF (.dxf)'
+ Blender: 249
Group: 'Export'
- Tooltip: 'Export geometry to Autocad DXF/DWG-r12 (Drawing eXchange Format).'
+ Tooltip: 'Export geometry to DXF/DWG-r12 (Drawing eXchange Format).'
"""
-__version__ = "v1.29 - 2009.04.11"
-__author__ = "Remigiusz Fiedler (AKA migius), Alexandros Sigalas (AKA alxarch), Stani Michiels"
+__version__ = "1.34 - 2009.06.08"
+__author__ = "Remigiusz Fiedler (AKA migius)"
__license__ = "GPL"
-__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
+__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
__bpydoc__ ="""The script exports Blender geometry to DXF format r12 version.
Version %s
Copyright %s
License %s
-extern dependances: dxfLibrary.py
+extern dependances: dxfLibrary.py, dxfColorMap.py (optionaly: DConvertCon.exe)
+
+CONTRIBUTORS:
+Remigiusz Fiedler (AKA migius)
+Alexandros Sigalas (AKA alxarch)
+Stani Michiels (AKA stani)
See the homepage for documentation.
url: %s
IDEAs:
- - correct normals for POLYLINE-POLYFACE via proper point-order
- - HPGL output for 2d and flattened 3d content
-
+- HPGL output, usefull for correct scaled printing of 2d drawings
+
TODO:
-- export dupligroups and dupliverts as blocks ( option for the user to decide )
-- optimize back-faces removal (probably needs matrix transform)
+- export dupligroups and dupliverts as blocks (option for the user to decide)
- optimize POLYFACE routine: remove double-vertices
-- optimize POLYFACE routine: remove unused vertices
+- more stable support for X,Y-rotated curves(to POLYLINEs): fix blender negative-matrix.invert()
- support hierarchies: groups, instances, parented structures
-- support 210-code (3d orientation vector)
-- presets for architectural scales
-- write drawing extends for automatic view positioning in CAD
+- support n/f-gons as POLYFACEs with invisible edges
+- mapping materials to DXF-styles
+- ProgressBar
+- wip: write drawing extends for automatic view positioning in CAD
+- wip: correct text-objects in persp-projection
+- wip: translate Camera to VPORT/VIEW
+- wip: translate current 3D-View to *ACTIVE-VPORT
History
-v1.29 - 2009.04.11 by migius
+v1.34 - 2009.06.08 by migius
+- export Lamps and Cameras as POINTs
+- export passepartout for perspective projection
+- added option for export objects only from visible layers
+- optimized POLYFACE output: remove loose vertices in back-faces-mode
+- cleaning code
+- fix nasty bug in getExtrusion()
+- support text-objects, also in ortho/persp-projection
+- support XYmirrored 2d-curves to 2dPOLYLINEs
+- support thickness and elevation for curve-objects
+- fix extrusion 210-code (3d orientation vector)
+- fix POLYFACE export, synchronized with dxfLibrary.py
+- changed to the new 2.49 method Vector.cross()
+- output style manager (first try)
+v1.33 - 2009.05.25 by migius
+- bugfix flipping normals in mirrored mesh-objects
+- added UI-Button for future Shadow Generator
+- support curve objects in projection-2d mode
+- UI stuff: camera selector/manager
+v1.32 - 2009.05.22 by migius
+- debug mode for curve-objects: output redirect to Blender
+- wip support 210-code(extrusion) calculation
+- default settings for 2D and 3D export
+v1.31 - 2009.05.18 by migius
+- globals translated to GUI_A/B dictionary
+- optimizing back-faces removal for "hidden-lines" mode
+- presets for global location and scale (architecture)
+- UI layout: scrollbars, pan with MMB/WHEEL, dynamic width
+- new GUI with Draw.Register() from DXF-importer.py
+v1.30 - 2008.12.14 by migius
+- started work on GUI with Draw.Register()
+v1.29 - 2009.04.11 by stani
- added DWG support, Stani Michiels idea for binding an extern DXF-DWG-converter
-v1.28 - 2009.02.05 by alxarch
+v1.28 - 2009.02.05 by Alexandros Sigalas (alxarch)
- added option to apply modifiers on exported meshes
- added option to also export duplicates (from dupliverts etc)
+v1.28 - 2008.10.22 by migius
+- workaround for PVert-bug on ubuntu (reported by Yorik)
+- add support for FGons - ignore invisible_tagged edges
+- add support for camera: ortho and perspective
v1.27 - 2008.10.07 by migius
- exclude Stani's DXF-Library to extern module
v1.26 - 2008.10.05 by migius
@@ -92,17 +134,79 @@ ______________________________________________________________
import Blender
-from Blender import Mathutils, Window, Scene, sys, Draw, Mesh
-import BPyMessages
+from Blender import Mathutils, Window, Scene, Draw, Camera, BezTriple
+from Blender import Registry, Object, Mesh, Curve
import os
import subprocess
-#print os.sys.platform
-#print dir(os.sys.version)
-
-#import dxfLibrary
+import dxfLibrary as DXF
+#reload(DXF)
#reload(dxfLibrary)
-from dxfLibrary import *
+#from dxfLibrary import *
+
+import math
+from math import atan, atan2, log10, sin, cos
+
+#pi = math.pi
+#pi = 3.14159265359
+r2d = 180.0 / math.pi
+d2r = math.pi / 180.0
+#note: d2r * angle == math.radians(angle)
+
+print '\n\n\n'
+print 'DXF-Exporter v%s *** start ***' %(__version__) #---------------------
+
+#DEBUG = True #activates debug mode
+
+
+#----globals------------------------------------------
+ONLYSELECTED = 1 # 0/1 = False/True
+ONLYVISIBLE = 1 # ignore objects on invisible layers
+POLYLINES = 1 # prefer POLYLINEs not LINEs
+POLYFACES = 1 # prefer POLYFACEs not 3DFACEs
+PROJECTION = 0 # output geometry will be projected to XYplane with Z=0.0
+HIDDEN_LINES = 0 #filter out hidden geometry
+SHADOWS = 0 # sun/shadows simulation
+CAMERA = 1 # selected camera index
+PERSPECTIVE = 0 # projection (camera) type: perspective, opposite to orthographic
+CAMERAVIEW = 0 # use camera for projection, opposite is 3d-view
+APPLY_MODIFIERS = 1
+INCLUDE_DUPLIS = 0
+OUTPUT_DWG = 0 #optional save to DWG with extern converter
+
+G_SCALE = 1.0 #(0.0001-1000) global scaling factor for output dxf data
+G_ORIGIN = [0.0,0.0,0.0] #global translation-vector (x,y,z) in Blender units
+ELEVATION = 0.0 #standard elevation = coordinate Z value in Blender units
+
+BYBLOCK = 0 #DXF-attribute: assign property to BLOCK defaults
+BYLAYER = None #256 #DXF-attribute: assign property to LAYER defaults
+PREFIX = 'BF_' #used as prefix for DXF names
+LAYERNAME_DEF = '' #default layer name
+LAYERCOLOR_DEF = 7 #default layer color index
+LAYERLTYPE_DEF = 0 #'CONTINUOUS' - default layer lineType
+ENTITYLAYER_DEF = LAYERNAME_DEF #default entity color index
+ENTITYCOLOR_DEF = BYLAYER #default entity color index
+ENTITYLTYPE_DEF = BYLAYER #default entity lineType
+E_M = 0
+LAB = "scroll MMB/WHEEL . wip .. todo" #"*) parts under construction"
+M_OBJ = 0
+
+FILENAME_MAX = 180 #max length of path+file_name string (FILE_MAXDIR + FILE_MAXFILE)
+NAMELENGTH_MAX = 80 #max_obnamelength in DXF, (limited to 256? )
+INIFILE_DEFAULT_NAME = 'exportDXF'
+INIFILE_EXTENSION = '.ini'
+INIFILE_HEADER = '#ExportDXF.py ver.1.0 config data'
+INFFILE_HEADER = '#ExportDXF.py ver.1.0 analyze of DXF-data'
+
+SCENE = None
+WORLDX = Mathutils.Vector((1,0,0))
+WORLDY = Mathutils.Vector((0,1,0))
+WORLDZ = Mathutils.Vector((0,0,1))
+
+AUTO = BezTriple.HandleTypes.AUTO
+FREE = BezTriple.HandleTypes.FREE
+VECT = BezTriple.HandleTypes.VECT
+ALIGN = BezTriple.HandleTypes.ALIGN
#-------- DWG support ------------------------------------------
@@ -127,8 +231,59 @@ More details in online Help.' %extCONV
#print 'extCONV_PATH = ', extCONV_PATH
+#----------------------------------------------
+def updateMenuCAMERA():
+ global CAMERAS
+ global MenuCAMERA
+ global MenuLIGHT
-#-----------------------------------------------------
+ scn = Scene.GetCurrent()
+ objs = scn.getChildren()
+ currcam = scn.getCurrentCamera()
+ if currcam: currcam = currcam.getName()
+ maincams = []
+ MenuCAMERA = "Select Camera%t"
+ for cam in objs:
+ if cam.getType() == 'Camera':
+ if cam.getName()[0:4] != "Temp":
+ maincams.append(cam.getName())
+ maincams.sort()
+ maincams.reverse()
+ CAMERAS = maincams
+ for i, cam in enumerate(CAMERAS):
+ if cam==currcam:
+ MenuCAMERA += "|* " + cam
+ else: MenuCAMERA += "| " + cam
+ MenuCAMERA += "|current 3d-View"
+ MenuLIGHT = "Select Sun%t| *todo"
+
+
+#----------------------------------------------
+def updateCAMERA():
+ global CAMERA, GUI_A
+ #CAMERA = 1
+ scn = Scene.GetCurrent()
+ currcam = scn.getCurrentCamera()
+ if currcam: currcam = currcam.getName()
+ if currcam in CAMERAS:
+ CAMERA = CAMERAS.index(currcam)+1
+ GUI_A['camera_selected'].val = CAMERA
+
+#----------------------------------------------
+def gotoCAMERA():
+ cam = Object.Get(CAMERAS[CAMERA-1])
+ #print 'deb: CAMERA, cam',CAMERA, cam
+ if cam.getType() != 'Camera':
+ sure = Draw.PupMenu("Info: %t| It is not a Camera Object.")
+ else:
+ scn = Scene.getCurrent()
+ scn.setCurrentCamera(cam)
+ Window.CameraView(0)
+ Window.Redraw()
+ updateMenuCAMERA()
+
+
+#------- Duplicates support ----------------------------------------------
def dupTest(object):
"""
Checks objects for duplicates enabled (any type)
@@ -146,8 +301,8 @@ def getObjectsAndDuplis(oblist,MATRICES=False,HACK=False):
"""
Return a list of real objects and duplicates and optionally their matrices
oblist: List of Blender Objects
- MATRICES: Boolean - Check to also get the objects matrices default=False
- HACK: Boolean - See note default=False
+ MATRICES: Boolean - Check to also get the objects matrices, default=False
+ HACK: Boolean - See note, default=False
Returns: List of objects or
List of tuples of the form:(ob,matrix) if MATRICES is set to True
NOTE: There is an ugly hack here that excludes all objects whose name
@@ -157,7 +312,7 @@ def getObjectsAndDuplis(oblist,MATRICES=False,HACK=False):
result = []
for ob in oblist:
- if dupTest(ob):
+ if INCLUDE_DUPLIS and dupTest(ob):
dup_obs=ob.DupObjects
if len(dup_obs):
for dup_ob, dup_mx in dup_obs:
@@ -182,231 +337,990 @@ def getObjectsAndDuplis(oblist,MATRICES=False,HACK=False):
return result
#-----------------------------------------------------
-def hidden_status(faces, mx_n):
- #print 'HIDDEN_MODE: caution! not full implemented yet'
- ok_faces = []
- ok_edges = []
- #sort out back-faces = with normals pointed away from camera
+def hidden_status(faces, mx, mx_n):
+ # sort out back-faces = with normals pointed away from camera
+ #print 'HIDDEN_LINES: caution! not full implemented yet'
+ front_faces = []
+ front_edges = []
for f in faces:
#print 'deb: face=', f #---------
+ #print 'deb: dir(face)=', dir(f) #---------
# get its normal-vector in localCS
vec_normal = f.no.copy()
#print 'deb: vec_normal=', vec_normal #------------------
- #must be transfered to camera/view-CS
+ # must be transfered to camera/view-CS
vec_normal *= mx_n
#vec_normal *= mb.rotationPart()
#print 'deb:2vec_normal=', vec_normal #------------------
#vec_normal *= mw0.rotationPart()
#print 'deb:3vec_normal=', vec_normal, '\n' #------------------
- # normal must point the Z direction-hemisphere
- if vec_normal[2] > 0.0 :
- ok_faces.append(f.index)
+
+ frontFace = False
+ if not PERSPECTIVE: #for ortho mode ----------
+ # normal must point the Z direction-hemisphere
+ if vec_normal[2] > 0.00001:
+ frontFace = True
+ else:
+ v = f.verts[0]
+ vert = Mathutils.Vector(v.co) * mx
+ if Mathutils.DotVecs(vert, vec_normal) < 0.00001:
+ frontFace = True
+
+ if frontFace:
+ front_faces.append(f.index)
for key in f.edge_keys:
#this test can be done faster with set()
- if key not in ok_edges:
- ok_edges.append(key)
- #print 'deb: amount of visible faces=', len(ok_faces) #---------
- #print 'deb: visible faces=', ok_faces #---------
- #print 'deb: amount of visible edges=', len(ok_edges) #---------
- #print 'deb: visible edges=', ok_edges #---------
- return ok_faces, ok_edges
+ if key not in front_edges:
+ front_edges.append(key)
+ #print 'deb: amount of visible faces=', len(front_faces) #---------
+ #print 'deb: visible faces=', front_faces #---------
+ #print 'deb: amount of visible edges=', len(front_edges) #---------
+ #print 'deb: visible edges=', front_edges #---------
+ return front_faces, front_edges
+
+
+#---- migration to 2.49-------------------------------------------------
+if 'cross' in dir(Mathutils.Vector()):
+ #Draw.PupMenu('DXF exporter: Abort%t|This script version works for Blender up 2.49 only!')
+ def M_CrossVecs(v1,v2):
+ return v1.cross(v2) #for up2.49
+ def M_DotVecs(v1,v2):
+ return v1.dot(v2) #for up2.49
+else:
+ def M_CrossVecs(v1,v2):
+ return Mathutils.CrossVecs(v1,v2) #for pre2.49
+ def M_DotVecs(v1,v2):
+ return Mathutils.DotVecs(v1,v2) #for pre2.49
+
#-----------------------------------------------------
-def projected_co(vec, mw):
- # convert the world coordinates of vector to screen coordinates
- #co = vec.co.copy().resize4D()
- co = vec.copy().resize4D()
- co[3] = 1.0
- sc = co * mw
- #print 'deb: viewprojection=', sc #---------
- return [sc[0],sc[1],0.0]
-
-
-#--------not used---------------------------------------------
-def flatten(points, mw):
- for i,v in enumerate(points):
- v = projected_co(v, mw)
- points[i]=v
- #print 'deb: flatten points=', points #---------
- return points
+def getExtrusion(matrix):
+ """calculates DXF-Extrusion = Arbitrary Xaxis and Zaxis vectors
+
+ """
+ AZaxis = matrix[2].copy().resize3D().normalize() # = ArbitraryZvector
+ Extrusion = [AZaxis[0],AZaxis[1],AZaxis[2]]
+ if AZaxis[2]==1.0:
+ Extrusion = None
+ AXaxis = matrix[0].copy().resize3D() # = ArbitraryXvector
+ else:
+ threshold = 1.0 / 64.0
+ if abs(AZaxis[0]) < threshold and abs(AZaxis[1]) < threshold:
+ # AXaxis is the intersection WorldPlane and ExtrusionPlane
+ AXaxis = M_CrossVecs(WORLDY,AZaxis)
+ else:
+ AXaxis = M_CrossVecs(WORLDZ,AZaxis)
+ #print 'deb:\n' #-------------
+ #print 'deb:getExtrusion() Extrusion=', Extrusion #---------
+ return Extrusion, AXaxis.normalize()
+
+
+#-----------------------------------------------------
+def getZRotation(AXaxis, rot_matrix_invert):
+ """calculates ZRotation = angle between ArbitraryXvector and obj.matrix.Xaxis
+
+ """
+ # this works: Xaxis is the obj.matrix-Xaxis vector
+ # but not correct for all orientations
+ #Xaxis = matrix[0].copy().resize3D() # = ArbitraryXvector
+ ##Xaxis.normalize() # = ArbitraryXvector
+ #ZRotation = - Mathutils.AngleBetweenVecs(Xaxis,AXaxis) #output in radians
+
+ # this works for all orientations, maybe a bit faster
+ # transform AXaxis into OCS:Object-Coord-System
+ #rot_matrix = normalizeMat(matrix.rotationPart())
+ #rot_matrix_invert = rot_matrix.invert()
+ vec = AXaxis * rot_matrix_invert
+ ##vec = AXaxis * matrix.copy().invert()
+ ##vec.normalize() # not needed for atan2()
+ #print '\ndeb:getExtrusion() vec=', vec #---------
+ ZRotation = - atan2(vec[1],vec[0]) #output in radians
+
+ #print 'deb:ZRotation() ZRotation=', ZRotation*r2d #---------
+ return ZRotation
+
+
+#------------------------------------------
+def normalizeMat(matrix):
+ mat12 = matrix.copy()
+ mat12 = [Mathutils.Vector(v).normalize() for v in mat12]
+ if len(mat12)>3:
+ matr12 = Mathutils.Matrix(mat12[0],mat12[1],mat12[2],mat12[3])
+ else:
+ matr12 = Mathutils.Matrix(mat12[0],mat12[1],mat12[2])
+ return matr12
+
+
+#-----------------------------------------------------
+def projected_co(verts, matrix):
+ """ converts coordinates of points from OCS to WCS->ScreenCS
+ needs matrix: a projection matrix
+ needs verts: a list of vectors[x,y,z]
+ returns a list of [x,y,z]
+ """
+ #print 'deb:projected_co() verts=', verts #---------
+ temp_verts = [Mathutils.Vector(v)*matrix for v in verts]
+ #print 'deb:projected_co() temp_verts=', temp_verts #---------
+
+ if GUI_A['Z_force_on'].val: locZ = GUI_A['Z_elev'].val
+ else: locZ = 0.0
+
+ if PROJECTION:
+ if PERSPECTIVE:
+ clipStart = 10.0
+ for v in temp_verts:
+ coef = - clipStart / v[2]
+ v[0] *= coef
+ v[1] *= coef
+ v[2] = locZ
+ for v in temp_verts:
+ v[2] = locZ
+ temp_verts = [v[:3] for v in temp_verts]
+ #print 'deb:projected_co() out_verts=', temp_verts #---------
+ return temp_verts
+
#-----------------------------------------------------
-def exportMesh(ob, mx, mx_n,me=None):
+def isLeftHand(matrix):
+ #Is the matrix a left-hand-system, or not?
+ ma = matrix.rotationPart()
+ crossXY = M_CrossVecs(ma[0], ma[1])
+ check = M_DotVecs(ma[2], crossXY)
+ if check < 0.00001: return 1
+ return 0
+
+
+#-----------------------------------------------------
+def exportMesh(ob, mx, mx_n, me=None, **common):
+ """converts Mesh-Object to desired projection and representation(DXF-Entity type)
+ """
entities = []
- global APPLY_MODIFIERS
- if me is None:
+ #print 'deb:exportMesh() common=', common #---------
+ if me==None:
me = ob.getData(mesh=1)
else:
me.getFromObject(ob)
- #me.transform(mx)
- # above is eventualy faster, but bad, cause
- # directly transforms origin geometry and write back rounding errors
- me_verts = me.verts[:] #we dont want manipulate origin data
- #print 'deb: me_verts=', me_verts #---------
- #me.transform(mx_inv) #counterpart to - back to the origin state
- for v in me_verts:
- v.co *= mx
- faces=[]
- edges=[]
- if HIDDEN_MODE:
- ok_faces, ok_edges = hidden_status(me.faces, mx_n)
-
- #if (not FLATTEN) and len(me.faces)>0 and ONLYFACES:
- if ONLYFACES:
- if POLYFACES: #export 3D as POLYFACEs
- allpoints = []
- allfaces = []
- allpoints = [v.co[:3] for v in me_verts]
- for f in me.faces:
- #print 'deb: face=', f #---------
- if not HIDDEN_MODE or \
- (HIDDEN_MODE and f.index in ok_faces):
- if 1:
- points = f.verts
- face = [p.index+1 for p in points]
- #print 'deb: face=', face #---------
- allfaces.append(face)
- else: #bad, cause create multiple vertex instances
- points = f.verts
- points = [ me_verts[p.index].co[:3] for p in points]
- #points = [p.co[:3] for p in points]
- #print 'deb: points=', points #---------
- index = len(allpoints)+1
- face = [index+i for i in range(len(points))]
- allpoints.extend(points)
- allfaces.append(face)
- if allpoints and allfaces:
- #print 'deb: allpoints=', allpoints #---------
- #print 'deb: allfaces=', allfaces #---------
- dxfPOLYFACE = PolyLine([allpoints, allfaces], flag=64)
- entities.append(dxfPOLYFACE)
- else: #export 3D as 3DFACEs
- for f in me.faces:
- #print 'deb: face=', f #---------
- if not HIDDEN_MODE or \
- (HIDDEN_MODE and f.index in ok_faces):
- points = f.verts
- points = [ me_verts[p.index].co[:3] for p in points]
+ # me.transform(mx); get verts data; me.transform(mx_inv)= back to the origin state
+ # above .transform method is faster, but bad, cause invasive:
+ # it manipulates original geometry and by retransformation lefts back rounding-errors
+ # we dont want to manipulate original data!
+ #temp_verts = me.verts[:] #doesn't work on ubuntu(Yorik), bug?
+ if me.verts:
+ #print 'deb:exportMesh() started' #---------
+ allpoints = [v.co for v in me.verts]
+ allpoints = projected_co(allpoints, mx)
+ allpoints = toNewOrigin(allpoints)
+ faces=[]
+ edges=[]
+ if me.faces and PROJECTION and HIDDEN_LINES:
+ #if DEBUG: print 'deb:exportMesh HIDDEN_LINES mode' #---------
+ faces, edges = hidden_status(me.faces, mx, mx_n)
+ faces = [[v.index for v in me.faces[f_nr].verts] for f_nr in faces]
+ else:
+ #if DEBUG: print 'deb:exportMesh STANDARD mode' #---------
+ for e in me.edges: edges.append(e.key)
+ #faces = [f.index for f in me.faces]
+ faces = [[v.index for v in f.verts] for f in me.faces]
+ #faces = [[allpoints[v.index] for v in f.verts] for f in me.faces]
+ #print 'deb: allpoints=\n', allpoints #---------
+ #print 'deb: edges=\n', edges #---------
+ #print 'deb: faces=\n', faces #---------
+ if isLeftHand(mx): # then change vertex-order in every face
+ for f in faces:
+ f.reverse()
+ #f = [f[-1]] + f[:-1] #TODO: might be needed
+ #print 'deb: faces=\n', faces #---------
+
+ c = mesh_as_list[GUI_A['mesh_as'].val]
+ if 'POINTs'==c: # export Mesh as multiple POINTs
+ for p in allpoints:
+ dxfPOINT = DXF.Point(points=[p],**common)
+ entities.append(dxfPOINT)
+ elif 'LINEs'==c or (not faces):
+ if edges and allpoints:
+ if DEBUG: mesh_drawBlender(allpoints, edges, None) #deb: draw to blender scene
+ for e in edges:
+ points = [allpoints[e[0]], allpoints[e[1]]]
+ dxfLINE = DXF.Line(points, **common)
+ entities.append(dxfLINE)
+ elif faces:
+ if c in ('POLYFACE','POLYLINE'):
+ if allpoints:
+ #TODO: purge allpoints: left only vertices used by faces
+ if DEBUG: mesh_drawBlender(allpoints, None, faces) #deb: draw to scene
+ if not (PROJECTION and HIDDEN_LINES):
+ faces = [[v+1 for v in f] for f in faces]
+ else:
+ # for back-Faces-mode remove face-free verts
+ map=verts_state= [0]*len(allpoints)
+ for f in faces:
+ for v in f:
+ verts_state[v]=1
+ if 0 in verts_state: # if dirty state
+ i,newverts=0,[]
+ for used_i,used in enumerate(verts_state):
+ if used:
+ newverts.append(allpoints[used_i])
+ map[used_i]=i
+ i+=1
+ allpoints = newverts
+ faces = [[map[v]+1 for v in f] for f in faces]
+ dxfPOLYFACE = DXF.PolyLine([allpoints, faces], flag=64, **common)
+ #print '\n deb: dxfPOLYFACE=',dxfPOLYFACE #-------------
+ entities.append(dxfPOLYFACE)
+ elif '3DFACEs'==c:
+ if DEBUG: mesh_drawBlender(allpoints, None, faces) #deb: draw to scene
+ for f in faces:
+ #print 'deb: face=', f #---------
+ points = [allpoints[key] for key in f]
#points = [p.co[:3] for p in points]
- #print 'deb: points=', points #---------
- dxfFACE = Face(points)
+ #print 'deb: pointsXX=\n', points #---------
+ dxfFACE = DXF.Face(points, **common)
entities.append(dxfFACE)
+
+ return entities
- else: #export 3D as LINEs
- if HIDDEN_MODE and len(me.faces)!=0:
- for e in ok_edges:
- points = [ me_verts[key].co[:3] for key in e]
- dxfLINE = Line(points)
- entities.append(dxfLINE)
+#-----------------------------------------------------
+def mesh_drawBlender(vertList, edgeList, faceList, name="dxfMesh", flatten=False, AT_CUR=True, link=True):
+ #print 'deb:mesh_drawBlender started XXXXXXXXXXXXXXXXXX' #---------
+ ob = Object.New("Mesh",name)
+ me = Mesh.New(name)
+ #print 'deb: vertList=\n', vertList #---------
+ #print 'deb: edgeList=\n', edgeList #---------
+ #print 'deb: faceList=\n', faceList #---------
+ me.verts.extend(vertList)
+ if edgeList: me.edges.extend(edgeList)
+ if faceList: me.faces.extend(faceList)
+ if flatten:
+ for v in me.verts: v.co.z = 0.0
+ ob.link(me)
+ if link:
+ sce = Scene.getCurrent()
+ sce.objects.link(ob)
+ #me.triangleToQuad()
+ if AT_CUR:
+ cur_loc = Window.GetCursorPos()
+ ob.setLocation(cur_loc)
+ Blender.Redraw()
+ #return ob
- else:
- for e in me.edges:
- #print 'deb: edge=', e #---------
- points=[]
- #points = [e.v1.co*mx, e.v2.co*mx]
- points = [ me_verts[key].co[:3] for key in e.key]
- #print 'deb: points=', points #---------
- dxfLINE = Line(points)
- entities.append(dxfLINE)
+#-----------------------------------------------------
+def curve_drawBlender(vertList, org_point=[0.0,0.0,0.0], closed=0, name="dxfCurve", flatten=False, AT_CUR=True, link=True):
+ #print 'deb:curve_drawBlender started XXXXXXXXXXXXXXXXXX' #---------
+ ob = Object.New("Curve",name)
+ cu = Curve.New(name)
+ #print 'deb: vertList=\n', vertList #---------
+ curve = cu.appendNurb(BezTriple.New(vertList[0]))
+ for p in vertList[1:]:
+ curve.append(BezTriple.New(p))
+ for point in curve:
+ #point.handleTypes = [VECT, VECT]
+ point.handleTypes = [FREE, FREE]
+ point.radius = 1.0
+ curve.flagU = closed # 0 sets the curve not cyclic=open
+ cu.setResolu(6)
+ cu.update() #important for handles calculation
+ if flatten:
+ for v in cu.verts: v.co.z = 0.0
+ ob.link(cu)
+ if link:
+ sce = Scene.getCurrent()
+ sce.objects.link(ob)
+ #me.triangleToQuad()
+ if AT_CUR:
+ cur_loc = Window.GetCursorPos()
+ ob.setLocation(cur_loc)
+ elif org_point:
+ cur_loc=org_point
+ ob.setLocation(cur_loc)
+ Blender.Redraw()
+ #return ob
+
+
+#-----------------------------------------------------
+def toNewOrigin(points):
+ """relocates points to the new location
+ needs a list of points [x,y,z]
+ """
+ if GUI_A['g_origin_on'].val:
+ for p in points:
+ p[0] += G_ORIGIN[0]
+ p[1] += G_ORIGIN[1]
+ p[2] += G_ORIGIN[2]
+ return points
+
+
+#-----------------------------------------------------
+def exportEmpty(ob, mx, mw, **common):
+ """converts Empty-Object to desired projection and representation(DXF-Entity type)
+ """
+ p = Mathutils.Vector(ob.loc)
+ [p] = projected_co([p], mx)
+ [p] = toNewOrigin([p])
+
+ entities = []
+ c = empty_as_list[GUI_A['empty_as'].val]
+ if c=="POINT": # export Empty as POINT
+ dxfPOINT = DXF.Point(points=[p],**common)
+ entities.append(dxfPOINT)
+ return entities
+
+#-----------------------------------------------------
+def exportCamera(ob, mx, mw, **common):
+ """converts Camera-Object to desired projection and representation(DXF-Entity type)
+ """
+ p = Mathutils.Vector(ob.loc)
+ [p] = projected_co([p], mx)
+ [p] = toNewOrigin([p])
+
+ entities = []
+ c = camera_as_list[GUI_A['camera_as'].val]
+ if c=="POINT": # export as POINT
+ dxfPOINT = DXF.Point(points=[p],**common)
+ entities.append(dxfPOINT)
+ return entities
+
+#-----------------------------------------------------
+def exportLamp(ob, mx, mw, **common):
+ """converts Lamp-Object to desired projection and representation(DXF-Entity type)
+ """
+ p = Mathutils.Vector(ob.loc)
+ [p] = projected_co([p], mx)
+ [p] = toNewOrigin([p])
+
+ entities = []
+ c = lamp_as_list[GUI_A['lamp_as'].val]
+ if c=="POINT": # export as POINT
+ dxfPOINT = DXF.Point(points=[p],**common)
+ entities.append(dxfPOINT)
+ return entities
+
+#-----------------------------------------------------
+def exportText(ob, mx, mw, **common):
+ """converts Text-Object to desired projection and representation(DXF-Entity type)
+ """
+ text3d = ob.getData()
+ textstr = text3d.getText()
+ WCS_loc = ob.loc # WCS_loc is object location in WorldCoordSystem
+ sizeX = ob.SizeX
+ sizeY = ob.SizeY
+ sizeZ = ob.SizeZ
+ rotX = ob.RotX
+ rotY = ob.RotY
+ rotZ = ob.RotZ
+ #print 'deb: sizeX=%s, sizeY=%s' %(sizeX, sizeY) #---------
+
+ Thickness,Extrusion,ZRotation,Elevation = None,None,None,None
+
+ AXaxis = mx[0].copy().resize3D() # = ArbitraryXvector
+ if not PROJECTION:
+ #Extrusion, ZRotation, Elevation = getExtrusion(mx)
+ Extrusion, AXaxis = getExtrusion(mx)
+
+ # no thickness/width for TEXTs converted into ScreenCS
+ if text3d.getExtrudeDepth():
+ Thickness = text3d.getExtrudeDepth() * sizeZ
+
+ #Horizontal text justification type, code 72, (optional, default = 0)
+ # integer codes (not bit-coded)
+ #0=left, 1=center, 2=right
+ #3=aligned, 4=middle, 5=fit
+ Alignment = None
+ alignment = text3d.getAlignment().value
+ if alignment in (1,2): Alignment = alignment
+
+ textHeight = text3d.getSize() / 1.7
+ textFlag = 0
+ if sizeX < 0.0: textFlag |= 2 # set flag for horizontal mirrored
+ if sizeZ < 0.0: textFlag |= 4 # vertical mirrored
+
+ entities = []
+ c = text_as_list[GUI_A['text_as'].val]
+
+ if c=="TEXT": # export text as TEXT
+ if not PROJECTION:
+ ZRotation,Zrotmatrix,OCS_origin,ECS_origin = getTargetOrientation(mx,Extrusion,\
+ AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ)
+ ZRotation *= r2d
+ point = ECS_origin
+ else: #TODO: fails correct location
+ point1 = Mathutils.Vector(ob.loc)
+ [point] = projected_co([point1], mx)
+ if PERSPECTIVE:
+ clipStart = 10.0
+ coef = -clipStart / (point1*mx)[2]
+ textHeight *= coef
+ #print 'deb: coef=', coef #--------------
+
+ #print 'deb: point=', point #--------------
+ [point] = toNewOrigin([point])
+ point2 = point
+
+ #if DEBUG: text_drawBlender(textstr,points,OCS_origin) #deb: draw to scene
+ common['extrusion']= Extrusion
+ #common['elevation']= Elevation
+ common['thickness']= Thickness
+ #print 'deb: common=', common #------------------
+ if 0: #DEBUG
+ #linepoints = [[0,0,0], [AXaxis[0],AXaxis[1],AXaxis[2]]]
+ linepoints = [[0,0,0], point]
+ dxfLINE = DXF.Line(linepoints,**common)
+ entities.append(dxfLINE)
+
+ dxfTEXT = DXF.Text(text=textstr,point=point,alignment=point2,rotation=ZRotation,\
+ flag=textFlag,height=textHeight,justifyhor=Alignment,**common)
+ entities.append(dxfTEXT)
+ if Thickness:
+ common['thickness']= -Thickness
+ dxfTEXT = DXF.Text(text=textstr,point=point,alignment=point2,rotation=ZRotation,\
+ flag=textFlag,height=textHeight,justifyhor=Alignment,**common)
+ entities.append(dxfTEXT)
return entities
+#-------------------------------------------
+def euler2matrix(rx, ry, rz):
+ """creates full 3D rotation matrix (optimized)
+ needs rx, ry, rz angles in radians
+ """
+ #print 'rx, ry, rz: ', rx, ry, rz
+ A, B = sin(rx), cos(rx)
+ C, D = sin(ry), cos(ry)
+ E, F = sin(rz), cos(rz)
+ AC, BC = A*C, B*C
+ return Mathutils.Matrix([D*F, D*E, -C],
+ [AC*F-B*E, AC*E+B*F, A*D],
+ [BC*F+A*E, BC*E-A*F, B*D])
+
+
+#-----------------------------------------------------
+def getTargetOrientation(mx,Extrusion,AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ):
+ """given
+ """
+ if 1:
+ rot_matrix = normalizeMat(mx.rotationPart())
+ #TODO: workaround for blender negative-matrix.invert()
+ # partially done: works only for rotX,rotY==0.0
+ if sizeX<0.0: rot_matrix[0] *= -1
+ if sizeY<0.0: rot_matrix[1] *= -1
+ #if sizeZ<0.0: rot_matrix[2] *= -1
+ rot_matrix_invert = rot_matrix.invert()
+ else: #TODO: to check, why below rot_matrix_invert is not equal above one
+ rot_euler_matrix = euler2matrix(rotX,rotY,rotZ)
+ rot_matrix_invert = euler2matrix(-rotX,-rotY,-rotZ)
+
+ # OCS_origin is Global_Origin in ObjectCoordSystem
+ OCS_origin = Mathutils.Vector(WCS_loc) * rot_matrix_invert
+ #print 'deb: OCS_origin=', OCS_origin #---------
+
+ ZRotation = rotZ
+ if Extrusion!=None:
+ ZRotation = getZRotation(AXaxis,rot_matrix_invert)
+ #Zrotmatrix = Mathutils.RotationMatrix(-ZRotation, 3, "Z")
+ rs, rc = sin(ZRotation), cos(ZRotation)
+ Zrotmatrix = Mathutils.Matrix([rc, rs,0.0],[-rs,rc,0.0],[0.0,0.0,1.0])
+ #print 'deb: Zrotmatrix=\n', Zrotmatrix #--------------
+
+ # ECS_origin is Global_Origin in EntityCoordSystem
+ ECS_origin = OCS_origin * Zrotmatrix
+ #print 'deb: ECS_origin=', ECS_origin #---------
+ #TODO: it doesnt work yet for negative scaled curve-objects!
+ return ZRotation,Zrotmatrix,OCS_origin,ECS_origin
+
+
#-----------------------------------------------------
-def exportCurve(ob, mx):
+def exportCurve(ob, mx, mw, **common):
+ """converts Curve-Object to desired projection and representation(DXF-Entity type)
+ """
entities = []
curve = ob.getData()
+ WCS_loc = ob.loc # WCS_loc is object location in WorldCoordSystem
+ #WCS_loc = [0.0,0.0,0.0]
+ #print 'deb: WCS_loc=', WCS_loc #---------
+ sizeX = ob.SizeX
+ sizeY = ob.SizeY
+ sizeZ = ob.SizeZ
+ rotX = ob.RotX
+ rotY = ob.RotY
+ rotZ = ob.RotZ
+ #print 'deb: sizeX=%s, sizeY=%s' %(sizeX, sizeY) #---------
+
+ Thickness,Extrusion,ZRotation,Elevation = None,None,None,None
+ AXaxis = mx[0].copy().resize3D() # = ArbitraryXvector
+ OCS_origin = [0,0,0]
+ if not PROJECTION:
+ #Extrusion, ZRotation, Elevation = getExtrusion(mx)
+ Extrusion, AXaxis = getExtrusion(mx)
+
+ # no thickness/width for POLYLINEs converted into ScreenCS
+ #print 'deb: curve.ext1=', curve.ext1 #---------
+ if curve.ext1: Thickness = curve.ext1 * sizeZ
+ if curve.ext2 and sizeX==sizeY:
+ Width = curve.ext2 * sizeX
+ if "POLYLINE"==curve_as_list[GUI_A['curve_as'].val]: # export as POLYLINE
+ ZRotation,Zrotmatrix,OCS_origin,ECS_origin = getTargetOrientation(mx,Extrusion,\
+ AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ)
+
for cur in curve:
#print 'deb: START cur=', cur #--------------
- if 1: #not cur.isNurb():
- #print 'deb: START points' #--------------
- points = []
- org_point = [0.0,0.0,0.0]
+ points = []
+ if cur.isNurb():
for point in cur:
- #print 'deb: point=', point #---------
- if cur.isNurb():
- vec = point[0:3]
- else:
- point = point.getTriple()
- #print 'deb: point=', point #---------
- vec = point[1]
+ #print 'deb:isNurb point=', point #---------
+ vec = point[0:3]
+ #print 'deb: vec=', vec #---------
+ pkt = Mathutils.Vector(vec)
+ #print 'deb: pkt=', pkt #---------
+ points.append(pkt)
+ else:
+ for point in cur:
+ #print 'deb:isBezier point=', point.getTriple() #---------
+ vec = point.getTriple()[1]
#print 'deb: vec=', vec #---------
- pkt = Mathutils.Vector(vec) * mx
+ pkt = Mathutils.Vector(vec)
#print 'deb: pkt=', pkt #---------
- #pkt *= SCALE_FACTOR
- if 0: #FLATTEN:
- pkt = projected_co(pkt, mw)
points.append(pkt)
- if cur.isCyclic(): closed = 1
- else: closed = 0
- if len(points)>1:
+
+ #print 'deb: points', points #--------------
+ if len(points)>1:
+ c = curve_as_list[GUI_A['curve_as'].val]
+
+ if c=="POLYLINE": # export Curve as POLYLINE
+ if not PROJECTION:
+ # recalculate points(2d=X,Y) into Entity-Coords-System
+ for p in points: # list of vectors
+ p[0] *= sizeX
+ p[1] *= sizeY
+ p2 = p * Zrotmatrix
+ p2[0] += ECS_origin[0]
+ p2[1] += ECS_origin[1]
+ p[0],p[1] = p2[0],p2[1]
+ else:
+ points = projected_co(points, mx)
#print 'deb: points', points #--------------
- if POLYLINES: dxfPLINE = PolyLine(points,org_point,closed)
- else: dxfPLINE = LineList(points,org_point,closed)
+
+ if cur.isCyclic(): closed = 1
+ else: closed = 0
+ points = toNewOrigin(points)
+
+ if DEBUG: curve_drawBlender(points,OCS_origin,closed) #deb: draw to scene
+ common['extrusion']= Extrusion
+ ##common['rotation']= ZRotation
+ ##common['elevation']= Elevation
+ common['thickness']= Thickness
+ #print 'deb: common=', common #------------------
+
+ if 0: #DEBUG
+ p=AXaxis[:3]
+ entities.append(DXF.Line([[0,0,0], p],**common))
+ p=ECS_origin[:3]
+ entities.append(DXF.Line([[0,0,0], p],**common))
+ common['color']= 5
+ p=OCS_origin[:3]
+ entities.append(DXF.Line([[0,0,0], p],**common))
+ #OCS_origin=[0,0,0] #only debug----------------
+ dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common)
+ entities.append(dxfPLINE)
+
+ dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common)
entities.append(dxfPLINE)
+ if Thickness:
+ common['thickness']= -Thickness
+ dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common)
+ entities.append(dxfPLINE)
+
+ elif c=="LINEs": # export Curve as multiple LINEs
+ points = projected_co(points, mx)
+ if cur.isCyclic(): points.append(points[0])
+ #print 'deb: points', points #--------------
+ points = toNewOrigin(points)
+
+ if DEBUG: curve_drawBlender(points,WCS_loc,closed) #deb: draw to scene
+ common['extrusion']= Extrusion
+ common['elevation']= Elevation
+ common['thickness']= Thickness
+ #print 'deb: common=', common #------------------
+ for i in range(len(points)-1):
+ linepoints = [points[i], points[i+1]]
+ dxfLINE = DXF.Line(linepoints,**common)
+ entities.append(dxfLINE)
+ if Thickness:
+ common['thickness']= -Thickness
+ for i in range(len(points)-1):
+ linepoints = [points[i], points[i+1]]
+ dxfLINE = DXF.Line(linepoints,**common)
+ entities.append(dxfLINE)
+
+ elif c=="POINTs": # export Curve as multiple POINTs
+ points = projected_co(points, mx)
+ for p in points:
+ dxfPOINT = DXF.Point(points=[p],**common)
+ entities.append(dxfPOINT)
+
return entities
#-----------------------------------------------------
+def getClipBox(camera):
+ """calculates Field-of-View-Clipping-Box of given Camera
+ returns clip_box: a list of vertices
+ returns matr: translation matrix
+ """
+ sce = Scene.GetCurrent()
+ context = sce.getRenderingContext()
+ #print 'deb: context=\n', context #------------------
+ sizeX = context.sizeX
+ sizeY = context.sizeY
+ ratioXY = sizeX/float(sizeY)
+ #print 'deb: size X,Y, ratio=', sizeX, sizeY, ratioXY #------------------
+
+ clip1_Z = - camera.clipStart
+ clip2_Z = - camera.clipEnd
+ #print 'deb: clip Start=', camera.clipStart #------------------
+ #print 'deb: clip End=', camera.clipEnd #------------------
+
+ if camera.type=='ortho':
+ scale = camera.scale
+ #print 'deb: camscale=', scale #------------------
+ clip1shiftX = clip2shiftX = camera.shiftX * scale
+ clip1shiftY = clip2shiftY = camera.shiftY * scale
+ clip1_X = scale * 0.5
+ clip1_Y = scale * 0.5
+ if ratioXY > 1.0: clip1_Y /= ratioXY
+ else: clip1_X *= ratioXY
+ clip2_X = clip1_X
+ clip2_Y = clip1_Y
+
+ near = clip1_Z
+ far = clip2_Z
+ right, left = clip1_X, -clip1_X
+ top, bottom = clip1_Y, -clip1_Y
+
+ scaleX = 2.0/float(right - left)
+ x3 = -float(right + left)/float(right - left)
+ scaleY = 2.0/float(top - bottom)
+ y3 = -float(top + bottom)/float(top - bottom)
+ scaleZ = 1.0/float(far - near)
+ z3 = -float(near)/float(far - near)
+
+ matrix = Mathutils.Matrix( [scaleX, 0.0, 0.0, x3],
+ [0.0, scaleY, 0.0, y3],
+ [0.0, 0.0, scaleZ, z3],
+ [0.0, 0.0, 0.0, 1.0])
+
+ elif camera.type=='persp':
+ #viewpoint = [0.0, 0.0, 0.0] #camera's coordinate system, hehe
+ #lens = camera.lens
+ angle = camera.angle
+ #print 'deb: cam angle=', angle #------------------
+ shiftX = camera.shiftX
+ shiftY = camera.shiftY
+ fov_coef = atan(angle * d2r)
+ fov_coef *= 1.3 #incl. passpartou
+ clip1_k = clip1_Z * fov_coef
+ clip2_k = clip2_Z * fov_coef
+ clip1shiftX = - camera.shiftX * clip1_k
+ clip2shiftX = - camera.shiftX * clip2_k
+ clip1shiftY = - camera.shiftY * clip1_k
+ clip2shiftY = - camera.shiftY * clip2_k
+ clip1_X = clip1_Y = clip1_k * 0.5
+ clip2_X = clip2_Y = clip2_k * 0.5
+ if ratioXY > 1.0:
+ clip1_Y /= ratioXY
+ clip2_Y /= ratioXY
+ else:
+ clip1_X *= ratioXY
+ clip2_X *= ratioXY
+
+ near = clip1_Z
+ far = clip2_Z
+ right, left = clip1_X, -clip1_X
+ top, bottom = clip1_Y, -clip1_Y
+ #return Matrix( [scaleX, 0.0, x2, 0.0],
+ #[0.0, scaleY, y2, 0.0],
+ #[0.0, 0.0, scaleZ, wZ],
+ #[0.0, 0.0, -1.0, 0.0])
+ matrix = Mathutils.Matrix( [(2.0 * near)/float(right - left), 0.0, float(right + left)/float(right - left), 0.0],
+ [0.0, (2.0 * near)/float(top - bottom), float(top + bottom)/float(top - bottom), 0.0],
+ [0.0, 0.0, -float(far + near)/float(far - near), -(2.0 * far * near)/float(far - near)],
+ [0.0, 0.0, -1.0, 0.0])
+
+
+ clip_box = [
+ -clip1_X + clip1shiftX, clip1_X + clip1shiftX,
+ -clip1_Y + clip1shiftY, clip1_Y + clip1shiftY,
+ -clip2_X + clip2shiftX, clip2_X + clip2shiftX,
+ -clip2_Y + clip2shiftY, clip2_Y + clip2shiftY,
+ clip1_Z, clip2_Z]
+ #print 'deb: clip_box=\n', clip_box #------------------
+ #drawClipBox(clip_box)
+ return clip_box, matrix
+
+
+#-----------------------------------------------------
+def drawClipBox(clip_box):
+ """debug tool: draws Clipping-Box of a Camera View
+ """
+ min_X1, max_X1, min_Y1, max_Y1,\
+ min_X2, max_X2, min_Y2, max_Y2,\
+ min_Z, max_Z = clip_box
+ verts = []
+ verts.append([min_X1, min_Y1, min_Z])
+ verts.append([max_X1, min_Y1, min_Z])
+ verts.append([max_X1, max_Y1, min_Z])
+ verts.append([min_X1, max_Y1, min_Z])
+ verts.append([min_X2, min_Y2, max_Z])
+ verts.append([max_X2, min_Y2, max_Z])
+ verts.append([max_X2, max_Y2, max_Z])
+ verts.append([min_X2, max_Y2, max_Z])
+ faces = [[0,1,2,3],[4,5,6,7]]
+ nme = Mesh.New()
+ nme.verts.extend(verts)
+ nme.faces.extend(faces)
+
+ plan = Object.New('Mesh','clip_box')
+ plan.link(nme)
+ sce = Scene.GetCurrent()
+ sce.objects.link(plan)
+ plan.setMatrix(sce.objects.camera.matrix)
+
+
+#-------------------------------------------------
+def getCommons(ob):
+ """set up common attributes for output style:
+ color=None
+ extrusion=None
+ layer='0',
+ lineType=None
+ lineTypeScale=None
+ lineWeight=None
+ thickness=None
+ parent=None
+ """
+
+ layers = ob.layers #gives a list e.g.[1,5,19]
+ if layers: ob_layer_nr = layers[0]
+ #print 'ob_layer_nr=', ob_layer_nr #--------------
+
+ materials = ob.getMaterials()
+ if materials:
+ ob_material = materials[0]
+ ob_mat_color = ob_material.rgbCol
+ else: ob_mat_color, ob_material = None, None
+ #print 'ob_mat_color, ob_material=', ob_mat_color, ob_material #--------------
+
+ data = ob.getData()
+ data_materials = ob.getMaterials()
+ if data_materials:
+ data_material = data_materials[0]
+ data_mat_color = data_material.rgbCol
+ else: data_mat_color, data_material = None, None
+ #print 'data_mat_color, data_material=', data_mat_color, data_material #--------------
+
+ entitylayer = ENTITYLAYER_DEF
+ c = entitylayer_from_list[GUI_A['entitylayer_from'].val]
+ #["default_LAYER","obj.name","obj.layer","obj.material","obj.data.name","obj.data.material","..vertexgroup","..group","..map_table"]
+ if c=="default_LAYER":
+ entitylayer = LAYERNAME_DEF
+ elif c=="obj.layer" and ob_layer_nr:
+ entitylayer = 'LAYER'+ str(ob_layer_nr)
+ elif c=="obj.material" and ob_material:
+ entitylayer = ob_material.name
+ elif c=="obj.name":
+ entitylayer = ob.name
+ elif c=="obj.data.material" and ob_material:
+ entitylayer = data_material.name
+ elif c=="obj.data.name":
+ entitylayer = data.name
+ entitylayer = validDXFr12name(PREFIX+entitylayer)
+ if entitylayer=="": entitylayer = "BF_0"
+
+ entitycolor = ENTITYCOLOR_DEF
+ c = entitycolor_from_list[GUI_A['entitycolor_from'].val]
+ if c=="default_COLOR":
+ entitycolor = LAYERCOLOR_DEF
+ elif c=="BYLAYER":
+ entitycolor = BYLAYER
+ elif c=="BYBLOCK":
+ entitycolor = BYBLOCK
+ elif c=="obj.layer" and ob_layer_nr:
+ entitycolor = ob_layer_nr
+ elif c=="obj.color" and ob.color:
+ entitycolor = col2DXF(ob.color)
+ elif c=="obj.material" and ob_mat_color:
+ entitycolor = col2DXF(ob_mat_color)
+ elif c=="obj.data.material" and data_mat_color:
+ entitycolor = col2DXF(data_mat_color)
+ #if entitycolor!=None: layercolor = entitycolor
+
+ entityltype = ENTITYLTYPE_DEF
+ c = entityltype_from_list[GUI_A['entityltype_from'].val]
+ if c=="default_LTYPE":
+ entityltype = LAYERLTYPE_DEF
+ elif c=="BYLAYER":
+ entityltype = BYLAYER
+ elif c=="BYBLOCK":
+ entityltype = BYBLOCK
+ elif c:
+ entityltype = c
+
+ return entitylayer,entitycolor,entityltype
+
+
+#-----------------------------------------------------
def do_export(export_list, filepath):
+ global PERSPECTIVE, CAMERAVIEW
Window.WaitCursor(1)
- t = sys.time()
-
- #init Drawing ---------------------
- d=Drawing()
- #add Tables -----------------
- #d.blocks.append(b) #table blocks
- d.styles.append(Style()) #table styles
- d.views.append(View('Normal')) #table view
- d.views.append(ViewByWindow('Window',leftBottom=(1,0),rightTop=(2,1))) #idem
-
- #add Entities --------------------
- something_ready = False
- #ViewVector = Mathutils.Vector(Window.GetViewVector())
- #print 'deb: ViewVector=', ViewVector #------------------
- mw0 = Window.GetViewMatrix()
- #mw0 = Window.GetPerspMatrix() #TODO: how get it working?
- mw = mw0.copy()
- if FLATTEN:
- m0 = Mathutils.Matrix()
- m0[2][2]=0.0
- mw *= m0 #flatten ViewMatrix
-
- if APPLY_MODIFIERS:
- tmp_me = Mesh.New('tmp')
- else:
- tmp_me = None
+ t = Blender.sys.time()
+ # init Drawing ---------------------
+ d=DXF.Drawing()
+ # add Tables -----------------
+ #d.blocks.append(b) #table blocks
+ #goes automatic: d.styles.append(DXF.Style()) #table styles
+ #d.views.append(DXF.View('Normal')) #table view
+ d.views.append(DXF.ViewByWindow('BF_TOPVIEW',leftBottom=(-100,-60),rightTop=(100,60))) #idem
+
+ # add Entities --------------------
+ something_ready = 0
+ selected_len = len(export_list)
+ sce = Scene.GetCurrent()
+
+ mw = Mathutils.Matrix( [1.0, 0.0, 0.0, 0.0],
+ [0.0, 1.0, 0.0, 0.0],
+ [0.0, 0.0, 1.0, 0.0],
+ [0.0, 0.0, 0.0, 1.0])
+ if PROJECTION:
+ if CAMERA<len(CAMERAS)+1: # the biggest number is the current 3d-view
+ act_camera = Object.Get(CAMERAS[CAMERA-1])
+ #context = sce.getRenderingContext()
+ #print 'deb: context=\n', context #------------------
+ #print 'deb: context=\n', dir(context) #------------------
+ #act_camera = sce.objects.camera
+ #print 'deb: act_camera=', act_camera #------------------
+ if act_camera:
+ CAMERAVIEW = 1
+ mc0 = act_camera.matrix.copy()
+ #print 'deb: camera.Matrix=\n', mc0 #------------------
+ camera = Camera.Get(act_camera.getData(name_only=True))
+ #print 'deb: camera=', dir(camera) #------------------
+ if camera.type=='persp': PERSPECTIVE = 1
+ elif camera.type=='ortho': PERSPECTIVE = 0
+ # mcp is matrix.camera.perspective
+ clip_box, mcp = getClipBox(camera)
+ if PERSPECTIVE:
+ # get border
+ # lens = camera.lens
+ min_X1, max_X1, min_Y1, max_Y1,\
+ min_X2, max_X2, min_Y2, max_Y2,\
+ min_Z, max_Z = clip_box
+ verts = []
+ verts.append([min_X1, min_Y1, min_Z])
+ verts.append([max_X1, min_Y1, min_Z])
+ verts.append([max_X1, max_Y1, min_Z])
+ verts.append([min_X1, max_Y1, min_Z])
+ border=verts
+ mw = mc0.copy().invert()
+
+ else: # get 3D-View instead of camera-view
+ #ViewVector = Mathutils.Vector(Window.GetViewVector())
+ #print 'deb: ViewVector=\n', ViewVector #------------------
+ #TODO: what is Window.GetViewOffset() for?
+ #print 'deb: Window.GetViewOffset():', Window.GetViewOffset() #---------
+ #Window.SetViewOffset([0,0,0])
+ mw0 = Window.GetViewMatrix()
+ #print 'deb: mwOrtho =\n', mw0 #---------
+ mwp = Window.GetPerspMatrix() #TODO: how to get it working?
+ #print 'deb: mwPersp =\n', mwp #---------
+ mw = mw0.copy()
+
+ #print 'deb: ViewMatrix=\n', mw #------------------
+
+ if APPLY_MODIFIERS: tmp_me = Mesh.New('tmp')
+ else: tmp_me = None
+
+ if GUI_A['paper_space_on'].val==1: espace=1
+ else: espace=None
+
+ layernames = []
for ob,mx in export_list:
entities = []
#mx = ob.matrix.copy()
- mb = mx.copy()
- #print 'deb: mb =\n', mb #---------
- #print 'deb: mw0 =\n', mw0 #---------
- mx_n = mx.rotationPart() * mw0.rotationPart() #trans-matrix for normal_vectors
- if SCALE_FACTOR!=1.0: mx *= SCALE_FACTOR
- if FLATTEN: mx *= mw
-
+ #print 'deb: ob =', ob #---------
+ print 'deb: ob.type =', ob.type #---------
+ #print 'deb: mx =\n', mx #---------
+ #print 'deb: mw0 =\n', mw0 #---------
+ #mx_n is trans-matrix for normal_vectors for front-side faces
+ mx_n = mx.rotationPart() * mw.rotationPart()
+ if G_SCALE!=1.0: mx *= G_SCALE
+ mx *= mw
+
#mx_inv = mx.copy().invert()
- #print 'deb: mx =\n', mx #---------
+ #print 'deb: mx =\n', mx #---------
#print 'deb: mx_inv=\n', mx_inv #---------
- if (ob.type == 'Mesh'):
- entities = exportMesh(ob, mx, mx_n,tmp_me)
- elif (ob.type == 'Curve'):
- entities = exportCurve(ob, mx)
+ if ob.type in ('Mesh','Curve','Empty','Text','Camera','Lamp'):
+ elayer,ecolor,eltype = getCommons(ob)
+ #print 'deb: elayer,ecolor,eltype =', elayer,ecolor,eltype #--------------
+
+ #TODO: use ob.boundBox for drawing extends
- for e in entities:
- d.append(e)
- something_ready = True
+ if elayer!=None:
+ if elayer not in layernames:
+ layernames.append(elayer)
+ if ecolor!=None: tempcolor = ecolor
+ else: tempcolor = LAYERCOLOR_DEF
+ d.layers.append(DXF.Layer(color=tempcolor, name=elayer))
+ if (ob.type == 'Mesh') and GUI_B['bmesh'].val:
+ entities = exportMesh(ob, mx, mx_n, tmp_me,\
+ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype)
+ elif (ob.type == 'Curve') and GUI_B['bcurve'].val:
+ entities = exportCurve(ob, mx, mw, \
+ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype)
+ elif (ob.type == 'Empty') and GUI_B['empty'].val:
+ entities = exportEmpty(ob, mx, mw, \
+ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype)
+ elif (ob.type == 'Text') and GUI_B['text'].val:
+ entities = exportText(ob, mx, mw, \
+ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype)
+ elif (ob.type == 'Camera') and GUI_B['camera'].val:
+ entities = exportCamera(ob, mx, mw, \
+ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype)
+ elif (ob.type == 'Lamp') and GUI_B['lamp'].val:
+ entities = exportLamp(ob, mx, mw, \
+ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype)
+
+ if entities:
+ something_ready += 1
+ for e in entities:
+ d.append(e)
+
if something_ready:
- if not OUTPUT_DWG:
- print 'exporting to %s' % filepath
- d.saveas(filepath)
- Window.WaitCursor(0)
- #Draw.PupMenu('DXF Exporter: job finished')
- print ' finished in %.2f seconds. -----DONE-----' % (sys.time()-t)
+ if PERSPECTIVE: # draw view border
+ mw2 = Mathutils.Matrix().identity()
+ points = projected_co(border, mw2)
+ closed = 1
+ points = toNewOrigin(points)
+
+ dxfPLINE = DXF.PolyLine(points,points[0],closed,\
+ paperspace=espace, color=LAYERCOLOR_DEF)
+ d.append(dxfPLINE)
+
+
+ if not GUI_A['outputDWG_on'].val:
+ print 'writing to %s' % filepath
+ try:
+ d.saveas(filepath)
+ Window.WaitCursor(0)
+ #print '%s objects exported to %s' %(something_ready,filepath)
+ print '%s/%s objects exported in %.2f seconds. -----DONE-----' %(something_ready,selected_len,(Blender.sys.time()-t))
+ Draw.PupMenu('DXF Exporter: job finished!| %s/%s objects exported in %.2f sek.' %(something_ready,selected_len, (Blender.sys.time()-t)))
+ except IOError:
+ Window.WaitCursor(0)
+ Draw.PupMenu('DXF Exporter: Write Error: Permission denied:| %s' %filepath)
+
else:
if not extCONV_OK:
Draw.PupMenu(extCONV_TEXT)
@@ -416,117 +1330,1443 @@ def do_export(export_list, filepath):
d.saveas(filepath)
#Draw.PupMenu('DXF Exporter: job finished')
#print 'exported to %s' % filepath
- #print 'finished in %.2f seconds' % (sys.time()-t)
+ #print 'finished in %.2f seconds' % (Blender.sys.time()-t)
filedwg = filepath[:-3]+'dwg'
print 'exporting to %s' % filedwg
os.system('%s %s -acad13 -dwg' %(extCONV_PATH,filepath))
#os.chdir(cwd)
os.remove(filepath)
Window.WaitCursor(0)
- print ' finished in %.2f seconds. -----DONE-----' % (sys.time()-t)
-
+ print ' finished in %.2f seconds. -----DONE-----' % (Blender.sys.time()-t)
+ Draw.PupMenu('DWG Exporter: job finished!| %s/%s objects exported in %.2f sek.' %(something_ready,selected_len, (Blender.sys.time()-t)))
else:
Window.WaitCursor(0)
- print "Abort: selected objects dont mach choosen export option, nothing exported!"
- Draw.PupMenu('DXF Exporter: nothing exported!|selected objects dont mach choosen export option!')
+ print "Abort: selected objects dont match choosen export option, nothing exported!"
+ Draw.PupMenu('DXF Exporter: nothing exported!|selected objects dont match choosen export option!')
-#----globals------------------------------------------
-ONLYSELECTED = True
-POLYLINES = True
-ONLYFACES = False
-POLYFACES = 1
-FLATTEN = 0
-HIDDEN_MODE = False #filter out hidden lines
-SCALE_FACTOR = 1.0 #optional, can be done later in CAD too
-APPLY_MODIFIERS = True
-INCLUDE_DUPLIS = False
-OUTPUT_DWG = False #optional save to DWG with extern converter
-#-----------------------------------------------------
-def dxf_export_ui(filepath):
- global ONLYSELECTED,\
- POLYLINES,\
- ONLYFACES,\
- POLYFACES,\
- FLATTEN,\
- HIDDEN_MODE,\
- SCALE_FACTOR,\
- APPLY_MODIFIERS,\
- OUTPUT_DWG,\
- INCLUDE_DUPLIS
-
- print '\n\nDXF-Export %s -----------START-----------' %__version__
- #filepath = 'blend_test.dxf'
- # Dont overwrite
- if not BPyMessages.Warning_SaveOver(filepath):
- print 'Aborted by user: nothing exported'
- return
- #test():return
-
-
- PREF_ONLYSELECTED= Draw.Create(ONLYSELECTED)
- PREF_POLYLINES= Draw.Create(POLYLINES)
- PREF_ONLYFACES= Draw.Create(ONLYFACES)
- PREF_POLYFACES= Draw.Create(POLYFACES)
- PREF_FLATTEN= Draw.Create(FLATTEN)
- PREF_HIDDEN_MODE= Draw.Create(HIDDEN_MODE)
- PREF_SCALE_FACTOR= Draw.Create(SCALE_FACTOR)
- PREF_APPLY_MODIFIERS= Draw.Create(APPLY_MODIFIERS)
- PREF_INCLUDE_DUPLIS= Draw.Create(INCLUDE_DUPLIS)
- PREF_HELP= Draw.Create(0)
- PREF_DWG= Draw.Create(OUTPUT_DWG)
- block = [\
- ("only selected", PREF_ONLYSELECTED, "export only selected geometry"),\
- ("Apply Modifiers", PREF_APPLY_MODIFIERS, "Apply modifier stack to mesh objects before export"),\
- ("Include Duplis", PREF_INCLUDE_DUPLIS, "Export also Duplicates (dupliverts, dupliframes etc)"),\
- ("global Scale:", PREF_SCALE_FACTOR, 0.001, 1000, "set global Scale factor for exporting geometry"),\
- (''),\
- ("export to 3DFaces", PREF_ONLYFACES, "from mesh-objects export only faces, otherwise only edges"),\
- ("mesh to POLYFACE", PREF_POLYFACES, "export mesh to POLYFACE, otherwise to 3DFACEs"),\
- ("curves to POLYLINEs", PREF_POLYLINES, "export curve to POLYLINE, otherwise to LINEs"),\
- ("3D-View to Flat", PREF_FLATTEN, "flatten geometry according current 3d-View"),\
- ("Hidden Mode", PREF_HIDDEN_MODE, "filter out hidden lines"),\
- ("online Help", PREF_HELP, "calls DXF-Exporter Manual Page on Wiki.Blender.org"),\
- (''),\
- ("DXF->DWG", PREF_DWG, "writes DWG with extern converter"),\
- ]
-
- if not Draw.PupBlock("DXF-Exporter %s" %__version__[:10], block): return
-
- if PREF_HELP.val!=0:
+#------------------------------------------------------
+"""
+v = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,\
+28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,47,58,59,60,61,62,63,64,91,92,93,94,96,\
+123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,\
+151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,\
+171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,\
+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,\
+211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,\
+231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254]
+invalid = ''.join([chr(i) for i in v])
+del v, i
+"""
+#TODO: validDXFr14 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.'
+validDXFr12 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
+
+#------------------------------------------------------
+def cleanName(name,valid):
+ validname = ''
+ for ch in name:
+ if ch not in valid: ch = '_'
+ validname += ch
+ return validname
+
+#------------------------------------------------------
+def validDXFr12name(str_name):
+ dxfname = str(str_name)
+ dxfname = dxfname[:NAMELENGTH_MAX].upper()
+ dxfname = cleanName(dxfname,validDXFr12)
+ return dxfname
+
+#print cleanName('dumka',validDXFr12)
+#print validDXFr12name('dum 15%ka')
+
+#------------------------------------------------------
+def col2RGB(color):
+ return [int(floor(255*color[0])),
+ int(floor(255*color[1])),
+ int(floor(255*color[2]))]
+
+global dxfColors
+dxfColors=None
+
+#------------------------------------------------------
+def col2DXF(rgbcolor):
+ global dxfColors
+ if dxfColors is None:
+ from dxfColorMap import color_map
+ dxfColors = [(tuple(color),idx) for idx, color in color_map.iteritems()]
+ dxfColors.sort()
+ entry = (tuple(rgbcolor), -1)
+ dxfColors.append(entry)
+ dxfColors.sort()
+ i = dxfColors.index(entry)
+ dxfColors.pop(i)
+ return dxfColors[i-1][1]
+
+
+
+# NEW UI -----#################################################-----------------
+# ------------#################################################-----------------
+
+class Settings: #-----------------------------------------------------------------
+ """A container for all the export settings and objects.
+
+ This is like a collection of globally accessable persistant properties and functions.
+ """
+ # Optimization constants
+ MIN = 0
+ MID = 1
+ PRO = 2
+ MAX = 3
+
+ def __init__(self, keywords, drawTypes):
+ """initialize all the important settings used by the export functions.
+ """
+ self.obj_number = 1 #global object_number for progress_bar
+
+ self.var = dict(keywords) #a dictionary of (key_variable:Value) control parameter
+ self.drawTypes = dict(drawTypes) #a dictionary of (entity_type:True/False) = import on/off for this entity_type
+
+ self.var['colorFilter_on'] = False #deb:remi------------
+ self.acceptedColors = [0,2,3,4,5,6,7,8,9,
+ 10 ]
+
+ self.var['materialFilter_on'] = False #deb:remi------------
+ self.acceptedLayers = ['3',
+ '0'
+ ]
+
+ self.var['groupFilter_on'] = False #deb:remi------------
+ self.acceptedLayers = ['3',
+ '0'
+ ]
+
+ #self.var['objectFilter_on'] = 0 #deb:remi------------
+ self.acceptedBlocks = ['WALL_1871',
+ 'BOX02'
+ ]
+ self.unwantedBlocks = ['BOX05',
+ 'BOX04'
+ ]
+
+
+ def update(self, keywords, drawTypes):
+ """update all the important settings used by the draw functions.
+ mostly used after loading parameters from INI-file
+ """
+
+ for k, v in keywords.iteritems():
+ self.var[k] = v
+ #print 'deb:settings_update var %s= %s' %(k, self.var[k]) #--------------
+ for t, v in drawTypes.iteritems():
+ self.drawTypes[t] = v
+ #print 'deb:settings_update drawType %s= %s' %(t, self.drawTypes[t]) #--------------
+
+ self.drawTypes['arc'] = self.drawTypes['surface']
+ self.drawTypes['circle'] = self.drawTypes['surface']
+ self.drawTypes['ellipse'] = self.drawTypes['surface']
+ self.drawTypes['trace'] = self.drawTypes['solid']
+ self.drawTypes['insert'] = self.drawTypes['group']
+ #self.drawTypes['vport'] = self.drawTypes['view']
+
+ #print 'deb:self.drawTypes', self.drawTypes #---------------
+
+
+ def validate(self, drawing):
+ """Given the drawing, build dictionaries of Layers, Colors and Blocks.
+ """
+ global oblist
+ #adjust the distance parameter to globalScale
+ if self.var['g_scale'] != 1.0:
+ self.var['dist_min'] = self.var['dist_min'] / self.var['g_scale']
+ self.g_origin = Mathutils.Vector(self.var['g_originX'], self.var['g_originY'], self.var['g_originZ'])
+
+
+ def write(self, text, newline=True):
+ """Wraps the built-in print command in a optimization check.
+ """
+ if self.var['optimization'] <= self.MID:
+ if newline:
+ print text
+ else:
+ print text,
+
+
+ def redraw(self):
+ """Update Blender if optimization level is low enough.
+ """
+ if self.var['optimization'] <= self.MIN:
+ Blender.Redraw()
+
+
+ def progress(self, done, text):
+ """Wrapper for Blender.Window.DrawProgressBar.
+ """
+ if self.var['optimization'] <= self.PRO:
+ progressbar = done * self.obj_number
+ Window.DrawProgressBar(progressbar, text)
+ #print 'deb:drawer done, progressbar: ', done, progressbar #-----------------------
+
+
+
+# GUI STUFF -----#################################################-----------------
+from Blender.BGL import *
+
+EVENT_NONE = 1
+EVENT_START = 2
+EVENT_REDRAW = 3
+EVENT_LOAD_INI = 4
+EVENT_SAVE_INI = 5
+EVENT_RESET = 6
+EVENT_CHOOSE_INI = 7
+EVENT_CHOOSE_DXF = 8
+EVENT_HELP = 9
+EVENT_CAMERA = 10
+EVENT_LIGHT =11
+EVENT_DXF_DIR = 12
+EVENT_setCAMERA = 13
+# = 14
+EVENT_ORIGIN = 15
+EVENT_SCALE = 16
+EVENT_PRESET2D = 20
+EVENT_PRESET3D = 21
+EVENT_PRESETPLINE = 22
+EVENT_PRESETS = 23
+EVENT_EXIT = 100
+
+GUI_A = {} # GUI-buttons dictionary for parameter
+GUI_B = {} # GUI-buttons dictionary for drawingTypes
+
+# settings default, initialize ------------------------
+
+#-----------------------------------------------
+def prepareMenu(title,list):
+ menu = title
+ for i, item in enumerate(list):
+ menu += '|'+ item + ' %x' + str(i)
+ return menu
+
+#-----------------------------------------------
+mesh_as_list = ["3DFACEs","POLYFACE","POLYLINE","LINEs","POINTs"]
+mesh_as_menu = prepareMenu("export to: %t", mesh_as_list)
+
+curve_as_list = ["LINEs","POLYLINE","..LWPOLYLINE r14","..SPLINE r14","POINTs"]
+curve_as_menu = prepareMenu("export to: %t", curve_as_list)
+
+surface_as_list = ["..3DFACEs","..POLYFACE","..POINTs","..NURBS"]
+surface_as_menu = prepareMenu("export to: %t", surface_as_list)
+
+meta_as_list = ["..3DFACEs","..POLYFACE","..3DSOLID"]
+meta_as_menu = prepareMenu("export to: %t", meta_as_list)
+
+text_as_list = ["TEXT","..MTEXT","..ATTRIBUT"]
+text_as_menu = prepareMenu("export to: %t", text_as_list)
+
+empty_as_list = ["POINT","..INSERT","..XREF"]
+empty_as_menu = prepareMenu("export to: %t|", empty_as_list)
+
+group_as_list = ["..GROUP","..BLOCK","..ungroup"]
+group_as_menu = prepareMenu("export to: %t", group_as_list)
+
+parent_as_list = ["..BLOCK","..ungroup"]
+parent_as_menu = prepareMenu("export to: %t", parent_as_list)
+
+proxy_as_list = ["..BLOCK","..XREF","..ungroup","..POINT"]
+proxy_as_menu = prepareMenu("export to: %t", proxy_as_list)
+
+camera_as_list = ["..BLOCK","..A_CAMERA","..VPORT","..VIEW","POINT"]
+camera_as_menu = prepareMenu("export to: %t", camera_as_list)
+
+lamp_as_list = ["..BLOCK","..A_LAMP","POINT"]
+lamp_as_menu = prepareMenu("export to: %t", lamp_as_list)
+
+material_to_list= ["COLOR","LAYER","..LINESTYLE","..BLOCK","..XDATA","..INI-File"]
+material_to_menu = prepareMenu("export to: %t", material_to_list)
+
+ltype_map_list= ["object_rgb","material_rgb","..map_table"]
+ltype_map_menu = prepareMenu("export to: %t", ltype_map_list)
+
+
+
+layername_from_list = [LAYERNAME_DEF,"drawing_name","scene_name"]
+layername_from_menu = prepareMenu("defaultLAYER: %t", layername_from_list)
+
+layerltype_def_list = ["CONTINUOUS","DOT","DASHED","DASHDOT","BORDER","HIDDEN"]
+layerltype_def_menu = prepareMenu("LINETYPE set to: %t",layerltype_def_list)
+
+entitylayer_from_list = ["default_LAYER","obj.name","obj.layer","obj.material","obj.data.name","obj.data.material","..vertexgroup","..group","..map_table"]
+entitylayer_from_menu = prepareMenu("entityLAYER from: %t", entitylayer_from_list)
+#print 'deb: entitylayer_from_menu=', entitylayer_from_menu #--------------
+
+entitycolor_from_list = ["default_COLOR","BYLAYER","BYBLOCK","obj.layer","obj.color","obj.material","obj.data.material","..map_table"]
+entitycolor_from_menu = prepareMenu("entityCOLOR set to: %t",entitycolor_from_list)
+
+entityltype_from_list = ["default_LTYPE","BYLAYER","BYBLOCK","CONTINUOUS","DOT","DASHED","DASHDOT","BORDER","HIDDEN"]
+entityltype_from_menu = prepareMenu("entityCOLOR set to: %t",entityltype_from_list)
+
+#dxf-LINE,ARC,CIRCLE,ELLIPSE
+
+g_scale_list = ''.join((
+ 'scale factor: %t',
+ '|user def. %x12',
+ '|yard to m %x8',
+ '|feet to m %x7',
+ '|inch to m %x6',
+ '| x 100000 %x5',
+ '| x 10000 %x4',
+ '| x 1000 %x3',
+ '| x 100 %x2',
+ '| x 10 %x1',
+ '| x 1 %x0',
+ '| x 0.1 %x-1',
+ '| x 0.01 %x-2',
+ '| x 0.001 %x-3',
+ '| x 0.0001 %x-4',
+ '| x 0.00001 %x-5'))
+
+#print 'deb: g_scale_list', g_scale_list #-----------
+
+dxfFileName = Draw.Create("")
+iniFileName = Draw.Create(INIFILE_DEFAULT_NAME + INIFILE_EXTENSION)
+user_preset = 0
+config_UI = Draw.Create(0) #switch_on/off extended config_UI
+g_scale_as = Draw.Create(int(log10(G_SCALE)))
+
+
+keywords_org = {
+ 'optimization': 2,
+ 'dummy_on' : 0,
+
+ 'xref_on' : 1,
+ 'block_nn': 0,
+
+ 'paper_space_on': 0,
+ 'layFrozen_on': 0,
+ 'objectFilter_on': 0,
+ 'materialFilter_on': 0,
+ 'colorFilter_on': 0,
+ 'groupFilter_on': 0,
+
+ 'only_selected_on': ONLYSELECTED,
+ 'only_visible_on': ONLYVISIBLE,
+ 'projection_on' : PROJECTION,
+ 'hidden_lines_on': HIDDEN_LINES,
+ 'shadows_on' : SHADOWS,
+ 'light_on' : 1,
+ 'outputDWG_on' : OUTPUT_DWG,
+ 'to_polyline_on': POLYLINES,
+ 'to_polyface_on': POLYFACES,
+ 'apply_modifiers_on': APPLY_MODIFIERS,
+ 'include_duplis_on': INCLUDE_DUPLIS,
+ 'camera_selected': CAMERA,
+
+ 'g_originX' : G_ORIGIN[0],
+ 'g_originY' : G_ORIGIN[1],
+ 'g_originZ' : G_ORIGIN[2],
+ 'g_origin_on': 0,
+ 'g_scale' : float(G_SCALE),
+# 'g_scale_as': int(log10(G_SCALE)), # 0,
+ 'g_scale_on': 0,
+ 'Z_force_on': 0,
+ 'Z_elev': float(ELEVATION),
+
+
+ 'prefix_def' : PREFIX,
+ 'layername_def' : LAYERNAME_DEF,
+ 'layercolor_def': LAYERCOLOR_DEF,
+ 'layerltype_def': LAYERLTYPE_DEF,
+ 'entitylayer_from': 5,
+ 'entitycolor_from': 1,
+ 'entityltype_from' : 1,
+
+ 'material_on': 1,
+ 'material_to': 2,
+ 'fill_on' : 1,
+
+ 'mesh_as' : 1,
+ 'curve_as' : 1,
+ 'surface_as' : 1,
+ 'meta_as' : 1,
+ 'text_as' : 0,
+ 'empty_as' : 0,
+ 'group_as' : 0,
+ 'parent_as' : 0,
+ 'proxy_as' : 0,
+ 'camera_as': 4,
+ 'lamp_as' : 2,
+ }
+
+drawTypes_org = {
+ 'bmesh' : 1,
+ 'bcurve': 1,
+ 'surface': 0,
+ 'bmeta' : 0,
+ 'text' : 1,
+ 'empty' : 1,
+ 'group' : 1,
+ 'parent': 1,
+ 'proxy' : 0,
+ 'camera': 0,
+ 'lamp' : 0,
+
+# 'view' : 0,
+ }
+
+# creating of GUI-buttons
+# GUI_A - GUI-buttons dictionary for parameter
+# GUI_B - GUI-buttons dictionary for drawingTypes
+for k, v in keywords_org.iteritems():
+ GUI_A[k] = Draw.Create(v)
+for k, v in drawTypes_org.iteritems():
+ GUI_B[k] = Draw.Create(v)
+#print 'deb:init GUI_A: ', GUI_A #---------------
+#print 'deb:init GUI_B: ', GUI_B #---------------
+
+model_space_on = Draw.Create(1)
+
+# initialize settings-object controls how dxf entities are drawn
+settings = Settings(keywords_org, drawTypes_org)
+
+
+def update_RegistryKey(key, item): #
+ """updates key in Blender.Registry
+ """
+ cache = True # data is also saved to a file
+ rdict = Registry.GetKey('DXF_Exporter', cache)
+ if not rdict: rdict = {}
+ if item:
+ rdict[key] = item
+ Registry.SetKey('DXF_Exporter', rdict, cache)
+ #print 'deb:update_RegistryKey rdict', rdict #---------------
+
+
+def check_RegistryKey(key):
+ """ check if the key is already there (saved on a previous execution of this script)
+ """
+ cache = True # data is also saved to a file
+ rdict = Registry.GetKey('DXF_Exporter', cache)
+ #print 'deb:check_RegistryKey rdict:', rdict #----------------
+ if rdict: # if found, get the values saved there
+ try:
+ item = rdict[key]
+ return item
+ except:
+ #update_RegistryKey() # if data isn't valid rewrite it
+ pass
+
+def saveConfig(): #--todo-----------------------------------------------
+ """Save settings/config/materials from GUI to INI-file.
+
+ Write all config data to INI-file.
+ """
+ global iniFileName
+
+ iniFile = iniFileName.val
+ #print 'deb:saveConfig inifFile: ', inifFile #----------------------
+ if iniFile.lower().endswith(INIFILE_EXTENSION):
+
+ #--todo-- sort key.list for output
+ #key_list = GUI_A.keys().val
+ #key_list.sort()
+ #for key in key_list:
+ # l_name, l_data = key, GUI_A[key].val
+ # list_A
+
+ output_str = '[%s,%s]' %(GUI_A, GUI_B)
+ if output_str =='None':
+ Draw.PupMenu('DXF-Exporter: INI-file: Alert!%t|no config-data present to save!')
+ else:
+ if Blender.sys.exists(iniFile):
+ f = file(iniFile, 'r')
+ header_str = f.readline()
+ f.close()
+ if header_str.startswith(INIFILE_HEADER[0:13]):
+ if Draw.PupMenu(' OK ? %t|SAVE OVER: ' + '\'%s\'' %iniFile) == 1:
+ save_ok = True
+ else: save_ok = False
+ elif Draw.PupMenu(' OK ? %t|SAVE OVER: ' + '\'%s\'' %iniFile +
+ '|Alert: this file has no valid ImportDXF-header| ! it may belong to another aplication !') == 1:
+ save_ok = True
+ else: save_ok = False
+ else: save_ok = True
+
+ if save_ok:
+ # replace: ',' -> ',\n'
+ # replace: '{' -> '\n{\n'
+ # replace: '}' -> '\n}\n'
+ output_str = ',\n'.join(output_str.split(','))
+ output_str = '\n}'.join(output_str.split('}'))
+ output_str = '{\n'.join(output_str.split('{'))
+ try:
+ f = file(iniFile, 'w')
+ f.write(INIFILE_HEADER + '\n# this is a comment line\n')
+ f.write(output_str)
+ f.close()
+ #Draw.PupMenu('DXF-Exporter: INI-file: Done!%t|config-data saved in ' + '\'%s\'' %iniFile)
+ except:
+ Draw.PupMenu('DXF-Exporter: INI-file: Error!%t|failure by writing to ' + '\'%s\'|no config-data saved!' %iniFile)
+
+ else:
+ Draw.PupMenu('DXF-Exporter: INI-file: Alert!%t|no valid name/extension for INI-file selected!')
+ print "DXF-Exporter: Alert!: no valid INI-file selected."
+ if not iniFile:
+ if dxfFileName.val.lower().endswith('.dxf'):
+ iniFileName.val = dxfFileName.val[0:-4] + INIFILE_EXTENSION
+
+
+def loadConfig(): #remi--todo-----------------------------------------------
+ """Load settings/config/materials from INI-file.
+
+ TODO: Read material-assignements from config-file.
+ """
+ #20070724 buggy Window.FileSelector(loadConfigFile, 'Load config data from INI-file', inifilename)
+ global iniFileName, GUI_A, GUI_B
+
+ iniFile = iniFileName.val
+ update_RegistryKey('iniFileName', iniFile)
+ #print 'deb:loadConfig iniFile: ', iniFile #----------------------
+ if iniFile.lower().endswith(INIFILE_EXTENSION) and Blender.sys.exists(iniFile):
+ f = file(iniFile, 'r')
+ header_str = f.readline()
+ if header_str.startswith(INIFILE_HEADER):
+ data_str = f.read()
+ f.close()
+ #print 'deb:loadConfig data_str from %s: \n' %iniFile , data_str #-----------------
+ data = eval(data_str)
+ for k, v in data[0].iteritems():
+ try: GUI_A[k].val = v
+ except: GUI_A[k] = Draw.Create(v)
+ for k, v in data[1].iteritems():
+ try: GUI_B[k].val = v
+ except: GUI_B[k] = Draw.Create(v)
+ else:
+ f.close()
+ Draw.PupMenu('DXF-Exporter: INI-file: Alert!%t|no valid header in INI-file: ' + '\'%s\'' %iniFile)
+ else:
+ Draw.PupMenu('DXF-Exporter: INI-file: Alert!%t|no valid INI-file selected!')
+ print "DXF-Exporter: Alert!: no valid INI-file selected."
+ if not iniFileName:
+ if dxfFileName.val.lower().endswith('.dxf'):
+ iniFileName.val = dxfFileName.val[0:-4] + INIFILE_EXTENSION
+
+
+
+def updateConfig(keywords, drawTypes): #-----------------------------------------------
+ """updates GUI_settings with given dictionaries
+
+ """
+ global GUI_A, GUI_B
+ #print 'deb:lresetDefaultConfig keywords_org: \n', keywords_org #---------
+ for k, v in keywords.iteritems():
+ GUI_A[k].val = v
+ for k, v in drawTypes.iteritems():
+ GUI_B[k].val = v
+
+def resetDefaultConfig(): #-----------------------------------------------
+ """Resets settings/config/materials to defaults.
+
+ """
+ #print 'deb:lresetDefaultConfig keywords_org: \n', keywords_org #---------
+ updateConfig(keywords_org, drawTypes_org)
+
+
+def presetConfig_polyline(activate): #-----------------------------------------------
+ """Sets settings/config for polygon representation: POLYLINE(FACE) or LINEs/3DFACEs.
+
+ """
+ global GUI_A
+ if activate:
+ GUI_A['to_polyline_on'].val = 1
+ GUI_A['mesh_as'].val = 1
+ GUI_A['curve_as'].val = 1
+ else:
+ GUI_A['to_polyline_on'].val = 0
+ GUI_A['mesh_as'].val = 0
+ GUI_A['curve_as'].val = 0
+
+def resetDefaultConfig_2D(): #-----------------------------------------------
+ """Sets settings/config/materials to defaults 2D.
+
+ """
+ keywords2d = {
+ 'projection_on' : 1,
+ 'fill_on' : 1,
+ 'text_as' : 0,
+ 'group_as' : 0,
+ }
+
+ drawTypes2d = {
+ 'bmesh' : 1,
+ 'bcurve': 1,
+ 'surface':0,
+ 'bmeta' : 0,
+ 'text' : 1,
+ 'empty' : 1,
+ 'group' : 1,
+ 'parent' : 1,
+ #'proxy' : 0,
+ #'camera': 0,
+ #'lamp' : 0,
+
+ }
+ presetConfig_polyline(1)
+ updateConfig(keywords2d, drawTypes2d)
+
+def resetDefaultConfig_3D(): #-----------------------------------------------
+ """Sets settings/config/materials to defaults 3D.
+
+ """
+ keywords3d = {
+ 'projection_on' : 0,
+ 'fill_on' : 0,
+ 'text_as' : 0,
+ 'group_as' : 0,
+ }
+
+ drawTypes3d = {
+ 'bmesh' : 1,
+ 'bcurve': 1,
+ 'surface':0,
+ 'bmeta' : 0,
+ 'text' : 0,
+ 'empty' : 1,
+ 'group' : 1,
+ 'parent' : 1,
+ #'proxy' : 0,
+ #'camera': 1,
+ #'lamp' : 1,
+ }
+ presetConfig_polyline(1)
+ updateConfig(keywords3d, drawTypes3d)
+
+
+def inputGlobalScale():
+ """Pop-up UI-Block for global scale factor
+ """
+ global GUI_A
+ #print 'deb:inputGlobalScale ##########' #------------
+ x_scale = Draw.Create(GUI_A['g_scale'].val)
+ block = []
+ #block.append("global translation vector:")
+ block.append(("", x_scale, 0.0, 10000000.0))
+
+ retval = Draw.PupBlock("set global scale factor:", block)
+
+ GUI_A['g_scale'].val = float(x_scale.val)
+
+
+def inputOriginVector():
+ """Pop-up UI-Block for global translation vector
+ """
+ global GUI_A
+ #print 'deb:inputOriginVector ##########' #------------
+ x_origin = Draw.Create(GUI_A['g_originX'].val)
+ y_origin = Draw.Create(GUI_A['g_originY'].val)
+ z_origin = Draw.Create(GUI_A['g_originZ'].val)
+ block = []
+ #block.append("global translation vector:")
+ block.append(("X: ", x_origin, -100000000.0, 100000000.0))
+ block.append(("Y: ", y_origin, -100000000.0, 100000000.0))
+ block.append(("Z: ", z_origin, -100000000.0, 100000000.0))
+
+ retval = Draw.PupBlock("set global translation vector:", block)
+
+ GUI_A['g_originX'].val = x_origin.val
+ GUI_A['g_originY'].val = y_origin.val
+ GUI_A['g_originZ'].val = z_origin.val
+
+
+def update_globals(): #-----------------------------------------------------------------
+ """ update globals if GUI_A changed
+ """
+ global ONLYSELECTED,ONLYVISIBLE, DEBUG,\
+ PROJECTION, HIDDEN_LINES, CAMERA, \
+ G_SCALE, G_ORIGIN,\
+ PREFIX, LAYERNAME_DEF, LAYERCOLOR_DEF, LAYERLTYPE_DEF,\
+ APPLY_MODIFIERS, INCLUDE_DUPLIS,\
+ OUTPUT_DWG
+ #global POLYLINES
+
+ ONLYSELECTED = GUI_A['only_selected_on'].val
+ ONLYVISIBLE = GUI_A['only_visible_on'].val
+ """
+ POLYLINES = GUI_A['to_polyline_on'].val
+ if GUI_A['curve_as'].val==1: POLYLINES=1
+ else: POLYLINES=0
+ """
+
+ if GUI_A['optimization'].val==0: DEBUG = 1
+ else: DEBUG = 0
+ PROJECTION = GUI_A['projection_on'].val
+ HIDDEN_LINES = GUI_A['hidden_lines_on'].val
+ CAMERA = GUI_A['camera_selected'].val
+ G_SCALE = GUI_A['g_scale'].val
+ if GUI_A['g_origin_on'].val:
+ G_ORIGIN[0] = GUI_A['g_originX'].val
+ G_ORIGIN[1] = GUI_A['g_originY'].val
+ G_ORIGIN[2] = GUI_A['g_originZ'].val
+ if GUI_A['g_scale_on'].val:
+ G_ORIGIN[0] *= G_SCALE
+ G_ORIGIN[1] *= G_SCALE
+ G_ORIGIN[2] *= G_SCALE
+
+ PREFIX = GUI_A['prefix_def'].val
+ LAYERNAME_DEF = GUI_A['layername_def'].val
+ LAYERCOLOR_DEF = GUI_A['layercolor_def'].val
+ LAYERLTYPE_DEF = layerltype_def_list[GUI_A['layerltype_def'].val]
+
+ APPLY_MODIFIERS = GUI_A['apply_modifiers_on'].val
+ INCLUDE_DUPLIS = GUI_A['include_duplis_on'].val
+ OUTPUT_DWG = GUI_A['outputDWG_on'].val
+ #print 'deb: GUI HIDDEN_LINES=', HIDDEN_LINES #---------
+ #print 'deb: GUI GUI_A: ', GUI_A['hidden_lines_on'].val #---------------
+ #print 'deb: GUI GUI_B: ', GUI_B #---------------
+
+
+def draw_UI(): #-----------------------------------------------------------------
+ """ Draw startUI and setup Settings.
+ """
+ global GUI_A, GUI_B #__version__
+ global user_preset, iniFileName, dxfFileName, config_UI, g_scale_as
+ global model_space_on
+ global SCROLL
+
+ global mPAN_X, menu_orgX, mPAN_Xmax
+ global mPAN_Y, menu_orgY, mPAN_Ymax
+ global menu__Area, headerArea, screenArea, scrollArea
+
+ size=Buffer(GL_FLOAT, 4)
+ glGetFloatv(GL_SCISSOR_BOX, size) #window X,Y,sizeX,sizeY
+ size= size.list
+ #print '-------------size:', size #--------------------------
+ for s in [0,1,2,3]: size[s]=int(size[s])
+ window_Area = [0,0,size[2],size[3]-2]
+ scrollXArea = [0,0,window_Area[2],15]
+ scrollYArea = [0,0,15,window_Area[3]]
+
+ menu_orgX = -mPAN_X
+ #menu_orgX = 0 #scrollW
+ #if menu_pan: menu_orgX -= mPAN_X
+ if menu_orgX < -mPAN_Xmax: menu_orgX, mPAN_X = -mPAN_Xmax,mPAN_Xmax
+ if menu_orgX > 0: menu_orgX, mPAN_X = 0,0
+
+ menu_orgY = -mPAN_Y
+ #if menu_pan: menu_orgY -= mPAN_Y
+ if menu_orgY < -mPAN_Ymax: menu_orgY, mPAN_Y = -mPAN_Ymax,mPAN_Ymax
+ if menu_orgY > 0: menu_orgY, mPAN_Y = 0,0
+
+
+ menu_margin = 10
+ butt_margin = 10
+ common_column = int((window_Area[2] - (3 * butt_margin) - (2 * menu_margin)-30) / 4.0)
+ common_column = 70
+ # This is for easy layout changes
+ but_0c = common_column #button 1.column width
+ but_1c = common_column #button 1.column width
+ but_2c = common_column #button 2.column
+ but_3c = common_column #button 3.column
+ menu_w = (3 * butt_margin) + but_0c + but_1c + but_2c + but_3c #menu width
+
+ simple_menu_h = 240
+ extend_menu_h = 345
+ menu_h = simple_menu_h # y is menu upper.y
+ if config_UI.val:
+ menu_h += extend_menu_h
+
+ mPAN_Xmax = menu_w-window_Area[2]+50
+ mPAN_Ymax = menu_h-window_Area[3]+30
+
+ y = menu_h
+ x = 0 #menu left.x
+ x +=menu_orgX+20
+ y +=menu_orgY+20
+
+
+ but0c = x + menu_margin #buttons 0.column position.x
+ but1c = but0c + but_0c + butt_margin
+ but2c = but1c + but_1c + butt_margin
+ but3c = but2c + but_2c + butt_margin
+ but4c = but3c + but_3c
+
+ # Here starts menu -----------------------------------------------------
+ #glClear(GL_COLOR_BUFFER_BIT)
+ #glRasterPos2d(8, 125)
+
+
+ ui_box(x, y, x+menu_w+menu_margin*2, y-menu_h)
+ y -= 20
+ Draw.Label("DXF(r12)-Exporter v" + __version__, but0c, y, menu_w, 20)
+
+ if config_UI.val:
+ b0, b0_ = but0c, but_0c-20 + butt_margin
+ b1, b1_ = but1c-20, but_1c+20
+ y_top = y
+
+ y -= 10
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['bmesh'] = Draw.Toggle('Mesh', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['bmesh'].val, "Export Mesh-Objects on/off")
+ if GUI_B['bmesh'].val:
+ GUI_A['mesh_as'] = Draw.Menu(mesh_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['mesh_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['bcurve'] = Draw.Toggle('Curve', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['bcurve'].val, "Export Curve-Objects on/off")
+ if GUI_B['bcurve'].val:
+ GUI_A['curve_as'] = Draw.Menu(curve_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['curve_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['surface'] = Draw.Toggle('..Surface', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['surface'].val, "(*todo) Export Surface-Objects on/off")
+ if GUI_B['surface'].val:
+ GUI_A['surface_as'] = Draw.Menu(surface_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['surface_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['bmeta'] = Draw.Toggle('..Meta', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['bmeta'].val, "(*todo) Export Meta-Objects on/off")
+ if GUI_B['bmeta'].val:
+ GUI_A['meta_as'] = Draw.Menu(meta_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['meta_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['text'] = Draw.Toggle('Text', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['text'].val, "Export Text-Objects on/off")
+ if GUI_B['text'].val:
+ GUI_A['text_as'] = Draw.Menu(text_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['text_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['empty'] = Draw.Toggle('Empty', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['empty'].val, "Export Empty-Objects on/off")
+ if GUI_B['empty'].val:
+ GUI_A['empty_as'] = Draw.Menu(empty_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['empty_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y_down = y
+ # -----------------------------------------------
+
+ y = y_top
+ b0, b0_ = but2c, but_2c-20 + butt_margin
+ b1, b1_ = but3c-20, but_3c+20
+
+ y -= 10
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['group'] = Draw.Toggle('..Group', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['group'].val, "(*todo) Export Group-Relationships on/off")
+ if GUI_B['group'].val:
+ GUI_A['group_as'] = Draw.Menu(group_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['group_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['parent'] = Draw.Toggle('..Parent', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['parent'].val, "(*todo) Export Parent-Relationships on/off")
+ if GUI_B['parent'].val:
+ GUI_A['parent_as'] = Draw.Menu(parent_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['parent_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['proxy'] = Draw.Toggle('..Proxy', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['proxy'].val, "(*todo) Export Proxy-Objects on/off")
+ if GUI_B['proxy'].val:
+ GUI_A['proxy_as'] = Draw.Menu(proxy_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['proxy_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['camera'] = Draw.Toggle('Camera', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['camera'].val, "(*wip) Export Camera-Objects on/off")
+ if GUI_B['camera'].val:
+ GUI_A['camera_as'] = Draw.Menu(camera_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['camera_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_B['lamp'] = Draw.Toggle('Lamp', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['lamp'].val, "(*wip) Export Lamp-Objects on/off")
+ if GUI_B['lamp'].val:
+ GUI_A['lamp_as'] = Draw.Menu(lamp_as_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['lamp_as'].val, "Select target DXF-object")
+ Draw.EndAlign()
+
+
+ if y < y_down: y_down = y
+ # -----end supported objects--------------------------------------
+
+ y_top = y_down
+ y = y_top
+ y -= 10
+ y -= 20
+ but_ = menu_w / 6
+ b0 = but0c + (menu_w - but_*6)/2
+ Draw.BeginAlign()
+ #GUI_A['dummy_on'] = Draw.Toggle('-', EVENT_NONE, b0+but_*0, y, but_, 20, GUI_A['dummy_on'].val, "placeholder only on/off")
+ GUI_A['paper_space_on'] = Draw.Toggle('Paper', EVENT_NONE, b0+but_*0, y, but_, 20, GUI_A['paper_space_on'].val, "Export to Paper-Space, otherwise to Model-Space on/off")
+ GUI_A['layFrozen_on'] = Draw.Toggle ('..frozen', EVENT_NONE, b0+but_*1, y, but_, 20, GUI_A['layFrozen_on'].val, "(*todo) Support LAYER.frozen status on/off")
+ GUI_A['materialFilter_on'] = Draw.Toggle('..material', EVENT_NONE, b0+but_*2, y, but_, 20, GUI_A['materialFilter_on'].val, "(*todo) Material filtering on/off")
+ GUI_A['colorFilter_on'] = Draw.Toggle('..color', EVENT_NONE, b0+but_*3, y, but_, 20, GUI_A['colorFilter_on'].val, "(*todo) Color filtering on/off")
+ GUI_A['groupFilter_on'] = Draw.Toggle('..group', EVENT_NONE, b0+but_*4, y, but_, 20, GUI_A['groupFilter_on'].val, "(*todo) Group filtering on/off")
+ GUI_A['objectFilter_on'] = Draw.Toggle('..object', EVENT_NONE, b0+but_*5, y, but_, 20, GUI_A['objectFilter_on'].val, "(*todo) Object filtering on/off")
+ Draw.EndAlign()
+
+ # -----end filters--------------------------------------
+
+ b0, b0_ = but0c, but_0c + butt_margin
+ b1, b1_ = but1c, but_1c
+
+ y -= 10
+ y -= 20
+ Draw.BeginAlign()
+ GUI_A['g_origin_on'] = Draw.Toggle('Location', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['g_origin_on'].val, "Global relocate all objects on/off")
+ if GUI_A['g_origin_on'].val:
+ tmp = Draw.PushButton('=', EVENT_ORIGIN, b1, y, 20, 20, "Edit relocation-vector (x,y,z in DXF units)")
+ origin_str = '(%.4f, %.4f, %.4f)' % (
+ GUI_A['g_originX'].val,
+ GUI_A['g_originY'].val,
+ GUI_A['g_originZ'].val
+ )
+ tmp = Draw.Label(origin_str, b1+20, y, 300, 20)
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_A['g_scale_on'] = Draw.Toggle('Scale', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['g_scale_on'].val, "Global scale all objects on/off")
+ if GUI_A['g_scale_on'].val:
+ g_scale_as = Draw.Menu(g_scale_list, EVENT_SCALE, b1, y, 45, 20, g_scale_as.val, "Factor for scaling the DXFdata")
+ if g_scale_as.val == 12:
+ pass
+ else:
+ if g_scale_as.val == 6: #scale inches to meters
+ GUI_A['g_scale'].val = 0.0254000
+ elif g_scale_as.val == 7: #scale feets to meters
+ GUI_A['g_scale'].val = 0.3048000
+ elif g_scale_as.val == 8: #scale yards to meters
+ GUI_A['g_scale'].val = 0.9144000
+ else:
+ GUI_A['g_scale'].val = 10.0 ** int(g_scale_as.val)
+ scale_float = GUI_A['g_scale'].val
+ if scale_float < 0.000001 or scale_float > 1000000:
+ scale_str = ' = %s' % GUI_A['g_scale'].val
+ else:
+ scale_str = ' = %.6f' % GUI_A['g_scale'].val
+ Draw.Label(scale_str, b1+45, y, 200, 20)
+ Draw.EndAlign()
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_A['Z_force_on'] = Draw.Toggle('Elevation', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['Z_force_on'].val, "Overwrite Z-coordinates (flatten geometry) on/off")
+ if GUI_A['Z_force_on'].val:
+ GUI_A['Z_elev'] = Draw.Number('', EVENT_NONE, b1, y, b1_, 20, GUI_A['Z_elev'].val, -1000, 1000, "Set value for default Z-coordinate (in DXF units)")
+ Draw.EndAlign()
+
+ """
+ y -= 30
+ Draw.BeginAlign()
+ GUI_A['material_on'] = Draw.Toggle('.material', EVENT_REDRAW, b0, y, b0_-20, 20, GUI_A['material_on'].val, "Support for material assignment on/off")
+ if GUI_A['material_on'].val:
+ GUI_A['material_to'] = Draw.Menu(material_to_menu, EVENT_NONE, b1-20, y, b1_+20, 20, GUI_A['material_to'].val, "Material assigned to?")
+ Draw.EndAlign()
+ """
+
+ #b0, b0_ = but0c, but_0c + butt_margin
+ b0, b0_ = but0c, 50
+ b1, b1_ = b0+b0_, but_0c-b0_+ but_1c + butt_margin
+ b2, b2_ = but2c, but_2c
+ b3, b3_ = but3c, but_3c
+
+ y -= 30
+ Draw.Label('Output:', b0, y, b0_, 20)
+ Draw.Label('LAYER:', b1, y, b1_, 20)
+ Draw.Label('COLOR:', b2, y, b2_, 20)
+ Draw.Label('LINETYPE:', b3, y, b3_, 20)
+ #Draw.Label('LINESIZE:', b4, y, b4_, 20)
+
+ y -= 20
+ Draw.BeginAlign()
+ GUI_A['prefix_def'] = Draw.String('', EVENT_NONE, b0, y, b0_, 20, GUI_A['prefix_def'].val, 10, "Type Prefix for LAYERs")
+ GUI_A['layername_def'] = Draw.String('', EVENT_NONE, b1, y, b1_, 20, GUI_A['layername_def'].val, 10, "Type default LAYER name")
+ GUI_A['layercolor_def'] = Draw.Number('', EVENT_NONE, b2, y, b2_, 20, GUI_A['layercolor_def'].val, 1, 255, "Set default COLOR. (0=BYBLOCK,256=BYLAYER)")
+ GUI_A['layerltype_def'] = Draw.Menu(layerltype_def_menu, EVENT_NONE, b3, y, b3_, 20, GUI_A['layerltype_def'].val, "Set default LINETYPE")
+ Draw.EndAlign()
+
+ y -= 25
+ Draw.Label('Style:', b0, y, b0_, 20)
+ Draw.BeginAlign()
+ GUI_A['entitylayer_from'] = Draw.Menu(entitylayer_from_menu, EVENT_NONE, b1, y, b1_, 20, GUI_A['entitylayer_from'].val, "entity LAYER assigned to?")
+ GUI_A['entitycolor_from'] = Draw.Menu(entitycolor_from_menu, EVENT_NONE, b2, y, b2_, 20, GUI_A['entitycolor_from'].val, "entity COLOR assigned to?")
+ GUI_A['entityltype_from'] = Draw.Menu(entityltype_from_menu, EVENT_NONE, b3, y, b3_, 20, GUI_A['entityltype_from'].val, "Set entity LINETYPE")
+ Draw.EndAlign()
+
+ y -= 10
+
+ y_down = y
+ # -----end material,translate,scale------------------------------------------
+
+
+ #--------------------------------------
+ y_top = y_down
+ y = y_top
+
+ y -= 30
+ Draw.BeginAlign()
+ Draw.PushButton('INI file >', EVENT_CHOOSE_INI, but0c, y, but_0c, 20, 'Select INI-file with file selector')
+ iniFileName = Draw.String(' :', EVENT_NONE, but1c, y, menu_w-but_1c-60, 20, iniFileName.val, FILENAME_MAX, "Write here the name of the INI-file")
+ but = but4c-60
+ Draw.PushButton('#', EVENT_PRESETS, but, y, 20, 20, "Toggle Preset-INI-files")
+ Draw.PushButton('L', EVENT_LOAD_INI, but+20, y, 20, 20, 'Loads configuration from selected ini-file: %s' % iniFileName.val)
+ Draw.PushButton('S', EVENT_SAVE_INI, but+40, y, 20, 20, 'Saves configuration to selected ini-file: %s' % iniFileName.val)
+ Draw.EndAlign()
+
+ bm = butt_margin/2
+
+ y -= 10
+ y -= 20
+ Draw.BeginAlign()
+ Draw.PushButton('DXFfile >', EVENT_CHOOSE_DXF, but0c, y, but_0c, 20, 'Select DXF-file with file selector')
+ dxfFileName = Draw.String(' :', EVENT_NONE, but1c, y, menu_w-but_0c-menu_margin, 20, dxfFileName.val, FILENAME_MAX, "Type path/name of output DXF-file")
+ Draw.EndAlign()
+
+ y -= 30
+ config_UI = Draw.Toggle('CONFIG', EVENT_REDRAW, but0c, y, but_0c+bm, 20, config_UI.val, 'Advanced configuration on/off' )
+ Draw.BeginAlign()
+ but, but_ = but1c, but_1c+bm
+ but_ /= 3
+ Draw.PushButton('X', EVENT_RESET, but, y, 15, 20, "Reset configuration to defaults")
+ Draw.PushButton('2D', EVENT_PRESET2D, but+but_, y, but_, 20, 'Set to standard configuration for 2D export')
+ Draw.PushButton('3D', EVENT_PRESET3D, but+(but_*2), y, but_, 20, 'Set to standard configuration for 3D import')
+ Draw.EndAlign()
+
+
+ y -= 30
+ b0, b0_ = but0c, but_0c + butt_margin +but_1c
+ GUI_A['only_selected_on'] = Draw.Toggle('Export Selection', EVENT_NONE, b0, y, b0_, 20, GUI_A['only_selected_on'].val, "Export only selected geometry on/off")
+ b0, b0_ = but2c, but_2c + butt_margin + but_3c
+ Draw.BeginAlign()
+ GUI_A['projection_on'] = Draw.Toggle('2d Projection', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['projection_on'].val, "Export a 2d Projection according 3d-View or Camera-View on/off")
+ if GUI_A['projection_on'].val:
+ GUI_A['camera_selected'] = Draw.Menu(MenuCAMERA, EVENT_CAMERA, b0, y-20, b0_-20, 20, GUI_A['camera_selected'].val, 'Choose the camera to be rendered')
+ Draw.PushButton('>', EVENT_setCAMERA, b0+b0_-20, y-20, 20, 20, 'switch to selected Camera - make it active')
+ GUI_A['hidden_lines_on'] = Draw.Toggle('Remove backFaces', EVENT_NONE, b0, y-40, b0_, 20, GUI_A['hidden_lines_on'].val, "Filter out backFaces on/off")
+ #GUI_A['shadows_on'] = Draw.Toggle('..Shadows', EVENT_REDRAW, b0, y-60, but_2c, 20, GUI_A['shadows_on'].val, "(*todo) Shadow tracing on/off")
+ #GUI_A['light_on'] = Draw.Menu(MenuLIGHT, EVENT_LIGHT, but3c, y-60, but_3c, 20, GUI_A['light_on'].val, '(*todo) Choose the light source(sun) to be rendered')
+ Draw.EndAlign()
+
+ y -= 20
+ b0, b0_ = but0c, but_0c + butt_margin +but_1c
+ GUI_A['only_visible_on'] = Draw.Toggle('Visible only', EVENT_PRESETPLINE, b0, y, b0_, 20, GUI_A['only_visible_on'].val, "Export only from visible layers on/off")
+ #b0, b0_ = but2c, but_2c + butt_margin + but_3c
+
+ y -= 20
+ b0, b0_ = but0c, but_0c + butt_margin +but_1c
+ GUI_A['to_polyline_on'] = Draw.Toggle('POLYLINE-Mode', EVENT_PRESETPLINE, b0, y, b0_, 20, GUI_A['to_polyline_on'].val, "Export to POLYLINE/POLYFACEs, otherwise to LINEs/3DFACEs on/off")
+ #b0, b0_ = but2c, but_2c + butt_margin + but_3c
+
+ y -= 20
+ b0, b0_ = but0c, but_0c + butt_margin +but_1c
+ GUI_A['apply_modifiers_on'] = Draw.Toggle('Apply Modifiers', EVENT_NONE, b0, y, b0_, 20, GUI_A['apply_modifiers_on'].val, "Apply modifier stack to mesh objects before export on/off")
+ #b0, b0_ = but2c, but_2c + butt_margin + but_3c
+
+ y -= 20
+ b0, b0_ = but0c, but_0c + butt_margin +but_1c
+ GUI_A['include_duplis_on'] = Draw.Toggle('Include Duplis', EVENT_NONE, b0, y, b0_, 20, GUI_A['include_duplis_on'].val, "Export Duplicates (dupliverts, dupliframes, dupligroups) on/off")
+ #b0, b0_ = but2c, but_2c + butt_margin + but_3c
+
+
+
+ y -= 30
+ Draw.PushButton('EXIT', EVENT_EXIT, but0c, y, but_0c+bm, 20, '' )
+ Draw.PushButton('HELP', EVENT_HELP, but1c, y, but_1c+bm, 20, 'goes to online-Manual on wiki.blender.org')
+ GUI_A['optimization'] = Draw.Number('', EVENT_NONE, but2c, y, 40, 20, GUI_A['optimization'].val, 0, 3, "Optimization Level: 0=Debug/Draw-in, 1=Verbose, 2=ProgressBar, 3=SilentMode")
+ GUI_A['outputDWG_on'] = Draw.Toggle('DWG*', EVENT_NONE, but2c, y+20, 40, 20, GUI_A['outputDWG_on'].val, "converts DXF to DWG (needs external converter) on/off")
+
+ Draw.BeginAlign()
+ Draw.PushButton('START EXPORT', EVENT_START, but2c+40, y, but_2c-40+but_3c+butt_margin, 40, 'Start the export process. For Cancel go to console and hit Ctrl-C')
+ Draw.EndAlign()
+
+ y -= 20
+ #Draw.BeginAlign()
+ #Draw.Label(' ', but0c-menu_margin, y, menu_margin, 20)
+ #Draw.Label(LAB, but0c, y, menu_w, 20)
+ Draw.Label(LAB, 30, y, menu_w, 20)
+ #Draw.Label(' ', but0c+menu_w, y, menu_margin, 20)
+ #Draw.EndAlign()
+
+ ui_scrollbarX(menu_orgX, menu_w+50, scrollXArea, c_fg, c_bg)
+ ui_scrollbarY(menu_orgY, menu_h+30, scrollYArea, c_fg, c_bg)
+
+
+
+
+#-- END GUI Stuf-----------------------------------------------------
+
+c0=[0.2,0.2,0.2,0.0]
+c1=[0.7,0.7,0.9,0.0]
+c2=[0.71,0.71,0.71,0.0]
+c3=[0.4,0.4,0.4,0.0]
+c4=[0.95,0.95,0.9,0.0]
+c5=[0.64,0.64,0.64,0]
+c6=[0.75,0.75,0.75,0]
+c7=[0.6,0.6,0.6,0]
+c8=[1.0,0.0,0.0,0]
+c9=[0.7,0.0,0.0,0]
+c10=[0.64,0.81,0.81,0]
+c11=[0.57,0.71,0.71,0]
+c_nor= c5[:3]
+c_act= c10[:3]
+c_sel= c11[:3]
+c_tx = c0[:3]
+c_fg = c2[:3]
+c_bg = c5[:3]
+
+def ui_rect(coords,color):
+ [X1,Y1,X2,Y2],[r,g,b] = coords,color
+ glColor3f(r,g,b)
+ glRecti(X1,Y1,X2,Y2)
+def ui_rectA(coords,color):
+ [X1,Y1,X2,Y2],[r,g,b,a] = coords,color
+ glColor4f(r,g,b,a)
+ glRecti(X1,Y1,X2,Y2) #integer coords
+ #glRectf(X1,Y1,X2,Y2) #floating coords
+def ui_line(coords,color):
+ [X1,Y1,X2,Y2],[r,g,b] = coords,color
+ glColor3f(r,g,b)
+ glBegin(GL_LINES)
+ glVertex2i(X1,Y1)
+ glVertex2i(X2,Y2)
+ glEnd()
+def ui_panel(posX,posY,L,H,color):
+ [r,g,b] = color
+ ui_rect([posX+4,posY-4,posX+L+4,posY-H-4],[.55,.55,.55]) #1st shadow
+ ui_rect([posX+3,posY-3,posX+L+3,posY-H-3],[.45,.45,.45])
+ ui_rect([posX+3,posY-3,posX+L+2,posY-H-2],[.30,.30,.30]) #2nd shadow
+ ui_rect([posX,posY-H,posX+L,posY],[r,g,b]) #Main
+ ui_rect([posX+3,posY-19,posX+L-3,posY-2],[.75*r,.75*g,.75*b]) #Titlebar
+ ui_line([posX+3,posY-19,posX+3,posY-2],[.25,.25,.25])
+ ui_line([posX+4,posY-19,posX+4,posY-2],[(r+.75)/4,(g+.75)/4,(b+.75)/4])
+ ui_line([posX+4,posY-2,posX+L-3,posY-2],[(r+.75)/4,(g+.75)/4,(b+.75)/4])
+def ui_box(x,y,xright,bottom):
+ color = [0.75, 0.75, 0.75]
+ coords = x+1,y+1,xright-1,bottom-1
+ ui_rect(coords,color)
+
+def ui_scrollbarX(Focus,PanelH,Area, color_fg, color_bg):
+ # Area = ScrollBarArea
+ # point1=down/left, point2=top/right
+ P1X,P1Y,P2X,P2Y = Area
+ AreaH = P2X-P1X
+ if PanelH > AreaH:
+ Slider = int(AreaH * (AreaH / float(PanelH)))
+ if Slider<3: Slider = 3 #minimal slider heigh
+ posX = -int(AreaH * (Focus / float(PanelH)))
+ ui_rect([P1X,P1Y,P2X,P2Y], color_bg)
+ ui_rect([P1X+posX,P1Y+3,P1X+posX+Slider,P2Y-3], color_fg)
+
+def ui_scrollbarY(Focus,PanelH,Area, color_fg, color_bg):
+ # Area = ScrollBarArea
+ # point1=down/left, point2=top/right
+ P1X,P1Y,P2X,P2Y = Area
+ AreaH = P2Y-P1Y
+ if PanelH > AreaH:
+ Slider = int(AreaH * (AreaH / float(PanelH)))
+ if Slider<3: Slider = 3 #minimal slider heigh
+ posY = -int(AreaH * (Focus / float(PanelH)))
+ ui_rect([P1X,P1Y,P2X-1,P2Y], color_bg)
+ #ui_rect([P1X+3,P2Y-posY,P2X-4,P2Y-posY-Slider], color_fg)
+ ui_rect([P1X+3,P1Y+posY,P2X-4,P1Y+posY+Slider], color_fg)
+
+
+#------------------------------------------------------------
+def dxf_callback(input_filename):
+ global dxfFileName
+ dxfFileName.val=input_filename
+# dirname == Blender.sys.dirname(Blender.Get('filename'))
+# update_RegistryKey('DirName', dirname)
+# update_RegistryKey('dxfFileName', input_filename)
+
+def ini_callback(input_filename):
+ global iniFileName
+ iniFileName.val=input_filename
+
+#------------------------------------------------------------
+def getSpaceRect():
+ __UI_RECT__ = Buffer(GL_FLOAT, 4)
+ glGetFloatv(GL_SCISSOR_BOX, __UI_RECT__)
+ __UI_RECT__ = __UI_RECT__.list
+ return (int(__UI_RECT__[0]), int(__UI_RECT__[1]), int(__UI_RECT__[2]), int(__UI_RECT__[3]))
+
+def getRelMousePos(mco, winRect):
+ # mco = Blender.Window.GetMouseCoords()
+ if pointInRect(mco, winRect):
+ return (mco[0] - winRect[0], mco[1] - winRect[1])
+ return None
+
+
+def pointInRect(pt, rect):
+ if rect[0] < pt[0] < rect[0]+rect[2] and\
+ rect[1] < pt[1] < rect[1]+rect[3]:
+ return True
+ else:
+ return False
+
+
+
+#--- variables UI menu ---------------------------
+mco = [0,0] # mouse coordinaten
+mbX, mbY = 0,0 # mouse buffer coordinaten
+scrollW = 20 # width of scrollbar
+rowH = 20 # height of menu raw
+menu__H = 2 * rowH +5 # height of menu bar
+headerH = 1 * rowH # height of column header bar
+scroll_left = True # position of scrollbar
+menu_bottom = False # position of menu
+edit_mode = False # indicator/activator
+iconlib_mode = False # indicator/activator
+icon_maps = [] #[['blenderbuttons.png',12,25,20,21],
+#['referenceicons.png',12,25,20,21]]
+help_text = False # indicator/activator
+menu_pan = False # indicator/activator
+compact_DESIGN = True # toggle UI
+showLINK = True # toggle Links
+filterList=[-1,-1,-1,-1,-1]
+dubbleclik_delay = 0.25
+
+PAN_X,PAN_Y = 0,0 # pan coordinates in characters
+mPAN_X,mPAN_Y = 0,0 # manu pan coordinates in characters
+menu_orgX = 0
+menu_orgY = 0
+mPAN_Xmax = 800
+mPAN_Ymax = 800
+
+
+#------------------------------------------------------------
+def event(evt, val):
+ global mbX, mbY, UP, UP0, scroll_pan, FOCUS_fix
+ global menu_bottom, scroll_left, mco
+ global PAN_X, PAN_Y, PAN_X0, PAN_Y0
+ global mPAN_X, mPAN_Y, mPAN_X0, mPAN_Y0, menu_pan
+
+ #if Blender.event:
+ # print 'Blender.event:%s, evt:%s' %(Blender.event, evt) #------------
+
+ if evt in (Draw.QKEY, Draw.ESCKEY) and not val:
+ print 'DXF-Exporter *** end ***' #---------------------
+ Draw.Exit()
+
+ elif val:
+ if evt==Draw.MIDDLEMOUSE:
+ mco2 = Window.GetMouseCoords()
+ relativeMouseCo = getRelMousePos(mco2, getSpaceRect())
+ if relativeMouseCo != None:
+ #rect = [menu__X1,menu__Y1,menu__X2,menu__Y2]
+ if 1: #pointInRect(relativeMouseCo, menu__Area):
+ menu_pan = True
+ mPAN_X0 = mPAN_X
+ mPAN_Y0 = mPAN_Y
+ mco = mco2
+ elif evt == Draw.MOUSEY or evt == Draw.MOUSEX:
+ if menu_pan:
+ mco2 = Window.GetMouseCoords()
+ mbX = mco2[0]-mco[0]
+ mbY = mco2[1]-mco[1]
+ mPAN_X = mPAN_X0 - mbX
+ mPAN_Y = mPAN_Y0 - mbY
+ #print mbX, mbY #--------------------
+ Draw.Redraw()
+ elif evt == Draw.WHEELDOWNMOUSE:
+ mPAN_Y -= 80
+ Draw.Redraw()
+ elif evt == Draw.WHEELUPMOUSE:
+ mPAN_Y += 80
+ Draw.Redraw()
+ else: # = if val==False:
+ if evt==Draw.LEFTMOUSE:
+ scroll_pan = False
+ elif evt==Draw.MIDDLEMOUSE:
+ menu_pan = False
+
+def bevent(evt):
+ global config_UI, user_preset
+ global CAMERA, GUI_A
+
+ ######### Manages GUI events
+ if (evt==EVENT_EXIT):
+ Draw.Exit()
+ print 'DXF-Exporter *** end ***' #---------------------
+ elif (evt==EVENT_CHOOSE_INI):
+ Window.FileSelector(ini_callback, "INI-file Selection", '*.ini')
+ elif (evt==EVENT_REDRAW):
+ Draw.Redraw()
+ elif (evt==EVENT_RESET):
+ resetDefaultConfig()
+ Draw.Redraw()
+ elif (evt==EVENT_PRESET2D):
+ resetDefaultConfig_2D()
+ Draw.Redraw()
+ elif (evt==EVENT_PRESET3D):
+ resetDefaultConfig_3D()
+ Draw.Redraw()
+ elif evt in (EVENT_CAMERA,EVENT_LIGHT):
+ CAMERA = GUI_A['camera_selected'].val
+ if CAMERA==len(CAMERAS)+1:
+ doAllCameras = True
+ else:
+ pass #print 'deb: CAMERAS=',CAMERAS #----------------
+ Draw.Redraw()
+ elif (evt==EVENT_setCAMERA):
+ if CAMERA<len(CAMERAS)+1:
+ gotoCAMERA()
+
+ elif (evt==EVENT_SCALE):
+ if g_scale_as.val == 12:
+ inputGlobalScale()
+ if GUI_A['g_scale'].val < 0.00000001:
+ GUI_A['g_scale'].val = 0.00000001
+ Draw.Redraw()
+ elif (evt==EVENT_ORIGIN):
+ inputOriginVector()
+ Draw.Redraw()
+ elif (evt==EVENT_PRESETPLINE):
+ presetConfig_polyline(GUI_A['to_polyline_on'].val)
+ Draw.Redraw()
+ elif (evt==EVENT_PRESETS):
+ user_preset += 1
+ index = str(user_preset)
+ if user_preset > 5: user_preset = 0; index = ''
+ iniFileName.val = INIFILE_DEFAULT_NAME + index + INIFILE_EXTENSION
+ Draw.Redraw()
+ elif (evt==EVENT_HELP):
try:
import webbrowser
webbrowser.open('http://wiki.blender.org/index.php?title=Scripts/Manual/Export/autodesk_dxf')
except:
- Draw.PupMenu('DXF Exporter: %t|no connection to manual-page on Blender-Wiki! try:|\
+ Draw.PupMenu('DXF-Exporter: HELP Alert!%t|no connection to manual-page on Blender-Wiki! try:|\
http://wiki.blender.org/index.php?title=Scripts/Manual/Export/autodesk_dxf')
- return
+ Draw.Redraw()
+ elif (evt==EVENT_LOAD_INI):
+ loadConfig()
+ Draw.Redraw()
+ elif (evt==EVENT_SAVE_INI):
+ saveConfig()
+ Draw.Redraw()
+ elif (evt==EVENT_DXF_DIR):
+ dxfFile = dxfFileName.val
+ dxfPathName = ''
+ if '/' in dxfFile:
+ dxfPathName = '/'.join(dxfFile.split('/')[:-1]) + '/'
+ elif '\\' in dxfFile:
+ dxfPathName = '\\'.join(dxfFile.split('\\')[:-1]) + '\\'
+ dxfFileName.val = dxfPathName + '*.dxf'
+# dirname == Blender.sys.dirname(Blender.Get('filename'))
+# update_RegistryKey('DirName', dirname)
+# update_RegistryKey('dxfFileName', dxfFileName.val)
+ GUI_A['only_selected_on'].val = 1
+ Draw.Redraw()
+ elif (evt==EVENT_CHOOSE_DXF):
+ filename = '' # '*.dxf'
+ if dxfFileName.val: filename = dxfFileName.val
+ Window.FileSelector(dxf_callback, "DXF-file Selection", filename)
+ elif (evt==EVENT_START):
+ dxfFile = dxfFileName.val
+ #print 'deb: dxfFile file: ', dxfFile #----------------------
+ if E_M: dxfFileName.val, dxfFile = e_mode(dxfFile) #evaluation mode
+ update_RegistryKey('dxfFileName', dxfFileName.val)
+ update_globals()
+ if dxfFile.lower().endswith('*.dxf'):
+ if Draw.PupMenu('DXF-Exporter: OK?|will write multiple DXF-files, one for each Scene, in:|%s' % dxfFile) == 1:
+ global UI_MODE
+ UI_MODE = False
+ #TODO: multi_export(dxfFile[:-5]) # cut last 5 characters '*.dxf'
+ Draw.Redraw()
+ UI_MODE = True
+ else:
+ Draw.Redraw()
+ elif dxfFile.lower()[-4:] in ('.dxf','.dwg'): # and Blender.sys.exists(dxfFile):
+ print 'preparing for export ---' #Standard Mode: activated
+ filepath = dxfFile
+ sce = Scene.GetCurrent()
+ if ONLYSELECTED: sel_group = sce.objects.selected
+ else: sel_group = sce.objects
+
+ if ONLYVISIBLE:
+ sel_group_temp = []
+ layerlist = sce.getLayers()
+ for ob in sel_group:
+ for lay in ob.layers:
+ if lay in layerlist:
+ sel_group_temp.append(ob)
+ break
+ sel_group = sel_group_temp
+
+ export_list = getObjectsAndDuplis(sel_group,MATRICES=True)
+
+ if export_list: do_export(export_list, filepath)
+ else:
+ print "Abort: selection was empty, no object to export!"
+ Draw.PupMenu('DXF Exporter: nothing exported!|empty selection!')
+ else:
+ Draw.PupMenu('DXF-Exporter: Alert!%t|no valid DXF-file selected!')
+ print "DXF-Exporter: error, no valid DXF-file selected! try again"
+ Draw.Redraw()
- ONLYSELECTED = PREF_ONLYSELECTED.val
- POLYLINES = PREF_POLYLINES.val
- ONLYFACES = PREF_ONLYFACES.val
- POLYFACES = PREF_POLYFACES.val
- FLATTEN = PREF_FLATTEN.val
- HIDDEN_MODE = PREF_HIDDEN_MODE.val
- SCALE_FACTOR = PREF_SCALE_FACTOR.val
- OUTPUT_DWG = PREF_DWG.val
-
- sce = Scene.GetCurrent()
- if ONLYSELECTED: sel_group = sce.objects.selected
- else: sel_group = sce.objects
- export_list = getObjectsAndDuplis(sel_group,MATRICES=True)
- if export_list: do_export(export_list, filepath)
- else:
- print "Abort: selection was empty, no object to export!"
- Draw.PupMenu('DXF Exporter: nothing exported!|empty selection!')
- # Timing the script is a good way to be aware on any speed hits when scripting
+def multi_export(DIR): #TODO:
+ """Imports all DXF-files from directory DIR.
+
+ """
+ global SCENE
+ batchTIME = Blender.sys.time()
+ #if #DIR == "": DIR = os.path.curdir
+ if DIR == "": DIR = Blender.sys.dirname(Blender.Get('filename'))
+ print 'Multifiles Import from %s' %DIR
+ files = \
+ [Blender.sys.join(DIR, f) for f in os.listdir(DIR) if f.lower().endswith('.dxf')]
+ if not files:
+ print '...None DXF-files found. Abort!'
+ return
+
+ i = 0
+ for dxfFile in files:
+ i += 1
+ print '\nDXF-file', i, 'of', len(files) #,'\nImporting', dxfFile
+ if ONLYSELECTED:
+ _dxf_file = dxfFile.split('/')[-1].split('\\')[-1]
+ _dxf_file = _dxf_file[:-4] # cut last char:'.dxf'
+ _dxf_file = _dxf_file[:NAMELENGTH_MAX] #? [-NAMELENGTH_MAX:])
+ SCENE = Blender.Scene.New(_dxf_file)
+ SCENE.makeCurrent()
+ #or so? Blender.Scene.makeCurrent(_dxf_file)
+ #sce = bpy.data.scenes.new(_dxf_file)
+ #bpy.data.scenes.active = sce
+ else:
+ SCENE = Blender.Scene.GetCurrent()
+ SCENE.objects.selected = [] # deselect all
+ main(dxfFile)
+ #Blender.Redraw()
+
+ print 'TOTAL TIME: %.6f' % (Blender.sys.time() - batchTIME)
+ print '\a\r', # beep when done
+
#-----------------------------------------------------
if __name__=='__main__':
- #main()
- if not copy:
- Draw.PupMenu('Error%t|This script requires a full python install')
- else: Window.FileSelector(dxf_export_ui, 'EXPORT DXF', sys.makename(ext='.dxf')) \ No newline at end of file
+
+ if not DXF.copy:
+ Draw.PupMenu('Error%t|The dxfLibrary.py script requires a full python install')
+ #Window.FileSelector(dxf_export_ui, 'EXPORT DXF', Blender.sys.makename(ext='.dxf'))
+ # recall last used DXF-file and INI-file names
+ dxffilename = check_RegistryKey('dxfFileName')
+ #print 'deb:start dxffilename:', dxffilename #----------------
+ if dxffilename: dxfFileName.val = dxffilename
+ else:
+ dirname = Blender.sys.dirname(Blender.Get('filename'))
+ #print 'deb:start dirname:', dirname #----------------
+ dxfFileName.val = Blender.sys.join(dirname, '')
+ inifilename = check_RegistryKey('iniFileName')
+ if inifilename: iniFileName.val = inifilename
+
+ updateMenuCAMERA()
+ updateCAMERA()
+
+ Draw.Register(draw_UI, event, bevent)
+
+ \ No newline at end of file
diff --git a/release/scripts/export_fbx.py b/release/scripts/export_fbx.py
index 730776bf1b8..4115140a852 100644
--- a/release/scripts/export_fbx.py
+++ b/release/scripts/export_fbx.py
@@ -1,13 +1,13 @@
#!BPY
"""
Name: 'Autodesk FBX (.fbx)...'
-Blender: 244
+Blender: 249
Group: 'Export'
Tooltip: 'Selection to an ASCII Autodesk FBX '
"""
__author__ = "Campbell Barton"
__url__ = ['www.blender.org', 'blenderartists.org']
-__version__ = "1.1"
+__version__ = "1.2"
__bpydoc__ = """\
This script is an exporter to the FBX file format.
@@ -93,8 +93,8 @@ def copy_images(dest_dir, textures):
dest_dir += Blender.sys.sep
image_paths = set()
- for img in textures:
- image_paths.add(Blender.sys.expandpath(img.filename))
+ for tex in textures:
+ image_paths.add(Blender.sys.expandpath(tex.filename))
# Now copy images
copyCount = 0
@@ -157,14 +157,29 @@ def increment_string(t):
# todo - Disallow the name 'Scene' and 'blend_root' - it will bugger things up.
def sane_name(data, dct):
#if not data: return None
- name = data.name
+
+ if type(data)==tuple: # materials are paired up with images
+ data, other = data
+ use_other = True
+ else:
+ other = None
+ use_other = False
+
+ if data: name = data.name
+ else: name = None
+ orig_name = name
+
+ if other:
+ orig_name_other = other.name
+ name = '%s #%s' % (name, orig_name_other)
+ else:
+ orig_name_other = None
# dont cache, only ever call once for each data type now,
# so as to avoid namespace collision between types - like with objects <-> bones
#try: return dct[name]
#except: pass
- orig_name = name
if not name:
name = 'unnamed' # blank string, ASKING FOR TROUBLE!
else:
@@ -173,7 +188,11 @@ def sane_name(data, dct):
while name in dct.itervalues(): name = increment_string(name)
- dct[orig_name] = name
+ if use_other: # even if other is None - orig_name_other will be a string or None
+ dct[orig_name, orig_name_other] = name
+ else:
+ dct[orig_name] = name
+
return name
def sane_obname(data): return sane_name(data, sane_name_mapping_ob)
@@ -511,7 +530,7 @@ def write(filename, batch_objects = None, \
if time:
curtime = time.localtime()[0:6]
else:
- curtime = [0,0,0,0,0,0]
+ curtime = (0,0,0,0,0,0)
#
file.write(\
'''FBXHeaderExtension: {
@@ -983,7 +1002,7 @@ def write(filename, batch_objects = None, \
#eDIRECTIONAL
#eSPOT
light_type = light.type
- if light_type > 3: light_type = 0
+ if light_type > 2: light_type = 1 # hemi and area lights become directional
mode = light.mode
if mode & Blender.Lamp.Modes.RayShadow or mode & Blender.Lamp.Modes.Shadows:
@@ -1333,17 +1352,20 @@ def write(filename, batch_objects = None, \
me = my_mesh.blenData
# if there are non NULL materials on this mesh
- if [mat for mat in my_mesh.blenMaterials if mat]: do_materials = True
- else: do_materials = False
+ if my_mesh.blenMaterials: do_materials = True
+ else: do_materials = False
if my_mesh.blenTextures: do_textures = True
- else: do_textures = False
+ else: do_textures = False
+
+ do_uvs = me.faceUV
file.write('\n\tModel: "Model::%s", "Mesh" {' % my_mesh.fbxName)
file.write('\n\t\tVersion: 232') # newline is added in write_object_props
- write_object_props(my_mesh.blenObject, None, my_mesh.parRelMatrix())
+ poseMatrix = write_object_props(my_mesh.blenObject, None, my_mesh.parRelMatrix())[3]
+ pose_items.append((my_mesh.fbxName, poseMatrix))
file.write('\n\t\t}')
file.write('\n\t\tMultiLayer: 0')
@@ -1385,22 +1407,18 @@ def write(filename, batch_objects = None, \
else: file.write(',%i,%i,%i,%i' % fi )
i+=1
- ed_val = [None, None]
- LOOSE = Blender.Mesh.EdgeFlags.LOOSE
+ file.write('\n\t\tEdges: ')
+ i=-1
for ed in me.edges:
- if ed.flag & LOOSE:
- ed_val[0] = ed.v1.index
- ed_val[1] = -(ed.v2.index+1)
if i==-1:
- file.write('%i,%i' % tuple(ed_val) )
+ file.write('%i,%i' % (ed.v1.index, ed.v2.index))
i=0
else:
if i==13:
file.write('\n\t\t')
i=0
- file.write(',%i,%i' % tuple(ed_val) )
+ file.write(',%i,%i' % (ed.v1.index, ed.v2.index))
i+=1
- del LOOSE
file.write('\n\t\tGeometryVersion: 124')
@@ -1423,6 +1441,51 @@ def write(filename, batch_objects = None, \
i+=1
file.write('\n\t\t}')
+ # Write Face Smoothing
+ file.write('''
+ LayerElementSmoothing: 0 {
+ Version: 102
+ Name: ""
+ MappingInformationType: "ByPolygon"
+ ReferenceInformationType: "Direct"
+ Smoothing: ''')
+
+ i=-1
+ for f in me.faces:
+ if i==-1:
+ file.write('%i' % f.smooth); i=0
+ else:
+ if i==54:
+ file.write('\n '); i=0
+ file.write(',%i' % f.smooth)
+ i+=1
+
+ file.write('\n\t\t}')
+
+ # Write Edge Smoothing
+ file.write('''
+ LayerElementSmoothing: 0 {
+ Version: 101
+ Name: ""
+ MappingInformationType: "ByEdge"
+ ReferenceInformationType: "Direct"
+ Smoothing: ''')
+
+ SHARP = Blender.Mesh.EdgeFlags.SHARP
+ i=-1
+ for ed in me.edges:
+ if i==-1:
+ file.write('%i' % ((ed.flag&SHARP)!=0)); i=0
+ else:
+ if i==54:
+ file.write('\n '); i=0
+ file.write(',%i' % ((ed.flag&SHARP)!=0))
+ i+=1
+
+ file.write('\n\t\t}')
+ del SHARP
+
+
# Write VertexColor Layers
# note, no programs seem to use this info :/
collayers = []
@@ -1475,7 +1538,7 @@ def write(filename, batch_objects = None, \
# Write UV and texture layers.
uvlayers = []
- if me.faceUV:
+ if do_uvs:
uvlayers = me.getUVLayerNames()
uvlayer_orig = me.activeUVLayer
for uvindex, uvlayer in enumerate(uvlayers):
@@ -1538,13 +1601,13 @@ def write(filename, batch_objects = None, \
if len(my_mesh.blenTextures) == 1:
file.write('0')
else:
- #texture_mapping_local = {None:0}
texture_mapping_local = {None:-1}
i = 0 # 1 for dummy
for tex in my_mesh.blenTextures:
- texture_mapping_local[tex] = i
- i+=1
+ if tex: # None is set above
+ texture_mapping_local[tex] = i
+ i+=1
i=-1
for f in me.faces:
@@ -1594,32 +1657,32 @@ def write(filename, batch_objects = None, \
file.write('0')
else:
# Build a material mapping for this
- #material_mapping_local = [0] * 16 # local-index : global index.
- material_mapping_local = [-1] * 16 # local-index : global index.
- i= 0 # 1
- for j, mat in enumerate(my_mesh.blenMaterials):
- if mat:
- material_mapping_local[j] = i
- i+=1
- # else leave as -1
+ material_mapping_local = {} # local-mat & tex : global index.
+
+ for j, mat_tex_pair in enumerate(my_mesh.blenMaterials):
+ material_mapping_local[mat_tex_pair] = j
len_material_mapping_local = len(material_mapping_local)
+ mats = my_mesh.blenMaterialList
+
i=-1
for f in me.faces:
- f_mat = f.mat
- if f_mat >= len_material_mapping_local:
- f_mat = 0
+ try: mat = mats[f.mat]
+ except:mat = None
+
+ if do_uvs: tex = f.image # WARNING - MULTI UV LAYER IMAGES NOT SUPPORTED :/
+ else: tex = None
if i==-1:
i=0
- file.write( '%s' % (material_mapping_local[f_mat]))
+ file.write( '%s' % (material_mapping_local[mat, tex])) # None for mat or tex is ok
else:
if i==55:
file.write('\n\t\t\t\t')
i=0
- file.write(',%s' % (material_mapping_local[f_mat]))
+ file.write(',%s' % (material_mapping_local[mat, tex]))
i+=1
file.write('\n\t\t}')
@@ -1654,7 +1717,7 @@ def write(filename, batch_objects = None, \
TypedIndex: 0
}''')
- if me.faceUV:
+ if do_uvs: # same as me.faceUV
file.write('''
LayerElement: {
Type: "LayerElementUV"
@@ -1736,8 +1799,8 @@ def write(filename, batch_objects = None, \
ob_all_typegroups = [ob_meshes, ob_lights, ob_cameras, ob_arms, ob_null]
groups = [] # blender groups, only add ones that have objects in the selections
- materials = {}
- textures = {}
+ materials = {} # (mat, image) keys, should be a set()
+ textures = {} # should be a set()
tmp_ob_type = ob_type = None # incase no objects are exported, so as not to raise an error
@@ -1837,30 +1900,34 @@ def write(filename, batch_objects = None, \
if EXP_MESH_HQ_NORMALS:
BPyMesh.meshCalcNormals(me) # high quality normals nice for realtime engines.
- for mat in mats:
- # 2.44 use mat.lib too for uniqueness
- if mat: materials[mat] = mat
-
texture_mapping_local = {}
+ material_mapping_local = {}
if me.faceUV:
uvlayer_orig = me.activeUVLayer
for uvlayer in me.getUVLayerNames():
me.activeUVLayer = uvlayer
for f in me.faces:
- img = f.image
- textures[img] = texture_mapping_local[img] = img
+ tex = f.image
+ textures[tex] = texture_mapping_local[tex] = None
+
+ try: mat = mats[f.mat]
+ except: mat = None
+
+ materials[mat, tex] = material_mapping_local[mat, tex] = None # should use sets, wait for blender 2.5
+
me.activeUVLayer = uvlayer_orig
+ else:
+ for mat in mats:
+ # 2.44 use mat.lib too for uniqueness
+ materials[mat, None] = material_mapping_local[mat, None] = None
+ else:
+ materials[None, None] = None
if EXP_ARMATURE:
armob = BPyObject.getObjectArmature(ob)
blenParentBoneName = None
- # Note - Fixed in BPyObject but for now just copy the function because testers wont have up to date modukes,
- # TODO - remove this for 2.45 release since getObjectArmature has been fixed
- if (not armob) and ob.parent and ob.parent.type == 'Armature' and ob.parentType == Blender.Object.ParentTypes.ARMATURE:
- armob = ob.parent
-
# parent bone - special case
if (not armob) and ob.parent and ob.parent.type == 'Armature' and ob.parentType == Blender.Object.ParentTypes.BONE:
armob = ob.parent
@@ -1876,8 +1943,9 @@ def write(filename, batch_objects = None, \
my_mesh = my_object_generic(ob, mtx)
my_mesh.blenData = me
my_mesh.origData = origData
- my_mesh.blenMaterials = mats
- my_mesh.blenTextures = texture_mapping_local.values()
+ my_mesh.blenMaterials = material_mapping_local.keys()
+ my_mesh.blenMaterialList = mats
+ my_mesh.blenTextures = texture_mapping_local.keys()
# if only 1 null texture then empty the list
if len(my_mesh.blenTextures) == 1 and my_mesh.blenTextures[0] == None:
@@ -1996,8 +2064,8 @@ def write(filename, batch_objects = None, \
# Finished finding groups we use
- materials = [(sane_matname(mat), mat) for mat in materials.itervalues() if mat]
- textures = [(sane_texname(img), img) for img in textures.itervalues() if img]
+ materials = [(sane_matname(mat_tex_pair), mat_tex_pair) for mat_tex_pair in materials.iterkeys()]
+ textures = [(sane_texname(tex), tex) for tex in textures.iterkeys() if tex]
materials.sort() # sort by name
textures.sort()
@@ -2126,8 +2194,8 @@ Objects: {''')
write_camera_default()
- for matname, mat in materials:
- write_material(matname, mat)
+ for matname, (mat, tex) in materials:
+ write_material(matname, mat) # We only need to have a material per image pair, but no need to write any image info into the material (dumb fbx standard)
# each texture uses a video, odd
for texname, tex in textures:
@@ -2247,7 +2315,7 @@ Relations: {''')
Model: "Model::Camera Switcher", "CameraSwitcher" {
}''')
- for matname, mat in materials:
+ for matname, (mat, tex) in materials:
file.write('\n\tMaterial: "Material::%s", "" {\n\t}' % matname)
if textures:
@@ -2299,9 +2367,14 @@ Connections: {''')
if materials:
for my_mesh in ob_meshes:
# Connect all materials to all objects, not good form but ok for now.
- for mat in my_mesh.blenMaterials:
- if mat:
- file.write('\n\tConnect: "OO", "Material::%s", "Model::%s"' % (sane_name_mapping_mat[mat.name], my_mesh.fbxName))
+ for mat, tex in my_mesh.blenMaterials:
+ if mat: mat_name = mat.name
+ else: mat_name = None
+
+ if tex: tex_name = tex.name
+ else: tex_name = None
+
+ file.write('\n\tConnect: "OO", "Material::%s", "Model::%s"' % (sane_name_mapping_mat[mat_name, tex_name], my_mesh.fbxName))
if textures:
for my_mesh in ob_meshes:
@@ -2519,8 +2592,18 @@ Takes: {''')
for TX_LAYER, TX_CHAN in enumerate('TRS'): # transform, rotate, scale
if TX_CHAN=='T': context_bone_anim_vecs = [mtx[0].translationPart() for mtx in context_bone_anim_mats]
- elif TX_CHAN=='R': context_bone_anim_vecs = [mtx[1].toEuler() for mtx in context_bone_anim_mats]
- else: context_bone_anim_vecs = [mtx[0].scalePart() for mtx in context_bone_anim_mats]
+ elif TX_CHAN=='S': context_bone_anim_vecs = [mtx[0].scalePart() for mtx in context_bone_anim_mats]
+ elif TX_CHAN=='R':
+ # Was....
+ # elif TX_CHAN=='R': context_bone_anim_vecs = [mtx[1].toEuler() for mtx in context_bone_anim_mats]
+ #
+ # ...but we need to use the previous euler for compatible conversion.
+ context_bone_anim_vecs = []
+ prev_eul = None
+ for mtx in context_bone_anim_mats:
+ if prev_eul: prev_eul = mtx[1].toEuler(prev_eul)
+ else: prev_eul = mtx[1].toEuler()
+ context_bone_anim_vecs.append(prev_eul)
file.write('\n\t\t\t\tChannel: "%s" {' % TX_CHAN) # translation
@@ -2539,10 +2622,9 @@ Takes: {''')
if frame!=act_start:
file.write(',')
- # Curve types are
+ # Curve types are 'C,n' for constant, 'L' for linear
# C,n is for bezier? - linear is best for now so we can do simple keyframe removal
- file.write('\n\t\t\t\t\t\t\t%i,%.15f,C,n' % (fbx_time(frame-1), context_bone_anim_vecs[frame-act_start][i] ))
- #file.write('\n\t\t\t\t\t\t\t%i,%.15f,L' % (fbx_time(frame-1), context_bone_anim_vecs[frame-act_start][i] ))
+ file.write('\n\t\t\t\t\t\t\t%i,%.15f,L' % (fbx_time(frame-1), context_bone_anim_vecs[frame-act_start][i] ))
frame+=1
else:
# remove unneeded keys, j is the frame, needed when some frames are removed.
@@ -2550,11 +2632,32 @@ Takes: {''')
# last frame to fisrt frame, missing 1 frame on either side.
# removeing in a backwards loop is faster
- for j in xrange( (act_end-act_start)-1, 0, -1 ):
- # Is this key reduenant?
- if abs(context_bone_anim_keys[j][0] - context_bone_anim_keys[j-1][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT and\
- abs(context_bone_anim_keys[j][0] - context_bone_anim_keys[j+1][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT:
+ #for j in xrange( (act_end-act_start)-1, 0, -1 ):
+ # j = (act_end-act_start)-1
+ j = len(context_bone_anim_keys)-2
+ while j > 0 and len(context_bone_anim_keys) > 2:
+ # print j, len(context_bone_anim_keys)
+ # Is this key the same as the ones next to it?
+
+ # co-linear horizontal...
+ if abs(context_bone_anim_keys[j][0] - context_bone_anim_keys[j-1][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT and\
+ abs(context_bone_anim_keys[j][0] - context_bone_anim_keys[j+1][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT:
+
del context_bone_anim_keys[j]
+
+ else:
+ frame_range = float(context_bone_anim_keys[j+1][1] - context_bone_anim_keys[j-1][1])
+ frame_range_fac1 = (context_bone_anim_keys[j+1][1] - context_bone_anim_keys[j][1]) / frame_range
+ frame_range_fac2 = 1.0 - frame_range_fac1
+
+ if abs(((context_bone_anim_keys[j-1][0]*frame_range_fac1 + context_bone_anim_keys[j+1][0]*frame_range_fac2)) - context_bone_anim_keys[j][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT:
+ del context_bone_anim_keys[j]
+ else:
+ j-=1
+
+ # keep the index below the list length
+ if j > len(context_bone_anim_keys)-2:
+ j = len(context_bone_anim_keys)-2
if len(context_bone_anim_keys) == 2 and context_bone_anim_keys[0][0] == context_bone_anim_keys[1][0]:
# This axis has no moton, its okay to skip KeyCount and Keys in this case
@@ -2567,8 +2670,7 @@ Takes: {''')
if frame != context_bone_anim_keys[0][1]: # not the first
file.write(',')
# frame is alredy one less then blenders frame
- file.write('\n\t\t\t\t\t\t\t%i,%.15f,C,n' % (fbx_time(frame), val ))
- #file.write('\n\t\t\t\t\t\t\t%i,%.15f,L' % (fbx_time(frame), val ))
+ file.write('\n\t\t\t\t\t\t\t%i,%.15f,L' % (fbx_time(frame), val ))
if i==0: file.write('\n\t\t\t\t\t\tColor: 1,0,0')
elif i==1: file.write('\n\t\t\t\t\t\tColor: 0,1,0')
@@ -2734,15 +2836,16 @@ def fbx_ui_exit(e,v):
GLOBALS['EVENT'] = e
def do_help(e,v):
- url = 'http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_fbx'
- print 'Trying to open web browser with documentation at this address...'
- print '\t' + url
-
- try:
- import webbrowser
- webbrowser.open(url)
- except:
- print '...could not open a browser window.'
+ url = 'http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_fbx'
+ print 'Trying to open web browser with documentation at this address...'
+ print '\t' + url
+
+ try:
+ import webbrowser
+ webbrowser.open(url)
+ except:
+ Blender.Draw.PupMenu("Error%t|Opening a webbrowser requires a full python installation")
+ print '...could not open a browser window.'
@@ -2846,7 +2949,7 @@ def fbx_ui():
Draw.BeginAlign()
GLOBALS['ANIM_OPTIMIZE'] = Draw.Toggle('Optimize Keyframes', EVENT_REDRAW, x+20, y+0, 160, 20, GLOBALS['ANIM_OPTIMIZE'].val, 'Remove double keyframes', do_redraw)
if GLOBALS['ANIM_OPTIMIZE'].val:
- GLOBALS['ANIM_OPTIMIZE_PRECISSION'] = Draw.Number('Precission: ', EVENT_NONE, x+180, y+0, 160, 20, GLOBALS['ANIM_OPTIMIZE_PRECISSION'].val, 3, 16, 'Tolerence for comparing double keyframes (higher for greater accuracy)')
+ GLOBALS['ANIM_OPTIMIZE_PRECISSION'] = Draw.Number('Precission: ', EVENT_NONE, x+180, y+0, 160, 20, GLOBALS['ANIM_OPTIMIZE_PRECISSION'].val, 1, 16, 'Tolerence for comparing double keyframes (higher for greater accuracy)')
Draw.EndAlign()
Draw.BeginAlign()
@@ -2924,7 +3027,7 @@ def write_ui():
# animation opts
GLOBALS['ANIM_ENABLE'] = Draw.Create(1)
GLOBALS['ANIM_OPTIMIZE'] = Draw.Create(1)
- GLOBALS['ANIM_OPTIMIZE_PRECISSION'] = Draw.Create(6) # decimal places
+ GLOBALS['ANIM_OPTIMIZE_PRECISSION'] = Draw.Create(4) # decimal places
GLOBALS['ANIM_ACTION_ALL'] = [Draw.Create(0), Draw.Create(1)] # not just the current action
# batch export options
diff --git a/release/scripts/export_obj.py b/release/scripts/export_obj.py
index 28e1443e953..0edc70a874b 100644
--- a/release/scripts/export_obj.py
+++ b/release/scripts/export_obj.py
@@ -7,9 +7,9 @@ Group: 'Export'
Tooltip: 'Save a Wavefront OBJ File'
"""
-__author__ = "Campbell Barton, Jiri Hnidek"
+__author__ = "Campbell Barton, Jiri Hnidek, Paolo Ciccone"
__url__ = ['http://wiki.blender.org/index.php/Scripts/Manual/Export/wavefront_obj', 'www.blender.org', 'blenderartists.org']
-__version__ = "1.2"
+__version__ = "1.21"
__bpydoc__ = """\
This script is an exporter to OBJ file format.
@@ -185,7 +185,8 @@ def write(filename, objects,\
EXPORT_TRI=False, EXPORT_EDGES=False, EXPORT_NORMALS=False, EXPORT_NORMALS_HQ=False,\
EXPORT_UV=True, EXPORT_MTL=True, EXPORT_COPY_IMAGES=False,\
EXPORT_APPLY_MODIFIERS=True, EXPORT_ROTX90=True, EXPORT_BLEN_OBS=True,\
-EXPORT_GROUP_BY_OB=False, EXPORT_GROUP_BY_MAT=False, EXPORT_KEEP_VERT_ORDER=False):
+EXPORT_GROUP_BY_OB=False, EXPORT_GROUP_BY_MAT=False, EXPORT_KEEP_VERT_ORDER=False,\
+EXPORT_POLYGROUPS=False):
'''
Basic write function. The context and options must be alredy set
This can be accessed externaly
@@ -199,6 +200,29 @@ EXPORT_GROUP_BY_OB=False, EXPORT_GROUP_BY_MAT=False, EXPORT_KEEP_VERT_ORDER=Fal
def veckey2d(v):
return round(v.x, 6), round(v.y, 6)
+ def findVertexGroupName(face, vWeightMap):
+ """
+ Searches the vertexDict to see what groups is assigned to a given face.
+ We use a frequency system in order to sort out the name because a given vetex can
+ belong to two or more groups at the same time. To find the right name for the face
+ we list all the possible vertex group names with their frequency and then sort by
+ frequency in descend order. The top element is the one shared by the highest number
+ of vertices is the face's group
+ """
+ weightDict = {}
+ for vert in face:
+ vWeights = vWeightMap[vert.index]
+ for vGroupName, weight in vWeights:
+ weightDict[vGroupName] = weightDict.get(vGroupName, 0) + weight
+
+ if weightDict:
+ alist = [(weight,vGroupName) for vGroupName, weight in weightDict.iteritems()] # sort least to greatest amount of weight
+ alist.sort()
+ return(alist[-1][1]) # highest value last
+ else:
+ return '(null)'
+
+
print 'OBJ Export path: "%s"' % filename
temp_mesh_name = '~tmp-mesh'
@@ -239,12 +263,12 @@ EXPORT_GROUP_BY_OB=False, EXPORT_GROUP_BY_MAT=False, EXPORT_KEEP_VERT_ORDER=Fal
globalNormals = {}
- # Get all meshs
+ # Get all meshes
for ob_main in objects:
for ob, ob_mat in BPyObject.getDerivedObjects(ob_main):
# Will work for non meshes now! :)
# getMeshFromObject(ob, container_mesh=None, apply_modifiers=True, vgroups=True, scn=None)
- me= BPyMesh.getMeshFromObject(ob, containerMesh, EXPORT_APPLY_MODIFIERS, False, scn)
+ me= BPyMesh.getMeshFromObject(ob, containerMesh, EXPORT_APPLY_MODIFIERS, EXPORT_POLYGROUPS, scn)
if not me:
continue
@@ -397,6 +421,17 @@ EXPORT_GROUP_BY_OB=False, EXPORT_GROUP_BY_MAT=False, EXPORT_KEEP_VERT_ORDER=Fal
if not faceuv:
f_image = None
+ if EXPORT_POLYGROUPS:
+ # Retrieve the list of vertex groups
+ vertGroupNames = me.getVertGroupNames()
+
+ currentVGroup = ''
+ # Create a dictionary keyed by face id and listing, for each vertex, the vertex groups it belongs to
+ vgroupsMap = [[] for _i in xrange(len(me.verts))]
+ for vertexGroupName in vertGroupNames:
+ for vIdx, vWeight in me.getVertsFromGroup(vertexGroupName, 1):
+ vgroupsMap[vIdx].append((vertexGroupName, vWeight))
+
for f_index, f in enumerate(faces):
f_v= f.v
f_smooth= f.smooth
@@ -411,9 +446,18 @@ EXPORT_GROUP_BY_OB=False, EXPORT_GROUP_BY_MAT=False, EXPORT_KEEP_VERT_ORDER=Fal
else:
key = materialNames[f_mat], None # No image, use None instead.
+ # Write the vertex group
+ if EXPORT_POLYGROUPS:
+ if vertGroupNames:
+ # find what vertext group the face belongs to
+ theVGroup = findVertexGroupName(f,vgroupsMap)
+ if theVGroup != currentVGroup:
+ currentVGroup = theVGroup
+ file.write('g %s\n' % theVGroup)
+
# CHECK FOR CONTEXT SWITCH
if key == contextMat:
- pass # Context alredy switched, dont do anythoing
+ pass # Context alredy switched, dont do anything
else:
if key[0] == None and key[1] == None:
# Write a null material, since we know the context has changed.
@@ -438,6 +482,7 @@ EXPORT_GROUP_BY_OB=False, EXPORT_GROUP_BY_MAT=False, EXPORT_KEEP_VERT_ORDER=Fal
if EXPORT_GROUP_BY_MAT:
file.write('g %s_%s_%s\n' % (fixName(ob.name), fixName(ob.getData(1)), mat_data[0]) ) # can be mat_image or (null)
+
file.write('usemtl %s\n' % mat_data[0]) # can be mat_image or (null)
contextMat = key
@@ -539,7 +584,8 @@ def write_ui(filename):
EXPORT_NORMALS, EXPORT_NORMALS_HQ, EXPORT_UV,\
EXPORT_MTL, EXPORT_SEL_ONLY, EXPORT_ALL_SCENES,\
EXPORT_ANIMATION, EXPORT_COPY_IMAGES, EXPORT_BLEN_OBS,\
- EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER
+ EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER,\
+ EXPORT_POLYGROUPS
EXPORT_APPLY_MODIFIERS = Draw.Create(0)
EXPORT_ROTX90 = Draw.Create(1)
@@ -557,6 +603,8 @@ def write_ui(filename):
EXPORT_GROUP_BY_OB = Draw.Create(0)
EXPORT_GROUP_BY_MAT = Draw.Create(0)
EXPORT_KEEP_VERT_ORDER = Draw.Create(1)
+ EXPORT_POLYGROUPS = Draw.Create(0)
+
# Old UI
'''
@@ -607,7 +655,7 @@ def write_ui(filename):
GLOBALS['EVENT'] = e
def do_split(e,v):
- global EXPORT_BLEN_OBS, EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_APPLY_MODIFIERS, KEEP_VERT_ORDER
+ global EXPORT_BLEN_OBS, EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_APPLY_MODIFIERS, KEEP_VERT_ORDER, EXPORT_POLYGROUPS
if EXPORT_BLEN_OBS.val or EXPORT_GROUP_BY_OB.val or EXPORT_GROUP_BY_MAT.val or EXPORT_APPLY_MODIFIERS.val:
EXPORT_KEEP_VERT_ORDER.val = 0
else:
@@ -621,6 +669,7 @@ def write_ui(filename):
if not (EXPORT_BLEN_OBS.val or EXPORT_GROUP_BY_OB.val or EXPORT_GROUP_BY_MAT.val or EXPORT_APPLY_MODIFIERS.val):
EXPORT_KEEP_VERT_ORDER.val = 1
+
def do_help(e,v):
url = __url__[0]
print 'Trying to open web browser with documentation at this address...'
@@ -637,43 +686,45 @@ def write_ui(filename):
# Center based on overall pup size
ui_x -= 165
- ui_y -= 110
+ ui_y -= 140
global EXPORT_APPLY_MODIFIERS, EXPORT_ROTX90, EXPORT_TRI, EXPORT_EDGES,\
EXPORT_NORMALS, EXPORT_NORMALS_HQ, EXPORT_UV,\
EXPORT_MTL, EXPORT_SEL_ONLY, EXPORT_ALL_SCENES,\
EXPORT_ANIMATION, EXPORT_COPY_IMAGES, EXPORT_BLEN_OBS,\
- EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER
+ EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER,\
+ EXPORT_POLYGROUPS
- Draw.Label('Context...', ui_x+9, ui_y+209, 220, 20)
+ Draw.Label('Context...', ui_x+9, ui_y+239, 220, 20)
Draw.BeginAlign()
- EXPORT_SEL_ONLY = Draw.Toggle('Selection Only', EVENT_NONE, ui_x+9, ui_y+189, 110, 20, EXPORT_SEL_ONLY.val, 'Only export objects in visible selection. Else export whole scene.')
- EXPORT_ALL_SCENES = Draw.Toggle('All Scenes', EVENT_NONE, ui_x+119, ui_y+189, 110, 20, EXPORT_ALL_SCENES.val, 'Each scene as a separate OBJ file.')
- EXPORT_ANIMATION = Draw.Toggle('Animation', EVENT_NONE, ui_x+229, ui_y+189, 110, 20, EXPORT_ANIMATION.val, 'Each frame as a numbered OBJ file.')
+ EXPORT_SEL_ONLY = Draw.Toggle('Selection Only', EVENT_NONE, ui_x+9, ui_y+219, 110, 20, EXPORT_SEL_ONLY.val, 'Only export objects in visible selection. Else export whole scene.')
+ EXPORT_ALL_SCENES = Draw.Toggle('All Scenes', EVENT_NONE, ui_x+119, ui_y+219, 110, 20, EXPORT_ALL_SCENES.val, 'Each scene as a separate OBJ file.')
+ EXPORT_ANIMATION = Draw.Toggle('Animation', EVENT_NONE, ui_x+229, ui_y+219, 110, 20, EXPORT_ANIMATION.val, 'Each frame as a numbered OBJ file.')
Draw.EndAlign()
- Draw.Label('Output Options...', ui_x+9, ui_y+159, 220, 20)
+ Draw.Label('Output Options...', ui_x+9, ui_y+189, 220, 20)
Draw.BeginAlign()
- EXPORT_APPLY_MODIFIERS = Draw.Toggle('Apply Modifiers', EVENT_REDRAW, ui_x+9, ui_y+140, 110, 20, EXPORT_APPLY_MODIFIERS.val, 'Use transformed mesh data from each object. May break vert order for morph targets.', do_split)
- EXPORT_ROTX90 = Draw.Toggle('Rotate X90', EVENT_NONE, ui_x+119, ui_y+140, 110, 20, EXPORT_ROTX90.val, 'Rotate on export so Blenders UP is translated into OBJs UP')
- EXPORT_COPY_IMAGES = Draw.Toggle('Copy Images', EVENT_NONE, ui_x+229, ui_y+140, 110, 20, EXPORT_COPY_IMAGES.val, 'Copy image files to the export directory, never overwrite.')
+ EXPORT_APPLY_MODIFIERS = Draw.Toggle('Apply Modifiers', EVENT_REDRAW, ui_x+9, ui_y+170, 110, 20, EXPORT_APPLY_MODIFIERS.val, 'Use transformed mesh data from each object. May break vert order for morph targets.', do_split)
+ EXPORT_ROTX90 = Draw.Toggle('Rotate X90', EVENT_NONE, ui_x+119, ui_y+170, 110, 20, EXPORT_ROTX90.val, 'Rotate on export so Blenders UP is translated into OBJs UP')
+ EXPORT_COPY_IMAGES = Draw.Toggle('Copy Images', EVENT_NONE, ui_x+229, ui_y+170, 110, 20, EXPORT_COPY_IMAGES.val, 'Copy image files to the export directory, never overwrite.')
Draw.EndAlign()
- Draw.Label('Export...', ui_x+9, ui_y+109, 220, 20)
+ Draw.Label('Export...', ui_x+9, ui_y+139, 220, 20)
Draw.BeginAlign()
- EXPORT_EDGES = Draw.Toggle('Edges', EVENT_NONE, ui_x+9, ui_y+90, 50, 20, EXPORT_EDGES.val, 'Edges not connected to faces.')
- EXPORT_TRI = Draw.Toggle('Triangulate', EVENT_NONE, ui_x+59, ui_y+90, 70, 20, EXPORT_TRI.val, 'Triangulate quads.')
+ EXPORT_EDGES = Draw.Toggle('Edges', EVENT_NONE, ui_x+9, ui_y+120, 50, 20, EXPORT_EDGES.val, 'Edges not connected to faces.')
+ EXPORT_TRI = Draw.Toggle('Triangulate', EVENT_NONE, ui_x+59, ui_y+120, 70, 20, EXPORT_TRI.val, 'Triangulate quads.')
Draw.EndAlign()
Draw.BeginAlign()
- EXPORT_MTL = Draw.Toggle('Materials', EVENT_NONE, ui_x+139, ui_y+90, 70, 20, EXPORT_MTL.val, 'Write a separate MTL file with the OBJ.')
- EXPORT_UV = Draw.Toggle('UVs', EVENT_NONE, ui_x+209, ui_y+90, 31, 20, EXPORT_UV.val, 'Export texface UV coords.')
+ EXPORT_MTL = Draw.Toggle('Materials', EVENT_NONE, ui_x+139, ui_y+120, 70, 20, EXPORT_MTL.val, 'Write a separate MTL file with the OBJ.')
+ EXPORT_UV = Draw.Toggle('UVs', EVENT_NONE, ui_x+209, ui_y+120, 31, 20, EXPORT_UV.val, 'Export texface UV coords.')
Draw.EndAlign()
Draw.BeginAlign()
- EXPORT_NORMALS = Draw.Toggle('Normals', EVENT_NONE, ui_x+250, ui_y+90, 59, 20, EXPORT_NORMALS.val, 'Export vertex normal data (Ignored on import).')
- EXPORT_NORMALS_HQ = Draw.Toggle('HQ', EVENT_NONE, ui_x+309, ui_y+90, 31, 20, EXPORT_NORMALS_HQ.val, 'Calculate high quality normals for rendering.')
+ EXPORT_NORMALS = Draw.Toggle('Normals', EVENT_NONE, ui_x+250, ui_y+120, 59, 20, EXPORT_NORMALS.val, 'Export vertex normal data (Ignored on import).')
+ EXPORT_NORMALS_HQ = Draw.Toggle('HQ', EVENT_NONE, ui_x+309, ui_y+120, 31, 20, EXPORT_NORMALS_HQ.val, 'Calculate high quality normals for rendering.')
Draw.EndAlign()
+ EXPORT_POLYGROUPS = Draw.Toggle('Polygroups', EVENT_REDRAW, ui_x+9, ui_y+95, 120, 20, EXPORT_POLYGROUPS.val, 'Export vertex groups as OBJ groups (one group per face approximation).')
Draw.Label('Blender Objects as OBJ:', ui_x+9, ui_y+59, 220, 20)
@@ -727,7 +778,7 @@ def write_ui(filename):
EXPORT_GROUP_BY_OB = EXPORT_GROUP_BY_OB.val
EXPORT_GROUP_BY_MAT = EXPORT_GROUP_BY_MAT.val
EXPORT_KEEP_VERT_ORDER = EXPORT_KEEP_VERT_ORDER.val
-
+ EXPORT_POLYGROUPS = EXPORT_POLYGROUPS.val
base_name, ext = splitExt(filename)
@@ -776,7 +827,8 @@ def write_ui(filename):
EXPORT_NORMALS_HQ, EXPORT_UV, EXPORT_MTL,\
EXPORT_COPY_IMAGES, EXPORT_APPLY_MODIFIERS,\
EXPORT_ROTX90, EXPORT_BLEN_OBS,\
- EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER)
+ EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER,\
+ EXPORT_POLYGROUPS)
Blender.Set('curframe', orig_frame)
diff --git a/release/scripts/help_bpy_api.py b/release/scripts/help_bpy_api.py
index 9c3a24af288..e8d77ed8452 100644
--- a/release/scripts/help_bpy_api.py
+++ b/release/scripts/help_bpy_api.py
@@ -36,6 +36,12 @@ This script opens the user's default web browser at http://www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import Blender, webbrowser
-version = str(int(Blender.Get('version')))
-webbrowser.open('http://www.blender.org/documentation/'+ version +'PythonDoc/')
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ version = str(int(Blender.Get('version')))
+ webbrowser.open('http://www.blender.org/documentation/'+ version +'PythonDoc/')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
diff --git a/release/scripts/help_getting_started.py b/release/scripts/help_getting_started.py
index a4f6da5cc55..77dda2cf88f 100644
--- a/release/scripts/help_getting_started.py
+++ b/release/scripts/help_getting_started.py
@@ -38,5 +38,13 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import Blender, webbrowser
-webbrowser.open('http://www.blender.org/education-help/tutorials/getting-started/')
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ webbrowser.open('http://www.blender.org/education-help/tutorials/getting-started/')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
+
+
diff --git a/release/scripts/help_manual.py b/release/scripts/help_manual.py
index b830975e593..27900040eb4 100644
--- a/release/scripts/help_manual.py
+++ b/release/scripts/help_manual.py
@@ -36,5 +36,13 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import Blender, webbrowser
-webbrowser.open('http://wiki.blender.org/index.php/Manual')
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ webbrowser.open('http://wiki.blender.org/index.php/Manual')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
+
+
diff --git a/release/scripts/help_release_notes.py b/release/scripts/help_release_notes.py
index 919ec72da3c..870f2391487 100644
--- a/release/scripts/help_release_notes.py
+++ b/release/scripts/help_release_notes.py
@@ -36,6 +36,12 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import Blender, webbrowser
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ webbrowser.open('http://www.blender.org/development/release-logs/')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
-webbrowser.open('http://www.blender.org/development/release-logs/')
diff --git a/release/scripts/help_tutorials.py b/release/scripts/help_tutorials.py
index 1fe466560f0..e0cef1abdbf 100644
--- a/release/scripts/help_tutorials.py
+++ b/release/scripts/help_tutorials.py
@@ -37,5 +37,11 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import Blender, webbrowser
-webbrowser.open('http://www.blender.org/education-help/tutorials/')
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ webbrowser.open('http://www.blender.org/education-help/tutorials/')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
diff --git a/release/scripts/help_web_blender.py b/release/scripts/help_web_blender.py
index db0a78d90f7..2a0f90844ae 100644
--- a/release/scripts/help_web_blender.py
+++ b/release/scripts/help_web_blender.py
@@ -38,5 +38,11 @@ www.blender.org.
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import Blender, webbrowser
-webbrowser.open('http://www.blender.org/')
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ webbrowser.open('http://www.blender.org/')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
diff --git a/release/scripts/help_web_devcomm.py b/release/scripts/help_web_devcomm.py
index e04a54501f7..46fa2487a89 100644
--- a/release/scripts/help_web_devcomm.py
+++ b/release/scripts/help_web_devcomm.py
@@ -37,5 +37,11 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import webbrowser
-webbrowser.open('http://www.blender.org/community/get-involved/')
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ webbrowser.open('http://www.blender.org/community/get-involved/')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
diff --git a/release/scripts/help_web_eshop.py b/release/scripts/help_web_eshop.py
index c33849ac419..e40795b3a0d 100644
--- a/release/scripts/help_web_eshop.py
+++ b/release/scripts/help_web_eshop.py
@@ -37,5 +37,11 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import Blender, webbrowser
-webbrowser.open('http://www.blender3d.org/e-shop')
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ webbrowser.open('http://www.blender3d.org/e-shop')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
diff --git a/release/scripts/help_web_usercomm.py b/release/scripts/help_web_usercomm.py
index a77a2bb9fef..dda5e42f34e 100644
--- a/release/scripts/help_web_usercomm.py
+++ b/release/scripts/help_web_usercomm.py
@@ -37,5 +37,11 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
-import webbrowser
-webbrowser.open('http://www.blender.org/community/user-community/')
+import Blender
+try: import webbrowser
+except: webbrowser = None
+
+if webbrowser:
+ webbrowser.open('http://www.blender.org/community/user-community/')
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
diff --git a/release/scripts/image_2d_cutout.py b/release/scripts/image_2d_cutout.py
new file mode 100644
index 00000000000..16d0805256b
--- /dev/null
+++ b/release/scripts/image_2d_cutout.py
@@ -0,0 +1,559 @@
+#!BPY
+
+"""
+Name: '2D Cutout Image Importer'
+Blender: 249
+Group: 'Image'
+Tooltip: 'Batch UV Map images to Planes'
+"""
+
+__author__ = "Kevin Morgan (forTe)"
+__url__ = ("Home page, http://gamulabs.freepgs.com")
+__version__ = "1.2.1"
+__bpydoc__ = """\
+This Script will take an image and
+UV map it to a plane sharing the same width to height ratio as the image.
+Import options allow for the image to be a still or sequence type image
+<br><br>
+Imports can be single images or whole directories of images depending on the chosen
+option.
+"""
+
+####################################################
+#Copyright (C) 2008: Kevin Morgan
+####################################################
+#-------------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 3 of the License, or
+#(at your option) any later version.
+#
+#This program is distributed in the hopes 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, see <http://www.gnu.org/licenses>.
+####################################################
+####################################################
+#V1.0
+#Basic Functionality
+#Published June 28, 2007
+####################################################
+#V1.1
+#Added Support for enabling viewport transparency
+#Added more options to the UI for materials
+#Added Proportionality code (Pixels per unit)
+#Added GPL License Block
+#Published June 29, 2007
+####################################################
+#V1.2
+#Added Support for Copying Existing Materials
+#Import Images as Sequences
+#Refreshed GUI - now with more clutter :(
+#Miscellaneous and Housekeeping
+#Published June 16, 2008
+####################################################
+#V1.2.1
+#Added Extend Texture Mode option at request of a user
+#Published September 24, 2008
+####################################################
+
+import Blender
+from Blender import BGL, Draw, Image, Mesh, Material, Texture, Window
+from Blender.Mathutils import *
+import bpy
+
+# Global Constants
+DIR = 0
+SINGLE = 1
+CUROFFS = 0
+
+# GUI CONSTANTS
+NO_EVT = 0
+SINGLE_IMG = 1
+DIRECTORY_IMG = 2
+CLR_PATH = 3
+CHG_EXT = 4
+EXIT = 5
+DO_SCRIPT = 6
+
+VERSIONSTRING = '1.2.1'
+
+# Note the two parameter dicts could be combined, I just, liked them seperate...
+# GUI Buttons Dict
+GUIPARAMS = {
+ 'Path': Draw.Create(''),
+ 'ImageExt': Draw.Create(''),
+ 'Seq': Draw.Create(0),
+ 'PackImage': Draw.Create(0),
+ 'PPU': Draw.Create(50),
+ 'VPTransp': Draw.Create(1),
+ 'XOff': Draw.Create(0.0),
+ 'YOff': Draw.Create(0.0),
+ 'ZOff': Draw.Create(0.0),
+ 'CopyMat': Draw.Create(0),
+ 'MatId': Draw.Create(0),
+ 'MatCol': Draw.Create(1.0, 0.0, 0.0),
+ 'Ref': Draw.Create(0.8),
+ 'Spec': Draw.Create(0.5),
+ 'Hard': Draw.Create(50),
+ 'Alpha': Draw.Create(1.0),
+ 'ZTransp': Draw.Create(1),
+ 'Shadeless': Draw.Create(0),
+ 'TexChan': Draw.Create(1),
+ 'MPTCol': Draw.Create(1),
+ 'MPTAlpha': Draw.Create(1),
+ 'UseAlpha': Draw.Create(1),
+ 'CalcAlpha': Draw.Create(0),
+ 'ExtendMode': Draw.Create(0),
+ 'AutoRefresh': Draw.Create(0),
+ 'Cyclic': Draw.Create(0),
+ 'Frames': Draw.Create(100),
+ 'Offs': Draw.Create(0),
+ 'StartFr': Draw.Create(1),
+ 'RedrawImp': Draw.Create(0)
+}
+
+# Script Execution Paramaters
+PARAMS = {
+ 'ImagePaths': [], # Path to images to import
+ 'ImportType': SINGLE, # Import a Directory or a Single Image?
+ 'ImageProp': Image.Sources.STILL, # What sources for the image, still or sequence
+ 'PackImage': 0, # Pack the Image(s)?
+ 'PPU': 20, # Pixels Per Blender Unit
+ 'MakeTransp': 1, # Make face transparent in viewport
+
+ 'NewMat': 1, # If true make a new material, otherwise duplicate an existing one, replacing appropriate attributes
+ 'MaterialId': 0, # ID to take from the Materials list upon copy
+ 'Materials': None, # Materials in Scene
+ 'MatProps': {'Col': [1.0, 0.0, 0.0], 'Shadeless': 1, 'Ref': 0.5, 'Spec': 0.5, 'Hard': 200, 'Alpha': 1.0, 'ZTransp': 1},
+
+ 'TexProps': {'UseAlpha': 1, 'CalcAlpha': 0, 'ExtendMode': 0}, # Texture Properties
+ 'TexChannel': 0, # Texture Channel
+ 'TexMapTo': {'Col': 1, 'Alpha': 1}, # Map to Col and/or Alpha
+ 'SeqProps': {'AutoRefresh': 0, 'Cyclic': 0, 'Frames': 100, 'Offs': 0, 'StartFr': 1},
+ 'ObOffset': Vector(1, 0, 0) # Offset by this vector upon creation for multifile import
+}
+
+# Get the Active Scene, of course
+scn = bpy.data.scenes.active
+
+##########################################
+# MAIN SCRIPT FUNCTIONS
+##########################################
+
+def imgImport(imgPath):
+ global CUROFFS, PARAMS
+ ######################################
+ # Load the image
+ ######################################
+ try:
+ img = Image.Load(imgPath)
+ imgDimensions = img.getSize() # do this to ensure the data is available
+ except:
+ Blender.Draw.PupMenu('Error%t|Unsupported image format for "'+ imgPath.split('\\')[-1].split('/')[-1] +'"')
+ return
+
+ if PARAMS['PackImage']:
+ img.pack()
+ name = Blender.sys.makename(imgPath, strip = 1)
+
+ ######################################
+ # Construct the mesh
+ ######################################
+
+ me = Mesh.New(name)
+
+ # Calculate Dimensions from Image Size
+ dim = [float(i)/PARAMS['PPU'] for i in imgDimensions]
+ v = [[dim[0], dim[1], 0], [-dim[0], dim[1], 0], [-dim[0], -dim[1], 0], [dim[0], -dim[1], 0]]
+ me.verts.extend(v)
+ me.faces.extend([0, 1, 2, 3])
+
+ me.faces[0].image = img
+ me.faces[0].uv = [Vector(1.0, 1.0), Vector(0.0, 1.0), Vector(0.0, 0.0), Vector(1.0, 0.0)]
+
+ if PARAMS['MakeTransp']:
+ me.faces[0].transp = Mesh.FaceTranspModes.ALPHA
+
+ ######################################
+ # Modify the Material
+ ######################################
+
+ mat = None
+ if not PARAMS['NewMat']:
+ mat = PARAMS['Materials'][PARAMS['MaterialId']].__copy__()
+ mat.setName(name)
+ else:
+ mat = Material.New(name)
+ properties = PARAMS['MatProps']
+ mat.setRGBCol(properties['Col'])
+ mat.setRef(properties['Ref'])
+ mat.setSpec(properties['Spec'])
+ mat.setHardness(properties['Hard'])
+ mat.setAlpha(properties['Alpha'])
+
+ if properties['Shadeless']:
+ mat.mode |= Material.Modes.SHADELESS
+ if properties['ZTransp']:
+ mat.mode |= Material.Modes.ZTRANSP
+
+ properties = PARAMS['TexProps']
+
+ tex = Texture.New(name)
+ tex.setType('Image')
+ tex.setImage(img)
+ if properties['UseAlpha']:
+ tex.useAlpha = Texture.ImageFlags.USEALPHA
+
+ if properties['CalcAlpha']:
+ tex.calcAlpha = Texture.ImageFlags.CALCALPHA
+
+ if properties['ExtendMode']:
+ tex.setExtend('Extend')
+
+ if PARAMS['ImageProp'] == Image.Sources.SEQUENCE:
+ properties = PARAMS['SeqProps']
+
+ img.source = PARAMS['ImageProp'] # Needs to be done here, otherwise an error with earlier getSize()
+
+ tex.animStart = properties['StartFr']
+ tex.animOffset = properties['Offs']
+ tex.animFrames = properties['Frames']
+ tex.autoRefresh = properties['AutoRefresh']
+ tex.cyclic = properties['Cyclic']
+
+ texMapSetters = Texture.TexCo.UV
+
+ # PARAMS['TexMapTo']['Col'] (and alpha) will either be 0 or 1 because its from a toggle, otherwise this line doesn't work
+ texChanSetters = Texture.MapTo.COL * PARAMS['TexMapTo']['Col'] | Texture.MapTo.ALPHA * PARAMS['TexMapTo']['Alpha']
+
+ mat.setTexture(PARAMS['TexChannel'], tex, texMapSetters, texChanSetters)
+ me.materials += [mat]
+
+ ######################################
+ # Object Construction
+ ######################################
+
+ ob = scn.objects.new(me, name)
+ p = Vector(ob.getLocation()) # Should be the origin, but just to be safe, get it
+ ob.setLocation((CUROFFS * PARAMS['ObOffset']) + p)
+
+ return
+
+def translateParams():
+ # Translates (or assigns for the most part) GUI values to those that can be read by the
+ # Import Function
+
+ global GUIPARAMS, PARAMS
+
+ if GUIPARAMS['Seq'].val and PARAMS['ImportType'] != DIR:
+ PARAMS['ImageProp'] = Image.Sources.SEQUENCE
+
+ PARAMS['PackImage'] = GUIPARAMS['PackImage'].val
+ PARAMS['PPU'] = GUIPARAMS['PPU'].val
+ PARAMS['MakeTransp'] = GUIPARAMS['VPTransp'].val
+ PARAMS['ObOffset'] = Vector(GUIPARAMS['XOff'].val, GUIPARAMS['YOff'].val, GUIPARAMS['ZOff'].val)
+
+ PARAMS['NewMat'] = not GUIPARAMS['CopyMat'].val
+ PARAMS['MaterialId'] = GUIPARAMS['MatId'].val
+ PARAMS['MatProps']['Col'] = list(GUIPARAMS['MatCol'].val)
+ PARAMS['MatProps']['Ref'] = GUIPARAMS['Ref'].val
+ PARAMS['MatProps']['Spec'] = GUIPARAMS['Spec'].val
+ PARAMS['MatProps']['Hard'] = GUIPARAMS['Hard'].val
+ PARAMS['MatProps']['Alpha'] = GUIPARAMS['Alpha'].val
+ PARAMS['MatProps']['ZTransp'] = GUIPARAMS['ZTransp'].val
+ PARAMS['MatProps']['Shadeless'] = GUIPARAMS['Shadeless'].val
+
+ PARAMS['TexChannel'] = GUIPARAMS['TexChan'].val - 1 #Channels are 0-9, but GUI shows 1-10
+ PARAMS['TexProps']['UseAlpha'] = GUIPARAMS['UseAlpha'].val
+ PARAMS['TexProps']['CalcAlpha'] = GUIPARAMS['CalcAlpha'].val
+ PARAMS['TexProps']['ExtendMode'] = GUIPARAMS['ExtendMode'].val
+ PARAMS['TexMapTo']['Col'] = GUIPARAMS['MPTCol'].val
+ PARAMS['TexMapTo']['Alpha'] = GUIPARAMS['MPTAlpha'].val
+
+ PARAMS['SeqProps']['AutoRefresh'] = GUIPARAMS['AutoRefresh'].val
+ PARAMS['SeqProps']['Cyclic'] = GUIPARAMS['Cyclic'].val
+ PARAMS['SeqProps']['Frames'] = GUIPARAMS['Frames'].val
+ PARAMS['SeqProps']['Offs'] = GUIPARAMS['Offs'].val
+ PARAMS['SeqProps']['StartFr'] = GUIPARAMS['StartFr'].val
+ return
+
+def doScript():
+ # Main script Function
+ # Consists of choosing between 2 loops, one with a redraw, one without, see comments for why
+
+ global CUROFFS
+
+ translateParams()
+
+ total = len(PARAMS['ImagePaths'])
+ broken = 0
+
+ if GUIPARAMS['RedrawImp'].val: # Reduces the need to compare on every go through the loop
+ for i, path in enumerate(PARAMS['ImagePaths']):
+ CUROFFS = i # Could be passed to the import Function, but I chose a global instead
+ Window.DrawProgressBar(float(i)/total, "Importing %i of %i Images..." %(i+1, total))
+ imgImport(path)
+ Blender.Redraw()
+ if Blender.Get('version') >= 246:
+ if Window.TestBreak():
+ broken = 1
+ break
+ else:
+ for i, path in enumerate(PARAMS['ImagePaths']):
+ CUROFFS = i
+ Window.DrawProgressBar(float(i)/total, "Importing %i of %i Images..." %(i+1, total))
+ imgImport(path)
+ if Blender.Get('version') >= 246:
+ if Window.TestBreak():
+ broken = 1
+ break
+
+ if broken:
+ Window.DrawProgressBar(1.0, "Script Execution Aborted")
+ else:
+ Window.DrawProgressBar(1.0, "Finished Importing")
+
+ Blender.Redraw() # Force a refresh, since the user may have chosen to not refresh as they go along
+
+ return
+
+##########################################
+# PATH SETTERS AND CHANGERS
+##########################################
+
+def setSinglePath(filename):
+ global GUIPARAMS, PARAMS
+ GUIPARAMS['Path'].val = filename
+ PARAMS['ImagePaths'] = [filename]
+ return
+
+def setDirPath(filename):
+ global GUIPARAMS, PARAMS
+
+ try:
+ import os
+ except:
+ Draw.PupMenu('Full install of python required to be able to set Directory Paths')
+ Draw.Exit()
+ return
+
+ path = os.path.dirname(filename) # Blender.sys.dirname fails on '/'
+ GUIPARAMS['Path'].val = path
+
+ ext_lower = GUIPARAMS['ImageExt'].val.lower()
+ for f in os.listdir(path):
+ if f.lower().endswith(ext_lower):
+ PARAMS['ImagePaths'].append(os.path.join(path, f))
+
+ return
+
+def changeExtension():
+ global GUIPARAMS, PARAMS
+
+ if PARAMS['ImportType'] == SINGLE:
+ return
+
+ try:
+ import os
+ except:
+ Draw.PupMenu('Full install of python required to be able to set Directory Paths')
+ Draw.Exit()
+ return
+
+ PARAMS['ImagePaths'] = []
+
+ ext_lower = GUIPARAMS['ImageExt'].val.lower()
+ for f in os.listdir(GUIPARAMS['Path'].val):
+ if f.lower().endswith(ext_lower):
+ PARAMS['ImagePaths'].append(os.path.join(GUIPARAMS['Path'].val, f))
+
+ return
+
+##########################################
+# INTERFACE FUNCTIONS
+##########################################
+def compileMaterialList():
+ # Pretty straight forward, just grabs the materials in the blend file and constructs
+ # an appropriate string for use as a menu
+
+ mats = [mat for mat in bpy.data.materials]
+ PARAMS['Materials'] = mats
+ title = 'Materials%t|'
+ menStrs = [mat.name + '%x' + str(i) + '|' for i, mat in enumerate(mats)]
+ return title + ''.join(menStrs)
+
+def event(evt, val):
+ # Disabled, since Esc is often used from the file browser
+ #if evt == Draw.ESCKEY:
+ # Draw.Exit()
+
+ return
+
+def bevent(evt):
+ global GUIPARAMS, PARAMS
+
+ if evt == NO_EVT:
+ Draw.Redraw()
+
+ elif evt == SINGLE_IMG:
+ Window.FileSelector(setSinglePath, 'Image', Blender.sys.expandpath('//'))
+ Draw.Redraw()
+ PARAMS['ImportType'] = SINGLE
+
+ elif evt == DIRECTORY_IMG:
+ Window.FileSelector(setDirPath, 'Directory', Blender.sys.expandpath('//'))
+ Draw.Redraw()
+ PARAMS['ImportType'] = DIR
+
+ elif evt == CLR_PATH:
+ GUIPARAMS['Path'].val = ''
+ PARAMS['ImagePaths'] = []
+ GUIPARAMS['ImageExt'].val = ''
+ Draw.Redraw()
+
+ elif evt == CHG_EXT:
+ changeExtension()
+ Draw.Redraw()
+
+ elif evt == EXIT:
+ Draw.Exit()
+
+ elif evt == DO_SCRIPT:
+ doScript()
+
+ else:
+ print "ERROR: UNEXPECTED BUTTON EVENT"
+
+ return
+
+# GUI Colors ######
+ScreenColor = [0.7, 0.7, 0.7]
+BackgroundColor = [0.8, 0.8, 0.8]
+TitleBG = [0.6, 0.6, 0.6]
+TitleCol = [1.0, 1.0, 1.0]
+ErrCol = [1.0, 0.0, 0.0]
+TextCol = [0.4, 0.4, 0.5]
+###################
+
+def GUI():
+ global GUIPARAMS, PARAMS
+
+ BGL.glClearColor(*(ScreenColor + [1.0]))
+ BGL.glClear(BGL.GL_COLOR_BUFFER_BIT)
+
+ minx = 5
+ maxx = 500
+ miny = 5
+ maxy = 450
+
+ lineheight = 24
+ buPad = 5 # Generic Button Padding, most buttons should have 24-19 (or 5) px space around them
+
+ lP = 5 # Left Padding
+ rP = 5 # Right Padding
+
+ # Draw Background Box
+ BGL.glColor3f(*BackgroundColor)
+ BGL.glRecti(minx, miny, maxx, maxy)
+
+ # Draw Title
+ BGL.glColor3f(*TitleBG)
+ BGL.glRecti(minx, maxy - (lineheight), maxx, maxy)
+ BGL.glColor3f(*TitleCol)
+
+ title = "2D Cutout Image Importer v" + VERSIONSTRING
+ BGL.glRasterPos2i(minx + lP, maxy - 15)
+ Draw.Text(title, 'large')
+
+ Draw.PushButton('Exit', EXIT, maxx-50-rP, maxy - lineheight + 2, 50, 19, "Exit Script")
+
+ # Path Buttons
+ if GUIPARAMS['Path'].val == '':
+ Draw.PushButton('Single Image', SINGLE_IMG, minx + lP, maxy - (2*lineheight), 150, 19, "Select a Single Image to Import")
+ Draw.PushButton('Directory', DIRECTORY_IMG, minx + lP + 150, maxy - (2*lineheight), 150, 19, "Select a Directory of Images to Import")
+
+ else:
+ Draw.PushButton('Clear', CLR_PATH, minx+lP, maxy - (2*lineheight), 50, 19, "Clear Path and Change Import Options")
+
+ GUIPARAMS['Path'] = Draw.String('Path: ', NO_EVT, minx + lP, maxy - (3*lineheight), (maxx-minx-lP-rP), 19, GUIPARAMS['Path'].val, 399, 'Path to Import From')
+ if PARAMS['ImportType'] == DIR:
+ GUIPARAMS['ImageExt'] = Draw.String('Image Ext: ', CHG_EXT, minx + lP, maxy - (4*lineheight), 110, 19, GUIPARAMS['ImageExt'].val, 6, 'Image extension for batch directory importing (case insensitive)')
+ GUIPARAMS['PackImage'] = Draw.Toggle('Pack', NO_EVT, maxx - rP - 50, maxy - (4*lineheight), 50, 19, GUIPARAMS['PackImage'].val, 'Pack Image(s) into .Blend File')
+
+ # Geometry and Viewport Options
+ BGL.glColor3f(*TextCol)
+ BGL.glRecti(minx+lP, maxy - (5*lineheight), maxx-rP, maxy - (5*lineheight) + 1)
+ BGL.glRasterPos2i(minx + lP, maxy-(5*lineheight) + 3)
+ Draw.Text('Geometry and Display Options', 'small')
+
+ GUIPARAMS['PPU'] = Draw.Slider('Pixels Per Unit: ', NO_EVT, minx + lP, maxy - (6*lineheight), (maxx-minx)/2 - lP, 19, GUIPARAMS['PPU'].val, 1, 5000, 0, 'Set the Number of Pixels Per Blender Unit to preserve Image Size Relations')
+ GUIPARAMS['VPTransp'] = Draw.Toggle('Viewport Transparency', NO_EVT, minx + lP, maxy - (8*lineheight), (maxx-minx)/2 - lP, 2*lineheight - buPad, GUIPARAMS['VPTransp'].val, 'Display Alpha Transparency in the Viewport')
+
+ GUIPARAMS['XOff'] = Draw.Slider('Offs X: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (6*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['XOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the X-Direction if Importing Multiple Images')
+ GUIPARAMS['YOff'] = Draw.Slider('Offs Y: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (7*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['YOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the Y-Direction if Importing Multiple Images')
+ GUIPARAMS['ZOff'] = Draw.Slider('Offs Z: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (8*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['ZOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the Z-Direction if Importing Multiple Images')
+
+ # Material and Texture Options
+ BGL.glColor3f(*TextCol)
+ BGL.glRecti(minx+lP, maxy - (9*lineheight), maxx-rP, maxy - (9*lineheight) + 1)
+ BGL.glRasterPos2i(minx + lP, maxy-(9*lineheight) + 3)
+ Draw.Text('Material and Texture Options', 'small')
+
+ half = (maxx-minx-lP-rP)/2
+ GUIPARAMS['CopyMat'] = Draw.Toggle('Copy Existing Material', NO_EVT, minx + lP, maxy-(10*lineheight), half, 19, GUIPARAMS['CopyMat'].val, 'Copy an Existing Material')
+ if GUIPARAMS['CopyMat'].val:
+ menStr = compileMaterialList()
+ GUIPARAMS['MatId'] = Draw.Menu(menStr, NO_EVT, minx + lP, maxy - (11*lineheight), half, 19, GUIPARAMS['MatId'].val, 'Material to Copy Settings From')
+ else:
+ GUIPARAMS['MatCol'] = Draw.ColorPicker(NO_EVT, minx+lP, maxy - (13*lineheight), 40, (3*lineheight) - buPad, GUIPARAMS['MatCol'].val, 'Color of Newly Created Material')
+ GUIPARAMS['Ref'] = Draw.Slider('Ref: ', NO_EVT, minx +lP+45, maxy - (11*lineheight), half-45, 19, GUIPARAMS['Ref'].val, 0.0, 1.0, 0, 'Set the Ref Value for Created Materials')
+ GUIPARAMS['Spec'] = Draw.Slider('Spec: ', NO_EVT, minx +lP+45, maxy - (12*lineheight), half-45, 19, GUIPARAMS['Spec'].val, 0.0, 2.0, 0, 'Set the Spec Value for Created Materials')
+ GUIPARAMS['Hard'] = Draw.Slider('Hard: ', NO_EVT, minx +lP+45, maxy - (13*lineheight), half-45, 19, GUIPARAMS['Hard'].val, 1, 500, 0, 'Set the Hardness Value for Created Materials')
+ GUIPARAMS['Alpha'] = Draw.Slider('A: ', NO_EVT, minx +lP, maxy - (14*lineheight), half, 19, GUIPARAMS['Alpha'].val, 0.0, 1.0, 0, 'Set the Alpha Value for Created Materials')
+
+ GUIPARAMS['ZTransp'] = Draw.Toggle('ZTransparency', NO_EVT, minx + lP, maxy - (15*lineheight), half, 19, GUIPARAMS['ZTransp'].val, 'Enable ZTransparency')
+ GUIPARAMS['Shadeless'] = Draw.Toggle('Shadeless', NO_EVT, minx + lP, maxy - (16*lineheight), half, 19, GUIPARAMS['Shadeless'].val, 'Enable Shadeless')
+
+ GUIPARAMS['TexChan'] = Draw.Number('Texture Channel: ', NO_EVT, minx + lP+ half + buPad, maxy - (10*lineheight), half-rP, 19, GUIPARAMS['TexChan'].val, 1, 10, 'Texture Channel for Image Texture')
+
+ GUIPARAMS['MPTCol'] = Draw.Toggle('Color', NO_EVT, minx + lP + half + buPad, maxy - (11*lineheight), half/2, 19, GUIPARAMS['MPTCol'].val, 'Map To Color Channel')
+ GUIPARAMS['MPTAlpha'] = Draw.Toggle('Alpha', NO_EVT, minx + lP + int((1.5)*half) + buPad, maxy - (11*lineheight), half/2 - rP, 19, GUIPARAMS['MPTAlpha'].val, 'Map To Alpha Channel')
+
+ third = int((maxx-minx-lP-rP)/6)
+ GUIPARAMS['UseAlpha'] = Draw.Toggle('Use Alpha', NO_EVT, minx + lP + half + buPad, maxy - (12*lineheight), third, 19, GUIPARAMS['UseAlpha'].val, "Use the Images' Alpha Values")
+ GUIPARAMS['CalcAlpha'] = Draw.Toggle('Calc Alpha', NO_EVT, minx + lP + half + third + buPad, maxy - (12*lineheight), third, 19, GUIPARAMS['CalcAlpha'].val, "Calculate Images' Alpha Values")
+ GUIPARAMS['ExtendMode'] = Draw.Toggle('Extend', NO_EVT, minx+lP+half+third+third+buPad, maxy - (12*lineheight), third-3, 19, GUIPARAMS['ExtendMode'].val, "Use Extend texture mode. If deselected, Repeat is used")
+ GUIPARAMS['Seq'] = Draw.Toggle('Sequence', NO_EVT, minx + lP + half + buPad, maxy - (13*lineheight), half-rP, 19, GUIPARAMS['Seq'].val, 'Set the Image(s) to use a Sequence instead of a Still')
+
+ if GUIPARAMS['Seq'].val and not PARAMS['ImportType'] == DIR:
+ GUIPARAMS['AutoRefresh'] = Draw.Toggle('Auto Refresh', NO_EVT, minx + lP + half + buPad, maxy - (14*lineheight), half/2, 19, GUIPARAMS['AutoRefresh'].val, 'Use Auto Refresh')
+ GUIPARAMS['Cyclic'] = Draw.Toggle('Cyclic', NO_EVT, minx + lP + half + buPad + half/2, maxy - (14*lineheight), half/2 - rP, 19, GUIPARAMS['Cyclic'].val, 'Repeat Frames Cyclically`')
+
+ GUIPARAMS['Frames'] = Draw.Number('Frames: ', NO_EVT, minx +lP + half + buPad, maxy - (15*lineheight), half - rP, 19, GUIPARAMS['Frames'].val, 1, 30000, 'Sets the Number of Images of a Movie to Use')
+ GUIPARAMS['Offs'] = Draw.Number('Offs: ', NO_EVT, minx +lP + half + buPad, maxy - (16*lineheight), half/2, 19, GUIPARAMS['Offs'].val, -30000, 30000, 'Offsets the Number of the Frame to use in the Animation')
+ GUIPARAMS['StartFr'] = Draw.Number('StartFr: ', NO_EVT, minx +lP + half + buPad + half/2, maxy - (16*lineheight), half/2 - rP, 19, GUIPARAMS['StartFr'].val, 1, 30000, 'Sets the Global Starting Frame of the Movie')
+ elif GUIPARAMS['Seq'].val and PARAMS['ImportType'] == DIR:
+ BGL.glColor3f(*ErrCol)
+ BGL.glRasterPos2i(minx + lP + half + buPad + 7, maxy-(14 * lineheight) + 5)
+ Draw.Text('Sequence only available for Single Image Import', 'small')
+
+ # Import Options
+ BGL.glColor3f(*TextCol)
+ BGL.glRecti(minx+lP, maxy - (17*lineheight), maxx-rP, maxy - (17*lineheight) + 1)
+ BGL.glRasterPos2i(minx + lP, maxy-(17*lineheight) + 3)
+ Draw.Text('Import', 'small')
+
+ if GUIPARAMS['Path'].val and GUIPARAMS['ImageExt'].val or GUIPARAMS['Path'].val and PARAMS['ImportType'] == SINGLE:
+ Draw.PushButton('Import', DO_SCRIPT, minx + lP, maxy - (18*lineheight), 75, 19, "Import Image(s)")
+ else:
+ BGL.glColor3f(*ErrCol)
+ BGL.glRasterPos2i(minx+lP, maxy - (18*lineheight) + 5)
+ Draw.Text('A path and image type must be specified to import images')
+
+ GUIPARAMS['RedrawImp'] = Draw.Toggle('Redraw During Import', NO_EVT, maxx - rP - 150, maxy - (18*lineheight), 150, 19, GUIPARAMS['RedrawImp'].val, 'Redraw the View as Images Import')
+
+Draw.Register(GUI, event, bevent) \ No newline at end of file
diff --git a/release/scripts/import_dxf.py b/release/scripts/import_dxf.py
index ceb4dd56722..36a1a048075 100644
--- a/release/scripts/import_dxf.py
+++ b/release/scripts/import_dxf.py
@@ -2,12 +2,12 @@
"""
Name: 'Autodesk DXF (.dxf .dwg)'
-Blender: 246
+Blender: 249
Group: 'Import'
Tooltip: 'Import for DWG/DXF geometry data.'
"""
__author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)'
-__version__ = '1.12 - 2009.04.11 by migius'
+__version__ = '1.12 - 2009.05.27 by migius'
__url__ = ["http://blenderartists.org/forum/showthread.php?t=84319",
"http://wiki.blender.org/index.php/Scripts/Manual/Import/DXF-3D"]
__email__ = ["migius(at)4d-vectors.de","Kitsune_e(at)yahoo.com"]
@@ -44,8 +44,8 @@ Supported DXF>r12 objects:
ELLIPSE,
LWPOLYLINE (LightWeight Polyline),
SPLINE,
-(wip v1.13) MLINE,
-(wip v1.13) MTEXT
+(todo v1.13) MLINE,
+(todo v1.13) MTEXT
Unsupported objects:
DXF r12: DIMENSION.
@@ -74,7 +74,7 @@ thickness,
width,
color,
layer,
-(wip v1.13: XDATA, grouped status)
+(todo v1.13: XDATA, grouped status)
It is recommended to use DXF-object properties for assign Blender materials.
Notes:
@@ -111,7 +111,11 @@ History:
-- support DXF-definitions of scene, lights and cameras
-- support ortho mode for VIEWs and VPORTs as cameras
-
+ v1.12 - 2009.05.27 by migius
+ d6 todo: bugfix negative scaled INSERTs - isLeftHand(Matrix) check
+ v1.12 - 2009.05.26 by migius
+ d5 changed to the new 2.49 method Vector.cross()
+ d5 bugfix WORLDY(1,1,0) to (0,1,0)
v1.12 - 2009.04.11 by migius
d4 added DWG support, Stani Michiels idea for binding an extern DXF-DWG-converter
v1.12 - 2009.03.14 by migius
@@ -309,7 +313,7 @@ History:
import Blender
from Blender import Mathutils, BezTriple, Draw, Registry, sys,\
-Text3d, Window, Mesh, Material, Group
+Text3d, Window, Mesh, Material, Group, Curve
#from Blender.Mathutils import Vector, Matrix
#import bpy #not used yet
#import BPyMessages
@@ -343,14 +347,12 @@ if os.name != 'mac':
except ImportError:
print 'psyco not imported'
-#try: Curve.orderU
-
print '\n\n\n'
print 'DXF/DWG-Importer v%s *** start ***' %(__version__) #---------------------
SCENE = None
WORLDX = Mathutils.Vector((1,0,0))
-WORLDY = Mathutils.Vector((1,1,0))
+WORLDY = Mathutils.Vector((0,1,0))
WORLDZ = Mathutils.Vector((0,0,1))
G_SCALE = 1.0 #(0.0001-1000) global scaling factor for all dxf data
@@ -375,7 +377,7 @@ GROUP_BYLAYER = 0 #(0/1) all entities from same layer import into one blender-
LAYER_DEF_NAME = 'AAAA' #default layer name
LAYER_DEF_COLOR = 4 #default layer color
E_M = 0
-LAB = "*) parts under construction"
+LAB = ". wip .. todo" #"*) parts under construction"
M_OBJ = 0
FILENAME_MAX = 180 #max length of path+file_name string (FILE_MAXDIR + FILE_MAXFILE)
@@ -392,7 +394,20 @@ ALIGN = BezTriple.HandleTypes.ALIGN
UI_MODE = True #activates UI-popup-print, if not multiple files imported
-
+#---- migration to 2.49-------------------------------------------------
+if 'cross' in dir(Mathutils.Vector()):
+ #Draw.PupMenu('DXF exporter: Abort%t|This script version works for Blender up 2.49 only!')
+ def M_CrossVecs(v1,v2):
+ return v1.cross(v2) #for up2.49
+ def M_DotVecs(v1,v2):
+ return v1.dot(v2) #for up2.49
+else:
+ def M_CrossVecs(v1,v2):
+ return Mathutils.CrossVecs(v1,v2) #for pre2.49
+ def M_DotVecs(v1,v2):
+ return Mathutils.DotVecs(v1,v2) #for pre2.49
+
+
#-------- DWG support ------------------------------------------
extCONV_OK = True
extCONV = 'DConvertCon.exe'
@@ -2237,7 +2252,6 @@ class LWpolyline(Polyline): #--------------------------------------------------
self.spline = False
self.curved = False
-
#print 'deb:LWpolyline.obj.data:\n', obj.data #------------------------
#print 'deb:LWpolyline.ENDinit:----------------' #------------------------
@@ -4419,11 +4433,11 @@ def getOCS(az): #--------------------------------------------------------------
cap = 0.015625 # square polar cap value (1/64.0)
if abs(az.x) < cap and abs(az.y) < cap:
- ax = Mathutils.CrossVecs(WORLDY, az)
+ ax = M_CrossVecs(WORLDY,az)
else:
- ax = Mathutils.CrossVecs(WORLDZ, az)
+ ax = M_CrossVecs(WORLDZ,az)
ax = ax.normalize()
- ay = Mathutils.CrossVecs(az, ax)
+ ay = M_CrossVecs(az, ax)
ay = ay.normalize()
return ax, ay, az
@@ -5166,17 +5180,17 @@ GUI_B = {} # GUI-buttons dictionary for drawingTypes
# settings default, initialize ------------------------
-points_as_menu = "convert to: %t|empty %x1|mesh.vertex %x2|thin sphere %x3|thin box %x4|*curve.vertex %x5"
-lines_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|thin box %x4|Bezier-curve %x5|*NURBS-curve %x6"
-mlines_as_menu = "convert to: %t|*edge %x1|*mesh %x2|*thin cylinder %x3|*thin box %x|*curve %x5"
-plines_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|*thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
-splines_as_menu = "convert to: %t|mesh %x2|*thin cylinder %x3|*thin box %x4|*Bezier-curve %x5|NURBS-curve %x6"
-plines3_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|*thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
-plmesh_as_menu = "convert to: %t|*edge %x1|mesh %x2|*NURBS-surface %x6"
-solids_as_menu = "convert to: %t|*edge %x1|mesh %x2"
-blocks_as_menu = "convert to: %t|dupliGroup %x1|*real.Group %x2|*exploded %x3"
-texts_as_menu = "convert to: %t|text %x1|*mesh %x2|*curve %x5"
-material_from_menu= "material from: %t|*LINESTYLE %x7|COLOR %x1|LAYER %x2|*LAYER+COLOR %x3|*BLOCK %x4|*XDATA %x5|*INI-File %x6"
+points_as_menu = "convert to: %t|empty %x1|mesh.vertex %x2|thin sphere %x3|thin box %x4|..curve.vertex %x5"
+lines_as_menu = "convert to: %t|..edge %x1|mesh %x2|..thin cylinder %x3|thin box %x4|Bezier-curve %x5|..NURBS-curve %x6"
+mlines_as_menu = "convert to: %t|..edge %x1|..mesh %x2|..thin cylinder %x3|..thin box %x|..curve %x5"
+plines_as_menu = "convert to: %t|..edge %x1|mesh %x2|..thin cylinder %x3|..thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
+splines_as_menu = "convert to: %t|mesh %x2|..thin cylinder %x3|..thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
+plines3_as_menu = "convert to: %t|..edge %x1|mesh %x2|..thin cylinder %x3|..thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
+plmesh_as_menu = "convert to: %t|..edge %x1|mesh %x2|..NURBS-surface %x6"
+solids_as_menu = "convert to: %t|..edge %x1|mesh %x2"
+blocks_as_menu = "convert to: %t|dupliGroup %x1|..real.Group %x2|..exploded %x3"
+texts_as_menu = "convert to: %t|text %x1|..mesh %x2|..curve %x5"
+material_from_menu= "material from: %t|..LINESTYLE %x7|COLOR %x1|LAYER %x2|..LAYER+COLOR %x3|..BLOCK %x4|..XDATA %x5|..INI-File %x6"
g_scale_list = ''.join((
'scale factor: %t',
'|user def. %x12',
@@ -5662,7 +5676,7 @@ def draw_UI(): #---------------------------------------------------------------
y -= 20
Draw.BeginAlign()
- GUI_B['mline'] = Draw.Toggle('*MLINE', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['mline'].val, "(*wip)support dxf-MLINE on/off")
+ GUI_B['mline'] = Draw.Toggle('..MLINE', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['mline'].val, "(*todo)support dxf-MLINE on/off")
if GUI_B['mline'].val:
GUI_A['mlines_as'] = Draw.Menu(mlines_as_menu, EVENT_NONE, but1c, y, but_1c, 20, GUI_A['mlines_as'].val, "select target Blender-object")
Draw.EndAlign()
@@ -5713,7 +5727,7 @@ def draw_UI(): #---------------------------------------------------------------
y -= 20
GUI_B['text'] = Draw.Toggle('TEXT', EVENT_NONE, b0, y, b0_, 20, GUI_B['text'].val, "support dxf-TEXT on/off")
- GUI_B['mtext'] = Draw.Toggle('*MTEXT', EVENT_NONE, b1, y, b1_, 20, GUI_B['mtext'].val, "(*wip)support dxf-MTEXT on/off")
+ GUI_B['mtext'] = Draw.Toggle('..MTEXT', EVENT_NONE, b1, y, b1_, 20, GUI_B['mtext'].val, "(*todo)support dxf-MTEXT on/off")
# GUI_A['texts_as'] = Draw.Menu(texts_as_menu, EVENT_NONE, but3c, y, but_3c, 20, GUI_A['texts_as'].val, "select target Blender-object")
y -= 20
@@ -5732,8 +5746,8 @@ def draw_UI(): #---------------------------------------------------------------
Draw.BeginAlign()
GUI_A['views_on'] = Draw.Toggle('views', EVENT_NONE, b0, y, b0_-25, 20, GUI_A['views_on'].val, "imports VIEWs and VIEWPORTs as cameras on/off")
- GUI_A['cams_on'] = Draw.Toggle('*cams', EVENT_NONE, b1-25, y, b1_-25, 20, GUI_A['cams_on'].val, "(*wip) support ASHADE cameras on/off")
- GUI_A['lights_on'] = Draw.Toggle('*lights', EVENT_NONE, b1+25, y, b1_-25, 20, GUI_A['lights_on'].val, "(*wip) support AVE_RENDER lights on/off")
+ GUI_A['cams_on'] = Draw.Toggle('..cams', EVENT_NONE, b1-25, y, b1_-25, 20, GUI_A['cams_on'].val, "(*todo) support ASHADE cameras on/off")
+ GUI_A['lights_on'] = Draw.Toggle('..lights', EVENT_NONE, b1+25, y, b1_-25, 20, GUI_A['lights_on'].val, "(*todo) support AVE_RENDER lights on/off")
Draw.EndAlign()
@@ -5749,10 +5763,10 @@ def draw_UI(): #---------------------------------------------------------------
Draw.BeginAlign()
GUI_A['paper_space_on'] = Draw.Toggle('paper', EVENT_NONE, b0+but_*0, y, but_, 20, GUI_A['paper_space_on'].val, "import only from Paper-Space on/off")
GUI_A['layFrozen_on'] = Draw.Toggle ('frozen', EVENT_NONE, b0+but_*1, y, but_, 20, GUI_A['layFrozen_on'].val, "import also from frozen LAYERs on/off")
- GUI_A['layerFilter_on'] = Draw.Toggle('layer', EVENT_NONE, b0+but_*2, y, but_, 20, GUI_A['layerFilter_on'].val, "(*wip) LAYER filtering on/off")
- GUI_A['colorFilter_on'] = Draw.Toggle('color', EVENT_NONE, b0+but_*3, y, but_, 20, GUI_A['colorFilter_on'].val, "(*wip) COLOR filtering on/off")
- GUI_A['groupFilter_on'] = Draw.Toggle('group', EVENT_NONE, b0+but_*4, y, but_, 20, GUI_A['groupFilter_on'].val, "(*wip) GROUP filtering on/off")
- GUI_A['blockFilter_on'] = Draw.Toggle('block', EVENT_NONE, b0+but_*5, y, but_, 20, GUI_A['blockFilter_on'].val, "(*wip) BLOCK filtering on/off")
+ GUI_A['layerFilter_on'] = Draw.Toggle('..layer', EVENT_NONE, b0+but_*2, y, but_, 20, GUI_A['layerFilter_on'].val, "(*todo) LAYER filtering on/off")
+ GUI_A['colorFilter_on'] = Draw.Toggle('..color', EVENT_NONE, b0+but_*3, y, but_, 20, GUI_A['colorFilter_on'].val, "(*todo) COLOR filtering on/off")
+ GUI_A['groupFilter_on'] = Draw.Toggle('..group', EVENT_NONE, b0+but_*4, y, but_, 20, GUI_A['groupFilter_on'].val, "(*todo) GROUP filtering on/off")
+ GUI_A['blockFilter_on'] = Draw.Toggle('..block', EVENT_NONE, b0+but_*5, y, but_, 20, GUI_A['blockFilter_on'].val, "(*todo) BLOCK filtering on/off")
#GUI_A['dummy_on'] = Draw.Toggle('-', EVENT_NONE, but3c, y, but_3c, 20, GUI_A['dummy_on'].val, "dummy on/off")
Draw.EndAlign()
@@ -5853,7 +5867,7 @@ def draw_UI(): #---------------------------------------------------------------
y -= 10
y -= 20
Draw.BeginAlign()
- GUI_A['Z_force_on'] = Draw.Toggle('*elevation', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['Z_force_on'].val, "*set objects Z-coordinates to elevation on/off")
+ GUI_A['Z_force_on'] = Draw.Toggle('.elevation', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['Z_force_on'].val, ".set objects Z-coordinates to elevation on/off")
if GUI_A['Z_force_on'].val:
GUI_A['Z_elev'] = Draw.Number('', EVENT_NONE, b1, y, b1_, 20, GUI_A['Z_elev'].val, -1000, 1000, "set default elevation(Z-coordinate)")
Draw.EndAlign()
@@ -6155,6 +6169,7 @@ def multi_import(DIR):
if __name__ == "__main__":
+ #Draw.PupMenu('DXF importer: Abort%t|This script version works for Blender up 2.49 only!')
UI_MODE = True
# recall last used DXF-file and INI-file names
dxffilename = check_RegistryKey('dxfFileName')
diff --git a/release/scripts/import_obj.py b/release/scripts/import_obj.py
index 493354601a6..31501173fda 100644
--- a/release/scripts/import_obj.py
+++ b/release/scripts/import_obj.py
@@ -7,9 +7,9 @@ Group: 'Import'
Tooltip: 'Load a Wavefront OBJ File, Shift: batch import all dir.'
"""
-__author__= "Campbell Barton", "Jiri Hnidek"
+__author__= "Campbell Barton", "Jiri Hnidek", "Paolo Ciccone"
__url__= ['http://wiki.blender.org/index.php/Scripts/Manual/Import/wavefront_obj', 'blender.org', 'blenderartists.org']
-__version__= "2.1"
+__version__= "2.11"
__bpydoc__= """\
This script imports a Wavefront OBJ files to Blender.
@@ -49,7 +49,6 @@ import BPyMessages
try: import os
except: os= False
-
# Generic path functions
def stripFile(path):
'''Return directory, where the file is'''
@@ -320,7 +319,7 @@ def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP,
return [(value[0], value[1], value[2], key_to_name(key)) for key, value in face_split_dict.iteritems()]
-def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, verts_tex, faces, unique_materials, unique_material_images, unique_smooth_groups, dataname):
+def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, verts_tex, faces, unique_materials, unique_material_images, unique_smooth_groups, vertex_groups, dataname):
'''
Takes all the data gathered and generates a mesh, adding the new object to new_objects
deals with fgons, sharp edges and assigning materials
@@ -530,6 +529,13 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l
ob= scn.objects.new(me)
new_objects.append(ob)
+ # Create the vertex groups. No need to have the flag passed here since we test for the
+ # content of the vertex_groups. If the user selects to NOT have vertex groups saved then
+ # the following test will never run
+ for group_name, group_indicies in vertex_groups.iteritems():
+ me.addVertGroup(group_name)
+ me.assignVertsToGroup(group_name, group_indicies,1.00, Mesh.AssignModes.REPLACE)
+
def get_float_func(filepath):
'''
find the float function for this obj file
@@ -547,7 +553,16 @@ def get_float_func(filepath):
# incase all vert values were ints
return float
-def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True, CREATE_SMOOTH_GROUPS= True, CREATE_EDGES= True, SPLIT_OBJECTS= True, SPLIT_GROUPS= True, SPLIT_MATERIALS= True, IMAGE_SEARCH=True):
+def load_obj(filepath,
+ CLAMP_SIZE= 0.0,
+ CREATE_FGONS= True,
+ CREATE_SMOOTH_GROUPS= True,
+ CREATE_EDGES= True,
+ SPLIT_OBJECTS= True,
+ SPLIT_GROUPS= True,
+ SPLIT_MATERIALS= True,
+ IMAGE_SEARCH=True,
+ POLYGROUPS=False):
'''
Called by the user interface or another script.
load_obj(path) - should give acceptable results.
@@ -556,13 +571,16 @@ def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True, CREATE_SMOOTH_GROUPS
'''
print '\nimporting obj "%s"' % filepath
+ if SPLIT_OBJECTS or SPLIT_GROUPS or SPLIT_MATERIALS:
+ POLYGROUPS = False
+
time_main= sys.time()
verts_loc= []
verts_tex= []
faces= [] # tuples of the faces
material_libs= [] # filanems to material libs this uses
-
+ vertex_groups = {} # when POLYGROUPS is true
# Get the string to float conversion func for this file- is 'float' for almost all files.
float_func= get_float_func(filepath)
@@ -571,7 +589,8 @@ def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True, CREATE_SMOOTH_GROUPS
context_material= None
context_smooth_group= None
context_object= None
-
+ context_vgroup = None
+
has_ngons= False
# has_smoothgroups= False - is explicit with len(unique_smooth_groups) being > 0
@@ -587,8 +606,9 @@ def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True, CREATE_SMOOTH_GROUPS
# so we need to know weather
multi_line_face= False
- print '\tpassing obj file "%s"...' % filepath,
+ print '\tparsing obj file "%s"...' % filepath,
time_sub= sys.time()
+
file= open(filepath, 'rU')
for line in file: #.xreadlines():
line = line.lstrip() # rare cases there is white space at the start of the line
@@ -641,6 +661,10 @@ def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True, CREATE_SMOOTH_GROUPS
obj_vert= v.split('/')
vert_loc_index= int(obj_vert[0])-1
+ # Add the vertex to the current group
+ # *warning*, this wont work for files that have groups defined around verts
+ if POLYGROUPS and context_vgroup:
+ vertex_groups[context_vgroup].append(vert_loc_index)
# Make relative negative vert indicies absolute
if vert_loc_index < 0:
@@ -684,6 +708,12 @@ def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True, CREATE_SMOOTH_GROUPS
context_object= line_value(line.split())
# print 'context_object', context_object
# unique_obects[context_object]= None
+ elif POLYGROUPS:
+ context_vgroup = line_value(line.split())
+ if context_vgroup and context_vgroup != '(null)':
+ vertex_groups.setdefault(context_vgroup, [])
+ else:
+ context_vgroup = None # dont assign a vgroup
elif line.startswith('usemtl'):
context_material= line_value(line.split())
@@ -721,8 +751,8 @@ def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True, CREATE_SMOOTH_GROUPS
else: SPLIT_OB_OR_GROUP = False
for verts_loc_split, faces_split, unique_materials_split, dataname in split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP, SPLIT_MATERIALS):
- # Create meshes from the data
- create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc_split, verts_tex, faces_split, unique_materials_split, unique_material_images, unique_smooth_groups, dataname)
+ # Create meshes from the data, warning 'vertex_groups' wont support splitting
+ create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc_split, verts_tex, faces_split, unique_materials_split, unique_material_images, unique_smooth_groups, vertex_groups, dataname)
axis_min= [ 1000000000]*3
axis_max= [-1000000000]*3
@@ -758,7 +788,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
if BPyMessages.Error_NoFile(filepath):
return
- global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, KEEP_VERT_ORDER
+ global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, POLYGROUPS, KEEP_VERT_ORDER
CREATE_SMOOTH_GROUPS= Draw.Create(0)
CREATE_FGONS= Draw.Create(1)
@@ -768,6 +798,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
SPLIT_MATERIALS= Draw.Create(0)
CLAMP_SIZE= Draw.Create(10.0)
IMAGE_SEARCH= Draw.Create(1)
+ POLYGROUPS= Draw.Create(0)
KEEP_VERT_ORDER= Draw.Create(1)
@@ -817,9 +848,10 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
GLOBALS['EVENT'] = e
def do_split(e,v):
- global SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, KEEP_VERT_ORDER
+ global SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, KEEP_VERT_ORDER, POLYGROUPS
if SPLIT_OBJECTS.val or SPLIT_GROUPS.val or SPLIT_MATERIALS.val:
KEEP_VERT_ORDER.val = 0
+ POLYGROUPS.val = 0
else:
KEEP_VERT_ORDER.val = 1
@@ -831,6 +863,11 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
if not (SPLIT_OBJECTS.val or SPLIT_GROUPS.val or SPLIT_MATERIALS.val):
KEEP_VERT_ORDER.val = 1
+ def do_polygroups(e,v):
+ global SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, KEEP_VERT_ORDER, POLYGROUPS
+ if POLYGROUPS.val:
+ SPLIT_OBJECTS.val = SPLIT_GROUPS.val = SPLIT_MATERIALS.val = 0
+
def do_help(e,v):
url = __url__[0]
print 'Trying to open web browser with documentation at this address...'
@@ -849,7 +886,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
ui_x -= 165
ui_y -= 90
- global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, KEEP_VERT_ORDER
+ global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, POLYGROUPS, KEEP_VERT_ORDER
Draw.Label('Import...', ui_x+9, ui_y+159, 220, 21)
Draw.BeginAlign()
@@ -869,8 +906,9 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
KEEP_VERT_ORDER = Draw.Toggle('Keep Vert Order', EVENT_REDRAW, ui_x+229, ui_y+89, 110, 21, KEEP_VERT_ORDER.val, 'Keep vert and face order, disables split options, enable for morph targets', do_vertorder)
Draw.Label('Options...', ui_x+9, ui_y+60, 211, 20)
- CLAMP_SIZE = Draw.Number('Clamp Scale: ', EVENT_NONE, ui_x+9, ui_y+39, 211, 21, CLAMP_SIZE.val, 0.0, 1000.0, 'Clamp the size to this maximum (Zero to Disable)')
- IMAGE_SEARCH = Draw.Toggle('Image Search', EVENT_NONE, ui_x+229, ui_y+39, 110, 21, IMAGE_SEARCH.val, 'Search subdirs for any assosiated images (Warning, may be slow)')
+ CLAMP_SIZE = Draw.Number('Clamp Scale: ', EVENT_NONE, ui_x+9, ui_y+39, 130, 21, CLAMP_SIZE.val, 0.0, 1000.0, 'Clamp the size to this maximum (Zero to Disable)')
+ POLYGROUPS = Draw.Toggle('Poly Groups', EVENT_REDRAW, ui_x+144, ui_y+39, 90, 21, POLYGROUPS.val, 'Import OBJ groups as vertex groups.', do_polygroups)
+ IMAGE_SEARCH = Draw.Toggle('Image Search', EVENT_NONE, ui_x+239, ui_y+39, 100, 21, IMAGE_SEARCH.val, 'Search subdirs for any assosiated images (Warning, may be slow)')
Draw.BeginAlign()
Draw.PushButton('Online Help', EVENT_REDRAW, ui_x+9, ui_y+9, 110, 21, 'Load the wiki page for this script', do_help)
Draw.PushButton('Cancel', EVENT_EXIT, ui_x+119, ui_y+9, 110, 21, '', obj_ui_set_event)
@@ -921,6 +959,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
SPLIT_GROUPS.val,\
SPLIT_MATERIALS.val,\
IMAGE_SEARCH.val,\
+ POLYGROUPS.val
)
else: # Normal load
@@ -933,6 +972,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
SPLIT_GROUPS.val,\
SPLIT_MATERIALS.val,\
IMAGE_SEARCH.val,\
+ POLYGROUPS.val
)
Window.WaitCursor(0)
diff --git a/release/scripts/import_web3d.py b/release/scripts/import_web3d.py
index fc3b5262376..a5547506dc7 100644
--- a/release/scripts/import_web3d.py
+++ b/release/scripts/import_web3d.py
@@ -85,7 +85,7 @@ def imageConvertCompat(path):
def vrmlFormat(data):
'''
- Keep this as a valid vrml file, but format in a way we can pradict.
+ Keep this as a valid vrml file, but format in a way we can predict.
'''
# Strip all commends - # not in strings - warning multiline strings are ignored.
def strip_comment(l):
diff --git a/release/scripts/lightwave_export.py b/release/scripts/lightwave_export.py
index 458e61f3a28..bbfb9649c69 100644
--- a/release/scripts/lightwave_export.py
+++ b/release/scripts/lightwave_export.py
@@ -68,8 +68,13 @@ v5.5 format.
# ***** END GPL LICENCE BLOCK *****
import Blender
-import struct, cStringIO, operator
import BPyMesh
+try: import struct
+except: struct = None
+try: import cStringIO
+except: cStringIO = None
+try: import operator
+except: operator = None
VCOL_NAME = "\251 Per-Face Vertex Colors"
DEFAULT_NAME = "\251 Blender Default"
@@ -95,12 +100,16 @@ def write(filename):
icon = "" #generate_icon()
meshes = []
+ mesh_object_name_lookup = {} # for name lookups only
+
for obj in objects:
mesh = BPyMesh.getMeshFromObject(obj, None, True, False, scn)
if mesh:
mesh.transform(obj.matrixWorld)
meshes.append(mesh)
-
+ mesh_object_name_lookup[mesh] = obj.name
+ del obj
+
material_names = get_used_material_names(meshes)
tags = generate_tags(material_names)
surfs = generate_surfs(material_names)
@@ -111,7 +120,7 @@ def write(filename):
layer_index = 0
for mesh in meshes:
- layr = generate_layr(obj.name, layer_index)
+ layr = generate_layr(mesh_object_name_lookup[mesh], layer_index)
pnts = generate_pnts(mesh)
bbox = generate_bbox(mesh)
pols = generate_pols(mesh)
@@ -149,7 +158,9 @@ def write(filename):
layer_index += 1
mesh.verts = None # save some ram
-
+
+ del mesh_object_name_lookup
+
for surf in surfs:
chunks.append(surf)
@@ -345,23 +356,28 @@ def generate_vmad_vc(mesh):
# === Generate Per-Face UV Coords (VMAD Chunk) ===
# ================================================
def generate_vmad_uv(mesh):
- data = cStringIO.StringIO()
- data.write("TXUV") # type
- data.write(struct.pack(">H", 2)) # dimension
- data.write(generate_nstring("Blender's UV Coordinates")) # name
+ layers = mesh.getUVLayerNames()
+ org_uv = mesh.activeUVLayer
+ for l in layers:
+ mesh.activeUVLayer = l
+ data = cStringIO.StringIO()
+ data.write("TXUV") # type
+ data.write(struct.pack(">H", 2)) # dimension
+ data.write(generate_nstring(l)) # name
+ for i, f in enumerate(mesh.faces):
+ if not i%100:
+ Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing UV Coordinates")
+
+ uv = f.uv
+ f_v = f.v
+ for j in xrange(len(f)-1, -1, -1): # Reverse order
+ U,V = uv[j]
+ v = f_v[j].index
+ data.write(struct.pack(">H", v)) # vertex index
+ data.write(struct.pack(">H", i)) # face index
+ data.write(struct.pack(">ff", U, V))
- for i, f in enumerate(mesh.faces):
- if not i%100:
- Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing UV Coordinates")
-
- uv = f.uv
- f_v = f.v
- for j in xrange(len(f)-1, -1, -1): # Reverse order
- U,V = uv[j]
- v = f_v[j].index
- data.write(struct.pack(">H", v)) # vertex index
- data.write(struct.pack(">H", i)) # face index
- data.write(struct.pack(">ff", U, V))
+ mesh.activeUVLayer = org_uv
return data.getvalue()
# ======================================
@@ -685,4 +701,7 @@ def fs_callback(filename):
if not filename.lower().endswith('.lwo'): filename += '.lwo'
write(filename)
-Blender.Window.FileSelector(fs_callback, "Export LWO", Blender.sys.makename(ext='.lwo'))
+if struct and cStringIO and operator:
+ Blender.Window.FileSelector(fs_callback, "Export LWO", Blender.sys.makename(ext='.lwo'))
+else:
+ Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
diff --git a/release/scripts/md2_export.py b/release/scripts/md2_export.py
index 588336ed447..cf5752597da 100644
--- a/release/scripts/md2_export.py
+++ b/release/scripts/md2_export.py
@@ -612,29 +612,9 @@ class md2_obj:
######################################################
# Validation
######################################################
+
def validation(object):
global user_frame_list
-
- #move the object to the origin if it's not already there
- if object.getLocation('worldspace')!=(0.0, 0.0, 0.0):
- print "Model not centered at origin"
- result=Blender.Draw.PupMenu("Model not centered at origin%t|Center (will not work with animations!)|Do not center")
- if result==1:
- object.setLocation(0.0,0.0,0.0)
-
- #resize the object in case it is not the right size
- if object.getSize('worldspace')!=(1.0,1.0,1.0):
- print "Object is scaled-You should scale the mesh verts, not the object"
- result=Blender.Draw.PupMenu("Object is scaled-You should scale the mesh verts, not the object%t|Fix scale (will not work with animations!)|Do not scale")
- if result==1:
- object.setSize(1.0,1.0,1.0)
-
- if object.getEuler('worldspace')!=Blender.Mathutils.Euler(0.0,0.0,0.0):
- print "object.rot: ", object.getEuler('worldspace')
- print "Object is rotated-You should rotate the mesh verts, not the object"
- result=Blender.Draw.PupMenu("Object is rotated-You should rotate the mesh verts, not the object%t|Fix rotation (will not work with animations!)|Do not rotate")
- if result==1:
- object.setEuler([0.0,0.0,0.0])
#get access to the mesh data
mesh=object.getData(False, True) #get the object (not just name) and the Mesh, not NMesh
@@ -696,7 +676,8 @@ def validation(object):
result=Blender.Draw.PupMenu("Model has more than 1 texture map assigned%t|Quit")
#return False
if mesh_image:
- size=mesh_image.getSize()
+ try: size=mesh_image.getSize()
+ except: size= 256,256 # No image data
#is this really what the user wants
if (size[0]!=256 or size[1]!=256):
print "Texture map size is non-standard (not 256x256), it is: ",size[0],"x",size[1]
@@ -753,6 +734,8 @@ def fill_md2(md2, object):
#create the vertex list from the first frame
Blender.Set("curframe", 1)
+ has_uvs = mesh.faceUV
+
#header information
md2.ident=844121161
md2.version=8
@@ -761,9 +744,11 @@ def fill_md2(md2, object):
#get the skin information
#use the first faces' image for the texture information
- if mesh.faceUV:
+ if has_uvs:
mesh_image=mesh.faces[0].image
- size=mesh_image.getSize()
+ try: size=mesh_image.getSize()
+ except: size= 256,256
+
md2.skin_width=size[0]
md2.skin_height=size[1]
md2.num_skins=1
@@ -777,12 +762,14 @@ def fill_md2(md2, object):
#put texture information in the md2 structure
#build UV coord dictionary (prevents double entries-saves space)
+ if not has_uvs:
+ t=(0,0)
+
for face in mesh.faces:
for i in xrange(0,3):
- if mesh.faceUV:
+ if has_uvs:
t=(face.uv[i])
- else:
- t=(0,0)
+
tex_key=(t[0],t[1])
if not tex_list.has_key(tex_key):
tex_list[tex_key]=tex_count
@@ -798,16 +785,25 @@ def fill_md2(md2, object):
#put faces in the md2 structure
#for each face in the model
+
+ if not has_uvs:
+ uv_coords=[(0,0)]*3
+
for this_face in xrange(0, md2.num_faces):
md2.faces.append(md2_face())
+ mf = mesh.faces[this_face]
+ mf_v = mf.v
+ if has_uvs:
+ uv_coords = mf.uv
+
for i in xrange(0,3):
#blender uses indexed vertexes so this works very well
- md2.faces[this_face].vertex_index[i]=mesh.faces[this_face].verts[i].index
+ md2.faces[this_face].vertex_index[i] = mf_v[i].index
#lookup texture index in dictionary
- if mesh.faceUV:
- uv_coord=(mesh.faces[this_face].uv[i])
- else:
- uv_coord=(0,0)
+ if has_uvs:
+ uv_coord = uv_coords[i]
+ # otherwise we set it before
+
tex_key=(uv_coord[0],uv_coord[1])
tex_index=tex_list[tex_key]
md2.faces[this_face].texture_index[i]=tex_index
@@ -837,13 +833,18 @@ def fill_md2(md2, object):
for frame_counter in xrange(0,md2.num_frames):
progress+=progressIncrement
- Blender.Window.DrawProgressBar(progress, "Calculating Frame: "+str(frame_counter))
+ Blender.Window.DrawProgressBar(progress, "Calculating Frame: %d of %d" % (frame_counter, md2.num_frames))
#add a frame
md2.frames.append(md2_frame())
#update the mesh objects vertex positions for the animation
Blender.Set("curframe", frame_counter) #set blender to the correct frame
- mesh.getFromObject(object.name) #update the mesh to make verts current
+
+
+
+
+ mesh.getFromObject(object) #update the mesh to make verts current
+ mesh.transform(object.matrixWorld)
#each frame has a scale and transform value that gets the vertex value between 0-255
#since the scale and transform are the same for the all the verts in the frame, we only need
@@ -862,13 +863,14 @@ def fill_md2(md2, object):
frame_max_z=-100000.0
for face in mesh.faces:
- for vert in face.verts:
- if frame_min_x>vert.co[1]: frame_min_x=vert.co[1]
- if frame_max_x<vert.co[1]: frame_max_x=vert.co[1]
- if frame_min_y>vert.co[0]: frame_min_y=vert.co[0]
- if frame_max_y<vert.co[0]: frame_max_y=vert.co[0]
- if frame_min_z>vert.co[2]: frame_min_z=vert.co[2]
- if frame_max_z<vert.co[2]: frame_max_z=vert.co[2]
+ for vert in face:
+ co = vert.co
+ if frame_min_x>co[1]: frame_min_x=co[1]
+ if frame_max_x<co[1]: frame_max_x=co[1]
+ if frame_min_y>co[0]: frame_min_y=co[0]
+ if frame_max_y<co[0]: frame_max_y=co[0]
+ if frame_min_z>co[2]: frame_min_z=co[2]
+ if frame_max_z<co[2]: frame_max_z=co[2]
#the scale is the difference between the min and max (on that axis) / 255
frame_scale_x=(frame_max_x-frame_min_x)/255
@@ -896,9 +898,10 @@ def fill_md2(md2, object):
#then translates the point so it's not less than 0
#then scale it so it's between 0..255
#print "frame scale : ", frame_scale_x, " ", frame_scale_y, " ", frame_scale_z
- new_x=int((mesh.verts[vert_counter].co[1]-frame_trans_x)/frame_scale_x)
- new_y=int((mesh.verts[vert_counter].co[0]-frame_trans_y)/frame_scale_y)
- new_z=int((mesh.verts[vert_counter].co[2]-frame_trans_z)/frame_scale_z)
+ co = mesh.verts[vert_counter].co
+ new_x=int((co[1]-frame_trans_x)/frame_scale_x)
+ new_y=int((co[0]-frame_trans_y)/frame_scale_y)
+ new_z=int((co[2]-frame_trans_z)/frame_scale_z)
#put them in the structure
md2.frames[frame_counter].vertices[vert_counter].vertices=(new_x, new_y, new_z)
@@ -908,14 +911,14 @@ def fill_md2(md2, object):
#swap y and x for difference in axis orientation
- x1=-mesh.verts[vert_counter].no[1]
- y1=mesh.verts[vert_counter].no[0]
- z1=mesh.verts[vert_counter].no[2]
+ no = mesh.verts[vert_counter].no
+ x1= -no[1]
+ y1= no[0]
+ z1= no[2]
+
for j in xrange(0,162):
#dot = (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
- dot = (x1*MD2_NORMALS[j][0]+
- y1*MD2_NORMALS[j][1]+
- z1*MD2_NORMALS[j][2]);
+ dot = (x1*MD2_NORMALS[j][0] + y1*MD2_NORMALS[j][1]+ z1*MD2_NORMALS[j][2]);
if (dot > maxdot):
maxdot = dot;
maxdotindex = j;
diff --git a/release/scripts/mesh_mirror_tool.py b/release/scripts/mesh_mirror_tool.py
index 33ce6936c7f..8e22e26cd53 100644
--- a/release/scripts/mesh_mirror_tool.py
+++ b/release/scripts/mesh_mirror_tool.py
@@ -3,7 +3,7 @@
Name: 'Mirror Vertex Locations & Weight'
Blender: 241
Group: 'Mesh'
-Tooltip: 'Snap Verticies to X mirrord locations and weights.'
+Tooltip: 'Snap Verticies to X mirrored locations and weights.'
"""
__author__ = "Campbell Barton aka ideasman42"
@@ -11,11 +11,11 @@ __url__ = ["www.blender.org", "blenderartists.org", "www.python.org"]
__version__= '1.0'
__bpydoc__= '''\
This script is used to mirror vertex locations and weights
-It is usefull if you have a model that was made symetrical
+It is useful if you have a model that was made symmetrical
but has verts that have moved from their mirrored locations slightly,
-casuing blenders X-Mirror options not to work.
+causing blenders X-Mirror options not to work.
-Weights can be mirrored too, this is usefull if you want to model 1 side of a mesh, copy the mesh and flip it.
+Weights can be mirrored too, this is useful if you want to model 1 side of a mesh, copy the mesh and flip it.
You can then use this script to mirror to the copy, even creating new flipped vertex groups, renaming group name left to right or .L to .R
Vertex positions are mirrored by doing a locational lookup,
diff --git a/release/scripts/mesh_poly_reduce_grid.py b/release/scripts/mesh_poly_reduce_grid.py
index 3741a47723a..2903909027a 100644
--- a/release/scripts/mesh_poly_reduce_grid.py
+++ b/release/scripts/mesh_poly_reduce_grid.py
@@ -3,7 +3,7 @@
Name: 'Poly Reduce Selection (Unsubsurf)'
Blender: 245
Group: 'Mesh'
-Tooltip: 'pradictable mesh simplifaction maintaining face loops'
+Tooltip: 'predictable mesh simplifaction maintaining face loops'
"""
from Blender import Scene, Mesh, Window, sys
@@ -50,7 +50,7 @@ def my_mesh_util(me):
for edkey, count in edge_count.iteritems():
- # Ignore verts that connect to edges with more then 2 faces.
+ # Ignore verts that connect to edges with more than 2 faces.
if count != 2:
vert_faces[edkey[0]] = None
vert_faces[edkey[1]] = None
diff --git a/release/scripts/mesh_skin.py b/release/scripts/mesh_skin.py
index a554e128b41..4a330a516fb 100644
--- a/release/scripts/mesh_skin.py
+++ b/release/scripts/mesh_skin.py
@@ -52,7 +52,7 @@ A pop-up will provide further options, if the results of a method are not adequa
import Blender
import bpy
from Blender import Window
-from Blender.Mathutils import MidpointVecs, Vector, CrossVecs
+from Blender.Mathutils import MidpointVecs, Vector
from Blender.Mathutils import AngleBetweenVecs as _AngleBetweenVecs_
import BPyMessages
@@ -119,7 +119,7 @@ class edgeLoop(object):
# GENERATE AN AVERAGE NORMAL FOR THE WHOLE LOOP.
self.normal = Vector()
for e in self.edges:
- n = CrossVecs(self.centre-e.co1, self.centre-e.co2)
+ n = (self.centre-e.co1).cross(self.centre-e.co2)
# Do we realy need tot normalize?
n.normalize()
self.normal += n
@@ -149,7 +149,7 @@ class edgeLoop(object):
a = n1-n2
b = n1-n3
- normal1 = CrossVecs(a,b)
+ normal1 = a.cross(b)
normal1.normalize()
n1 = e.co2
@@ -159,7 +159,7 @@ class edgeLoop(object):
a = n1-n2
b = n1-n3
- normal2 = CrossVecs(a,b)
+ normal2 = a.cross(b)
normal2.normalize()
# Reuse normal1 var
diff --git a/release/scripts/mesh_unfolder.py b/release/scripts/mesh_unfolder.py
index 906e0f0a300..f5c19a92bd0 100644
--- a/release/scripts/mesh_unfolder.py
+++ b/release/scripts/mesh_unfolder.py
@@ -164,8 +164,8 @@ class Fold:
sangle = Mathutils.AngleBetweenVecs(self.refPolyNormal, self.polyNormal)
if(sangle!=sangle):
sangle=0.0
- ncp = Mathutils.CrossVecs(self.refPolyNormal, self.polyNormal)
- dp = Mathutils.DotVecs(ncp, self.edge.vector)
+ ncp = self.refPolyNormal.cross(self.polyNormal)
+ dp = ncp.dot(self.edge.vector)
if(dp>0.0):
return +sangle
else:
@@ -855,7 +855,7 @@ class Poly:
p.resize3D()
q = a-c
q.resize3D()
- return CrossVecs(p,q)
+ return p.cross(q)
def makeEdges(self):
self.edges = []
for i in xrange(self.nPoints()):
diff --git a/release/scripts/object_active_to_other.py b/release/scripts/object_active_to_other.py
new file mode 100644
index 00000000000..131d1f63d74
--- /dev/null
+++ b/release/scripts/object_active_to_other.py
@@ -0,0 +1,58 @@
+#!BPY
+"""
+Name: 'Copy Active to Selected'
+Blender: 249
+Group: 'Object'
+Tooltip: 'For every selected object, copy the active to their loc/size/rot'
+"""
+
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Script copyright (C) Campbell Barton
+#
+# 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.
+#
+# ***** END GPL LICENCE BLOCK *****
+# --------------------------------------------------------------------------
+
+
+from Blender import Window, sys, Draw
+import bpy
+
+def my_object_util(sce):
+ ob_act = sce.objects.active
+
+ if not ob_act:
+ Draw.PupMenu('Error%t|No active object selected')
+ return
+
+ mats = [ob.matrixWorld for ob in sce.objects.context if ob != ob_act]
+
+ for m in mats:
+ ob_copy = ob_act.copy()
+ sce.objects.link(ob_copy)
+ ob_copy.setMatrix(m)
+ ob_copy.Layers = ob.Layers
+
+
+def main():
+ sce = bpy.data.scenes.active
+
+ Window.WaitCursor(1)
+ my_object_util(sce)
+ Window.WaitCursor(0)
+
+if __name__ == '__main__':
+ main()
diff --git a/release/scripts/object_cookie_cutter.py b/release/scripts/object_cookie_cutter.py
index 2a6e0ad6b2e..4950c18c0f4 100644
--- a/release/scripts/object_cookie_cutter.py
+++ b/release/scripts/object_cookie_cutter.py
@@ -10,7 +10,7 @@ __url__= ["blender", "blenderartist"]
__version__= "1.0"
__bpydoc__= """\
-This script takes the selected mesh objects, devides them into 2 groups
+This script takes the selected mesh objects, divides them into 2 groups
Cutters and The objects to be cut.
Cutters are meshes with no faces, just edge loops. and any meshes with faces will be cut.
@@ -128,14 +128,14 @@ def sorted_indicies(i1, i2):
def fake_length2d(pt1, pt2):
'''
- Only used for comparison so dont sqrt
+ Only used for comparison so don't sqrt
'''
#return math.sqrt(abs(pow(x1-x2, 2)+ pow(y1-y2, 2)))
return pow(pt1[0]-pt2[0], 2) + pow(pt1[1]- pt2[1], 2)
def length2d(pt1, pt2):
'''
- Only used for comparison so dont sqrt
+ Only used for comparison so don't sqrt
'''
#return math.sqrt(abs(pow(x1-x2, 2)+ pow(y1-y2, 2)))
return sqrt(pow(pt1[0]-pt2[0], 2) + pow(pt1[1]- pt2[1], 2))
@@ -150,7 +150,7 @@ def tri_area_2d(v1, v2, v3):
return 0.25 * sqrt(abs(p*(p-2*e1)*(p-2*e2)*(p-2*e3)))
def tri_pt_find_z_2d(pt, tri):
- """ Takes a face and 3d vector and assigns teh vectors Z to its on the face"""
+ """ Takes a face and 3d vector and assigns the vectors Z to its on the face"""
l1= tri_area_2d(tri[1], tri[2], pt)
l2= tri_area_2d(tri[0], tri[2], pt)
@@ -170,7 +170,7 @@ def tri_pt_find_z_2d(pt, tri):
def tri_pt_find_uv_2d(pt, tri, uvs):
- """ Takes a face and 3d vector and assigns teh vectors Z to its on the face"""
+ """ Takes a face and 3d vector and assigns the vectors Z to its on the face"""
l1= tri_area_2d(tri[1], tri[2], pt)
l2= tri_area_2d(tri[0], tri[2], pt)
@@ -288,12 +288,12 @@ def terrain_cut_2d(t, c, PREF_Z_LOC):
# Loop through the cutter edges.
for ei_c, ed_c in enumerate(me_c.edges):
# If the cutter edge has 2 verts inside the same face then we can ignore it
- # Bothe are different faces or None
+ # Both are different faces or None
if cut_vert_terrain_faces[ed_c.v1.index] != cut_vert_terrain_faces[ed_c.v2.index] or\
cut_vert_terrain_faces[ed_c.v1.index] == cut_vert_terrain_faces[ed_c.v2.index] == None:
eb_c= c.edge_bounds[ei_c]
if bounds_intersect(eb_t, eb_c): # face/edge bounds intersect?
- # Now we know the 2 edges might intersect, we'll do a propper test
+ # Now we know the 2 edges might intersect, we'll do a proper test
x= LineIntersect2D(ed_t.v1.co, ed_t.v2.co, ed_c.v1.co, ed_c.v2.co)
if x:
@@ -340,7 +340,7 @@ def terrain_cut_2d(t, c, PREF_Z_LOC):
for f in faces:
faces_intersecting.setdefault(f.index, []).append(ed_isect)
- # this list is used to store edges that are totaly inside a face ( no intersections with terrain)
+ # this list is used to store edges that are totally inside a face ( no intersections with terrain)
# we can remove these as we
face_containing_edges= [[] for i in xrange(len(me_t.faces))]
for ed_c in me_c.edges:
@@ -412,8 +412,8 @@ def terrain_cut_2d(t, c, PREF_Z_LOC):
- # edges that dont have a vert in the face have to span between to intersection points
- # since we dont know the other point at any 1 time we need to remember edges that
+ # edges that don't have a vert in the face have to span between to intersection points
+ # since we don't know the other point at any 1 time we need to remember edges that
# span a face and add them once we'v collected both
# first add outline edges
edge_span_face= {}
@@ -507,7 +507,7 @@ def terrain_cut_2d(t, c, PREF_Z_LOC):
# 0,2,3
f_uv_mod= f_uv[0], f_uv[2], f_uv[3]
f_vco_mod= f_vco[0], f_vco[2], f_vco[3]
- # else - side of 0,1,2 - dont modify the quad
+ # else - side of 0,1,2 - don't modify the quad
uvs[i]= tri_pt_find_uv_2d(v_co, f_vco_mod, f_uv_mod)
@@ -579,7 +579,7 @@ def main():
for ob in obs:
if ob.type == 'Mesh':
me= ob.getData(mesh=1)
- elif ob.data.flag & 1: # Is the curve 3D? else dont use.
+ elif ob.data.flag & 1: # Is the curve 3D? else don't use.
me= BPyMesh.getMeshFromObject(ob) # get the curve
else:
continue
diff --git a/release/scripts/object_drop.py b/release/scripts/object_drop.py
index f4803e62d98..19cc1f8d15a 100644
--- a/release/scripts/object_drop.py
+++ b/release/scripts/object_drop.py
@@ -1,13 +1,13 @@
#!BPY
"""
Name: 'Drop Onto Ground'
-Blender: 245
+Blender: 249
Group: 'Object'
Tooltip: 'Drop the selected objects onto "ground" objects'
"""
__author__= "Campbell Barton"
__url__= ["blender.org", "blenderartists.org"]
-__version__= "1.0"
+__version__= "1.1"
__bpydoc__= """
"""
@@ -36,6 +36,7 @@ __bpydoc__= """
from Blender import Draw, Geometry, Mathutils, Window
+from Blender.Mathutils import Vector, AngleBetweenVecs, RotationMatrix
import bpy
@@ -44,6 +45,8 @@ GLOBALS['GROUND_SOURCE'] = [Draw.Create(1), Draw.Create(0)]
GLOBALS['GROUND_GROUP_NAME'] = Draw.Create('terrain')
GLOBALS['DROP_AXIS'] = [Draw.Create(1), Draw.Create(0)] # on what axis will we drop?
GLOBALS['DROP_OVERLAP_CHECK'] = Draw.Create(1) # is the terrain a single skin?
+GLOBALS['DROP_ORIENT'] = Draw.Create(1)
+GLOBALS['DROP_ORIENT_VALUE'] = Draw.Create(100.0)
GLOBALS['EVENT'] = 2
GLOBALS['MOUSE'] = None
@@ -52,19 +55,18 @@ def collect_terrain_triangles(obs_terrain):
me = bpy.data.meshes.new()
for ob in obs_terrain:
- # this matrix takes the object and drop matrix into account
- ob_mat = ob.matrixWorld # * drop_matrix
-
def blend_face_to_terrain_tris(f):
- cos = [v.co*ob_mat for v in f]
- if len(cos) == 4: return [(cos[0], cos[1], cos[2]), (cos[0], cos[2], cos[3])]
- else: return [(cos[0], cos[1], cos[2]), ]
+ no = f.no
+ cos = [v.co for v in f]
+ if len(cos) == 4: return [(cos[0], cos[1], cos[2], no), (cos[0], cos[2], cos[3], no)]
+ else: return [(cos[0], cos[1], cos[2], no), ]
# Clear
me.verts = None
try: me.getFromObject(ob)
except: pass
+ me.transform(ob.matrixWorld)
for f in me.faces: # may be [], thats ok
terrain_tris.extend( blend_face_to_terrain_tris(f) )
@@ -72,30 +74,34 @@ def collect_terrain_triangles(obs_terrain):
return terrain_tris
def calc_drop_loc(ob, terrain_tris, axis):
- pt = Mathutils.Vector(ob.loc)
+ pt = Vector(ob.loc)
isect = None
isect_best = None
+ isect_best_no = None
isect_best_len = 0.0
- for t1,t2,t3 in terrain_tris:
+ for t1,t2,t3, no in terrain_tris:
#if Geometry.PointInTriangle2D(pt, t1,t2,t3):
isect = Mathutils.Intersect(t1, t2, t3, axis, pt, 1) # 1==clip
if isect:
if not GLOBALS['DROP_OVERLAP_CHECK'].val:
# Find the first location
- return isect
+ return isect, no
else:
if isect_best:
isect_len = (pt-isect).length
if isect_len < isect_best_len:
isect_best_len = isect_len
isect_best = isect
+ isect_best_no = no
else:
isect_best_len = (pt-isect).length
isect_best = isect;
- return isect_best
+ isect_best_no = no
+
+ return isect_best, isect_best_no
def error_nogroup():
@@ -135,13 +141,28 @@ def terrain_clamp(event, value):
if GLOBALS['DROP_AXIS'][0].val:
- axis = Mathutils.Vector(0,0,-1)
+ axis = Vector(0,0,-1)
else:
- axis = Mathutils.Vector(Window.GetViewVector())
+ axis = Vector(Window.GetViewVector())
+
+ do_orient = GLOBALS['DROP_ORIENT'].val
+ do_orient_val = GLOBALS['DROP_ORIENT_VALUE'].val/100.0
+ if not do_orient_val: do_orient = False
for ob in obs_clamp:
- loc = calc_drop_loc(ob, terrain_tris, axis)
+ loc, no = calc_drop_loc(ob, terrain_tris, axis)
if loc:
+ if do_orient:
+ try: ang = AngleBetweenVecs(no, axis)
+ except:ang = 0.0
+ if ang > 90.0:
+ no = -no
+ ang = 180.0-ang
+
+ if ang > 0.0001:
+ ob_matrix = ob.matrixWorld * RotationMatrix(ang * do_orient_val, 4, 'r', axis.cross(no))
+ ob.setMatrix(ob_matrix)
+
ob.loc = loc
# to make the while loop exist
@@ -175,7 +196,8 @@ def do_ground_group_name(e,v):
if not g: error_nogroup()
GLOBALS['EVENT'] = e
-
+def do_dummy(e,v):
+ GLOBALS['EVENT'] = e
EVENT_NONE = 0
EVENT_EXIT = 1
@@ -185,7 +207,7 @@ def terain_clamp_ui():
# Only to center the UI
x,y = GLOBALS['MOUSE']
x-=40
- y-=60
+ y-=70
Draw.Label('Drop Axis', x-70,y+120, 60, 20)
Draw.BeginAlign()
@@ -204,7 +226,13 @@ def terain_clamp_ui():
GLOBALS['DROP_OVERLAP_CHECK'] = Draw.Toggle('Overlapping Terrain', EVENT_NONE, x-70, y+20, 190, 20, GLOBALS['DROP_OVERLAP_CHECK'].val, "Check all terrain triangles and use the top most (slow)")
- Draw.PushButton('Drop Objects', EVENT_EXIT, x+20, y-10, 100, 20, 'Drop the selected objects', terrain_clamp)
+ Draw.BeginAlign()
+ GLOBALS['DROP_ORIENT'] = Draw.Toggle('Orient Normal', EVENT_REDRAW, x-70, y-10, 110, 20, GLOBALS['DROP_ORIENT'].val, "Rotate objects to the face normal", do_dummy)
+ if GLOBALS['DROP_ORIENT'].val:
+ GLOBALS['DROP_ORIENT_VALUE'] = Draw.Number('', EVENT_NONE, x+40, y-10, 80, 20, GLOBALS['DROP_ORIENT_VALUE'].val, 0.0, 100.0, "Percentage to orient 0.0 - 100.0")
+ Draw.EndAlign()
+
+ Draw.PushButton('Drop Objects', EVENT_EXIT, x+20, y-40, 100, 20, 'Drop the selected objects', terrain_clamp)
# So moving the mouse outside the popup exits the while loop
GLOBALS['EVENT'] = EVENT_EXIT
diff --git a/release/scripts/ply_import.py b/release/scripts/ply_import.py
index 43129ec01e9..29e8ce48361 100644
--- a/release/scripts/ply_import.py
+++ b/release/scripts/ply_import.py
@@ -149,6 +149,7 @@ def read(filename):
'uint8': 'B',
'int16': 'h',
'uint16': 'H',
+ 'ushort': 'H',
'int': 'i',
'int32': 'i',
'uint': 'I',
@@ -156,6 +157,7 @@ def read(filename):
'float': 'f',
'float32': 'f',
'float64': 'd',
+ 'double': 'd',
'string': 's'}
obj_spec = object_spec()
diff --git a/release/scripts/rvk1_torvk2.py b/release/scripts/rvk1_torvk2.py
index a48d065813a..d013343c05c 100644
--- a/release/scripts/rvk1_torvk2.py
+++ b/release/scripts/rvk1_torvk2.py
@@ -2,7 +2,7 @@
# coding: utf-8
""" Registration info for Blender menus: <- these words are ignored
Name: 'Deformed mesh to Rvk'
-Blender: 243
+Blender: 248
Group: 'Mesh'
Tip: 'Copy deform data (not surf. subdiv) of active obj to rvk of the 2nd selected obj'
"""
@@ -11,21 +11,24 @@ __author__ = "Jean-Michel Soler (jms)"
__url__ = ("blender", "blenderartists.org",
"Script's homepage, http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_rvk1versrvk2.htm",
"Communicate problems and errors, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender")
-__version__ = "2007/04/27"
+__version__ = "2009/05/18"
__bpydoc__ = """\
-"DEFORM to RVK2" copies deform data (except EDGESPLIT,DECIMATE,SUBSURF,BOOLEAN,
-BUILD,MIRROR,ARRAY) of the active object to the RVK (relative vertex key) of
-the other selected object.
+"DEFORM to RVK2" copies deformed data (except all data with not exactly
+the same number of vertices like EDGESPLIT,DECIMATE,SUBSURF, BOOLEAN,
+BUILD, MIRROR, ARRAY) of the active object to the RVK (relative vertex
+key, now called Shapes key) of the other selected object.
It is presupposed that the second mesh object is built exactly like the first
one. In fact, it is better to use a true copy with at least one basic shape
-key.
+key. If there is no other object selected, the script can create a copy.
The new version of this scrit (Blender 2.43) manages the modifier changes.
There are a lot of modifiers but only the ones which just deforms the shape
-can be used : LATTICE, CURVE, WAVE, ARMATURE. You can unset these modifiers
-from the script.
+can be used : LATTICE, CURVE, WAVE, ARMATURE, CAST, DISPLACE, SMOOTH.
+SIMPLEDEFORM and SHRINKWRAP are not correctly seen before Blender 2.49, but
+they can be copied too. You can unset one or more of these modifiers from
+the script.
Usage:
@@ -37,9 +40,9 @@ the rvk it will also ask whether it should replace or add a new vertex group.
"""
-
#----------------------------------------------
-# jm soler (c) 2004-2007 : 'Deformed mesh to Rvk' released under GPL licence
+# jm soler (c) 2004-2009 : 'Deformed mesh to Rvk'
+# released under GPL licence
#----------------------------------------------
"""
Ce programme est libre, vous pouvez le redistribuer et/ou
@@ -72,11 +75,6 @@ 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
-# Copy the rvk (1, or armature, lattice, or
-# any mesh deformation except surface
-# sbdivision) of the active object to rvk (2) of
-# the second selected object. Create rvk or modify
-# absolute key if needed.
#----------------------------------------------
# official Page :
# http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_rvk1versrvk2.htm
@@ -90,7 +88,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Communiquer les problemes et erreurs sur:
# http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
#---------------------------------------------
-#---------------------------------------------
import Blender
from Blender import NMesh,Draw,Object,Modifier
@@ -99,175 +96,246 @@ DEBUG=0
def Value(t):
exec "t=Modifier.Types.%s"%t
- return t
+ return t
-def deform2rvk():
+def copy_shapes(RVK1,RVK2):
POSSMOD_list=['EDGESPLIT',
- 'DECIMATE',
- 'SUBSURF',
- 'BOOLEAN',
- 'BUILD',
- 'MIRROR',
- 'ARRAY']
+ 'DECIMATE',
+ 'SUBSURF',
+ 'BOOLEAN',
+ 'BUILD',
+ 'MIRROR',
+ 'ARRAY',
+ 'BEVEL',
+ 'EXPLODE']
AUTHMOD_list=['LATTICE',
- 'CURVE',
- 'WAVE',
- 'ARMATURE']
-
- MODIFIERS=0
+ 'CURVE',
+ 'WAVE',
+ 'ARMATURE',
+ 'SMOOTH',
+ 'SIMPLEDEFORM',
+ 'SHRINKWRAP',
+ 'CAST',
+ 'DISPLACE',
+ 'MESHDEFORM']
+
BMOD=[['Possible Modifiers'],
- ['Allowed Modifiers']]
-
- # =================================================================
- # at leat 2 objects ===============================================
- # =================================================================
- if len(Object.GetSelected())>1 :
- RVK1=Object.GetSelected()[0]
- RVK2=Object.GetSelected()[1]
- # =============================================================
- # must be 2 meshes ============================================
- # =============================================================
- if RVK1.getType()=='Mesh' and RVK2.getType()=='Mesh':
- FRAME=Blender.Get('curframe')
+ ['Allowed Modifiers']]
+ # =============================================================
+ # must be 2 meshes ============================================
+ # =============================================================
+ if RVK1.getType()=='Mesh' and RVK2.getType()=='Mesh':
+ #MODIFIERS=0
+ FRAME=Blender.Get('curframe')
+ DATA2=RVK2.getData()
+ if DEBUG: print DATA2.getKey()
+ # ============================================================
+ # at least the second must have a shape key ==================
+ # ============================================================
+ def select_modifier(RVK1, RVK2, DATA2):
+ # ======================================================
+ # in case of modifiers, use =============================
+ # ======================================================
+ if RVK1.modifiers:
+ #MODIFIERS=1
+ POSSMOD=[Value(t) for t in POSSMOD_list]
+ AUTHMOD=[Value(t) for t in AUTHMOD_list]
+ if DEBUG: print 'POSSMOD:',POSSMOD,'\nAUTHMOD:', AUTHMOD
+ MODRVK1=RVK1.modifiers
+ block = []
+ # ===================================================
+ # === Bloc Menu Modifiers ===1 doc =================
+ # ===================================================
+ m=0
+ for mod in MODRVK1:
+ if DEBUG: print mod.type
+ if mod.type in POSSMOD:
+ BMOD[0].append([Draw.Create(0),mod.type,
+ m,
+ POSSMOD_list[POSSMOD.index(mod.type)],
+ mod[Modifier.Settings.RENDER]==1,
+ mod[Modifier.Settings.EDITMODE]==1
+ ])
+ elif mod.type in AUTHMOD:
+ BMOD[1].append([Draw.Create(1),
+ mod.type,
+ m,
+ AUTHMOD_list[AUTHMOD.index(mod.type)],
+ mod[Modifier.Settings.RENDER]==1,
+ mod[Modifier.Settings.EDITMODE]==1
+ ])
+ m+=1
+ # ===================================================
+ # === Bloc Menu Modifiers ===2 display =============
+ # ===================================================
+ block.append(BMOD[1][0])
+ for B in BMOD[1][1:]:
+ block.append((B[3],B[0],""))
+ block.append(BMOD[0][0])
+ block.append("not alredy implemented")
+ block.append("in this script.")
+ for B in BMOD[0][1:]:
+ block.append((B[3],B[0],""))
+ retval = Blender.Draw.PupBlock("MESH 2 RVK", block)
+ # ===================================================
+ # === unset Modifiers =============================
+ # ===================================================
+ for B in BMOD[0][1:]:
+ if DEBUG: print B[2]
+ MODRVK1[B[2]][Modifier.Settings.RENDER]=0
+ for B in BMOD[1]:
+ if not B[1]:
+ MODRVK1[B[2]][Modifier.Settings.RENDER]=0
+ # ===================================================
+ # === update Modifiers =============================
+ # ===================================================
+ #RVK1.makeDisplayList()
+ # =======================================================
+ # === get deformed mesh ================================
+ # =======================================================
+ RVK1NAME=Object.GetSelected()[0].getName()
+ meshrvk1=NMesh.GetRawFromObject(RVK1NAME)
+ if DEBUG: print len(meshrvk1.verts)
+ # =======================================================
+ # === get normal mesh for vertex group =================
+ # =======================================================
+ DATA1=RVK1.getData()
+ # =======================================================
+ # === get destination mesh ============================
+ # =======================================================
DATA2=RVK2.getData()
- if DEBUG: print DATA2.getKey()
- # ============================================================
- # at least the second must have a shape key ==================
- # ============================================================
- if DATA2.getKey():
- # ======================================================
- # in case of modifiers use =============================
- # ======================================================
+ if DEBUG: print len(meshrvk1.verts)
+ if DEBUG: print len(DATA2.verts)
+ # ========================================================
+ # ===== is there the same number of vertices =============
+ # ========================================================
+ if len(meshrvk1.verts)==len(DATA2.verts):
+ name = "Do you want to replace or add vertex groups ? %t| YES %x1| NO ? %x2 "
+ result = Draw.PupMenu(name)
+ if result==1:
+ # =====================================================
+ # ===== Do we save vertex groups ? ===================
+ # =====================================================
+ GROUPNAME2=DATA2.getVertGroupNames()
+ if len(GROUPNAME2)!=0:
+ for GROUP2 in GROUPNAME2:
+ DATA2.removeVertGroup(GROUP2)
+ GROUPNAME1=DATA1.getVertGroupNames()
+ if len(GROUPNAME1)!=0:
+ for GROUP1 in GROUPNAME1:
+ DATA2.addVertGroup(GROUP1)
+ DATA2.assignVertsToGroup(GROUP1,DATA1.getVertsFromGroup(GROUP1),1.0,'replace')
+ # ========================================================
+ # ===== now copy the vertices coords =====================
+ # ========================================================
+ for v in meshrvk1.verts:
+ i= meshrvk1.verts.index(v)
+ v1=DATA2.verts[i]
+ for n in [0,1,2]:
+ v1.co[n]=v.co[n]
+ DATA2.update()
+ DATA2.insertKey(FRAME,'relative')
+ DATA2.update()
+ RVK2.makeDisplayList()
+
if RVK1.modifiers:
- MODIFIERS=1
- POSSMOD=[Value(t) for t in POSSMOD_list]
- AUTHMOD=[Value(t) for t in AUTHMOD_list]
- if DEBUG: print 'POSSMOD:',POSSMOD,'\nAUTHMOD:', AUTHMOD
- MODRVK1=RVK1.modifiers
- block = []
- # ===================================================
- # === Bloc Menu Modifiers ===1 doc =================
- # ===================================================
- m=0
- for mod in MODRVK1:
- if DEBUG: print mod.type
- if mod.type in POSSMOD:
- BMOD[0].append([Draw.Create(0),mod.type,
- m,
- POSSMOD_list[POSSMOD.index(mod.type)],
- mod[Modifier.Settings.RENDER]==1,
- mod[Modifier.Settings.EDITMODE]==1
- ])
- elif mod.type in AUTHMOD:
- BMOD[1].append([Draw.Create(1),
- mod.type,
- m,
- AUTHMOD_list[AUTHMOD.index(mod.type)],
- mod[Modifier.Settings.RENDER]==1,
- mod[Modifier.Settings.EDITMODE]==1
- ])
- m+=1
- # ===================================================
- # === Bloc Menu Modifiers ===2 display =============
- # ===================================================
- block.append(BMOD[1][0])
- for B in BMOD[1][1:]:
- block.append((B[3],B[0],""))
- block.append(BMOD[0][0])
- block.append("not alredy implemented")
- block.append("in this script.")
- for B in BMOD[0][1:]:
- block.append((B[3],B[0],""))
- retval = Blender.Draw.PupBlock("MESH 2 RVK", block)
# ===================================================
# === unset Modifiers =============================
# ===================================================
for B in BMOD[0][1:]:
- if DEBUG: print B[2]
- MODRVK1[B[2]][Modifier.Settings.RENDER]=0
+ MODRVK1[B[2]][Modifier.Settings.RENDER]|=B[-2]
for B in BMOD[1]:
if not B[1]:
- MODRVK1[B[2]][Modifier.Settings.RENDER]=0
- # ===================================================
- # === update Modifiers =============================
- # ===================================================
- #RVK1.makeDisplayList()
- # =======================================================
- # === get deformed mesh ================================
- # =======================================================
- RVK1NAME=Object.GetSelected()[0].getName()
- meshrvk1=NMesh.GetRawFromObject(RVK1NAME)
- if DEBUG: print len(meshrvk1.verts)
- # =======================================================
- # === get normal mesh for vertex group =================
- # =======================================================
- DATA1=RVK1.getData()
- # =======================================================
- # === get destination mesh ============================
- # =======================================================
- DATA2=RVK2.getData()
- if DEBUG: print len(meshrvk1.verts)
- if DEBUG: print len(DATA2.verts)
- # ========================================================
- # ===== is there the same number of vertices =============
- # ========================================================
- if len(meshrvk1.verts)==len(DATA2.verts):
- name = "Do you want to replace or add vertex groups ? %t| YES %x1| NO ? %x2 "
- result = Draw.PupMenu(name)
- if result==1:
- # =====================================================
- # ===== Do we save vertex groups ? ===================
- # =====================================================
- GROUPNAME2=DATA2.getVertGroupNames()
- if len(GROUPNAME2)!=0:
- for GROUP2 in GROUPNAME2:
- DATA2.removeVertGroup(GROUP2)
- GROUPNAME1=DATA1.getVertGroupNames()
- if len(GROUPNAME1)!=0:
- for GROUP1 in GROUPNAME1:
- DATA2.addVertGroup(GROUP1)
- DATA2.assignVertsToGroup(GROUP1,DATA1.getVertsFromGroup(GROUP1),1.0,'replace')
- # ========================================================
- # ===== now copy the vertices coords =====================
- # ========================================================
- for v in meshrvk1.verts:
- i= meshrvk1.verts.index(v)
- v1=DATA2.verts[i]
- for n in [0,1,2]:
- v1.co[n]=v.co[n]
- DATA2.update()
- DATA2.insertKey(FRAME,'relative')
- DATA2.update()
- RVK2.makeDisplayList()
- if MODIFIERS:
- # ===================================================
- # === unset Modifiers =============================
- # ===================================================
- for B in BMOD[0][1:]:
MODRVK1[B[2]][Modifier.Settings.RENDER]|=B[-2]
- for B in BMOD[1]:
- if not B[1]:
- MODRVK1[B[2]][Modifier.Settings.RENDER]|=B[-2]
- else:
- name = "Meshes Objects must the same number of vertices %t| Ok. %x1"
- result = Draw.PupMenu(name)
- return
+
else:
- name = "Second Object must have at least a shape key %t| Ok. %x1"
+ name = "Meshes Objects must have the same number of vertices %t|Ok. %x1"
result = Draw.PupMenu(name)
- return
+ return
+ if DATA2.getKey():
+ select_modifier(RVK1, RVK2, DATA2)
else:
- name = "Object must be Meshes %t| Ok. %x1"
+ name = "Second Object must have at least a shape key %t| Ok. %x1| Add one ? %x2"
result = Draw.PupMenu(name)
+ if result :
+ RVK2.insertShapeKey()
+ DATA2=RVK2.getData()
+ select_modifier(RVK1, RVK2, DATA2)
+ else:
+ return
+ else:
+ name = "Object must be Meshes %t| Ok. %x1"
+ result = Draw.PupMenu(name)
+ return
+
+def deform2rvk():
+ scn = Blender.Scene.GetCurrent()
+ # =================================================================
+ # at leat 2 objects ===============================================
+ # =================================================================
+ if len(scn.objects.selected) >1 :
+ RVK1 = Object.GetSelected()[0]
+ RVK2=Object.GetSelected()[1]
+ if RVK2.getType()=='Mesh' :
+ copy_shapes(RVK1,RVK2)
+ # =================================================================
+ # ... but if only one...===========================================
+ # =================================================================
+ elif len(scn.objects.selected)==1:
+ name = "At least 2 Meshes must be selected %t| Ok. %x1| Add one ? %x2"
+ result = Draw.PupMenu(name)
+ RVK1 = Object.GetSelected()[0]
+ if result and RVK1.getType()=='Mesh' :
+ Blender.Object.Duplicate(mesh=1)
+ RVK2=scn.objects.active
+ mod = RVK2.modifiers
+ for m in mod :
+ RVK2.modifiers.remove(m)
+ RVK2.LocX+=2.0
+ copy_shapes(RVK1,RVK2)
+ scn.objects.selected=[]
+ RVK2.sel=1
+ RVK1.sel=1
+ # ================================================================
+ # ... and not a mesh...===========================================
+ # ================================================================
+ elif result:
+ name = "Selected object must be a mesh %t| Ok. %x1"
+ result = Draw.PupMenu(name)
+ return
+ else :
return
- else :
- name = "At least 2 Meshes as to be selected %t| Ok. %x1"
+ # ================================================================
+ # ... if not object at all. =====================================
+ # ================================================================
+ else:
+ name = "At least one Mesh object must be selected %t| Ok. %x1"
result = Draw.PupMenu(name)
return
+
Blender.Redraw()
+
EDITMODE=Blender.Window.EditMode()
Blender.Window.EditMode(0)
-deform2rvk()
-Blender.Window.EditMode(EDITMODE) \ No newline at end of file
+END = 0
+DEFAULT= Blender.Get('curframe')
+
+while not END:
+ deform2rvk()
+ name = "Do you want to copy at a new frame %t| Yes ? %x1| No ? %x2"
+ result = Draw.PupMenu(name)
+ if result == 1:
+ msg = "Frame :"
+ inputresult = Draw.PupIntInput(msg, DEFAULT , Blender.Get('staframe'), Blender.Get('endframe'))
+ print inputresult
+ if inputresult != None:
+ Blender.Set('curframe',inputresult)
+ Blender.Window.RedrawAll()
+ else:
+ END = 1
+ else:
+ END = 1
+
+Blender.Window.EditMode(EDITMODE)
diff --git a/release/scripts/scripttemplate_gamelogic.py b/release/scripts/scripttemplate_gamelogic.py
index 01348e86d0a..577847c0dda 100644
--- a/release/scripts/scripttemplate_gamelogic.py
+++ b/release/scripts/scripttemplate_gamelogic.py
@@ -1,7 +1,7 @@
#!BPY
"""
Name: 'GameLogic Example'
-Blender: 245
+Blender: 249
Group: 'ScriptTemplate'
Tooltip: 'Script template with examples of how to use game logic'
"""
@@ -29,63 +29,63 @@ def main():
cont = GameLogic.getCurrentController()
# The KX_GameObject that owns this controller.
- own = cont.getOwner()
+ own = cont.owner
# for scripts that deal with spacial logic
- own_pos = own.getPosition()
+ own_pos = own.worldPosition
# Some example functions, remove to write your own script.
# check for a positive sensor, will run on any object without errors.
- print 'Logic info for KX_GameObject', own.getName()
+ print 'Logic info for KX_GameObject', own.name
input = False
- for sens in cont.getSensors():
+ for sens in cont.sensors:
# The sensor can be on another object, we may want to use it
- own_sens = sens.getOwner()
- print ' sensor:', sens.getName(),
- if sens.isPositive():
+ own_sens = sens.owner
+ print ' sensor:', sens.name,
+ if sens.positive:
print '(true)'
input = True
else:
print '(false)'
- for actu in cont.getActuators():
+ for actu in cont.actuators:
# The actuator can be on another object, we may want to use it
- own_actu = actu.getOwner()
- print ' actuator:', actu.getName()
+ own_actu = actu.owner
+ print ' actuator:', actu.name
# This runs the actuator or turns it off
# note that actuators will continue to run unless explicitly turned off.
if input:
- GameLogic.addActiveActuator(actu, True)
+ cont.activate(actu)
else:
- GameLogic.addActiveActuator(actu, False)
+ cont.deactivate(actu)
- # Its also good practice to get sensors and actuators by names
- # so any changes to their order wont break the script.
+ # Its also good practice to get sensors and actuators by name
+ # rather then index so any changes to their order wont break the script.
- # sens_key = cont.getSensor('key_sensor')
- # actu_motion = cont.getActuator('motion')
+ # sens_key = cont.sensors['key_sensor']
+ # actu_motion = cont.actuators['motion']
# Loop through all other objects in the scene
sce = GameLogic.getCurrentScene()
- print 'Scene Objects:', sce.getName()
- for ob in sce.getObjectList():
- print ' ', ob.getName(), ob.getPosition()
+ print 'Scene Objects:', sce.name
+ for ob in sce.objects:
+ print ' ', ob.name, ob.worldPosition
# Example where collision objects are checked for their properties
# adding to our objects "life" property
"""
- actu_collide = cont.getSensor('collision_sens')
- for ob in actu_collide.getHitObjectList():
+ actu_collide = cont.sensors['collision_sens']
+ for ob in actu_collide.objectHitList:
# Check to see the object has this property
- if hasattr(ob, 'life'):
- own.life += ob.life
- ob.life = 0
- print own.life
+ if ob.has_key('life'):
+ own['life'] += ob['life']
+ ob['life'] = 0
+ print own['life']
"""
main()
diff --git a/release/scripts/scripttemplate_gamelogic_basic.py b/release/scripts/scripttemplate_gamelogic_basic.py
index 1584659d317..fd404d5c8a4 100644
--- a/release/scripts/scripttemplate_gamelogic_basic.py
+++ b/release/scripts/scripttemplate_gamelogic_basic.py
@@ -1,7 +1,7 @@
#!BPY
"""
Name: 'GameLogic Template'
-Blender: 245
+Blender: 249
Group: 'ScriptTemplate'
Tooltip: 'Basic template for new game logic scripts'
"""
@@ -14,15 +14,15 @@ script_data = \
def main():
cont = GameLogic.getCurrentController()
- own = cont.getOwner()
+ own = cont.owner
- sens = cont.getSensor('mySensor')
- actu = cont.getActuator('myActuator')
+ sens = cont.sensors['mySensor']
+ actu = cont.actuators['myActuator']
- if sens.isPositive():
- GameLogic.addActiveActuator(actu, True)
+ if sens.positive:
+ cont.activate(actu)
else:
- GameLogic.addActiveActuator(actu, False)
+ cont.deactivate(actu)
main()
'''
diff --git a/release/scripts/scripttemplate_gamelogic_module.py b/release/scripts/scripttemplate_gamelogic_module.py
new file mode 100644
index 00000000000..2ef4950917b
--- /dev/null
+++ b/release/scripts/scripttemplate_gamelogic_module.py
@@ -0,0 +1,45 @@
+#!BPY
+"""
+Name: 'GameLogic Module'
+Blender: 249
+Group: 'ScriptTemplate'
+Tooltip: 'Basic template for new game logic modules'
+"""
+
+from Blender import Window
+import bpy
+
+script_data = \
+'''
+# This module can be accessed by a python controller with
+# its execution method set to 'Module'
+# * Set the module string to "gamelogic_module.main" (without quotes)
+# * When renaming the script it MUST have a .py extension
+# * External text modules are supported as long as they are at
+# the same location as the blendfile or one of its libraries.
+
+import GameLogic
+
+# variables defined here will only be set once when the
+# module is first imported. Set object spesific vars
+# inside the function if you intend to use the module
+# with multiple objects.
+
+def main(cont):
+ own = cont.owner
+
+ sens = cont.sensors['mySensor']
+ actu = cont.actuators['myActuator']
+
+ if sens.positive:
+ cont.activate(actu)
+ else:
+ cont.deactivate(actu)
+
+# dont call main(GameLogic.getCurrentController()), the py controller will
+'''
+
+new_text = bpy.data.texts.new('gamelogic_module.py')
+new_text.write(script_data)
+bpy.data.texts.active = new_text
+Window.RedrawAll()
diff --git a/release/scripts/textplugin_convert_ge.py b/release/scripts/textplugin_convert_ge.py
new file mode 100644
index 00000000000..f3b44cdb14b
--- /dev/null
+++ b/release/scripts/textplugin_convert_ge.py
@@ -0,0 +1,863 @@
+#!BPY
+"""
+Name: 'Convert BGE 2.49'
+Blender: 246
+Group: 'TextPlugin'
+Shortcut: ''
+Tooltip: 'Attemps to update deprecated usage of game engine API.'
+"""
+
+#
+# Copyright 2009 Alex Fraser <alex@phatcore.com>
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+#
+# This script updates game engine scripts that were designed for pre-2.49
+# versions of Blender to run with the new API. Deprecated function calls are
+# listed in attributeRenameDict. This script searches for instances of the keys
+# in a target script and re-writes them.
+#
+# Some deprecated functions are complicated to re-write. The most common
+# conversions have been implemented, but some have not. Running this will reduce
+# the number of deprecation warnings in your scripts, but may not eliminate them
+# entirely.
+#
+# NOTE: The conversion is not guaranteed to be perfect. It is strongly
+# recommended that you review all changes after running this script.
+#
+# TODO: The following attributes are either ambiguous or need special processing
+# to handle parameters. Deprecated attributes that map to multiple target
+# attributes will require a refactor of the main conversion loop in the
+# convert248to249 function: currently, it doesn't allow any conversion to
+# advance the row index by more than one.
+#
+# getLinearVelocity (KX_SCA_AddObjectActuator, KX_ObjectActuator)
+# Conflicts with KX_GameObject.
+# Maps to multiple attributes.
+# setLinearVelocity (KX_SCA_AddObjectActuator, KX_ObjectActuator)
+# Conflicts with KX_GameObject.
+# Maps to multiple attributes.
+# getAngularVelocity (KX_SCA_AddObjectActuator, KX_ObjectActuator)
+# Conflicts with KX_GameObject.
+# Maps to multiple attributes.
+# setAngularVelocity (KX_SCA_AddObjectActuator, KX_ObjectActuator)
+# Conflicts with KX_GameObject.
+# Maps to multiple attributes.
+# setAction (BL_ShapeActionActuator, BL_ActionActuator)
+# `reset' argument has no conversion target.
+# set (KX_VisibilityActuator, KX_IpoActuator)
+# Different numbers of arguments.
+# Arguments map to multiple attributes.
+# getIndex (SCA_JoystickSensor)
+# Incompatible values: Old = 1-based index; new = 0-based.
+# getMesh (KX_SCA_ReplaceMeshActuator)
+# Return types differ. Need to call object.name.
+# getObject (KX_SCA_AddObjectActuator, KX_CameraActuator,
+# KX_TrackToActuator, KX_ParentActuator)
+# Default return type differs between classes.
+# setIndex (SCA_JoystickSensor)
+# Incompatible values: Old = 1-based index; new = 0-based.
+# setObject (KX_SCA_AddObjectActuator, KX_CameraActuator,
+# KX_TrackToActuator, KX_ParentActuator)
+# Incompatible types: Old = KX_GameObject or String; new =
+# KX_GameObject.
+# setOperation (KX_SCA_DynamicActuator, KX_StateActuator)
+# Ambiguous: different target names.
+# getDRot (KX_ObjectActuator)
+# Maps to multiple attributes.
+# setDRot (KX_ObjectActuator)
+# Arguments map to multiple attributes.
+# getDLoc (KX_ObjectActuator)
+# Maps to multiple attributes.
+# setDLoc (KX_ObjectActuator)
+# Arguments map to multiple attributes.
+# getTorque (KX_ObjectActuator)
+# Maps to multiple attributes.
+# setTorque (KX_ObjectActuator)
+# Arguments map to multiple attributes.
+# getForce (KX_ObjectActuator)
+# Maps to multiple attributes.
+# setForce (KX_ObjectActuator)
+# Arguments map to multiple attributes.
+# position (KX_GameObject)
+# Conflicts with KX_SoundActuator.
+# orientation (KX_GameObject)
+# Conflicts with KX_SoundActuator.
+#
+
+import string
+import re
+
+COMMENTCHAR = '#'
+
+class ParseError(Exception): pass
+class ConversionError(Exception): pass
+
+def findBalancedParens(lines, row, col, openChar = '(', closeChar = ')'):
+ """Finds a balanced pair of parentheses, searching from lines[row][col].
+ The opening parenthesis must be on the starting line.
+
+ Returns two tuples containing the row and column of the opening paren, and
+ the row and column of the matching paren.
+
+ Throws a ParseError if the first character is not openChar, or if a matching
+ paren cannot be found."""
+
+ #
+ # Find the opening coordinates.
+ #
+ oRow = row
+ oCol = col
+ line = lines[oRow]
+ while oCol < len(line):
+ if line[oCol] == openChar:
+ break
+ elif line[oCol] == COMMENTCHAR:
+ break
+ oCol = oCol + 1
+
+ if oCol >= len(line) or line[oCol] != openChar or not re.match(r'^\s*$', line[col:oCol]):
+ raise ParseError, "Can't find opening parenthesis. '%s'" % openChar
+
+ #
+ # Find the closing coordinates.
+ #
+ eRow = oRow
+ eCol = oCol + 1
+ level = 1
+ while eRow < len(lines) and level > 0:
+ line = lines[eRow]
+ while eCol < len(line) and level > 0:
+ c = line[eCol]
+ if c == openChar:
+ # Found a nested paren.
+ level = level + 1
+ elif c == closeChar:
+ # Exiting one level of nesting.
+ level = level - 1
+ if level == 0:
+ # Back to top level!
+ return (oRow, oCol), (eRow, eCol)
+ elif c == COMMENTCHAR:
+ # Comment. Skip the rest of the line.
+ break
+ eCol = eCol + 1
+ eRow = eRow + 1
+ eCol = 0
+ raise ParseError, "Couldn't find closing parenthesis."
+
+def findLastAssignment(lines, row, attrName):
+ """Finds the most recent assignment of `attrName' before `row'. Returns
+ everything after the '=' sign or None, if there was no match."""
+ contRegex = re.compile(r'[^#]*?' + # Don't search in comments.
+ attrName +
+ r'\s*=\s*(.*)') # Assignment
+
+ cRow = row - 1
+ while cRow >= 0:
+ match = contRegex.search(lines[cRow])
+ if match:
+ return match.group(1)
+ cRow = cRow - 1
+ return None
+
+def replaceSubstr(s, start, end, newSubStr):
+ """Replace the contents of `s' between `start' and `end' with
+ `newSubStr'."""
+ return s[:start] + newSubStr + s[end:]
+
+def replaceNextParens(lines, row, colStart, newOpenChar, newCloseChar,
+ oldOpenChar = '(', oldCloseChar = ')'):
+ """Replace the next set of parentheses with different characters. The
+ opening parenthesis must be located on line `row', and on or after
+ `colStart'. The closing parenthesis may be on the same line or any following
+ line. The strings are edited in-place.
+
+ Throws a ParseError if the set of parentheses can't be found. In this case,
+ the strings in `lines' will be untouched."""
+ try:
+ pOpen, pClose = findBalancedParens(lines, row, colStart, oldOpenChar,
+ oldCloseChar)
+ except ParseError:
+ raise
+
+ # Replacement may change string length. Replace closing paren first.
+ r, c = pClose
+ lines[r] = replaceSubstr(lines[r], c, c + 1, newCloseChar)
+ # Replace opening paren.
+ r, c = pOpen
+ lines[r] = replaceSubstr(lines[r], c, c + 1, newOpenChar)
+
+def replaceSimpleGetter(lines, row, colStart, colEnd, newName):
+ """Replace a call to a simple getter function with a reference to a
+ property, e.g. foo.getBar() -> foo.bar
+
+ The function identifier being replaced must be on line `row' and
+ between `colStart' and `colEnd'. The opening parenthesis must follow
+ immediately (whitespace is allowed). The closing parenthesis may be on the
+ same or following lines.
+
+ Throws a ConversionError if the parentheses can't be found. In this case
+ the content of `lines' will be untouched."""
+ try:
+ replaceNextParens(lines, row, colEnd, newOpenChar = '', newCloseChar = '')
+ except ParseError:
+ raise ConversionError, ("Deprecated function reference.")
+
+ lines[row] = replaceSubstr(lines[row], colStart, colEnd, newName)
+
+def replaceSimpleSetter(lines, row, colStart, colEnd, newName):
+ """Replace a call to a simple setter function with a reference to a
+ property, e.g. foo.setBar(baz) -> foo.bar = baz
+
+ The function identifier being replaced must be on line `row' and
+ between `colStart' and `colEnd'. The opening parenthesis must follow
+ immediately (whitespace is allowed). The closing parenthesis may be on the
+ same or following lines.
+
+ Throws a ConversionError if the parentheses can't be found. In this case
+ the content of `lines' will be untouched."""
+ try:
+ replaceNextParens(lines, row, colEnd, newOpenChar = '', newCloseChar = '')
+ except ParseError:
+ raise ConversionError, ("Deprecated function reference.")
+
+ lines[row] = replaceSubstr(lines[row], colStart, colEnd, newName + ' = ')
+
+def replaceArgsWithListSetter(lines, row, colStart, colEnd, newName):
+ """Replace a call to a multi-agument setter function with a reference to a
+ list property, e.g. foo.setBar(baz, bazZ) -> foo.bar = [baz, bazZ]
+
+ The function identifier being replaced must be on line `row' and
+ between `colStart' and `colEnd'. The opening parenthesis must follow
+ immediately (whitespace is allowed). The closing parenthesis may be on the
+ same or following lines.
+
+ Throws a ConversionError if the parentheses can't be found. In this case
+ the content of `lines' will be untouched."""
+ try:
+ replaceNextParens(lines, row, colEnd, newOpenChar = '[', newCloseChar = ']')
+ except ParseError:
+ raise ConversionError, ("Deprecated function reference.")
+
+ lines[row] = replaceSubstr(lines[row], colStart, colEnd, newName + ' = ')
+
+
+def replaceKeyedGetter(lines, row, colStart, colEnd, newName):
+ """Replace a call to a keyed getter function with a reference to a
+ property, e.g. foo.getBar(baz) -> foo.bar[baz]
+
+ The function identifier being replaced must be on line `row' and
+ between `colStart' and `colEnd'. The opening parenthesis must follow
+ immediately (whitespace is allowed). The closing parenthesis may be on the
+ same or following lines.
+
+ Throws a ConversionError if the parentheses can't be found. In this case
+ the content of `lines' will be untouched."""
+ try:
+ replaceNextParens(lines, row, colEnd, newOpenChar = '[', newCloseChar = ']')
+ except ParseError:
+ raise ConversionError, ("Deprecated function reference.")
+
+ lines[row] = replaceSubstr(lines[row], colStart, colEnd, newName)
+
+def replaceGetXYPosition(lines, row, colStart, colEnd, axis):
+ '''SCA_MouseSensor.getXPosition; SCA_MouseSensor.getYPosition.
+ This is like a keyed getter, but the key is embedded in the attribute
+ name.
+
+ Throws a ConversionError if the parentheses can't be found. In this case
+ the content of `lines' will be untouched.'''
+ try:
+ (openRow, openCol), (closeRow, closeCol) = findBalancedParens(lines,
+ row, colEnd)
+ except ParseError:
+ raise ConversionError, "Deprecated function reference."
+ if closeRow != row:
+ raise ConversionError, "Can't modify multiple lines."
+
+ lines[row] = replaceSubstr(lines[row], openCol, closeCol + 1,
+ "[%s]" % axis)
+
+ lines[row] = replaceSubstr(lines[row], colStart, colEnd, 'position')
+
+def replaceRename(lines, row, colStart, colEnd, newName):
+ """Replace an identifier with another, e.g.
+ foo.getBar() -> foo.getBaz()
+ foo.bar -> foo.baz
+
+ The identifier being replaced must be on line `row' and between `colStart'
+ and `colEnd'."""
+ lines[row] = replaceSubstr(lines[row], colStart, colEnd, newName)
+
+def replaceAddActiveActuator(lines, row, colStart, colEnd, closure):
+ '''Extra work needs to be done here to find out the name of the controller,
+ and whether the actuator should be activated or deactivated.
+
+ Throws a ConversionError if the actuator, controller or condition can't be
+ found. In this case the content of `lines' will be untouched.'''
+ try:
+ (openRow, openCol), (closeRow, closeCol) = findBalancedParens(lines, row, colEnd)
+ except ParseError:
+ ConversionError, "Can't find arguments."
+
+ if closeRow != openRow:
+ raise ConversionError, ("Can't perform conversion: arguments span multiple lines.")
+
+ args = lines[row][openCol + 1:closeCol]
+ match = re.search(r'([a-zA-Z_]\w*)' # Actuator identifier
+ r',\s*'
+ r'([0-9a-zA-Z_]\w*)', # Condition (boolean)
+ args)
+ if not match:
+ raise ConversionError, "Can't find arguments."
+
+ actuator = match.group(1)
+ condition = match.group(2)
+ controller = None
+
+ assn = findLastAssignment(lines, row, actuator)
+ if assn:
+ match = re.search(r'([a-zA-Z_]\w*)' # Controller identifier
+ r'\s*\.\s*' # Dot
+ r'(actuators\s*\[|getActuator\s*\()', # Dictionary/getter identifier
+ assn)
+ if match:
+ controller = match.group(1)
+
+ if not controller:
+ raise ConversionError, "Can't find actuator's controller."
+
+ gameLogicStart = lines[row].rfind("GameLogic", 0, colStart)
+ if gameLogicStart < 0:
+ raise ConversionError, "Can't find GameLogic identifier."
+
+ newExpr = None
+ if condition in ['1', 'True']:
+ newExpr = "%s.activate(%s)" % (controller, actuator)
+ elif condition in ['0', 'False']:
+ newExpr = "%s.deactivate(%s)" % (controller, actuator)
+ else:
+ newExpr = "(lambda: %s and (%s.activate(%s) or True) or %s.deactivate(%s))()" % (
+ condition, controller, actuator, controller, actuator)
+ lines[row] = replaceSubstr(lines[row], gameLogicStart, closeCol + 1, newExpr)
+
+def getObject(line, attributeStart):
+ '''Get the object that an attribute belongs to. `attributeStart' is the
+ index of the first character of the attribute name in the string `line'.
+ Returns: the identifier preceding `attributeStart', or None if one can't be
+ found.'''
+ match = re.search(r'([a-zA-Z_]\w*)\s*\.\s*$', line[0:attributeStart])
+ if not match:
+ return None
+ return match.group(1)
+
+def replaceGetActuator(lines, row, colStart, colEnd, closure):
+ '''getActuator is ambiguous: it could belong to SCA_IController or
+ SCA_ActuatorSensor. Try to resolve and then convert.
+
+ Raises a ConversionError if the parentheses can't be found, or if the
+ ambiguity can't be resolved.'''
+ # Get the name of the object this attribute is attached to.
+ obName = getObject(lines[row], colStart)
+ if obName:
+ # Try to find out whether the object is a controller.
+ assn = findLastAssignment(lines, row, obName)
+ if assn and re.search(r'GameLogic\s*\.\s*getCurrentController', assn):
+ # It is (probably) a controller!
+ replaceKeyedGetter(lines, row, colStart, colEnd, 'actuators')
+ return
+
+ raise ConversionError, "Ambiguous: addActiveActuator -> actuators[key] (SCA_IController) or actuator (SCA_ActuatorSensor)."
+
+def replaceSetOrientation(lines, row, colStart, colEnd, closure):
+ '''setOrientation is ambiguous: it could belong to KX_SoundActuator or
+ KX_GameObject. Try to resolve and then convert. If the type can't be
+ determined, it is assumed to be a KX_GameObject. Currently, only the
+ conversion for KX_GameObject is implemented.
+
+ Raises a ConversionError if the parentheses can't be found, or if the
+ object is found to be a KX_SoundActuator.'''
+ # Get the name of the object this attribute is attached to.
+ obName = getObject(lines[row], colStart)
+ if obName:
+ # Try to find out whether the object is an actuator.
+ assn = findLastAssignment(lines, row, obName)
+ if assn:
+ match = re.search(r'([a-zA-Z_]\w*)' # Controller identifier
+ r'\s*\.\s*' # Dot
+ r'(actuators\s*\[|getActuator\s*\()', # Dictionary/getter identifier
+ assn)
+ if match:
+ # It's probably a KX_SoundActuator.
+ raise ConversionError, "Not implemented: Can't convert arguments to matrix."
+
+ # It's probably a KX_GameObject.
+ replaceSimpleSetter(lines, row, colStart, colEnd, 'localOrientation')
+
+def replaceSetPosition(lines, row, colStart, colEnd, closure):
+ '''setPosition is ambiguous: it could belong to KX_SoundActuator or
+ KX_GameObject. Try to resolve and then convert. If the type can't be
+ determined, it is assumed to be a KX_GameObject.
+
+ Raises a ConversionError if the parentheses can't be found.'''
+ # Get the name of the object this attribute is attached to.
+ obName = getObject(lines[row], colStart)
+ if obName:
+ # Try to find out whether the object is an actuator.
+ assn = findLastAssignment(lines, row, obName)
+ if assn:
+ match = re.search(r'([a-zA-Z_]\w*)' # Controller identifier
+ r'\s*\.\s*' # Dot
+ r'(actuators\s*\[|getActuator\s*\()', # Dictionary/getter identifier
+ assn)
+ if match:
+ # It's probably a KX_SoundActuator.
+ replaceSimpleSetter(lines, row, colStart, colEnd, 'position')
+
+ # It's probably a KX_GameObject.
+ replaceSimpleSetter(lines, row, colStart, colEnd, 'localPosition')
+
+def replaceSplitProperty(lines, row, colStart, colEnd, (newGetter, newSetter)):
+ '''Some property attributes behave differently when being written to or read
+ from. Try to determine the operation, and replace accordingly. E.G.
+ o.position = foo -> o.localPosition = foo # set
+ foo = o.position -> foo = o.worldPosition # get
+
+ This implementation can not handle cases where the object is returned from
+ a function, e.g.
+ foo = bar.getObject().position # Error!
+
+ Raises a ConversionError if the operation can't be determined, or if the
+ object is returned from a function.'''
+ assnRegex = re.compile(r'(=\s*)?' # Getter
+ r'[a-zA-Z_]\w*' # Object identifier
+ r'\.([a-zA-Z_][a-zA-Z0-9_.]*)+' # Trailing attributes
+ r'(\s*=)?') # Setter
+ match = assnRegex.search(lines[row])
+
+ if not match:
+ raise ConversionError, "Can't determine operation (getting or setting)."
+
+ setting = False
+ getting = False
+ if match.group(1):
+ getting = True
+ if match.group(3):
+ setting = True
+ if (getting and setting) or ((not getting) and (not setting)):
+ raise ConversionError, "Can't determine operation (getting or setting)."
+
+ if getting:
+ replaceRename(lines, row, colStart, colEnd, newGetter)
+ else:
+ replaceRename(lines, row, colStart, colEnd, newSetter)
+
+def notImplemented(lines, row, colStart, colEnd, classNames):
+ message = "Conversion not implemented. See documentation for " +\
+ string.join(classNames, ', ')
+ raise ConversionError, message
+
+#
+# Deprecated attribute information. The format is:
+# deprecatedAttributeName: (conversionFunction, closure)
+# Usually the closure will be the name of the superceding attribute.
+#
+# Since each deprecated attribute can appear in this dictionary only once, it is
+# the conversion function's responsibility to resolve ambiguity.
+#
+attributeRenameDict = {
+ # Special cases
+ 'addActiveActuator': (replaceAddActiveActuator, None), #
+ 'getActuator': (replaceGetActuator, None), # SCA_IController, SCA_ActuatorSensor
+ 'getXPosition': (replaceGetXYPosition, '0'), # SCA_MouseSensor
+ 'getYPosition': (replaceGetXYPosition, '1'), # SCA_MouseSensor
+ 'setOrientation': (replaceSetOrientation, None), # KX_GameObject, KX_SoundActuator
+ 'setPosition': (replaceSetPosition, None), # KX_GameObject, KX_SoundActuator
+
+ # Keyed getters/setters
+ 'getSensor': (replaceKeyedGetter, 'sensors'), # SCA_IController
+
+ # Multi-arg -> List setter
+ 'setAxis': (replaceArgsWithListSetter, 'axis'), # SCA_JoystickSensor
+ 'setForceLimitX': (replaceArgsWithListSetter, 'forceLimitX'), # KX_ObjectActuator
+ 'setForceLimitY': (replaceArgsWithListSetter, 'forceLimitY'), # KX_ObjectActuator
+ 'setForceLimitZ': (replaceArgsWithListSetter, 'forceLimitZ'), # KX_ObjectActuator
+ 'setHat': (replaceArgsWithListSetter, 'hat'), # SCA_JoystickSensor
+ 'setPID': (replaceArgsWithListSetter, 'pid'), # KX_ObjectActuator
+ 'setVelocity': (replaceArgsWithListSetter, 'velocity'), # KX_SoundActuator
+
+ # Straight rename
+ 'getButtonValue': (replaceRename, 'getButtonActiveList'), # SCA_JoystickSensor
+
+ # Split properties
+ 'scaling': (replaceSplitProperty, ('worldScaling', 'localScaling')), # KX_GameObject
+
+ # Simple getters/setters
+ 'getSensors': (replaceSimpleGetter, 'sensors'), # SCA_IController
+ 'getActuators': (replaceSimpleGetter, 'actuators'), # SCA_IController
+ 'enableViewport': (replaceSimpleSetter, 'useViewport'), # KX_Camera
+ 'getAction': (replaceSimpleGetter, 'action'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'getAxis': (replaceSimpleGetter, 'axis'), # SCA_JoystickSensor
+ 'getAxisValue': (replaceSimpleGetter, 'axisValues'), # SCA_JoystickSensor
+ 'getBlendin': (replaceSimpleGetter, 'blendIn'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'getBodies': (replaceSimpleGetter, 'bodies'), # KX_NetworkMessageSensor
+ 'getButton': (replaceSimpleGetter, 'button'), # SCA_JoystickSensor
+ 'getCamera': (replaceSimpleGetter, 'camera'), # KX_SceneActuator
+ 'getConeOrigin': (replaceSimpleGetter, 'coneOrigin'), # KX_RadarSensor
+ 'getConeTarget': (replaceSimpleGetter, 'coneTarget'), # KX_RadarSensor
+ 'getContinue': (replaceSimpleGetter, 'useContinue'), # BL_ActionActuator
+ 'getCurrentlyPressedKeys': (replaceSimpleGetter, 'events'), # SCA_KeyboardSensor
+ 'getDamping': (replaceSimpleGetter, 'damping'), # KX_ObjectActuator
+ 'getDelay': (replaceSimpleGetter, 'delay'), # SCA_DelaySensor
+ 'getDistribution': (replaceSimpleGetter, 'distribution'), # SCA_RandomActuator
+ 'getDuration': (replaceSimpleGetter, 'duration'), # SCA_DelaySensor
+ 'getEnd': (replaceSimpleGetter, 'frameEnd'), # BL_ShapeActionActuator, KX_IpoActuator, BL_ActionActuator
+ 'getExecutePriority': (replaceSimpleGetter, 'executePriority'), # SCA_ILogicBrick
+ 'getFile': (replaceSimpleGetter, 'fileName'), # KX_GameActuator
+ 'getFilename': (replaceSimpleGetter, 'fileName'), # KX_SoundActuator
+ 'getForceIpoActsLocal': (replaceSimpleGetter, 'useIpoLocal'), # KX_IpoActuator
+ 'getForceLimitX': (replaceSimpleGetter, 'forceLimitX'), # KX_ObjectActuator
+ 'getForceLimitY': (replaceSimpleGetter, 'forceLimitY'), # KX_ObjectActuator
+ 'getForceLimitZ': (replaceSimpleGetter, 'forceLimitZ'), # KX_ObjectActuator
+ 'getFrame': (replaceSimpleGetter, 'frame'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'getFrameMessageCount': (replaceSimpleGetter, 'frameMessageCount'), # KX_NetworkMessageSensor
+ 'getFrameProperty': (replaceSimpleGetter, 'framePropName'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'getFrequency': (replaceSimpleGetter, 'frequency'), # SCA_ISensor
+ 'getGain': (replaceSimpleGetter, 'volume'), # KX_SoundActuator, KX_CDActuator
+ 'getHat': (replaceSimpleGetter, 'hat'), # SCA_JoystickSensor
+ 'getHeight': (replaceSimpleGetter, 'height'), # KX_CameraActuator
+ 'getHitNormal': (replaceSimpleGetter, 'hitNormal'), # KX_MouseFocusSensor, KX_RaySensor
+ 'getHitObject': (replaceSimpleGetter, 'hitObject'), # KX_MouseFocusSensor, KX_RaySensor, KX_TouchSensor
+ 'getHitObjectList': (replaceSimpleGetter, 'hitObjectList'), # KX_TouchSensor
+ 'getHitPosition': (replaceSimpleGetter, 'hitPosition'), # KX_MouseFocusSensor, KX_RaySensor
+ 'getHold1': (replaceSimpleGetter, 'hold1'), # SCA_KeyboardSensor
+ 'getHold2': (replaceSimpleGetter, 'hold2'), # SCA_KeyboardSensor
+ 'getInvert': (replaceSimpleGetter, 'invert'), # SCA_ISensor
+ 'getIpoAdd': (replaceSimpleGetter, 'useIpoAdd'), # KX_IpoActuator
+ 'getIpoAsForce': (replaceSimpleGetter, 'useIpoAsForce'), # KX_IpoActuator
+ 'getKey': (replaceSimpleGetter, 'key'), # SCA_KeyboardSensor
+ 'getLastCreatedObject': (replaceSimpleGetter, 'objectLastCreated'), # KX_SCA_AddObjectActuator
+ 'getLevel': (replaceSimpleGetter, 'level'), # SCA_ISensor
+ 'getLightList': (replaceSimpleGetter, 'lights'), # KX_Scene
+ 'getLooping': (replaceSimpleGetter, 'looping'), # KX_SoundActuator
+ 'getMass': (replaceSimpleGetter, 'mass'), # KX_GameObject
+ 'getMax': (replaceSimpleGetter, 'max'), # KX_CameraActuator
+ 'getMin': (replaceSimpleGetter, 'min'), # KX_CameraActuator
+ 'getName': (replaceSimpleGetter, 'name'), # KX_Scene
+ 'getNumAxes': (replaceSimpleGetter, 'numAxis'), # SCA_JoystickSensor
+ 'getNumButtons': (replaceSimpleGetter, 'numButtons'), # SCA_JoystickSensor
+ 'getNumHats': (replaceSimpleGetter, 'numHats'), # SCA_JoystickSensor
+ 'getObjectList': (replaceSimpleGetter, 'objects'), # KX_Scene
+ 'getOperation': (replaceSimpleGetter, 'mode'), # KX_SCA_DynamicActuator
+ 'getOrientation': (replaceSimpleGetter, 'worldOrientation'), # KX_GameObject
+ 'getOwner': (replaceSimpleGetter, 'owner'), # SCA_ILogicBrick
+ 'getPara1': (replaceSimpleGetter, 'para1'), # SCA_RandomActuator
+ 'getPara2': (replaceSimpleGetter, 'para2'), # SCA_RandomActuator
+ 'getParent': (replaceSimpleGetter, 'parent'), # KX_GameObject
+ 'getPID': (replaceSimpleGetter, 'pid'), # KX_ObjectActuator
+ 'getPitch': (replaceSimpleGetter, 'pitch'), # KX_SoundActuator
+ 'getPosition': (replaceSimpleGetter, 'worldPosition'), # KX_GameObject
+ 'getPressedKeys': (replaceSimpleGetter, 'events'), # SCA_KeyboardSensor
+ 'getPriority': (replaceSimpleGetter, 'priority'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'getProjectionMatrix': (replaceSimpleGetter, 'projection_matrix'), # KX_Camera
+ 'getProperty': (replaceSimpleGetter, 'propName'), # SCA_PropertySensor, SCA_RandomActuator, SCA_PropertyActuator
+ 'getRayDirection': (replaceSimpleGetter, 'rayDirection'), # KX_MouseFocusSensor, KX_RaySensor
+ 'getRaySource': (replaceSimpleGetter, 'raySource'), # KX_MouseFocusSensor
+ 'getRayTarget': (replaceSimpleGetter, 'rayTarget'), # KX_MouseFocusSensor
+ 'getRepeat': (replaceSimpleGetter, 'repeat'), # SCA_DelaySensor
+ 'getRollOffFactor': (replaceSimpleGetter, 'rollOffFactor'), # KX_SoundActuator
+ 'getScene': (replaceSimpleGetter, 'scene'), # KX_SceneActuator
+ 'getScript': (replaceSimpleGetter, 'script'), # SCA_PythonController
+ 'getSeed': (replaceSimpleGetter, 'seed'), # SCA_RandomActuator
+ 'getStart': (replaceSimpleGetter, 'frameStart'), # BL_ShapeActionActuator, KX_IpoActuator, BL_ActionActuator
+ 'getState': (replaceSimpleGetter, 'state'), # SCA_IController, KX_GameObject
+ 'getSubject': (replaceSimpleGetter, 'subject'), # KX_NetworkMessageSensor
+ 'getSubjects': (replaceSimpleGetter, 'subjects'), # KX_NetworkMessageSensor
+ 'getThreshold': (replaceSimpleGetter, 'threshold'), # SCA_JoystickSensor
+ 'getTime': (replaceSimpleGetter, 'time'), # KX_SCA_AddObjectActuator, KX_TrackToActuator
+ 'getTouchMaterial': (replaceSimpleGetter, 'useMaterial'), # KX_TouchSensor
+ 'getType': (replaceSimpleGetter, 'mode'), # SCA_PropertySensor
+ 'getUse3D': (replaceSimpleGetter, 'use3D'), # KX_TrackToActuator
+ 'getUseNegPulseMode': (replaceSimpleGetter, 'useNegPulseMode'), # SCA_ISensor
+ 'getUsePosPulseMode': (replaceSimpleGetter, 'usePosPulseMode'), # SCA_ISensor
+ 'getUseRestart': (replaceSimpleGetter, 'useRestart'), # KX_SceneActuator
+ 'getValue': (replaceSimpleGetter, 'value'), # SCA_PropertySensor, SCA_PropertyActuator
+ 'getVisible': (replaceSimpleGetter, 'visible'), # KX_GameObject
+ 'getXY': (replaceSimpleGetter, 'useXY'), # KX_CameraActuator
+ 'isConnected': (replaceSimpleGetter, 'connected'), # SCA_JoystickSensor
+ 'isPositive': (replaceSimpleGetter, 'positive'), # SCA_ISensor
+ 'isTriggered': (replaceSimpleGetter, 'triggered'), # SCA_ISensor
+ 'setActuator': (replaceSimpleSetter, 'actuator'), # SCA_ActuatorSensor
+ 'setBlendin': (replaceSimpleSetter, 'blendIn'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'setBlendtime': (replaceSimpleSetter, 'blendTime'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'setBodyType': (replaceSimpleSetter, 'usePropBody'), # KX_NetworkMessageActuator
+ 'setBody': (replaceSimpleSetter, 'body'), # KX_NetworkMessageActuator
+ 'setButton': (replaceSimpleSetter, 'button'), # SCA_JoystickSensor
+ 'setCamera': (replaceSimpleSetter, 'camera'), # KX_SceneActuator
+ 'setContinue': (replaceSimpleSetter, 'useContinue'), # BL_ActionActuator
+ 'setDamping': (replaceSimpleSetter, 'damping'), # KX_ObjectActuator
+ 'setDelay': (replaceSimpleSetter, 'delay'), # SCA_DelaySensor
+ 'setDuration': (replaceSimpleSetter, 'duration'), # SCA_DelaySensor
+ 'setEnd': (replaceSimpleSetter, 'frameEnd'), # BL_ShapeActionActuator, KX_IpoActuator, BL_ActionActuator
+ 'setExecutePriority': (replaceSimpleSetter, 'executePriority'), # SCA_ILogicBrick
+ 'setFile': (replaceSimpleSetter, 'fileName'), # KX_GameActuator
+ 'setFilename': (replaceSimpleSetter, 'fileName'), # KX_SoundActuator
+ 'setForceIpoActsLocal': (replaceSimpleSetter, 'useIpoLocal'), # KX_IpoActuator
+ 'setFrame': (replaceSimpleSetter, 'frame'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'setFrameProperty': (replaceSimpleSetter, 'framePropName'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'setFrequency': (replaceSimpleSetter, 'frequency'), # SCA_ISensor
+ 'setGain': (replaceSimpleSetter, 'volume'), # KX_SoundActuator, KX_CDActuator
+ 'setHeight': (replaceSimpleSetter, 'height'), # KX_CameraActuator
+ 'setHold1': (replaceSimpleSetter, 'hold1'), # SCA_KeyboardSensor
+ 'setHold2': (replaceSimpleSetter, 'hold2'), # SCA_KeyboardSensor
+ 'setInvert': (replaceSimpleSetter, 'invert'), # SCA_ISensor
+ 'setIpoAdd': (replaceSimpleSetter, 'useIpoAdd'), # KX_IpoActuator
+ 'setIpoAsForce': (replaceSimpleSetter, 'useIpoAsForce'), # KX_IpoActuator
+ 'setKey': (replaceSimpleSetter, 'key'), # SCA_KeyboardSensor
+ 'setLevel': (replaceSimpleSetter, 'level'), # SCA_ISensor
+ 'setLooping': (replaceSimpleSetter, 'looping'), # KX_SoundActuator
+ 'setMask': (replaceSimpleSetter, 'mask'), # KX_StateActuator
+ 'setMax': (replaceSimpleSetter, 'max'), # KX_CameraActuator
+ 'setMesh': (replaceSimpleSetter, 'mesh'), # KX_SCA_ReplaceMeshActuator
+ 'setMin': (replaceSimpleSetter, 'min'), # KX_CameraActuator
+ 'setPitch': (replaceSimpleSetter, 'pitch'), # KX_SoundActuator
+ 'setPriority': (replaceSimpleSetter, 'priority'), # BL_ShapeActionActuator, BL_ActionActuator
+ 'setProjectionMatrix': (replaceSimpleSetter, 'projection_matrix'), # KX_Camera
+ 'setProperty': (replaceSimpleSetter, 'propName'), # KX_IpoActuator, SCA_PropertySensor, SCA_RandomActuator, SCA_PropertyActuator
+ 'setRepeat': (replaceSimpleSetter, 'repeat'), # SCA_DelaySensor
+ 'setRollOffFactor': (replaceSimpleSetter, 'rollOffFactor'), # KX_SoundActuator
+ 'setScene': (replaceSimpleSetter, 'scene'), # KX_SceneActuator
+ 'setScript': (replaceSimpleSetter, 'script'), # SCA_PythonController
+ 'setSeed': (replaceSimpleSetter, 'seed'), # SCA_RandomActuator
+ 'setStart': (replaceSimpleSetter, 'frameStart'), # BL_ShapeActionActuator, KX_IpoActuator, BL_ActionActuator
+ 'setState': (replaceSimpleSetter, 'state'), # KX_GameObject
+ 'setSubject': (replaceSimpleSetter, 'subject'), # KX_NetworkMessageActuator
+ 'setSubjectFilterText': (replaceSimpleSetter, 'subject'), # KX_NetworkMessageSensor
+ 'setThreshold': (replaceSimpleSetter, 'threshold'), # SCA_JoystickSensor
+ 'setTime': (replaceSimpleSetter, 'time'), # KX_SCA_AddObjectActuator, KX_TrackToActuator
+ 'setToPropName': (replaceSimpleSetter, 'propName'), # KX_NetworkMessageActuator
+ 'setType': (replaceSimpleSetter, 'mode'), # SCA_PropertySensor
+ 'setUse3D': (replaceSimpleSetter, 'use3D'), # KX_TrackToActuator
+ 'setUseNegPulseMode': (replaceSimpleSetter, 'useNegPulseMode'), # SCA_ISensor
+ 'setUsePosPulseMode': (replaceSimpleSetter, 'usePosPulseMode'), # SCA_ISensor
+ 'setUseRestart': (replaceSimpleSetter, 'useRestart'), # KX_SceneActuator
+ 'setValue': (replaceSimpleSetter, 'value'), # SCA_PropertySensor, SCA_PropertyActuator
+ 'setXY': (replaceSimpleSetter, 'useXY'), # KX_CameraActuator
+
+ # Unimplemented!
+ 'getLinearVelocity': (notImplemented, ['KX_SCA_AddObjectActuator', 'KX_GameObject']),
+ 'setLinearVelocity': (notImplemented, ['KX_SCA_AddObjectActuator', 'KX_GameObject']),
+ 'getAngularVelocity': (notImplemented, ['KX_SCA_AddObjectActuator', 'KX_GameObject']),
+ 'setAngularVelocity': (notImplemented, ['KX_SCA_AddObjectActuator', 'KX_GameObject']),
+ 'setAction': (notImplemented, ['BL_ShapeActionActuator', 'BL_ActionActuator']),
+ 'set': (notImplemented, ['KX_VisibilityActuator', 'KX_IpoActuator']),
+ 'getIndex': (notImplemented, ['SCA_JoystickSensor']),
+ 'getMesh': (notImplemented, ['KX_SCA_ReplaceMeshActuator']),
+ 'getObject': (notImplemented, ['KX_SCA_AddObjectActuator', 'KX_CameraActuator', 'KX_TrackToActuator', 'KX_ParentActuator']),
+ 'setIndex': (notImplemented, ['SCA_JoystickSensor']),
+ 'setObject': (notImplemented, ['KX_SCA_AddObjectActuator', 'KX_CameraActuator', 'KX_TrackToActuator', 'KX_ParentActuator']),
+ 'setOperation': (notImplemented, ['KX_SCA_DynamicActuator', 'KX_StateActuator']),
+ 'position': (notImplemented, ['KX_GameObject', 'KX_SoundActuator']),
+ 'orientation': (notImplemented, ['KX_GameObject', 'KX_SoundActuator']),
+ 'getDRot': (notImplemented, ['KX_ObjectActuator']),
+ 'setDRot': (notImplemented, ['KX_ObjectActuator']),
+ 'getDLoc': (notImplemented, ['KX_ObjectActuator']),
+ 'setDLoc': (notImplemented, ['KX_ObjectActuator']),
+ 'getTorque': (notImplemented, ['KX_ObjectActuator']),
+ 'getTorque': (notImplemented, ['KX_ObjectActuator']),
+ 'getForce': (notImplemented, ['KX_ObjectActuator']),
+ 'setForce': (notImplemented, ['KX_ObjectActuator']),
+}
+
+def convert248to249(lines, log = True, logErrors = True, fileName = None):
+ # Regular expression for finding attributes. For the string 'a.b', this
+ # returns three groups: ['a.b', 'a.', 'b']. The last is the attribute name.
+ attrRegex = re.compile(r'\.\s*' # Dot
+ r'([a-zA-Z_]\w*)') # Identifier
+
+ fileIdStr = ""
+ if fileName:
+ fileIdStr = fileName + ": "
+ row = 0
+ col = 0
+ nconverted = 0
+ nerrors = 0
+ while row < len(lines):
+ originalLine = lines[row]
+ changed = False
+ while col < len(lines[row]):
+ # Don't search past comment. We have to check each iteration
+ # because the line contents may have changed.
+ commentStart = lines[row].find('#', col)
+ if commentStart < 0:
+ commentStart = len(lines[row])
+
+ # Search for an attribute identifier.
+ match = attrRegex.search(lines[row], col, commentStart)
+ if not match:
+ break
+
+ attrName = match.group(1)
+ if attributeRenameDict.has_key(attrName):
+ # name is deprecated.
+ func, closure = attributeRenameDict[attrName]
+ try:
+ # Convert!
+ func(lines, row, match.start(1), match.end(1), closure)
+ except ConversionError as e:
+ # Insert a comment saying the conversion failed.
+ print "ERROR: %sline %d, %s: %s\n" % (
+ fileIdStr, row + 1, attrName, e)
+ if logErrors:
+ lines.insert(row,
+ "##248## ERROR: %s: %s\n" %
+ (attrName, e))
+ row = row + 1
+ nerrors = nerrors + 1
+ else:
+ changed = True
+ nconverted = nconverted + 1
+ # Search the rest of this line.
+ col = match.start(1)
+
+ if changed and log:
+ # Insert a comment to showing difference in lines.
+ if originalLine[-1] != '\n':
+ originalLine = originalLine + '\n'
+ lines.insert(row, "##248##%s" % originalLine)
+ row = row + 1
+
+ row = row + 1
+ col = 0
+ return nconverted, nerrors
+
+def usage():
+ print "Usage: blender248to249.py [options] <infile> [outfile]"
+ print "Options:"
+ print "\t--nolog Don't include old lines as comments."
+ print "\t--quieterrors Don't insert errors as comments."
+
+def runAsConsoleScript():
+ '''Called when being run as a console script.'''
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "", ["nolog", "quieterrors"])
+ except getopt.GetoptError, err:
+ # print help information and exit:
+ print str(err)
+ usage()
+ sys.exit(2)
+
+ log = True
+ logErrors = True
+ for o, a in opts:
+ if o == "--nolog":
+ log = False
+ elif o == "--quieterrors":
+ logErrors = False
+
+ try:
+ inpath = args.pop(0)
+ except IndexError:
+ usage()
+ sys.exit(2)
+ try:
+ outpath = args.pop(0)
+ except IndexError:
+ outpath = inpath
+
+ infile = io.FileIO(inpath, 'r')
+ # arbitrary file size of around 100kB
+ lines = infile.readlines(100000)
+ infile.close()
+
+ nconverted, nerrors = convert248to249(lines, log, logErrors)
+
+ outfile = io.FileIO(outpath, 'w')
+ outfile.writelines(lines)
+ outfile.close()
+ print "Conversion finished. Modified %d attributes." % nconverted
+ print "There were %d errors." % nerrors
+ print "Please review all the changes."
+
+def runAsTextPlugin():
+ '''Called when run as a text plugin.'''
+
+ import Blender
+ from Blender import Window, sys, Draw
+ import BPyTextPlugin, bpy
+
+ message = ("Convert Game Engine script from 4.48 API to 2.49 API%t|"
+ "Run on active script only%x1|"
+ "Run on ALL text buffers%x2")
+ convertAllBuffers = Draw.PupMenu(message) == 2
+
+ Window.WaitCursor(1)
+ try:
+ nconverted = 0
+ nerrors = 0
+
+ if convertAllBuffers:
+ texts = bpy.data.texts
+ else:
+ if not bpy.data.texts.active:
+ Draw.PupMenu("No active buffer.")
+ return
+ texts = [bpy.data.texts.active]
+
+ Blender.SaveUndoState('Convert BGE 2.49')
+
+ for txt in texts:
+ bufName = txt.name
+ if txt.lib:
+ bufName = txt.lib + '/' + bufName
+ lines = txt.asLines()
+ for i in range(0, len(lines)):
+ if not lines[i].endswith('\n'):
+ lines[i] = lines[i] + '\n'
+
+ nc, ne = convert248to249(lines, fileName = bufName)
+ nconverted = nconverted + nc
+ nerrors = nerrors + ne
+ txt.clear()
+ for line in lines:
+ txt.write(line)
+
+ finally:
+ Window.WaitCursor(0)
+
+ message = "Converted %d attributes." % nconverted
+ if nerrors == 1:
+ message = message + " There was 1 error (see console)."
+ if nerrors > 1:
+ message = message + " There were %d errors (see console)." % nerrors
+ message = message + "|Please review all the changes."
+ Draw.PupMenu(message)
+
+def main():
+ try:
+ import Blender
+ except ImportError:
+ runAsConsoleScript()
+ else:
+ runAsTextPlugin()
+
+# This lets you import the script without running it
+if __name__ == "__main__":
+ import sys
+ import getopt
+ import io
+ main()
diff --git a/release/scripts/uvcalc_quad_clickproj.py b/release/scripts/uvcalc_quad_clickproj.py
index 130a7e5af77..298103e4d5f 100644
--- a/release/scripts/uvcalc_quad_clickproj.py
+++ b/release/scripts/uvcalc_quad_clickproj.py
@@ -46,7 +46,7 @@ import BPyWindow
mouseViewRay= BPyWindow.mouseViewRay
from Blender import Mathutils, Window, Scene, Draw, sys
-from Blender.Mathutils import CrossVecs, Vector, Matrix, LineIntersect, Intersect #, AngleBetweenVecs, Intersect
+from Blender.Mathutils import Vector, Matrix, LineIntersect, Intersect #, AngleBetweenVecs, Intersect
LMB= Window.MButs.L
RMB= Window.MButs.R
@@ -229,7 +229,7 @@ def main():
y_axis_length = line_a_len
x_axis_length = (line_isect_b_pair[1]-face_corner_main).length
- proj_y_component = CrossVecs(proj_x_component, proj_z_component)
+ proj_y_component = proj_x_component.cross(proj_z_component)
proj_y_component.length = 1/y_axis_length
proj_x_component.length = 1/x_axis_length
diff --git a/release/scripts/uvcalc_smart_project.py b/release/scripts/uvcalc_smart_project.py
index 55d6ebfaa6f..9d9bd2aaefd 100644
--- a/release/scripts/uvcalc_smart_project.py
+++ b/release/scripts/uvcalc_smart_project.py
@@ -43,7 +43,7 @@ selected faces, or all faces.
from Blender import Object, Draw, Window, sys, Mesh, Geometry
-from Blender.Mathutils import CrossVecs, Matrix, Vector, RotationMatrix, DotVecs
+from Blender.Mathutils import Matrix, Vector, RotationMatrix
import bpy
from math import cos
@@ -96,7 +96,7 @@ def pointInTri2D(v, v1, v2, v3):
side1 = v2 - v1
side2 = v3 - v1
- nor = CrossVecs(side1, side2)
+ nor = side1.cross(side2)
l1 = [side1[0], side1[1], side1[2]]
l2 = [side2[0], side2[1], side2[2]]
@@ -804,11 +804,11 @@ def VectoMat(vec):
a3 = vec.__copy__().normalize()
up = Vector(0,0,1)
- if abs(DotVecs(a3, up)) == 1.0:
+ if abs(a3.dot(up)) == 1.0:
up = Vector(0,1,0)
- a1 = CrossVecs(a3, up).normalize()
- a2 = CrossVecs(a3, a1)
+ a1 = a3.cross(up).normalize()
+ a2 = a3.cross(a1)
return Matrix([a1[0], a1[1], a1[2]], [a2[0], a2[1], a2[2]], [a3[0], a3[1], a3[2]])
@@ -1001,7 +1001,7 @@ def main():
for fIdx in xrange(len(tempMeshFaces)-1, -1, -1):
# Use half the angle limit so we dont overweight faces towards this
# normal and hog all the faces.
- if DotVecs(newProjectVec, tempMeshFaces[fIdx].no) > USER_PROJECTION_LIMIT_HALF_CONVERTED:
+ if newProjectVec.dot(tempMeshFaces[fIdx].no) > USER_PROJECTION_LIMIT_HALF_CONVERTED:
newProjectMeshFaces.append(tempMeshFaces.pop(fIdx))
# Add the average of all these faces normals as a projectionVec
@@ -1027,7 +1027,7 @@ def main():
# Get the closest vec angle we are to.
for p in projectVecs:
- temp_angle_diff= DotVecs(p, tempMeshFaces[fIdx].no)
+ temp_angle_diff= p.dot(tempMeshFaces[fIdx].no)
if angleDifference < temp_angle_diff:
angleDifference= temp_angle_diff
@@ -1066,14 +1066,14 @@ def main():
i = len(projectVecs)
# Initialize first
- bestAng = DotVecs(fvec, projectVecs[0])
+ bestAng = fvec.dot(projectVecs[0])
bestAngIdx = 0
# Cycle through the remaining, first alredy done
while i-1:
i-=1
- newAng = DotVecs(fvec, projectVecs[i])
+ newAng = fvec.dot(projectVecs[i])
if newAng > bestAng: # Reverse logic for dotvecs
bestAng = newAng
bestAngIdx = i
diff --git a/release/scripts/vertexpaint_selfshadow_ao.py b/release/scripts/vertexpaint_selfshadow_ao.py
index 95ba7d2fb23..54c67fd27e2 100644
--- a/release/scripts/vertexpaint_selfshadow_ao.py
+++ b/release/scripts/vertexpaint_selfshadow_ao.py
@@ -45,7 +45,6 @@ import BPyMesh
def vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PREF_CLAMP_CONCAVE, PREF_CLAMP_CONVEX, PREF_SHADOW_ONLY, PREF_SEL_ONLY):
Window.WaitCursor(1)
- DotVecs = Mathutils.DotVecs
Ang= Mathutils.AngleBetweenVecs
BPyMesh.meshCalcNormals(me)
@@ -63,7 +62,7 @@ def vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PRE
for v in f.v:
vno=v.no # get a scaled down normal.
- dot= DotVecs(vno, v.co) - DotVecs(vno, fc)
+ dot= vno.dot(v.co) - vno.dot(fc)
vert_tone_count[v.index]+=1
try:
a= Ang(vno, fno)
@@ -180,6 +179,10 @@ def main():
t= sys.time()
vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PREF_CLAMP_CONCAVE, PREF_CLAMP_CONVEX, PREF_SHADOW_ONLY, PREF_SEL_ONLY)
+
+ if ob.modifiers:
+ me.update()
+
print 'done in %.6f' % (sys.time()-t)
if __name__=='__main__':
main()
diff --git a/release/scripts/wizard_bolt_factory.py b/release/scripts/wizard_bolt_factory.py
new file mode 100644
index 00000000000..6a280eccc58
--- /dev/null
+++ b/release/scripts/wizard_bolt_factory.py
@@ -0,0 +1,2804 @@
+#!BPY
+# -*- coding: latin-1 -*-
+"""
+Name: 'Bolt Factory'
+Blender: 248
+Group: 'Wizards'
+Tooltip: 'Create models of various types of screw fasteners.'
+"""
+
+__author__ = " Aaron Keith (Spudmn) "
+__version__ = "2.00 2009/05/22"
+__url__ = ["Author's site,http://sourceforge.net/projects/boltfactory/", "Blender,http://wiki.blender.org/index.php/Extensions:Py/Scripts/Manual/Misc/Bolt_Factory"]
+__bpydoc__ = """\
+Bolt_Factory.py
+
+Bolt Factory is a Python script for Blender 3D.
+
+The script allows the user to create models of various types of screw fasteners.
+
+For best results set the material to smooth and apply a Edge Split modifier
+with default settings.
+
+
+History:
+
+V2.00 22/05/09 by Aaron Keith
+
+- Better error checking.
+- Lock Nut and Hex Nut meshes added.
+- Pre-sets for common metric bolts and nuts.
+- Improved GUI.
+- Meshes scaled to a smaller size
+- Fixed bug when using crest and root percent other than 10%
+- Can now create meshes in Edit Mode. This will add to the
+ current mesh and align with the current view.
+
+V1.00 01/04/08 by Aaron Keith
+
+- This version is very much a work in progress.
+- This is my first attempt to program in Python. This version is
+ unpolished and doesn't do much error checking. Therefore
+ if the user sets strange variable the model created will be
+ as equally strange.
+
+- To Do:
+- Better error checking.
+- More Head and Bit types.
+- Better documentation.
+
+
+"""
+
+# --------------------------------------------------------------------------
+# Bolt_Factory.py
+# --------------------------------------------------------------------------
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Copyright (C) 2009: Aaron Keith
+#
+# 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.
+#
+# ***** END GPL LICENCE BLOCK *****
+# --------------------------------------------------------------------------
+
+
+
+
+import Blender
+from Blender import Draw, BGL,Mesh
+from Blender import *
+from math import *
+from Blender import Mathutils
+from Blender.Mathutils import *
+
+
+#Global_Scale = 0.001 #1 blender unit = X mm
+Global_Scale = 0.1 #1 blender unit = X mm
+#Global_Scale = 1.0 #1 blender unit = X mm
+Global_NutRad = 0.0
+MAX_INPUT_NUMBER = 50
+
+No_Event,On_Preset_Click,On_Apply_Click,On_Create_Click,On_Hex_Click, On_Cap_Click,On_Dome_Click,On_Pan_Click,On_Bit_None_Click,On_Bit_Allen_Click,On_Bit_Philips_Click,On_Exit_Click,On_Model_Bolt_Click,On_Model_Nut_Click,On_Hex_Nut_Click,On_Lock_Nut_Click,On_Test_Click = range(17) # this is like a ENUM
+
+
+Head_Type={'HEX' : [Draw.Create(1),On_Hex_Click,""],
+ 'CAP' : [Draw.Create(0),On_Cap_Click,""],
+ 'DOME': [Draw.Create(0),On_Dome_Click,""],
+ 'PAN' : [Draw.Create(0),On_Pan_Click,""]}
+
+
+Bit_Type={'NONE' : [Draw.Create(1),On_Bit_None_Click,""],
+ 'ALLEN' : [Draw.Create(0),On_Bit_Allen_Click,""],
+ 'PHILLIPS': [Draw.Create(0),On_Bit_Philips_Click,""]}
+
+Model_Type={'BOLT' : [Draw.Create(1),On_Model_Bolt_Click,"Bolt Settings"],
+ 'NUT' : [Draw.Create(0),On_Model_Nut_Click,"Nut Settings"]}
+
+Nut_Type={'HEX' : [Draw.Create(1),On_Hex_Nut_Click,""],
+ 'LOCK' : [Draw.Create(0),On_Lock_Nut_Click,""]}
+
+
+Phillips_Bit_Depth = Draw.Create(3.27)
+Philips_Bit_Dia = Draw.Create(5.20)
+
+Allen_Bit_Depth = Draw.Create(4.0)
+Allen_Bit_Flat_Distance = Draw.Create(6.0)
+
+Hex_Head_Height = Draw.Create(5.3)
+Hex_Head_Flat_Distance = Draw.Create(13.0)
+
+Cap_Head_Dia = Draw.Create(13.5)
+Cap_Head_Height = Draw.Create(8.0)
+
+Dome_Head_Dia = Draw.Create(16.0)
+
+Pan_Head_Dia = Draw.Create(16.0)
+
+Shank_Dia = Draw.Create(8.0)
+Shank_Length = Draw.Create(0.0)
+
+Thread_Length = Draw.Create(16.0)
+Major_Dia = Draw.Create(8.0)
+Minor_Dia = Draw.Create(6.917)
+Pitch = Draw.Create(1.0)
+Crest_Percent = Draw.Create(10)
+Root_Percent = Draw.Create(10)
+
+Hex_Nut_Height = Draw.Create(8.0)
+Hex_Nut_Flat_Distance = Draw.Create(13.0)
+
+Preset_Menu = Draw.Create(5)
+
+
+##########################################################################################
+##########################################################################################
+## Miscellaneous Utilities
+##########################################################################################
+##########################################################################################
+
+# Returns a list of verts rotated by the given matrix. Used by SpinDup
+def Rot_Mesh(verts,matrix):
+ return [list(Vector(v) * matrix) for v in verts]
+
+# Returns a list of faces that has there index incremented by offset
+def Copy_Faces(faces,offset):
+ ret = []
+ for f in faces:
+ fsub = []
+ for i in range(len(f)):
+ fsub.append(f[i]+ offset)
+ ret.append(fsub)
+ return ret
+
+
+# Much like Blenders built in SpinDup.
+def SpinDup(VERTS,FACES,DEGREE,DIVISIONS,AXIS):
+ verts=[]
+ faces=[]
+
+ if DIVISIONS == 0:
+ DIVISIONS = 1
+
+ step = DEGREE/DIVISIONS # set step so pieces * step = degrees in arc
+
+ for i in xrange(int(DIVISIONS)):
+ rotmat = Mathutils.RotationMatrix(step*i, 4, AXIS) # 4x4 rotation matrix, 30d about the x axis.
+ Rot = Rot_Mesh(VERTS,rotmat)
+ faces.extend(Copy_Faces(FACES,len(verts)))
+ verts.extend(Rot)
+ return verts,faces
+
+
+# Returns a list of verts that have been moved up the z axis by DISTANCE
+def Move_Verts_Up_Z(VERTS,DISTANCE):
+ return [[v[0],v[1],v[2]+DISTANCE] for v in VERTS]
+
+
+# Returns a list of verts and faces that has been mirrored in the AXIS
+def Mirror_Verts_Faces(VERTS,FACES,AXIS,FLIP_POINT =0):
+ ret_vert = []
+ ret_face = []
+ offset = len(VERTS)
+ if AXIS == 'y':
+ for v in VERTS:
+ Delta = v[0] - FLIP_POINT
+ ret_vert.append([FLIP_POINT-Delta,v[1],v[2]])
+ if AXIS == 'x':
+ for v in VERTS:
+ Delta = v[1] - FLIP_POINT
+ ret_vert.append([v[0],FLIP_POINT-Delta,v[2]])
+ if AXIS == 'z':
+ for v in VERTS:
+ Delta = v[2] - FLIP_POINT
+ ret_vert.append([v[0],v[1],FLIP_POINT-Delta])
+
+ for f in FACES:
+ fsub = []
+ for i in range(len(f)):
+ fsub.append(f[i]+ offset)
+ fsub.reverse() # flip the order to make norm point out
+ ret_face.append(fsub)
+
+ return ret_vert,ret_face
+
+
+
+# Returns a list of faces that
+# make up an array of 4 point polygon.
+def Build_Face_List_Quads(OFFSET,COLUM,ROW,FLIP = 0):
+ Ret =[]
+ RowStart = 0;
+ for j in range(ROW):
+ for i in range(COLUM):
+ Res1 = RowStart + i;
+ Res2 = RowStart + i + (COLUM +1)
+ Res3 = RowStart + i + (COLUM +1) +1
+ Res4 = RowStart+i+1
+ if FLIP:
+ Ret.append([OFFSET+Res1,OFFSET+Res2,OFFSET+Res3,OFFSET+Res4])
+ else:
+ Ret.append([OFFSET+Res4,OFFSET+Res3,OFFSET+Res2,OFFSET+Res1])
+ RowStart += COLUM+1
+ return Ret
+
+
+# Returns a list of faces that makes up a fill pattern for a
+# circle
+def Fill_Ring_Face(OFFSET,NUM,FACE_DOWN = 0):
+ Ret =[]
+ Face = [1,2,0]
+ TempFace = [0,0,0]
+ A = 0
+ B = 1
+ C = 2
+ if NUM < 3:
+ return None
+ for i in range(NUM-2):
+ if (i%2):
+ TempFace[0] = Face[C];
+ TempFace[1] = Face[C] + 1;
+ TempFace[2] = Face[B];
+ if FACE_DOWN:
+ Ret.append([OFFSET+Face[2],OFFSET+Face[1],OFFSET+Face[0]])
+ else:
+ Ret.append([OFFSET+Face[0],OFFSET+Face[1],OFFSET+Face[2]])
+ else:
+ TempFace[0] =Face[C];
+ if Face[C] == 0:
+ TempFace[1] = NUM-1;
+ else:
+ TempFace[1] = Face[C] - 1;
+ TempFace[2] = Face[B];
+ if FACE_DOWN:
+ Ret.append([OFFSET+Face[0],OFFSET+Face[1],OFFSET+Face[2]])
+ else:
+ Ret.append([OFFSET+Face[2],OFFSET+Face[1],OFFSET+Face[0]])
+
+ Face[0] = TempFace[0]
+ Face[1] = TempFace[1]
+ Face[2] = TempFace[2]
+ return Ret
+
+
+##########################################################################################
+##########################################################################################
+## Converter Functions For Bolt Factory
+##########################################################################################
+##########################################################################################
+
+
+def Flat_To_Radius(FLAT):
+ h = (float(FLAT)/2)/cos(radians(30))
+ return h
+
+def Get_Phillips_Bit_Height(Bit_Dia):
+ Flat_Width_half = (Bit_Dia*(0.5/1.82))/2.0
+ Bit_Rad = Bit_Dia / 2.0
+ x = Bit_Rad - Flat_Width_half
+ y = tan(radians(60))*x
+ return y
+
+##########################################################################################
+##########################################################################################
+## Error Checking
+##########################################################################################
+##########################################################################################
+
+
+def Error_Check():
+
+ #global Phillips_Bit_Depth
+ #global Philips_Bit_Dia
+
+ #global Allen_Bit_Depth
+ #global Allen_Bit_Flat_Distance
+
+ #global Hex_Head_Height
+ #global Hex_Head_Flat_Distance
+
+ #global Cap_Head_Dia
+ #global Cap_Head_Height
+
+
+ #global Dome_Head_Dia
+
+ #global Pan_Head_Dia
+
+ #global Shank_Dia
+ #global Shank_Length
+
+ global Thread_Length
+ global Major_Dia
+ global Minor_Dia
+ global Pitch
+ global Hex_Nut_Flat_Distance
+ global Model_Type
+ #global Crest_Percent
+ #global Root_Percent
+
+ Error_Result = 0
+
+ if Minor_Dia.val >= Major_Dia.val:
+ error_txt = "Error%t|Major Dia must be larger than Minor Dia"
+ Blender.Draw.PupMenu(error_txt)
+ print error_txt
+ Error_Result = TRUE
+
+ elif (Model_Type['BOLT'][0].val) and ((Pitch.val*7.0) > Thread_Length.val):
+ error_txt = "Error%t|Thread length must be at least 7 times the Pitch"
+ Blender.Draw.PupMenu(error_txt)
+ print error_txt
+ Error_Result = TRUE
+
+ elif (Model_Type['NUT'][0].val) and (Hex_Nut_Flat_Distance.val < Major_Dia.val):
+ error_txt = "Error%t|Nut Flat Distance must be greater than Major Dia"
+ Blender.Draw.PupMenu(error_txt)
+ print error_txt
+ Error_Result = TRUE
+
+ elif (Model_Type['NUT'][0].val) and ((Pitch.val * 2.5 )> Hex_Nut_Height.val):
+ error_txt = "Error%t|Nut Height must be greater than 2.5 * Pitch"
+ Blender.Draw.PupMenu(error_txt)
+ print error_txt
+ Error_Result = TRUE
+
+ elif (Model_Type['BOLT'][0].val):
+ Check_Head_Height = None
+ Check_Bit_Height = None
+ if (Bit_Type['ALLEN'][0].val):
+ Check_Bit_Height = Allen_Bit_Depth.val
+ if (Bit_Type['PHILLIPS'][0].val):
+ Check_Bit_Height = Phillips_Bit_Depth.val
+ if (Head_Type['HEX'][0].val):
+ Check_Head_Height = Hex_Head_Height.val
+ if (Head_Type['CAP'][0].val):
+ Check_Head_Height = Cap_Head_Height.val
+
+ if Check_Head_Height != None and Check_Bit_Height != None :
+ if Check_Bit_Height > Check_Head_Height:
+ error_txt = "Error%t|Bit Depth must not be greater that Head Height"
+ Blender.Draw.PupMenu(error_txt)
+ print error_txt
+ Error_Result = TRUE
+
+
+ return Error_Result
+
+
+
+##########################################################################################
+##########################################################################################
+## Create Allen Bit
+##########################################################################################
+##########################################################################################
+
+
+def Allen_Fill(OFFSET,FLIP= 0):
+ faces = []
+ Lookup = [[19,1,0],
+ [19,2,1],
+ [19,3,2],
+ [19,20,3],
+ [20,4,3],
+ [20,5,4],
+ [20,6,5],
+ [20,7,6],
+ [20,8,7],
+ [20,9,8],
+
+ [20,21,9],
+
+ [21,10,9],
+ [21,11,10],
+ [21,12,11],
+ [21,13,12],
+ [21,14,13],
+ [21,15,14],
+
+ [21,22,15],
+ [22,16,15],
+ [22,17,16],
+ [22,18,17]
+ ]
+ for i in Lookup:
+ if FLIP:
+ faces.append([OFFSET+i[2],OFFSET+i[1],OFFSET+i[0]])
+ else:
+ faces.append([OFFSET+i[0],OFFSET+i[1],OFFSET+i[2]])
+
+ return faces
+
+def Allen_Bit_Dia(FLAT_DISTANCE):
+ Flat_Radius = (float(FLAT_DISTANCE)/2.0)/cos(radians(30))
+ return (Flat_Radius * 1.05) * 2.0
+
+def Allen_Bit_Dia_To_Flat(DIA):
+ Flat_Radius = (DIA/2.0)/1.05
+ return (Flat_Radius * cos (radians(30)))* 2.0
+
+
+
+def Create_Allen_Bit(FLAT_DISTANCE,HEIGHT):
+ Div = 36
+ verts = []
+ faces = []
+
+ Flat_Radius = (float(FLAT_DISTANCE)/2.0)/cos(radians(30))
+ OUTTER_RADIUS = Flat_Radius * 1.05
+ Outter_Radius_Height = Flat_Radius * (0.1/5.77)
+ FaceStart_Outside = len(verts)
+ Deg_Step = 360.0 /float(Div)
+
+ for i in range((Div/2)+1): # only do half and mirror later
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,0])
+
+ FaceStart_Inside = len(verts)
+
+ Deg_Step = 360.0 /float(6)
+ for i in range((6/2)+1):
+ x = sin(radians(i*Deg_Step))* Flat_Radius
+ y = cos(radians(i*Deg_Step))* Flat_Radius
+ verts.append([x,y,0-Outter_Radius_Height])
+
+ faces.extend(Allen_Fill(FaceStart_Outside,0))
+
+
+ FaceStart_Bottom = len(verts)
+
+ Deg_Step = 360.0 /float(6)
+ for i in range((6/2)+1):
+ x = sin(radians(i*Deg_Step))* Flat_Radius
+ y = cos(radians(i*Deg_Step))* Flat_Radius
+ verts.append([x,y,0-HEIGHT])
+
+ faces.extend(Build_Face_List_Quads(FaceStart_Inside,3,1,TRUE))
+ faces.extend(Fill_Ring_Face(FaceStart_Bottom,4))
+
+
+ M_Verts,M_Faces = Mirror_Verts_Faces(verts,faces,'y')
+ verts.extend(M_Verts)
+ faces.extend(M_Faces)
+
+ return verts,faces,OUTTER_RADIUS * 2.0
+
+
+##########################################################################################
+##########################################################################################
+## Create Phillips Bit
+##########################################################################################
+##########################################################################################
+
+
+def Phillips_Fill(OFFSET,FLIP= 0):
+ faces = []
+ Lookup = [[0,1,10],
+ [1,11,10],
+ [1,2,11],
+ [2,12,11],
+
+ [2,3,12],
+ [3,4,12],
+ [4,5,12],
+ [5,6,12],
+ [6,7,12],
+
+ [7,13,12],
+ [7,8,13],
+ [8,14,13],
+ [8,9,14],
+
+
+ [10,11,16,15],
+ [11,12,16],
+ [12,13,16],
+ [13,14,17,16],
+ [15,16,17,18]
+
+
+ ]
+ for i in Lookup:
+ if FLIP:
+ if len(i) == 3:
+ faces.append([OFFSET+i[2],OFFSET+i[1],OFFSET+i[0]])
+ else:
+ faces.append([OFFSET+i[3],OFFSET+i[2],OFFSET+i[1],OFFSET+i[0]])
+ else:
+ if len(i) == 3:
+ faces.append([OFFSET+i[0],OFFSET+i[1],OFFSET+i[2]])
+ else:
+ faces.append([OFFSET+i[0],OFFSET+i[1],OFFSET+i[2],OFFSET+i[3]])
+ return faces
+
+
+
+def Create_Phillips_Bit(FLAT_DIA,FLAT_WIDTH,HEIGHT):
+ Div = 36
+ verts = []
+ faces = []
+
+ FLAT_RADIUS = FLAT_DIA * 0.5
+ OUTTER_RADIUS = FLAT_RADIUS * 1.05
+
+ Flat_Half = float(FLAT_WIDTH)/2.0
+
+ FaceStart_Outside = len(verts)
+ Deg_Step = 360.0 /float(Div)
+ for i in range((Div/4)+1): # only do half and mirror later
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,0])
+
+
+ FaceStart_Inside = len(verts)
+ verts.append([0,FLAT_RADIUS,0]) #10
+ verts.append([Flat_Half,FLAT_RADIUS,0]) #11
+ verts.append([Flat_Half,Flat_Half,0]) #12
+ verts.append([FLAT_RADIUS,Flat_Half,0]) #13
+ verts.append([FLAT_RADIUS,0,0]) #14
+
+
+ verts.append([0,Flat_Half,0-HEIGHT]) #15
+ verts.append([Flat_Half,Flat_Half,0-HEIGHT]) #16
+ verts.append([Flat_Half,0,0-HEIGHT]) #17
+
+ verts.append([0,0,0-HEIGHT]) #18
+
+ faces.extend(Phillips_Fill(FaceStart_Outside,TRUE))
+
+ Spin_Verts,Spin_Face = SpinDup(verts,faces,360,4,'z')
+
+ return Spin_Verts,Spin_Face,OUTTER_RADIUS * 2
+
+
+##########################################################################################
+##########################################################################################
+## Create Head Types
+##########################################################################################
+##########################################################################################
+
+def Max_Pan_Bit_Dia(HEAD_DIA):
+ HEAD_RADIUS = HEAD_DIA * 0.5
+ XRad = HEAD_RADIUS * 1.976
+ return (sin(radians(10))*XRad) * 2.0
+
+
+def Create_Pan_Head(HOLE_DIA,HEAD_DIA,SHANK_DIA,HEIGHT,RAD1,RAD2,FACE_OFFSET):
+
+ DIV = 36
+ HOLE_RADIUS = HOLE_DIA * 0.5
+ HEAD_RADIUS = HEAD_DIA * 0.5
+ SHANK_RADIUS = SHANK_DIA * 0.5
+
+ verts = []
+ faces = []
+ Row = 0
+ BEVEL = HEIGHT * 0.01
+ #Dome_Rad = HEAD_RADIUS * (1.0/1.75)
+
+ Dome_Rad = HEAD_RADIUS * 1.12
+ RAD_Offset = HEAD_RADIUS * 0.96
+ OtherRad = HEAD_RADIUS * 0.16
+ OtherRad_X_Offset = HEAD_RADIUS * 0.84
+ OtherRad_Z_Offset = HEAD_RADIUS * 0.504
+ XRad = HEAD_RADIUS * 1.976
+ ZRad = HEAD_RADIUS * 1.768
+ EndRad = HEAD_RADIUS * 0.284
+ EndZOffset = HEAD_RADIUS * 0.432
+ HEIGHT = HEAD_RADIUS * 0.59
+
+# Dome_Rad = 5.6
+# RAD_Offset = 4.9
+# OtherRad = 0.8
+# OtherRad_X_Offset = 4.2
+# OtherRad_Z_Offset = 2.52
+# XRad = 9.88
+# ZRad = 8.84
+# EndRad = 1.42
+# EndZOffset = 2.16
+# HEIGHT = 2.95
+
+ FaceStart = FACE_OFFSET
+
+ z = cos(radians(10))*ZRad
+ verts.append([HOLE_RADIUS,0.0,(0.0-ZRad)+z])
+ Start_Height = 0 - ((0.0-ZRad)+z)
+ Row += 1
+
+ #for i in range(0,30,10): was 0 to 30 more work needed to make this look good.
+ for i in range(10,30,10):
+ x = sin(radians(i))*XRad
+ z = cos(radians(i))*ZRad
+ verts.append([x,0.0,(0.0-ZRad)+z])
+ Row += 1
+
+ for i in range(20,140,10):
+ x = sin(radians(i))*EndRad
+ z = cos(radians(i))*EndRad
+ if ((0.0 - EndZOffset)+z) < (0.0-HEIGHT):
+ verts.append([(HEAD_RADIUS -EndRad)+x,0.0,0.0 - HEIGHT])
+ else:
+ verts.append([(HEAD_RADIUS -EndRad)+x,0.0,(0.0 - EndZOffset)+z])
+ Row += 1
+
+
+ verts.append([SHANK_RADIUS,0.0,(0.0-HEIGHT)])
+ Row += 1
+
+ verts.append([SHANK_RADIUS,0.0,(0.0-HEIGHT)-Start_Height])
+ Row += 1
+
+
+ sVerts,sFaces = SpinDup(verts,faces,360,DIV,'z')
+ sVerts.extend(verts) #add the start verts to the Spin verts to complete the loop
+
+ faces.extend(Build_Face_List_Quads(FaceStart,Row-1,DIV))
+
+ Global_Head_Height = HEIGHT ;
+
+
+ return Move_Verts_Up_Z(sVerts,Start_Height),faces,HEIGHT
+
+
+
+def Create_Dome_Head(HOLE_DIA,HEAD_DIA,SHANK_DIA,HEIGHT,RAD1,RAD2,FACE_OFFSET):
+ DIV = 36
+ HOLE_RADIUS = HOLE_DIA * 0.5
+ HEAD_RADIUS = HEAD_DIA * 0.5
+ SHANK_RADIUS = SHANK_DIA * 0.5
+
+ verts = []
+ faces = []
+ Row = 0
+ BEVEL = HEIGHT * 0.01
+ #Dome_Rad = HEAD_RADIUS * (1.0/1.75)
+
+ Dome_Rad = HEAD_RADIUS * 1.12
+ #Head_Height = HEAD_RADIUS * 0.78
+ RAD_Offset = HEAD_RADIUS * 0.98
+ Dome_Height = HEAD_RADIUS * 0.64
+ OtherRad = HEAD_RADIUS * 0.16
+ OtherRad_X_Offset = HEAD_RADIUS * 0.84
+ OtherRad_Z_Offset = HEAD_RADIUS * 0.504
+
+
+# Dome_Rad = 5.6
+# RAD_Offset = 4.9
+# Dome_Height = 3.2
+# OtherRad = 0.8
+# OtherRad_X_Offset = 4.2
+# OtherRad_Z_Offset = 2.52
+#
+
+ FaceStart = FACE_OFFSET
+
+ verts.append([HOLE_RADIUS,0.0,0.0])
+ Row += 1
+
+
+ for i in range(0,60,10):
+ x = sin(radians(i))*Dome_Rad
+ z = cos(radians(i))*Dome_Rad
+ if ((0.0-RAD_Offset)+z) <= 0:
+ verts.append([x,0.0,(0.0-RAD_Offset)+z])
+ Row += 1
+
+
+ for i in range(60,160,10):
+ x = sin(radians(i))*OtherRad
+ z = cos(radians(i))*OtherRad
+ z = (0.0-OtherRad_Z_Offset)+z
+ if z < (0.0-Dome_Height):
+ z = (0.0-Dome_Height)
+ verts.append([OtherRad_X_Offset+x,0.0,z])
+ Row += 1
+
+ verts.append([SHANK_RADIUS,0.0,(0.0-Dome_Height)])
+ Row += 1
+
+
+ sVerts,sFaces = SpinDup(verts,faces,360,DIV,'z')
+ sVerts.extend(verts) #add the start verts to the Spin verts to complete the loop
+
+ faces.extend(Build_Face_List_Quads(FaceStart,Row-1,DIV))
+
+ return sVerts,faces,Dome_Height
+
+
+
+def Create_Cap_Head(HOLE_DIA,HEAD_DIA,SHANK_DIA,HEIGHT,RAD1,RAD2):
+ DIV = 36
+
+ HOLE_RADIUS = HOLE_DIA * 0.5
+ HEAD_RADIUS = HEAD_DIA * 0.5
+ SHANK_RADIUS = SHANK_DIA * 0.5
+
+ verts = []
+ faces = []
+ Row = 0
+ BEVEL = HEIGHT * 0.01
+
+
+ FaceStart = len(verts)
+
+ verts.append([HOLE_RADIUS,0.0,0.0])
+ Row += 1
+
+ #rad
+
+ for i in range(0,100,10):
+ x = sin(radians(i))*RAD1
+ z = cos(radians(i))*RAD1
+ verts.append([(HEAD_RADIUS-RAD1)+x,0.0,(0.0-RAD1)+z])
+ Row += 1
+
+
+ verts.append([HEAD_RADIUS,0.0,0.0-HEIGHT+BEVEL])
+ Row += 1
+
+ verts.append([HEAD_RADIUS-BEVEL,0.0,0.0-HEIGHT])
+ Row += 1
+
+ #rad2
+
+ for i in range(0,100,10):
+ x = sin(radians(i))*RAD2
+ z = cos(radians(i))*RAD2
+ verts.append([(SHANK_RADIUS+RAD2)-x,0.0,(0.0-HEIGHT-RAD2)+z])
+ Row += 1
+
+
+ sVerts,sFaces = SpinDup(verts,faces,360,DIV,'z')
+ sVerts.extend(verts) #add the start verts to the Spin verts to complete the loop
+
+
+ faces.extend(Build_Face_List_Quads(FaceStart,Row-1,DIV))
+
+ return sVerts,faces,HEIGHT+RAD2
+
+
+
+def Create_Hex_Head(FLAT,HOLE_DIA,SHANK_DIA,HEIGHT):
+
+ verts = []
+ faces = []
+ HOLE_RADIUS = HOLE_DIA * 0.5
+ Half_Flat = FLAT/2
+ TopBevelRadius = Half_Flat - (Half_Flat* (0.05/8))
+ Undercut_Height = (Half_Flat* (0.05/8))
+ Shank_Bevel = (Half_Flat* (0.05/8))
+ Flat_Height = HEIGHT - Undercut_Height - Shank_Bevel
+ #Undercut_Height = 5
+ SHANK_RADIUS = SHANK_DIA/2
+ Row = 0;
+
+ verts.append([0.0,0.0,0.0])
+
+
+ FaceStart = len(verts)
+ #inner hole
+
+ x = sin(radians(0))*HOLE_RADIUS
+ y = cos(radians(0))*HOLE_RADIUS
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/6))*HOLE_RADIUS
+ y = cos(radians(60/6))*HOLE_RADIUS
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/3))*HOLE_RADIUS
+ y = cos(radians(60/3))*HOLE_RADIUS
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/2))*HOLE_RADIUS
+ y = cos(radians(60/2))*HOLE_RADIUS
+ verts.append([x,y,0.0])
+ Row += 1
+
+ #bevel
+
+ x = sin(radians(0))*TopBevelRadius
+ y = cos(radians(0))*TopBevelRadius
+ vec1 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/6))*TopBevelRadius
+ y = cos(radians(60/6))*TopBevelRadius
+ vec2 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/3))*TopBevelRadius
+ y = cos(radians(60/3))*TopBevelRadius
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/2))*TopBevelRadius
+ y = cos(radians(60/2))*TopBevelRadius
+ vec4 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,0.0])
+ Row += 1
+
+ #Flats
+
+ x = tan(radians(0))*Half_Flat
+ dvec = vec1 - Mathutils.Vector([x,Half_Flat,0.0])
+ verts.append([x,Half_Flat,-dvec.length])
+
+
+ x = tan(radians(60/6))*Half_Flat
+ dvec = vec2 - Mathutils.Vector([x,Half_Flat,0.0])
+ verts.append([x,Half_Flat,-dvec.length])
+
+
+ x = tan(radians(60/3))*Half_Flat
+ dvec = vec3 - Mathutils.Vector([x,Half_Flat,0.0])
+ Lowest_Point = -dvec.length
+ verts.append([x,Half_Flat,-dvec.length])
+
+
+ x = tan(radians(60/2))*Half_Flat
+ dvec = vec4 - Mathutils.Vector([x,Half_Flat,0.0])
+ Lowest_Point = -dvec.length
+ verts.append([x,Half_Flat,-dvec.length])
+ Row += 1
+
+ #down Bits Tri
+ x = tan(radians(0))*Half_Flat
+ verts.append([x,Half_Flat,Lowest_Point])
+
+ x = tan(radians(60/6))*Half_Flat
+ verts.append([x,Half_Flat,Lowest_Point])
+
+ x = tan(radians(60/3))*Half_Flat
+ verts.append([x,Half_Flat,Lowest_Point])
+
+ x = tan(radians(60/2))*Half_Flat
+ verts.append([x,Half_Flat,Lowest_Point])
+ Row += 1
+
+ #down Bits
+
+ x = tan(radians(0))*Half_Flat
+ verts.append([x,Half_Flat,-Flat_Height])
+
+ x = tan(radians(60/6))*Half_Flat
+ verts.append([x,Half_Flat,-Flat_Height])
+
+ x = tan(radians(60/3))*Half_Flat
+ verts.append([x,Half_Flat,-Flat_Height])
+
+ x = tan(radians(60/2))*Half_Flat
+ verts.append([x,Half_Flat,-Flat_Height])
+ Row += 1
+
+
+ #under cut
+
+ x = sin(radians(0))*Half_Flat
+ y = cos(radians(0))*Half_Flat
+ vec1 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height])
+
+ x = sin(radians(60/6))*Half_Flat
+ y = cos(radians(60/6))*Half_Flat
+ vec2 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height])
+
+ x = sin(radians(60/3))*Half_Flat
+ y = cos(radians(60/3))*Half_Flat
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height])
+
+ x = sin(radians(60/2))*Half_Flat
+ y = cos(radians(60/2))*Half_Flat
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height])
+ Row += 1
+
+ #under cut down bit
+ x = sin(radians(0))*Half_Flat
+ y = cos(radians(0))*Half_Flat
+ vec1 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height])
+
+ x = sin(radians(60/6))*Half_Flat
+ y = cos(radians(60/6))*Half_Flat
+ vec2 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height])
+
+ x = sin(radians(60/3))*Half_Flat
+ y = cos(radians(60/3))*Half_Flat
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height])
+
+ x = sin(radians(60/2))*Half_Flat
+ y = cos(radians(60/2))*Half_Flat
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height])
+ Row += 1
+
+ #under cut to Shank BEVEAL
+ x = sin(radians(0))*(SHANK_RADIUS+Shank_Bevel)
+ y = cos(radians(0))*(SHANK_RADIUS+Shank_Bevel)
+ vec1 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height])
+
+ x = sin(radians(60/6))*(SHANK_RADIUS+Shank_Bevel)
+ y = cos(radians(60/6))*(SHANK_RADIUS+Shank_Bevel)
+ vec2 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height])
+
+ x = sin(radians(60/3))*(SHANK_RADIUS+Shank_Bevel)
+ y = cos(radians(60/3))*(SHANK_RADIUS+Shank_Bevel)
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height])
+
+ x = sin(radians(60/2))*(SHANK_RADIUS+Shank_Bevel)
+ y = cos(radians(60/2))*(SHANK_RADIUS+Shank_Bevel)
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height])
+ Row += 1
+
+ #under cut to Shank BEVEAL
+ x = sin(radians(0))*SHANK_RADIUS
+ y = cos(radians(0))*SHANK_RADIUS
+ vec1 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height-Shank_Bevel])
+
+ x = sin(radians(60/6))*SHANK_RADIUS
+ y = cos(radians(60/6))*SHANK_RADIUS
+ vec2 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height-Shank_Bevel])
+
+ x = sin(radians(60/3))*SHANK_RADIUS
+ y = cos(radians(60/3))*SHANK_RADIUS
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height-Shank_Bevel])
+
+ x = sin(radians(60/2))*SHANK_RADIUS
+ y = cos(radians(60/2))*SHANK_RADIUS
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,-Flat_Height-Undercut_Height-Shank_Bevel])
+ Row += 1
+
+
+ #Global_Head_Height = 0 - (-HEIGHT-0.1)
+ faces.extend(Build_Face_List_Quads(FaceStart,3,Row - 1))
+
+
+ Mirror_Verts,Mirror_Faces = Mirror_Verts_Faces(verts,faces,'y')
+ verts.extend(Mirror_Verts)
+ faces.extend(Mirror_Faces)
+
+ Spin_Verts,Spin_Faces = SpinDup(verts,faces,360,6,'z')
+
+ return Spin_Verts,Spin_Faces,0 - (-HEIGHT)
+
+
+##########################################################################################
+##########################################################################################
+## Create Bolt
+##########################################################################################
+##########################################################################################
+
+
+
+def MakeBolt():
+ global Phillips_Bit_Depth
+ global Philips_Bit_Dia
+
+ global Allen_Bit_Depth
+ global Allen_Bit_Flat_Distance
+
+ global Hex_Head_Height
+ global Hex_Head_Flat_Distance
+
+ global Cap_Head_Dia
+ global Cap_Head_Height
+
+
+ global Dome_Head_Dia
+
+ global Pan_Head_Dia
+
+ global Shank_Dia
+ global Shank_Length
+
+ global Thread_Length
+ global Major_Dia
+ global Minor_Dia
+ global Pitch
+ global Crest_Percent
+ global Root_Percent
+
+ verts = []
+ faces = []
+ Bit_Verts = []
+ Bit_Faces = []
+ Bit_Dia = 0.001
+ Head_Verts = []
+ Head_Faces= []
+ Head_Height = 0.0
+ ReSized_Allen_Bit_Flat_Distance = Allen_Bit_Flat_Distance.val # set default
+
+
+ Head_Height = Hex_Head_Height.val # will be changed by the Head Functions
+
+ if Bit_Type['ALLEN'][0].val and Head_Type['PAN'][0].val:
+ #need to size Allen bit if it is too big.
+ if Allen_Bit_Dia(Allen_Bit_Flat_Distance.val) > Max_Pan_Bit_Dia(Pan_Head_Dia.val):
+ ReSized_Allen_Bit_Flat_Distance = Allen_Bit_Dia_To_Flat(Max_Pan_Bit_Dia(Pan_Head_Dia.val)) * 1.05
+ print "Resized Allen Bit Flat Distance to ",ReSized_Allen_Bit_Flat_Distance
+
+ #bit Mesh
+ if Bit_Type['ALLEN'][0].val:
+ Bit_Verts,Bit_Faces,Bit_Dia = Create_Allen_Bit(ReSized_Allen_Bit_Flat_Distance,Allen_Bit_Depth.val)
+
+ if Bit_Type['PHILLIPS'][0].val:
+ Bit_Verts,Bit_Faces,Bit_Dia = Create_Phillips_Bit(Philips_Bit_Dia.val,Philips_Bit_Dia.val*(0.5/1.82),Phillips_Bit_Depth.val)
+
+
+ #Head Mesh
+ if Head_Type['HEX'][0].val:
+ Head_Verts,Head_Faces,Head_Height = Create_Hex_Head(Hex_Head_Flat_Distance.val,Bit_Dia,Shank_Dia.val,Hex_Head_Height.val)
+
+ elif Head_Type['CAP'][0].val:
+ Head_Verts,Head_Faces,Head_Height = Create_Cap_Head(Bit_Dia,Cap_Head_Dia.val,Shank_Dia.val,Cap_Head_Height.val,Cap_Head_Dia.val*(1.0/19.0),Cap_Head_Dia.val*(1.0/19.0))
+
+ elif Head_Type['DOME'][0].val:
+ Head_Verts,Head_Faces,Head_Height = Create_Dome_Head(Bit_Dia,Dome_Head_Dia.val,Shank_Dia.val,Hex_Head_Height.val,1,1,0)
+
+ elif Head_Type['PAN'][0].val:
+ Head_Verts,Head_Faces,Head_Height = Create_Pan_Head(Bit_Dia,Pan_Head_Dia.val,Shank_Dia.val,Hex_Head_Height.val,1,1,0)
+
+
+ Face_Start = len(verts)
+ verts.extend(Move_Verts_Up_Z(Bit_Verts,Head_Height))
+ faces.extend(Copy_Faces(Bit_Faces,Face_Start))
+
+ Face_Start = len(verts)
+ verts.extend(Move_Verts_Up_Z(Head_Verts,Head_Height))
+ faces.extend(Copy_Faces(Head_Faces,Face_Start))
+
+ Face_Start = len(verts)
+ Thread_Verts,Thread_Faces,Thread_Height = Create_External_Thread(Shank_Dia.val,Shank_Length.val,Minor_Dia.val,Major_Dia.val,Pitch.val,Thread_Length.val,Crest_Percent.val,Root_Percent.val)
+
+ verts.extend(Move_Verts_Up_Z(Thread_Verts,00))
+ faces.extend(Copy_Faces(Thread_Faces,Face_Start))
+
+ return Move_Verts_Up_Z(verts,Thread_Height),faces
+
+
+
+
+
+
+
+##########################################################################################
+##########################################################################################
+## Create Internal Thread
+##########################################################################################
+##########################################################################################
+
+
+def Create_Internal_Thread_Start_Verts(verts,INNER_RADIUS,OUTTER_RADIUS,PITCH,DIV,CREST_PERCENT,ROOT_PERCENT,Height_Offset):
+
+
+ Ret_Row = 0;
+
+ Height_Offset = Height_Offset + PITCH #Move the offset up so that the verts start at
+ #at the correct place (Height_Start)
+
+ Half_Pitch = float(PITCH)/2
+ Height_Start = Height_Offset - PITCH
+ Height_Step = float(PITCH)/float(DIV)
+ Deg_Step = 360.0 /float(DIV)
+
+ Crest_Height = float(PITCH) * float(CREST_PERCENT)/float(100)
+ Root_Height = float(PITCH) * float(ROOT_PERCENT)/float(100)
+ Root_to_Crest_Height = Crest_to_Root_Height = (float(PITCH) - (Crest_Height + Root_Height))/2.0
+
+
+ Rank = float(OUTTER_RADIUS - INNER_RADIUS)/float(DIV)
+ for j in range(1):
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,z])
+ Height_Offset -= Crest_Height
+ Ret_Row += 1
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,z ])
+ Height_Offset -= Crest_to_Root_Height
+ Ret_Row += 1
+
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+ if j == 0:
+ x = sin(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ y = cos(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ verts.append([x,y,z ])
+ Height_Offset -= Root_Height
+ Ret_Row += 1
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+
+ if j == 0:
+ x = sin(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ y = cos(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ verts.append([x,y,z ])
+ Height_Offset -= Root_to_Crest_Height
+ Ret_Row += 1
+
+ return Ret_Row,Height_Offset
+
+
+def Create_Internal_Thread_End_Verts(verts,INNER_RADIUS,OUTTER_RADIUS,PITCH,DIV,CREST_PERCENT,ROOT_PERCENT,Height_Offset):
+
+
+ Ret_Row = 0;
+
+ Half_Pitch = float(PITCH)/2
+ #Height_End = Height_Offset - PITCH - PITCH - PITCH- PITCH - PITCH- PITCH
+ Height_End = Height_Offset - PITCH
+ #Height_End = -2.1
+ Height_Step = float(PITCH)/float(DIV)
+ Deg_Step = 360.0 /float(DIV)
+
+ Crest_Height = float(PITCH) * float(CREST_PERCENT)/float(100)
+ Root_Height = float(PITCH) * float(ROOT_PERCENT)/float(100)
+ Root_to_Crest_Height = Crest_to_Root_Height = (float(PITCH) - (Crest_Height + Root_Height))/2.0
+
+
+
+ Rank = float(OUTTER_RADIUS - INNER_RADIUS)/float(DIV)
+
+ Num = 0
+
+ for j in range(2):
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z < Height_End:
+ z = Height_End
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,z])
+ Height_Offset -= Crest_Height
+ Ret_Row += 1
+
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z < Height_End:
+ z = Height_End
+
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,z ])
+ Height_Offset -= Crest_to_Root_Height
+ Ret_Row += 1
+
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z < Height_End:
+ z = Height_End
+
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+ if j == Num:
+ x = sin(radians(i*Deg_Step))*(INNER_RADIUS + (i*Rank))
+ y = cos(radians(i*Deg_Step))*(INNER_RADIUS + (i*Rank))
+ if j > Num:
+ x = sin(radians(i*Deg_Step))*(OUTTER_RADIUS)
+ y = cos(radians(i*Deg_Step))*(OUTTER_RADIUS )
+
+ verts.append([x,y,z ])
+ Height_Offset -= Root_Height
+ Ret_Row += 1
+
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z < Height_End:
+ z = Height_End
+
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+
+ if j == Num:
+ x = sin(radians(i*Deg_Step))*(INNER_RADIUS + (i*Rank))
+ y = cos(radians(i*Deg_Step))*(INNER_RADIUS + (i*Rank))
+ if j > Num:
+ x = sin(radians(i*Deg_Step))*(OUTTER_RADIUS )
+ y = cos(radians(i*Deg_Step))*(OUTTER_RADIUS )
+
+ verts.append([x,y,z ])
+ Height_Offset -= Root_to_Crest_Height
+ Ret_Row += 1
+
+
+ return Ret_Row,Height_End # send back Height End as this is the lowest point
+
+
+def Create_Internal_Thread(INNER_DIA,OUTTER_DIA,PITCH,HEIGHT,CREST_PERCENT,ROOT_PERCENT,INTERNAL = 1):
+ verts = []
+ faces = []
+
+ DIV = 36
+
+ INNER_RADIUS = INNER_DIA/2
+ OUTTER_RADIUS = OUTTER_DIA/2
+
+ Half_Pitch = float(PITCH)/2
+ Deg_Step = 360.0 /float(DIV)
+ Height_Step = float(PITCH)/float(DIV)
+
+ Num = int(round((HEIGHT- PITCH)/PITCH)) # less one pitch for the start and end that is 1/2 pitch high
+
+ Col = 0
+ Row = 0
+
+
+ Crest_Height = float(PITCH) * float(CREST_PERCENT)/float(100)
+ Root_Height = float(PITCH) * float(ROOT_PERCENT)/float(100)
+ Root_to_Crest_Height = Crest_to_Root_Height = (float(PITCH) - (Crest_Height + Root_Height))/2.0
+
+ Height_Offset = 0
+ FaceStart = len(verts)
+
+ Row_Inc,Height_Offset = Create_Internal_Thread_Start_Verts(verts,INNER_RADIUS,OUTTER_RADIUS,PITCH,DIV,CREST_PERCENT,ROOT_PERCENT,Height_Offset)
+ Row += Row_Inc
+
+ for j in range(Num):
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,Height_Offset - (Height_Step*i) ])
+ Height_Offset -= Crest_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,Height_Offset - (Height_Step*i) ])
+ Height_Offset -= Crest_to_Root_Height
+ Row += 1
+
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+ verts.append([x,y,Height_Offset - (Height_Step*i) ])
+ Height_Offset -= Root_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+ verts.append([x,y,Height_Offset - (Height_Step*i) ])
+ Height_Offset -= Root_to_Crest_Height
+ Row += 1
+
+
+ Row_Inc,Height_Offset = Create_Internal_Thread_End_Verts(verts,INNER_RADIUS,OUTTER_RADIUS,PITCH,DIV,CREST_PERCENT,ROOT_PERCENT,Height_Offset)
+ Row += Row_Inc
+
+ faces.extend(Build_Face_List_Quads(FaceStart,DIV,Row -1,INTERNAL))
+
+ return verts,faces,0 - Height_Offset
+
+
+
+##########################################################################################
+##########################################################################################
+## Create External Thread
+##########################################################################################
+##########################################################################################
+
+
+
+def Thread_Start3(verts,INNER_RADIUS,OUTTER_RADIUS,PITCH,DIV,CREST_PERCENT,ROOT_PERCENT,Height_Offset):
+
+
+ Ret_Row = 0;
+
+ Half_Pitch = float(PITCH)/2
+ Height_Start = Height_Offset - PITCH
+ Height_Step = float(PITCH)/float(DIV)
+ Deg_Step = 360.0 /float(DIV)
+
+ Crest_Height = float(PITCH) * float(CREST_PERCENT)/float(100)
+ Root_Height = float(PITCH) * float(ROOT_PERCENT)/float(100)
+ Root_to_Crest_Height = Crest_to_Root_Height = (float(PITCH) - (Crest_Height + Root_Height))/2.0
+
+#theard start
+
+ Rank = float(OUTTER_RADIUS - INNER_RADIUS)/float(DIV)
+ for j in range(4):
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,z])
+ Height_Offset -= Crest_Height
+ Ret_Row += 1
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,z ])
+ Height_Offset -= Crest_to_Root_Height
+ Ret_Row += 1
+
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+ if j == 0:
+ x = sin(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ y = cos(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ verts.append([x,y,z ])
+ Height_Offset -= Root_Height
+ Ret_Row += 1
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+
+ if j == 0:
+ x = sin(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ y = cos(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ verts.append([x,y,z ])
+ Height_Offset -= Root_to_Crest_Height
+ Ret_Row += 1
+
+ return Ret_Row,Height_Offset
+
+
+def Create_Shank_Verts(START_DIA,OUTTER_DIA,LENGTH,Z_LOCATION = 0):
+
+ verts = []
+ DIV = 36
+
+ START_RADIUS = START_DIA/2
+ OUTTER_RADIUS = OUTTER_DIA/2
+
+ Opp = abs(START_RADIUS - OUTTER_RADIUS)
+ Taper_Lentgh = Opp/tan(radians(31));
+
+ if Taper_Lentgh > LENGTH:
+ Taper_Lentgh = 0
+
+ Stright_Length = LENGTH - Taper_Lentgh
+
+ Deg_Step = 360.0 /float(DIV)
+
+ Row = 0
+
+ Lowest_Z_Vert = 0;
+
+ Height_Offset = Z_LOCATION
+
+
+ #ring
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*START_RADIUS
+ y = cos(radians(i*Deg_Step))*START_RADIUS
+ z = Height_Offset - 0
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Stright_Length
+ Row += 1
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*START_RADIUS
+ y = cos(radians(i*Deg_Step))*START_RADIUS
+ z = Height_Offset - 0
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Taper_Lentgh
+ Row += 1
+
+
+ return verts,Row,Height_Offset
+
+
+def Create_Thread_Start_Verts(INNER_DIA,OUTTER_DIA,PITCH,CREST_PERCENT,ROOT_PERCENT,Z_LOCATION = 0):
+
+ verts = []
+ DIV = 36
+
+ INNER_RADIUS = INNER_DIA/2
+ OUTTER_RADIUS = OUTTER_DIA/2
+
+ Half_Pitch = float(PITCH)/2
+ Deg_Step = 360.0 /float(DIV)
+ Height_Step = float(PITCH)/float(DIV)
+
+ Row = 0
+
+ Lowest_Z_Vert = 0;
+
+ Height_Offset = Z_LOCATION
+
+ Height_Start = Height_Offset
+
+ Crest_Height = float(PITCH) * float(CREST_PERCENT)/float(100)
+ Root_Height = float(PITCH) * float(ROOT_PERCENT)/float(100)
+ Root_to_Crest_Height = Crest_to_Root_Height = (float(PITCH) - (Crest_Height + Root_Height))/2.0
+
+ Rank = float(OUTTER_RADIUS - INNER_RADIUS)/float(DIV)
+
+ Height_Offset = Z_LOCATION + PITCH
+ Cut_off = Z_LOCATION
+
+
+ for j in range(1):
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ z = Height_Offset - (Height_Step*i)
+ if z > Cut_off : z = Cut_off
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Crest_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ z = Height_Offset - (Height_Step*i)
+ if z > Cut_off : z = Cut_off
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Crest_to_Root_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ z = Height_Offset - (Height_Step*i)
+ if z > Cut_off : z = Cut_off
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Root_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ z = Height_Offset - (Height_Step*i)
+ if z > Cut_off : z = Cut_off
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Root_to_Crest_Height
+ Row += 1
+
+
+ for j in range(2):
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Crest_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ verts.append([x,y,z ])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Crest_to_Root_Height
+ Row += 1
+
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+ if j == 0:
+ x = sin(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ y = cos(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ verts.append([x,y,z ])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Root_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ if z > Height_Start:
+ z = Height_Start
+
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+
+ if j == 0:
+ x = sin(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ y = cos(radians(i*Deg_Step))*(OUTTER_RADIUS - (i*Rank))
+ verts.append([x,y,z ])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Root_to_Crest_Height
+ Row += 1
+
+
+ return verts,Row,Height_Offset
+
+
+
+def Create_Thread_Verts(INNER_DIA,OUTTER_DIA,PITCH,HEIGHT,CREST_PERCENT,ROOT_PERCENT,Z_LOCATION = 0):
+ verts = []
+
+ DIV = 36
+
+ INNER_RADIUS = INNER_DIA/2
+ OUTTER_RADIUS = OUTTER_DIA/2
+
+ Half_Pitch = float(PITCH)/2
+ Deg_Step = 360.0 /float(DIV)
+ Height_Step = float(PITCH)/float(DIV)
+
+ NUM_OF_START_THREADS = 4.0
+ NUM_OF_END_THREADS = 3.0
+ Num = int((HEIGHT- ((NUM_OF_START_THREADS*PITCH) + (NUM_OF_END_THREADS*PITCH) ))/PITCH)
+ Row = 0
+
+
+ Crest_Height = float(PITCH) * float(CREST_PERCENT)/float(100)
+ Root_Height = float(PITCH) * float(ROOT_PERCENT)/float(100)
+ Root_to_Crest_Height = Crest_to_Root_Height = (float(PITCH) - (Crest_Height + Root_Height))/2.0
+
+
+ Height_Offset = Z_LOCATION
+
+ Lowest_Z_Vert = 0;
+ FaceStart = len(verts)
+
+
+ for j in range(Num):
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ z = Height_Offset - (Height_Step*i)
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Crest_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
+ y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
+ z = Height_Offset - (Height_Step*i)
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Crest_to_Root_Height
+ Row += 1
+
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+ z = Height_Offset - (Height_Step*i)
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Root_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ x = sin(radians(i*Deg_Step))*INNER_RADIUS
+ y = cos(radians(i*Deg_Step))*INNER_RADIUS
+ z = Height_Offset - (Height_Step*i)
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Root_to_Crest_Height
+ Row += 1
+
+ return verts,Row,Height_Offset
+
+
+
+def Create_Thread_End_Verts(INNER_DIA,OUTTER_DIA,PITCH,CREST_PERCENT,ROOT_PERCENT,Z_LOCATION = 0):
+ verts = []
+
+ DIV = 36
+
+ INNER_RADIUS = INNER_DIA/2
+ OUTTER_RADIUS = OUTTER_DIA/2
+
+ Half_Pitch = float(PITCH)/2
+ Deg_Step = 360.0 /float(DIV)
+ Height_Step = float(PITCH)/float(DIV)
+
+ Crest_Height = float(PITCH) * float(CREST_PERCENT)/float(100)
+ Root_Height = float(PITCH) * float(ROOT_PERCENT)/float(100)
+ Root_to_Crest_Height = Crest_to_Root_Height = (float(PITCH) - (Crest_Height + Root_Height))/2.0
+
+ Col = 0
+ Row = 0
+
+ Height_Offset = Z_LOCATION
+
+ Tapper_Height_Start = Height_Offset - PITCH - PITCH
+
+ Max_Height = Tapper_Height_Start - PITCH
+
+ Lowest_Z_Vert = 0;
+
+ FaceStart = len(verts)
+ for j in range(4):
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ z = max(z,Max_Height)
+ Tapper_Radius = OUTTER_RADIUS
+ if z < Tapper_Height_Start:
+ Tapper_Radius = OUTTER_RADIUS - (Tapper_Height_Start - z)
+
+ x = sin(radians(i*Deg_Step))*(Tapper_Radius)
+ y = cos(radians(i*Deg_Step))*(Tapper_Radius)
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Crest_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ z = max(z,Max_Height)
+ Tapper_Radius = OUTTER_RADIUS
+ if z < Tapper_Height_Start:
+ Tapper_Radius = OUTTER_RADIUS - (Tapper_Height_Start - z)
+
+ x = sin(radians(i*Deg_Step))*(Tapper_Radius)
+ y = cos(radians(i*Deg_Step))*(Tapper_Radius)
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Crest_to_Root_Height
+ Row += 1
+
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ z = max(z,Max_Height)
+ Tapper_Radius = OUTTER_RADIUS - (Tapper_Height_Start - z)
+ if Tapper_Radius > INNER_RADIUS:
+ Tapper_Radius = INNER_RADIUS
+
+ x = sin(radians(i*Deg_Step))*(Tapper_Radius)
+ y = cos(radians(i*Deg_Step))*(Tapper_Radius)
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Root_Height
+ Row += 1
+
+ for i in range(DIV+1):
+ z = Height_Offset - (Height_Step*i)
+ z = max(z,Max_Height)
+ Tapper_Radius = OUTTER_RADIUS - (Tapper_Height_Start - z)
+ if Tapper_Radius > INNER_RADIUS:
+ Tapper_Radius = INNER_RADIUS
+
+ x = sin(radians(i*Deg_Step))*(Tapper_Radius)
+ y = cos(radians(i*Deg_Step))*(Tapper_Radius)
+ verts.append([x,y,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Height_Offset -= Root_to_Crest_Height
+ Row += 1
+
+ return verts,Row,Height_Offset,Lowest_Z_Vert
+
+
+
+
+def Create_External_Thread(SHANK_DIA,SHANK_LENGTH,INNER_DIA,OUTTER_DIA,PITCH,LENGTH,CREST_PERCENT,ROOT_PERCENT):
+
+ verts = []
+ faces = []
+
+ DIV = 36
+
+ Total_Row = 0
+ Thread_Len = 0;
+
+ Face_Start = len(verts)
+ Offset = 0.0;
+
+
+ Shank_Verts,Shank_Row,Offset = Create_Shank_Verts(SHANK_DIA,OUTTER_DIA,SHANK_LENGTH,Offset)
+ Total_Row += Shank_Row
+
+ Thread_Start_Verts,Thread_Start_Row,Offset = Create_Thread_Start_Verts(INNER_DIA,OUTTER_DIA,PITCH,CREST_PERCENT,ROOT_PERCENT,Offset)
+ Total_Row += Thread_Start_Row
+
+
+ Thread_Verts,Thread_Row,Offset = Create_Thread_Verts(INNER_DIA,OUTTER_DIA,PITCH,LENGTH,CREST_PERCENT,ROOT_PERCENT,Offset)
+ Total_Row += Thread_Row
+
+
+ Thread_End_Verts,Thread_End_Row,Offset,Lowest_Z_Vert = Create_Thread_End_Verts(INNER_DIA,OUTTER_DIA,PITCH,CREST_PERCENT,ROOT_PERCENT,Offset )
+ Total_Row += Thread_End_Row
+
+
+ verts.extend(Shank_Verts)
+ verts.extend(Thread_Start_Verts)
+ verts.extend(Thread_Verts)
+ verts.extend(Thread_End_Verts)
+
+ faces.extend(Build_Face_List_Quads(Face_Start,DIV,Total_Row -1,0))
+ faces.extend(Fill_Ring_Face(len(verts)-DIV,DIV,1))
+
+ return verts,faces,0.0 - Lowest_Z_Vert
+
+
+##########################################################################################
+##########################################################################################
+## Create Nut
+##########################################################################################
+##########################################################################################
+
+
+def add_Hex_Nut(FLAT,HOLE_DIA,HEIGHT):
+ global Global_Head_Height
+ global Global_NutRad
+
+ verts = []
+ faces = []
+ HOLE_RADIUS = HOLE_DIA * 0.5
+ Half_Flat = FLAT/2
+ Half_Height = HEIGHT/2
+ TopBevelRadius = Half_Flat - 0.05
+
+ Global_NutRad = TopBevelRadius
+
+ Row = 0;
+ Lowest_Z_Vert = 0.0;
+
+ verts.append([0.0,0.0,0.0])
+
+
+ FaceStart = len(verts)
+ #inner hole
+
+ x = sin(radians(0))*HOLE_RADIUS
+ y = cos(radians(0))*HOLE_RADIUS
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/6))*HOLE_RADIUS
+ y = cos(radians(60/6))*HOLE_RADIUS
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/3))*HOLE_RADIUS
+ y = cos(radians(60/3))*HOLE_RADIUS
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/2))*HOLE_RADIUS
+ y = cos(radians(60/2))*HOLE_RADIUS
+ verts.append([x,y,0.0])
+ Row += 1
+
+ #bevel
+
+ x = sin(radians(0))*TopBevelRadius
+ y = cos(radians(0))*TopBevelRadius
+ vec1 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/6))*TopBevelRadius
+ y = cos(radians(60/6))*TopBevelRadius
+ vec2 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/3))*TopBevelRadius
+ y = cos(radians(60/3))*TopBevelRadius
+ vec3 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,0.0])
+
+
+ x = sin(radians(60/2))*TopBevelRadius
+ y = cos(radians(60/2))*TopBevelRadius
+ vec4 = Mathutils.Vector([x,y,0.0])
+ verts.append([x,y,0.0])
+ Row += 1
+
+ #Flats
+
+ x = tan(radians(0))*Half_Flat
+ dvec = vec1 - Mathutils.Vector([x,Half_Flat,0.0])
+ verts.append([x,Half_Flat,-dvec.length])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,-dvec.length)
+
+
+ x = tan(radians(60/6))*Half_Flat
+ dvec = vec2 - Mathutils.Vector([x,Half_Flat,0.0])
+ verts.append([x,Half_Flat,-dvec.length])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,-dvec.length)
+
+
+ x = tan(radians(60/3))*Half_Flat
+ dvec = vec3 - Mathutils.Vector([x,Half_Flat,0.0])
+ Lowest_Point = -dvec.length
+ verts.append([x,Half_Flat,-dvec.length])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,-dvec.length)
+
+ x = tan(radians(60/2))*Half_Flat
+ dvec = vec4 - Mathutils.Vector([x,Half_Flat,0.0])
+ Lowest_Point = -dvec.length
+ verts.append([x,Half_Flat,-dvec.length])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,-dvec.length)
+ Row += 1
+
+ #down Bits Tri
+ x = tan(radians(0))*Half_Flat
+ verts.append([x,Half_Flat,Lowest_Point])
+
+
+ x = tan(radians(60/6))*Half_Flat
+ verts.append([x,Half_Flat,Lowest_Point])
+
+ x = tan(radians(60/3))*Half_Flat
+ verts.append([x,Half_Flat,Lowest_Point])
+
+ x = tan(radians(60/2))*Half_Flat
+ verts.append([x,Half_Flat,Lowest_Point])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,Lowest_Point)
+ Row += 1
+
+ #down Bits
+
+ x = tan(radians(0))*Half_Flat
+ verts.append([x,Half_Flat,-Half_Height])
+
+ x = tan(radians(60/6))*Half_Flat
+ verts.append([x,Half_Flat,-Half_Height])
+
+ x = tan(radians(60/3))*Half_Flat
+ verts.append([x,Half_Flat,-Half_Height])
+
+ x = tan(radians(60/2))*Half_Flat
+ verts.append([x,Half_Flat,-Half_Height])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,-Half_Height)
+ Row += 1
+
+
+
+
+ faces.extend(Build_Face_List_Quads(FaceStart,3,Row - 1))
+
+
+ Global_Head_Height = HEIGHT
+
+ Tvert,tface = Mirror_Verts_Faces(verts,faces,'z',Lowest_Z_Vert)
+ verts.extend(Tvert)
+ faces.extend(tface)
+
+
+ Tvert,tface = Mirror_Verts_Faces(verts,faces,'y')
+ verts.extend(Tvert)
+ faces.extend(tface)
+
+ S_verts,S_faces = SpinDup(verts,faces,360,6,'z')
+ return S_verts,S_faces,TopBevelRadius
+
+
+def add_Nylon_Head(OUTSIDE_RADIUS,Z_LOCATION = 0):
+ DIV = 36
+ verts = []
+ faces = []
+ Row = 0
+
+ INNER_HOLE = OUTSIDE_RADIUS - (OUTSIDE_RADIUS * (1.25/4.75))
+ EDGE_THICKNESS = (OUTSIDE_RADIUS * (0.4/4.75))
+ RAD1 = (OUTSIDE_RADIUS * (0.5/4.75))
+ OVER_ALL_HEIGTH = (OUTSIDE_RADIUS * (2.0/4.75))
+
+
+ FaceStart = len(verts)
+
+ Start_Height = 0 - 3
+ Height_Offset = Z_LOCATION
+ Lowest_Z_Vert = 0
+
+ x = INNER_HOLE
+ z = (Height_Offset - OVER_ALL_HEIGTH) + EDGE_THICKNESS
+ verts.append([x,0.0,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Row += 1
+
+ x = INNER_HOLE
+ z = (Height_Offset - OVER_ALL_HEIGTH)
+ verts.append([x,0.0,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Row += 1
+
+
+ for i in range(180,80,-10):
+ x = sin(radians(i))*RAD1
+ z = cos(radians(i))*RAD1
+ verts.append([(OUTSIDE_RADIUS-RAD1)+x,0.0,((Height_Offset - OVER_ALL_HEIGTH)+RAD1)+z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Row += 1
+
+
+ x = OUTSIDE_RADIUS - 0
+ z = Height_Offset
+ verts.append([x,0.0,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Row += 1
+
+ sVerts,sFaces = SpinDup(verts,faces,360,DIV,'z')
+ sVerts.extend(verts) #add the start verts to the Spin verts to complete the loop
+
+ faces.extend(Build_Face_List_Quads(FaceStart,Row-1,DIV))
+
+ return Move_Verts_Up_Z(sVerts,0),faces,Lowest_Z_Vert
+
+
+
+def add_Nylon_Part(OUTSIDE_RADIUS,Z_LOCATION = 0):
+ DIV = 36
+ verts = []
+ faces = []
+ Row = 0
+
+ INNER_HOLE = OUTSIDE_RADIUS - (OUTSIDE_RADIUS * (1.5/4.75))
+ EDGE_THICKNESS = (OUTSIDE_RADIUS * (0.4/4.75))
+ RAD1 = (OUTSIDE_RADIUS * (0.5/4.75))
+ OVER_ALL_HEIGTH = (OUTSIDE_RADIUS * (2.0/4.75))
+ PART_THICKNESS = OVER_ALL_HEIGTH - EDGE_THICKNESS
+ PART_INNER_HOLE = (OUTSIDE_RADIUS * (2.5/4.75))
+
+ FaceStart = len(verts)
+
+ Start_Height = 0 - 3
+ Height_Offset = Z_LOCATION
+ Lowest_Z_Vert = 0
+
+
+ x = INNER_HOLE + EDGE_THICKNESS
+ z = Height_Offset
+ verts.append([x,0.0,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Row += 1
+
+ x = PART_INNER_HOLE
+ z = Height_Offset
+ verts.append([x,0.0,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Row += 1
+
+ x = PART_INNER_HOLE
+ z = Height_Offset - PART_THICKNESS
+ verts.append([x,0.0,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Row += 1
+
+ x = INNER_HOLE + EDGE_THICKNESS
+ z = Height_Offset - PART_THICKNESS
+ verts.append([x,0.0,z])
+ Lowest_Z_Vert = min(Lowest_Z_Vert,z)
+ Row += 1
+
+
+ sVerts,sFaces = SpinDup(verts,faces,360,DIV,'z')
+ sVerts.extend(verts) #add the start verts to the Spin verts to complete the loop
+
+ faces.extend(Build_Face_List_Quads(FaceStart,Row-1,DIV))
+
+ return sVerts,faces,0 - Lowest_Z_Vert
+
+
+
+def Nut_Mesh():
+
+ verts = []
+ faces = []
+ Head_Verts = []
+ Head_Faces= []
+
+ Face_Start = len(verts)
+ Thread_Verts,Thread_Faces,New_Nut_Height = Create_Internal_Thread(Minor_Dia.val,Major_Dia.val,Pitch.val,Hex_Nut_Height.val,Crest_Percent.val,Root_Percent.val,1)
+ verts.extend(Thread_Verts)
+ faces.extend(Copy_Faces(Thread_Faces,Face_Start))
+
+ Face_Start = len(verts)
+ Head_Verts,Head_Faces,Lock_Nut_Rad = add_Hex_Nut(Hex_Nut_Flat_Distance.val,Major_Dia.val,New_Nut_Height)
+ verts.extend((Head_Verts))
+ faces.extend(Copy_Faces(Head_Faces,Face_Start))
+
+ LowZ = 0 - New_Nut_Height
+
+ if Nut_Type['LOCK'][0].val:
+ Face_Start = len(verts)
+ Nylon_Head_Verts,Nylon_Head_faces,LowZ = add_Nylon_Head(Lock_Nut_Rad,0-New_Nut_Height)
+ verts.extend((Nylon_Head_Verts))
+ faces.extend(Copy_Faces(Nylon_Head_faces,Face_Start))
+
+ Face_Start = len(verts)
+ Nylon_Verts,Nylon_faces,Temp_LowZ = add_Nylon_Part(Lock_Nut_Rad,0-New_Nut_Height)
+ verts.extend((Nylon_Verts))
+ faces.extend(Copy_Faces(Nylon_faces,Face_Start))
+
+
+ return Move_Verts_Up_Z(verts,0 - LowZ),faces
+
+
+
+##################################################################################################
+
+
+def Create_Nut():
+
+ verts = []
+ faces = []
+
+
+ if Error_Check() :
+ return
+
+
+ verts, faces = Nut_Mesh()
+ Add_Mesh_To_Scene('Nut', verts, faces)
+
+
+##################################################################################################
+
+
+def Create_Bolt():
+ verts = []
+ faces = []
+
+
+ if Error_Check() :
+ return
+
+ verts, faces = MakeBolt()
+ Add_Mesh_To_Scene('Bolt', verts, faces)
+
+
+
+def Remove_Doubles_From_Mesh(verts,faces):
+ Ret_verts = []
+ Ret_faces = []
+
+ is_editmode = Window.EditMode() # Store edit mode state
+ if is_editmode: Window.EditMode(0) # Python must get a mesh in object mode.
+
+ Temp_mesh = Mesh.New('MeshTemp') # create a new mesh
+
+ Temp_mesh.verts.extend(verts) # add vertices to mesh
+ Temp_mesh.faces.extend(faces) # add faces to the mesh (also adds edges)
+
+ scn = Scene.GetCurrent() # link object to current scene
+ Temp_Object = scn.objects.new(Temp_mesh, 'ObjectTemp')
+
+ Temp_mesh.remDoubles(0.010)
+ Temp_mesh.transform(Mathutils.Matrix([Global_Scale,0,0,0], [0,Global_Scale,0,0], [0,0,Global_Scale,0], [0,0,0, Global_Scale]))
+ Ret_verts[:] = [v.co for v in Temp_mesh.verts]
+ Ret_faces[:] = [ [v.index for v in f] for f in Temp_mesh.faces]
+
+ #delete temp mesh
+ scn.objects.unlink(Temp_Object)
+ scn.update(0)
+
+ if is_editmode: Window.EditMode(1)
+ return Ret_verts,Ret_faces
+
+
+
+def Add_Mesh_To_Scene(name, verts, faces):
+
+ scn = Scene.GetCurrent()
+ if scn.lib: return
+ ob_act = scn.objects.active
+
+ is_editmode = Window.EditMode()
+
+ cursor = Window.GetCursorPos()
+ quat = None
+
+ if is_editmode or Blender.Get('add_view_align'): # Aligning seems odd for editmode, but blender does it, oh well
+ try: quat = Blender.Mathutils.Quaternion(Window.GetViewQuat())
+ except: pass
+
+
+ # Exist editmode for non mesh types
+ if ob_act and ob_act.type != 'Mesh' and is_editmode:
+ EditMode(0)
+
+ # We are in mesh editmode
+ if Window.EditMode():
+ me = ob_act.getData(mesh=1)
+
+ if me.multires:
+ error_txt = 'Error%t|Unable to complete action with multires enabled'
+ Blender.Draw.PupMenu(error_txt)
+ print error_txt
+ return
+
+ #Don't want to remove doubles and scale the existing
+ # mesh so we need to get the verts and the faces from
+ # a mesh that has been scaled.
+ verts,faces = Remove_Doubles_From_Mesh(verts, faces)
+
+ # Add to existing mesh
+ # must exit editmode to modify mesh
+ Window.EditMode(0)
+
+ me.sel = False
+
+ vert_offset = len(me.verts)
+ face_offset = len(me.faces)
+
+
+ # transform the verts
+ txmat = Blender.Mathutils.TranslationMatrix(Blender.Mathutils.Vector(cursor))
+ if quat:
+ mat = quat.toMatrix()
+ mat.invert()
+ mat.resize4x4()
+ txmat = mat * txmat
+
+ txmat = txmat * ob_act.matrixWorld.copy().invert()
+
+
+ me.verts.extend(verts)
+ # Transform the verts by the cursor and view rotation
+ me.transform(txmat, selected_only=True)
+
+ if vert_offset:
+ me.faces.extend([[i+vert_offset for i in f] for f in faces])
+ else:
+ # Mesh with no data, unlikely
+ me.faces.extend(faces)
+ else:
+
+ # Object mode add new
+ me = Mesh.New(name)
+ me.verts.extend(verts)
+ me.faces.extend(faces)
+
+
+ me.sel = True
+
+ # Object creation and location
+ scn.objects.selected = []
+ ob_act = scn.objects.new(me, name)
+
+ me.remDoubles(0.010)
+ me.transform(Mathutils.Matrix([Global_Scale,0,0,0], [0,Global_Scale,0,0], [0,0,Global_Scale,0], [0,0,0, Global_Scale]))
+
+ scn.objects.active = ob_act
+
+ if quat:
+ mat = quat.toMatrix()
+ mat.invert()
+ mat.resize4x4()
+ ob_act.setMatrix(mat)
+
+ ob_act.loc = cursor
+
+ me.calcNormals()
+
+ if is_editmode or Blender.Get('add_editmode'):
+ Window.EditMode(1)
+
+ Blender.Redraw(-1)#Redraw all
+
+##################################################################################################
+
+
+
+def Load_Preset():
+
+ global Preset_Menu
+ global Shank_Dia
+ global Shank_Length
+ global Thread_Length
+ global Major_Dia
+ global Minor_Dia
+ global Pitch
+ global Crest_Percent
+ global Root_Percent
+ global Allen_Bit_Flat_Distance
+ global Allen_Bit_Depth
+ global Head_Height
+ global Hex_Head_Flat_Distance
+ global Head_Dia
+ global Dome_Head_Dia
+ global Pan_Head_Dia
+ global Philips_Bit_Dia
+ global Phillips_Bit_Depth
+ global Cap_Head_Height
+
+ global Hex_Nut_Height
+ global Hex_Nut_Flat_Distance
+
+
+ if Preset_Menu.val == 1 : #M3
+ Shank_Dia.val = 3.0
+ #Pitch.val = 0.5 #Coarse
+ Pitch.val = 0.35 #Fine
+ Crest_Percent.val = 10
+ Root_Percent.val = 10
+ Major_Dia.val = 3.0
+ Minor_Dia.val = Major_Dia.val - (1.082532 * Pitch.val)
+ Hex_Head_Flat_Distance.val = 5.5
+ Hex_Head_Height.val = 2.0
+ Cap_Head_Dia.val = 5.5
+ Cap_Head_Height.val = 3.0
+ Allen_Bit_Flat_Distance.val = 2.5
+ Allen_Bit_Depth.val = 1.5
+ Pan_Head_Dia.val = 5.6
+ Dome_Head_Dia.val = 5.6
+ Philips_Bit_Dia.val = Pan_Head_Dia.val*(1.82/5.6)
+ Phillips_Bit_Depth.val = Get_Phillips_Bit_Height(Philips_Bit_Dia.val)
+ Hex_Nut_Height.val = 2.4
+ Hex_Nut_Flat_Distance.val = 5.5
+ Thread_Length.val = 6
+ Shank_Length.val = 0.0
+
+
+ if Preset_Menu.val == 2 : #M4
+ Shank_Dia.val = 4.0
+ #Pitch.val = 0.7 #Coarse
+ Pitch.val = 0.5 #Fine
+ Crest_Percent.val = 10
+ Root_Percent.val = 10
+ Major_Dia.val = 4.0
+ Minor_Dia.val = Major_Dia.val - (1.082532 * Pitch.val)
+ Hex_Head_Flat_Distance.val = 7.0
+ Hex_Head_Height.val = 2.8
+ Cap_Head_Dia.val = 7.0
+ Cap_Head_Height.val = 4.0
+ Allen_Bit_Flat_Distance.val = 3.0
+ Allen_Bit_Depth.val = 2.0
+ Pan_Head_Dia.val = 8.0
+ Dome_Head_Dia.val = 8.0
+ Philips_Bit_Dia.val = Pan_Head_Dia.val*(1.82/5.6)
+ Phillips_Bit_Depth.val = Get_Phillips_Bit_Height(Philips_Bit_Dia.val)
+ Hex_Nut_Height.val = 3.2
+ Hex_Nut_Flat_Distance.val = 7.0
+ Thread_Length.val = 8
+ Shank_Length.val = 0.0
+
+
+ if Preset_Menu.val == 3 : #M5
+ Shank_Dia.val = 5.0
+ #Pitch.val = 0.8 #Coarse
+ Pitch.val = 0.5 #Fine
+ Crest_Percent.val = 10
+ Root_Percent.val = 10
+ Major_Dia.val = 5.0
+ Minor_Dia.val = Major_Dia.val - (1.082532 * Pitch.val)
+ Hex_Head_Flat_Distance.val = 8.0
+ Hex_Head_Height.val = 3.5
+ Cap_Head_Dia.val = 8.5
+ Cap_Head_Height.val = 5.0
+ Allen_Bit_Flat_Distance.val = 4.0
+ Allen_Bit_Depth.val = 2.5
+ Pan_Head_Dia.val = 9.5
+ Dome_Head_Dia.val = 9.5
+ Philips_Bit_Dia.val = Pan_Head_Dia.val*(1.82/5.6)
+ Phillips_Bit_Depth.val = Get_Phillips_Bit_Height(Philips_Bit_Dia.val)
+ Hex_Nut_Height.val = 4.0
+ Hex_Nut_Flat_Distance.val = 8.0
+ Thread_Length.val = 10
+ Shank_Length.val = 0.0
+
+
+ if Preset_Menu.val == 4 : #M6
+ Shank_Dia.val = 6.0
+ #Pitch.val = 1.0 #Coarse
+ Pitch.val = 0.75 #Fine
+ Crest_Percent.val = 10
+ Root_Percent.val = 10
+ Major_Dia.val = 6.0
+ Minor_Dia.val = Major_Dia.val - (1.082532 * Pitch.val)
+ Hex_Head_Flat_Distance.val = 10.0
+ Hex_Head_Height.val = 4.0
+ Cap_Head_Dia.val = 10.0
+ Cap_Head_Height.val = 6.0
+ Allen_Bit_Flat_Distance.val = 5.0
+ Allen_Bit_Depth.val = 3.0
+ Pan_Head_Dia.val = 12.0
+ Dome_Head_Dia.val = 12.0
+ Philips_Bit_Dia.val = Pan_Head_Dia.val*(1.82/5.6)
+ Phillips_Bit_Depth.val = Get_Phillips_Bit_Height(Philips_Bit_Dia.val)
+ Hex_Nut_Height.val = 5.0
+ Hex_Nut_Flat_Distance.val = 10.0
+ Thread_Length.val = 12
+ Shank_Length.val = 0.0
+
+
+ if Preset_Menu.val == 5 : #M8
+ Shank_Dia.val = 8.0
+ #Pitch.val = 1.25 #Coarse
+ Pitch.val = 1.00 #Fine
+ Crest_Percent.val = 10
+ Root_Percent.val = 10
+ Major_Dia.val = 8.0
+ Minor_Dia.val = Major_Dia.val - (1.082532 * Pitch.val)
+ Hex_Head_Flat_Distance.val = 13.0
+ Hex_Head_Height.val = 5.3
+ Cap_Head_Dia.val = 13.5
+ Cap_Head_Height.val = 8.0
+ Allen_Bit_Flat_Distance.val = 6.0
+ Allen_Bit_Depth.val = 4.0
+ Pan_Head_Dia.val = 16.0
+ Dome_Head_Dia.val = 16.0
+ Philips_Bit_Dia.val = Pan_Head_Dia.val*(1.82/5.6)
+ Phillips_Bit_Depth.val = Get_Phillips_Bit_Height(Philips_Bit_Dia.val)
+ Hex_Nut_Height.val = 6.5
+ Hex_Nut_Flat_Distance.val = 13.0
+ Thread_Length.val = 16
+ Shank_Length.val = 0.0
+
+ if Preset_Menu.val == 6 : #M10
+ Shank_Dia.val = 10.0
+ #Pitch.val = 1.5 #Coarse
+ Pitch.val = 1.25 #Fine
+ Crest_Percent.val = 10
+ Root_Percent.val = 10
+ Major_Dia.val = 10.0
+ Minor_Dia.val = Major_Dia.val - (1.082532 * Pitch.val)
+ Hex_Head_Flat_Distance.val = 17.0
+ Hex_Head_Height.val = 6.4
+ Cap_Head_Dia.val = 16.0
+ Cap_Head_Height.val = 10.0
+ Allen_Bit_Flat_Distance.val = 8.0
+ Allen_Bit_Depth.val = 5.0
+ Pan_Head_Dia.val = 20.0
+ Dome_Head_Dia.val = 20.0
+ Philips_Bit_Dia.val = Pan_Head_Dia.val*(1.82/5.6)
+ Phillips_Bit_Depth.val = Get_Phillips_Bit_Height(Philips_Bit_Dia.val)
+ Hex_Nut_Height.val = 8.0
+ Hex_Nut_Flat_Distance.val = 17.0
+ Thread_Length.val = 20
+ Shank_Length.val = 0.0
+
+
+ if Preset_Menu.val == 7 : #M12
+ #Pitch.val = 1.75 #Coarse
+ Pitch.val = 1.50 #Fine
+ Crest_Percent.val = 10
+ Root_Percent.val = 10
+ Major_Dia.val = 12.0
+ Minor_Dia.val = Major_Dia.val - (1.082532 * Pitch.val)
+ Hex_Head_Flat_Distance.val = 19.0
+ Hex_Head_Height.val = 7.5
+ Cap_Head_Dia.val = 18.5
+ Cap_Head_Height.val = 12.0
+ Allen_Bit_Flat_Distance.val = 10.0
+ Allen_Bit_Depth.val = 6.0
+ Pan_Head_Dia.val = 24.0
+ Dome_Head_Dia.val = 24.0
+ Philips_Bit_Dia.val = Pan_Head_Dia.val*(1.82/5.6)
+ Phillips_Bit_Depth.val = Get_Phillips_Bit_Height(Philips_Bit_Dia.val)
+ Hex_Nut_Height.val = 10.0
+ Hex_Nut_Flat_Distance.val = 19.0
+ Shank_Dia.val = 12.0
+ Shank_Length.val = 33.0
+ Thread_Length.val = 32.0
+
+##############################################################################################
+
+def Test():
+ verts = []
+ faces = []
+
+ if Error_Check() :
+ return
+
+ verts, faces = MakeBolt()
+
+ Add_Mesh_To_Scene("TestBolt", verts,faces)
+
+ Window.Redraw(-1)
+
+
+
+
+def event(evt, val): # the function to handle input events
+
+ if evt == Draw.ESCKEY:
+ Draw.Exit() # exit when user presses ESC
+ return
+
+
+def button_event(evt): # the function to handle Draw Button events
+
+ if evt == On_Exit_Click:
+ Draw.Exit() # exit when user presses ESC
+ return
+
+ if evt == On_Test_Click:
+ Test()
+ Draw.Redraw(1)
+
+ if evt == On_Preset_Click:
+ Load_Preset()
+ Draw.Redraw(1)
+
+ if evt == On_Create_Click:
+ if Model_Type['BOLT'][0].val:
+ Create_Bolt()
+ if Model_Type['NUT'][0].val:
+ Create_Nut()
+ Draw.Redraw(1)
+
+ elif (evt in [On_Hex_Click, On_Cap_Click,On_Dome_Click,On_Pan_Click]):
+ for k in Head_Type.iterkeys():
+ if Head_Type[k][1]!=evt:
+ Head_Type[k][0].val=0
+ else:
+ Head_Type[k][0].val=1
+ Draw.Redraw(1)
+
+ elif (evt in [On_Bit_None_Click,On_Bit_Allen_Click,On_Bit_Philips_Click]):
+ for k in Bit_Type.iterkeys():
+ if Bit_Type[k][1]!=evt:
+ Bit_Type[k][0].val=0
+ else:
+ Bit_Type[k][0].val=1
+ Draw.Redraw(1)
+
+ elif (evt in [On_Model_Bolt_Click,On_Model_Nut_Click]):
+ for k in Model_Type.iterkeys():
+ if Model_Type[k][1]!=evt:
+ Model_Type[k][0].val=0
+ else:
+ Model_Type[k][0].val=1
+ Draw.Redraw(1)
+
+ elif (evt in [On_Hex_Nut_Click,On_Lock_Nut_Click]):
+ for k in Nut_Type.iterkeys():
+ if Nut_Type[k][1]!=evt:
+ Nut_Type[k][0].val=0
+ else:
+ Nut_Type[k][0].val=1
+ Draw.Redraw(1)
+
+#####################################################################################
+
+
+def Draw_Border(X1,Y1,X2,Y2): # X1,Y1 = Top Left X2,Y2 = Bottom Right
+ INDENT = 3
+
+ BGL.glColor3f(1.0,1.0,1.0)
+ BGL.glBegin(BGL.GL_LINES)
+ BGL.glVertex2i(X1+INDENT,Y1-INDENT) #top line
+ BGL.glVertex2i(X2-INDENT,Y1-INDENT)
+
+ BGL.glVertex2i(X1+INDENT,Y1-INDENT) #left line
+ BGL.glVertex2i(X1+INDENT,Y2+INDENT)
+ BGL.glEnd()
+
+ BGL.glColor3f(0.5,0.5,0.5)
+ BGL.glBegin(BGL.GL_LINES)
+ BGL.glVertex2i(X2-INDENT,Y1-INDENT) #Right line
+ BGL.glVertex2i(X2-INDENT,Y2+INDENT)
+
+ BGL.glVertex2i(X1+INDENT,Y2+INDENT) #bottom line
+ BGL.glVertex2i(X2-INDENT,Y2+INDENT)
+ BGL.glEnd()
+
+
+
+
+def Create_Tab(X1,Y1,X2,Y2,Title,Buttons): # X1,Y1 = Top Left X2,Y2 = Bottom Right
+
+ BIT_BUTTON_WIDTH = 55
+ BIT_BUTTON_HEIGHT = 18
+ TITLE_HEIGHT = 15
+ INDENT = 6
+ BUTTON_GAP = 4
+
+ BGL.glColor3f(0.75, 0.75, 0.75)
+ BGL.glRecti(X1,Y1,X2,Y2)
+
+ Draw_Border(X1,Y1,X2,Y2);
+
+ BGL.glColor3f(0.0,0.0,0.0)
+ BGL.glRasterPos2d(X1+INDENT,Y1 - TITLE_HEIGHT)
+ Draw.Text(Title)
+
+ Button_X = X1 + INDENT
+ Button_Y = Y1 - TITLE_HEIGHT - BIT_BUTTON_HEIGHT - 8
+
+ #Nut_Number_X = Nut_Button_X
+ #Nut_Number_Y = Nut_Button_Y - 25
+ if (Buttons != 0):
+ key= Buttons.keys()
+ for k in key:
+ Buttons[k][0]= Draw.Toggle(k,Buttons[k][1],Button_X,Button_Y, BIT_BUTTON_WIDTH,BIT_BUTTON_HEIGHT,Buttons[k][0].val,Buttons[k][2])
+ Button_X += BIT_BUTTON_WIDTH + BUTTON_GAP
+
+
+
+def Dispaly_Title_Bar(Y_POS,CONTROL_HEIGHT):
+ CONTROL_WIDTH = 250
+ Create_Tab(3,Y_POS,CONTROL_WIDTH,Y_POS -CONTROL_HEIGHT,"Bolt Factory V2.00",Model_Type)
+
+
+
+def Dispaly_Preset_Tab(Y_POS,CONTROL_HEIGHT):
+ CONTROL_WIDTH = 250
+ BUTTON_Y_OFFSET = 40
+
+ Create_Tab(3,Y_POS,CONTROL_WIDTH,Y_POS-CONTROL_HEIGHT,"Preset",0)
+
+ name = "M3%x1|M4%x2|M5%x3|M6%x4|M8%x5|M10%x6|M12%x7"
+
+ global Preset_Menu
+ Preset_Menu = Draw.Menu(name,No_Event,9,Y_POS-BUTTON_Y_OFFSET,50,18, Preset_Menu.val, "Predefined metric screw sizes.")
+ Draw.Button("Apply",On_Preset_Click,150,Y_POS-BUTTON_Y_OFFSET,55,18,"Apply the preset screw sizes.")
+
+
+def Dispaly_Bit_Tab(Y_POS,CONTROL_HEIGHT):
+
+ CONTROL_WIDTH = 250
+ NUMBER_HEIGHT = 18
+ NUMBER_WIDTH = CONTROL_WIDTH -3-3-3-3-3
+
+ Bit_Number_X = 3+3+3
+ Bit_Number_Y = Y_POS - 64
+
+ Create_Tab(3,Y_POS,CONTROL_WIDTH,Y_POS-CONTROL_HEIGHT,"Bit Type",Bit_Type)
+
+ if Bit_Type['NONE'][0].val:
+ DoNothing = 1;
+
+ elif Bit_Type['ALLEN'][0].val:
+ global Allen_Bit_Depth
+ Allen_Bit_Depth = Draw.Number('Bit Depth: ',No_Event,Bit_Number_X,Bit_Number_Y,NUMBER_WIDTH, NUMBER_HEIGHT,Allen_Bit_Depth.val, 0,100, '')
+ Bit_Number_Y -= NUMBER_HEIGHT
+ global Allen_Bit_Flat_Distance
+ Allen_Bit_Flat_Distance = Draw.Number('Flat Dist: ',No_Event,Bit_Number_X,Bit_Number_Y,NUMBER_WIDTH,NUMBER_HEIGHT,Allen_Bit_Flat_Distance.val, 0,100, '')
+ Bit_Number_Y -= NUMBER_HEIGHT
+
+ elif Bit_Type['PHILLIPS'][0].val:
+ global Phillips_Bit_Depth
+ Phillips_Bit_Depth = Draw.Number('Bit Depth: ',No_Event,Bit_Number_X,Bit_Number_Y,NUMBER_WIDTH, NUMBER_HEIGHT,Phillips_Bit_Depth.val, 0,100, '')
+ Bit_Number_Y -= NUMBER_HEIGHT
+ global Philips_Bit_Dia
+ Philips_Bit_Dia = Draw.Number('Bit Dia: ',No_Event,Bit_Number_X,Bit_Number_Y, NUMBER_WIDTH, NUMBER_HEIGHT,Philips_Bit_Dia.val, 0,100, '')
+ Bit_Number_Y -= NUMBER_HEIGHT
+
+
+
+def Dispaly_Shank_Tab(Y_POS,CONTROL_HEIGHT):
+
+ CONTROL_WIDTH = 250
+ NUMBER_HEIGHT = 18
+ NUMBER_WIDTH = CONTROL_WIDTH -3-3-3-3-3
+
+ Number_X = 3+3+3
+ Number_Y_Pos = Y_POS - 40
+
+ Create_Tab(3,Y_POS,CONTROL_WIDTH,Y_POS-CONTROL_HEIGHT,"Shank",0)
+
+ global Shank_Length
+ Shank_Length = Draw.Number('Shank Length: ',No_Event,Number_X,Number_Y_Pos,NUMBER_WIDTH,NUMBER_HEIGHT, Shank_Length.val, 0,MAX_INPUT_NUMBER, 'some text tip')
+ Number_Y_Pos -= NUMBER_HEIGHT
+
+ global Shank_Dia
+ Shank_Dia = Draw.Number('Shank Dia: ',No_Event,Number_X,Number_Y_Pos,NUMBER_WIDTH,NUMBER_HEIGHT, Shank_Dia.val, 0,MAX_INPUT_NUMBER, 'some text tip')
+ Number_Y_Pos -= NUMBER_HEIGHT
+
+
+
+def Dispaly_Thread_Tab(Y_POS,CONTROL_HEIGHT):
+
+ CONTROL_WIDTH = 250
+ NUMBER_HEIGHT = 18
+ NUMBER_WIDTH = CONTROL_WIDTH -3-3-3-3-3
+
+
+ Number_X = 3+3+3
+ Number_Y_Pos = Y_POS - 40
+
+ Create_Tab(3,Y_POS,CONTROL_WIDTH,Y_POS-CONTROL_HEIGHT,"Thread",0)
+
+ global Thread_Length
+ if Model_Type['BOLT'][0].val:
+ Thread_Length = Draw.Number('Thread Length: ',No_Event, Number_X,Number_Y_Pos,NUMBER_WIDTH,NUMBER_HEIGHT, Thread_Length.val, 0,MAX_INPUT_NUMBER, '')
+ Number_Y_Pos -= NUMBER_HEIGHT
+
+ global Major_Dia
+ Major_Dia = Draw.Number('Major Dia: ',No_Event,Number_X,Number_Y_Pos, NUMBER_WIDTH,NUMBER_HEIGHT, Major_Dia.val, 0,MAX_INPUT_NUMBER, '')
+ Number_Y_Pos -= NUMBER_HEIGHT
+
+ global Minor_Dia
+ Minor_Dia = Draw.Number('Minor Dia: ',No_Event,Number_X,Number_Y_Pos, NUMBER_WIDTH,NUMBER_HEIGHT, Minor_Dia.val, 0,MAX_INPUT_NUMBER, '')
+ Number_Y_Pos -= NUMBER_HEIGHT
+
+ global Pitch
+ Pitch = Draw.Number('Pitch: ',No_Event,Number_X,Number_Y_Pos,NUMBER_WIDTH,NUMBER_HEIGHT, Pitch.val, 0.1,7.0, '')
+ Number_Y_Pos -= NUMBER_HEIGHT
+
+ global Crest_Percent
+ Crest_Percent = Draw.Number('Crest %: ',No_Event,Number_X,Number_Y_Pos,NUMBER_WIDTH,NUMBER_HEIGHT,Crest_Percent.val, 1,90, '')
+ Number_Y_Pos -= NUMBER_HEIGHT
+
+ global Root_Percent
+ Root_Percent = Draw.Number('Root %: ',No_Event,Number_X,Number_Y_Pos,NUMBER_WIDTH,NUMBER_HEIGHT,Root_Percent.val, 1,90, '')
+ Number_Y_Pos -= NUMBER_HEIGHT
+
+
+
+
+def Dispaly_Head_Tab(Y_POS,CONTROL_HEIGHT):
+
+ CONTROL_WIDTH = 250
+ NUMBER_HEIGHT = 18
+ NUMBER_WIDTH = CONTROL_WIDTH -3-3-3-3-3
+
+ Head_Number_X = 3+3+3
+ Head_Number_Y = Y_POS - 64
+
+ Create_Tab(3,Y_POS,CONTROL_WIDTH,Y_POS-CONTROL_HEIGHT,"Head Type",Head_Type)
+
+ if Head_Type['HEX'][0].val:
+ global Hex_Head_Height
+ Hex_Head_Height = Draw.Number('Head Height: ',No_Event,Head_Number_X ,Head_Number_Y, NUMBER_WIDTH, NUMBER_HEIGHT,Hex_Head_Height.val, 0,100, '')
+ Head_Number_Y -= NUMBER_HEIGHT
+ global Hex_Head_Flat_Distance
+ Hex_Head_Flat_Distance = Draw.Number('Head Hex Flat Distance ',No_Event,Head_Number_X,Head_Number_Y,NUMBER_WIDTH, NUMBER_HEIGHT,Hex_Head_Flat_Distance.val, 0,MAX_INPUT_NUMBER, '')
+ Head_Number_Y -= NUMBER_HEIGHT
+
+ elif Head_Type['CAP'][0].val:
+ global Cap_Head_Height
+ Cap_Head_Height = Draw.Number('Head Height: ',No_Event, Head_Number_X,Head_Number_Y, NUMBER_WIDTH, NUMBER_HEIGHT,Cap_Head_Height.val, 0,100, '')
+ Head_Number_Y -= NUMBER_HEIGHT
+ global Cap_Head_Dia
+ Cap_Head_Dia = Draw.Number('Head Dia ',No_Event,Head_Number_X,Head_Number_Y,NUMBER_WIDTH, NUMBER_HEIGHT,Cap_Head_Dia.val, 0,MAX_INPUT_NUMBER, '')
+ Head_Number_Y -= NUMBER_HEIGHT
+
+ elif Head_Type['DOME'][0].val:
+ global Dome_Head_Dia
+ Dome_Head_Dia = Draw.Number(' Dome Head Dia ',No_Event,Head_Number_X,Head_Number_Y, NUMBER_WIDTH, NUMBER_HEIGHT,Dome_Head_Dia.val, 0,MAX_INPUT_NUMBER, '')
+ Head_Number_Y -= NUMBER_HEIGHT
+
+ elif Head_Type['PAN'][0].val:
+ global Pan_Head_Dia
+ Pan_Head_Dia = Draw.Number('Pan Head Dia ',No_Event,Head_Number_X,Head_Number_Y, NUMBER_WIDTH, NUMBER_HEIGHT,Pan_Head_Dia.val, 0,MAX_INPUT_NUMBER, '')
+ Head_Number_Y -= NUMBER_HEIGHT
+
+
+
+
+def Dispaly_Nut_Tab(Y_POS,CONTROL_HEIGHT):
+
+ CONTROL_WIDTH = 250
+ NUMBER_HEIGHT = 18
+ NUMBER_WIDTH = CONTROL_WIDTH -3-3-3-3-3
+
+ Nut_Number_X = 3+3+3
+ Nut_Number_Y = Y_POS - 64
+
+ Create_Tab(3,Y_POS,CONTROL_WIDTH,Y_POS-CONTROL_HEIGHT,"Nut Type",Nut_Type)
+
+ #if Nut_Type['HEX'][0].val:
+ global Hex_Nut_Height
+ Hex_Nut_Height = Draw.Number('Nut Height: ',No_Event,Nut_Number_X ,Nut_Number_Y, NUMBER_WIDTH, NUMBER_HEIGHT,Hex_Nut_Height.val, 0,MAX_INPUT_NUMBER, '')
+ Nut_Number_Y -= NUMBER_HEIGHT
+ global Hex_Nut_Flat_Distance
+ Hex_Nut_Flat_Distance = Draw.Number('Nut Flat Distance ',No_Event,Nut_Number_X,Nut_Number_Y, NUMBER_WIDTH, NUMBER_HEIGHT,Hex_Nut_Flat_Distance.val, 0,MAX_INPUT_NUMBER, '')
+ Nut_Number_Y -= NUMBER_HEIGHT
+
+
+def Dispaly_Bolt_Tab():
+
+ Dispaly_Shank_Tab(284,66)
+ Dispaly_Head_Tab(374,90)
+ Dispaly_Bit_Tab(464,90)
+
+
+##########################################################################################
+
+def gui(): # the function to draw the screen
+
+ CONTROL_WIDTH = 250
+
+ BGL.glClearColor(0.6, 0.6, 0.6, 1.0)
+ BGL.glClear(BGL.GL_COLOR_BUFFER_BIT)
+
+ BGL.glColor3f(0.75, 0.75, 0.75)
+ BGL.glRecti(3,30,CONTROL_WIDTH,3)
+
+ Dispaly_Title_Bar(514,50);
+
+ if Model_Type['BOLT'][0].val:
+ Dispaly_Bolt_Tab();
+
+ if Model_Type['NUT'][0].val:
+ Dispaly_Nut_Tab(464,246);
+
+ Dispaly_Thread_Tab(218,138)
+
+ Dispaly_Preset_Tab(80,50)
+
+ Draw.PushButton("Create",On_Create_Click,6,8,55,18,"Create Bolt")
+ Draw.Button("Exit",On_Exit_Click,6+55+4,8,55,18)
+
+# Draw.Button("Test",On_Test_Click,150,10,55,20)
+
+Load_Preset()
+Draw.Register(gui, event, button_event) # registering the 3 callbacks
diff --git a/release/scripts/wizard_curve2tree.py b/release/scripts/wizard_curve2tree.py
index 1965f9a5070..07b45c1986f 100644
--- a/release/scripts/wizard_curve2tree.py
+++ b/release/scripts/wizard_curve2tree.py
@@ -39,7 +39,7 @@ __bpydoc__ = """\
import bpy
import Blender
import BPyMesh
-from Blender.Mathutils import Vector, Matrix, CrossVecs, AngleBetweenVecs, LineIntersect, TranslationMatrix, ScaleMatrix, RotationMatrix, Rand
+from Blender.Mathutils import Vector, Matrix, AngleBetweenVecs, LineIntersect, TranslationMatrix, ScaleMatrix, RotationMatrix, Rand
from Blender.Geometry import ClosestPointOnLine
from Blender.Noise import randuvec
@@ -496,12 +496,12 @@ class tree:
# Align this with the existing branch
angle = AngleBetweenVecsSafe(zup, parent_pt.no)
- cross = CrossVecs(zup, parent_pt.no)
+ cross = zup.cross(parent_pt.no)
mat_align = RotationMatrix(angle, 3, 'r', cross)
# Use the bend on the point to work out which way to make the branch point!
- if parent_pt.prev: cross = CrossVecs(parent_pt.no, parent_pt.prev.no - parent_pt.no)
- else: cross = CrossVecs(parent_pt.no, parent_pt.next.no - parent_pt.no)
+ if parent_pt.prev: cross = parent_pt.no.cross(parent_pt.prev.no - parent_pt.no)
+ else: cross = parent_pt.no.cross(parent_pt.next.no - parent_pt.no)
if parent_pt.branch.parent_pt:
angle = AngleBetweenVecsSafe(parent_pt.branch.parent_pt.no, parent_pt.no)
@@ -1065,8 +1065,8 @@ class tree:
l = line_normal.length
- cross1 = CrossVecs( seg.no, line_normal )
- cross2 = CrossVecs( pt.no, line_normal )
+ cross1 = seg.no.cross(line_normal)
+ cross2 = pt.no.cross(line_normal)
angle_line = min(AngleBetweenVecsSafe(cross1, cross2), AngleBetweenVecsSafe(cross1, -cross2))
angle_leaf_no_diff = min(AngleBetweenVecsSafe(line_normal, seg.no), AngleBetweenVecsSafe(line_normal, -seg.no))
@@ -1914,8 +1914,8 @@ class tree:
# endpoints dont rotate
if pt.next != None:
- cross1 = CrossVecs(zup, pt.no) # use this to offset the leaf later
- cross2 = CrossVecs(cross1, pt.no)
+ cross1 = zup.cross(pt.no) # use this to offset the leaf later
+ cross2 = cross1.cross(pt.no)
if odd_even ==0:
mat_yaw = RotationMatrix(leaf_branch_angle, 3, 'r', cross2)
else:
@@ -1939,7 +1939,7 @@ class tree:
# Randomize pitch and roll for the leaf
# work out the axis to pitch and roll
- cross1 = CrossVecs(zup, leaf_no) # use this to offset the leaf later
+ cross1 = zup.cross(leaf_no) # use this to offset the leaf later
if leaf_branch_pitch_rand or leaf_branch_pitch_angle:
angle = -leaf_branch_pitch_angle
@@ -2480,7 +2480,7 @@ class bpoint(object):
def calcVerts(self):
if self.prev == None:
if self.branch.parent_pt:
- cross = CrossVecs(self.no, self.branch.parent_pt.no) * RotationMatrix(-45, 3, 'r', self.no)
+ cross = self.no.cross(self.branch.parent_pt.no) * RotationMatrix(-45, 3, 'r', self.no)
else:
# parentless branch - for best results get a cross thats not the same as the normal, in rare cases this happens.
@@ -2493,9 +2493,9 @@ class bpoint(object):
else: cross = xup
else:
- cross = CrossVecs(self.prev.vecs[0], self.no)
+ cross = self.prev.vecs[0].cross(self.no)
- self.vecs[0] = Blender.Mathutils.CrossVecs(self.no, cross)
+ self.vecs[0] = self.no.cross(cross)
self.vecs[0].length = abs(self.radius)
mat = RotationMatrix(90, 3, 'r', self.no)
self.vecs[1] = self.vecs[0] * mat
@@ -2660,8 +2660,8 @@ class branch:
self_normal = self.bpoints[1].co - self.parent_pt.co
# We only want the angle in relation to the parent points normal
# modify self_normal to make this so
- cross = CrossVecs(self_normal, self.parent_pt.no)
- self_normal = CrossVecs(self.parent_pt.no, cross) # CHECK
+ cross = self_normal.cross(self.parent_pt.no)
+ self_normal = self.parent_pt.no.cross(cross) # CHECK
#try: angle = AngleBetweenVecs(parent_normal, self_normal)
#except: return 0.0
@@ -2670,7 +2670,7 @@ class branch:
# see if we need to rotate positive or negative
# USE DOT PRODUCT!
- cross = CrossVecs(parent_normal, self_normal)
+ cross = parent_normal.cross(self_normal)
if AngleBetweenVecsSafe(cross, self.parent_pt.no) > 90:
angle = -angle
@@ -3018,7 +3018,7 @@ class branch:
scales = []
for cos_ls in (cos1, cos2):
- cross = CrossVecs(cos_ls[-1], zup)
+ cross = cos_ls[-1].cross(zup)
mat = RotationMatrix(AngleBetweenVecsSafe(cos_ls[-1], zup), 3, 'r', cross)
cos_ls[:] = [co*mat for co in cos_ls]
@@ -3029,7 +3029,7 @@ class branch:
for co in cos_ls:
xy_nor.x += co.x
xy_nor.y += co.y
- cross = CrossVecs(xy_nor, xup)
+ cross = xy_nor.cross(xup)
# Also scale them here so they are 1.0 tall always
scale = 1.0/(cos_ls[0]-cos_ls[-1]).length
diff --git a/release/scripts/wizard_landscape_ant.py b/release/scripts/wizard_landscape_ant.py
new file mode 100644
index 00000000000..405c06432ca
--- /dev/null
+++ b/release/scripts/wizard_landscape_ant.py
@@ -0,0 +1,2148 @@
+#!BPY
+"""
+Name: 'Landscape Generator (A.N.T)'
+Blender: 248
+Group: 'Wizards'
+Tip: 'Create landscape mesh.'
+"""
+
+__author__ = "Jimmy Hazevoet"
+__url__ = ('http://wiki.blender.org/index.php/Scripts/Manual/Wizards/ANTLandscape','elysiun')
+__version__ = "v.1.05 03-2007"
+__bpydoc__ = """\
+
+Another Noise Tool 'Landscape' v.1.05
+
+This script uses noise functions to create a terrain from a grid mesh.
+
+Usage:
+
+Make new terrain: press the "Add New Grid" button, change some noise settings and press the "Update" button.
+
+Work on previous made grid: select the grid/terrain in the 3D view, and press the "Assign" button.
+
+Tip: use a low resolution grid mesh and add some Multires levels for detail
+
+Note: when using Multires materials can get weird,
+only apply materials when your terrain is ready, or not use Multires.
+
+This Script creates a landscape mesh.
+Press the Auto button when you start the script.
+Then the Generate Button & read it's tooltip.
+The mesh created is average 16000 verts.
+To me the mesh appears quite small in the 3d view.
+Just Press S in the 3d view to scale it up.
+This saves overhead drawing the Mesh.
+
+Known Issues:
+If the mesh is not drawn in the 3d view first time,
+Move your mouse to the 3d view, or press the button again.
+
+Not really an issue, more to be aware.
+Due to the complex nature & design of the script, it only creates one mesh at a time.
+When you press Generate or Reset,
+Even if you have Closed then Opened the script or .blend file,
+The mesh Will be Overwritten.
+To create Multiple Landscapes you Must Re-Name or save the Mesh
+in Blender's F7 menu Links & Materials Panel.
+
+Readme:
+v.1.04:
+_ New G.U.I.
+_ New noise types like:
+Double_Terrain,
+StatsByAlt_Terrain,
+slickRock,
+ditorted_heteroTerrain,
+vlNoise_turbulence,
+and many more.
+
+New fractalized Effect functions.
+Effect types such as: gradient,
+waves and bumps, dome, piramide,
+squares, grid, shattered rocks,
+lunar, and many more.
+
+Bias types: Sin, Cos, Tri, Saw,
+and Default(no bias).
+
+For example the 'Rings' effect
+with 'Sin Bias' makes 'Rings'
+and 'Default Bias' makes 'Dome'.
+The Effect 'Mix factor' Slider gives control over how much of the Effect is vissible,
+-1.0=noise, 0.0=average, 1.0=effect
+this slider controls also the 'Warp amount' if mix type 'Warp' is selected.
+
+Image effect: mix image with noise
+_ IPOCurve Filter: use Ipo curve to filter terrain height.
+I know it's a bit strange to use animation curves for landscape modelling, (actualy i want a curves panel in my G.U.I. but i dont know how to do that)
+the downside of this method is that you have this 'Empty' moving around in your scene, so put it on another layer and 'Pin' the Ipo block so that it stays visible.
+Usage:
+Add one 'Empty' Object to your scene, now add one Loc Key at Frame 1, go to Frame 101 (UpArrow ten times),
+move the 'Empty' +100 units in X+ direction and add another Loc Key, open the Ipo Curve Editor Window, rename this IpoBlock if you want,
+Copie the first curve to buffer and Paste it in the empty slots (from top to bottom), now you can edit the curves freely.
+(use the 'Pin' option to keep the curves visible while other objects are selected)
+Set the CurveLength and CurveHeight Button value's according to the length and height of the selected curve.
+A curve filter is very versatile when it comes to 'height' filtering.
+
+_ PreView in UV/Image Editor Window:
+The preview image is now rendered as Blender.Image and will be saved to file directory as 'ANTview_size.tga'
+you have to select 'ANTview_size.tga' in the UV/Image Editor Window
+now it's posible to render and save a large HeightMap image (you can also create nice texture images when the VertCol gradient is enabled),
+! If you Change the preview image Size a New Blender.Image object is created. (one for size 256, one for size 512 one for.....) !
+
+_ VertexColours: use any image as colour gradient.
+This function actualy uses one 'row' of pixels from a image to produce the color gradient,
+Make one or more custom gradient images with the Gimp or any other graphics software, the gradients must go from left to right (left is bottom and right is top.
+you only need one row of pixels so you can put 10 gradients in a 256*10 image.(higher resolutions like 512*n or 1024*n gives smoother result)
+Set Window DrawMode 'Textured' , and set the 'VCol Paint' option in the Materials panel !
+
+_ Mesh Tiles: Create large scale terrains.
+
+_ Vertices Selection: select flat areas.
+
+_ Keyboard HotKeys:
+SPACE = Update mesh.
+R = Randomise.
+V = Redraw preview.
+
+_ and more...
+
+"""
+
+
+
+
+###
+#
+# Alt+P to start script.
+#
+###
+# scroll down to see info about updates
+##
+################################################################################################################
+# Another Noise Tool 'Landscape'
+# Jimmy Hazevoet
+# license: Do whatever you want with it.
+################################################################################################################
+
+################################################################################################################
+# v.1.04:
+#
+# _ New G.U.I.
+# _ New noise types like: Double_Terrain, StatsByAlt_Terrain, slickRock, ditorted_heteroTerrain, vlNoise_turbulence, and many more.
+# _ New fractalized Effect functions.
+# Effect types such as: gradient, waves and bumps, dome, piramide, squares, grid, shattered rocks, lunar, and many more.
+# Bias types: Sin, Cos, Tri, Saw, and Default(no bias).
+# For example the 'Rings' effect with 'Sin Bias' makes 'Rings' and 'Default Bias' makes 'Dome'.
+# _ The Effect 'Mix factor' Slider gives control over how much of the Effect is vissible, -1.0=noise, 0.0=average, 1.0=effect
+# this slider controls also the 'Warp amount' if mix type 'Warp' is selected.
+# _ Image effect: mix image with noise
+# _ IPOCurve Filter: use Ipo curve to filter terrain height.
+# I know it's a bit strange to use animation curves for landscape modelling, (actualy i want a curves panel in my G.U.I. but i dont know how to do that)
+# the downside of this method is that you have this 'Empty' moving around in your scene, so put it on another layer and 'Pin' the Ipo block so that it stays visible.
+# Usage:
+# Add one 'Empty' Object to your scene, now add one Loc Key at Frame 1, go to Frame 101 (UpArrow ten times),
+# move the 'Empty' +100 units in X+ direction and add another Loc Key, open the Ipo Curve Editor Window, rename this IpoBlock if you want,
+# Copie the first curve to buffer and Paste it in the empty slots (from top to bottom), now you can edit the curves freely.
+# (use the 'Pin' option to keep the curves visible while other objects are selected)
+# Set the CurveLength and CurveHeight Button value's according to the length and height of the selected curve.
+# A curve filter is very versatile when it comes to 'height' filtering.
+# _ PreView in UV/Image Editor Window:
+# The preview image is now rendered as Blender.Image and will be saved to file directory as 'ANTview_size.tga'
+# you have to select 'ANTview_size.tga' in the UV/Image Editor Window
+# now it's posible to render and save a large HeightMap image (you can also create nice texture images when the VertCol gradient is enabled),
+# ! If you Change the preview image Size a New Blender.Image object is created. (one for size 256, one for size 512 one for.....) !
+# _ VertexColours: use any image as colour gradient.
+# This function actualy uses one 'row' of pixels from a image to produce the color gradient,
+# Make one or more custom gradient images with the Gimp or any other graphics software, the gradients must go from left to right (left is bottom and right is top.
+# you only need one row of pixels so you can put 10 gradients in a 256*10 image.(higher resolutions like 512*n or 1024*n gives smoother result)
+# Set Window DrawMode 'Textured' , and set the 'VCol Paint' option in the Materials panel !
+# _ Mesh Tiles: Create large scale terrains.
+# _ Vertices Selection: select flat areas.
+# _ Keyboard HotKeys:
+# SPACE = Update mesh.
+# R = Randomise.
+# V = Redraw preview.
+# _ and more...
+################################################################################################################
+
+################################################################################################################
+# BugFix: Sept./2006 v.1.04a
+#-----------------------------
+# _Image Effect did not worked well with tiled mesh. Fixed (now use Freq. and Loc. buttons to scale and position image).
+#
+################################################################################################################
+
+
+################################################################################################################
+# UPDATE: v.1.05 03-2007
+#---------------------------------------------------------------------------------------------------------------
+#
+# _ New: Save and Load function, save your settings to a .ant file.
+# __NOTE: when saving/loading settings to/from a file,
+# make sure the filename/path is not too long!
+# __HOTKEY__ Load from file: L
+# __HOTKEY__ Save to file : S
+#
+# _ New mesh code, uses Mesh instead of NMesh,
+# this gives a small speed improvement and alows you to use Multires.
+#
+# Usage: Select a Grid/Terrain mesh and hit the Assign button, now you can work on it, when ready you assign another.
+#
+# _ New: 'Musgrave' noise types, 'Random noise' and 'Constant' in 'Effects' section.
+# _ New: 'Custom Effect', write custom formulae ( x,y, a,b, from math import *, from Blender.Noise import * )
+# _ New: 'Custom Height Filter', write custom formulae ( x,y, h, a,b, from math import *, from Blender.Noise import * )
+# _ New: 'Change Filter Order', Toggle: OFF = Noise+Effect+Falloff+FILTER / ON = Noise+FILTER+Effect+Falloff
+#
+# _ If you want to make a tiled terrain, you need to set the coordinates to "WorldSpace" or "Center at Cursor" (in G.U.I.Noise panel),
+# create and place the grid meshes. now one by one select, assign and update, you may need to adjust the "EdgeFalloff" size.
+#
+# WARNING!: when using Multires, materials can get weird (?), so apply materials when your terrain is finnished.
+#
+###############################################################################################################
+
+
+###############################################################################################################
+#
+## Execute Script: Alt P
+#
+
+
+import Blender
+from Blender import *
+from math import *
+from Blender.Noise import *
+from Blender.Draw import *
+from Blender.BGL import *
+from Blender import Image
+import string
+from string import strip
+import BPyMathutils
+from BPyMathutils import genrand
+from random import choice
+scene = Scene.GetCurrent()
+
+###---------------------------------------------------------------------------
+
+CurVersion = 'A.N.T.Landscape v.1.05'
+
+##---------------------------------------------------------------------------
+# Customise default settings: ----------------------------------------------
+
+# Names:
+antfilename = 'Terrain' # Default filename
+previewname = Create('') # Default preview Image name
+DefaultIpoName = '' # Default Ipo DataBlock name (for height filter)
+# G.U.I.:
+FullScreen = Create( 0 ) # FullScreen on/off
+# gui colors:
+ledcolors = [ [1.0,0.498,0.498], [1.0,0.698,0.498], [1.0,0.898,0.498], [0.898,1.0,0.498], [0.698,1.0,0.498], [0.498,1.0,0.498], [0.498,1.0,0.698], [0.498,1.0,0.898], [0.600,0.918,1.0], [0.6,0.757,1.0], [0.6,0.6,1.0], [0.757,0.6,1.0], [0.898,0.498,1.0], [1.0,0.498,0.898] ]
+#ledcolor = [ 1.0, 0.5, 0.0 ]
+lightgrey = [ 0.76, 0.76, 0.76 ] # gui col.
+grey = [ 0.6, 0.6, 0.6 ] # panel col.
+background = [ 0.7, 0.7, 0.7, 1.0 ] # background col.
+black = [ 0.0, 0.0, 0.0 ] # text col.
+white = [ 1.0, 1.0, 1.0 ]
+# gui size
+size_x = 320 # gui x size
+size_y = 280 # gui y size
+# tabs
+guitabs = [ Create( 1 ), Create( 0 ), Create( 0 ), Create( 0 ), Create( 0 ) ] # gui Tabs
+# How long does it take to generate a mesh or image ?
+print_time = 0 # 1 = Print time in console.
+
+# end customise. ----------------------------------------------------------
+##--------------------------------------------------------------------------
+###--------------------------------------------------------------------------
+####--------------------------------------------------------------------------
+##---------------------------------------------------------------------------
+
+dirpath=Blender.sys.dirname(Blender.Get('filename'))
+fname=dirpath.replace('\\','/')+'/' + antfilename + '.ant'
+txtFile = Create( fname )
+
+###---------------------------------------------------------------------------
+columns = 10 # gui columns
+rows = 13 # gui rows
+actob = [] # active object
+actme = [] # active mesh
+ipoblockname=''
+thiscurve=[]
+selectedcurve=0
+phi=3.14159265359
+# events
+App_Evt = 144
+New_Evt = 166
+SelFile_Evt = 71
+LoadFile_Evt = 72
+SaveFile_Evt = 73
+UseMe_Evt = 74
+No_Evt = 1
+Btn_Evt = 2
+Msh_Evt = 12
+Upd_Evt = 3
+Rndm_Evt = 4
+Load_Evt = 5
+Sel_Evt = 6
+Save_Evt = 7
+Rend_Evt = 8
+End_Evt = 9
+Scrn_Evt = 15
+Im_Evt = 16
+gt0_Evt = 20
+gt1_Evt = 21
+gt2_Evt = 22
+gt3_Evt = 23
+gt4_Evt = 24
+Ipo_Evt = 17
+New_Ipo_Evt=700
+
+###---------------------------------------------------------------------------
+# menus
+noisetypemenu = "Noise type: %t|multiFractal %x0|ridgedMFractal %x1|hybridMFractal %x2|heteroTerrain %x3|fBm %x4|turbulence %x5|Voronoi turb. %x6|vlNoise turb. %x7|noise %x8|cellNoise %x9|Marble %x10|lava_multiFractal %x11|slopey_noise %x12|duo_multiFractal %x13|distorted_heteroTerrain %x14|slickRock %x15|terra_turbulence %x16|rocky_fBm %x17|StatsByAlt_Terrain %x18|Double_Terrain %x19|Shattered_hTerrain %x20|vlhTerrain %x21"
+noisebasismenu = "Basis %t|Blender Original%x0|Original Perlin%x1|Improved Perlin%x2|Voronoi_F1%x3|Voronoi_F2%x4|Voronoi_F3%x5|Voronoi_F4%x6|Voronoi_F2-F1%x7|Voronoi Crackle%x8|CellNoise%x9"
+voronitypemenu = "Voronoi type %t|Distance %x0|Distance Squared %x1|Manhattan %x2|Chebychev %x3|Minkovsky 1/2 %x4|Minkovsky 4 %x5|Minkovsky %x6"
+tBasismodemenu = "Terrain basis mode: %t|noise %x0|ridged noise %x1|vlNoise %x2|ridged vlNoise %x3"
+effecttypemenu = ['Effect Type %t','No Effect %x0','Image %x1','Turbulence %x2','vlNoise %x3','Marble %x4', 'multiFractal %x5','ridgedMFractal %x6','hybridMFractal %x7','heteroTerrain %x8','fBm %x9', 'Gradient %x10','Waves and Bumps %x11','ZigZag %x12','Wavy %x13','Sine Bump %x14','Dots %x15','Rings / Dome %x16','Spiral %x17','Square / Piramide %x18','Blocks %x19','Grid %x20','Tech %x21','Crackle %x22','Sparse Cracks %x23','Shattered Rocks %x24','Lunar %x25','Cosine noise %x26','Spike noise %x27','Stone noise %x28','Flat Turb %x29','Flat Voroni %x30','Random noise %x31','Constant %x32','Custom Effect %x33' ]
+mixtypemenu = ['Mix Type %t','Effect only %x0','%l','Mix %x1','Add %x2','Subtract %x3','Multiply %x4','Difference %x5','Screen %x6','addmodulo %x7','Minimum %x8','Maximum %x9','%l','Warp Effect %x10','Warp Noise %x11']
+biastypemenu = "Bias %t|Sin bias %x0|Cos bias %x1|Tri bias %x2|Saw bias %x3|Default (no bias)%x4"
+sharptypemenu = "Sharpen %t|Soft %x0|Sharp %x1|Sharper %x2"
+filtermodemenu = "Filter Mode %t|No Filter %x0| %l|Default Filters %x1|IPOCurve Filter %x2|Custom Filter %x3"
+filtertypemenu = "Filter Type %t|Default Terrace %x0|Sharper Terrace %x1|Rounded Terrace %x2|Posterise Mixed %x3|Posterise %x4|Layered Peaks %x5|Peaked %x6|Smooth-thing %x7|Sin bias %x8|Cos bias %x9|Tri bias %x10|Saw bias %x11|Clamp Max. %x12"
+falloftypemenu = "Edge Falloff %t|No Edge Falloff %x0| %l|Soft Falloff %x1|Default Falloff %x2|Hard Falloff %x3|Linear Falloff Y %x4|Linear Falloff X %x5|Diagonal Falloff + %x6|Diagonal Falloff - %x7|Square %x8|Round %x9"
+randomtypemenu = "Random type: %t|setRandomSeed() : Blender.Noise %x0|Rand() : Blender.Mathutils %x1|genrand() : BPyMathutils MersenneTwister %x2"
+
+##--------------------------------------------------
+def Set_ReSet_Values():
+ global fileinfo, filemessage
+ global iScale, Offset, Invert, NSize, Sx, Sy, Lx, Ly, WorldSpaceCo
+ global NType, Basis, musgr, vlnoi, vlnoiTwo, voron, turbOne, turbTwo, marbleOne, marbleTwo, tBasismod, musgrTwo
+ global CustomFX, effect_image, Effect_Ctrl, Min, Max, Falloff, CustomFilt, Filter_Mode, Def_Filter_Ctrl, Ipo_Filter_Ctrl, Filter_Order
+ global RandMod, RSeed, rand_H, rand_S, rand_L, rand_I, AutoUpd, PreView, DefaultIpoName
+
+ filemessage = ''
+ fileinfo = ''
+ effect_image = 'Load and Select image.'
+ AutoUpd = Create( 0 )
+ PreView = [ Create( 0 ), Create( 1.0 ), Create( 0.0 ) ]
+ ## Coords controls:
+ WorldSpaceCo = Create(0)
+ iScale = [ Create( 1.0 ), Create( 1.0 ), Create( 0.25) ]
+ Offset = [ Create( 0.0 ), Create( 0.0), Create( 0.0) ]
+ Invert = [ Create( 0 ), Create( 0 ), Create( 0 ) ]
+ NSize = [ Create( 1.0 ), Create( 2.0 ) ]
+ Sx = [ Create( 1.0 ), Create( 1.0 ) ]
+ Sy = [ Create( 1.0 ), Create( 1.0 ) ]
+ Lx = [ Create( 0.0 ), Create( 0.0 ) ]
+ Ly = [ Create( 0.0 ), Create( 0.0 ) ]
+ ## Noise controls:
+ NType = Create( 3 )
+ Basis = [ Create( 0 ), Create( 0 ) ]
+ musgr = [ Create( 1.0 ), Create( 2.0 ), Create( 8 ), Create( 1.0 ), Create( 1.0 ), Create( 0.5 ) ]
+ vlnoi = [ Create( 1.0 ), Create( 0 ) ]
+ vlnoiTwo = [ Create( 1.0 ), Create( 0 ) ]
+ voron = [ Create( 0 ), Create( 2.5 ) ]
+ turbOne = [ Create( 6 ), Create( 0 ), Create( 0.5 ), Create( 2.0 ) ]
+ marbleOne = [ Create( 6 ), Create( 0 ), Create( 2.0 ), Create( 0 ), Create( 0 ), Create( 1.0 ) ]
+ tBasismod = Create(0)
+ ## Effect controls:
+ musgrTwo = [ Create( 1.0 ), Create( 2.0 ), Create( 8 ), Create( 1.0 ), Create( 1.0 ) ]
+ turbTwo = [ Create( 6 ), Create( 0 ), Create( 0.5 ), Create( 2.0 ) ]
+ marbleTwo = [ Create( 6 ), Create( 0 ), Create( 2.0 ), Create( 0 ), Create( 0 ), Create( 1.0 ) ]
+ Effect_Ctrl = [ Create( 0 ),Create( 2 ),Create( 0.0 ),Create( 0 ),Create( 0.0 ) ,Create( 0 ),Create( 2.0 ),Create( 0.5 ),Create( 0.5 ) ]
+ CustomFX = [ Create('sin(x*pi)'), Create('cos(y*pi)'), Create('abs(a*b)*0.5') ]
+ ## Filter controls:
+ Min = Create( 0.0 )
+ Max = Create( 1.0 )
+ Falloff = [ Create( 2 ), Create( 1.0 ), Create( 1.0 ), Create( 0 ) , Create( 0 ) ]
+ Filter_Mode = Create( 0 )
+ Def_Filter_Ctrl = [ Create( 0 ), Create( 3.0 ) ]
+ Ipo_Filter_Ctrl = [ Create( DefaultIpoName ), Create( 0 ), Create( 100.0 ), Create( 100.0 ) ]
+ Filter_Order = Create( 0 )
+ CustomFilt = [ Create('sqrt(h*h)**2'), Create('0'), Create('a') ]
+ ## Randomise noise buttons:
+ RandMod = Create( 1 )
+ RSeed = Create( 0 )
+ rand_I = Create( 0 )
+ rand_H = Create( 0 )
+ rand_S = Create( 0 )
+ rand_L = Create( 1 )
+
+##-------------------------
+Set_ReSet_Values()
+
+
+####----------------------------------------------------------------------------------------------------
+###----------------------------------------------------------------------------------------------------
+## G.U.I.: text,backpanel,panel
+#--------------------------------------------------
+def draw_Text( ( x, y ), text, color, size ):
+ glColor3f( color[0],color[1],color[2] )
+ glRasterPos2d(x,y)
+ txtsize = 'small', 'normal', 'large'
+ Text( text, txtsize[ size ] )
+def draw_BackPanel( text, x, y, w, h, colors ):
+ glColor3f( colors[0]*0.76, colors[1]*0.76, colors[2]*0.76 )
+ glRecti( x, h, w, h+20 )
+ glColor3f( colors[0], colors[1], colors[2] )
+ glRecti( x, y, w, h )
+ glColor3f( colors[0], colors[1], colors[2] )
+ glRasterPos2d( x+10, h+5 )
+ Text( text, 'small' )
+def draw_Panel( x, y, w, h, colors ):
+ glColor3f( colors[0], colors[1], colors[2] )
+ glRecti( x,y, w,h )
+def draw_Frame( text, x, y, w, h, color ):
+ glColor3f( color[0], color[1], color[2] )
+ glRasterPos2i(x+3,h-3)
+ Text(text ,'small')
+ stringwidth = GetStringWidth( text,'small' )
+ glColor3f( color[0], color[1], color[2] )
+ glBegin(Blender.BGL.GL_LINE_STRIP)
+ glVertex2i(x,h)
+ glVertex2i(x,y)
+ glVertex2i(w,y)
+ glVertex2i(w,h)
+ glVertex2i(x+stringwidth+10,h)
+ glEnd()
+def draw_Led( x, y, colors ):
+ glColor3f( colors[0], colors[1], colors[2] )
+ glRecti( x,y, x+4,y+4 )
+
+
+###----------------------------------------------------------------------------------------------------
+## G.U.I. Buttons:
+#----------------------------------------------------------------------------------------------------
+
+###-------------------------
+## Main / Mesh Buttons:
+#
+def MeshButtons( col, row, width, height ):
+ global actme, actob, AutoUpd, txtFile, filemessage, fileinfo
+
+ PushButton("I", UseMe_Evt, col[8], row[3], width[0], height[1], "Info: Here you can write some text to save with the file." )
+ draw_Text( ( col[0], row[1]+5 ), 'Info: ' + fileinfo, black, 0 )
+ txtFile = String("", No_Evt, col[0], row[2], width[9], height[1], txtFile.val, 256, "File: Full path and filename" )
+ PushButton( "Select", SelFile_Evt, col[1], row[3], width[0], height[1], "File: Open FileBrowser and select *.ant file" )
+ PushButton( "Load", LoadFile_Evt,col[2], row[3], width[2], height[1], "File: Load settings from file ( HotKey: L )" )
+ PushButton( "Save", SaveFile_Evt,col[5], row[3], width[2], height[1], "File: Save settings to file ( HotKey: S )" )
+
+ activeobname = ''
+ if actme !=[]:
+ activeobname = actob[0].name
+ draw_Text( ( col[5]+5, row[7]-5 ), 'OB: ' + activeobname, [0.0,0.0,1.0], 1 )
+ PushButton( "Add New Grid", New_Evt, col[0], row[6], width[4], height[2] )
+ PushButton( "Assign Selected", App_Evt, col[5], row[6], width[4], height[2], 'Assign selected terrain')
+
+###-------------------------
+## Noise Buttons:
+#
+def NoiseButtons( col, row, width, height ):
+ global NSize, iScale, Offset, Invert, Lx, Ly, Sx, Sy, WorldSpaceCo
+ global Ha, La, Oc, Of, Ga, Basis, NType, musgr, vlnoi, voron, turbOne, tBasismod
+ global Depth, Hard, Amp, Freq, vlBasis, Distort, VFunc, VExp, VDep, marbleOne
+ global RandMod, RSeed, rand_H, rand_S, rand_L, rand_I
+
+ bth = height[1]/2+5
+ iScale[0] = Number("iScale:", Btn_Evt, col[5], row[2]+bth, width[3], height[1], iScale[0].val, -10.0, 10.0 , "Noise: Intensity Scale." )
+ Invert[0] = Toggle("Inv.", Btn_Evt, col[9], row[2]+bth, width[0], height[1], Invert[0].val, "Noise: Invert")
+ Offset[0] = Number("Offset:", Btn_Evt, col[5], row[3]+bth, width[4], height[1], Offset[0].val, -10.0, 10.0 , "Noise: Offset " )
+ NSize[0] = Number("Noise Size:",Btn_Evt, col[5], row[5], width[4], height[2], NSize[0].val, 0.001, 10.0 , "Noise Size" )
+ Sx[0] = Number("Size X:", Btn_Evt, col[5], row[6], width[4], height[1], Sx[0].val, 0.001, 10.0 , "Size X" )
+ Sy[0] = Number("Size Y:", Btn_Evt, col[5], row[7], width[4], height[1], Sy[0].val, 0.001, 10.0 , "Size Y" )
+ Lx[0] = Number("Loc X:", Btn_Evt, col[5], row[8], width[4], height[1], Lx[0].val, -10000.0, 10000.0 , "Loc X" )
+ Ly[0] = Number("Loc Y:", Btn_Evt, col[5], row[9],width[4], height[1], Ly[0].val, -10000.0, 10000.0 , "Loc Y" )
+ WorldSpaceCo = Menu( "Coordinates %t|Local Space %x0|World Space %x1|Center at CursorPos %x2", Btn_Evt, col[5], row[10], width[4], height[1], WorldSpaceCo.val, "x,y,z coordinates for noise, effect and height falloff " )
+
+ NType = Menu( noisetypemenu, Btn_Evt, col[0], row[2], width[4], height[2], NType.val, "Noise type" )
+ if NType.val == 6:
+ voron[0] = Menu( voronitypemenu, Btn_Evt, col[0], row[3], width[4], height[1], voron[0].val, "Voronoi type" )
+ else:
+ if NType.val != 9:
+ Basis[0] = Menu( noisebasismenu, Btn_Evt, col[0], row[3], width[4], height[1], Basis[0].val, "Noise Basis" )
+
+ if NType.val in [0,1,2,3,4,11,12,13,14,15,17,18,19,20,21]:
+ musgr[0] = Slider( "H: ", Btn_Evt, col[0], row[5], width[4], height[1], musgr[0].val, 0.0, 3.0, 0 , "H" )
+ musgr[1] = Slider( "Lacu: ", Btn_Evt, col[0], row[6], width[4], height[1], musgr[1].val, 0.0, 6.0, 0 , "Lacunarity" )
+ musgr[2] = Slider( "Octs: ", Btn_Evt, col[0], row[4], width[4], height[1], musgr[2].val, 0, 12, 0 , "Octaves" )
+ if NType.val in [1,2,3,13,14,15,18,19,20,21]:
+ musgr[3] = Slider( "Offst: ", Btn_Evt, col[0], row[7], width[4], height[1], musgr[3].val, 0.0, 6.0, 0 , "Offset" )
+ if NType.val in [1,2,13,15,18]:
+ musgr[4] = Slider( "Gain: ", Btn_Evt, col[0], row[8], width[4], height[1], musgr[4].val, 0.0, 6.0, 0 , "Gain" )
+ if NType.val == 19:
+ musgr[5] = Slider( "Thresh: ", Btn_Evt, col[0], row[8], width[4], height[1], musgr[5].val, 0.001, 2.0, 0 , "Threshold" )
+ if NType.val in [5,6,7,16]:
+ turbOne[0] = Number( "Depth:", Btn_Evt, col[0], row[4], width[4], height[1], turbOne[0].val, 0, 12, "Octaves")
+ turbOne[1] = Toggle( "Hard noise", Btn_Evt, col[0], row[5], width[4], height[1], turbOne[1].val, "Soft noise / Hard noise")
+ turbOne[2] = Slider( "Amp:", Btn_Evt, col[0], row[6], width[4], height[1], turbOne[2].val, 0.0, 3.0, 0, "Ampscale ")
+ turbOne[3] = Slider( "Freq:", Btn_Evt, col[0], row[7], width[4], height[1], turbOne[3].val, 0.0, 6.0, 0, "Freqscale")
+ if NType.val in [18,19]:
+ tBasismod = Menu( tBasismodemenu, Btn_Evt, col[0], row[9], width[4], height[1], tBasismod.val, "Terrain basis mode.")
+ if NType.val == 6:
+ if voron[0].val == 6:
+ voron[1] = Slider( "Exp: ", Btn_Evt, col[0], row[8], width[4], height[1], voron[1].val, 0.0,10.0, 0, "Minkovsky exponent")
+ if NType.val in [7,11,12,14,20,21]:
+ vlnoi[0] = Slider( "Dist: ", Btn_Evt, col[0], row[8], width[4], height[1], vlnoi[0].val, 0.0, 10.0, 0 , "Distort" )
+ if NType.val in [7,13,14,15,21]:
+ vlnoi[1] = Menu(noisebasismenu, Btn_Evt, col[0], row[9], width[4], height[1], vlnoi[1].val, "Distortion Noise")
+ if NType.val == 10:
+ marbleOne[0] = Number( "Depth: ", Btn_Evt, col[0], row[6], width[4], height[1], marbleOne[0].val, 0, 12, "Octaves")
+ marbleOne[2] = Slider( "Turb: ", Btn_Evt, col[0], row[7], width[4], height[1], marbleOne[2].val, 0.0,20.0, 0, "Turbulence ")
+ marbleOne[3] = Menu( biastypemenu, Btn_Evt ,col[0], row[4], width[4], height[1], marbleOne[3].val, "Bias")
+ marbleOne[5] = Slider("ReScale: ", Btn_Evt, col[0], row[8], width[4], height[1], marbleOne[5].val, 0.0,20.0, 0, "ReScale")
+ if marbleOne[3].val != 4:
+ marbleOne[4] = Menu(sharptypemenu, Btn_Evt ,col[0], row[5], width[4], height[1], marbleOne[4].val, "Sharpen")
+
+ RandMod = Menu( randomtypemenu, No_Evt, col[0], row[10], width[0], height[1], RandMod.val, "Random Type" )
+ rand_H = Toggle("TH",No_Evt ,col[1], row[10], width[0], height[1], rand_H.val, "Randomise Terrain Height ( in Height panel )")
+ rand_I = Toggle("NH",No_Evt ,col[2], row[10], width[0], height[1], rand_I.val, "Randomise Noise Height")
+ rand_S = Toggle("NS",No_Evt ,col[3], row[10], width[0], height[1], rand_S.val, "Randomise Noise Size")
+ rand_L = Toggle("NL",No_Evt ,col[4], row[10], width[0], height[1], rand_L.val, "Randomise Noise Location")
+
+###-------------------------
+## Effect Buttons:
+#
+def EffectButtons( col, row, width, height ):
+ global Effect_Type, Effect_Ctrl, Blend_Effect, CustomFX
+ global NSize, iScale, Offset, Invert, Lx, Ly, Sx, Sy
+ global BasisTwo, turbTwo, marbleTwo, vlnoiTwo, musgrTwo
+
+ Effect_Ctrl[0] = Menu( '|'.join( effecttypemenu ), Btn_Evt, col[0], row[2], width[4], height[2], Effect_Ctrl[0].val, "Effect: Type" )
+ if Effect_Ctrl[0].val != 0:
+ Effect_Ctrl[1] = Menu( '|'.join( mixtypemenu ), Btn_Evt, col[5], row[2], width[4], height[2], Effect_Ctrl[1].val, "Mix: Type" )
+ if Effect_Ctrl[1].val in [10,11]:
+ Effect_Ctrl[2] = Slider("Warp: ", Btn_Evt, col[5], row[3], width[4], height[1], Effect_Ctrl[2].val, -1.0, 1.0, 0, "Mix factor / Warp amount" )
+ else: Effect_Ctrl[2] = Slider("Mix: ",Btn_Evt, col[5], row[3], width[4], height[1], Effect_Ctrl[2].val, -1.0, 1.0, 0, "Mix factor / Warp amount" )
+
+ iScale[1] = Number("iScale:", Btn_Evt, col[5], row[4], width[3], height[1], iScale[1].val, -20.0, 20.0 , "Effect: Intensity Scale " )
+ Invert[1] = Toggle("Inv.", Btn_Evt, col[9], row[4], width[0], height[1], Invert[1].val, "Effect: Invert")
+ Offset[1] = Number("Offset:", Btn_Evt, col[5], row[5], width[4], height[1], Offset[1].val, -20.0, 20.0 , "Effect: Offset " )
+ NSize[1] = Number("Frequency:",Btn_Evt, col[5], row[6], width[4], height[1], NSize[1].val, 0.001, 100.0, "Effect Frequency ( Scale )" )
+ Sx[1] = Number("Freq X:", Btn_Evt, col[5], row[7], width[4], height[1], Sx[1].val, -50.0, 50.0 , "Effect Frequency X ( ScaleX )" )
+ Sy[1] = Number("Freq Y:", Btn_Evt, col[5], row[8], width[4], height[1], Sy[1].val, -50.0, 50.0 , "Effect Frequency Y ( ScaleY )" )
+ Lx[1] = Number("Loc X:", Btn_Evt, col[5], row[9], width[4], height[1], Lx[1].val, -1000.0, 1000.0 , "Effect Loc X" )
+ Ly[1] = Number("Loc Y:", Btn_Evt, col[5], row[10], width[4], height[1], Ly[1].val, -1000.0, 1000.0 , "Effect Loc Y" )
+
+ if Effect_Ctrl[0].val == 1:
+ PushButton("Load Image", Load_Evt, col[0], row[4], width[4], height[2] , "Load Image")
+ PushButton("Select Image", Sel_Evt, col[0], row[6], width[4], height[3] , "Select Image")
+ draw_Text( ( col[0]+5, row[7] ), effect_image, black, 1 )
+
+ if Effect_Ctrl[0].val in [2,3,4,5,6,7,8,9]:
+ Basis[1] = Menu( noisebasismenu, Btn_Evt, col[0], row[3], width[4], height[1], Basis[1].val, "Basis" )
+
+ if Effect_Ctrl[0].val == 2:
+ turbTwo[0] = Number( "Depth:", Btn_Evt, col[0], row[4], width[4], height[1], turbTwo[0].val, 1, 12, "Octaves")
+ turbTwo[1] = Toggle("Hard noise", Btn_Evt, col[0], row[5], width[4], height[1], turbTwo[1].val, "Hard noise")
+ turbTwo[2] = Slider( "Amp:", Btn_Evt, col[0], row[6], width[4], height[1], turbTwo[2].val, 0.0, 3.0, 0, "Ampscale ")
+ turbTwo[3] = Slider( "Freq:", Btn_Evt, col[0], row[7], width[4], height[1], turbTwo[3].val, 0.0, 6.0, 0, "Freqscale")
+ if Effect_Ctrl[0].val == 3:
+ vlnoiTwo[1] = Menu(noisebasismenu, Btn_Evt, col[0], row[4], width[4], height[1], vlnoiTwo[1].val, "Distortion Noise")
+ vlnoiTwo[0] = Slider( "Dist: ", Btn_Evt, col[0], row[5], width[4], height[1], vlnoiTwo[0].val, 0.0, 10.0, 0 , "Distort" )
+ if Effect_Ctrl[0].val == 4:
+ marbleTwo[0] = Number( "Depth: ", Btn_Evt, col[0], row[6], width[4], height[1], marbleTwo[0].val, 1, 12, "Octaves")
+ marbleTwo[2] = Slider( "Turb: ", Btn_Evt, col[0], row[7], width[4], height[1], marbleTwo[2].val, 0.0,20.0, 0, "Turbulence")
+ marbleTwo[3] = Menu( biastypemenu, Btn_Evt ,col[0], row[4], width[4], height[1], marbleTwo[3].val, "Bias")
+ marbleTwo[5] = Slider("ReScale: ", Btn_Evt, col[0], row[8], width[4], height[1], marbleTwo[5].val, 0.0,20.0, 0, "ReScale")
+ if marbleTwo[3].val != 4:
+ marbleTwo[4] = Menu(sharptypemenu,Btn_Evt ,col[0], row[5], width[4], height[1], marbleTwo[4].val, "Sharpen")
+
+ if Effect_Ctrl[0].val in [5,6,7,8,9]:
+ musgrTwo[0] = Slider( "H: ", Btn_Evt, col[0], row[5], width[4], height[1], musgrTwo[0].val, 0.0, 3.0, 0 , "H" )
+ musgrTwo[1] = Slider( "Lacu: ", Btn_Evt, col[0], row[6], width[4], height[1], musgrTwo[1].val, 0.0, 6.0, 0 , "Lacunarity" )
+ musgrTwo[2] = Slider( "Octs: ", Btn_Evt, col[0], row[4], width[4], height[1], musgrTwo[2].val, 0, 12, 0 , "Octaves" )
+ if Effect_Ctrl[0].val in [6,7,8]:
+ musgrTwo[3] = Slider( "Offst: ", Btn_Evt, col[0], row[7], width[4], height[1], musgrTwo[3].val, 0.0, 6.0, 0 , "Offset" )
+ if Effect_Ctrl[0].val in [6,7]:
+ musgrTwo[4] = Slider( "Gain: ", Btn_Evt, col[0], row[8], width[4], height[1], musgrTwo[4].val, 0.0, 6.0, 0 , "Gain" )
+
+ if Effect_Ctrl[0].val > 9 and Effect_Ctrl[0].val < 31:
+ Effect_Ctrl[5] = Number("Depth:", Btn_Evt, col[0], row[4], width[4], height[1], Effect_Ctrl[5].val, 0, 12 , "Fractalize Effect: Octaves" )
+ Effect_Ctrl[4] = Number("Distort:",Btn_Evt, col[0], row[7], width[4], height[1], Effect_Ctrl[4].val, 0.0, 50.0 , "Distort Effect: Amount" )
+ Effect_Ctrl[6] = Slider("Freq:", Btn_Evt, col[0], row[5], width[4], height[1], Effect_Ctrl[6].val, 0.0, 6.0, 0, "Fractalize Effect: Frequency" )
+ Effect_Ctrl[7] = Slider("Amp:", Btn_Evt, col[0], row[6], width[4], height[1], Effect_Ctrl[7].val, 0.0, 3.0, 0, "Fractalize Effect: Amplitude" )
+ if Effect_Ctrl[0].val < 22:
+ Effect_Ctrl[3] = Menu(biastypemenu, Btn_Evt ,col[0], row[3], width[4], height[1], Effect_Ctrl[3].val, "Effect bias")
+ if Effect_Ctrl[0].val in [31,32]:
+ Effect_Ctrl[8] = Number("Amount:", Btn_Evt, col[0], row[4], width[4], height[1], Effect_Ctrl[8].val, -20.0, 20.0, "Effect: Amount" )
+ if Effect_Ctrl[0].val == 33:
+ draw_Text( ( col[0]+5, row[4] ), 'Custom math ( h, x,y, a,b )' , black, 0 )
+ CustomFX[0] = String( "a = ", Btn_Evt, col[0], row[5], width[4], height[1] ,CustomFX[0].val,96, "a" )
+ CustomFX[1] = String( "b = ", Btn_Evt, col[0], row[6], width[4], height[1] ,CustomFX[1].val,96, "b" )
+ CustomFX[2] = String( "result = ", Btn_Evt, col[0], row[7], width[4], height[1] ,CustomFX[2].val,96, "result" )
+
+###-------------------------
+## Filter / Height Buttons:
+#
+def FilterButtons( col, row, width, height ):
+ global iScale, Offset, Invert, Min, Max, Falloff, CustomFilt
+ global Filter_Mode, Def_Filter_Ctrl, Ipo_Filter_Ctrl, DefaultIpoName, Filter_Order
+
+ iScale[2] = Number("Height:", Btn_Evt, col[5], row[2], width[3], height[2], iScale[2].val, -10.0, 10.0 , "Terrain Height: Scale" )
+ Invert[2] = Toggle("Inv.", Btn_Evt, col[9], row[2], width[0], height[2], Invert[2].val, "Terrain Height: Invert")
+ Offset[2] = Number("Offset:", Btn_Evt, col[5], row[3], width[4], height[1], Offset[2].val, -10.0, 10.0 , "Terrain Height: Offset" )
+ Max = Number( "Plateau:", Btn_Evt, col[5], row[5], width[4], height[1], Max.val, Min.val, 1.0 , "Terrain Height: Clamp Max. ( Plateau )" )
+ Min = Number( "Sealevel:", Btn_Evt, col[5], row[6], width[4], height[1], Min.val, -1.0, Max.val , "Terrain Height: Clamp Min. ( Sealevel )" )
+ Falloff[0] = Menu( falloftypemenu, Btn_Evt ,col[5], row[9], width[4], height[2], Falloff[0].val, "Terrain Height: Edge falloff")
+ if Falloff[0].val !=0:
+ Falloff[1] = Number("X:", Btn_Evt, col[5], row[10], width[1], height[1], Falloff[1].val , 0.01, 100.0 , "Edge falloff: X Size" )
+ Falloff[2] = Number("Y:", Btn_Evt, col[8], row[10], width[1], height[1], Falloff[2].val , 0.01, 100.0 , "Edge falloff: Y Size" )
+ Falloff[4] = Toggle("Inv.", Btn_Evt, col[7], row[10], width[0], height[1], Falloff[4].val, "Edge falloff: Invert")
+ Falloff[3] = Toggle("Edge At Sealevel", Btn_Evt, col[5], row[7], width[4], height[1], Falloff[3].val, "Edge falloff: Edge at Sealevel")
+
+ Filter_Mode = Menu( filtermodemenu, No_Evt, col[0], row[2], width[4], height[2], Filter_Mode.val, "Filter: Mode")
+ if Filter_Mode.val ==1:
+ Def_Filter_Ctrl[0] = Menu( filtertypemenu, Btn_Evt, col[0], row[5], width[4], height[2], Def_Filter_Ctrl[0].val, "Filter: Type")
+ Def_Filter_Ctrl[1] = Number("Amount: ", Btn_Evt, col[0], row[6], width[4], height[1], Def_Filter_Ctrl[1].val, 0.1, 100.0 , "Filter: Amount" )
+
+ if Filter_Mode.val ==2:
+ Ipo_Filter_Ctrl[0] = String("IP:", Ipo_Evt, col[0], row[5], width[4], height[2], Ipo_Filter_Ctrl[0].val,20, "Ipo datablock name" )
+ if Ipo_Filter_Ctrl[0].val !='':
+ Ipo_Filter_Ctrl[1] = Number("Use This Curve:",Ipo_Evt, col[0], row[7], width[4], height[3], Ipo_Filter_Ctrl[1].val, 0, 29, "Select curve to use" )
+ Ipo_Filter_Ctrl[2] = Number("Curve Length:", Ipo_Evt, col[0], row[8], width[4], height[1], Ipo_Filter_Ctrl[2].val, 0.0, 1000.0, "X: Length (number of frames) of the selected curve." )
+ Ipo_Filter_Ctrl[3] = Number("Curve Height:", Ipo_Evt, col[0], row[9], width[4], height[1], Ipo_Filter_Ctrl[3].val, 0.0, 1000.0, "Y: Height (offset) of the selected curve." )
+ else:
+ draw_Text( ( col[0]+5, row[6] ), 'Enter Ipo DataBlock name,' , black, 0 )
+ draw_Text( ( col[0]+5, row[9] ), 'or else:' , black, 0 )
+ PushButton( "New IpoDataBlock/Object", New_Ipo_Evt, col[0], row[10], width[4], height[1], "Creates new Ipo Object(Empty), and Ipo DataBlock(curves)' to use as height filter")
+
+ if Filter_Mode.val ==3:
+ draw_Text( ( col[0]+5, row[4] ), 'Custom math ( h, x,y, a,b )' , black, 0 )
+ CustomFilt[0] = String( "a = ", Btn_Evt, col[0], row[5], width[4], height[1] ,CustomFilt[0].val,96, "a" )
+ CustomFilt[1] = String( "b = ", Btn_Evt, col[0], row[6], width[4], height[1] ,CustomFilt[1].val,96, "b" )
+ CustomFilt[2] = String( "result = ", Btn_Evt, col[0], row[7], width[4], height[1] ,CustomFilt[2].val,96, "result" )
+ if Filter_Mode.val !=0:
+ Filter_Order = Toggle("Change Filter Order", Btn_Evt, col[0], row[3], width[4], height[1], Filter_Order.val, "Filter Order: OFF = Noise+Effect+Falloff+FILTER / ON = Noise+FILTER+Effect+Falloff.")
+
+###-------------------------
+## Option / Generate Image Buttons:
+#
+def OptionButtons( col, row, width, height ):
+ global PreView, previewname
+
+ PreView[0] = Toggle("Make Image", No_Evt, col[0], row[2], width[4], height[2], PreView[0].val, "Image: On/Off (Make a new Image in UV/ImageEditor Window, and give a name to it)")
+ if PreView[0].val !=0:
+ previewname = String( "IM:", No_Evt, col[0], row[3], width[4], height[1] ,previewname.val, 16, "IM:Name, Render terrain height to this image" )
+ PreView[1] = Number("", Im_Evt, col[0], row[4], width[1], height[1], PreView[1].val, 0.0, 10.0, "Image: Intensity Scale")
+ PreView[2] = Number("", Im_Evt, col[3], row[4], width[1], height[1], PreView[2].val,-10.0, 10.0, "Image: Offset")
+ PushButton( "Draw Image", Im_Evt, col[0], row[5], width[4], height[1] , "Image: Update image ( KEY: V )")
+ draw_Text( ( col[5], row[1] ), 'Create yourself a new image', black, 0 )
+ draw_Text( ( col[5], row[2] ), 'in UV/Image Editor Window,', black, 0 )
+ draw_Text( ( col[5], row[3] ), 'give it a name,', black, 0 )
+ draw_Text( ( col[5], row[4] ), 'and save it manualy.', black, 0 )
+
+####--------------------------------------------------------------------------
+###--------------------------------------------------------------------------
+## Draw G.U.I. -------------------------------------------------------------
+#--------------------------------------------------------------------------
+def drawgui():
+ global guitabs, ledcolor, FullScreen, AutoUpd, RandMod, RSeed, filemessage
+ global Effect_Ctrl, Filter_Mode, Falloff, PreView, rand_H, rand_S, rand_L, rand_I
+
+ glClearColor(background[0],background[1],background[2],background[3])
+ glClear(GL_COLOR_BUFFER_BIT)
+ scissorbox=Buffer(GL_FLOAT,4)
+ glGetFloatv(GL_SCISSOR_BOX,scissorbox)
+ scissbleft=int(scissorbox[0])
+ scissbbase=int(scissorbox[1])
+ scissbwidth=int(scissorbox[2])
+ scissbheight=int(scissorbox[3])
+ xstart = 5
+ ystart = 5
+ xgap = 5
+ ygap = 5
+ if FullScreen.val==1:
+ guiwidth = scissbwidth-10
+ guiheight = scissbheight-25
+ if guiwidth < size_x/2:
+ guiwidth = size_x/2
+ if guiheight < size_y/2:
+ guiheight = size_y/2
+ else:
+ guiwidth = size_x
+ guiheight = size_y
+ col,row = [],[]
+ xpart = ( ( guiwidth-xstart ) / columns )
+ ypart = ( ( guiheight-ystart ) / rows )
+ width = []
+ for c in xrange( columns ):
+ col.append( xgap + xpart * c + xstart )
+ width.append( xpart*(c+1)-xgap )
+ height = [ (ypart-ygap)/2 , ypart-ygap, (ypart*3-ygap)/2, ypart*2-ygap, (ypart*5-ygap)/2 ]
+ for r in xrange( rows ):
+ row.append( ygap + ypart * r + ystart )
+ row.reverse()
+
+ ###-------------------------
+ ## Draw G.U.I.:
+ draw_BackPanel( 'Another Noise Tool 1.05', xstart, ystart, guiwidth, guiheight + ygap, lightgrey )
+
+ FullScreen = Toggle("", Scrn_Evt, guiwidth-32, guiheight+ygap+3, 15, 15, FullScreen.val ,"FullScreen" )
+ PushButton( "X", End_Evt, guiwidth-16, guiheight+ygap+3, 15, 15, "Exit" )
+ draw_Text(( guiwidth-(guiwidth/2)-width[0], guiheight+ygap+5 ), filemessage, white, 0 )
+
+ # gui tabs
+ guitabs[0] = Toggle("Main", gt0_Evt, col[0], row[0], width[1], height[1], guitabs[0].val ,"Main / Mesh settings" )
+ guitabs[1] = Toggle("Noise", gt1_Evt, col[2], row[0], width[1], height[1], guitabs[1].val ,"Noise settings" )
+ guitabs[2] = Toggle("Effect", gt2_Evt, col[4], row[0], width[1], height[1], guitabs[2].val ,"Add Effect" )
+ guitabs[3] = Toggle("Height", gt3_Evt, col[6], row[0], width[1], height[1], guitabs[3].val ,"Height Filter" )
+ guitabs[4] = Toggle("Options", gt4_Evt, col[8], row[0], width[1], height[1], guitabs[4].val ,"Options" )
+
+ if guitabs[0].val !=0: MeshButtons( col, row, width, height )
+ elif guitabs[1].val !=0: NoiseButtons( col, row, width, height )
+ elif guitabs[2].val !=0: EffectButtons( col, row, width, height )
+ elif guitabs[3].val !=0: FilterButtons( col, row, width, height )
+ elif guitabs[4].val !=0: OptionButtons( col, row, width, height )
+ else: # some info
+ draw_Panel( col[0], row[0]-5, col[9]+width[0], row[10]-10, black )
+ draw_Text( ( col[0]+5, row[1] ), 'Another Noise Tool v.1.05', ledcolors[0], 2 )
+ draw_Text( ( col[0]+5, row[2] ), 'by: Jimmy Hazevoet, 01/2005-03/2007', ledcolors[1], 2 )
+ draw_Text( ( col[0]+5, row[3] ), 'v.1.05: build/tested in: Blender 2.43 (Wndws)', ledcolors[2], 1 )
+ draw_Text( ( col[0]+5, row[4] ), 'HotKeys: ----------------------------', ledcolors[3], 2 )
+ draw_Text( ( col[0]+5, row[5] ), 'Space = Update mesh', ledcolors[4], 2 )
+ draw_Text( ( col[0]+5, row[6] ), 'V = Update Image', ledcolors[5], 2 )
+ draw_Text( ( col[0]+5, row[7] ), 'R = Randomise', ledcolors[6], 2 )
+ draw_Text( ( col[0]+5, row[8] ), 'L = Load from file', ledcolors[7], 2 )
+ draw_Text( ( col[0]+5, row[9] ), 'S = Save to file', ledcolors[8], 2 )
+ draw_Text( ( col[0]+5, row[10] ),'Q = Quit', ledcolors[9], 2 )
+
+ # auto/generate/randomise buttons
+ rand_on_off = 0
+ if rand_H.val !=0: rand_on_off = 1
+ elif rand_I.val !=0: rand_on_off = 1
+ elif rand_S.val !=0: rand_on_off = 1
+ elif rand_L.val !=0: rand_on_off = 1
+ else: rand_on_off = 0
+ if rand_on_off != 0:
+ if RandMod.val in [1,2]:
+ PushButton( "Randomise", Rndm_Evt, col[2], row[12], width[2], height[2] , "Randomise Noise ( KEY: R )")
+ else: RSeed = Number("Seed: ", Rndm_Evt, col[2], row[12], width[2], height[2], RSeed.val, 0, 255 , "Random Seed: If seed = 0, the current time will be used as seed." )
+ AutoUpd = Toggle("Auto", No_Evt, col[0], row[12], width[1], height[2], AutoUpd.val ,"Automatic update" )
+ PushButton("Update", Upd_Evt, col[5], row[12], width[4], height[2] , "Generate / Update. ( KEY: SPACE )")
+ else:
+ AutoUpd = Toggle("Auto", No_Evt, col[0], row[12], width[1], height[2], AutoUpd.val ,"Automatic update" )
+ PushButton("Update", Upd_Evt, col[2], row[12], width[7], height[2] , "Generate / Update. ( KEY: SPACE )")
+ ####---------------------------------------------------------------------------
+
+###---------------------------------------------------------------------------
+##---------------------------------------------------------------------------
+# Key Events:
+
+def events(evt, val):
+ global PreView, txtFile, AutoUpd, PreView
+
+ ## hotkey: Q = Quit
+ if (evt == QKEY and not val):
+ name = "Quit ?%t|No %x0|Yes %x1"
+ result = Blender.Draw.PupMenu(name)
+ if result==1:
+ Exit()
+
+ ## hotkey: Space = Generate/Update terrain
+ if (evt == SPACEKEY and not val):
+ do_it()
+
+ ## hotkey: R = Randomise noise
+ if (evt in [ RKEY ] and not val):
+ if AutoUpd.val != 0:
+ do_it_random()
+ else:
+ randomiseNoise()
+ Draw()
+
+ ## hotkey: V = Update image
+ if PreView[0].val != 0:
+ if (evt in [ VKEY, RKEY ] and not val):
+ do_it_preview()
+
+ ## hotkey: L = Load from file
+ if (evt == LKEY and not val):
+ loadmenu = "Load file ?%t|" + txtFile.val
+ loadresult = Blender.Draw.PupMenu(loadmenu)
+ if loadresult==1:
+ LoadPreset(txtFile.val)
+ if AutoUpd.val != 0:
+ do_it()
+ else: Draw()
+
+ ## hotkey: S = Save to file
+ if (evt == SKEY and not val):
+ savemenu = "Save file ?%t|" + txtFile.val
+ saveresult = Blender.Draw.PupMenu(savemenu)
+ if saveresult==1:
+ SavePreset(txtFile.val)
+ Draw()
+
+###---------------------------------------------------------------------------
+##---------------------------------------------------------------------------
+# Button events:
+
+def bevents(evt):
+ global txtFile, effect_image, PreView, fileinfo, filemessage
+ global Filter_Mode, Ipo_Filter_Ctrl, iponame, thiscurve, selectedcurve
+ global antfilename, terrainname
+ global actob, actme
+
+ # quit/reset event
+ if (evt == End_Evt ):
+ name = "OK ?%t|Reset %x1|Quit %x2"
+ result = Blender.Draw.PupMenu(name)
+ if result==1:
+ Set_ReSet_Values()
+ Draw()
+ elif result==2:
+ Exit()
+
+ ## file info string event
+ if (evt == UseMe_Evt ):
+ result = Blender.Draw.PupStrInput("Info: ", fileinfo, 96)
+ if result:
+ fileinfo = result
+ Draw()
+ else: return
+
+ ## none event
+ if (evt in [No_Evt, Scrn_Evt] ):
+ Draw()
+
+ ## image event
+ if (evt == Im_Evt ):
+ do_it_preview()
+
+ ## generate/update event
+ if (evt == Upd_Evt ):
+ if PreView[0].val != 0:
+ do_it_preview()
+ do_it()
+
+ ## mesh button event
+ if (evt == Msh_Evt):
+ if AutoUpd.val != 0:
+ do_it()
+ else: Draw()
+
+ ## button event
+ if (evt == Btn_Evt ):
+ if AutoUpd.val != 0:
+ if PreView[0].val != 0:
+ do_it_preview()
+ do_it()
+ else: Draw()
+
+ ## randomise event
+ if (evt == Rndm_Evt ):
+ if AutoUpd.val != 0:
+ do_it_random()
+ else:
+ randomiseNoise()
+ if PreView[0].val != 0:
+ do_it_preview()
+ Draw()
+
+ ###---------------------------------------------------------
+ ## Effect Image Load/Select:
+ if (evt == Load_Evt ):
+ Blender.Window.FileSelector ( load_image, 'LOAD IMAGE')
+ if (evt == Sel_Evt ):
+ try: effect_image = Image_Menu()
+ except: pass
+ if AutoUpd.val != 0:
+ do_it()
+ else: Draw()
+
+ ###---------------------------------------------------------
+ ## Make New IPOCurve to use as Filter:
+ if (evt == New_Ipo_Evt ):
+ objname = Create("ANT_Ipo_Empty")
+ iponame = Create("ANT_IPO")
+ block = []
+ block.append("Enter new names")
+ block.append("and hit OK button")
+ block.append(("OB: ", objname, 0, 30, "New Ipo Object Name. (Object type = 'Empty')"))
+ block.append(("IP: ", iponame, 0, 30, "New Ipo DataBlock Name"))
+ block.append("Open IpoCurveEditor")
+ block.append("select Ipo DataBlock" )
+ block.append("'Pin' the view" )
+ block.append("and edit the curves." )
+ retval = PupBlock("Make A.N.T. IpoCurve Object", block)
+ if retval !=0:
+ ANTAutoIpo( objname.val, iponame.val )
+ Ipo_Filter_Ctrl[0].val = iponame.val
+
+ ###---------------------------------------------------------
+ ## get IPOCurve to use as Filter:
+ if (evt in [Ipo_Evt, New_Ipo_Evt] ):
+ if Filter_Mode.val == 2:
+ if AutoUpd.val != 0:
+ try:
+ ipoblockname = Ipo.Get( Ipo_Filter_Ctrl[0].val )
+ thiscurve = ipoblockname.getCurves()
+ selectedcurve = thiscurve[ Ipo_Filter_Ctrl[1].val ]
+ if PreView[0].val != 0:
+ do_it_preview()
+ #if AutoUpd.val != 0:
+ do_it()
+ except: pass
+ else:
+ try:
+ ipoblockname = Ipo.Get( Ipo_Filter_Ctrl[0].val )
+ thiscurve = ipoblockname.getCurves()
+ selectedcurve = thiscurve[ Ipo_Filter_Ctrl[1].val ]
+ if PreView[0].val != 0:
+ do_it_preview()
+ else:
+ Draw()
+ except: pass
+
+ ###---------------------------------------------------------
+ ## gui tabs
+ if (evt == gt0_Evt ):
+ if guitabs[0].val == 1:
+ guitabs[1].val = ( 0 )
+ guitabs[2].val = ( 0 )
+ guitabs[3].val = ( 0 )
+ guitabs[4].val = ( 0 )
+ Draw()
+ if (evt == gt1_Evt ):
+ if guitabs[1].val == 1:
+ guitabs[0].val = ( 0 )
+ guitabs[2].val = ( 0 )
+ guitabs[3].val = ( 0 )
+ guitabs[4].val = ( 0 )
+ Draw()
+ if (evt == gt2_Evt ):
+ if guitabs[2].val == 1:
+ guitabs[0].val = ( 0 )
+ guitabs[1].val = ( 0 )
+ guitabs[3].val = ( 0 )
+ guitabs[4].val = ( 0 )
+ Draw()
+ if (evt == gt3_Evt ):
+ if guitabs[3].val == 1:
+ guitabs[0].val = ( 0 )
+ guitabs[1].val = ( 0 )
+ guitabs[2].val = ( 0 )
+ guitabs[4].val = ( 0 )
+ Draw()
+ if (evt == gt4_Evt ):
+ if guitabs[4].val == 1:
+ guitabs[0].val = ( 0 )
+ guitabs[1].val = ( 0 )
+ guitabs[2].val = ( 0 )
+ guitabs[3].val = ( 0 )
+ Draw()
+
+ ###---------------------------------------------------------
+ ## load and save all settings:
+ if (evt == SelFile_Evt ):
+ Blender.Window.FileSelector ( callback, "Select .ant File")
+ if (evt == LoadFile_Evt ):
+ loadmenu = "Load file ?%t|" + txtFile.val
+ loadresult = Blender.Draw.PupMenu(loadmenu)
+ if loadresult==1:
+ LoadPreset(txtFile.val)
+ Draw()
+ if AutoUpd.val != 0:
+ do_it()
+ if (evt == SaveFile_Evt ):
+ savemenu = "Save file ?%t|" + txtFile.val
+ saveresult = Blender.Draw.PupMenu(savemenu)
+ if saveresult==1:
+ SavePreset(txtFile.val)
+ Draw()
+
+ ###---------------------------------------------------------
+ # New Grid
+ ###-------------------------
+ if (evt == New_Evt):
+ scn = Blender.Scene.GetCurrent()
+ gridname = Create("Terrain")
+ gridres = Create(256)
+ curspos = Create(0)
+ block = []
+ block.append(("OB: ", gridname, 0, 30, "New Object Name."))
+ block.append(("Resol: ", gridres, 4, 1024, "New grid resolution"))
+ block.append(("At Cursor", curspos, "New grid at cursor position"))
+ retval = PupBlock("New Grid Mesh", block)
+ if retval !=0:
+ MakeGridMesh( gridres.val, gridname.val, curspos.val, scn )
+ obj = scn.objects.active
+ if obj.type == 'Mesh':
+ actob=[]
+ actme=[]
+ actob.append( obj )
+ actme.append( actob[0].getData(mesh=1) )
+ Blender.Redraw()
+
+ ###---------------------------------------------------------
+ # Assign Grid
+ ###-------------------------
+ if (evt == App_Evt):
+ scn = Blender.Scene.GetCurrent()
+ obj = scn.objects.active
+ if obj:
+ if obj.type == 'Mesh':
+ actob=[]
+ actme=[]
+ actob.append( obj )
+ actme.append( actob[0].getData(mesh=1) )
+ Draw()
+
+ ###-------------------------
+ if (evt not in [LoadFile_Evt,SaveFile_Evt] ):
+ filemessage = ''
+ #Draw()
+
+ ### end events. -------------------------
+
+####-------------------------------------------------------------------------------------
+###-------------------------------------------------------------------------------------
+##-------------------------------------------------------------------------------------
+#-------------------------------------------------------------------------------------
+
+##----------------------------------
+# A.N.T. Auto Ipo generator:
+def ANTAutoIpo( objname, iponame ):
+ scn=Scene.GetCurrent()
+ # Deselect all objects:
+ scn.objects.selected=[]
+ # Create new 'ANT_IPO_OBJECT':
+ obj = scn.objects.new('Empty', objname )
+ obj.setDrawMode(8)
+ obj.select(1)
+ obj.layers = Window.ViewLayers()
+ # Set current frame at 1:
+ frame = Get('curframe')
+ if frame !=1:
+ Set('curframe',1)
+ frame = Get('curframe')
+ # Insert IpoKeys:
+ obj.setLocation(0.0, 0.0, 0.0)
+ obj.insertIpoKey(0)
+ Set('curframe',101)
+ obj.setLocation(100.0, 100.0, 100.0)
+ obj.insertIpoKey(0)
+ Set('curframe',1)
+ # Set Ipo name:
+ ip = obj.getIpo()
+ ip.name = iponame
+ #-------------------------
+ print "New ANT_IPO: " + objname +" (Object) and " + iponame + " (Ipo DataBlock) Created!"
+ #-------------------------
+
+##-------------------------------------------------------------------------------------
+
+##-------------------------
+# Generate random numbers:
+def randnum(low,high):
+ global RandMod, RSeed
+ if RandMod.val == 0:
+ # Noise.random setRandomSeed
+ s = Noise.setRandomSeed( RSeed.val )
+ num = Noise.random()
+ num = num*(high-low)
+ num = num+low
+ elif RandMod.val == 1:
+ # Mathutils.Rand
+ num = Mathutils.Rand(low,high)
+ else:
+ # BPyMathutils Mersenne Twister genrand
+ num = genrand()
+ num = num*(high-low)
+ num = num+low
+ return num
+
+##-------------------------
+# Randomise noise: height, size and location:
+def randomiseNoise():
+ global rand_I, rand_H, rand_S, rand_L, NSize, iScale, Offset, Invert, Lx, Ly, Sx, Sy
+
+ if rand_I.val !=0:
+ iScale[0] = Create( randnum( 0.2 , 3.0 ) )
+ Offset[0] = Create( randnum(-1.0 , 1.0 ) )
+ if rand_H.val !=0:
+ iScale[2] = Create( randnum( 0.10 , 1.0 ) )
+ Offset[2] = Create( randnum(-0.25 , 0.25 ) )
+ if rand_S.val !=0:
+ NSize[0] = Create( randnum( 0.25 , 2.5 ) )
+ #Sx[0] = Create( randnum( 0.5 , 1.5 ) )
+ #Sy[0] = Create( randnum( 0.5 , 1.5 ) )
+ if rand_L.val !=0:
+ Lx[0] = Create( randnum( -10000 , 10000 ) )
+ Ly[0] = Create( randnum( -10000 , 10000 ) )
+
+##-------------------------------------------------------------------------------------
+
+###--------------------------
+# Load Image:
+def load_image( ImageFileName ):
+ Image.Load( ImageFileName )
+
+###--------------------------
+# Select Image Menu:
+def Image_Menu():
+ try:
+ names=[]
+ imagelist = Image.Get()
+ imagelist.reverse()
+ for numbers, obnames in enumerate( imagelist ):
+ n = obnames.getName()
+ names.append( n )
+ imlistText = string.join( [ '|' + str(names[key]) + '%x' + str(key) for key in xrange(numbers+1) ], '' )
+ image_menu = Blender.Draw.PupMenu( "Images: %t" + imlistText )
+ if image_menu == -1:
+ return ''
+ return imagelist[ image_menu ].getName()
+ except:
+ return 'No image found!'
+
+###--------------------------
+# Get Image Pixels:
+def Image_Func( x,y ):
+ try:
+ pic = Image.Get( effect_image )
+ except:
+ return 0.0
+ w, h = pic.getSize()
+ x, y = x,-y
+ x = int(w * ((x + 1.0) % 2.0) / 2.0)
+ y = int((h-1) - h * ((y + 1.0) % 2.0) / 2.0)
+ c = pic.getPixelF( x,y )
+ return ( c[0] + c[1] + c[2] ) / 3.0
+
+##-------------------------------------------------------------------------------------
+
+# Transpose noise coords:
+def Trans((x,y,z), size, loc ):
+ x = ( x / size[1] / size[0] + loc[0] )
+ y = ( y / size[2] / size[0] + loc[1] )
+ z = 0.0 #( z / size[3] / size[0] + loc[2] )
+ return x,y,z
+
+# Transpose effect coords:
+def Trans_Effect((x,y,z), size, loc ):
+ x = ( x * size[1] * size[0] + loc[0] )
+ y = ( y * size[2] * size[0] + loc[1] )
+ z = 0.0
+ return x,y,z
+
+# Height scale:
+def HeightScale( input, iscale, offset, invert ):
+ if invert !=0:
+ return (1.0-input) * iscale + offset
+ else:
+ return input * iscale + offset
+
+# dist.
+def Dist(x,y):
+ return sqrt( (x*x)+(y*y) )
+
+##-----------------------------------
+# bias types:
+def no_bias(a):
+ return a
+def sin_bias(a):
+ return 0.5 + 0.5 * sin(a)
+def cos_bias(a):
+ return 0.5 + 0.5 * cos(a)
+def tri_bias(a):
+ b = 2 * phi
+ a = 1 - 2 * abs(floor((a * (1/b))+0.5) - (a*(1/b)))
+ return a
+def saw_bias(a):
+ b = 2 * phi
+ n = int(a/b)
+ a -= n * b
+ if a < 0: a += b
+ return a / b
+# sharpen types:
+def soft(a):
+ return a
+def sharp(a):
+ return a**0.5
+def sharper(a):
+ return sharp(sharp(a))
+Bias_Types = [ sin_bias, cos_bias, tri_bias, saw_bias, no_bias ]
+Sharp_Types = [ soft, sharp, sharper ]
+
+##-----------------------------------
+# clamp height
+def clamp( height, min, max ):
+ if ( height < min ): height = min
+ if ( height > max ): height = max
+ return height
+
+##-----------------------------------
+# Mix modes
+def maximum( a, b ):
+ if ( a > b ): b = a
+ return b
+def minimum( a, b ):
+ if ( a < b ): b = a
+ return b
+
+def Mix_Modes( (i,j),(x,y,z) , a,b, mixfactor, mode ):
+ a = a * ( 1.0 - mixfactor )
+ b = b * ( 1.0 + mixfactor )
+ if mode == 0: return ( b ) #0 effect only
+ elif mode == 1: return ( a*(1.0-0.5) + (b*0.5) ) #1 mix
+ elif mode == 2: return ( a + b ) #2 add
+ elif mode == 3: return ( a - b ) #3 sub.
+ elif mode == 4: return ( a * b ) #4 mult.
+ elif mode == 5: return (abs( a - b )) #5 abs diff.
+ elif mode == 6: return 1.0-((1.0-a)*(1.0-b)/1.0) #6 screen
+ elif mode == 7: return ( a + b ) % 1.0 #7 addmodulo
+ elif mode == 8: return min( a, b ) #8 min.
+ elif mode == 9: return max( a, b ) #9 max.
+ elif mode == 10: #10 warp: effect
+ noise = mixfactor * Noise_Function(x,y,z)
+ return Effects( (i,j),(x+noise,y+noise,z) )
+ elif mode == 11: #11 warp: noise
+ effect = mixfactor * Effects( (i,j),(x,y,z) )
+ return Noise_Function( x+effect, y+effect, z )
+ else: return a
+
+###----------------------------------------------------------------------
+# Effect functions:
+
+# Effect_Basis_Function:
+def Effect_Basis_Function((x,y), type, bias ):
+
+ iscale = 1.0
+ offset = 0.0
+ ## gradient:
+ if type == 0:
+ effect = offset + iscale * ( Bias_Types[ bias ]( x + y ) )
+ ## waves / bumps:
+ if type == 1:
+ effect = offset + iscale * 0.5 * ( Bias_Types[ bias ]( x*phi ) + Bias_Types[ bias ]( y*phi ) )
+ ## zigzag:
+ if type == 2:
+ effect = offset + iscale * Bias_Types[ bias ]( offset + iscale * sin( x*phi + sin( y*phi ) ) )
+ ## wavy:
+ if type == 3:
+ effect = offset + iscale * ( Bias_Types[ bias ]( cos( x ) + sin( y ) + cos( x*2+y*2 ) - sin( -x*4+y*4) ) )
+ ## sine bump:
+ if type == 4:
+ effect = offset + iscale * 1-Bias_Types[ bias ](( sin( x*phi ) + sin( y*phi ) ))
+ ## dots:
+ if type == 5:
+ effect = offset + iscale * ( Bias_Types[ bias ](x*phi*2) * Bias_Types[ bias ](y*phi*2) )-0.5
+ ## rings / dome:
+ if type == 6:
+ effect = offset + iscale * ( Bias_Types[ bias ]( 1.0-(x*x+y*y) ) )
+ ## spiral:
+ if type == 7:
+ effect = offset + iscale * Bias_Types[ bias ](( x*sin( x*x+y*y ) + y*cos( x*x+y*y ) ))*0.5
+ ## square / piramide:
+ if type == 8:
+ effect = offset + iscale * Bias_Types[ bias ](1.0-sqrt( (x*x)**10 + (y*y)**10 )**0.1)
+ ## blocks:
+ if type == 9:
+ effect = ( 0.5-max( Bias_Types[ bias ](x*phi) , Bias_Types[ bias ](y*phi) ))
+ if effect > 0.0: effect = 1.0
+ effect = offset + iscale * effect
+ ## grid:
+ if type == 10:
+ effect = ( 0.025-min( Bias_Types[ bias ](x*phi) , Bias_Types[ bias ](y*phi) ))
+ if effect > 0.0: effect = 1.0
+ effect = offset + iscale * effect
+ ## tech:
+ if type == 11:
+ a = ( max( Bias_Types[ bias ](x*pi) , Bias_Types[ bias ](y*pi) ))
+ b = ( max( Bias_Types[ bias ](x*pi*2+2) , Bias_Types[ bias ](y*pi*2+2) ))
+ effect = ( min( Bias_Types[ bias ](a) , Bias_Types[ bias ](b) ))*3.0-2.0
+ if effect > 0.5: effect = 1.0
+ effect = offset + iscale * effect
+
+ ## crackle:
+ if type == 12:
+ t = turbulence(( x, y, 0 ), 6, 0, 0 ) * 0.25
+ effect = vlNoise(( x, y, t ), 0.25, 0, 8 )
+ if effect > 0.5: effect = 0.5
+ effect = offset + iscale * ( effect )
+ ## sparse cracks noise:
+ if type == 13:
+ effect = 2.5 * abs( noise((x*0.5,y*0.5, 0 ), 1 ) )-0.1
+ if effect > 0.25: effect = 0.25
+ effect = offset + iscale * ( effect * 2.5 )
+ ## shattered rock noise:
+ if type == 14:
+ effect = 0.5 + noise((x,y,0), 7 )
+ if effect > 0.75: effect = 0.75
+ effect = offset + iscale * effect
+ ## lunar noise:
+ if type == 15:
+ effect = 0.25 + 1.5 * voronoi(( x+2, y+2, 0 ), 1 )[0][0]
+ if effect > 0.5: effect = 0.5
+ effect = offset + iscale * ( effect * 2.0 )
+ ## cosine noise:
+ if type == 16:
+ effect = cos( 5*noise(( x, y, 0 ), 0 ) )
+ effect = offset + iscale * ( effect*0.5 )
+ ## spikey noise:
+ if type == 17:
+ n = 0.5 + 0.5 * turbulence(( x*5, y*5, 0 ), 8, 0, 0 )
+ effect = ( ( n*n )**5 )
+ effect = offset + iscale * effect
+ ## stone noise:
+ if type == 18:
+ effect = offset + iscale *( noise((x*2,y*2, 0 ), 0 ) * 1.5 - 0.75)
+ ## Flat Turb:
+ if type == 19:
+ t = turbulence(( x, y, 0 ), 6, 0, 0 )
+ effect = t*2.0
+ if effect > 0.25: effect = 0.25
+ effect = offset + iscale * ( effect )
+ ## Flat Voroni:
+ if type == 20:
+ t = 1-noise(( x, y, 0 ), 3 )
+ effect = t*2-1.75
+ if effect > 0.25: effect = 0.25
+ effect = offset + iscale * ( effect )
+
+ if effect < 0.0: effect = 0.0
+ return effect
+
+# fractalize Effect_Basis_Function: ------------------------------
+def Effect_Function((x,y), type,bias, turb, depth,frequency,amplitude ):
+
+ ## effect distortion:
+ if turb != 0.0:
+ t = vTurbulence(( x, y, 0 ), 6, 0, 0 )
+ x = x + ( 0.5 + 0.5 * t[0] ) * turb
+ y = y + ( 0.5 + 0.5 * t[1] ) * turb
+
+ result = Effect_Basis_Function((x,y), type, bias )
+ ## fractalize effect:
+ if depth != 0:
+ i=0
+ while i < depth:
+ i+=1
+ x *= frequency
+ y *= frequency
+ amplitude = amplitude / i
+ result += Effect_Basis_Function( (x,y), type, bias ) * amplitude
+ return result
+
+###--------------------------------------------------
+# Custom effect:
+def CustomEffect( x,y,z,h ):
+ global CustomFX
+ try:
+ a = eval( CustomFX[0].val )
+ b = eval( CustomFX[1].val )
+ result = eval( CustomFX[2].val )
+ return result
+ except:
+ return 0.0
+
+###--------------------------------------------------
+## Effect Selector:
+
+def Effects( (i,j),(x,y,z), h=0.0 ):
+ global Effect_Type, Effect_Ctrl, iScale, Offset, Invert
+ global NSize, Lx, Ly, Lz, Sx, Sy, Sz, marbleTwo, turbTwo, vlnoiTwo, Basis, musgrTwo
+
+ x,y,z = Trans_Effect((x,y,z),( NSize[1].val, Sx[1].val, Sy[1].val, 0 ),( Lx[1].val, Ly[1].val, 0 ) )
+ basis = Basis[1].val
+ if basis == 9: basis = 14
+ vbasis = vlnoiTwo[1].val
+ if vbasis == 9: vbasis = 14
+ if Effect_Ctrl[0].val == 1:
+ try: effect = Image_Func( x,y )
+ except: effect = 0.0
+ elif Effect_Ctrl[0].val == 2: effect = 0.5+0.5*turbulence(( x,y,z ),turbTwo[0].val, turbTwo[1].val, basis, turbTwo[2].val, turbTwo[3].val )
+ elif Effect_Ctrl[0].val == 3: effect = 0.5+0.5*vlNoise(( x,y,z ),vlnoiTwo[0].val, vbasis, basis )
+ elif Effect_Ctrl[0].val == 4: effect = 0.5*marbleNoise((x,y,z), marbleTwo[0].val, basis, marbleTwo[2].val, marbleTwo[3].val, marbleTwo[4].val, marbleTwo[5].val )
+ elif Effect_Ctrl[0].val == 5: effect = 0.5*multiFractal(( x,y,z ),musgrTwo[0].val, musgrTwo[1].val, musgrTwo[2].val, basis )
+ elif Effect_Ctrl[0].val == 6: effect = 0.5*ridgedMFractal(( x,y,z ),musgrTwo[0].val, musgrTwo[1].val, musgrTwo[2].val, musgrTwo[3].val, musgrTwo[4].val, basis )
+ elif Effect_Ctrl[0].val == 7: effect = 0.5*hybridMFractal(( x,y,z ),musgrTwo[0].val, musgrTwo[1].val, musgrTwo[2].val, musgrTwo[3].val, musgrTwo[4].val, basis )
+ elif Effect_Ctrl[0].val == 8: effect = 0.5*heteroTerrain(( x,y,z ),musgrTwo[0].val, musgrTwo[1].val, musgrTwo[2].val, musgrTwo[3].val, basis )*0.5
+ elif Effect_Ctrl[0].val == 9: effect = 0.5*fBm(( x,y,z ),musgrTwo[0].val, musgrTwo[1].val, musgrTwo[2].val, basis )+0.5
+ elif Effect_Ctrl[0].val > 9 and Effect_Ctrl[0].val < 31:
+ effect = Effect_Function((x,y), Effect_Ctrl[0].val-10, Effect_Ctrl[3].val, Effect_Ctrl[4].val, Effect_Ctrl[5].val, Effect_Ctrl[6].val, Effect_Ctrl[7].val )
+ elif Effect_Ctrl[0].val == 31: effect = Effect_Ctrl[8].val * random()
+ elif Effect_Ctrl[0].val == 32: effect = Effect_Ctrl[8].val
+ elif Effect_Ctrl[0].val == 33: effect = CustomEffect( x,y,z, h )
+ effect = HeightScale( effect, iScale[1].val , Offset[1].val, Invert[1].val )
+ return effect*2.0
+
+###----------------------------------------------------------------------
+# Noise:
+##-----------------------------------
+
+## voronoi_turbulence:
+def voroTurbMode((x,y,z), voro, mode ):
+ if mode == 0: # soft
+ return voronoi(( x,y,z ),voro[0], voro[1] )[0][0]
+ if mode == 1: # hard
+ return ( abs( 0.5-voronoi(( x,y,z ),voro[0], voro[1] )[0][0] ) )+0.5
+def voronoi_turbulence((x,y,z), voro, tur ):
+ result = voroTurbMode((x,y,z), voro, tur[1] )
+ depth = tur[0]
+ amp = tur[2]
+ freq = tur[3]
+ i=0
+ for i in xrange( depth ):
+ i+=1
+ result += voroTurbMode( ( x*(freq*i), y*(freq*i), z ), voro, tur[1] )* ( amp*0.5/i )
+ return (result*4.0-2.0)
+
+## DistortedNoise / vlNoise_turbulence:
+def vlnTurbMode((x,y,z), vlno, basis, mode ):
+ if mode == 0: # soft
+ return vlNoise(( x,y,z ),vlno[0], vlno[1], basis )
+ if mode == 1: # hard
+ return ( abs( -vlNoise(( x,y,z ),vlno[0], vlno[1], basis ) ) )
+def vlNoise_turbulence((x,y,z), vlno, tur, basis ):
+ result = vlnTurbMode((x,y,z), vlno, basis, tur[1] )
+ depth = tur[0]
+ amp = tur[2]
+ freq = tur[3]
+ i=0
+ for i in xrange( depth ):
+ i+=1
+ result += vlnTurbMode( ( x*(freq*i), y*(freq*i), z ), vlno, basis, tur[1] ) * ( amp*0.5/i )
+ return result*2.0+0.5
+
+## marbleNoise:
+def marbleNoise( (x,y,z), depth, basis, turb, bias, sharpnes, rescale ):
+ m = ( x * rescale + y * rescale + z ) * 5
+ height = m + turb * turbulence( ( x ,y ,z ), depth, 0, basis, 0.5, 2.0 )
+ height = Bias_Types[ bias ]( height )
+ if bias != 4:
+ height = Sharp_Types[ sharpnes ]( height )
+ return height*2.0
+
+## lava_multiFractal:
+def lava_multiFractal( ( x,y,z ),Ha, La, Oc, distort, Basis ):
+ m = multiFractal( ( x,y,z ), Ha, La, Oc, Basis)
+ d = m * distort
+ m2 = 0.5 * multiFractal( ( x+d,y+d,d*0.5 ), Ha, La, Oc, Basis)
+ return (m * m2)**0.5
+
+## slopey_noise:
+def slopey_noise((x,y,z), H, lacunarity, octaves, distort, basis ):
+ x=x*2
+ y=y*2
+ turb = fBm((x,y,z), H, lacunarity, octaves, 2 ) * 0.5
+ map = 0.5 + noise( ( x+turb, y+turb, z ), basis )
+ result = map + turb * distort
+ return result
+
+## duo_multiFractal:
+def double_multiFractal((x,y,z), H, lacunarity, octaves, offset, gain, basis ):
+ n1 = multiFractal( (x*1.5+1,y*1.5+1,z), 1.0, 1.0, 1.0, basis[0] ) * offset
+ n2 = multiFractal( (x-1,y-1,z), H, lacunarity, octaves, basis[1] ) * gain
+ result = ( n1*n1 + n2*n2 )*0.5
+ return result
+
+## distorted_heteroTerrain:
+def distorted_heteroTerrain((x,y,z), H, lacunarity, octaves, offset, distort, basis ):
+ h1 = ( heteroTerrain((x,y,z), 1.0, 2.0, 1.0, 1.0, basis[0] ) * 0.5 )
+ h2 = ( heteroTerrain(( x, y, h1*distort ), H, lacunarity, octaves, offset, basis[1] ) * 0.25 )
+ result = ( h1*h1 + h2*h2 )
+ return result
+
+## SlickRock:
+def SlickRock((x,y,z), H, lacunarity, octaves, offset, gain, basis ):
+ n = multiFractal( (x,y,z), 1.0, 2.0, 1.0, basis[0] )
+ r = ridgedMFractal((x,y,n*0.5), H, lacunarity, octaves, offset, gain, basis[1] )*0.5
+ return n+(n*r)
+
+## terra_turbulence:
+def terra_turbulence((x,y,z), depth, hard, basis, amp, freq ):
+ t2 = turbulence( ( x, y, z ), depth, hard , basis, amp, freq )
+ return (t2*t2*t2)+0.5
+
+## rocky_fBm:
+def rocky_fBm((x,y,z), H, lacunarity, octaves, basis ):
+ turb = fBm((x,y,z), H, lacunarity, octaves, 2 ) * 0.25
+ coords = ( x+turb, y+turb, z )
+ map = noise( coords, 7 )
+ result = map + fBm( coords, H, lacunarity, octaves, basis ) + 1.0
+ return result
+
+## Shattered_hTerrain:
+def Shattered_hTerrain((x,y,z), H, lacunarity, octaves, offset, distort, basis ):
+ d = ( turbulence( ( x, y, z ), 6, 0, 0, 0.5, 2.0 ) * 0.5 + 0.5 )*distort*0.25
+ t0 = ( turbulence( ( x+d, y+d, z ), 0, 0, 7, 0.5, 2.0 ) + 0.5 )
+ t2 = ( heteroTerrain(( x*2, y*2, t0*0.5 ), H, lacunarity, octaves, offset, basis ) )
+ return (( t0*t2 )+t2*0.5)*0.75
+
+## vlhTerrain
+def vlhTerrain((x,y,z), H, lacunarity, octaves, offset, basis, vlbasis, distort ):
+ ht = heteroTerrain(( x, y, z ), H, lacunarity, octaves, offset, basis )*0.5
+ vl = ht * vlNoise((x,y,z), distort, basis, vlbasis )*0.5+0.5
+ return vl * ht
+
+####---------------------------------------.
+### StatsByAlt, double terrain basis mode:
+def TerrainBasisMode((x,y,z), basis, mode ):
+ if mode == 0: # noise
+ return noise((x,y,z),basis)
+ if mode == 1: # noise ridged
+ return ( 1.0-abs( noise((x,y,z),basis) ) )-0.5
+ if mode == 2: # vlNoise
+ return vlNoise((x,y,z), 1.0, 0, basis )
+ else: # vlNoise ridged
+ return ( 1.0-abs( vlNoise((x,y,z), 1.0, 0, basis ) ) )-0.5
+
+#### StatsByAlt terrain:
+def StatsByAltTerrain((x,y,z), exp, lacu, octs, offset, amp, basis, mode ):
+ result = 0.5 * (offset + TerrainBasisMode((x,y,z), basis, mode ) )
+ octs = int( octs )
+ i = 0
+ for i in xrange( 1, octs ):
+ i += 1
+ result += result * amp * 0.5 * (offset + TerrainBasisMode((x,y,z), basis, mode ) )
+ x *= lacu
+ y *= lacu
+ amp /= ( exp * 0.5 ) * i
+ return result
+
+##### double terrain:
+def doubleTerrain((x,y,z), exp, lacu, octs, offset, threshold, basis, mode ):
+ result = amp = freq = 1.0
+ #octs = int( octs )
+ offset*=0.5
+ i = 1
+ signal = result = 0.5 * (offset + TerrainBasisMode((x,y,z), basis, mode ) )
+ for i in xrange( 1, octs ):
+ i += 1
+ x = x * lacu
+ y = y * lacu
+ freq *= lacu
+ amp = pow( freq, -exp )
+ amp *= i
+ weight = signal / threshold
+ if weight > 1.0: weight = 1.0
+ if weight < 0.0: weigth = 0.0
+ signal = weight * 0.5 * ( offset + TerrainBasisMode((x,y,z), basis, mode ) )
+ result += amp * signal
+ return result * 2.0
+
+##------------------------------------------------------------
+# Noise Functions:
+def Noise_Function(x,y,z):
+ global Basis, NType, musgr, vlnoi, voron, turbOne, marbleOne, tBasismod
+ global vlBasis, Distort, VFunc, VExp, VDep
+ global iScale, Offset, Invert, NSize, Lx, Ly, Sx, Sy
+
+ x,y,z = Trans((x,y,z),( NSize[0].val, Sx[0].val, Sy[0].val, 0 ),( Lx[0].val, Ly[0].val, 0 ) )
+ basis = Basis[0].val
+ if basis == 9: basis = 14
+ vbasis = vlnoi[1].val
+ if vbasis == 9: vbasis = 14
+ if NType.val == 0: z = multiFractal(( x,y,z ),musgr[0].val, musgr[1].val, musgr[2].val, basis )
+ elif NType.val == 1: z = ridgedMFractal(( x,y,z ),musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, musgr[4].val, basis )
+ elif NType.val == 2: z = hybridMFractal(( x,y,z ),musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, musgr[4].val, basis )
+ elif NType.val == 3: z = heteroTerrain(( x,y,z ),musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, basis )*0.5
+ elif NType.val == 4: z = fBm(( x,y,z ),musgr[0].val, musgr[1].val, musgr[2].val, basis )+0.5
+ elif NType.val == 5: z = turbulence(( x,y,z ),turbOne[0].val, turbOne[1].val, basis, turbOne[2].val, turbOne[3].val )+0.5
+ elif NType.val == 6: z = voronoi_turbulence((x,y,z),(voron[0].val,voron[1].val),(turbOne[0].val,turbOne[1].val,turbOne[2].val,turbOne[3].val) )*0.5+0.5
+ elif NType.val == 7: z = vlNoise_turbulence((x,y,z),(vlnoi[0].val,vbasis), (turbOne[0].val,turbOne[1].val,turbOne[2].val,turbOne[3].val), basis )*0.5+0.5
+ elif NType.val == 8: z = noise(( x,y,z ),basis )+0.5
+ elif NType.val == 9: z = cellNoise(( x,y,z ))+0.5
+ elif NType.val == 10: z = marbleNoise(( x,y,z), marbleOne[0].val, basis, marbleOne[2].val, marbleOne[3].val, marbleOne[4].val, marbleOne[5].val )
+ elif NType.val == 11: z = lava_multiFractal(( x,y,z ), musgr[0].val, musgr[1].val, musgr[2].val, vlnoi[0].val, basis )
+ elif NType.val == 12: z = slopey_noise(( x,y,z), musgr[0].val, musgr[1].val, musgr[2].val, vlnoi[0].val, basis )+0.5
+ elif NType.val == 13: z = double_multiFractal(( x,y,z), musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, musgr[4].val, (vbasis,basis) )
+ elif NType.val == 14: z = distorted_heteroTerrain((x,y,z), musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, vlnoi[0].val, (vbasis,basis) )
+ elif NType.val == 15: z = SlickRock(( x,y,z), musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, musgr[4].val, (vbasis,basis) )
+ elif NType.val == 16: z = terra_turbulence(( x,y,z), turbOne[0].val, turbOne[1].val, basis, turbOne[2].val, turbOne[3].val )
+ elif NType.val == 17: z = rocky_fBm(( x,y,z ),musgr[0].val, musgr[1].val, musgr[2].val, basis )
+ elif NType.val == 18: z = StatsByAltTerrain( (x,y,z), musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, musgr[4].val*0.5, basis, tBasismod.val )
+ elif NType.val == 19: z = doubleTerrain( (x,y,z), musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, musgr[5].val, basis, tBasismod.val )
+ elif NType.val == 20: z = Shattered_hTerrain((x,y,z), musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, vlnoi[0].val, basis )
+ elif NType.val == 21: z = vlhTerrain((x,y,z), musgr[0].val, musgr[1].val, musgr[2].val, musgr[3].val, basis, vbasis, vlnoi[0].val )
+ else: z = 0.0
+ return HeightScale( z, iScale[0].val , Offset[0].val, Invert[0].val )
+
+###----------------------------------------------------------------------
+##-----------------------------------
+# Filter functions:
+
+##-----------------------------------
+# Filter: Clamp height
+def Clamp_Max( height, max ):
+ if ( height > max ): height = max
+ return height
+def Clamp_Min( height, min ):
+ if ( height < min ): height = min
+ return height
+
+##-----------------------------------
+# Filters: terrace / posterise / peaked / bias:
+def Def_Filter((x,y,z), input, numb, type ):
+ if type == 0:
+ s = ( sin( input*numb*phi ) * ( 0.1/numb*phi ) )
+ return ( input * (1.0-0.5) + s*0.5 ) * 2.0
+ elif type == 1:
+ s = -abs( sin( input*(numb*0.5)*phi ) * ( 0.1/(numb*0.5)*phi ) )
+ return ( input * (1.0-0.5) + s*0.5 ) * 2.0
+ elif type == 2:
+ s = abs( sin( input*(numb*0.5)*phi ) * ( 0.1/(numb*0.5)*phi ) )
+ return ( input * (1.0-0.5) + s*0.5 ) * 2.0
+ elif type == 3:
+ numb = numb*0.5
+ s = ( int( input*numb ) * 1.0/numb )
+ return ( input * (1.0-0.5) + s*0.5 ) * 2.0
+ elif type == 4:
+ numb = numb*0.5
+ s = ( int( input*numb ) * 1.0/numb )
+ return ( s ) * 2.0
+ elif type == 5:
+ s = ( sin( input*(2*numb)*phi ) * ( 0.1/(2*numb)*phi ) )
+ l = ( input * (1.0-0.5) + s*0.5 ) * 2.0
+ p = ( ( l*numb*0.25 ) * ( l*numb*0.25 ) )**2
+ return ( l * (1.0-0.5) + p*0.5 ) * 2.0
+ elif type == 6:
+ return ( input*numb*0.25 )**4
+ elif type == 7:
+ return 2.0-exp( 1.0-(input*numb/3.0) )
+ elif type == 8:
+ return sin_bias( input*numb )*2.0
+ elif type == 9:
+ return cos_bias( input*numb )*2.0
+ elif type == 10:
+ return tri_bias( input*numb )*2.0
+ elif type == 11:
+ return saw_bias( input*numb )*2.0
+ elif type == 12:
+ return Clamp_Max( input, numb )
+ else:
+ return input
+
+##-----------------------------------
+# Filter: Edge falloff
+def EdgeFalloff( (x,y,z), height, type ):
+ global Falloff, iScale, Offset
+
+ x = x / Falloff[1].val
+ y = y / Falloff[2].val
+
+ if Falloff[3].val != 0:
+ sealevel = (Min.val-Offset[2].val)*2.0/iScale[2].val
+ else:
+ sealevel = 0.0
+
+ falltypes = ( 0, sqrt(x*x+y*y), sqrt((x*x)**2+(y*y)**2), sqrt((x*x)**10+(y*y)**10), sqrt(y*y), sqrt(x*x), abs(x-y), abs(x+y), ((x*x)**10+(y*y)**10)**0.1, ((x*x)+(y*y)) )
+
+ dist = falltypes[ type ]
+ if Falloff[4].val != 0:
+ dist = 1.0 - dist
+ radius = 1.0
+ height = height - sealevel
+ if( dist < radius ):
+ dist = dist / radius
+ dist = ( (dist) * (dist) * ( 3-2*(dist) ) )
+ height = ( height - height * dist ) + sealevel
+ else:
+ height = sealevel
+
+ if Falloff[3].val != 0:
+ height = Clamp_Min( height, sealevel )
+ else:
+ height = Clamp_Min( height, Min.val )
+
+ return height
+
+##-----------------------------------
+# Filter: Custom height filter:
+def CustomFilter( x,y,z, h ):
+ global CustomFilt
+ try:
+ a = eval(CustomFilt[0].val)
+ b = eval(CustomFilt[1].val)
+ result = eval(CustomFilt[2].val)
+ return result
+ except:
+ return 0.0
+
+#####-------------------------------------------------------------------------------------#####
+####-------------------------------------------------------------------------------------####
+### Combine Functions: (get noise, Add effect, filter height and return result) ###
+##-------------------------------------------------------------------------------------##
+
+def Combine_Functions( (i,j),(x,y,z) ):
+ global Effect_Ctrl, Blend_Effect, Filter_Mode, Def_Filter_Ctrl, Ipo_Filter_Ctrl, Filter_Order
+ global iScale, Offset, Invert, Min, Max, Falloff
+
+ # get noise height:
+ height = Noise_Function(x,y,0.0)
+
+ ### Filter On
+ if Filter_Mode.val !=0:
+ ### 0= Default Filter Order: Noise>Effect>Filter ---------------------
+ if Filter_Order.val ==0:
+ # mix noise with effect:
+ if Effect_Ctrl[0].val !=0:
+ height = Mix_Modes( (i,j),(x,y,z), height , Effects( (i,j),(x,y,z),height ), Effect_Ctrl[2].val, Effect_Ctrl[1].val )
+ # edge fallof:
+ if Falloff[0].val !=0:
+ height = EdgeFalloff( (x,y,z), height, Falloff[0].val )
+ #else: pass
+
+ if Filter_Mode.val !=0:
+ # height Def_Filter (Terrace/peaked/bias):
+ if Filter_Mode.val ==1:
+ height = Def_Filter((x,y,z), height, Def_Filter_Ctrl[ 1 ].val, Def_Filter_Ctrl[ 0 ].val )
+
+ ## 'IPOCurve' height filter:
+ elif Filter_Mode.val ==2:
+ try:
+ height = selectedcurve.evaluate( 1 + ( height*Ipo_Filter_Ctrl[2].val/2 ) )*2.0/Ipo_Filter_Ctrl[3].val
+ except:
+ height = height
+
+ ## Custom filter:
+ elif Filter_Mode.val ==3:
+ height = CustomFilter( x,y,z, height )
+
+ ### 1= Changed Filter Order: Noise>Filter>Effect ---------------------
+ if Filter_Order.val !=0:
+ # mix noise with effect:
+ if Effect_Ctrl[0].val !=0:
+ height = Mix_Modes( (i,j),(x,y,z), height , Effects( (i,j),(x,y,z),height ), Effect_Ctrl[2].val, Effect_Ctrl[1].val )
+ # edge fallof:
+ if Falloff[0].val !=0:
+ height = EdgeFalloff( (x,y,z), height, Falloff[0].val )
+ #else: pass
+
+ ### Filter Off ---------------------
+ else:
+ # mix noise with effect:
+ if Effect_Ctrl[0].val !=0:
+ height = Mix_Modes( (i,j),(x,y,z), height , Effects( (i,j),(x,y,z),height ), Effect_Ctrl[2].val, Effect_Ctrl[1].val )
+ # edge fallof:
+ if Falloff[0].val !=0:
+ height = EdgeFalloff( (x,y,z), height, Falloff[0].val )
+
+ # height scale:
+ height = HeightScale( height, 0.5*iScale[2].val , Offset[2].val, Invert[2].val )
+
+ # clamp height min. max.:
+ if Falloff[0].val !=1:
+ height = Clamp_Min( height, Min.val )
+ height = Clamp_Max( height, Max.val )
+
+ # return height:
+ return height
+
+
+#------------------------------------------------------------
+##------------------------------------------------------------
+### Render Noise to a Image('NAME') (you must create one first)
+##------------------------------------------------------------
+#------------------------------------------------------------
+
+def HeightFieldImage():
+ global PreView, previewname
+
+ iname = previewname.val
+ try:
+ pic = Image.Get( iname )
+ except:
+ #print iname, ' No Image with this name'
+ PupMenu( 'No Image with this name' )
+ return
+ res = pic.getMaxXY()
+ for i in xrange( res[0] ):
+ x = i - (res[0]) / 2.0
+ x = (x*2.0) / (res[0])
+ for j in xrange( res[1] ):
+ y = j - (res[1]) / 2.0
+ y = (y*2.0) / (res[1])
+ height = PreView[2].val + PreView[1].val * Combine_Functions( (i,j),(x,y,0) )
+ if height > 1.0: height = 1.0
+ if height < 0.0: height = 0.0
+ pic.setPixelF( i, j, ( height,height,height, 1.0 ) )
+
+
+#------------------------------------------------------------
+##------------------------------------------------------------
+### Mesh
+##------------------------------------------------------------
+#------------------------------------------------------------
+
+#------------------------------------------------------------
+## Mesh: make new grid
+###------------------------------------------------------------
+
+def MakeGridMesh( RESOL=32, NAME='GridMesh', CURSORPOS=0, SCENE=None ):
+ # scene, object, mesh ---------------------------------------
+ if not SCENE:
+ SCENE = Blender.Scene.GetCurrent()
+ SCENE.objects.selected=[]
+ newme = Blender.Mesh.New( NAME )
+ newob = SCENE.objects.new( newme, NAME )
+ n = RESOL
+ # verts ---------------------------------------
+ v=[]
+ for i in xrange( n ):
+ x = i-(n-1)/2.0
+ x = x*2.0/(n-1)
+ for j in xrange( n ):
+ y = j-(n-1)/2.0
+ y = y*2.0/(n-1)
+ v.append( [ x, y, 0 ] )
+ newme.verts.extend(v)
+ # faces ---------------------------------------
+ f=[]
+ for i in xrange( n-1 ):
+ for j in xrange( n-1 ):
+ f.append( [ i*n+j,\
+ (i+1)*n+j,\
+ (i+1)*n+j+1,\
+ i*n+j+1 ] )
+
+ newme.faces.extend(f, smooth=True)
+ #---------------------------------------
+ newme.calcNormals()
+ #---------------------------------------
+ if CURSORPOS !=0:
+ newob.loc = Window.GetCursorPos()
+ newob.select(1)
+
+#------------------------------------------------------------
+## Mesh: Grid vert displace / update terrain
+###------------------------------------------------------------
+
+def displace( OB, ME, WORLD=0 ):
+ if WORLD == 1:
+ wx,wy,wz = OB.getLocation( 'worldspace' )
+ elif WORLD ==2:
+ l = OB.getLocation( 'worldspace' )
+ w = Window.GetCursorPos()
+ wx,wy,wz = l[0]-w[0], l[1]-w[1], l[2]-w[2]
+ else:
+ wx,wy,wz = 0,0,0
+
+ for v in ME.verts:
+ co = v.co
+ co[2] = Combine_Functions( (co[0]+wx,co[1]+wy),(co[0]+wx, co[1]+wy, 0.0+wz) )
+ ME.update()
+ ME.calcNormals()
+ #OB.makeDisplayList()
+
+
+#----------------------------------------------------------------------------------------------------
+##----------------------------------------------------------------------------------------------------
+###----------------------------------------------------------------------------------------------------
+####----------------------------------------------------------------------------------------------------
+###----------------------------------------------------------------------------------------------------
+## Do_it:
+#--------------------------------------
+
+#--------------------------------------
+def do_it():
+ global PreView, actme, actob, WorldSpaceCo
+ if actme !=[]:
+ if print_time !=0:
+ t= sys.time()
+ Window.WaitCursor(1)
+ in_editmode = Window.EditMode()
+ if in_editmode: Window.EditMode(0)
+ if PreView[0].val != 0:
+ do_it_preview()
+ displace( actob[0], actme[0], WorldSpaceCo.val )
+ Window.RedrawAll()
+ else:
+ displace( actob[0], actme[0], WorldSpaceCo.val )
+ Window.RedrawAll()
+ if in_editmode: Window.EditMode(1)
+ Window.WaitCursor(0)
+ if print_time !=0:
+ print 'Generate Mesh: done in %.6f' % (sys.time()-t)
+
+#--------------------------------------
+def do_it_random():
+ global PreView, actme, actob
+ if actme !=[]:
+ if print_time !=0:
+ t= sys.time()
+ Window.WaitCursor(1)
+ in_editmode = Window.EditMode()
+ if in_editmode: Window.EditMode(0)
+ randomiseNoise()
+ if PreView[0].val != 0:
+ do_it_preview()
+ displace( actob[0], actme[0], WorldSpaceCo.val )
+ Window.RedrawAll()
+ else:
+ displace( actob[0], actme[0], WorldSpaceCo.val )
+ Window.RedrawAll()
+ if in_editmode: Window.EditMode(1)
+ Window.WaitCursor(0)
+ if print_time !=0:
+ print 'Generate Mesh: done in %.6f' % (sys.time()-t)
+
+#--------------------------------------
+def do_it_preview():
+ if print_time !=0:
+ t= sys.time()
+ HeightFieldImage()
+ Window.RedrawAll()
+ if print_time !=0:
+ print 'Generate Image: done in %.6f' % (sys.time()-t)
+
+###---------------------------------------------------------
+###---------------------------------------------------------
+## load and save:
+#-------------------------
+
+def callback( filename ):
+ txtFile.val = filename
+ Register(drawgui, events, bevents)
+def writeln(f,x):
+ f.write(str(x))
+ f.write("\n")
+def readint(f):
+ return int(f.readline())
+def readfloat(f):
+ return float(f.readline())
+def readstr(f):
+ s = (f.readline())
+ return strip(s)
+
+#--------------------------------------------------
+# Save settings to .ant file
+def SavePreset(FName):
+ global iScale, Offset, Invert, NSize, Sx, Sy, Lx, Ly
+ global NType, Basis, musgr, tBasismod, vlnoi, vlnoiTwo, voron, turbOne, turbTwo, marbleOne, marbleTwo, musgrTwo
+ global CustomFX, effect_image, Effect_Ctrl, Min, Max, Falloff, CustomFilt, Filter_Mode, Def_Filter_Ctrl, Ipo_Filter_Ctrl, Filter_Order
+ global RandMod, RSeed, rand_H, rand_S, rand_L, rand_I, filemessage, fileinfo
+
+ try:
+ f = open(FName,'w')
+ writeln(f,CurVersion)
+ except:
+ filemessage = "Unable to save file."
+ return
+
+ writeln(f,fileinfo)
+ writeln(f,iScale[0].val)
+ writeln(f,iScale[1].val)
+ writeln(f,iScale[2].val)
+ writeln(f,Offset[0].val)
+ writeln(f,Offset[1].val)
+ writeln(f,Offset[2].val)
+ writeln(f,Invert[0].val)
+ writeln(f,Invert[1].val)
+ writeln(f,Invert[2].val)
+ writeln(f,NSize[0].val)
+ writeln(f,NSize[1].val)
+ writeln(f,Sx[0].val)
+ writeln(f,Sx[1].val)
+ writeln(f,Sy[0].val)
+ writeln(f,Sy[1].val)
+ writeln(f,Lx[0].val)
+ writeln(f,Lx[1].val)
+ writeln(f,Ly[0].val)
+ writeln(f,Ly[1].val)
+ writeln(f,NType.val)
+ writeln(f,Basis[0].val)
+ writeln(f,Basis[1].val)
+ writeln(f,musgr[0].val)
+ writeln(f,musgr[1].val)
+ writeln(f,musgr[2].val)
+ writeln(f,musgr[3].val)
+ writeln(f,musgr[4].val)
+ writeln(f,musgr[5].val)
+ writeln(f,tBasismod.val)
+ writeln(f,vlnoi[0].val)
+ writeln(f,vlnoi[1].val)
+ writeln(f,vlnoiTwo[0].val)
+ writeln(f,vlnoiTwo[1].val)
+ writeln(f,voron[0].val)
+ writeln(f,voron[1].val)
+ writeln(f,turbOne[0].val)
+ writeln(f,turbOne[1].val)
+ writeln(f,turbOne[2].val)
+ writeln(f,turbOne[3].val)
+ writeln(f,turbTwo[0].val)
+ writeln(f,turbTwo[1].val)
+ writeln(f,turbTwo[2].val)
+ writeln(f,turbTwo[3].val)
+ writeln(f,marbleOne[0].val)
+ writeln(f,marbleOne[1].val)
+ writeln(f,marbleOne[2].val)
+ writeln(f,marbleOne[3].val)
+ writeln(f,marbleOne[4].val)
+ writeln(f,marbleOne[5].val)
+ writeln(f,marbleTwo[0].val)
+ writeln(f,marbleTwo[1].val)
+ writeln(f,marbleTwo[2].val)
+ writeln(f,marbleTwo[3].val)
+ writeln(f,marbleTwo[4].val)
+ writeln(f,marbleTwo[5].val)
+ writeln(f,musgrTwo[0].val)
+ writeln(f,musgrTwo[1].val)
+ writeln(f,musgrTwo[2].val)
+ writeln(f,musgrTwo[3].val)
+ writeln(f,musgrTwo[4].val)
+ writeln(f,effect_image)
+ writeln(f,Effect_Ctrl[0].val)
+ writeln(f,Effect_Ctrl[1].val)
+ writeln(f,Effect_Ctrl[2].val)
+ writeln(f,Effect_Ctrl[3].val)
+ writeln(f,Effect_Ctrl[4].val)
+ writeln(f,Effect_Ctrl[5].val)
+ writeln(f,Effect_Ctrl[6].val)
+ writeln(f,Effect_Ctrl[7].val)
+ writeln(f,Effect_Ctrl[8].val)
+ writeln(f,CustomFX[0].val)
+ writeln(f,CustomFX[1].val)
+ writeln(f,CustomFX[2].val)
+ writeln(f,Min.val)
+ writeln(f,Max.val)
+ writeln(f,Falloff[0].val)
+ writeln(f,Falloff[1].val)
+ writeln(f,Falloff[2].val)
+ writeln(f,Falloff[3].val)
+ writeln(f,Falloff[4].val)
+ writeln(f,Filter_Mode.val)
+ writeln(f,Filter_Order.val)
+ writeln(f,CustomFilt[0].val)
+ writeln(f,CustomFilt[1].val)
+ writeln(f,CustomFilt[2].val)
+ writeln(f,Def_Filter_Ctrl[0].val)
+ writeln(f,Def_Filter_Ctrl[1].val)
+ writeln(f,Ipo_Filter_Ctrl[0].val)
+ writeln(f,Ipo_Filter_Ctrl[1].val)
+ writeln(f,Ipo_Filter_Ctrl[2].val)
+ writeln(f,Ipo_Filter_Ctrl[3].val)
+ writeln(f,RandMod.val)
+ writeln(f,RSeed.val)
+ writeln(f,rand_H.val)
+ writeln(f,rand_I.val)
+ writeln(f,rand_S.val)
+ writeln(f,rand_L.val)
+ filemessage = 'Settings saved to file.'
+ f.close()
+
+#--------------------------------------------------
+# load settings from .ant file
+def LoadPreset(FName):
+ global iScale, Offset, Invert, NSize, Sx, Sy, Lx, Ly
+ global NType, Basis, musgr, tBasismod, vlnoi, vlnoiTwo, voron, turbOne, turbTwo, marbleOne, marbleTwo, musgrTwo
+ global CustomFX, effect_image, Effect_Ctrl, Min, Max, Falloff, CustomFilt, Filter_Mode, Def_Filter_Ctrl, Ipo_Filter_Ctrl, Filter_Order
+ global RandMod, RSeed, rand_H, rand_S, rand_L, rand_I, filemessage, fileinfo
+
+ try:
+ f = open(FName,'r')
+ FVersion = readstr(f)
+ except:
+ filemessage = "Unable to open file."
+ return
+
+ fileinfo = readstr(f)
+ iScale[0].val = readfloat(f)
+ iScale[1].val = readfloat(f)
+ iScale[2].val = readfloat(f)
+ Offset[0].val = readfloat(f)
+ Offset[1].val = readfloat(f)
+ Offset[2].val = readfloat(f)
+ Invert[0].val = readint(f)
+ Invert[1].val = readint(f)
+ Invert[2].val = readint(f)
+ NSize[0].val = readfloat(f)
+ NSize[1].val = readfloat(f)
+ Sx[0].val = readfloat(f)
+ Sx[1].val = readfloat(f)
+ Sy[0].val = readfloat(f)
+ Sy[1].val = readfloat(f)
+ Lx[0].val = readfloat(f)
+ Lx[1].val = readfloat(f)
+ Ly[0].val = readfloat(f)
+ Ly[1].val = readfloat(f)
+ NType.val = readint(f)
+ Basis[0].val = readint(f)
+ Basis[1].val = readint(f)
+ musgr[0].val = readfloat(f)
+ musgr[1].val = readfloat(f)
+ musgr[2].val = readint(f)
+ musgr[3].val = readfloat(f)
+ musgr[4].val = readfloat(f)
+ musgr[5].val = readfloat(f)
+ tBasismod.val = readint(f)
+ vlnoi[0].val = readfloat(f)
+ vlnoi[1].val = readint(f)
+ vlnoiTwo[0].val = readfloat(f)
+ vlnoiTwo[1].val = readint(f)
+ voron[0].val = readint(f)
+ voron[1].val = readfloat(f)
+ turbOne[0].val = readint(f)
+ turbOne[1].val = readint(f)
+ turbOne[2].val = readfloat(f)
+ turbOne[3].val = readfloat(f)
+ turbTwo[0].val = readint(f)
+ turbTwo[1].val = readint(f)
+ turbTwo[2].val = readfloat(f)
+ turbTwo[3].val = readfloat(f)
+ marbleOne[0].val = readint(f)
+ marbleOne[1].val = readint(f)
+ marbleOne[2].val = readfloat(f)
+ marbleOne[3].val = readint(f)
+ marbleOne[4].val = readint(f)
+ marbleOne[5].val = readfloat(f)
+ marbleTwo[0].val = readint(f)
+ marbleTwo[1].val = readint(f)
+ marbleTwo[2].val = readfloat(f)
+ marbleTwo[3].val = readint(f)
+ marbleTwo[4].val = readint(f)
+ marbleTwo[5].val = readfloat(f)
+ musgrTwo[0].val = readfloat(f)
+ musgrTwo[1].val = readfloat(f)
+ musgrTwo[2].val = readint(f)
+ musgrTwo[3].val = readfloat(f)
+ musgrTwo[4].val = readfloat(f)
+ effect_image = readstr(f)
+ Effect_Ctrl[0].val = readint(f)
+ Effect_Ctrl[1].val = readint(f)
+ Effect_Ctrl[2].val = readfloat(f)
+ Effect_Ctrl[3].val = readint(f)
+ Effect_Ctrl[4].val = readfloat(f)
+ Effect_Ctrl[5].val = readint(f)
+ Effect_Ctrl[6].val = readfloat(f)
+ Effect_Ctrl[7].val = readfloat(f)
+ Effect_Ctrl[8].val = readfloat(f)
+ CustomFX[0].val = readstr(f)
+ CustomFX[1].val = readstr(f)
+ CustomFX[2].val = readstr(f)
+ Min.val = readfloat(f)
+ Max.val = readfloat(f)
+ Falloff[0].val = readint(f)
+ Falloff[1].val = readfloat(f)
+ Falloff[2].val = readfloat(f)
+ Falloff[3].val = readint(f)
+ Falloff[4].val = readint(f)
+ Filter_Mode.val = readint(f)
+ Filter_Order.val = readint(f)
+ CustomFilt[0].val = readstr(f)
+ CustomFilt[1].val = readstr(f)
+ CustomFilt[2].val = readstr(f)
+ Def_Filter_Ctrl[0].val = readint(f)
+ Def_Filter_Ctrl[1].val = readfloat(f)
+ Ipo_Filter_Ctrl[0].val = readstr(f)
+ Ipo_Filter_Ctrl[1].val = readint(f)
+ Ipo_Filter_Ctrl[2].val = readfloat(f)
+ Ipo_Filter_Ctrl[3].val = readfloat(f)
+ RandMod.val = readint(f)
+ RSeed.val = readint(f)
+ rand_H.val = readint(f)
+ rand_I.val = readint(f)
+ rand_S.val = readint(f)
+ rand_L.val = readint(f)
+ filemessage = 'Settings loaded from file.'
+ f.close()
+
+##---------------------------------------------------------------------------
+# Register:
+
+Register( drawgui, events, bevents )
+###--------------------------------------------------------------------------
+ \ No newline at end of file
diff --git a/release/scripts/xfig_export.py b/release/scripts/xfig_export.py
deleted file mode 100644
index ddc0dd4dcea..00000000000
--- a/release/scripts/xfig_export.py
+++ /dev/null
@@ -1,234 +0,0 @@
-#!BPY
-"""
-Name: 'xfig export (.fig)'
-Blender: 244
-Group: 'Export'
-Tooltip: 'Export selected mesh to xfig Format (.fig)'
-"""
-
-__author__ = 'Dino Ghilardi', 'Campbell Barton AKA Ideasman42'
-__url__ = ("blender", "blenderartists.org")
-__version__ = "1.1"
-
-__bpydoc__ = """\
- This script exports the selected mesh to xfig (www.xfig.org) file format (i.e.: .fig)
-
- The starting point of this script was Anthony D'Agostino's raw triangle format export.
- (some code is still here and there, cut'n pasted from his script)
-
- Usage:<br>
- Select the mesh to be exported and run this script from "File->Export" menu.
- The toggle button 'export 3 files' enables the generation of 4 files: one global
- and three with the three different views of the object.
- This script is licensed under the GPL license. (c) Dino Ghilardi, 2005
-
-"""
-
-# .fig export, mostly brutally cut-n pasted from the
-# 'Raw triangle export' (Anthony D'Agostino, http://www.redrival.com/scorpius)|
-
-import Blender
-from Blender import Draw
-import BPyObject
-#, meshtools
-import sys
-import bpy
-#import time
-
-# =================================
-# === Write xfig Format.===
-# =================================
-
-def collect_edges(edges):
- """Gets the max-min coordinates of the mesh"""
-
- """Getting the extremes of the mesh to be exported"""
-
- maxX=maxY=maxZ = -1000000000
- minX=minY=minZ = 1000000000
-
- FGON= Blender.Mesh.EdgeFlags.FGON
-
- me = bpy.data.meshes.new()
- for ob_base in bpy.data.scenes.active.objects.context:
- for ob in BPyObject.getDerivedObjects(ob_base):
- me.verts = None
- try: me.getFromObject(ob[0])
- except: pass
-
- if me.edges:
- me.transform(ob[1])
-
- for ed in me.edges:
- if not ed.flag & FGON:
- x,y,z = v1 = tuple(ed.v1.co)
- maxX = max(maxX, x)
- maxY = max(maxY, y)
- maxZ = max(maxZ, z)
- minX = min(minX, x)
- minY = min(minY, y)
- minZ = min(minZ, z)
-
- x,y,z = v2 = tuple(ed.v2.co)
- maxX = max(maxX, x)
- maxY = max(maxY, y)
- maxZ = max(maxZ, z)
- minX = min(minX, x)
- minY = min(minY, y)
- minZ = min(minZ, z)
-
- edges.append( (v1, v2) )
-
- me.verts = None # free memory
- return maxX,maxY,maxZ,minX,minY,minZ
-
-def xfigheader(file):
- file.write('#FIG 3.2 Produced by xfig version 3.2.5-alpha5\n')
- file.write('Landscape\n')
- file.write('Center\n')
- file.write('Metric\n')
- file.write('A4\n')
- file.write('100.00\n')
- file.write('Single\n')
- file.write('-2\n')
- file.write('1200 2\n')
-
-def figdata(file, edges, expview, bounds, scale, space):
- maxX,maxY,maxZ,minX,minY,minZ = bounds
-
- def xytransform(ed):
- """gives the face vertexes coordinates in the xfig format/translation (view xy)"""
- x1,y1,z1 = ed[0]
- x2,y2,z2 = ed[1]
- y1=-y1; y2=-y2
- return x1,y1,z1,x2,y2,z2
-
- def xztransform(ed):
- """gives the face vertexes coordinates in the xfig format/translation (view xz)"""
- x1,y1,z1 = ed[0]
- x2,y2,z2 = ed[1]
- y1=-y1
- y2=-y2
-
- z1=-z1+maxZ-minY +space
- z2=-z2+maxZ-minY +space
- return x1,y1,z1,x2,y2,z2
-
- def yztransform(ed):
- """gives the face vertexes coordinates in the xfig format/translation (view xz)"""
- x1,y1,z1 = ed[0]
- x2,y2,z2 = ed[1]
- y1=-y1; y2=-y2
- z1=-(z1-maxZ-maxX-space)
- z2=-(z2-maxZ-maxX-space)
- return x1,y1,z1,x2,y2,z2
-
- def transform(ed, expview, scale):
- if expview=='xy':
- x1,y1,z1,x2,y2,z2 = xytransform(ed)
- return int(x1*scale),int(y1*scale),int(x2*scale),int(y2*scale)
- elif expview=='xz':
- x1,y1,z1,x2,y2,z2 = xztransform(ed)
- return int(x1*scale),int(z1*scale),int(x2*scale),int(z2*scale)
- elif expview=='yz':
- x1,y1,z1,x2,y2,z2 = yztransform(ed)
- return int(z1*scale),int(y1*scale),int(z2*scale),int(y2*scale)
-
-
- """Prints all the xfig data (no header)"""
- for ed in edges:
- file.write('2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n')
- file.write('\t %i %i %i %i\n' % transform(ed, expview, scale))
-
-def writexy(edges, bounds, filename, scale, space):
- """writes the x-y view file exported"""
-
- file = open(filename, 'wb')
- xfigheader(file)
- figdata(file, edges, 'xy', bounds, scale, space)
- file.close()
- print 'Successfully exported ', Blender.sys.basename(filename)# + seconds
-
-def writexz(edges, bounds, filename, scale, space):
- """writes the x-z view file exported"""
- #start = time.clock()
- file = open(filename, 'wb')
- xfigheader(file)
- figdata(file, edges, 'xz', bounds, scale, space)
- file.close()
- print 'Successfully exported ', Blender.sys.basename(filename)# + seconds
-
-def writeyz(edges, bounds, filename, scale, space):
- """writes the y-z view file exported"""
-
- #start = time.clock()
- file = open(filename, 'wb')
- xfigheader(file)
- figdata(file, edges, 'yz', bounds, scale, space)
- file.close()
- #end = time.clock()
- #seconds = " in %.2f %s" % (end-start, "seconds")
- print 'Successfully exported ', Blender.sys.basename(filename)# + seconds
-
-def writeall(edges, bounds, filename, scale=450, space=2.0):
- """writes all 3 views
-
- Every view is a combined object in the resulting xfig. file."""
-
- maxX,maxY,maxZ,minX,minY,minZ = bounds
-
- file = open(filename, 'wb')
-
- xfigheader(file)
- file.write('#upper view (7)\n')
- file.write('6 % i % i % i % i ')
- file.write('%.6f %.6f %.6f %.6f\n' % (minX, minY, maxX, maxY))
-
- figdata(file, edges, 'xy', bounds, scale, space)
- file.write('-6\n')
- file.write('#bottom view (1)\n')
- file.write('6 %i %i %i %i ')
- file.write('%.6f %.6f %.6f %.6f\n' % (minX, -minZ+maxZ-minY +space, maxX,-maxZ+maxZ-minY +space))
-
- figdata(file, edges, 'xz', bounds, scale, space)
- file.write('-6\n')
-
- file.write('#right view (3)\n')
- file.write('6 %i %i %i %i ')
- file.write('%.6f %.6f %.6f %.6f\n' % (minX, -minZ+maxZ-minY +space, maxX,-maxZ+maxZ-minY +space))
- figdata(file, edges, 'yz', bounds, scale, space)
- file.write('-6\n')
-
- file.close()
- print 'Successfully exported ', Blender.sys.basename(filename)# + seconds
-
-import BPyMessages
-
-def write_ui(filename):
- if filename.lower().endswith('.fig'): filename = filename[:-4]
-
- PREF_SEP= Draw.Create(0)
- PREF_SCALE= Draw.Create(1200)
- PREF_SPACE= Draw.Create(2.0)
-
- block = [\
- ("Separate Files", PREF_SEP, "Export each view axis as a seperate file"),\
- ("Space: ", PREF_SPACE, 0.0, 10.0, "Space between views in blender units"),\
- ("Scale: ", PREF_SCALE, 10, 100000, "Scale, 1200 is a good default")]
-
- if not Draw.PupBlock("Export FIG", block):
- return
-
- edges = []
- bounds = collect_edges(edges)
-
- if PREF_SEP.val:
- writexy(edges, bounds, filename + '_XY.fig', PREF_SCALE.val, PREF_SPACE.val)
- writexz(edges, bounds, filename + '_XZ.fig', PREF_SCALE.val, PREF_SPACE.val)
- writeyz(edges, bounds, filename + '_YZ.fig', PREF_SCALE.val, PREF_SPACE.val)
-
- writeall(edges, bounds, filename + '.fig', PREF_SCALE.val, PREF_SPACE.val)
-
-if __name__ == '__main__':
- Blender.Window.FileSelector(write_ui, 'Export XFIG', Blender.sys.makename(ext='.fig'))
- \ No newline at end of file
diff --git a/release/ui/space_sequencer.py b/release/ui/space_sequencer.py
index aaa702b2fc1..71a185dbe18 100644
--- a/release/ui/space_sequencer.py
+++ b/release/ui/space_sequencer.py
@@ -464,3 +464,4 @@ bpy.types.register(SEQUENCER_PT_effect)
bpy.types.register(SEQUENCER_PT_input)
bpy.types.register(SEQUENCER_PT_filter)
bpy.types.register(SEQUENCER_PT_proxy)
+
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 04566ec3b0b..4764caddf6a 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -24,12 +24,13 @@
#
# ***** END GPL LICENSE BLOCK *****
-SUBDIRS(blender kernel)
+ADD_SUBDIRECTORY(blender)
+ADD_SUBDIRECTORY(kernel)
IF(WITH_GAMEENGINE)
- SUBDIRS(gameengine)
+ ADD_SUBDIRECTORY(gameengine)
ENDIF(WITH_GAMEENGINE)
IF(WINDOWS)
- SUBDIRS(icons)
+ ADD_SUBDIRECTORY(icons)
ENDIF(WINDOWS)
diff --git a/source/Makefile b/source/Makefile
index 087369e0ad4..535a86e9139 100644
--- a/source/Makefile
+++ b/source/Makefile
@@ -155,6 +155,9 @@ ifneq ($(NAN_NO_KETSJI),true)
COMLIB += $(NAN_BULLET2)/lib/libbullet2.a
endif
+# Cloth requires bullet2, gameegine does not matter anymore
+#COMLIB += $(NAN_BULLET2)/lib/libbullet2.a
+
COMLIB += $(OCGDIR)/blender/makesdna/$(DEBUG_DIR)libdna.a
COMLIB += $(NAN_GUARDEDALLOC)/lib/libguardedalloc.a
COMLIB += $(NAN_MEMUTIL)/lib/libmemutil.a
@@ -274,6 +277,7 @@ SPLIB = $(OCGDIR)/blender/readblenfile/$(DEBUG_DIR)libreadblenfile.a
# can I just not check them? nm claims they aren't...
SPLIB += $(OCGDIR)/blender/blenkernel/blenkernel_blc/$(DEBUG_DIR)libblenkernel_blc.a
SPLIB += $(OCGDIR)/blender/makesrna/$(DEBUG_DIR)librna.a
+SPLIB += $(OCGDIR)/blender/blenlib/$(DEBUG_DIR)libblenlib.a
# These three need to be explicitly mentioned on the cl, because
# if they are offered as a lib, they are optimized away. (nzc)
@@ -375,8 +379,6 @@ else
NAN_SND_LIBS += $(OPENALSOUND)
NAN_SND_LIBS += $(SDLSOUND)
NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a
- ALUT = $(wildcard $(NAN_OPENAL)/lib/libalut.a)
- NAN_SND_LIBS += $(ALUT)
NAN_SND_LIBS += $(SOUNDSYSTEM)
else
ifeq ($(OS),windows)
@@ -385,8 +387,6 @@ else
NAN_SND_LIBS += $(OPENALSOUND)
NAN_SND_LIBS += $(SDLSOUND)
NAN_SND_LIBS += $(NAN_OPENAL)/lib/openal_static.lib
- ALUT = $(wildcard $(NAN_OPENAL)/lib/alut_static.lib)
- NAN_SND_LIBS += $(ALUT)
NAN_SND_LIBS += $(SOUNDSYSTEM)
else
NAN_SND_LIBS = $(SOUNDSYSTEM)
@@ -400,8 +400,6 @@ else
NAN_SND_LIBS += $(DUMMYSOUND)
NAN_SND_LIBS += $(OPENALSOUND)
NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a
- ALUT = $(wildcard $(NAN_OPENAL)/lib/libalut.a)
- NAN_SND_LIBS += $(ALUT)
NAN_SND_LIBS += $(SOUNDSYSTEM)
else
ifeq ($(OS), solaris)
@@ -410,8 +408,6 @@ else
NAN_SND_LIBS += $(OPENALSOUND)
NAN_SND_LIBS += $(SDLSOUND)
NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a
- ALUT = $(wildcard $(NAN_OPENAL)/lib/libalut.a)
- NAN_SND_LIBS += $(ALUT)
NAN_SND_LIBS += $(SOUNDSYSTEM)
else
ifeq ($(OS), irix)
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 344d51db248..a53b15673e2 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -24,20 +24,37 @@
#
# ***** END GPL LICENSE BLOCK *****
-SUBDIRS(windowmanager editors avi nodes blenkernel blenlib blenloader blenpluginapi imbuf imbuf/intern/cineon gpu makesdna makesrna radiosity readblenfile render blenfont)
+ADD_SUBDIRECTORY(windowmanager)
+ADD_SUBDIRECTORY(editors)
+ADD_SUBDIRECTORY(avi)
+ADD_SUBDIRECTORY(nodes)
+ADD_SUBDIRECTORY(blenkernel)
+ADD_SUBDIRECTORY(blenlib)
+ADD_SUBDIRECTORY(blenloader)
+ADD_SUBDIRECTORY(blenpluginapi)
+ADD_SUBDIRECTORY(imbuf)
+ADD_SUBDIRECTORY(imbuf/intern/cineon)
+ADD_SUBDIRECTORY(gpu)
+ADD_SUBDIRECTORY(makesdna)
+ADD_SUBDIRECTORY(makesrna)
+ADD_SUBDIRECTORY(radiosity)
+ADD_SUBDIRECTORY(readblenfile)
+ADD_SUBDIRECTORY(render)
+ADD_SUBDIRECTORY(blenfont)
IF(WITH_OPENEXR)
- SUBDIRS(imbuf/intern/openexr)
+ ADD_SUBDIRECTORY(imbuf/intern/openexr)
ENDIF(WITH_OPENEXR)
IF(WITH_DDS)
- SUBDIRS(imbuf/intern/dds)
+ ADD_SUBDIRECTORY(imbuf/intern/dds)
ENDIF(WITH_DDS)
IF(WITH_QUICKTIME)
- SUBDIRS(quicktime)
+ ADD_SUBDIRECTORY(quicktime)
ENDIF(WITH_QUICKTIME)
IF(WITH_PYTHON)
- SUBDIRS(python)
+ ADD_SUBDIRECTORY(python)
ENDIF(WITH_PYTHON)
+
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 8c54c35473c..06103596be1 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -445,6 +445,9 @@ DerivedMesh *mesh_create_derived_no_deform(struct Scene *scene, struct Object *o
DerivedMesh *mesh_create_derived_no_deform_render(struct Scene *scene, struct Object *ob,
float (*vertCos)[3],
CustomDataMask dataMask);
+/* for gameengine */
+DerivedMesh *mesh_create_derived_no_virtual(struct Scene *scene, struct Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask);
DerivedMesh *editmesh_get_derived_base(struct Object *, struct EditMesh *em);
DerivedMesh *editmesh_get_derived_cage(struct Scene *scene, struct Object *,
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 70eba5006d6..9bb246f88cc 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -35,6 +35,7 @@ struct bglMats;
struct Scene;
struct Object;
struct Base;
+struct Text;
struct AviCodecData;
struct QuicktimeCodecData;
struct RenderData;
diff --git a/source/blender/blenkernel/BKE_sequence.h b/source/blender/blenkernel/BKE_sequence.h
index 0960f968c4e..65a3b0216fe 100644
--- a/source/blender/blenkernel/BKE_sequence.h
+++ b/source/blender/blenkernel/BKE_sequence.h
@@ -142,10 +142,10 @@ void seq_free_strip(struct Strip *strip);
void seq_free_editing(struct Editing *ed);
struct Editing *seq_give_editing(struct Scene *scene, int alloc);
char *give_seqname(struct Sequence *seq);
-struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown);
-struct ImBuf *give_ibuf_seq_threaded(struct Scene *scene, int rectx, int recty, int cfra, int chanshown);
-struct ImBuf *give_ibuf_seq_direct(struct Scene *scene, int rectx, int recty, int cfra, struct Sequence *seq);
-void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown);
+struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size);
+struct ImBuf *give_ibuf_seq_threaded(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size);
+struct ImBuf *give_ibuf_seq_direct(struct Scene *scene, int rectx, int recty, int cfra, int render_size, struct Sequence *seq);
+void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int render_size);
void calc_sequence(struct Sequence *seq);
void calc_sequence_disp(struct Sequence *seq);
void new_tstripdata(struct Sequence *seq);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 25ca0b0f1b1..bc6e549dc6f 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -904,7 +904,7 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
glShadeModel(GL_SMOOTH);
for (i=0,eve=em->verts.first; eve; eve= eve->next)
- eve->tmp.l = (long) i++;
+ eve->tmp.l = (intptr_t) i++;
#define PASSATTRIB(efa, eve, vert) { \
if(attribs.totorco) { \
@@ -1581,6 +1581,11 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm)
CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, dm->numFaceData);
}
+/* new value for useDeform -1 (hack for the gameengine):
+ * - apply only the modifier stack of the object, skipping the virtual modifiers,
+ * - don't apply the key
+ * - apply deform modifiers and input vertexco
+ */
static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos)[3],
DerivedMesh **deform_r, DerivedMesh **final_r,
int useRenderParams, int useDeform,
@@ -1595,7 +1600,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
int numVerts = me->totvert;
int required_mode;
- md = firstmd = modifiers_getVirtualModifierList(ob);
+ md = firstmd = (useDeform<0) ? ob->modifiers.first : modifiers_getVirtualModifierList(ob);
modifiers_clearErrors(ob);
@@ -1612,8 +1617,10 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
else required_mode = eModifierMode_Realtime;
if(useDeform) {
- if(do_ob_key(scene, ob)) /* shape key makes deform verts */
+ if(useDeform > 0 && do_ob_key(scene, ob)) /* shape key makes deform verts */
deformedVerts = mesh_getVertexCos(me, &numVerts);
+ else if(inputVertexCos)
+ deformedVerts = inputVertexCos;
/* Apply all leading deforming modifiers */
for(;md; md = md->next, curr = curr->next) {
@@ -1623,6 +1630,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
if((md->mode & required_mode) != required_mode) continue;
if(mti->isDisabled && mti->isDisabled(md)) continue;
+ if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
if(mti->type == eModifierTypeType_OnlyDeform) {
if(!deformedVerts)
@@ -1678,6 +1686,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
}
if(mti->isDisabled && mti->isDisabled(md)) continue;
if(needMapping && !modifier_supportsMapping(md)) continue;
+ if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
/* add an orco layer if needed by this modifier */
if(dm && mti->requiredDataMask) {
@@ -2199,6 +2208,16 @@ DerivedMesh *mesh_create_derived_no_deform(Scene *scene, Object *ob, float (*ver
return final;
}
+DerivedMesh *mesh_create_derived_no_virtual(Scene *scene, Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask)
+{
+ DerivedMesh *final;
+
+ mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, -1, 0, dataMask, -1);
+
+ return final;
+}
+
DerivedMesh *mesh_create_derived_no_deform_render(Scene *scene, Object *ob,
float (*vertCos)[3],
CustomDataMask dataMask)
diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile
index 1528ec1c86e..a6a5066b574 100644
--- a/source/blender/blenkernel/intern/Makefile
+++ b/source/blender/blenkernel/intern/Makefile
@@ -82,7 +82,7 @@ CPPFLAGS += -I../../gpu
CPPFLAGS += -I..
# path to bullet2, for cloth
-CPPFLAGS += -I../../../../extern/bullet2/src
+CPPFLAGS += -I$(NAN_BULLET2)/include
CPPFLAGS += -I$(NAN_FREETYPE)/include
CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 3169905b7f5..5fc7d18689d 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -400,7 +400,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename)
MEM_freeN(bfd);
}
-static void handle_subversion_warning(Main *main)
+static int handle_subversion_warning(Main *main)
{
if(main->minversionfile > BLENDER_VERSION ||
(main->minversionfile == BLENDER_VERSION &&
@@ -411,7 +411,7 @@ static void handle_subversion_warning(Main *main)
sprintf(str, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
// XXX error(str);
}
-
+ return 1;
}
void BKE_userdef_free(void)
@@ -438,9 +438,14 @@ int BKE_read_file(bContext *C, char *dir, void *unused, ReportList *reports)
if (bfd) {
if(bfd->user) retval= 2;
- setup_app_data(C, bfd, dir);
-
- handle_subversion_warning(G.main);
+ if(0==handle_subversion_warning(bfd->main)) {
+ free_main(bfd->main);
+ MEM_freeN(bfd);
+ bfd= NULL;
+ retval= 0;
+ }
+ else
+ setup_app_data(C, bfd, dir); // frees BFD
}
else
BKE_reports_prependf(reports, "Loading %s failed: ", dir);
diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c
index 0af54b86ed6..09770b2b4ba 100644
--- a/source/blender/blenkernel/intern/bmfont.c
+++ b/source/blender/blenkernel/intern/bmfont.c
@@ -178,7 +178,7 @@ void detectBitmapFont(ImBuf *ibuf)
{
unsigned char * rect;
unsigned short version;
- long i;
+ int i;
if (ibuf != NULL) {
// bitmap must have an x size that is a power of two
diff --git a/source/blender/blenkernel/intern/bullet.c b/source/blender/blenkernel/intern/bullet.c
index b389f8c0536..44e8ed1f08c 100644
--- a/source/blender/blenkernel/intern/bullet.c
+++ b/source/blender/blenkernel/intern/bullet.c
@@ -82,6 +82,7 @@ BulletSoftBody *bsbNew(void)
bsb->collisionflags = 0;
//bsb->collisionflags = OB_BSB_COL_CL_RS + OB_BSB_COL_CL_SS;
bsb->numclusteriterations = 64;
+ bsb->welding = 0.f;
return bsb;
}
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 6c9dfe4bf0a..e98d7bb01a4 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -157,7 +157,7 @@ BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float epsilon)
{
unsigned int i;
BVHTree *bvhtree;
- Cloth *cloth = clmd->clothObject;
+ Cloth *cloth;
ClothVertex *verts;
MFace *mfaces;
float co[12];
@@ -198,7 +198,7 @@ BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon)
{
unsigned int i;
BVHTree *bvhtree;
- Cloth *cloth = clmd->clothObject;
+ Cloth *cloth;
ClothVertex *verts;
MFace *mfaces;
float co[12];
@@ -787,15 +787,14 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
int j = 0;
MDeformVert *dvert = NULL;
Cloth *clothObj = NULL;
- int numverts = dm->getNumVerts ( dm );
+ int numverts;
float goalfac = 0;
ClothVertex *verts = NULL;
+ if (!clmd || !dm) return;
+
clothObj = clmd->clothObject;
- if ( !dm )
- return;
-
numverts = dm->getNumVerts ( dm );
verts = clothObj->verts;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index c055a0ca6a7..a43389a2ef6 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -3430,6 +3430,8 @@ void copy_constraints (ListBase *dst, ListBase *src)
/* make a new copy of the constraint's data */
con->data = MEM_dupallocN(con->data);
+ id_us_plus((ID *)con->ipo);
+
/* only do specific constraints if required */
if (cti && cti->copy_data)
cti->copy_data(con, srccon);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 8c1065c1d84..705d0b66d7f 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -33,7 +33,7 @@
*/
#include "BKE_customdata.h"
-
+#include "BKE_utildefines.h" // CLAMP
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
@@ -573,6 +573,14 @@ static void layerInterp_mloopcol(void **sources, float *weights,
col.b += src->b * weight;
}
}
+
+ /* Subdivide smooth or fractal can cause problems without clamping
+ * although weights should also not cause this situation */
+ CLAMP(col.a, 0.0f, 255.0f);
+ CLAMP(col.r, 0.0f, 255.0f);
+ CLAMP(col.g, 0.0f, 255.0f);
+ CLAMP(col.b, 0.0f, 255.0f);
+
mc->a = (int)col.a;
mc->r = (int)col.r;
mc->g = (int)col.g;
@@ -648,6 +656,14 @@ static void layerInterp_mcol(void **sources, float *weights,
}
for(j = 0; j < 4; ++j) {
+
+ /* Subdivide smooth or fractal can cause problems without clamping
+ * although weights should also not cause this situation */
+ CLAMP(col[j].a, 0.0f, 255.0f);
+ CLAMP(col[j].r, 0.0f, 255.0f);
+ CLAMP(col[j].g, 0.0f, 255.0f);
+ CLAMP(col[j].b, 0.0f, 255.0f);
+
mc[j].a = (int)col[j].a;
mc[j].r = (int)col[j].r;
mc[j].g = (int)col[j].g;
@@ -783,7 +799,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
number++;
if(layer->flag & CD_FLAG_NOCOPY) continue;
- else if(!(mask & (1 << type))) continue;
+ else if(!((int)mask & (int)(1 << (int)type))) continue;
else if(number < CustomData_number_of_layers(dest, type)) continue;
if((alloctype == CD_ASSIGN) && (layer->flag & CD_FLAG_NOFREE))
@@ -1301,7 +1317,7 @@ void CustomData_set_only_copy(const struct CustomData *data,
int i;
for(i = 0; i < data->totlayer; ++i)
- if(!(mask & (1 << data->layers[i].type)))
+ if(!((int)mask & (int)(1 << (int)data->layers[i].type)))
data->layers[i].flag |= CD_FLAG_NOCOPY;
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 8779ed5404b..fe138407d54 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -940,7 +940,7 @@ void filldisplist(ListBase *dispbase, ListBase *to)
DispList *dlnew=0, *dl;
float *f1;
int colnr=0, charidx=0, cont=1, tot, a, *index;
- long totvert;
+ intptr_t totvert;
if(dispbase==0) return;
if(dispbase->first==0) return;
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 077a0c437d4..9858025af5a 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -79,7 +79,6 @@
#include "BKE_screen.h"
#include "BKE_utildefines.h"
-#include "PIL_time.h"
#include "RE_render_ext.h"
/* fluid sim particle import */
@@ -162,8 +161,7 @@ static void add_to_effectorcache(ListBase *lb, Scene *scene, Object *ob, Object
if(pd->forcefield == PFIELD_WIND)
{
- pd->rng = rng_new(1);
- rng_srandom(pd->rng, (unsigned int)(ceil(PIL_check_seconds_timer()))); // use better seed
+ pd->rng = rng_new(pd->seed);
}
ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
@@ -287,14 +285,14 @@ static float eff_calc_visibility(Scene *scene, Object *ob, float *co, float *dir
// noise function for wind e.g.
static float wind_func(struct RNG *rng, float strength)
{
- int random = (rng_getInt(rng)+1) % 65535; // max 2357
+ int random = (rng_getInt(rng)+1) % 128; // max 2357
float force = rng_getFloat(rng) + 1.0f;
float ret;
float sign = 0;
- sign = (random > 32000.0) ? 1.0: -1.0; // dividing by 2 is not giving equal sign distribution
+ sign = ((float)random > 64.0) ? 1.0: -1.0; // dividing by 2 is not giving equal sign distribution
- ret = sign*((float)random / force)*strength/65535.0f;
+ ret = sign*((float)random / force)*strength/128.0f;
return ret;
}
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index 5488d50e226..929d3f942dc 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -944,7 +944,7 @@ static int iv_finddata(struct IvNode *iv, char *field, int fieldnr)
float *fp;
int len, stackcount, skipdata=0;
char *cpa, terminator, str[64];
- long i;
+ intptr_t i;
len= strlen(field);
@@ -2397,7 +2397,7 @@ static void write_videoscape_mesh(Scene *scene, Object *ob, char *str)
unsigned int kleur[32];
float co[3];
int a;
- long tot;
+ intptr_t tot;
char *cp;
if(ob && ob->type==OB_MESH);
@@ -2447,17 +2447,17 @@ static void write_videoscape_mesh(Scene *scene, Object *ob, char *str)
if(evl->v4==0) {
fprintf(fp, "3 %ld %ld %ld 0x%x\n",
- (long int) evl->v1->tmp.l,
- (long int) evl->v2->tmp.l,
- (long int) evl->v3->tmp.l,
+ (intptr_t) evl->v1->tmp.l,
+ (intptr_t) evl->v2->tmp.l,
+ (intptr_t) evl->v3->tmp.l,
kleur[evl->mat_nr]);
}
else {
fprintf(fp, "4 %ld %ld %ld %ld 0x%x\n",
- (long int) evl->v1->tmp.l,
- (long int) evl->v2->tmp.l,
- (long int) evl->v3->tmp.l,
- (long int) evl->v4->tmp.l,
+ (intptr_t) evl->v1->tmp.l,
+ (intptr_t) evl->v2->tmp.l,
+ (intptr_t) evl->v3->tmp.l,
+ (intptr_t) evl->v4->tmp.l,
kleur[evl->mat_nr]);
}
evl= evl->next;
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index b94652eb7c3..c3cf6e06c09 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -1144,14 +1144,12 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
ct= chartransdata;
if (cu->sepchar==0) {
for (i= 0; i<slen; i++) {
- cha = (unsigned long) mem[i];
- info = &(custrinfo[i]);
-
+ cha = (uintptr_t) mem[i];
+ info = &(cu->strinfo[i]);
if (info->mat_nr > (ob->totcol)) {
/* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */
info->mat_nr = 0;
}
-
// We do not want to see any character for \n or \r
if(cha != '\n' && cha != '\r')
buildchar(cu, cha, info, ct->xof, ct->yof, ct->rot, i);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 629f34518b9..8eef9984c92 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -433,7 +433,7 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, sho
unsigned char *rect= NULL;
float *rect_float= NULL;
int x, y;
- int checkerwidth=21, dark=1;
+ int checkerwidth=32, dark=1;
if (floatbuf) {
ibuf= IMB_allocImBuf(width, height, 24, IB_rectfloat, 0);
@@ -668,6 +668,11 @@ static uintptr_t image_mem_size(Image *ima)
uintptr_t size = 0;
size= 0;
+
+ /* viewers have memory depending on other rules, has no valid rect pointer */
+ if(ima->source==IMA_SRC_VIEWER)
+ return 0;
+
for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) {
if(ibuf->rect) size += MEM_allocN_len(ibuf->rect);
else if(ibuf->rect_float) size += MEM_allocN_len(ibuf->rect_float);
@@ -1052,7 +1057,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
}
if (scene->r.stamp & R_STAMP_SEQSTRIP) {
- Sequence *seq= NULL; //XXX = get_forground_frame_seq(scene->r.cfra);
+ Sequence *seq= NULL; //XXX = get_foreground_frame_seq(scene->r.cfra);
if (seq) strcpy(text, seq->name+2);
else strcpy(text, "<none>");
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 9c5560be8f3..8cbf25eaeed 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1741,3 +1741,4 @@ void do_versions_ipos_to_animato(Main *main)
printf("INFO: Animato convert done \n"); // xxx debug
}
+
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 3e881f2d871..74d56e81a87 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -296,7 +296,10 @@ Object *find_basis_mball(Scene *scene, Object *basis)
splitIDname(basis->id.name+2, basisname, &basisnr);
totelem= 0;
- next_object(scene, 0, 0, 0);
+ /* XXX recursion check, see scene.c, just too simple code this next_object() */
+ if(F_ERROR==next_object(scene, 0, 0, 0))
+ return NULL;
+
while(next_object(scene, 1, &base, &ob)) {
if (ob->type==OB_MBALL) {
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index e8427a973d0..6ebd68e990f 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -6265,6 +6265,48 @@ static int is_last_displist(Object *ob)
return 0;
}
+
+static DerivedMesh *get_original_dm(Scene *scene, Object *ob, float (*vertexCos)[3], int orco)
+{
+ DerivedMesh *dm= NULL;
+
+ if(ob->type==OB_MESH) {
+ dm = CDDM_from_mesh((Mesh*)(ob->data), ob);
+
+ if(vertexCos) {
+ CDDM_apply_vert_coords(dm, vertexCos);
+ //CDDM_calc_normals(dm);
+ }
+
+ if(orco)
+ DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob));
+ }
+ else if(ELEM3(ob->type,OB_FONT,OB_CURVE,OB_SURF)) {
+ Object *tmpobj;
+ Curve *tmpcu;
+
+ if(is_last_displist(ob)) {
+ /* copies object and modifiers (but not the data) */
+ tmpobj= copy_object(ob);
+ tmpcu = (Curve *)tmpobj->data;
+ tmpcu->id.us--;
+
+ /* copies the data */
+ tmpobj->data = copy_curve((Curve *) ob->data);
+
+ makeDispListCurveTypes(scene, tmpobj, 1);
+ nurbs_to_mesh(tmpobj);
+
+ dm = CDDM_from_mesh((Mesh*)(tmpobj->data), tmpobj);
+ //CDDM_calc_normals(dm);
+
+ free_libblock_us(&G.main->object, tmpobj);
+ }
+ }
+
+ return dm;
+}
+
/* saves the current emitter state for a particle system and calculates particles */
static void particleSystemModifier_deformVerts(
ModifierData *md, Object *ob, DerivedMesh *derivedData,
@@ -6283,43 +6325,13 @@ static void particleSystemModifier_deformVerts(
if(!psys_check_enabled(ob, psys))
return;
- if(dm==0){
- if(ob->type==OB_MESH){
- dm = CDDM_from_mesh((Mesh*)(ob->data), ob);
-
- CDDM_apply_vert_coords(dm, vertexCos);
- //CDDM_calc_normals(dm);
-
- DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob));
-
- needsFree=1;
- }
- else if(ELEM3(ob->type,OB_FONT,OB_CURVE,OB_SURF)){
- Object *tmpobj;
- Curve *tmpcu;
-
- if(is_last_displist(ob)){
- /* copies object and modifiers (but not the data) */
- tmpobj= copy_object( ob );
- tmpcu = (Curve *)tmpobj->data;
- tmpcu->id.us--;
-
- /* copies the data */
- tmpobj->data = copy_curve( (Curve *) ob->data );
-
- makeDispListCurveTypes(md->scene, tmpobj, 1 );
- nurbs_to_mesh( tmpobj );
+ if(dm==0) {
+ dm= get_original_dm(md->scene, ob, vertexCos, 1);
- dm = CDDM_from_mesh((Mesh*)(tmpobj->data), tmpobj);
- //CDDM_calc_normals(dm);
-
- free_libblock_us( &G.main->object, tmpobj );
+ if(!dm)
+ return;
- needsFree=1;
- }
- else return;
- }
- else return;
+ needsFree= 1;
}
/* clear old dm */
@@ -7658,6 +7670,14 @@ static void meshdeformModifier_do(
}
else
cagedm= mmd->object->derivedFinal;
+
+ /* if we don't have one computed, use derivedmesh from data
+ * without any modifiers */
+ if(!cagedm) {
+ cagedm= get_original_dm(md->scene, mmd->object, NULL, 0);
+ if(cagedm)
+ cagedm->needsFree= 1;
+ }
if(!cagedm)
return;
@@ -7951,7 +7971,7 @@ static void shrinkwrapModifier_deformVerts(ModifierData *md, Object *ob, Derived
else if(ob->type==OB_LATTICE) dm = NULL;
else return;
- if(dm != NULL && (dataMask & CD_MVERT))
+ if(dm != NULL && (dataMask & (1<<CD_MVERT)))
{
CDDM_apply_vert_coords(dm, vertexCos);
CDDM_calc_normals(dm);
@@ -7976,7 +7996,7 @@ static void shrinkwrapModifier_deformVertsEM(ModifierData *md, Object *ob, EditM
else if(ob->type==OB_LATTICE) dm = NULL;
else return;
- if(dm != NULL && (dataMask & CD_MVERT))
+ if(dm != NULL && (dataMask & (1<<CD_MVERT)))
{
CDDM_apply_vert_coords(dm, vertexCos);
CDDM_calc_normals(dm);
@@ -8906,8 +8926,10 @@ void modifier_freeTemporaryData(ModifierData *md)
if(md->type == eModifierType_Armature) {
ArmatureModifierData *amd= (ArmatureModifierData*)md;
- if(amd->prevCos)
+ if(amd->prevCos) {
MEM_freeN(amd->prevCos);
+ amd->prevCos= NULL;
+ }
}
}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 43df11335fe..a83b8817580 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1990,9 +1990,9 @@ static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack)
}
}
+/* notes below are ancient! (ton) */
/* stack indices make sure all nodes only write in allocated data, for making it thread safe */
/* only root tree gets the stack, to enable instances to have own stack entries */
-/* only two threads now! */
/* per tree (and per group) unique indices are created */
/* the index_ext we need to be able to map from groups to the group-node own stack */
@@ -2007,14 +2007,9 @@ static bNodeThreadStack *ntreeGetThreadStack(bNodeTree *ntree, int thread)
ListBase *lb= &ntree->threadstack[thread];
bNodeThreadStack *nts;
- /* for material shading this is called quite a lot (perhaps too much locking unlocking)
- * however without locking we get bug #18058 - Campbell */
- BLI_lock_thread(LOCK_CUSTOM1);
-
for(nts=lb->first; nts; nts=nts->next) {
if(!nts->used) {
nts->used= 1;
- BLI_unlock_thread(LOCK_CUSTOM1);
return nts;
}
}
@@ -2022,7 +2017,7 @@ static bNodeThreadStack *ntreeGetThreadStack(bNodeTree *ntree, int thread)
nts->stack= MEM_dupallocN(ntree->stack);
nts->used= 1;
BLI_addtail(lb, nts);
- BLI_unlock_thread(LOCK_CUSTOM1);
+
return nts;
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index d7619010808..81bd78f1851 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -977,6 +977,8 @@ Object *add_only_object(int type, char *name)
ob->anisotropicFriction[2] = 1.0f;
ob->gameflag= OB_PROP|OB_COLLISION;
ob->margin = 0.0;
+ /* ob->pad3 == Contact Processing Threshold */
+ ob->m_contactProcessingThreshold = 1.;
/* NT fluid sim defaults */
ob->fluidsimFlag = 0;
@@ -1131,6 +1133,9 @@ static void copy_object_pose(Object *obn, Object *ob)
* is changed to object->proxy_from when evaluating the driver. */
if(con->ipo && !con->ipo->id.lib) {
IpoCurve *icu;
+
+ con->ipo= copy_ipo(con->ipo);
+
for(icu= con->ipo->curve.first; icu; icu= icu->next) {
if(icu->driver && icu->driver->ob==ob)
icu->driver->ob= obn;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 6cef9959d8b..74a754c0ca8 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -348,15 +348,17 @@ void free_hair(ParticleSystem *psys, int softbody)
}
void free_keyed_keys(ParticleSystem *psys)
{
- if(psys->particles && psys->particles->keys) {
- ParticleData *pa;
- int i, totpart=psys->totpart;
+ ParticleData *pa;
+ int i;
+ if(psys->particles && psys->particles->keys) {
MEM_freeN(psys->particles->keys);
- for(i=0, pa=psys->particles; i<totpart; i++,pa++){
- pa->keys = NULL;
- pa->totkey = 0;
+ for(i=0, pa=psys->particles; i<psys->totpart; i++, pa++) {
+ if(pa->keys) {
+ pa->keys= NULL;
+ pa->totkey= 0;
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index f097af279b6..c0ef92b489e 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -196,8 +196,11 @@ static void realloc_particles(Object *ob, ParticleSystem *psys, int new_totpart)
if(psys->particles->keys)
MEM_freeN(psys->particles->keys);
- for(i=0, pa=psys->particles; i<totsaved; i++, pa++)
- if(pa->keys) pa->keys= NULL;
+ for(i=0, pa=psys->particles; i<psys->totpart; i++, pa++)
+ if(pa->keys) {
+ pa->keys= NULL;
+ pa->totkey= 0;
+ }
for(i=totsaved, pa=psys->particles+totsaved; i<psys->totpart; i++, pa++)
if(pa->hair) MEM_freeN(pa->hair);
@@ -2010,7 +2013,6 @@ static void set_keyed_keys(Scene *scene, Object *ob, ParticleSystem *psys)
Object *kob = ob;
ParticleSystem *kpsys = psys;
ParticleData *pa;
- ParticleKey state;
int totpart = psys->totpart, i, k, totkeys = psys->totkeyed + 1;
float prevtime, nexttime, keyedtime;
@@ -2034,10 +2036,11 @@ static void set_keyed_keys(Scene *scene, Object *ob, ParticleSystem *psys)
}
psys->flag &= ~PSYS_KEYED;
- state.time=-1.0;
for(k=0; k<totkeys; k++) {
for(i=0,pa=psys->particles; i<totpart; i++, pa++) {
+ (pa->keys + k)->time = -1.0; /* use current time */
+
if(kpsys->totpart > 0)
psys_get_particle_state(scene, kob, kpsys, i%kpsys->totpart, pa->keys + k, 1);
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index e8c6c5c199f..74d2347ec39 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -134,7 +134,7 @@ void init_sensor(bSensor *sens)
switch(sens->type) {
case SENS_ALWAYS:
- sens->pulse = 1;
+ sens->pulse = 0;
break;
case SENS_TOUCH:
sens->data= MEM_callocN(sizeof(bTouchSensor), "touchsens");
@@ -579,6 +579,10 @@ void set_sca_new_poins_ob(Object *ob)
bCameraActuator *ca= act->data;
ID_NEW(ca->ob);
}
+ else if(act->type==ACT_OBJECT) {
+ bObjectActuator *oa= act->data;
+ ID_NEW(oa->reference);
+ }
else if(act->type==ACT_SCENE) {
bSceneActuator *sca= act->data;
ID_NEW(sca->camera);
@@ -606,6 +610,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
bMessageSensor *ms;
bActuator *act;
bCameraActuator *ca;
+ bObjectActuator *oa;
bSceneActuator *sa;
bEditObjectActuator *eoa;
bPropertyActuator *pa;
@@ -628,6 +633,10 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
ca= act->data;
if(ca->ob==ob) ca->ob= NULL;
break;
+ case ACT_OBJECT:
+ oa= act->data;
+ if(oa->reference==ob) oa->reference= NULL;
+ break;
case ACT_PROPERTY:
pa= act->data;
if(pa->ob==ob) pa->ob= NULL;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 5c936c3ab39..156bdae9b00 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -245,9 +245,9 @@ Scene *add_scene(char *name)
sce->r.stereomode = 1; // no stereo
sce->r.domeangle = 180;
sce->r.domemode = 1;
- sce->r.domesize = 1.0f;
sce->r.domeres = 4;
sce->r.domeresbuf = 1.0f;
+ sce->r.dometilt = 0;
sce->r.simplify_subsurf= 6;
sce->r.simplify_particles= 1.0f;
@@ -411,16 +411,25 @@ int next_object(Scene *scene, int val, Base **base, Object **ob)
{
static ListBase *duplilist= NULL;
static DupliObject *dupob;
- static int fase;
+ static int fase= F_START, in_next_object= 0;
int run_again=1;
/* init */
if(val==0) {
fase= F_START;
dupob= NULL;
+
+ /* XXX particle systems with metas+dupligroups call this recursively */
+ /* see bug #18725 */
+ if(in_next_object) {
+ printf("ERROR: MetaBall generation called recursively, not supported\n");
+
+ return F_ERROR;
+ }
}
else {
-
+ in_next_object= 1;
+
/* run_again is set when a duplilist has been ended */
while(run_again) {
run_again= 0;
@@ -502,6 +511,9 @@ int next_object(Scene *scene, int val, Base **base, Object **ob)
}
}
+ /* reset recursion test */
+ in_next_object= 0;
+
return fase;
}
@@ -723,4 +735,4 @@ void free_dome_warp_text(struct Text *txt)
scene->r.dometext = NULL;
scene = scene->id.next;
}
-} \ No newline at end of file
+}
diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c
index 121dfce4980..3365af36f8c 100644
--- a/source/blender/blenkernel/intern/sequence.c
+++ b/source/blender/blenkernel/intern/sequence.c
@@ -122,6 +122,14 @@ void new_tstripdata(Sequence *seq)
/* free */
+static void free_proxy_seq(Sequence *seq)
+{
+ if (seq->strip && seq->strip->proxy && seq->strip->proxy->anim) {
+ IMB_free_anim(seq->strip->proxy->anim);
+ seq->strip->proxy->anim = 0;
+ }
+}
+
void seq_free_strip(Strip *strip)
{
strip->us--;
@@ -136,6 +144,10 @@ void seq_free_strip(Strip *strip)
}
if (strip->proxy) {
+ if (strip->proxy->anim) {
+ IMB_free_anim(strip->proxy->anim);
+ }
+
MEM_freeN(strip->proxy);
}
if (strip->crop) {
@@ -598,6 +610,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq)
seq->strip->len = seq->len;
}
+ free_proxy_seq(seq);
+
calc_sequence(seq);
}
@@ -1112,7 +1126,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se
#define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE)
-static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * name)
+static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * name, int render_size)
{
int frameno;
char dir[FILE_MAXDIR];
@@ -1132,12 +1146,20 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na
}
}
+ if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
+ BLI_join_dirfile(name, dir, seq->strip->proxy->file);
+ BLI_convertstringcode(name, G.sce);
+ BLI_convertstringframe(name, cfra);
+
+ return TRUE;
+ }
+
/* generate a seperate proxy directory for each preview size */
if (seq->type == SEQ_IMAGE) {
StripElem * se = give_stripelem(seq, cfra);
snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy",
- dir, scene->r.size, se->name);
+ dir, render_size, se->name);
frameno = 1;
} else if (seq->type == SEQ_MOVIE) {
TStripElem * tse = give_tstripelem(seq, cfra);
@@ -1146,14 +1168,14 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na
snprintf(name, PROXY_MAXFILE, "%s/%s/%d/####", dir,
seq->strip->stripdata->name,
- scene->r.size);
+ render_size);
} else {
TStripElem * tse = give_tstripelem(seq, cfra);
frameno = tse->nr + seq->anim_startofs;
snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir,
- scene->r.size);
+ render_size);
}
BLI_convertstringcode(name, G.sce);
@@ -1165,7 +1187,7 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na
return TRUE;
}
-static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra)
+static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, int render_size)
{
char name[PROXY_MAXFILE];
@@ -1174,11 +1196,28 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra)
}
/* rendering at 100% ? No real sense in proxy-ing, right? */
- if (scene->r.size == 100.0) {
+ if (render_size == 100) {
return 0;
}
- if (!seq_proxy_get_fname(scene, seq, cfra, name)) {
+ if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
+ TStripElem * tse = give_tstripelem(seq, cfra);
+ int frameno = tse->nr + seq->anim_startofs;
+ if (!seq->strip->proxy->anim) {
+ if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) {
+ return 0;
+ }
+
+ seq->strip->proxy->anim = openanim(name, IB_rect);
+ }
+ if (!seq->strip->proxy->anim) {
+ return 0;
+ }
+
+ return IMB_anim_absolute(seq->strip->proxy->anim, frameno);
+ }
+
+ if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) {
return 0;
}
@@ -1190,9 +1229,9 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra)
}
static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra,
- int build_proxy_run);
+ int build_proxy_run, int render_size);
-static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra)
+static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int render_size)
{
char name[PROXY_MAXFILE];
int quality;
@@ -1206,11 +1245,16 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra)
}
/* rendering at 100% ? No real sense in proxy-ing, right? */
- if (scene->r.size == 100.0) {
+ if (render_size == 100) {
return;
}
- if (!seq_proxy_get_fname(scene, seq, cfra, name)) {
+ /* that's why it is called custom... */
+ if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
+ return;
+ }
+
+ if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) {
return;
}
@@ -1224,14 +1268,14 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra)
se->ibuf = 0;
}
- do_build_seq_ibuf(scene, seq, se, cfra, TRUE);
+ do_build_seq_ibuf(scene, seq, se, cfra, TRUE, render_size);
if (!se->ibuf) {
return;
}
- rectx= (scene->r.size*scene->r.xsch)/100;
- recty= (scene->r.size*scene->r.ysch)/100;
+ rectx= (render_size*scene->r.xsch)/100;
+ recty= (render_size*scene->r.ysch)/100;
ibuf = se->ibuf;
@@ -1286,7 +1330,7 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq)
TStripElem * tse = give_tstripelem(seq, cfra);
if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) {
- seq_proxy_build_frame(scene, seq, cfra);
+ seq_proxy_build_frame(scene, seq, cfra, scene->r.size);
tse->flag |= STRIPELEM_PREVIEW_DONE;
}
if (blender_test_break()) {
@@ -1299,7 +1343,7 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq)
TStripElem * tse = give_tstripelem(seq, cfra);
if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) {
- seq_proxy_build_frame(scene, seq, cfra);
+ seq_proxy_build_frame(scene, seq, cfra, scene->r.size);
tse->flag |= STRIPELEM_PREVIEW_DONE;
}
if (blender_test_break()) {
@@ -1752,11 +1796,46 @@ static void free_metastrip_imbufs(ListBase *seqbasep, int cfra, int chanshown)
}
+static void check_limiter_refcount(const char * func, TStripElem *se)
+{
+ if (se && se->ibuf) {
+ int refcount = IMB_cache_limiter_get_refcount(se->ibuf);
+ if (refcount != 1) {
+ /* can happen on complex pipelines */
+ if (refcount > 1 && (G.f & G_DEBUG) == 0) {
+ return;
+ }
+
+ fprintf(stderr,
+ "sequencer: (ibuf) %s: "
+ "suspicious memcache "
+ "limiter refcount: %d\n", func, refcount);
+ }
+ }
+}
+
+static void check_limiter_refcount_comp(const char * func, TStripElem *se)
+{
+ if (se && se->ibuf_comp) {
+ int refcount = IMB_cache_limiter_get_refcount(se->ibuf_comp);
+ if (refcount != 1) {
+ /* can happen on complex pipelines */
+ if (refcount > 1 && (G.f & G_DEBUG) == 0) {
+ return;
+ }
+ fprintf(stderr,
+ "sequencer: (ibuf comp) %s: "
+ "suspicious memcache "
+ "limiter refcount: %d\n", func, refcount);
+ }
+ }
+}
+
static TStripElem* do_build_seq_array_recursively(Scene *scene,
- ListBase *seqbasep, int cfra, int chanshown);
+ ListBase *seqbasep, int cfra, int chanshown, int render_size);
static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra,
- int build_proxy_run)
+ int build_proxy_run, int render_size)
{
char name[FILE_MAXDIR+FILE_MAXFILE];
int use_limiter = TRUE;
@@ -1766,18 +1845,23 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
if(seq->type == SEQ_META) {
TStripElem * meta_se = 0;
+ int use_preprocess = FALSE;
use_limiter = FALSE;
if (!build_proxy_run && se->ibuf == 0) {
- se->ibuf = seq_proxy_fetch(scene, seq, cfra);
+ se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size);
if (se->ibuf) {
use_limiter = TRUE;
+ use_preprocess = TRUE;
}
}
if(!se->ibuf && seq->seqbase.first) {
meta_se = do_build_seq_array_recursively(scene,
- &seq->seqbase, seq->start + se->nr, 0);
+ &seq->seqbase, seq->start + se->nr, 0,
+ render_size);
+
+ check_limiter_refcount("do_build_seq_ibuf: for META", meta_se);
}
se->ok = STRIPELEM_OK;
@@ -1799,21 +1883,24 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
se->ibuf = i;
use_limiter = TRUE;
+ use_preprocess = TRUE;
}
+ } else if (se->ibuf) {
+ use_limiter = TRUE;
}
if (meta_se) {
free_metastrip_imbufs(
&seq->seqbase, seq->start + se->nr, 0);
}
- if (use_limiter) {
+ if (use_preprocess) {
input_preprocess(scene, seq, se, cfra);
}
} else if(seq->type & SEQ_EFFECT) {
/* should the effect be recalculated? */
if (!build_proxy_run && se->ibuf == 0) {
- se->ibuf = seq_proxy_fetch(scene, seq, cfra);
+ se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size);
}
if(se->ibuf == 0) {
@@ -1834,13 +1921,19 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
BLI_convertstringcode(name, G.sce);
BLI_convertstringframe(name, scene->r.cfra);
if (!build_proxy_run) {
- se->ibuf = seq_proxy_fetch(scene, seq, cfra);
+ se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size);
}
copy_from_ibuf_still(seq, se);
if (!se->ibuf) {
se->ibuf= IMB_loadiffname(
name, IB_rect);
+ /* we don't need both (speed reasons)! */
+ if (se->ibuf &&
+ se->ibuf->rect_float && se->ibuf->rect) {
+ imb_freerectImBuf(se->ibuf);
+ }
+
copy_to_ibuf_still(seq, se);
}
@@ -1853,7 +1946,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
} else if(seq->type == SEQ_MOVIE) {
if(se->ok == STRIPELEM_OK && se->ibuf==0) {
if(!build_proxy_run) {
- se->ibuf = seq_proxy_fetch(scene, seq, cfra);
+ se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size);
}
copy_from_ibuf_still(seq, se);
@@ -1871,6 +1964,13 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
if(seq->anim) {
IMB_anim_set_preseek(seq->anim, seq->anim_preseek);
se->ibuf = IMB_anim_absolute(seq->anim, se->nr + seq->anim_startofs);
+ /* we don't need both (speed reasons)! */
+ if (se->ibuf
+ && se->ibuf->rect_float
+ && se->ibuf->rect) {
+ imb_freerectImBuf(se->ibuf);
+ }
+
}
copy_to_ibuf_still(seq, se);
}
@@ -1894,7 +1994,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
int sce_valid =sce&& (sce->camera || sce->r.scemode & R_DOSEQ);
if (se->ibuf == NULL && sce_valid && !build_proxy_run) {
- se->ibuf = seq_proxy_fetch(scene, seq, cfra);
+ se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size);
if (se->ibuf) {
input_preprocess(scene, seq, se, cfra);
}
@@ -1910,7 +2010,10 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
if (!sce_valid) {
se->ok = STRIPELEM_FAILED;
} else if (se->ibuf==NULL && sce_valid) {
- waitcursor(1);
+ /* no need to display a waitcursor on sequencer
+ scene strips */
+ if (!(sce->r.scemode & R_DOSEQ))
+ waitcursor(1);
/* Hack! This function can be called from do_render_seq(), in that case
the seq->scene can already have a Render initialized with same name,
@@ -1960,6 +2063,13 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
/* restore */
scene->r.scemode |= doseq;
+
+ // XXX
+#if 0
+ if((G.f & G_PLAYANIM)==0 /* bad, is set on do_render_seq */
+ && !(sce->r.scemode & R_DOSEQ))
+ waitcursor(0);
+#endif
CFRA = oldcfra;
set_last_seq(oldseq);
@@ -1986,9 +2096,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
}
}
-static TStripElem* do_build_seq_recursively(Scene *scene, Sequence *seq, int cfra);
+static TStripElem* do_build_seq_recursively(Scene *scene, Sequence *seq, int cfra, int render_size);
-static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *se, int cfra)
+static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *se, int cfra, int render_size)
{
float fac, facf;
struct SeqEffectHandle sh = get_sequence_effect(seq);
@@ -2017,22 +2127,22 @@ static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *s
/* no input needed */
break;
case 0:
- se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra);
- se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra);
+ se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra, render_size);
+ se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra, render_size);
if (seq->seq3) {
- se->se3 = do_build_seq_recursively(scene, seq->seq3, cfra);
+ se->se3 = do_build_seq_recursively(scene, seq->seq3, cfra, render_size);
}
break;
case 1:
- se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra);
+ se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra, render_size);
break;
case 2:
- se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra);
+ se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra, render_size);
break;
}
- do_build_seq_ibuf(scene, seq, se, cfra, FALSE);
+ do_build_seq_ibuf(scene, seq, se, cfra, FALSE, render_size);
/* children are not needed anymore ... */
@@ -2045,9 +2155,10 @@ static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *s
if (se->se3 && se->se3->ibuf) {
IMB_cache_limiter_unref(se->se3->ibuf);
}
+ check_limiter_refcount("do_effect_seq_recursively", se);
}
-static TStripElem* do_build_seq_recursively_impl(Scene *scene, Sequence * seq, int cfra)
+static TStripElem* do_build_seq_recursively_impl(Scene *scene, Sequence * seq, int cfra, int render_size)
{
TStripElem *se;
@@ -2055,9 +2166,9 @@ static TStripElem* do_build_seq_recursively_impl(Scene *scene, Sequence * seq, i
if(se) {
if (seq->type & SEQ_EFFECT) {
- do_effect_seq_recursively(scene, seq, se, cfra);
+ do_effect_seq_recursively(scene, seq, se, cfra, render_size);
} else {
- do_build_seq_ibuf(scene, seq, se, cfra, FALSE);
+ do_build_seq_ibuf(scene, seq, se, cfra, FALSE, render_size);
}
}
return se;
@@ -2071,7 +2182,7 @@ instead of faking using the blend code below...
*/
-static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra)
+static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra, int render_size)
{
SpeedControlVars * s = (SpeedControlVars *)seq->effectdata;
int nr = cfra - seq->start;
@@ -2100,7 +2211,7 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra
test_and_auto_discard_ibuf(se);
if (se->ibuf == NULL) {
- se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left);
+ se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left, render_size);
if((se1 && se1->ibuf && se1->ibuf->rect_float))
se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0);
@@ -2132,8 +2243,8 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra
}
if (se->ibuf == NULL) {
- se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left);
- se2 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_right);
+ se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left, render_size);
+ se2 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_right, render_size);
if((se1 && se1->ibuf && se1->ibuf->rect_float))
se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0);
@@ -2168,6 +2279,8 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra
if (se2 && se2->ibuf)
IMB_cache_limiter_unref(se2->ibuf);
+ check_limiter_refcount("do_handle_speed_effect", se);
+
return se;
}
@@ -2183,25 +2296,22 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra
*
*/
-static TStripElem* do_build_seq_recursively(Scene *scene, Sequence * seq, int cfra)
+static TStripElem* do_build_seq_recursively(Scene *scene, Sequence * seq, int cfra, int render_size)
{
+ TStripElem *se;
if (seq->type == SEQ_SPEED) {
- return do_handle_speed_effect(scene, seq, cfra);
+ se = do_handle_speed_effect(scene, seq, cfra, render_size);
} else {
- return do_build_seq_recursively_impl(scene, seq, cfra);
+ se = do_build_seq_recursively_impl(scene, seq, cfra, render_size);
}
-}
-/* Bug: 18209
- * when dragging the mouse over a metastrip, on mouse-up for some unknown
- * reason in some cases the metastrips TStripElem->ibuf->rect is NULL,
- * This should be fixed but I had a look and couldnt work out why its
- * happening so for now workaround with a NULL check - campbell */
+ check_limiter_refcount("do_build_seq_recursively", se);
-#define SEQ_SPECIAL_SEQ_UPDATE_WORKAROUND
+ return se;
+}
static TStripElem* do_build_seq_array_recursively(Scene *scene,
- ListBase *seqbasep, int cfra, int chanshown)
+ ListBase *seqbasep, int cfra, int chanshown, int render_size)
{
Sequence* seq_arr[MAXSEQ+1];
int count;
@@ -2231,7 +2341,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
if(count == 1) {
- se = do_build_seq_recursively(scene, seq_arr[0], cfra);
+ se = do_build_seq_recursively(scene, seq_arr[0], cfra, render_size);
if (se->ibuf) {
se->ibuf_comp = se->ibuf;
IMB_refImBuf(se->ibuf_comp);
@@ -2253,7 +2363,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
break;
}
if (seq->blend_mode == SEQ_BLEND_REPLACE) {
- do_build_seq_recursively(scene, seq, cfra);
+ do_build_seq_recursively(scene, seq, cfra, render_size);
if (se->ibuf) {
se->ibuf_comp = se->ibuf;
IMB_refImBuf(se->ibuf);
@@ -2261,6 +2371,9 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
se->ibuf_comp = IMB_allocImBuf(
(short)seqrectx, (short)seqrecty,
32, IB_rect, 0);
+ IMB_cache_limiter_insert(se->ibuf_comp);
+ IMB_cache_limiter_ref(se->ibuf_comp);
+ IMB_cache_limiter_touch(se->ibuf_comp);
}
break;
}
@@ -2285,7 +2398,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
switch (early_out) {
case -1:
case 2:
- do_build_seq_recursively(scene, seq, cfra);
+ do_build_seq_recursively(scene, seq, cfra, render_size);
if (se->ibuf) {
se->ibuf_comp = se->ibuf;
IMB_refImBuf(se->ibuf_comp);
@@ -2293,6 +2406,9 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
se->ibuf_comp = IMB_allocImBuf(
(short)seqrectx, (short)seqrecty,
32, IB_rect, 0);
+ IMB_cache_limiter_insert(se->ibuf_comp);
+ IMB_cache_limiter_ref(se->ibuf_comp);
+ IMB_cache_limiter_touch(se->ibuf_comp);
}
break;
case 1:
@@ -2306,11 +2422,14 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
}
break;
case 0:
- do_build_seq_recursively(scene, seq, cfra);
+ do_build_seq_recursively(scene, seq, cfra, render_size);
if (!se->ibuf) {
se->ibuf = IMB_allocImBuf(
(short)seqrectx, (short)seqrecty,
32, IB_rect, 0);
+ IMB_cache_limiter_insert(se->ibuf);
+ IMB_cache_limiter_ref(se->ibuf);
+ IMB_cache_limiter_touch(se->ibuf);
}
if (i == 0) {
se->ibuf_comp = se->ibuf;
@@ -2369,13 +2488,6 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
IMB_rect_from_float(se2->ibuf);
}
-#ifdef SEQ_SPECIAL_SEQ_UPDATE_WORKAROUND
- if (se2->ibuf->rect==NULL && se2->ibuf->rect_float==NULL) {
- printf("ERROR: sequencer se2->ibuf missing buffer\n");
- } else if (se1->ibuf && se1->ibuf->rect==NULL && se1->ibuf->rect_float==NULL) {
- printf("ERROR: sequencer se1->ibuf missing buffer\n");
- } else {
-#endif
/* bad hack, to fix crazy input ordering of
those two effects */
@@ -2397,10 +2509,6 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
se2->ibuf_comp);
}
-#ifdef SEQ_SPECIAL_SEQ_UPDATE_WORKAROUND
- }
-#endif
-
IMB_cache_limiter_insert(se2->ibuf_comp);
IMB_cache_limiter_ref(se2->ibuf_comp);
IMB_cache_limiter_touch(se2->ibuf_comp);
@@ -2428,7 +2536,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene,
* you have to unref after usage!
*/
-static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, int chanshown)
+static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size)
{
Editing *ed= seq_give_editing(scene, FALSE);
int count;
@@ -2449,28 +2557,32 @@ static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, i
seqrectx= rectx; /* bad bad global! */
seqrecty= recty;
- se = do_build_seq_array_recursively(scene, seqbasep, cfra, chanshown);
+ se = do_build_seq_array_recursively(scene, seqbasep, cfra, chanshown, render_size);
if(!se) {
return 0;
}
+ check_limiter_refcount_comp("give_ibuf_seq_impl", se);
+
return se->ibuf_comp;
}
-ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, Sequence *seq)
+ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, int render_size, Sequence *seq)
{
TStripElem* se;
seqrectx= rectx; /* bad bad global! */
seqrecty= recty;
- se = do_build_seq_recursively(scene, seq, cfra);
+ se = do_build_seq_recursively(scene, seq, cfra, render_size);
if(!se) {
return 0;
}
+ check_limiter_refcount("give_ibuf_seq_direct", se);
+
if (se->ibuf) {
IMB_cache_limiter_unref(se->ibuf);
}
@@ -2478,9 +2590,9 @@ ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, Sequen
return se->ibuf;
}
-ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown)
+ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size)
{
- ImBuf* i = give_ibuf_seq_impl(scene, rectx, recty, cfra, chanshown);
+ ImBuf* i = give_ibuf_seq_impl(scene, rectx, recty, cfra, chanshown, render_size);
if (i) {
IMB_cache_limiter_unref(i);
@@ -2535,6 +2647,7 @@ typedef struct PrefetchQueueElem {
int recty;
int cfra;
int chanshown;
+ int render_size;
int monoton_cfra;
@@ -2580,7 +2693,8 @@ static void *seq_prefetch_thread(void * This_)
if (e->cfra >= s_last) {
e->ibuf = give_ibuf_seq_impl(This->scene,
- e->rectx, e->recty, e->cfra, e->chanshown);
+ e->rectx, e->recty, e->cfra, e->chanshown,
+ e->render_size);
}
pthread_mutex_lock(&queue_lock);
@@ -2689,7 +2803,8 @@ void seq_stop_threads()
BLI_end_threads(0);
}
-void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown)
+void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown,
+ int render_size)
{
PrefetchQueueElem *e;
if (seq_thread_shutdown) {
@@ -2701,6 +2816,7 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown)
e->recty = recty;
e->cfra = cfra;
e->chanshown = chanshown;
+ e->render_size = render_size;
e->monoton_cfra = monoton_cfra++;
pthread_mutex_lock(&queue_lock);
@@ -2741,13 +2857,13 @@ void seq_wait_for_prefetch_ready()
fprintf(stderr, "SEQ-THREAD: prefetch done\n");
}
-ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int chanshown)
+ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size)
{
PrefetchQueueElem *e = NULL;
int found_something = FALSE;
if (seq_thread_shutdown) {
- return give_ibuf_seq(scene, rectx, recty, cfra, chanshown);
+ return give_ibuf_seq(scene, rectx, recty, cfra, chanshown, render_size);
}
while (!e) {
@@ -2758,7 +2874,8 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int
if (cfra == e->cfra &&
chanshown == e->chanshown &&
rectx == e->rectx &&
- recty == e->recty) {
+ recty == e->recty &&
+ render_size == e->render_size) {
success = TRUE;
found_something = TRUE;
break;
@@ -2770,7 +2887,8 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int
if (cfra == e->cfra &&
chanshown == e->chanshown &&
rectx == e->rectx &&
- recty == e->recty) {
+ recty == e->recty &&
+ render_size == e->render_size) {
found_something = TRUE;
break;
}
@@ -2786,7 +2904,8 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int
cfra == tslot->current->cfra &&
chanshown == tslot->current->chanshown &&
rectx == tslot->current->rectx &&
- recty == tslot->current->recty) {
+ recty == tslot->current->recty &&
+ render_size== tslot->current->render_size){
found_something = TRUE;
break;
}
@@ -2887,6 +3006,7 @@ void free_imbuf_seq_except(Scene *scene, int cfra)
if(seq->type==SEQ_MOVIE)
if(seq->startdisp > cfra || seq->enddisp < cfra)
free_anim_seq(seq);
+ free_proxy_seq(seq);
}
}
SEQ_END
@@ -3010,6 +3130,7 @@ void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo)
if(seq->type == SEQ_SPEED) {
sequence_effect_speed_rebuild_map(seq, 1);
}
+ free_proxy_seq(seq);
}
}
SEQ_END
@@ -3021,7 +3142,7 @@ void do_render_seq(RenderResult *rr, int cfra)
{
ImBuf *ibuf;
- ibuf= give_ibuf_seq(scene, rr->rectx, rr->recty, cfra, 0);
+ ibuf= give_ibuf_seq(scene, rr->rectx, rr->recty, cfra, 0, scene->r.size);
if(ibuf) {
if(ibuf->rect_float) {
@@ -3076,6 +3197,7 @@ void do_render_seq(RenderResult *rr, int cfra)
"user preferences.\n");
free_imbuf_seq();
}
+ free_proxy_seq(seq);
}
}
else {
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 8bf56f136bc..27357d92aae 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -547,7 +547,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object
calc.vgroup = get_named_vertexgroup_num(calc.ob, smd->vgroup_name);
- if(dm != NULL)
+ if(dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT)
{
//Setup arrays to get vertexs positions, normals and deform weights
calc.vert = dm->getVertDataArray(dm, CD_MVERT);
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index d7accd54fb9..bc6b487080c 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -3075,8 +3075,8 @@ static void apply_spring_memory(Object *ob)
int a;
float b,l,r;
- b = sb->plastic;
if (sb && sb->totspring){
+ b = sb->plastic;
for(a=0; a<sb->totspring; a++) {
bs = &sb->bspring[a];
bp1 =&sb->bpoint[bs->v1];
@@ -3546,9 +3546,9 @@ static void springs_from_particles(Object *ob)
int a,k;
float hairmat[4][4];
- psys= ob->soft->particles;
- sb= ob->soft;
- if(ob && sb && psys) {
+ if(ob && ob->soft && ob->soft->particles) {
+ psys= ob->soft->particles;
+ sb= ob->soft;
psmd = psys_get_modifier(ob, psys);
bp= sb->bpoint;
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 8bad269a85e..7fe129ed6fc 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -110,6 +110,10 @@ World *add_world(char *name)
wrld->mode = WO_DBVT_CULLING; // DBVT culling by default
wrld->occlusionRes = 128;
wrld->preview = NULL;
+ wrld->ticrate = 60;
+ wrld->maxlogicstep = 5;
+ wrld->physubstep = 1;
+ wrld->maxphystep = 5;
return wrld;
}
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 472a6612a50..0277da5f908 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -242,6 +242,9 @@ static void write_video_frame(RenderData *rd, AVFrame* frame)
#ifdef FFMPEG_CODEC_TIME_BASE
frame->pts = rd->cfra - rd->sfra;
#endif
+ if (G.scene->r.mode & R_FIELDS) {
+ frame->top_field_first = ((G.scene->r.mode & R_ODDFIELD) != 0);
+ }
outsize = avcodec_encode_video(c, video_buffer, video_buffersize,
frame);
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index ce9dd44601b..4e5bf650196 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -96,6 +96,7 @@ int BLI_strcaseeq(const char *a, const char *b);
char *BLI_strcasestr(const char *s, const char *find);
int BLI_strcasecmp(const char *s1, const char *s2);
int BLI_strncasecmp(const char *s1, const char *s2, int n);
+int BLI_natstrcmp(const char *s1, const char *s2);
void BLI_timestr(double _time, char *str); /* time var is global */
diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h
index 8838b1992e4..bd89959801a 100644
--- a/source/blender/blenlib/BLI_vfontdata.h
+++ b/source/blender/blenlib/BLI_vfontdata.h
@@ -54,7 +54,7 @@ typedef struct VFontData {
typedef struct VChar {
struct VChar *next, *prev;
ListBase nurbsbase;
- unsigned long index;
+ intptr_t index;
float resol;
float width;
float *points;
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 9204ab18bfa..688a4ab901b 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -154,7 +154,7 @@ int BLI_compare(struct direntry *entry1, struct direntry *entry2)
if( strcmp(entry1->relname, "..")==0 ) return (-1);
if( strcmp(entry2->relname, "..")==0 ) return (1);
- return (BLI_strcasecmp(entry1->relname,entry2->relname));
+ return (BLI_natstrcmp(entry1->relname,entry2->relname));
}
@@ -330,7 +330,7 @@ void BLI_builddir(char *dirname, char *relname)
void BLI_adddirstrings()
{
char datum[100];
- char buf[250];
+ char buf[512];
char size[250];
static char * types[8] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"};
int num, mode;
@@ -427,9 +427,6 @@ void BLI_adddirstrings()
sprintf(size, "%10d", (int) st_size);
}
- sprintf(buf,"%s %s %10s %s", files[num].date, files[num].time, size,
- files[num].relname);
-
sprintf(buf,"%s %s %s %7s %s %s %10s %s", file->mode1, file->mode2, file->mode3, files[num].owner, files[num].date, files[num].time, size,
files[num].relname);
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 843f6b62735..fa4bcbc26bc 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -170,6 +170,54 @@ int BLI_strncasecmp(const char *s1, const char *s2, int n) {
return 0;
}
+/* natural string compare, keeping numbers in order */
+int BLI_natstrcmp(const char *s1, const char *s2)
+{
+ int d1= 0, d2= 0;
+
+ /* if both chars are numeric, to a strtol().
+ then increase string deltas as long they are
+ numeric, else do a tolower and char compare */
+
+ while(1) {
+ char c1 = tolower(s1[d1]);
+ char c2 = tolower(s2[d2]);
+
+ if( isdigit(c1) && isdigit(c2) ) {
+ int val1, val2;
+
+ val1= (int)strtol(s1+d1, (char **)NULL, 10);
+ val2= (int)strtol(s2+d2, (char **)NULL, 10);
+
+ if (val1<val2) {
+ return -1;
+ } else if (val1>val2) {
+ return 1;
+ }
+ d1++;
+ while( isdigit(s1[d1]) )
+ d1++;
+ d2++;
+ while( isdigit(s2[d2]) )
+ d2++;
+
+ c1 = tolower(s1[d1]);
+ c2 = tolower(s2[d2]);
+ }
+
+ if (c1<c2) {
+ return -1;
+ } else if (c1>c2) {
+ return 1;
+ } else if (c1==0) {
+ break;
+ }
+ d1++;
+ d2++;
+ }
+ return 0;
+}
+
void BLI_timestr(double _time, char *str)
{
/* format 00:00:00.00 (hr:min:sec) string has to be 12 long */
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index 137a32c4689..df4ad4e7c75 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -1472,9 +1472,6 @@ char* BLI_getbundle(void) {
}
#endif
-
-
-
#ifdef WITH_ICONV
#include "iconv.h"
#include "localcharset.h"
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index cf26527e3f0..ce3a35c7194 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -156,6 +156,8 @@
#include "readfile.h"
+#include "PIL_time.h"
+
#include <errno.h>
/*
@@ -611,10 +613,16 @@ static BHeadN *get_bhead(FileData *fd)
BHead bhead;
BHeadN *new_bhead = 0;
int readsize;
-
+
if (fd) {
if ( ! fd->eof) {
+ /* not strictly needed but shuts valgrind up
+ * since uninitialized memory gets compared */
+ memset(&bhead8, 0, sizeof(BHead8));
+ memset(&bhead4, 0, sizeof(BHead4));
+ memset(&bhead, 0, sizeof(BHead));
+
// First read the bhead structure.
// Depending on the platform the file was written on this can
// be a big or little endian BHead4 or BHead8 structure.
@@ -1489,6 +1497,8 @@ static void lib_link_brush(FileData *fd, Main *main)
if(brush->id.flag & LIB_NEEDLINK) {
brush->id.flag -= LIB_NEEDLINK;
+ brush->clone.image= newlibadr_us(fd, brush->id.lib, brush->clone.image);
+
for(a=0; a<MAX_MTEX; a++) {
mtex= brush->mtex[a];
if(mtex)
@@ -3146,6 +3156,18 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
lvl->colfaces= newdataadr(fd, lvl->colfaces);
}
}
+
+ /* Gracefully handle corrupted mesh */
+ if(mesh->mr && !mesh->mr->verts) {
+ /* If totals match, simply load the current mesh verts into multires */
+ if(mesh->totvert == ((MultiresLevel*)mesh->mr->levels.last)->totvert)
+ mesh->mr->verts = MEM_dupallocN(mesh->mvert);
+ else {
+ /* Otherwise, we can't recover the data, silently remove multires */
+ multires_free(mesh->mr);
+ mesh->mr = NULL;
+ }
+ }
if((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) {
TFace *tf= mesh->tface;
@@ -3337,6 +3359,10 @@ static void lib_link_object(FileData *fd, Main *main)
bAddObjectActuator *eoa= act->data;
if(eoa) eoa->ob= newlibadr(fd, ob->id.lib, eoa->ob);
}
+ else if(act->type==ACT_OBJECT) {
+ bObjectActuator *oa= act->data;
+ oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
+ }
else if(act->type==ACT_EDIT_OBJECT) {
bEditObjectActuator *eoa= act->data;
if(eoa==NULL) {
@@ -3347,6 +3373,15 @@ static void lib_link_object(FileData *fd, Main *main)
eoa->me= newlibadr(fd, ob->id.lib, eoa->me);
}
}
+ else if(act->type==ACT_OBJECT) {
+ bObjectActuator *oa= act->data;
+ if(oa==NULL) {
+ init_actuator(act);
+ }
+ else {
+ oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
+ }
+ }
else if(act->type==ACT_SCENE) {
bSceneActuator *sa= act->data;
sa->camera= newlibadr(fd, ob->id.lib, sa->camera);
@@ -3451,6 +3486,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->emCache = smd->mCache = 0;
}
+ else if (md->type==eModifierType_Armature) {
+ ArmatureModifierData *amd = (ArmatureModifierData*) md;
+
+ amd->prevCos= NULL;
+ }
else if (md->type==eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData*) md;
@@ -3957,6 +3997,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
if (seq->flag & SEQ_USE_PROXY) {
seq->strip->proxy = newdataadr(
fd, seq->strip->proxy);
+ seq->strip->proxy->anim = 0;
} else {
seq->strip->proxy = 0;
}
@@ -4389,6 +4430,22 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
if((v3d->layact & v3d->lay)==0) v3d->layact= v3d->lay;
}
+ else if(sl->spacetype==SPACE_IPO) {
+ /* XXX animato */
+#if 0
+ SpaceIpo *sipo= (SpaceIpo *)sl;
+
+ sipo->ipo= restore_pointer_by_name(newmain, (ID *)sipo->ipo, 0);
+ if(sipo->blocktype==ID_SEQ)
+ sipo->from= (ID *)find_sequence_from_ipo_helper(newmain, sipo->ipo);
+ else
+ sipo->from= restore_pointer_by_name(newmain, (ID *)sipo->from, 0);
+
+ // not free sipo->ipokey, creates dependency with src/
+ if(sipo->editipo) MEM_freeN(sipo->editipo);
+ sipo->editipo= NULL;
+#endif
+ }
else if(sl->spacetype==SPACE_BUTS) {
SpaceButs *sbuts= (SpaceButs *)sl;
sbuts->lockpoin= NULL;
@@ -8852,7 +8909,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* Adjustments needed after Bullets update */
for(ob = main->object.first; ob; ob= ob->id.next) {
ob->damping *= 0.635f;
- ob->rdamping = 0.1 + (0.59f * ob->rdamping);
+ ob->rdamping = 0.1 + (0.8f * ob->rdamping);
}
}
@@ -8864,9 +8921,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
for (sce= main->scene.first; sce; sce= sce->id.next) {
sce->r.domeangle = 180;
sce->r.domemode = 1;
- sce->r.domesize = 1.0f;
sce->r.domeres = 4;
sce->r.domeresbuf = 1.0f;
+ sce->r.dometilt = 0;
}
/* DBVT culling by default */
for(wrld=main->world.first; wrld; wrld= wrld->id.next) {
@@ -8875,6 +8932,49 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) {
+ Object *ob;
+ World *wrld;
+ for(ob = main->object.first; ob; ob= ob->id.next) {
+ ob->m_contactProcessingThreshold = 1.; //pad3 is used for m_contactProcessingThreshold
+ if(ob->parent) {
+ /* check if top parent has compound shape set and if yes, set this object
+ to compound shaper as well (was the behaviour before, now it's optional) */
+ Object *parent= newlibadr(fd, lib, ob->parent);
+ while (parent && parent->parent != NULL) {
+ parent = newlibadr(fd, lib, parent->parent);
+ }
+ if(parent) {
+ if (parent->gameflag & OB_CHILD)
+ ob->gameflag |= OB_CHILD;
+ }
+ }
+ }
+ for(wrld=main->world.first; wrld; wrld= wrld->id.next) {
+ wrld->ticrate = 60;
+ wrld->maxlogicstep = 5;
+ wrld->physubstep = 1;
+ wrld->maxphystep = 5;
+ }
+ }
+
+ if (main->versionfile < 249) {
+ Scene *sce;
+ for (sce= main->scene.first; sce; sce= sce->id.next)
+ sce->r.renderer= 0;
+
+ }
+
+ // correct introduce of seed for wind force
+ if (main->versionfile < 249 && main->subversionfile < 1) {
+ Object *ob;
+ for(ob = main->object.first; ob; ob= ob->id.next) {
+ if(ob->pd)
+ ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128;
+ }
+
+ }
+
if (main->versionfile < 250) {
bScreen *screen;
Scene *scene;
@@ -9021,6 +9121,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
+
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
@@ -9848,6 +9949,10 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
expand_doit(fd, mainvar, eoa->me);
}
}
+ else if(act->type==ACT_OBJECT) {
+ bObjectActuator *oa= act->data;
+ expand_doit(fd, mainvar, oa->reference);
+ }
else if(act->type==ACT_SCENE) {
bSceneActuator *sa= act->data;
expand_doit(fd, mainvar, sa->camera);
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index c2a1199f6c6..aecf437a30b 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -33,6 +33,7 @@
*/
+#include <math.h>
#include <stdio.h>
#include "MEM_guardedalloc.h"
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 1c113c25720..9c9be51f010 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -734,6 +734,7 @@ int join_armature(Scene *scene, View3D *v3d)
VecSubf(delta, curbone->tail, curbone->head);
vec_roll_to_mat3(delta, curbone->roll, temp);
+ Mat4One(premat); /* Mat4MulMat34 only sets 3x3 part */
Mat4MulMat34(premat, temp, mat);
Mat4MulVecfl(mat, curbone->head);
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 45605ad472d..f010abdb7e7 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -2273,6 +2273,7 @@ void sk_applyCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
pt.type = PT_EXACT;
pt.mode = PT_PROJECT; /* take mode from neighbouring points */
VECCOPY(pt.p, isect->p);
+ VECCOPY(pt.no, isect->stroke->points[isect->before].no);
sk_insertStrokePoint(isect->stroke, &pt, isect->after);
}
@@ -2314,6 +2315,7 @@ void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
pt.type = PT_EXACT;
pt.mode = PT_PROJECT; /* take mode from neighbouring points */
VECCOPY(pt.p, isect->p);
+ VECCOPY(pt.no, isect->stroke->points[isect->before].no);
VecSubf(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p);
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 3d8d446c579..0d7bb3c63cc 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -1688,18 +1688,25 @@ void pose_clear_user_transforms(Scene *scene, Object *ob)
if (ob->pose == NULL)
return;
- /* find selected bones */
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- if (pchan->bone && (pchan->bone->flag & BONE_SELECTED) && (pchan->bone->layer & arm->layer)) {
- /* just clear the BONE_UNKEYED flag, allowing this bone to get overwritten by actions again */
- pchan->bone->flag &= ~BONE_UNKEYED;
+ /* if the object has an action, restore pose to the pose defined by the action by clearing pose on selected bones */
+ if (ob->action) {
+ /* find selected bones */
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (pchan->bone && (pchan->bone->flag & BONE_SELECTED) && (pchan->bone->layer & arm->layer)) {
+ /* just clear the BONE_UNKEYED flag, allowing this bone to get overwritten by actions again */
+ pchan->bone->flag &= ~BONE_UNKEYED;
+ }
}
+
+ /* clear pose locking flag
+ * - this will only clear the user-defined pose in the selected bones, where BONE_UNKEYED has been cleared
+ */
+ ob->pose->flag |= POSE_DO_UNLOCK;
+ }
+ else {
+ /* no action, so restore entire pose to rest pose (cannot restore only selected bones) */
+ rest_pose(ob->pose);
}
-
- /* clear pose locking flag
- * - this will only clear the user-defined pose in the selected bones, where BONE_UNKEYED has been cleared
- */
- ob->pose->flag |= POSE_DO_UNLOCK;
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
BIF_undo_push("Clear User Transform");
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index 7e6c84764ae..ea794b2c7c1 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -2702,7 +2702,7 @@ static float cotan_weight(float *v1, float *v2, float *v3)
return Inpf(a, b)/clen;
}
-void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, long e1, long e2, long e3)
+void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2, int e3)
{
/* Angle opposite e1 */
float t1= cotan_weight(v1->co, v2->co, v3->co) / e2;
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index ec4e79a7e5a..1b2c8ea6b11 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -226,7 +226,7 @@ void update_string(Curve *cu)
wcs2utf8s(cu->str, ef->textbuf);
}
-static int insert_into_textbuf(Object *obedit, unsigned long c)
+static int insert_into_textbuf(Object *obedit, uintptr_t c)
{
Curve *cu= obedit->data;
@@ -1290,7 +1290,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
Curve *cu= obedit->data;
EditFont *ef= cu->editfont;
static int accentcode= 0;
- unsigned long ascii = evt->ascii;
+ uintptr_t ascii = evt->ascii;
int alt= evt->alt, shift= evt->shift, ctrl= evt->ctrl;
int event= evt->type, val= evt->val;
wchar_t inserted_text[2]= {0};
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index e5868338f75..735f1ffddb9 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -131,12 +131,14 @@ void gp_ui_delstroke_cb (void *gpd, void *gpl)
{
bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0);
- if (gpf->framenum != CFRA) return;
+ if (gpf) {
+ if (gpf->framenum != CFRA) return;
- gpencil_layer_setactive(gpd, gpl);
- gpencil_frame_delete_laststroke(gpl, gpf);
-
- scrarea_queue_winredraw(curarea);
+ gpencil_layer_setactive(gpd, gpl);
+ gpencil_frame_delete_laststroke(gpl, gpf);
+
+ scrarea_queue_winredraw(curarea);
+ }
}
/* delete active frame of active layer */
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index aa4372d164f..e112ca704bb 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -609,7 +609,7 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch
WM_operator_properties_create(&ptr, opname);
/*RNA_enum_set(&ptr, propname, value);*/
- if(prop= RNA_struct_find_property(&ptr, propname)) {
+ if((prop= RNA_struct_find_property(&ptr, propname))) {
RNA_property_enum_items(&ptr, prop, &item, &totitem);
if(RNA_enum_value_from_id(item, value_str, &value)==0) {
printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
diff --git a/source/blender/editors/mesh/editdeform.c b/source/blender/editors/mesh/editdeform.c
index 3019aabf371..3ccd4d56ece 100644
--- a/source/blender/editors/mesh/editdeform.c
+++ b/source/blender/editors/mesh/editdeform.c
@@ -223,11 +223,10 @@ void duplicate_defgroup ( Object *ob )
bDeformGroup *dg, *cdg;
char name[32], s[32];
MDeformWeight *org, *cpy;
- MDeformVert *dvert;
- Mesh *me;
- int i, idg, icdg;
+ MDeformVert *dvert, *dvert_array;
+ int i, idg, icdg, dvert_tot;
- if (ob->type != OB_MESH)
+ if (ob->type != OB_MESH && ob->type != OB_LATTICE)
return;
dg = BLI_findlink (&ob->defbase, (ob->actdef-1));
@@ -258,16 +257,28 @@ void duplicate_defgroup ( Object *ob )
ob->actdef = BLI_countlist (&ob->defbase);
icdg = (ob->actdef-1);
- me = get_mesh (ob);
- if (!me->dvert)
+ if(ob->type == OB_MESH) {
+ Mesh *me = get_mesh (ob);
+ dvert_array= me->dvert;
+ dvert_tot= me->totvert;
+ }
+ else if (ob->type == OB_LATTICE) {
+ Lattice *lt= (Lattice *)ob->data;
+ dvert_array= lt->dvert;
+ dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
+ }
+
+ if (!dvert_array)
return;
- for (i = 0; i < me->totvert; i++) {
- dvert = me->dvert+i;
+ for (i = 0; i < dvert_tot; i++) {
+ dvert = dvert_array+i;
org = get_defweight (dvert, idg);
if (org) {
+ float weight = org->weight;
+ /* verify_defweight re-allocs org so need to store the weight first */
cpy = verify_defweight (dvert, icdg);
- cpy->weight = org->weight;
+ cpy->weight = weight;
}
}
}
@@ -335,29 +346,39 @@ static void del_defgroup_update_users(Object *ob, int id)
void del_defgroup_in_object_mode ( Object *ob )
{
bDeformGroup *dg;
- MDeformVert *dvert;
- Mesh *me;
- int i, e;
+ MDeformVert *dvert_array, *dvert;
+
+ int i, e, dvert_tot;
- if ((!ob) || (ob->type != OB_MESH))
+ if ((!ob) || (ob->type != OB_MESH && ob->type != OB_LATTICE))
return;
+ if(ob->type == OB_MESH) {
+ Mesh *me = get_mesh (ob);
+ dvert_array= me->dvert;
+ dvert_tot= me->totvert;
+ }
+ else if (ob->type == OB_LATTICE) {
+ Lattice *lt= (Lattice *)ob->data;
+ dvert_array= lt->dvert;
+ dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
+ }
+
dg = BLI_findlink (&ob->defbase, (ob->actdef-1));
if (!dg)
return;
-
- me = get_mesh (ob);
- if (me->dvert) {
- for (i = 0; i < me->totvert; i++) {
- dvert = me->dvert + i;
+
+ if (dvert_array) {
+ for (i = 0; i < dvert_tot; i++) {
+ dvert = dvert_array + i;
if (dvert) {
if (get_defweight (dvert, (ob->actdef-1)))
remove_vert_defgroup (ob, dg, i);
}
}
- for (i = 0; i < me->totvert; i++) {
- dvert = me->dvert+i;
+ for (i = 0; i < dvert_tot; i++) {
+ dvert = dvert_array+i;
if (dvert) {
for (e = 0; e < dvert->totweight; e++) {
if (dvert->dw[e].def_nr > (ob->actdef-1))
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index d835fdb8eed..f8f0030b258 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -615,9 +615,9 @@ static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, f
float fx, fy, fz;
int vx, vy, vz;
- if (isnan(co[0]) || !finite(co[0]) ||
- isnan(co[1]) || !finite(co[1]) ||
- isnan(co[2]) || !finite(co[2])
+ if (!finite(co[0]) ||
+ !finite(co[1]) ||
+ !finite(co[2])
) {
return;
}
@@ -834,9 +834,9 @@ EditVert *editmesh_get_x_mirror_vert(Object *ob, EditMesh *em, float *co)
intptr_t poinval;
/* ignore nan verts */
- if (isnan(co[0]) || !finite(co[0]) ||
- isnan(co[1]) || !finite(co[1]) ||
- isnan(co[2]) || !finite(co[2])
+ if (!finite(co[0]) ||
+ !finite(co[1]) ||
+ !finite(co[2])
)
return NULL;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 97835fba5af..4cf98f2c904 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -281,12 +281,12 @@ static Object *object_add_type(bContext *C, int type)
ob= add_object(scene, type);
/* editor level activate, notifiers */
ED_base_object_activate(C, BASACT);
-
+
/* more editor stuff */
ED_object_base_init_from_view(C, BASACT);
-
+
DAG_scene_sort(scene);
-
+
return ob;
}
diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c
index f60d5493058..0947f540fc6 100644
--- a/source/blender/editors/physics/editparticle.c
+++ b/source/blender/editors/physics/editparticle.c
@@ -2455,13 +2455,16 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
new_pars= MEM_callocN(newtotpart*sizeof(ParticleData), "ParticleData new");
new_keys= MEM_callocN(newtotpart*sizeof(ParticleEditKey*), "ParticleEditKey new");
- memcpy(new_pars, psys->particles, totpart*sizeof(ParticleData));
- memcpy(new_keys, edit->keys, totpart*sizeof(ParticleEditKey*));
-
- if(psys->particles) MEM_freeN(psys->particles);
+ if(psys->particles) {
+ memcpy(new_pars, psys->particles, totpart*sizeof(ParticleData));
+ MEM_freeN(psys->particles);
+ }
psys->particles= new_pars;
- if(edit->keys) MEM_freeN(edit->keys);
+ if(edit->keys) {
+ memcpy(new_keys, edit->keys, totpart*sizeof(ParticleEditKey*));
+ MEM_freeN(edit->keys);
+ }
edit->keys= new_keys;
if(edit->mirror_cache) {
diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c
index b0d093dc10b..3ed4fa6bd0f 100644
--- a/source/blender/editors/preview/previewrender.c
+++ b/source/blender/editors/preview/previewrender.c
@@ -252,6 +252,12 @@ void BIF_preview_changed(short id_code)
GPU_lamp_free(ob);
}
}
+
+ for(ma=G.main->mat.first; ma; ma=ma->id.next) {
+ if(ma->gpumaterial.first) {
+ GPU_material_free(ma);
+ }
+ }
} else if(OBACT) {
Object *ob = OBACT;
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 77cd06581fd..1effd8fd377 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -189,7 +189,7 @@ typedef struct ImagePaintPartialRedraw {
// #define PROJ_BUCKET_CLONE_INIT 1<<1
/* used for testing doubles, if a point is on a line etc */
-#define PROJ_GEOM_TOLERANCE 0.0002f
+#define PROJ_GEOM_TOLERANCE 0.00075f
/* vert flags */
#define PROJ_VERT_CULL 1
@@ -238,8 +238,8 @@ typedef struct ProjPaintState {
char *faceSeamFlags; /* store info about faces, if they are initialized etc*/
float (*faceSeamUVs)[4][2]; /* expanded UVs for faces to use as seams */
LinkNode **vertFaces; /* Only needed for when seam_bleed_px is enabled, use to find UV seams */
- char *vertFlags; /* store options per vert, now only store if the vert is pointing away from the view */
#endif
+ char *vertFlags; /* store options per vert, now only store if the vert is pointing away from the view */
int buckets_x; /* The size of the bucket grid, the grid span's screenMin/screenMax so you can paint outsize the screen or with 2 brushes at once */
int buckets_y;
@@ -341,7 +341,7 @@ typedef struct UndoTile {
typedef struct UndoElem {
struct UndoElem *next, *prev;
char name[MAXUNDONAME];
- unsigned long undosize;
+ uintptr_t undosize;
ImBuf *ibuf;
ListBase tiles;
@@ -485,12 +485,12 @@ static void undo_imagepaint_push_begin(char *name)
static void undo_imagepaint_push_end()
{
UndoElem *uel;
- unsigned long totmem, maxmem;
+ uintptr_t totmem, maxmem;
if(U.undomemory != 0) {
/* limit to maximum memory (afterwards, we can't know in advance) */
totmem= 0;
- maxmem= ((unsigned long)U.undomemory)*1024*1024;
+ maxmem= ((uintptr_t)U.undomemory)*1024*1024;
uel= undobase.last;
while(uel) {
@@ -716,8 +716,8 @@ static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w
static void uvco_to_wrapped_pxco(float uv[2], int ibuf_x, int ibuf_y, float *x, float *y)
{
/* use */
- *x = (float)fmod(uv[0], 1.0f);
- *y = (float)fmod(uv[1], 1.0f);
+ *x = (float)fmodf(uv[0], 1.0f);
+ *y = (float)fmodf(uv[1], 1.0f);
if (*x < 0.0f) *x += 1.0f;
if (*y < 0.0f) *y += 1.0f;
@@ -751,7 +751,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float
Vec2Weightf(uv, tf->uv[0], tf->uv[2], tf->uv[3], w);
}
- ibuf = BKE_image_get_ibuf((Image *)tf->tpage, NULL); /* TODO - this may be slow, the only way around it is to have an ibuf index per face */
+ ibuf = tf->tpage->ibufs.first; /* we must have got the imbuf before getting here */
if (!ibuf) return 0;
if (interp) {
@@ -760,21 +760,21 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float
if (ibuf->rect_float) {
if (rgba_fp) {
- bilinear_interpolation_color(ibuf, NULL, rgba_fp, x, y);
+ bilinear_interpolation_color_wrap(ibuf, NULL, rgba_fp, x, y);
}
else {
float rgba_tmp_f[4];
- bilinear_interpolation_color(ibuf, NULL, rgba_tmp_f, x, y);
+ bilinear_interpolation_color_wrap(ibuf, NULL, rgba_tmp_f, x, y);
IMAPAINT_FLOAT_RGBA_TO_CHAR(rgba, rgba_tmp_f);
}
}
else {
if (rgba) {
- bilinear_interpolation_color(ibuf, rgba, NULL, x, y);
+ bilinear_interpolation_color_wrap(ibuf, rgba, NULL, x, y);
}
else {
unsigned char rgba_tmp[4];
- bilinear_interpolation_color(ibuf, rgba_tmp, NULL, x, y);
+ bilinear_interpolation_color_wrap(ibuf, rgba_tmp, NULL, x, y);
IMAPAINT_CHAR_RGBA_TO_FLOAT(rgba_fp, rgba_tmp);
}
}
@@ -911,7 +911,7 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc
else
isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], w, ps->is_ortho);
}
- if (isect_ret==1) {
+ if (isect_ret>=1) {
/* TODO - we may want to cache the first hit,
* it is not possible to swap the face order in the list anymore */
return 1;
@@ -939,7 +939,7 @@ static int line_isect_y(const float p1[2], const float p2[2], const float y_leve
return ISECT_TRUE_P2;
}
- y_diff= fabs(p1[1]-p2[1]); /* yuck, horizontal line, we cant do much here */
+ y_diff= fabsf(p1[1]-p2[1]); /* yuck, horizontal line, we cant do much here */
if (y_diff < 0.000001f) {
*x_isect = (p1[0]+p2[0]) * 0.5f;
@@ -972,7 +972,7 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve
return ISECT_TRUE_P2;
}
- x_diff= fabs(p1[0]-p2[0]); /* yuck, horizontal line, we cant do much here */
+ x_diff= fabsf(p1[0]-p2[0]); /* yuck, horizontal line, we cant do much here */
if (x_diff < 0.000001) { /* yuck, vertical line, we cant do much here */
*y_isect = (p1[0]+p2[0]) * 0.5f;
@@ -996,14 +996,15 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve
* Its possible this gives incorrect results, when the UVs for 1 face go into the next
* tile, but do not do this for the adjacent face, it could return a false positive.
* This is so unlikely that Id not worry about it. */
+#ifndef PROJ_DEBUG_NOSEAMBLEED
static int cmp_uv(const float vec2a[2], const float vec2b[2])
{
/* if the UV's are not between 0.0 and 1.0 */
- float xa = (float)fmod(vec2a[0], 1.0f);
- float ya = (float)fmod(vec2a[1], 1.0f);
+ float xa = (float)fmodf(vec2a[0], 1.0f);
+ float ya = (float)fmodf(vec2a[1], 1.0f);
- float xb = (float)fmod(vec2b[0], 1.0f);
- float yb = (float)fmod(vec2b[1], 1.0f);
+ float xb = (float)fmodf(vec2b[0], 1.0f);
+ float yb = (float)fmodf(vec2b[1], 1.0f);
if (xa < 0.0f) xa += 1.0f;
if (ya < 0.0f) ya += 1.0f;
@@ -1011,12 +1012,13 @@ static int cmp_uv(const float vec2a[2], const float vec2b[2])
if (xb < 0.0f) xb += 1.0f;
if (yb < 0.0f) yb += 1.0f;
- return ((fabs(xa-xb) < PROJ_GEOM_TOLERANCE) && (fabs(ya-yb) < PROJ_GEOM_TOLERANCE)) ? 1:0;
+ return ((fabsf(xa-xb) < PROJ_GEOM_TOLERANCE) && (fabsf(ya-yb) < PROJ_GEOM_TOLERANCE)) ? 1:0;
}
-
+#endif
/* set min_px and max_px to the image space bounds of the UV coords
* return zero if there is no area in the returned rectangle */
+#ifndef PROJ_DEBUG_NOSEAMBLEED
static int pixel_bounds_uv(
const float uv1[2], const float uv2[2], const float uv3[2], const float uv4[2],
rcti *bounds_px,
@@ -1044,6 +1046,7 @@ static int pixel_bounds_uv(
/* face uses no UV area when quantized to pixels? */
return (bounds_px->xmin == bounds_px->xmax || bounds_px->ymin == bounds_px->ymax) ? 0 : 1;
}
+#endif
static int pixel_bounds_array(float (* uv)[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, int tot)
{
@@ -1151,7 +1154,7 @@ static float angleToLength(float angle)
return 1.0f;
}
else {
- return fabs(1.0f / cos(angle * (M_PI/180.0f)));
+ return fabsf(1.0f / cosf(angle * (M_PI/180.0f)));
}
}
@@ -1384,10 +1387,10 @@ static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const
if (ibuf_other->rect_float) { /* from float to float */
- bilinear_interpolation_color(ibuf_other, NULL, rgba_f, x, y);
+ bilinear_interpolation_color_wrap(ibuf_other, NULL, rgba_f, x, y);
}
else { /* from char to float */
- bilinear_interpolation_color(ibuf_other, rgba_ub, NULL, x, y);
+ bilinear_interpolation_color_wrap(ibuf_other, rgba_ub, NULL, x, y);
}
}
@@ -1407,7 +1410,7 @@ float project_paint_uvpixel_mask(
ImBuf *ibuf_other;
const MTFace *tf_other = ps->dm_mtface_mask + face_index;
- if (tf_other->tpage && (ibuf_other = BKE_image_get_ibuf((Image *)tf_other->tpage, NULL))) {
+ if (tf_other->tpage && (ibuf_other = BKE_image_get_ibuf(tf_other->tpage, NULL))) {
/* BKE_image_get_ibuf - TODO - this may be slow */
unsigned char rgba_ub[4];
float rgba_f[4];
@@ -1563,7 +1566,7 @@ static ProjPixel *project_paint_uvpixel_init(
ImBuf *ibuf_other;
const MTFace *tf_other = ps->dm_mtface_clone + face_index;
- if (tf_other->tpage && (ibuf_other = BKE_image_get_ibuf((Image *)tf_other->tpage, NULL))) {
+ if (tf_other->tpage && (ibuf_other = BKE_image_get_ibuf(tf_other->tpage, NULL))) {
/* BKE_image_get_ibuf - TODO - this may be slow */
if (ibuf->rect_float) {
@@ -1632,7 +1635,7 @@ static int line_clip_rect2f(
{
/* first account for horizontal, then vertical lines */
/* horiz */
- if (fabs(l1[1]-l2[1]) < PROJ_GEOM_TOLERANCE) {
+ if (fabsf(l1[1]-l2[1]) < PROJ_GEOM_TOLERANCE) {
/* is the line out of range on its Y axis? */
if (l1[1] < rect->ymin || l1[1] > rect->ymax) {
return 0;
@@ -1643,7 +1646,7 @@ static int line_clip_rect2f(
}
- if (fabs(l1[0]-l2[0]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/
+ if (fabsf(l1[0]-l2[0]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/
if (BLI_in_rctf(rect, l1[0], l1[1])) {
VECCOPY2D(l1_clip, l1);
VECCOPY2D(l2_clip, l2);
@@ -1660,7 +1663,7 @@ static int line_clip_rect2f(
CLAMP(l2_clip[0], rect->xmin, rect->xmax);
return 1;
}
- else if (fabs(l1[0]-l2[0]) < PROJ_GEOM_TOLERANCE) {
+ else if (fabsf(l1[0]-l2[0]) < PROJ_GEOM_TOLERANCE) {
/* is the line out of range on its X axis? */
if (l1[0] < rect->xmin || l1[0] > rect->xmax) {
return 0;
@@ -1671,7 +1674,7 @@ static int line_clip_rect2f(
return 0;
}
- if (fabs(l1[1]-l2[1]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/
+ if (fabsf(l1[1]-l2[1]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/
if (BLI_in_rctf(rect, l1[0], l1[1])) {
VECCOPY2D(l1_clip, l1);
VECCOPY2D(l2_clip, l2);
@@ -2015,7 +2018,6 @@ static void project_bucket_clip_face(
const int flip = ((SIDE_OF_LINE(v1coSS, v2coSS, v3coSS) > 0.0f) != (SIDE_OF_LINE(uv1co, uv2co, uv3co) > 0.0f));
float bucket_bounds_ss[4][2];
- float w[3];
/* get the UV space bounding box */
inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v1coSS[0], v1coSS[1]);
@@ -2086,6 +2088,7 @@ static void project_bucket_clip_face(
/* Maximum possible 6 intersections when using a rectangle and triangle */
float isectVCosSS[8][3]; /* The 3rd float is used to store angle for qsort(), NOT as a Z location */
float v1_clipSS[2], v2_clipSS[2];
+ float w[3];
/* calc center*/
float cent[2] = {0.0f, 0.0f};
@@ -2128,6 +2131,7 @@ static void project_bucket_clip_face(
if ((*tot) < 3) { /* no intersections to speak of */
*tot = 0;
+ return;
}
/* now we have all points we need, collect their angles and sort them clockwise */
@@ -2156,16 +2160,15 @@ static void project_bucket_clip_face(
for(i=0; i<(*tot); i++) {
v2_clipSS[0] = isectVCosSS[i][0] - cent[0];
v2_clipSS[1] = isectVCosSS[i][1] - cent[1];
- isectVCosSS[i][2] = atan2(v1_clipSS[0]*v2_clipSS[1] - v1_clipSS[1]*v2_clipSS[0], v1_clipSS[0]*v2_clipSS[0]+v1_clipSS[1]*v2_clipSS[1]);
+ isectVCosSS[i][2] = atan2f(v1_clipSS[0]*v2_clipSS[1] - v1_clipSS[1]*v2_clipSS[0], v1_clipSS[0]*v2_clipSS[0]+v1_clipSS[1]*v2_clipSS[1]);
}
if (flip) qsort(isectVCosSS, *tot, sizeof(float)*3, float_z_sort_flip);
else qsort(isectVCosSS, *tot, sizeof(float)*3, float_z_sort);
-
/* remove doubles */
/* first/last check */
- if (fabs(isectVCosSS[0][0]-isectVCosSS[(*tot)-1][0]) < PROJ_GEOM_TOLERANCE && fabs(isectVCosSS[0][1]-isectVCosSS[(*tot)-1][1]) < PROJ_GEOM_TOLERANCE) {
+ if (fabsf(isectVCosSS[0][0]-isectVCosSS[(*tot)-1][0]) < PROJ_GEOM_TOLERANCE && fabsf(isectVCosSS[0][1]-isectVCosSS[(*tot)-1][1]) < PROJ_GEOM_TOLERANCE) {
(*tot)--;
}
@@ -2180,8 +2183,8 @@ static void project_bucket_clip_face(
while (doubles==TRUE) {
doubles = FALSE;
for(i=1; i<(*tot); i++) {
- if (fabs(isectVCosSS[i-1][0]-isectVCosSS[i][0]) < PROJ_GEOM_TOLERANCE &&
- fabs(isectVCosSS[i-1][1]-isectVCosSS[i][1]) < PROJ_GEOM_TOLERANCE)
+ if (fabsf(isectVCosSS[i-1][0]-isectVCosSS[i][0]) < PROJ_GEOM_TOLERANCE &&
+ fabsf(isectVCosSS[i-1][1]-isectVCosSS[i][1]) < PROJ_GEOM_TOLERANCE)
{
int j;
for(j=i+1; j<(*tot); j++) {
@@ -2309,6 +2312,19 @@ int IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
return 1;
}
+static int IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot)
+{
+ int i;
+ int side = (SIDE_OF_LINE(uv[tot-1], uv[0], pt) > 0.0f);
+
+ for (i=1; i<tot; i++) {
+ if ((SIDE_OF_LINE(uv[i-1], uv[i], pt) > 0.0f) != side)
+ return 0;
+
+ }
+
+ return 1;
+}
/* One of the most important function for projectiopn painting, since it selects the pixels to be added into each bucket.
* initialize pixels from this face where it intersects with the bucket_index, optionally initialize pixels for removing seams */
@@ -2352,6 +2368,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
float uv_clip[8][2];
int uv_clip_tot;
const short is_ortho = ps->is_ortho;
+ const short do_backfacecull = ps->do_backfacecull;
vCo[0] = ps->dm_mvert[mf->v1].co;
vCo[1] = ps->dm_mvert[mf->v2].co;
@@ -2361,9 +2378,20 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* Use tf_uv_pxoffset instead of tf->uv so we can offset the UV half a pixel
* this is done so we can avoid offseting all the pixels by 0.5 which causes
* problems when wrapping negative coords */
- xhalfpx = 0.5f / ibuf_xf;
- yhalfpx = 0.5f / ibuf_yf;
-
+ xhalfpx = (0.5f+ (PROJ_GEOM_TOLERANCE/3.0f) ) / ibuf_xf;
+ yhalfpx = (0.5f+ (PROJ_GEOM_TOLERANCE/4.0f) ) / ibuf_yf;
+
+ /* Note about (PROJ_GEOM_TOLERANCE/x) above...
+ Needed to add this offset since UV coords are often quads aligned to pixels.
+ In this case pixels can be exactly between 2 triangles causing nasty
+ artifacts.
+
+ This workaround can be removed and painting will still work on most cases
+ but since the first thing most people try is painting onto a quad- better make it work.
+ */
+
+
+
tf_uv_pxoffset[0][0] = tf->uv[0][0] - xhalfpx;
tf_uv_pxoffset[0][1] = tf->uv[0][1] - yhalfpx;
@@ -2399,8 +2427,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
v1coSS = ps->screenCoords[ (*(&mf->v1 + i1)) ];
v2coSS = ps->screenCoords[ (*(&mf->v1 + i2)) ];
v3coSS = ps->screenCoords[ (*(&mf->v1 + i3)) ];
-
-
+
/* This funtion gives is a concave polyline in UV space from the clipped quad and tri*/
project_bucket_clip_face(
is_ortho, bucket_bounds,
@@ -2408,8 +2435,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
uv1co, uv2co, uv3co,
uv_clip, &uv_clip_tot
);
-
-
+
/* sometimes this happens, better just allow for 8 intersectiosn even though there should be max 6 */
/*
if (uv_clip_tot>6) {
@@ -2431,7 +2457,10 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
//uv[0] = (((float)x) + 0.5f) / ibuf->x;
uv[0] = (float)x / ibuf_xf; /* use pixel offset UV coords instead */
- if (IsectPoly2Df(uv, uv_clip, uv_clip_tot)) {
+ /* Note about IsectPoly2Df_twoside, checking the face or uv flipping doesnt work,
+ * could check the poly direction but better to do this */
+ if( (do_backfacecull && IsectPoly2Df(uv, uv_clip, uv_clip_tot)) ||
+ (do_backfacecull==0 && IsectPoly2Df_twoside(uv, uv_clip, uv_clip_tot))) {
has_x_isect = has_isect = 1;
@@ -2518,7 +2547,6 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
float (*outset_uv)[2] = ps->faceSeamUVs[face_index];
float insetCos[4][3]; /* inset face coords. NOTE!!! ScreenSace for ortho, Worldspace in prespective view */
- float *uv_seam_quad[4];
float fac;
float *vCoSS[4]; /* vertex screenspace coords */
@@ -2574,16 +2602,11 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
fac1 = Vec2Lenf(vCoSS[fidx1], bucket_clip_edges[0]) / ftot;
fac2 = Vec2Lenf(vCoSS[fidx1], bucket_clip_edges[1]) / ftot;
- uv_seam_quad[0] = tf_uv_pxoffset[fidx1];
- uv_seam_quad[1] = tf_uv_pxoffset[fidx2];
- uv_seam_quad[2] = outset_uv[fidx2];
- uv_seam_quad[3] = outset_uv[fidx1];
-
- Vec2Lerpf(seam_subsection[0], uv_seam_quad[0], uv_seam_quad[1], fac1);
- Vec2Lerpf(seam_subsection[1], uv_seam_quad[0], uv_seam_quad[1], fac2);
-
- Vec2Lerpf(seam_subsection[2], uv_seam_quad[3], uv_seam_quad[2], fac2);
- Vec2Lerpf(seam_subsection[3], uv_seam_quad[3], uv_seam_quad[2], fac1);
+ Vec2Lerpf(seam_subsection[0], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac1);
+ Vec2Lerpf(seam_subsection[1], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac2);
+
+ Vec2Lerpf(seam_subsection[2], outset_uv[fidx1], outset_uv[fidx2], fac2);
+ Vec2Lerpf(seam_subsection[3], outset_uv[fidx1], outset_uv[fidx2], fac1);
/* if the bucket_clip_edges values Z values was kept we could avoid this
* Inset needs to be added so occlusion tests wont hit adjacent faces */
@@ -2636,14 +2659,28 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* Only bother calculating the weights if we intersect */
if (ps->do_mask_normal || ps->dm_mtface_clone) {
- /* TODO, this is not QUITE correct since UV is not inside the UV's but good enough for seams */
+#if 0
+ /* This is not QUITE correct since UV is not inside the UV's but good enough for seams */
if (side) {
BarycentricWeights2f(uv, tf_uv_pxoffset[0], tf_uv_pxoffset[2], tf_uv_pxoffset[3], w);
}
else {
BarycentricWeights2f(uv, tf_uv_pxoffset[0], tf_uv_pxoffset[1], tf_uv_pxoffset[2], w);
}
-
+#endif
+#if 1
+ /* Cheat, we know where we are along the edge so work out the weights from that */
+ fac = fac1 + (fac * (fac2-fac1));
+ w[0]=w[1]=w[2]= 0.0;
+ if (side) {
+ w[fidx1?fidx1-1:0] = fac;
+ w[fidx2?fidx2-1:0] = 1.0-fac;
+ }
+ else {
+ w[fidx1] = fac;
+ w[fidx2] = 1.0-fac;
+ }
+#endif
}
/* a pitty we need to get the worldspace pixel location here */
@@ -3076,7 +3113,7 @@ static void project_paint_begin(ProjPaintState *ps)
ps->buckets_x = (int)(ps->screen_width / (((float)ps->brush->size) / PROJ_BUCKET_BRUSH_DIV));
ps->buckets_y = (int)(ps->screen_height / (((float)ps->brush->size) / PROJ_BUCKET_BRUSH_DIV));
- printf("\tscreenspace bucket division x:%d y:%d\n", ps->buckets_x, ps->buckets_y);
+ /* printf("\tscreenspace bucket division x:%d y:%d\n", ps->buckets_x, ps->buckets_y); */
/* really high values could cause problems since it has to allocate a few
* (ps->buckets_x*ps->buckets_y) sized arrays */
@@ -3232,7 +3269,7 @@ static void project_paint_begin(ProjPaintState *ps)
image_index = BLI_linklist_index(image_LinkList, tf->tpage);
- if (image_index==-1 && BKE_image_get_ibuf((Image *)tf->tpage, NULL)) { /* MemArena dosnt have an append func */
+ if (image_index==-1 && BKE_image_get_ibuf(tf->tpage, NULL)) { /* MemArena dosnt have an append func */
BLI_linklist_append(&image_LinkList, tf->tpage);
image_index = ps->image_tot;
ps->image_tot++;
@@ -3254,10 +3291,10 @@ static void project_paint_begin(ProjPaintState *ps)
for (node= image_LinkList, i=0; node; node= node->next, i++, projIma++) {
projIma->ima = node->link;
- // calloced - projIma->touch = 0;
+ projIma->touch = 0;
projIma->ibuf = BKE_image_get_ibuf(projIma->ima, NULL);
projIma->partRedrawRect = BLI_memarena_alloc(arena, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
- // calloced - memset(projIma->partRedrawRect, 0, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
+ memset(projIma->partRedrawRect, 0, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
}
/* we have built the array, discard the linked list */
@@ -3308,6 +3345,7 @@ static void project_paint_end(ProjPaintState *ps)
int size = sizeof(UndoTile **) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->x) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->y);
last_projIma->undoRect = (UndoTile **) BLI_memarena_alloc(arena, size);
memset(last_projIma->undoRect, 0, size);
+ last_projIma->ibuf->userflags |= IB_BITMAPDIRTY;
}
for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) {
@@ -3375,15 +3413,16 @@ static void project_paint_end(ProjPaintState *ps)
MEM_freeN(ps->bucketFaces);
MEM_freeN(ps->bucketFlags);
+#ifndef PROJ_DEBUG_NOSEAMBLEED
if (ps->seam_bleed_px > 0.0f) {
MEM_freeN(ps->vertFaces);
MEM_freeN(ps->faceSeamFlags);
MEM_freeN(ps->faceSeamUVs);
}
+#endif
if (ps->vertFlags) MEM_freeN(ps->vertFlags);
-
for (a=0; a<ps->thread_tot; a++) {
BLI_memarena_free(ps->arena_mt[a]);
}
@@ -3411,7 +3450,7 @@ static void partial_redraw_array_init(ImagePaintPartialRedraw *pr)
static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPartialRedraw *pr_other, int tot)
{
- int touch;
+ int touch= 0;
while (tot--) {
pr->x1 = MIN2(pr->x1, pr_other->x1);
pr->y1 = MIN2(pr->y1, pr_other->y1);
@@ -3539,6 +3578,7 @@ static void blend_color_mix(unsigned char *cp, const unsigned char *cp1, const u
cp[0]= (mfac*cp1[0]+fac*cp2[0])/255;
cp[1]= (mfac*cp1[1]+fac*cp2[1])/255;
cp[2]= (mfac*cp1[2]+fac*cp2[2])/255;
+ cp[3]= (mfac*cp1[3]+fac*cp2[3])/255;
}
static void blend_color_mix_float(float *cp, const float *cp1, const float *cp2, const float fac)
@@ -3547,6 +3587,7 @@ static void blend_color_mix_float(float *cp, const float *cp1, const float *cp2,
cp[0]= mfac*cp1[0] + fac*cp2[0];
cp[1]= mfac*cp1[1] + fac*cp2[1];
cp[2]= mfac*cp1[2] + fac*cp2[2];
+ cp[3]= mfac*cp1[3] + fac*cp2[3];
}
static void do_projectpaint_clone(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask)
@@ -3583,8 +3624,8 @@ static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, floa
if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1)==0)
return;
-
- ((ProjPixelClone *)projPixel)->clonepx.uint = IMB_blend_color(*projPixel->pixel.uint_pt, *((unsigned int *)rgba_ub), (int)(alpha*mask*255), ps->blend);
+ /* ((ProjPixelClone *)projPixel)->clonepx.uint = IMB_blend_color(*projPixel->pixel.uint_pt, *((unsigned int *)rgba_ub), (int)(alpha*mask*255), ps->blend); */
+ blend_color_mix(((ProjPixelClone *)projPixel)->clonepx.ch, projPixel->pixel.ch_pt, rgba_ub, (int)(alpha*mask*255));
BLI_linklist_prepend_arena(smearPixels, (void *)projPixel, smearArena);
}
@@ -3597,7 +3638,8 @@ static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, fl
return;
IMAPAINT_FLOAT_RGBA_TO_CHAR(rgba_smear, projPixel->pixel.f_pt);
- ((ProjPixelClone *)projPixel)->clonepx.uint = IMB_blend_color(*((unsigned int *)rgba_smear), *((unsigned int *)rgba_ub), (int)(alpha*mask*255), ps->blend);
+ /* (ProjPixelClone *)projPixel)->clonepx.uint = IMB_blend_color(*((unsigned int *)rgba_smear), *((unsigned int *)rgba_ub), (int)(alpha*mask*255), ps->blend); */
+ blend_color_mix(((ProjPixelClone *)projPixel)->clonepx.ch, rgba_smear, (rgba_ub), (int)(alpha*mask*255));
BLI_linklist_prepend_arena(smearPixels_f, (void *)projPixel, smearArena);
}
@@ -3708,12 +3750,12 @@ static void *do_projectpaint_thread(void *ph_v)
projPixel = (ProjPixel *)node->link;
- /*dist = Vec2Lenf(projPixel->projCoSS, pos);*/ /* correct but uses a sqrt */
+ /*dist = Vec2Lenf(projPixel->projCoSS, pos);*/ /* correct but uses a sqrtf */
dist_nosqrt = Vec2Lenf_nosqrt(projPixel->projCoSS, pos);
- /*if (dist < s->brush->size) {*/ /* correct but uses a sqrt */
+ /*if (dist < s->brush->size) {*/ /* correct but uses a sqrtf */
if (dist_nosqrt < brush_size_sqared) {
- falloff = brush_sample_falloff_noalpha(ps->brush, sqrt(dist_nosqrt));
+ falloff = brush_sample_falloff_noalpha(ps->brush, sqrtf(dist_nosqrt));
if (falloff > 0.0f) {
if (ps->is_texbrush) {
brush_sample_tex(ps->brush, projPixel->projCoSS, rgba);
@@ -3802,10 +3844,9 @@ static void *do_projectpaint_thread(void *ph_v)
*projPixel->pixel.uint_pt = ((ProjPixelClone *)projPixel)->clonepx.uint;
}
- for (node= smearPixels_f; node; node= node->next) { /* this wont run for a float image */
+ for (node= smearPixels_f; node; node= node->next) {
projPixel = node->link;
IMAPAINT_CHAR_RGBA_TO_FLOAT(projPixel->pixel.f_pt, ((ProjPixelClone *)projPixel)->clonepx.ch);
- node = node->next;
}
BLI_memarena_free(smearArena);
@@ -4261,7 +4302,7 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint
) {
ImBuf *ibuf;
- newimage = (Image*)((s->me->mtface+newfaceindex)->tpage);
+ newimage = (s->me->mtface+newfaceindex)->tpage;
ibuf= BKE_image_get_ibuf(newimage, s->sima? &s->sima->iuser: NULL);
if(ibuf && ibuf->rect)
@@ -4399,6 +4440,7 @@ typedef struct PaintOperation {
int first;
int prevmouse[2];
+ int brush_size_orig;
double starttime;
ViewContext vc;
@@ -4485,6 +4527,8 @@ static int paint_init(bContext *C, wmOperator *op)
pop->ps.brush = pop->s.brush;
pop->ps.tool = pop->s.tool;
pop->ps.blend = pop->s.blend;
+
+ pop->brush_size_orig = pop->ps.brush->size; /* not nice hack because 1 size brushes always fail with projection paint */
}
if(pop->mode != PAINT_MODE_2D) {
@@ -4504,6 +4548,10 @@ static int paint_init(bContext *C, wmOperator *op)
return 0;
}
+
+ /* Dont allow brush size below 2 */
+ if (pop->ps.brush->size<=1)
+ pop->ps.brush->size = 2;
}
/* note, if we have no UVs on the derived mesh, then we must return here */
@@ -4602,8 +4650,10 @@ static void paint_exit(bContext *C, wmOperator *op)
imapaint_canvas_free(&pop->s);
brush_painter_free(pop->painter);
- if(pop->mode == PAINT_MODE_3D_PROJECT)
+ if(pop->mode == PAINT_MODE_3D_PROJECT) {
+ pop->ps.brush->size = pop->brush_size_orig;
project_paint_end(&pop->ps);
+ }
paint_redraw(C, &pop->s, 1);
undo_imagepaint_push_end();
@@ -5186,3 +5236,4 @@ void PAINT_OT_texture_paint_radial_control(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c
index 753095eeb53..79284ada483 100644
--- a/source/blender/editors/space_buttons/buttons_header.c
+++ b/source/blender/editors/space_buttons/buttons_header.c
@@ -172,7 +172,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
if(sbuts->pathflag & (1<<BCONTEXT_OBJECT))
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_OBJECT_DATA, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object");
if(sbuts->pathflag & (1<<BCONTEXT_CONSTRAINT))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Modifier");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Constraint");
if(sbuts->pathflag & (1<<BCONTEXT_MODIFIER))
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MODIFIER, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifier");
if(sbuts->pathflag & (1<<BCONTEXT_DATA))
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 01f94741f59..28121de1f1a 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -105,7 +105,7 @@ static void file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, short v
int act_file;
short selecting = (val == LEFTMOUSE);
FileSelectParams *params = ED_fileselect_get_params(sfile);
- FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
+ // FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
int numfiles = filelist_numfiles(sfile->files);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index f60b6f08348..766dec7c064 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -170,7 +170,7 @@ static int compare_name(const void *a1, const void *a2)
if( strcmp(entry1->relname, "..")==0 ) return (-1);
if( strcmp(entry2->relname, "..")==0 ) return (1);
- return (BLI_strcasecmp(entry1->relname,entry2->relname));
+ return (BLI_natstrcmp(entry1->relname,entry2->relname));
}
static int compare_date(const void *a1, const void *a2)
@@ -201,7 +201,7 @@ static int compare_date(const void *a1, const void *a2)
if ( entry1->s.st_mtime < entry2->s.st_mtime) return 1;
if ( entry1->s.st_mtime > entry2->s.st_mtime) return -1;
- else return BLI_strcasecmp(entry1->relname,entry2->relname);
+ else return BLI_natstrcmp(entry1->relname,entry2->relname);
}
static int compare_size(const void *a1, const void *a2)
@@ -231,7 +231,7 @@ static int compare_size(const void *a1, const void *a2)
if ( entry1->s.st_size < entry2->s.st_size) return 1;
if ( entry1->s.st_size > entry2->s.st_size) return -1;
- else return BLI_strcasecmp(entry1->relname,entry2->relname);
+ else return BLI_natstrcmp(entry1->relname,entry2->relname);
}
static int compare_extension(const void *a1, const void *a2) {
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 0cede662a9a..378d91c8e32 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -579,7 +579,7 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
static char *filesel_imagetype_string(Image *ima)
{
- char *strp, *str= MEM_callocN(14*32, "menu for filesel");
+ char *strp, *str= MEM_callocN(15*32, "menu for filesel");
strp= str;
str += sprintf(str, "Save Image as: %%t|");
@@ -588,6 +588,9 @@ static char *filesel_imagetype_string(Image *ima)
str += sprintf(str, "PNG %%x%d|", R_PNG);
str += sprintf(str, "BMP %%x%d|", R_BMP);
str += sprintf(str, "Jpeg %%x%d|", R_JPEG90);
+#ifdef WITH_OPENJPEG
+ str += sprintf(str, "Jpeg 2000 %%x%d|", R_JP2);
+#endif
str += sprintf(str, "Iris %%x%d|", R_IRIS);
if(G.have_libtiff)
str += sprintf(str, "Tiff %%x%d|", R_TIFF);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 6fe3aa734b4..f7f637670b5 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -35,6 +35,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_action_types.h"
+#include "DNA_brush_types.h"
#include "DNA_color_types.h"
#include "DNA_image_types.h"
#include "DNA_ipo_types.h"
@@ -211,7 +212,7 @@ void snode_handle_recalc(bContext *C, SpaceNode *snode)
else if(snode->treetype==NTREE_COMPOSIT)
WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id);
else if(snode->treetype==NTREE_TEXTURE) {
- // ntreeTexUpdatePreviews(snode->nodetree);
+ // ntreeTexUpdatePreviews(snode->nodetree); /* XXX texture nodes should follow shader node methods (ton) */
// XXX BIF_preview_changed(ID_TE);
}
}
@@ -573,7 +574,7 @@ void node_texture_default(Tex *tx)
nodeAddLink(tx->nodetree, in, fromsock, out, tosock);
ntreeSolveOrder(tx->nodetree); /* needed for pointers */
- ntreeTexUpdatePreviews(tx->nodetree);
+ ntreeTexUpdatePreviews(tx->nodetree); /* XXX texture nodes should follow shader node methods (ton) */
}
/* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */
@@ -607,13 +608,42 @@ void snode_set_context(SpaceNode *snode, Scene *scene)
snode->nodetree= scene->nodetree;
}
else if(snode->treetype==NTREE_TEXTURE) {
- if(ob) {
- Tex *tx= give_current_texture(ob, ob->actcol);
- if(tx) {
- snode->from= (ID*)ob; /* please check this; i have no idea what 'from' is. */
- snode->id= &tx->id;
- snode->nodetree= tx->nodetree;
+ Tex *tx= NULL;
+
+ if(snode->texfrom==SNODE_TEX_OBJECT) {
+ if(ob) {
+ tx= give_current_texture(ob, ob->actcol);
+ snode->from= (ID *)ob;
+ }
+ }
+ else if(snode->texfrom==SNODE_TEX_WORLD) {
+ tx= give_current_world_texture(scene);
+ snode->from= (ID *)scene->world;
+ }
+ else {
+ MTex *mtex= NULL;
+
+ if(G.f & G_SCULPTMODE) {
+ Sculpt *sd= scene->toolsettings->sculpt;
+ if(sd && sd->brush)
+ if(sd->brush->texact != -1)
+ mtex= sd->brush->mtex[sd->brush->texact];
}
+ else {
+ Brush *br= scene->toolsettings->imapaint.brush;
+ if(br)
+ mtex= br->mtex[br->texact];
+ }
+
+ if(mtex) {
+ snode->from= (ID *)scene;
+ tx= mtex->tex;
+ }
+ }
+
+ if(tx) {
+ snode->id= &tx->id;
+ snode->nodetree= tx->nodetree;
}
}
@@ -1080,7 +1110,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event)
}
// XXX
if(snode->nodetree->type == NTREE_TEXTURE)
- ntreeTexUpdatePreviews(snode->nodetree);
+ ntreeTexUpdatePreviews(snode->nodetree); /* XXX texture nodes should follow shader node methods (ton) */
ED_region_tag_redraw(ar);
@@ -1626,7 +1656,7 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float
if(snode->nodetree->type==NTREE_TEXTURE) {
ntreeTexCheckCyclics(snode->edittree);
- ntreeTexUpdatePreviews(snode->edittree);
+ ntreeTexUpdatePreviews(snode->edittree); /* XXX texture nodes should follow shader node methods (ton) */
}
return node;
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 8373f588fb2..f6cf6de4b00 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -338,6 +338,10 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filename", filename);
+ /* XXX if(sfile->flag & FILE_STRINGCODE) {
+ BLI_makestringcode(G.sce, str);
+ }*/
+
// XXX sound= sound_new_sound(filename);
sound= NULL;
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index fb42d30e496..f127ab4b0cf 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -134,5 +134,3 @@ void SEQUENCER_OT_properties(wmOperatorType *ot)
ot->flag= 0;
}
-
-
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 675602a23a0..bd31d8d86ff 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -741,12 +741,21 @@ static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq)
static int recursive= 0;
float zoom;
float zoomx, zoomy;
+ int render_size = 0;
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
- rectx= (scene->r.size*scene->r.xsch)/100;
- recty= (scene->r.size*scene->r.ysch)/100;
+ render_size = sseq->render_size;
+ if (render_size == 0) {
+ render_size = scene->r.size;
+ }
+ if (render_size < 0) {
+ return;
+ }
+
+ rectx= (render_size*scene->r.xsch)/100;
+ recty= (render_size*scene->r.ysch)/100;
/* BIG PROBLEM: the give_ibuf_seq() can call a rendering, which in turn calls redraws...
this shouldn't belong in a window drawing....
@@ -758,13 +767,13 @@ static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq)
else {
recursive= 1;
if (special_seq_update) {
- ibuf= give_ibuf_seq_direct(scene, rectx, recty, (scene->r.cfra), special_seq_update);
+ ibuf= give_ibuf_seq_direct(scene, rectx, recty, (scene->r.cfra), render_size, special_seq_update);
}
else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) {
- ibuf= (ImBuf *)give_ibuf_seq(scene, rectx, recty, (scene->r.cfra), sseq->chanshown);
+ ibuf= (ImBuf *)give_ibuf_seq(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, render_size);
}
else {
- ibuf= (ImBuf *)give_ibuf_seq_threaded(scene, rectx, recty, (scene->r.cfra), sseq->chanshown);
+ ibuf= (ImBuf *)give_ibuf_seq_threaded(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, render_size);
}
recursive= 0;
@@ -815,6 +824,7 @@ static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq)
zoom= SEQ_ZOOM_FAC(sseq->zoom);
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+ zoom /= render_size / 100.0;
zoomx = zoom * ((float)scene->r.xasp / (float)scene->r.yasp);
zoomy = zoom;
} else {
@@ -949,13 +959,21 @@ void seq_viewmove(Scene *scene, ARegion *ar, SpaceSeq *sseq)
void drawprefetchseqspace(Scene *scene, ARegion *ar, SpaceSeq *sseq)
{
int rectx, recty;
+ int render_size = sseq->render_size;
+ if (render_size == 0) {
+ render_size = scene->r.size;
+ }
+ if (render_size < 0) {
+ return;
+ }
- rectx= (scene->r.size*scene->r.xsch)/100;
- recty= (scene->r.size*scene->r.ysch)/100;
+ rectx= (render_size*scene->r.xsch)/100;
+ recty= (render_size*scene->r.ysch)/100;
if(sseq->mainb != SEQ_DRAW_SEQUENCE) {
give_ibuf_prefetch_request(
- rectx, recty, (scene->r.cfra), sseq->chanshown);
+ rectx, recty, (scene->r.cfra), sseq->chanshown,
+ render_size);
}
}
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 8c3ec96971b..9c3191c93d6 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -160,7 +160,7 @@ void set_last_seq(Scene *scene, Sequence *seq)
ed->act_seq= seq;
}
-Sequence *get_forground_frame_seq(Scene *scene, int frame)
+Sequence *get_foreground_frame_seq(Scene *scene, int frame)
{
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq, *best_seq=NULL;
@@ -879,12 +879,33 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de
static Sequence *dupli_seq(Sequence *seq)
{
Sequence *seqn = MEM_dupallocN(seq);
+ // XXX animato: ID *id;
seq->tmp = seqn;
seqn->strip= MEM_dupallocN(seq->strip);
- if(seqn->ipo) seqn->ipo->id.us++;
+ // XXX animato
+#if 0
+ if (seqn->ipo) {
+ if (U.dupflag & USER_DUP_IPO) {
+ id= (ID *)seqn->ipo;
+ seqn->ipo= copy_ipo(seqn->ipo);
+ /* we don't need to decrease the number
+ * of the ipo because we never increase it,
+ * for example, adduplicate need decrease
+ * the number but only because copy_object
+ * call id_us_plus for the ipo block and
+ * single_ipo_users only work if id->us > 1.
+ *
+ * need call ipo_idnew here, for drivers ??
+ * - Diego
+ */
+ }
+ else
+ seqn->ipo->id.us++;
+ }
+#endif
seqn->strip->tstripdata = 0;
seqn->strip->tstripdata_startstill = 0;
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 57d459015dd..d7cb08db414 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -1576,7 +1576,7 @@ static void view3d_panel_bonesketch_spaces(const bContext *C, Panel *pa)
uiBlockBeginAlign(block);
/* use real flag instead of 1 */
- uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, yco, 160, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
+ uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, yco, 160, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones, (Ctrl snaps to mesh volume)");
uiDefButBitC(block, TOG, BONE_SKETCHING_ADJUST, B_REDR, "A", 170, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Adjust strokes by drawing near them");
uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 190, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
yco -= 20;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index bbf0279692a..54696fc4508 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -36,6 +36,7 @@
#include "DNA_customdata_types.h"
#include "DNA_group_types.h"
#include "DNA_key_types.h"
+#include "DNA_lamp_types.h"
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
@@ -1052,7 +1053,7 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
int m;
#endif
- if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT);
+ if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || (FACESEL_PAINT_TEST));
else if((G.f & G_TEXTUREPAINT) && scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE));
else if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
@@ -1727,12 +1728,14 @@ typedef struct View3DShadow {
static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object *par, float obmat[][4], ListBase *shadows)
{
GPULamp *lamp;
+ Lamp *la = (Lamp*)ob->data;
View3DShadow *shadow;
lamp = GPU_lamp_from_blender(scene, ob, par);
if(lamp) {
GPU_lamp_update(lamp, ob->lay, obmat);
+ GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy);
if((ob->lay & v3d->lay) && GPU_lamp_has_shadow_buffer(lamp)) {
shadow= MEM_callocN(sizeof(View3DShadow), "View3DShadow");
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 2d623c9c33d..de0680c6cc1 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -5465,7 +5465,7 @@ void view3d_header_buttons(const bContext *C, ARegion *ar)
uiBlockBeginAlign(block);
if (scene->snap_flag & SCE_SNAP) {
- uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab)");
+ uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)");
xco+= XIC;
uiDefIconButBitS(block, TOG, SCE_SNAP_ROTATE, B_REDR, ICON_SNAP_NORMAL,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Align rotation with the snapping target");
xco+= XIC;
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 5cc471ebc22..20f74085e52 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -4374,11 +4374,11 @@ void param_pack(ParamHandle *handle, float margin)
}
box = boxarray+(i-unpacked);
- trans[0] = margin * area;
- trans[1] = margin * area;
+ trans[0] = margin;
+ trans[1] = margin;
p_chart_uv_translate(chart, trans);
- box->w += (margin * area) *2;
- box->h += (margin * area) *2;
+ box->w += margin*2;
+ box->h += margin*2;
}
}
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index ccc687858f4..49c0dc166c1 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -159,6 +159,7 @@ void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize
void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp);
void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4]);
+void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy);
int GPU_lamp_shadow_layer(GPULamp *lamp);
#ifdef __cplusplus
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 0e123d872fe..f8d0957f70d 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -79,29 +79,24 @@ void GPU_render_text(MTFace *tface, int mode,
const char *textstr, int textlen, unsigned int *col,
float *v1, float *v2, float *v3, float *v4, int glattrib)
{
- if (mode & TF_BMFONT) {
- Image* ima;
- int characters, index, character;
+ if ((mode & TF_BMFONT) && (textlen>0) && tface->tpage) {
+ Image* ima = (Image*)tface->tpage;
+ int index, character;
float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
float advance_tab;
-
/* multiline */
- float line_start= 0.0f, line_height;
+ float line_start= 0.0f, line_height;
+
if (v4)
line_height= MAX4(v1[1], v2[1], v3[1], v4[2]) - MIN4(v1[1], v2[1], v3[1], v4[2]);
else
line_height= MAX3(v1[1], v2[1], v3[1]) - MIN3(v1[1], v2[1], v3[1]);
line_height *= 1.2; /* could be an option? */
/* end multiline */
-
- characters = textlen;
- ima = (Image*)tface->tpage;
- if (ima == NULL)
- characters = 0;
-
- // color has been set
+
+ /* color has been set */
if (tface->mode & TF_OBCOL)
col= NULL;
else if (!col)
@@ -116,7 +111,7 @@ void GPU_render_text(MTFace *tface, int mode,
advance_tab= advance * 4; /* tab width could also be an option */
- for (index = 0; index < characters; index++) {
+ for (index = 0; index < textlen; index++) {
float uv[4][2];
// lets calculate offset stuff
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 87703bc73bf..818b67170c7 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -1306,6 +1306,16 @@ void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4])
Mat4Invert(lamp->imat, mat);
}
+void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy)
+{
+ lamp->energy = energy;
+ if(lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
+
+ lamp->col[0]= r* lamp->energy;
+ lamp->col[1]= g* lamp->energy;
+ lamp->col[2]= b* lamp->energy;
+}
+
static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp)
{
float temp, angle, pixsize, wsize;
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 8bc1439fd09..1d8035a2358 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -410,6 +410,7 @@ void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float
void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
+void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
/**
* Change the ordering of the color bytes pointed to by rect from
diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c
index 30f24d9bbf3..a2dbdfbe483 100644
--- a/source/blender/imbuf/intern/anim.c
+++ b/source/blender/imbuf/intern/anim.c
@@ -1046,10 +1046,11 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) {
char head[256], tail[256];
unsigned short digits;
int pic;
- int filter_y = (anim->ib_flags & IB_animdeinterlace);
-
+ int filter_y;
if (anim == NULL) return(0);
+ filter_y = (anim->ib_flags & IB_animdeinterlace);
+
if (anim->curtype == 0) {
ibuf = anim_getnew(anim);
if (ibuf == NULL) {
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index fe7e26eac2b..e4977c77155 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -294,10 +294,79 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float *
b= v-floor(v);
a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
- outI[0]= ma_mb*row1I[0] + a_mb*row3I[0] + ma_b*row2I[0]+ a_b*row4I[0];
- outI[1]= ma_mb*row1I[1] + a_mb*row3I[1] + ma_b*row2I[1]+ a_b*row4I[1];
- outI[2]= ma_mb*row1I[2] + a_mb*row3I[2] + ma_b*row2I[2]+ a_b*row4I[2];
- outI[3]= ma_mb*row1I[3] + a_mb*row3I[3] + ma_b*row2I[3]+ a_b*row4I[3];
+ /* need to add 0.5 to avoid rounding down (causes darken with the smear brush)
+ * tested with white images and this should not wrap back to zero */
+ outI[0]= (ma_mb*row1I[0] + a_mb*row3I[0] + ma_b*row2I[0]+ a_b*row4I[0]) + 0.5f;
+ outI[1]= (ma_mb*row1I[1] + a_mb*row3I[1] + ma_b*row2I[1]+ a_b*row4I[1]) + 0.5f;
+ outI[2]= (ma_mb*row1I[2] + a_mb*row3I[2] + ma_b*row2I[2]+ a_b*row4I[2]) + 0.5f;
+ outI[3]= (ma_mb*row1I[3] + a_mb*row3I[3] + ma_b*row2I[3]+ a_b*row4I[3]) + 0.5f;
+ }
+}
+
+/* function assumes out to be zero'ed, only does RGBA */
+/* BILINEAR INTERPOLATION */
+
+/* Note about wrapping, the u/v still needs to be within the image bounds,
+ * just the interpolation is wrapped.
+ * This the same as bilinear_interpolation_color except it wraps rather then using empty and emptyI */
+void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, float *outF, float u, float v)
+{
+ float *row1, *row2, *row3, *row4, a, b;
+ unsigned char *row1I, *row2I, *row3I, *row4I;
+ float a_b, ma_b, a_mb, ma_mb;
+ int y1, y2, x1, x2;
+
+
+ /* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */
+
+ x1= (int)floor(u);
+ x2= (int)ceil(u);
+ y1= (int)floor(v);
+ y2= (int)ceil(v);
+
+ // sample area entirely outside image?
+ if (x2<0 || x1>in->x-1 || y2<0 || y1>in->y-1) return;
+
+ /* wrap interpolation pixels - main difference from bilinear_interpolation_color */
+ if(x1<0)x1= in->x+x1;
+ if(y1<0)y1= in->y+y1;
+
+ if(x2>=in->x)x2= x2-in->x;
+ if(y2>=in->y)y2= y2-in->y;
+
+ if (outF) {
+ // sample including outside of edges of image
+ row1= (float *)in->rect_float + in->x * y1 * 4 + 4*x1;
+ row2= (float *)in->rect_float + in->x * y2 * 4 + 4*x1;
+ row3= (float *)in->rect_float + in->x * y1 * 4 + 4*x2;
+ row4= (float *)in->rect_float + in->x * y2 * 4 + 4*x2;
+
+ a= u-floor(u);
+ b= v-floor(v);
+ a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
+
+ outF[0]= ma_mb*row1[0] + a_mb*row3[0] + ma_b*row2[0]+ a_b*row4[0];
+ outF[1]= ma_mb*row1[1] + a_mb*row3[1] + ma_b*row2[1]+ a_b*row4[1];
+ outF[2]= ma_mb*row1[2] + a_mb*row3[2] + ma_b*row2[2]+ a_b*row4[2];
+ outF[3]= ma_mb*row1[3] + a_mb*row3[3] + ma_b*row2[3]+ a_b*row4[3];
+ }
+ if (outI) {
+ // sample including outside of edges of image
+ row1I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1;
+ row2I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x1;
+ row3I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x2;
+ row4I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x2;
+
+ a= u-floor(u);
+ b= v-floor(v);
+ a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
+
+ /* need to add 0.5 to avoid rounding down (causes darken with the smear brush)
+ * tested with white images and this should not wrap back to zero */
+ outI[0]= (ma_mb*row1I[0] + a_mb*row3I[0] + ma_b*row2I[0]+ a_b*row4I[0]) + 0.5f;
+ outI[1]= (ma_mb*row1I[1] + a_mb*row3I[1] + ma_b*row2I[1]+ a_b*row4I[1]) + 0.5f;
+ outI[2]= (ma_mb*row1I[2] + a_mb*row3I[2] + ma_b*row2I[2]+ a_b*row4I[2]) + 0.5f;
+ outI[3]= (ma_mb*row1I[3] + a_mb*row3I[3] + ma_b*row2I[3]+ a_b*row4I[3]) + 0.5f;
}
}
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index e723609f3ae..32d97d79bd7 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -570,13 +570,17 @@ void IMB_exr_write_channels(void *handle)
FrameBuffer frameBuffer;
ExrChannel *echan;
- for(echan= (ExrChannel *)data->channels.first; echan; echan= echan->next)
- frameBuffer.insert (echan->name, Slice (FLOAT, (char *)echan->rect,
- echan->xstride*sizeof(float), echan->ystride*sizeof(float)));
-
- data->ofile->setFrameBuffer (frameBuffer);
- data->ofile->writePixels (data->height);
-
+ if(data->channels.first) {
+ for(echan= (ExrChannel *)data->channels.first; echan; echan= echan->next)
+ frameBuffer.insert (echan->name, Slice (FLOAT, (char *)echan->rect,
+ echan->xstride*sizeof(float), echan->ystride*sizeof(float)));
+
+ data->ofile->setFrameBuffer (frameBuffer);
+ data->ofile->writePixels (data->height);
+ }
+ else {
+ printf("Error: attempt to save MultiLayer without layers.\n");
+ }
}
void IMB_exr_read_channels(void *handle)
@@ -861,6 +865,7 @@ static const char *exr_rgba_channelname(InputFile *file, const char *chan)
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i)
{
+ /* const Channel &channel = i.channel(); */ /* Not used yet */
const char *str= i.name();
int len= strlen(str);
if(len) {
diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c
index c04987b3e71..732c06907df 100644
--- a/source/blender/imbuf/intern/rotate.c
+++ b/source/blender/imbuf/intern/rotate.c
@@ -30,6 +30,7 @@
*/
#include "BLI_blenlib.h"
+#include "BKE_utildefines.h"
#include "imbuf.h"
#include "imbuf_patch.h"
@@ -94,7 +95,6 @@ void IMB_flipy(struct ImBuf * ibuf)
void IMB_flipx(struct ImBuf * ibuf)
{
short x, y, xr, xl, yi;
- unsigned int px;
float px_f[4];
if (ibuf == NULL) return;
@@ -105,9 +105,7 @@ void IMB_flipx(struct ImBuf * ibuf)
if (ibuf->rect) {
for(yi=y-1;yi>=0;yi--) {
for(xr=x-1, xl=0; xr>=xl; xr--, xl++) {
- px = ibuf->rect[(x*yi)+xr];
- ibuf->rect[(x*yi)+xr] = ibuf->rect[(x*yi)+xl];
- ibuf->rect[(x*yi)+xl] = px;
+ SWAP(unsigned int, ibuf->rect[(x*yi)+xr], ibuf->rect[(x*yi)+xl]);
}
}
}
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 807b0c84e90..1ccdad05deb 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -596,12 +596,12 @@ static void shrink_picture_byte(
y_counter = 65536;
for (y_src = 0; y_src < src_height; y_src++) {
unsigned char* line = src + y_src * 4 * src_width;
- uintptr_t weight1y = 65536 - (y_dst & 0xffff);
- uintptr_t weight2y = 65536 - weight1y;
+ uintptr_t weight1y = 65535 - (y_dst & 0xffff);
+ uintptr_t weight2y = 65535 - weight1y;
x_dst = 0;
for (x_src = 0; x_src < src_width; x_src++) {
- uintptr_t weight1x = 65536 - (x_dst & 0xffff);
- uintptr_t weight2x = 65536 - weight1x;
+ uintptr_t weight1x = 65535 - (x_dst & 0xffff);
+ uintptr_t weight2x = 65535 - weight1x;
uintptr_t x = x_dst >> 16;
@@ -609,34 +609,35 @@ static void shrink_picture_byte(
w = (weight1y * weight1x) >> 16;
- dst_line1[x].r += (line[0] * w) >> 16;
- dst_line1[x].g += (line[1] * w) >> 16;
- dst_line1[x].b += (line[2] * w) >> 16;
- dst_line1[x].a += (line[3] * w) >> 16;
+ /* ensure correct rounding, without this you get ugly banding, or too low color values (ton) */
+ dst_line1[x].r += (line[0] * w + 32767) >> 16;
+ dst_line1[x].g += (line[1] * w + 32767) >> 16;
+ dst_line1[x].b += (line[2] * w + 32767) >> 16;
+ dst_line1[x].a += (line[3] * w + 32767) >> 16;
dst_line1[x].weight += w;
w = (weight2y * weight1x) >> 16;
- dst_line2[x].r += (line[0] * w) >> 16;
- dst_line2[x].g += (line[1] * w) >> 16;
- dst_line2[x].b += (line[2] * w) >> 16;
- dst_line2[x].a += (line[3] * w) >> 16;
+ dst_line2[x].r += (line[0] * w + 32767) >> 16;
+ dst_line2[x].g += (line[1] * w + 32767) >> 16;
+ dst_line2[x].b += (line[2] * w + 32767) >> 16;
+ dst_line2[x].a += (line[3] * w + 32767) >> 16;
dst_line2[x].weight += w;
w = (weight1y * weight2x) >> 16;
- dst_line1[x+1].r += (line[0] * w) >> 16;
- dst_line1[x+1].g += (line[1] * w) >> 16;
- dst_line1[x+1].b += (line[2] * w) >> 16;
- dst_line1[x+1].a += (line[3] * w) >> 16;
+ dst_line1[x+1].r += (line[0] * w + 32767) >> 16;
+ dst_line1[x+1].g += (line[1] * w + 32767) >> 16;
+ dst_line1[x+1].b += (line[2] * w + 32767) >> 16;
+ dst_line1[x+1].a += (line[3] * w + 32767) >> 16;
dst_line1[x+1].weight += w;
w = (weight2y * weight2x) >> 16;
- dst_line2[x+1].r += (line[0] * w) >> 16;
- dst_line2[x+1].g += (line[1] * w) >> 16;
- dst_line2[x+1].b += (line[2] * w) >> 16;
- dst_line2[x+1].a += (line[3] * w) >> 16;
+ dst_line2[x+1].r += (line[0] * w + 32767) >> 16;
+ dst_line2[x+1].g += (line[1] * w + 32767) >> 16;
+ dst_line2[x+1].b += (line[2] * w + 32767) >> 16;
+ dst_line2[x+1].a += (line[3] * w + 32767) >> 16;
dst_line2[x+1].weight += w;
x_dst += dx_dst;
@@ -646,18 +647,18 @@ static void shrink_picture_byte(
y_dst += dy_dst;
y_counter -= dy_dst;
if (y_counter < 0) {
+ int val;
uintptr_t x;
struct scale_outpix_byte * temp;
y_counter += 65536;
for (x=0; x < dst_width; x++) {
- uintptr_t f = 0x80000000UL
- / dst_line1[x].weight;
- *dst++ = (dst_line1[x].r * f) >> 15;
- *dst++ = (dst_line1[x].g * f) >> 15;
- *dst++ = (dst_line1[x].b * f) >> 15;
- *dst++ = (dst_line1[x].a * f) >> 15;
+ uintptr_t f = 0x80000000UL / dst_line1[x].weight;
+ *dst++ = (val= (dst_line1[x].r * f) >> 15) > 255 ? 255: val;
+ *dst++ = (val= (dst_line1[x].g * f) >> 15) > 255 ? 255: val;
+ *dst++ = (val= (dst_line1[x].b * f) >> 15) > 255 ? 255: val;
+ *dst++ = (val= (dst_line1[x].a * f) >> 15) > 255 ? 255: val;
}
memset(dst_line1, 0, dst_width *
sizeof(struct scale_outpix_byte));
@@ -667,13 +668,14 @@ static void shrink_picture_byte(
}
}
if (dst - dst_begin < dst_width * dst_height * 4) {
+ int val;
uintptr_t x;
for (x = 0; x < dst_width; x++) {
uintptr_t f = 0x80000000UL / dst_line1[x].weight;
- *dst++ = (dst_line1[x].r * f) >> 15;
- *dst++ = (dst_line1[x].g * f) >> 15;
- *dst++ = (dst_line1[x].b * f) >> 15;
- *dst++ = (dst_line1[x].a * f) >> 15;
+ *dst++ = (val= (dst_line1[x].r * f) >> 15) > 255 ? 255: val;
+ *dst++ = (val= (dst_line1[x].g * f) >> 15) > 255 ? 255: val;
+ *dst++ = (val= (dst_line1[x].b * f) >> 15) > 255 ? 255: val;
+ *dst++ = (val= (dst_line1[x].a * f) >> 15) > 255 ? 255: val;
}
}
MEM_freeN(dst_line1);
@@ -911,6 +913,8 @@ static void q_scale_float(float* in, float* out, int in_width,
Should be comparable in speed to the ImBuf ..._fast functions at least
for byte-buffers.
+ NOTE: disabled, due to inacceptable inaccuracy and quality loss, see bug #18609 (ton)
+
*/
static int q_scale_linear_interpolation(
struct ImBuf *ibuf, int newx, int newy)
@@ -1583,7 +1587,8 @@ struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, short newx, short newy)
scalefast_Z_ImBuf(ibuf, newx, newy);
/* try to scale common cases in a fast way */
- if (q_scale_linear_interpolation(ibuf, newx, newy)) {
+ /* disabled, quality loss is inacceptable, see report #18609 (ton) */
+ if (0 && q_scale_linear_interpolation(ibuf, newx, newy)) {
return ibuf;
}
diff --git a/source/blender/makesdna/CMakeLists.txt b/source/blender/makesdna/CMakeLists.txt
index a1afa37e5e6..1f8ab831ba6 100644
--- a/source/blender/makesdna/CMakeLists.txt
+++ b/source/blender/makesdna/CMakeLists.txt
@@ -24,4 +24,4 @@
#
# ***** END GPL LICENSE BLOCK *****
-SUBDIRS(intern)
+ADD_SUBDIRECTORY(intern)
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index aeabae42adf..f713b4a8acc 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -107,6 +107,7 @@ typedef struct bObjectActuator {
float loc[3], rot[3];
float dloc[3], drot[3];
float linearvelocity[3], angularvelocity[3];
+ struct Object *reference;
} bObjectActuator;
typedef struct bIpoActuator {
@@ -214,7 +215,8 @@ typedef struct bTwoDFilterActuator{
}bTwoDFilterActuator;
typedef struct bParentActuator {
- char pad[4];
+ char pad[2];
+ short flag;
int type;
struct Object *ob;
} bParentActuator;
@@ -482,6 +484,11 @@ typedef struct FreeCamera {
/* parentactuator->type */
#define ACT_PARENT_SET 0
#define ACT_PARENT_REMOVE 1
+
+/* parentactuator->flag */
+#define ACT_PARENT_COMPOUND 1
+#define ACT_PARENT_GHOST 2
+
#endif
diff --git a/source/blender/makesdna/DNA_controller_types.h b/source/blender/makesdna/DNA_controller_types.h
index 376f95b0145..599bbf9653a 100644
--- a/source/blender/makesdna/DNA_controller_types.h
+++ b/source/blender/makesdna/DNA_controller_types.h
@@ -43,6 +43,9 @@ typedef struct bExpressionCont {
typedef struct bPythonCont {
struct Text *text;
+ char module[64];
+ int mode;
+ int flag; /* only used for debug now */
} bPythonCont;
typedef struct bController {
@@ -76,6 +79,10 @@ typedef struct bController {
#define CONT_DEL 2
#define CONT_NEW 4
#define CONT_MASK 8
+#define CONT_PRIO 16
+
+/* pyctrl->flag */
+#define CONT_PY_DEBUG 1
#endif
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 49435000820..718d1a17834 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -69,7 +69,7 @@ typedef struct PartDeflect {
struct Tex *tex; /* Texture of the texture effector */
struct RNG *rng; /* random noise generator for e.g. wind */
float f_noise; /* noise of force (currently used for wind) */
- int pad;
+ int seed; /* wind noise random seed */
} PartDeflect;
typedef struct PointCache {
@@ -119,7 +119,8 @@ typedef struct BulletSoftBody {
float kAHR; /* Anchors hardness [0,1] */
int collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
int numclusteriterations; /* number of iterations to refine collision clusters*/
-
+ float welding; /* welding limit to remove duplicate/nearby vertices, 0.0..0.01 */
+ float margin; /* margin specific to softbody */
} BulletSoftBody;
/* BulletSoftBody.flag */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 60ca659c19c..febf2fe59cd 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -161,7 +161,7 @@ typedef struct Object {
float margin;
float max_vel; /* clamp the maximum velocity 0.0 is disabled */
float min_vel; /* clamp the maximum velocity 0.0 is disabled */
- float pad3; /* clamp the maximum velocity 0.0 is disabled */
+ float m_contactProcessingThreshold;
char dt, dtx;
char totcol; /* copy of mesh or curve or meta */
@@ -427,6 +427,7 @@ extern Object workob;
#define OB_COLLISION 65536
#define OB_SOFT_BODY 0x20000
#define OB_OCCLUDER 0x40000
+#define OB_SENSOR 0x80000
/* ob->gameflag2 */
#define OB_NEVER_DO_ACTIVITY_CULLING 1
@@ -446,6 +447,7 @@ extern Object workob;
#define OB_BODY_TYPE_RIGID 3
#define OB_BODY_TYPE_SOFT 4
#define OB_BODY_TYPE_OCCLUDER 5
+#define OB_BODY_TYPE_SENSOR 6
/* ob->scavisflag */
#define OB_VIS_SENS 1
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 6f88a98fee8..7391201776e 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -320,9 +320,9 @@ typedef struct RenderData {
/* Dome variables */
short domeres, domemode;
- short domeangle, pad9;
- float domesize;
+ short domeangle, dometilt;
float domeresbuf;
+ float pad2;
struct Text *dometext;
} RenderData;
@@ -679,6 +679,7 @@ typedef struct Scene {
#define R_STAMP_INFO 0x4000
#define R_FULL_SAMPLE 0x8000
#define R_COMP_RERENDER 0x10000
+#define R_RECURS_PROTECTION 0x20000
/* r->stamp */
#define R_STAMP_TIME 0x0001
@@ -762,7 +763,7 @@ typedef struct Scene {
#define MAXFRAMEF 300000.0f
#define MINFRAME 1
-#define MINFRAMEF 1.0
+#define MINFRAMEF 1.0f
/* depricate this! */
#define TESTBASE(v3d, base) ( ((base)->flag & SELECT) && ((base)->lay & v3d->lay) && (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) )
@@ -835,6 +836,7 @@ typedef struct Scene {
/* return flag next_object function */
+#define F_ERROR -1
#define F_START 0
#define F_SCENE 1
#define F_SET 2
diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h
index 7a358ad0694..8b29ce1338d 100644
--- a/source/blender/makesdna/DNA_sensor_types.h
+++ b/source/blender/makesdna/DNA_sensor_types.h
@@ -158,7 +158,8 @@ typedef struct bSensor {
/* just add here, to avoid align errors... */
short invert; /* Whether or not to invert the output. */
short level; /* Whether the sensor is level base (edge by default) */
- int pad;
+ short tap;
+ short pad;
} bSensor;
typedef struct bJoystickSensor {
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index a5a25adf37b..7fa26aa7572 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -78,6 +78,8 @@ typedef struct StripColorBalance {
typedef struct StripProxy {
char dir[160];
+ char file[80];
+ struct anim *anim;
} StripProxy;
typedef struct Strip {
@@ -262,6 +264,7 @@ typedef struct SpeedControlVars {
#define SEQ_USE_CROP 131072
#define SEQ_USE_COLOR_BALANCE 262144
#define SEQ_USE_PROXY_CUSTOM_DIR 524288
+#define SEQ_USE_PROXY_CUSTOM_FILE 2097152
/* deprecated, dont use a flag anymore*/
/*#define SEQ_ACTIVE 1048576*/
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 1b58bced0eb..3864bcd0a21 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -155,7 +155,8 @@ typedef struct SpaceSeq {
View2D v2d; /* depricated, copied to region */
float xof, yof; /* offset for drawing the image preview */
- short mainb, pad;
+ short mainb;
+ short render_size;
short chanshown;
short zebra;
int flag;
@@ -344,7 +345,8 @@ typedef struct SpaceNode {
float mx, my; /* mousepos for drawing socketless link */
struct bNodeTree *nodetree, *edittree;
- int treetype, pad; /* treetype: as same nodetree->type */
+ int treetype; /* treetype: as same nodetree->type */
+ short texfrom, pad; /* texfrom object, world or brush */
struct bGPdata *gpd; /* grease-pencil data */
} SpaceNode;
@@ -353,6 +355,11 @@ typedef struct SpaceNode {
#define SNODE_BACKDRAW 2
#define SNODE_DISPGP 4
+/* snode->texfrom */
+#define SNODE_TEX_OBJECT 0
+#define SNODE_TEX_WORLD 1
+#define SNODE_TEX_BRUSH 2
+
typedef struct SpaceImaSel {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index 8216a0fb800..608a4ca982e 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -92,6 +92,7 @@ typedef struct World {
short mode;
short occlusionRes; /* resolution of occlusion Z buffer in pixel */
short physicsEngine; /* here it's aligned */
+ short ticrate, maxlogicstep, physubstep, maxphystep;
float misi, miststa, mistdist, misthi;
diff --git a/source/blender/makesrna/CMakeLists.txt b/source/blender/makesrna/CMakeLists.txt
index 879ebccc223..75f79fbdc3b 100644
--- a/source/blender/makesrna/CMakeLists.txt
+++ b/source/blender/makesrna/CMakeLists.txt
@@ -24,4 +24,4 @@
#
# ***** END GPL LICENSE BLOCK *****
-SUBDIRS(intern)
+ADD_SUBDIRECTORY(intern)
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 5145522a544..deda1a15b70 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -656,8 +656,8 @@ void RNA_enum_set(PointerRNA *ptr, const char *name, int value);
int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname);
/* lower level functions that donr use a PointerRNA */
-int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value);
-int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier);
+int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *value);
+int RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **identifier);
void RNA_string_get(PointerRNA *ptr, const char *name, char *value);
char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index c8037c1553a..870fa4d9aa3 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -2032,7 +2032,7 @@ int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname)
}
}
-int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value)
+int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *value)
{
for( ; item->identifier; item++) {
if(strcmp(item->identifier, identifier)==0) {
@@ -2044,7 +2044,7 @@ int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *
return 0;
}
-int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier)
+int RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **identifier)
{
for( ; item->identifier; item++) {
if(item->value==value) {
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index d0730cd7bb0..a98bc41d129 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -904,8 +904,8 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna)
static EnumPropertyItem pivot_items[] = {
{CONSTRAINT_RB_BALL, "BALL", "Ball", ""},
{CONSTRAINT_RB_HINGE, "HINGE", "Hinge", ""},
- {CONSTRAINT_RB_CONETWIST, "CONETWIST", "Cone Twist", ""},
- {CONSTRAINT_RB_GENERIC6DOF, "GENERIC", "Generic 6 DoF", ""},
+ {CONSTRAINT_RB_CONETWIST, "CONE_TWIST", "Cone Twist", ""},
+ {CONSTRAINT_RB_GENERIC6DOF, "GENERIC_6_DOF", "Generic 6 DoF", ""},
{0, NULL, NULL, NULL}};
srna= RNA_def_struct(brna, "RigidBodyJointConstraint", "Constraint");
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index dcdd749be6e..08eca7b0528 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -976,12 +976,12 @@ static StructRNA *rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sf");
RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF);
- RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for ipo's and dupligroup instances.");
+ RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for IPO's and dupligroup instances.");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
prop= RNA_def_property(srna, "time_offset_edit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_OB);
- RNA_def_property_ui_text(prop, "Time Offset Edit", "Use time offset when inserting keys and display time offset for ipo and action views.");
+ RNA_def_property_ui_text(prop, "Time Offset Edit", "Use time offset when inserting keys and display time offset for IPO and action views.");
prop= RNA_def_property(srna, "time_offset_parent", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENT);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index afa45834eb0..4f4530e0424 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -233,6 +233,10 @@ static void rna_def_field(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Noise", "Noise of the wind force");
+ prop= RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_range(prop, 1, 128);
+ RNA_def_property_ui_text(prop, "Seed", "Seed of the wind noise");
+
/* Boolean */
prop= RNA_def_property(srna, "use_min_distance", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c b/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c
index 846aec490c2..15f3148b54c 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c
@@ -55,6 +55,7 @@ static void do_normalize(bNode *node, float *out, float *src, float *min, float
}
}
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
#define BLENDER_ZMAX 10000.0f
static void node_composit_exec_normalize(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
@@ -63,7 +64,7 @@ static void node_composit_exec_normalize(void *data, bNode *node, bNodeStack **i
/* stack order out: valbuf */
if(out[0]->hasoutput==0) return;
- /* input no image? then only value operation */
+ /* Input has no image buffer? Then pass the value */
if(in[0]->data==NULL) {
QUATCOPY(out[0]->vec, in[0]->vec);
}
@@ -78,18 +79,20 @@ static void node_composit_exec_normalize(void *data, bNode *node, bNodeStack **i
CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); /* allocs */
for (val = cbuf->rect; tot; tot--, val++) {
- if ((*val > max) && (*val < BLENDER_ZMAX)) {
+ if ((*val > max) && (*val <= BLENDER_ZMAX)) {
max = *val;
}
- if (*val < min) {
+ if ((*val < min) && (*val >= -BLENDER_ZMAX)) {
min = *val;
}
}
- mult = 1.0f/(max-min);
-
- printf("min %f max %f\n", min, max);
-
- composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, NULL, &min, NULL, &mult, do_normalize, CB_VAL, CB_VAL, CB_VAL);
+ /* In the rare case of flat buffer, which would cause a divide by 0, just pass the input to the output */
+ if ((max-min) != 0.0f) {
+ mult = 1.0f/(max-min);
+ composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, NULL, &min, NULL, &mult, do_normalize, CB_VAL, CB_VAL, CB_VAL);
+ } else {
+ memcpy(stackbuf->rect, cbuf->rect, sizeof(float) * cbuf->x * cbuf->y);
+ }
out[0]->data= stackbuf;
}
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_scale.c b/source/blender/nodes/intern/CMP_nodes/CMP_scale.c
index cc6f9249495..ee3607c11f6 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_scale.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_scale.c
@@ -65,8 +65,8 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b
newx = cbuf->x * (rd->size / 100.0f);
newy = cbuf->y * (rd->size / 100.0f);
} else { /* CMP_SCALE_ABSOLUTE */
- newx= (int)in[1]->vec[0];
- newy= (int)in[2]->vec[0];
+ newx= MAX2((int)in[1]->vec[0], 1);
+ newy= MAX2((int)in[2]->vec[0], 1);
}
newx= MIN2(newx, CMP_SCALE_MAX);
newy= MIN2(newy, CMP_SCALE_MAX);
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
index fedca8f9086..fbc56dfcc83 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
@@ -33,6 +33,11 @@
#include <eval.h>
#endif
+/* TODO, support python3.x */
+#if PY_VERSION_HEX >= 0x03000000
+#define DISABLE_PYTHON 1
+#endif
+
#include "DNA_text_types.h"
#include "BKE_text.h"
#include "BKE_utildefines.h"
@@ -56,13 +61,15 @@ static void node_dynamic_free_storage_cb(bNode *node);
#ifndef DISABLE_PYTHON
static PyObject *init_dynamicdict(void) {
- PyObject *newscriptdict;
+ PyObject *newscriptdict, *item;
PyGILState_STATE gilstate = PyGILState_Ensure();
newscriptdict= PyDict_New();
PyDict_SetItemString(newscriptdict, "__builtins__", PyEval_GetBuiltins());
- EXPP_dict_set_item_str(newscriptdict, "__name__", PyString_FromString("__main__"));
+ item= PyString_FromString("__main__");
+ PyDict_SetItemString(newscriptdict, "__name__", item);
+ Py_DECREF(item);
PyGILState_Release(gilstate);
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_material.c b/source/blender/nodes/intern/SHD_nodes/SHD_material.c
index c0a2534ac4a..69c2c0a345c 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_material.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_material.c
@@ -130,7 +130,9 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in,
nodestack_get_vec(&shi->translucency, SOCK_VALUE, in[MAT_IN_TRANSLUCENCY]);
}
+ shi->nodes= 1; /* temp hack to prevent trashadow recursion */
node_shader_lamp_loop(shi, &shrnode); /* clears shrnode */
+ shi->nodes= 0;
/* write to outputs */
if(node->custom1 & SH_NODE_MAT_DIFF) {
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_math.c b/source/blender/nodes/intern/SHD_nodes/SHD_math.c
index 050c2cdcc95..645f95686d7 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_math.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_math.c
@@ -197,7 +197,7 @@ bNodeStack **out)
static int gpu_shader_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
static char *names[] = {"math_add", "math_subtract", "math_multiply",
- "math_divide", "math_sine", "math_cosine", "math_tangnet", "math_asin",
+ "math_divide", "math_sine", "math_cosine", "math_tangent", "math_asin",
"math_acos", "math_atan", "math_pow", "math_log", "math_min", "math_max",
"math_round", "math_less_than", "math_greater_than"};
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c b/source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c
index 96db8db18a6..8a73a318f70 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c
@@ -101,7 +101,7 @@ static void node_shader_exec_vect_math(void *data, bNode *node, bNodeStack **in,
static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
- static char *names[] = {"vec_math_add", "vec_math_subtract",
+ static char *names[] = {"vec_math_add", "vec_math_sub",
"vec_math_average", "vec_math_dot", "vec_math_cross",
"vec_math_normalize"};
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
index c9fa3528b02..80cbd6188ee 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
@@ -49,12 +49,21 @@ static void init(bNode *node) {
node->custom4 = 1.0; /* squash */
}
+static float noise(int n) /* fast integer noise */
+{
+ int nn;
+ n = (n >> 13) ^ n;
+ nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
+ return 0.5f * ((float)nn / 1073741824.0f);
+}
+
static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
{
float x = coord[0];
float y = coord[1];
- float bricknum, rownum, offset = 0;
+ int bricknum, rownum;
+ float offset = 0;
float ins_x, ins_y;
float tint;
@@ -71,20 +80,19 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor
tex_input_rgba(bricks2, in[1], coord, thread);
tex_input_rgba(mortar, in[2], coord, thread);
- rownum = floor(y / row_height);
+ rownum = (int)floor(y / row_height);
if( node->custom1 && node->custom2 ) {
brick_width *= ((int)(rownum) % node->custom2 ) ? 1.0f : node->custom4; /* squash */
offset = ((int)(rownum) % node->custom1 ) ? 0 : (brick_width*node->custom3); /* offset */
}
- bricknum = floor((x+offset) / brick_width);
+ bricknum = (int)floor((x+offset) / brick_width);
ins_x = (x+offset) - brick_width*bricknum;
ins_y = y - row_height*rownum;
- srand( (123456*rownum) + bricknum );
- tint = rand() / (float)RAND_MAX + bias;
+ tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias;
CLAMP(tint,0.0f,1.0f);
if( ins_x < mortar_thickness || ins_y < mortar_thickness ||
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c
index 0e903301789..cadd27612f4 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c
@@ -31,7 +31,7 @@
static bNodeSocketType inputs[]= {
{ SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { SOCK_VECTOR, 1, "Offset", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f },
+ { SOCK_VECTOR, 1, "Offset", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f },
{ -1, 0, "" }
};
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 2cee2673a26..0ad48fe97a9 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -171,6 +171,7 @@ typedef struct ShadeInput
/* from initialize, part or renderlayer */
short do_preview; /* for nodes, in previewrender */
short thread, sample; /* sample: ShadeSample array index */
+ short nodes; /* indicate node shading, temp hack to prevent recursion */
unsigned int lay;
int layflag, passflag, combinedflag;
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 996bf2c3b19..199ff5dbb43 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -1760,7 +1760,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(parent->num < psmd->dm->getNumFaces(psmd->dm))
num = parent->num;
- get_particle_uvco_mcol(part->from, psmd->dm, pa->fuv, num, &sd);
+ get_particle_uvco_mcol(part->from, psmd->dm, parent->fuv, num, &sd);
}
dosimplify = psys_render_simplify_params(psys, cpa, simplify);
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index c75de189b10..1cbf2523156 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -1633,7 +1633,7 @@ void sample_occ(Render *re, ShadeInput *shi)
sample_occ_surface(shi);
}
/* try to get result from the cache if possible */
- else if(!sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao)) {
+ else if(shi->depth!=0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao)) {
/* no luck, let's sample the occlusion */
exclude.obi= shi->obi - re->objectinstance;
exclude.facenr= shi->vlr->index;
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index e464cbd1f43..07560edb76b 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1667,6 +1667,42 @@ static void do_render_3d(Render *re)
RE_Database_Free(re);
}
+/* called by blur loop, accumulate RGBA key alpha */
+static void addblur_rect_key(RenderResult *rr, float *rectf, float *rectf1, float blurfac)
+{
+ float mfac= 1.0f - blurfac;
+ int a, b, stride= 4*rr->rectx;
+ int len= stride*sizeof(float);
+
+ for(a=0; a<rr->recty; a++) {
+ if(blurfac==1.0f) {
+ memcpy(rectf, rectf1, len);
+ }
+ else {
+ float *rf= rectf, *rf1= rectf1;
+
+ for( b= rr->rectx; b>0; b--, rf+=4, rf1+=4) {
+ if(rf1[3]<0.01f)
+ rf[3]= mfac*rf[3];
+ else if(rf[3]<0.01f) {
+ rf[0]= rf1[0];
+ rf[1]= rf1[1];
+ rf[2]= rf1[2];
+ rf[3]= blurfac*rf1[3];
+ }
+ else {
+ rf[0]= mfac*rf[0] + blurfac*rf1[0];
+ rf[1]= mfac*rf[1] + blurfac*rf1[1];
+ rf[2]= mfac*rf[2] + blurfac*rf1[2];
+ rf[3]= mfac*rf[3] + blurfac*rf1[3];
+ }
+ }
+ }
+ rectf+= stride;
+ rectf1+= stride;
+ }
+}
+
/* called by blur loop, accumulate renderlayers */
static void addblur_rect(RenderResult *rr, float *rectf, float *rectf1, float blurfac, int channels)
{
@@ -1690,8 +1726,9 @@ static void addblur_rect(RenderResult *rr, float *rectf, float *rectf1, float bl
}
}
+
/* called by blur loop, accumulate renderlayers */
-static void merge_renderresult_blur(RenderResult *rr, RenderResult *brr, float blurfac)
+static void merge_renderresult_blur(RenderResult *rr, RenderResult *brr, float blurfac, int key_alpha)
{
RenderLayer *rl, *rl1;
RenderPass *rpass, *rpass1;
@@ -1700,8 +1737,12 @@ static void merge_renderresult_blur(RenderResult *rr, RenderResult *brr, float b
for(rl= rr->layers.first; rl && rl1; rl= rl->next, rl1= rl1->next) {
/* combined */
- if(rl->rectf && rl1->rectf)
- addblur_rect(rr, rl->rectf, rl1->rectf, blurfac, 4);
+ if(rl->rectf && rl1->rectf) {
+ if(key_alpha)
+ addblur_rect_key(rr, rl->rectf, rl1->rectf, blurfac);
+ else
+ addblur_rect(rr, rl->rectf, rl1->rectf, blurfac, 4);
+ }
/* passes are allocated in sync */
rpass1= rl1->passes.first;
@@ -1731,7 +1772,7 @@ static void do_render_blur_3d(Render *re)
blurfac= 1.0f/(float)(re->r.osa-blur);
- merge_renderresult_blur(rres, re->result, blurfac);
+ merge_renderresult_blur(rres, re->result, blurfac, re->r.alphamode & R_ALPHAKEY);
if(re->test_break(re->tbh)) break;
}
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index e89cf20e4b1..33b58cf9751 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -262,13 +262,15 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
shade_input_set_shade_texco(shi);
- if(is->mode==RE_RAY_SHADOW_TRA)
- if(shi->mat->nodetree && shi->mat->use_nodes) {
+ if(is->mode==RE_RAY_SHADOW_TRA) {
+ /* temp hack to prevent recursion */
+ if(shi->nodes==0 && shi->mat->nodetree && shi->mat->use_nodes) {
ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
shi->mat= vlr->mat; /* shi->mat is being set in nodetree */
}
else
shade_color(shi, shr);
+ }
else {
if(shi->mat->nodetree && shi->mat->use_nodes) {
ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
@@ -1273,7 +1275,7 @@ static void addAlphaLight(float *shadfac, float *col, float alpha, float filter)
shadfac[3]= (1.0f-alpha)*shadfac[3];
}
-static void ray_trace_shadow_tra(Isect *is, int depth, int traflag)
+static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int traflag)
{
/* ray to lamp, find first face that intersects, check alpha properties,
if it has col[3]>0.0f continue. so exit when alpha is full */
@@ -1290,16 +1292,15 @@ static void ray_trace_shadow_tra(Isect *is, int depth, int traflag)
/* end warning! - Campbell */
shi.depth= 1; /* only used to indicate tracing */
- shi.mask= 1;
-
- /*shi.osatex= 0;
- shi.thread= shi.sample= 0;
- shi.lay= 0;
- shi.passflag= 0;
- shi.combinedflag= 0;
- shi.do_preview= 0;
- shi.light_override= NULL;
- shi.mat_override= NULL;*/
+ shi.mask= origshi->mask;
+ shi.thread= origshi->thread;
+ shi.passflag= SCE_PASS_COMBINED;
+ shi.combinedflag= 0xFFFFFF; /* ray trace does all options */
+
+ shi.xs= origshi->xs;
+ shi.ys= origshi->ys;
+ shi.lay= origshi->lay;
+ shi.nodes= origshi->nodes;
shade_ray(is, &shi, &shr);
if (traflag & RAY_TRA)
@@ -1315,7 +1316,7 @@ static void ray_trace_shadow_tra(Isect *is, int depth, int traflag)
is->oborig= RAY_OBJECT_SET(&R, shi.obi);
is->faceorig= (RayFace*)shi.vlr;
- ray_trace_shadow_tra(is, depth-1, traflag | RAY_TRA);
+ ray_trace_shadow_tra(is, origshi, depth-1, traflag | RAY_TRA);
}
}
}
@@ -1943,7 +1944,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float *
isec->col[0]= isec->col[1]= isec->col[2]= 1.0f;
isec->col[3]= 1.0f;
- ray_trace_shadow_tra(isec, DEPTH_SHADOW_TRA, 0);
+ ray_trace_shadow_tra(isec, shi, DEPTH_SHADOW_TRA, 0);
shadfac[0] += isec->col[0];
shadfac[1] += isec->col[1];
shadfac[2] += isec->col[2];
@@ -2041,7 +2042,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, float *lampco, floa
isec->col[0]= isec->col[1]= isec->col[2]= 1.0f;
isec->col[3]= 1.0f;
- ray_trace_shadow_tra(isec, DEPTH_SHADOW_TRA, 0);
+ ray_trace_shadow_tra(isec, shi, DEPTH_SHADOW_TRA, 0);
shadfac[0] += isec->col[0];
shadfac[1] += isec->col[1];
shadfac[2] += isec->col[2];
@@ -2122,7 +2123,7 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac)
isec.col[0]= isec.col[1]= isec.col[2]= 1.0f;
isec.col[3]= 1.0f;
- ray_trace_shadow_tra(&isec, DEPTH_SHADOW_TRA, 0);
+ ray_trace_shadow_tra(&isec, shi, DEPTH_SHADOW_TRA, 0);
QUATCOPY(shadfac, isec.col);
}
else if(RE_ray_tree_intersect(R.raytree, &isec)) shadfac[3]= 0.0f;
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 27dd43a4ef9..165cb88de71 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -2542,8 +2542,12 @@ static void shade_tface(BakeShade *bs)
/* get pixel level vertex coordinates */
for(a=0; a<4; a++) {
- vec[a][0]= tface->uv[a][0]*(float)bs->rectx - 0.5f;
- vec[a][1]= tface->uv[a][1]*(float)bs->recty - 0.5f;
+ /* Note, workaround for pixel aligned UVs which are common and can screw up our intersection tests
+ * where a pixel gets inbetween 2 faces or the middle of a quad,
+ * camera aligned quads also have this problem but they are less common.
+ * Add a small offset to the UVs, fixes bug #18685 - Campbell */
+ vec[a][0]= tface->uv[a][0]*(float)bs->rectx - (0.5f + 0.001);
+ vec[a][1]= tface->uv[a][1]*(float)bs->recty - (0.5f + 0.002);
}
/* UV indices have to be corrected for possible quad->tria splits */
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
index 4c627056c1d..130cda9f107 100644
--- a/source/blender/render/intern/source/shadeoutput.c
+++ b/source/blender/render/intern/source/shadeoutput.c
@@ -1005,6 +1005,7 @@ static void do_specular_ramp(ShadeInput *shi, float is, float t, float *spec)
}
/* pure AO, check for raytrace and world should have been done */
+/* preprocess, textures were not done, don't use shi->amb for that reason */
void ambient_occlusion(ShadeInput *shi)
{
if((R.wrld.ao_gather_method == WO_AOGATHER_APPROX) && shi->mat->amb!=0.0f)
@@ -1020,8 +1021,8 @@ void ambient_occlusion(ShadeInput *shi)
void ambient_occlusion_to_diffuse(ShadeInput *shi, float *diff)
{
if((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX) {
- if(shi->mat->amb!=0.0f) {
- float f= R.wrld.aoenergy*shi->mat->amb;
+ if(shi->amb!=0.0f) {
+ float f= R.wrld.aoenergy*shi->amb;
if (R.wrld.aomix==WO_AOADDSUB) {
diff[0] = 2.0f*shi->ao[0]-1.0f;
diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c
index afe732d885b..16f876fdd38 100644
--- a/source/blender/render/intern/source/texture.c
+++ b/source/blender/render/intern/source/texture.c
@@ -2029,6 +2029,10 @@ void do_material_tex(ShadeInput *shi)
shi->amb= texture_value_blend(mtex->def_var, shi->amb, texres.tin, varfac, mtex->blendtype, flip);
if(shi->amb<0.0) shi->amb= 0.0;
else if(shi->amb>1.0) shi->amb= 1.0;
+
+ shi->ambr= shi->amb*R.wrld.ambr;
+ shi->ambg= shi->amb*R.wrld.ambg;
+ shi->ambb= shi->amb*R.wrld.ambb;
}
}
}
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 2c7493a51ab..627aebbe875 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -55,7 +55,12 @@ static GHOST_TStandardCursor convert_cursor(int curs)
case CURSOR_FACESEL: return GHOST_kStandardCursorRightArrow;
case CURSOR_WAIT: return GHOST_kStandardCursorWait;
case CURSOR_EDIT: return GHOST_kStandardCursorCrosshair;
- case CURSOR_HELP: return GHOST_kStandardCursorHelp;
+ case CURSOR_HELP:
+#ifdef __APPLE__
+ return GHOST_kStandardCursorLeftRight;
+#else
+ return GHOST_kStandardCursorHelp;
+#endif
case CURSOR_X_MOVE: return GHOST_kStandardCursorLeftRight;
case CURSOR_Y_MOVE: return GHOST_kStandardCursorUpDown;
case CURSOR_PENCIL: return GHOST_kStandardCursorPencil;
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index fe0f741bb96..221c0a92e09 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -180,14 +180,14 @@ IF(WIN32)
ADD_CUSTOM_COMMAND(TARGET blender
POST_BUILD
MAIN_DEPENDENCY blender
- COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-51.dll\" \"${TARGETDIR}\\\"
+ COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
- COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-49.dll\" \"${TARGETDIR}\\\"
+ COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\"
- COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-0.dll\" \"${TARGETDIR}\\\"
+ COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\"
COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\"
- COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-59.dll\" \"${TARGETDIR}\\\"
+ COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\"
COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\"
)
diff --git a/source/creator/buildinfo.c b/source/creator/buildinfo.c
index e25caa34f46..cef98915d79 100644
--- a/source/creator/buildinfo.c
+++ b/source/creator/buildinfo.c
@@ -33,11 +33,11 @@
#ifdef BUILD_DATE
#ifndef WIN32
-char * build_date=BUILD_DATE;
-char * build_time=BUILD_TIME;
-char * build_rev=BUILD_REV;
-char * build_platform=BUILD_PLATFORM;
-char * build_type=BUILD_TYPE;
+const char * build_date=BUILD_DATE;
+const char * build_time=BUILD_TIME;
+const char * build_rev=BUILD_REV;
+const char * build_platform=BUILD_PLATFORM;
+const char * build_type=BUILD_TYPE;
#else
#include "winbuildinfo.h"
#endif
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 2ac65f7a08a..5ffce91ec2d 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -497,6 +497,19 @@ int main(int argc, char **argv)
BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */
#ifndef DISABLE_SDL
+#if (defined(WIN32) || defined(WIN64))
+#if defined(FREE_WINDOWS)
+ putenv("SDL_VIDEODRIVER=dummy");
+#else
+ _putenv_s("SDL_VIDEODRIVER", "dummy");
+#endif
+#else
+#ifdef __sgi
+ putenv("SDL_VIDEODRIVER=dummy");
+#else
+ setenv("SDL_VIDEODRIVER", "dummy", 1); /* initializing the video driver can cause crashes on some systems - Campbell */
+#endif
+#endif
#ifdef __linux__
/* On linux the default SDL driver dma often would not play
* use alsa if none is set */
@@ -616,8 +629,10 @@ int main(int argc, char **argv)
Scene *scene= CTX_data_scene(C);
if (a < argc) {
- int frame= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
- Render *re= RE_NewRender(scene->id.name);
+ int frame = atoi(argv[a]);
+ Render *re = RE_NewRender(scene->id.name);
+
+ frame = MIN2(MAXFRAME, MAX2(1, frame));
#ifndef DISABLE_PYTHON
if (G.f & G_DOSCRIPTLINKS)
BPY_do_all_scripts(SCRIPT_RENDER, 0);
@@ -657,8 +672,10 @@ int main(int argc, char **argv)
a++;
if (CTX_data_scene(C)) {
Scene *scene= CTX_data_scene(C);
- int frame= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
- if (a < argc) (scene->r.sfra) = frame;
+ if (a < argc) {
+ int frame = atoi(argv[a]);
+ (scene->r.sfra) = MIN2(MAXFRAME, MAX2(1, frame));
+ }
} else {
printf("\nError: no blend loaded. cannot use '-s'.\n");
}
@@ -667,8 +684,10 @@ int main(int argc, char **argv)
a++;
if (CTX_data_scene(C)) {
Scene *scene= CTX_data_scene(C);
- int frame= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
- if (a < argc) (scene->r.efra) = frame;
+ if (a < argc) {
+ int frame = atoi(argv[a]);
+ (scene->r.efra) = MIN2(MAXFRAME, MAX2(1, frame));
+ }
} else {
printf("\nError: no blend loaded. cannot use '-e'.\n");
}
@@ -677,8 +696,10 @@ int main(int argc, char **argv)
a++;
if (CTX_data_scene(C)) {
Scene *scene= CTX_data_scene(C);
- int fstep= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
- if (a < argc) (scene->frame_step) = fstep;
+ if (a < argc) {
+ int frame = atoi(argv[a]);
+ (scene->frame_step) = MIN2(MAXFRAME, MAX2(1, frame));
+ }
} else {
printf("\nError: no blend loaded. cannot use '-j'.\n");
}
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index d8de24c610c..4ac28e36c48 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -129,6 +129,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
BLI_strncpy(oldsce, G.sce, sizeof(oldsce));
+ resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path
setGamePythonPath(G.sce);
// Acquire Python's GIL (global interpreter lock)
@@ -153,7 +154,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
bool game2ipo = (SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0);
bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
-
+ bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0);
// create the canvas, rasterizer and rendertools
RAS_ICanvas* canvas = new KX_BlenderCanvas(area);
canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
@@ -161,12 +162,12 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
RAS_IRasterizer* rasterizer = NULL;
if(displaylists) {
- if (GLEW_VERSION_1_1)
+ if (GLEW_VERSION_1_1 && !novertexarrays)
rasterizer = new RAS_ListRasterizer(canvas, true, true);
else
rasterizer = new RAS_ListRasterizer(canvas);
}
- else if (GLEW_VERSION_1_1)
+ else if (GLEW_VERSION_1_1 && !novertexarrays)
rasterizer = new RAS_VAOpenGLRasterizer(canvas, false);
else
rasterizer = new RAS_OpenGLRasterizer(canvas);
@@ -292,6 +293,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
if(blenderdata) {
BLI_strncpy(G.sce, blenderdata->name, sizeof(G.sce));
BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
+ setGamePythonPath(G.sce);
}
}
// else forget it, we can't find it
@@ -321,12 +323,11 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
{
int startFrame = blscene->r.cfra;
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);
}
-
-
- // Quad buffered needs a special window.
- if (blscene->r.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
- rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->r.stereomode);
if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
{
@@ -380,6 +381,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
initGameKeys();
initPythonConstraintBinding();
initMathutils();
+ initGeometry();
initBGL();
#ifdef WITH_FFMPEG
initVideoTexture();
@@ -387,7 +389,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
//initialize Dome Settings
if(blscene->r.stereomode == RAS_IRasterizer::RAS_STEREO_DOME)
- ketsjiengine->InitDome(blscene->r.domesize, blscene->r.domeres, blscene->r.domemode, blscene->r.domeangle, blscene->r.domeresbuf, blscene->r.dometext);
+ ketsjiengine->InitDome(blscene->r.domeres, blscene->r.domemode, blscene->r.domeangle, blscene->r.domeresbuf, blscene->r.dometilt, blscene->r.dometext);
if (sceneconverter)
{
@@ -684,6 +686,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
initGameKeys();
initPythonConstraintBinding();
initMathutils();
+ initGeometry();
initBGL();
#ifdef WITH_FFMPEG
initVideoTexture();
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
index 9dbda3f195b..17d1bf65ca4 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
@@ -68,8 +68,8 @@ void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty)
{
m_clientobject = NULL;
m_lastlightlayer = -1;
- m_lastlighting = false;
m_lastauxinfo = NULL;
+ m_lastlighting = true; /* force disable in DisableOpenGLLights() */
DisableOpenGLLights();
}
@@ -295,7 +295,7 @@ void KX_BlenderRenderTools::RenderText(
RAS_IPolyMaterial* polymat,
float v1[3], float v2[3], float v3[3], float v4[3], int glattrib)
{
- STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
+ const STR_String& mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
const unsigned int flag = polymat->GetFlag();
struct MTFace* tface = 0;
diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt
index 3ea788791e2..fd05858710d 100644
--- a/source/gameengine/CMakeLists.txt
+++ b/source/gameengine/CMakeLists.txt
@@ -24,25 +24,23 @@
#
# ***** END GPL LICENSE BLOCK *****
-SUBDIRS(
- BlenderRoutines
- Converter
- Expressions
- GameLogic
- Ketsji
- Ketsji/KXNetwork
- Network
- Network/LoopBackNetwork
- Physics/common
- Physics/Dummy
- Rasterizer
- Rasterizer/RAS_OpenGLRasterizer
- SceneGraph
- Physics/Bullet
- Physics/Sumo
- VideoTexture
-)
+ADD_SUBDIRECTORY(BlenderRoutines)
+ADD_SUBDIRECTORY(Converter)
+ADD_SUBDIRECTORY(Expressions)
+ADD_SUBDIRECTORY(GameLogic)
+ADD_SUBDIRECTORY(Ketsji)
+ADD_SUBDIRECTORY(Ketsji/KXNetwork)
+ADD_SUBDIRECTORY(Network)
+ADD_SUBDIRECTORY(Network/LoopBackNetwork)
+ADD_SUBDIRECTORY(Physics/common)
+ADD_SUBDIRECTORY(Physics/Dummy)
+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)
- SUBDIRS(GamePlayer)
+ ADD_SUBDIRECTORY(GamePlayer)
ENDIF(WITH_PLAYER)
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index 662d6b7a63e..e4dd588f06a 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -66,9 +66,9 @@ BL_ActionActuator::~BL_ActionActuator()
game_free_pose(m_blendpose);
}
-void BL_ActionActuator::ProcessReplica(){
-// bPose *oldpose = m_pose;
-// bPose *oldbpose = m_blendpose;
+void BL_ActionActuator::ProcessReplica()
+{
+ SCA_IActuator::ProcessReplica();
m_pose = NULL;
m_blendpose = NULL;
@@ -84,9 +84,6 @@ void BL_ActionActuator::SetBlendTime (float newtime){
CValue* BL_ActionActuator::GetReplica() {
BL_ActionActuator* replica = new BL_ActionActuator(*this);//m_float,GetName());
replica->ProcessReplica();
-
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
}
@@ -159,16 +156,9 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
// maybe there are events for us in the queue !
if (frame)
{
- for (vector<CValue*>::iterator i=m_events.begin(); !(i==m_events.end());i++)
- {
- if ((*i)->GetNumber() == 0.0f)
- bNegativeEvent = true;
- else
- bPositiveEvent= true;
- (*i)->Release();
-
- }
- m_events.clear();
+ bNegativeEvent = m_negevent;
+ bPositiveEvent = m_posevent;
+ RemoveAllEvents();
if (bPositiveEvent)
m_flag |= ACT_FLAG_ACTIVE;
@@ -945,8 +935,13 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
/* ------------------------------------------------------------------------- */
PyTypeObject BL_ActionActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"BL_ActionActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -1002,17 +997,17 @@ PyMethodDef BL_ActionActuator::Methods[] = {
};
PyAttributeDef BL_ActionActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
- KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
- KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
+ KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
+ KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
+ KX_PYATTRIBUTE_FLOAT_RW("blendIn", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ActionActuator, m_localtime, CheckFrame),
- KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ActionActuator, m_propname),
- KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ActionActuator, m_framepropname),
- KX_PYATTRIBUTE_BOOL_RW("continue", BL_ActionActuator, m_end_reset),
+ KX_PYATTRIBUTE_STRING_RW("propName", 0, 31, false, BL_ActionActuator, m_propname),
+ KX_PYATTRIBUTE_STRING_RW("framePropName", 0, 31, false, BL_ActionActuator, m_framepropname),
+ KX_PYATTRIBUTE_BOOL_RW("useContinue", BL_ActionActuator, m_end_reset),
KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
- KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType),
+ KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ActionActuator,m_playtype,CheckType),
{ NULL } //Sentinel
};
@@ -1020,6 +1015,10 @@ 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);
}
@@ -1038,7 +1037,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF
if (!PyString_Check(value))
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
- return -1;
+ return PY_SET_ATTR_FAIL;
}
bAction *action= NULL;
@@ -1050,11 +1049,11 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF
if (!action)
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
}
self->SetAction(action);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index 6ae7f716b4b..b3c15c08f50 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -114,6 +114,7 @@ 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);
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index 071cd50c506..6fc5c40d570 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -70,20 +70,17 @@ BL_ArmatureObject::BL_ArmatureObject(
CValue* BL_ArmatureObject::GetReplica()
{
BL_ArmatureObject* replica = new BL_ArmatureObject(*this);
-
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
- ProcessReplica(replica);
+ replica->ProcessReplica();
return replica;
}
-void BL_ArmatureObject::ProcessReplica(BL_ArmatureObject *replica)
+void BL_ArmatureObject::ProcessReplica()
{
- KX_GameObject::ProcessReplica(replica);
+ bPose *pose= m_pose;
+ KX_GameObject::ProcessReplica();
- replica->m_pose = NULL;
- game_copy_pose(&replica->m_pose, m_pose);
+ m_pose = NULL;
+ game_copy_pose(&m_pose, pose);
}
BL_ArmatureObject::~BL_ArmatureObject()
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
index d68e37d9e37..d5402cfd126 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ b/source/gameengine/Converter/BL_ArmatureObject.h
@@ -45,7 +45,7 @@ class BL_ArmatureObject : public KX_GameObject
public:
double GetLastFrame ();
short GetActivePriority();
- virtual void ProcessReplica(BL_ArmatureObject *replica);
+ virtual void ProcessReplica();
class BL_ActionActuator * GetActiveAction();
BL_ArmatureObject(
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 5220361d10d..c25bdbe71f7 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -90,6 +90,7 @@
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BL_SkinMeshObject.h"
+#include "BL_ModifierDeformer.h"
#include "BL_ShapeDeformer.h"
#include "BL_SkinDeformer.h"
#include "BL_MeshDeformer.h"
@@ -317,7 +318,8 @@ typedef struct MTF_localLayer
}MTF_localLayer;
// ------------------------------------
-BL_Material* ConvertMaterial(
+bool ConvertMaterial(
+ BL_Material *material,
Material *mat,
MTFace* tface,
const char *tfaceName,
@@ -328,9 +330,7 @@ BL_Material* ConvertMaterial(
MTF_localLayer *layers,
bool glslmat)
{
- //this needs some type of manager
- BL_Material *material = new BL_Material();
-
+ material->Initialize();
int numchan = -1, texalpha = 0;
bool validmat = (mat!=0);
bool validface = (tface!=0);
@@ -341,6 +341,7 @@ BL_Material* ConvertMaterial(
material->IdMode = DEFAULT_BLENDER;
material->glslmat = (validmat)? glslmat: false;
+ material->materialindex = mface->mat_nr;
// --------------------------------
if(validmat) {
@@ -718,7 +719,7 @@ BL_Material* ConvertMaterial(
material->tface = tface;
material->material = mat;
- return material;
+ return true;
}
@@ -728,6 +729,8 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
bool skinMesh = false;
int lightlayer = blenderobj->lay;
+ if ((meshobj = converter->FindGameMesh(mesh/*, ob->lay*/)) != NULL)
+ return meshobj;
// Get DerivedMesh data
DerivedMesh *dm = CDDM_from_mesh(mesh, blenderobj);
@@ -747,7 +750,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
}
// Determine if we need to make a skinned mesh
- if (mesh->dvert || mesh->key || ((blenderobj->gameflag & OB_SOFT_BODY) != 0))
+ if (mesh->dvert || mesh->key || ((blenderobj->gameflag & OB_SOFT_BODY) != 0) || BL_ModifierDeformer::HasCompatibleDeformer(blenderobj))
{
meshobj = new BL_SkinMeshObject(mesh, lightlayer);
skinMesh = true;
@@ -779,6 +782,13 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
meshobj->SetName(mesh->id.name);
meshobj->m_sharedvertex_map.resize(totvert);
+ RAS_IPolyMaterial* polymat = NULL;
+ STR_String imastr;
+ // These pointers will hold persistent material structure during the conversion
+ // to avoid countless allocation/deallocation of memory.
+ BL_Material* bl_mat = NULL;
+ KX_BlenderMaterial* kx_blmat = NULL;
+ KX_PolygonMaterial* kx_polymat = NULL;
for (int f=0;f<totface;f++,mface++)
{
@@ -841,8 +851,6 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
{
bool visible = true;
bool twoside = false;
- RAS_IPolyMaterial* polymat = NULL;
- BL_Material *bl_mat = NULL;
if(converter->GetMaterials()) {
/* do Blender Multitexture and Blender GLSL materials */
@@ -850,11 +858,11 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
MT_Point2 uv[4];
/* first is the BL_Material */
- bl_mat = ConvertMaterial(ma, tface, tfaceName, mface, mcol,
+ if (!bl_mat)
+ bl_mat = new BL_Material();
+ ConvertMaterial(bl_mat, ma, tface, tfaceName, mface, mcol,
lightlayer, blenderobj, layers, converter->GetGLSLMaterials());
- bl_mat->material_index = (int)mface->mat_nr;
-
visible = ((bl_mat->ras_mode & POLY_VIS)!=0);
collider = ((bl_mat->ras_mode & COLLIDER)!=0);
twoside = ((bl_mat->mode & TF_TWOSIDE)!=0);
@@ -873,12 +881,16 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
uv22 = uv[2]; uv23 = uv[3];
/* then the KX_BlenderMaterial */
- polymat = new KX_BlenderMaterial(scene, bl_mat, skinMesh, lightlayer);
+ if (kx_blmat == NULL)
+ kx_blmat = new KX_BlenderMaterial();
+
+ kx_blmat->Initialize(scene, bl_mat, skinMesh, lightlayer);
+ polymat = static_cast<RAS_IPolyMaterial*>(kx_blmat);
}
else {
/* do Texture Face materials */
Image* bima = (tface)? (Image*)tface->tpage: NULL;
- STR_String imastr = (tface)? (bima? (bima)->id.name : "" ) : "";
+ imastr = (tface)? (bima? (bima)->id.name : "" ) : "";
char transp=0;
short mode=0, tile=0;
@@ -956,9 +968,12 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
bool alpha = (transp == TF_ALPHA || transp == TF_ADD);
bool zsort = (mode & TF_ALPHASORT)? alpha: 0;
- polymat = new KX_PolygonMaterial(imastr, ma,
+ if (kx_polymat == NULL)
+ kx_polymat = new KX_PolygonMaterial();
+ kx_polymat->Initialize(imastr, ma, (int)mface->mat_nr,
tile, tilexrep, tileyrep,
mode, transp, alpha, zsort, lightlayer, tface, (unsigned int*)mcol);
+ polymat = static_cast<RAS_IPolyMaterial*>(kx_polymat);
if (ma) {
polymat->m_specular = MT_Vector3(ma->specr, ma->specg, ma->specb)*ma->spec;
@@ -983,15 +998,17 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
converter->RegisterPolyMaterial(polymat);
if(converter->GetMaterials()) {
converter->RegisterBlenderMaterial(bl_mat);
+ // the poly material has been stored in the bucket, next time we must create a new one
+ bl_mat = NULL;
+ kx_blmat = NULL;
+ } else {
+ // the poly material has been stored in the bucket, next time we must create a new one
+ kx_polymat = NULL;
}
} else {
- // delete the material objects since they are no longer needed
// from now on, use the polygon material from the material bucket
- delete polymat;
- if(converter->GetMaterials()) {
- delete bl_mat;
- }
polymat = bucket->GetPolyMaterial();
+ // keep the material pointers, they will be reused for next face
}
int nverts = (mface->v4)? 4: 3;
@@ -1028,14 +1045,21 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
// pre calculate texture generation
for(list<RAS_MeshMaterial>::iterator mit = meshobj->GetFirstMaterial();
mit != meshobj->GetLastMaterial(); ++ mit) {
- mit->m_bucket->GetPolyMaterial()->OnConstruction();
+ mit->m_bucket->GetPolyMaterial()->OnConstruction(lightlayer);
}
if (layers)
delete []layers;
dm->release(dm);
-
+ // cleanup material
+ if (bl_mat)
+ delete bl_mat;
+ if (kx_blmat)
+ delete kx_blmat;
+ if (kx_polymat)
+ delete kx_polymat;
+ converter->RegisterGameMesh(meshobj, mesh);
return meshobj;
}
@@ -1228,18 +1252,34 @@ static void my_tex_space_mesh(Mesh *me)
}
-static void my_get_local_bounds(Object *ob, float *center, float *size)
+static void my_get_local_bounds(Object *ob, DerivedMesh *dm, float *center, float *size)
{
BoundBox *bb= NULL;
/* uses boundbox, function used by Ketsji */
switch (ob->type)
{
case OB_MESH:
- bb= ( (Mesh *)ob->data )->bb;
- if(bb==0)
+ if (dm)
+ {
+ float min_r[3], max_r[3];
+ INIT_MINMAX(min_r, max_r);
+ dm->getMinMax(dm, min_r, max_r);
+ size[0]= 0.5*fabs(max_r[0] - min_r[0]);
+ size[1]= 0.5*fabs(max_r[1] - min_r[1]);
+ size[2]= 0.5*fabs(max_r[2] - min_r[2]);
+
+ center[0]= 0.5*(max_r[0] + min_r[0]);
+ center[1]= 0.5*(max_r[1] + min_r[1]);
+ center[2]= 0.5*(max_r[2] + min_r[2]);
+ return;
+ } else
{
- my_tex_space_mesh((struct Mesh *)ob->data);
bb= ( (Mesh *)ob->data )->bb;
+ if(bb==0)
+ {
+ my_tex_space_mesh((struct Mesh *)ob->data);
+ bb= ( (Mesh *)ob->data )->bb;
+ }
}
break;
case OB_CURVE:
@@ -1297,8 +1337,15 @@ void BL_CreateGraphicObjectNew(KX_GameObject* gameobj,
gameobj->SetGraphicController(ctrl);
ctrl->setNewClientInfo(gameobj->getClientInfo());
ctrl->setLocalAabb(localAabbMin, localAabbMax);
- if (isActive)
- env->addCcdGraphicController(ctrl);
+ if (isActive) {
+ // add first, this will create the proxy handle, only if the object is visible
+ if (gameobj->GetVisible())
+ env->addCcdGraphicController(ctrl);
+ // update the mesh if there is a deformer, this will also update the bounding box for modifiers
+ RAS_Deformer* deformer = gameobj->GetDeformer();
+ if (deformer)
+ deformer->UpdateBuckets();
+ }
}
break;
#endif
@@ -1334,10 +1381,11 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
}
bool isCompoundChild = false;
+ bool hasCompoundChildren = !parent && (blenderobject->gameflag & OB_CHILD);
- if (parent && (parent->gameflag & OB_DYNAMIC)) {
+ if (parent/* && (parent->gameflag & OB_DYNAMIC)*/) {
- if ((parent->gameflag & OB_CHILD) != 0)
+ if ((parent->gameflag & OB_CHILD) != 0 && (blenderobject->gameflag & OB_CHILD))
{
isCompoundChild = true;
}
@@ -1363,14 +1411,26 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_lockZRotaxis = (blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS) !=0;
objprop.m_isCompoundChild = isCompoundChild;
- objprop.m_hasCompoundChildren = (blenderobject->gameflag & OB_CHILD) != 0;
+ objprop.m_hasCompoundChildren = hasCompoundChildren;
objprop.m_margin = blenderobject->margin;
+
// ACTOR is now a separate feature
objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0;
objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0;
objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0;
objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
+ ///contact processing threshold is only for rigid bodies and static geometry, not 'dynamic'
+ if (objprop.m_angular_rigidbody || !objprop.m_dyna )
+ {
+ objprop.m_contactProcessingThreshold = blenderobject->m_contactProcessingThreshold;
+ } else
+ {
+ objprop.m_contactProcessingThreshold = 0.f;
+ }
+
+ objprop.m_sensor = (blenderobject->gameflag & OB_SENSOR) != 0;
+
if (objprop.m_softbody)
{
///for game soft bodies
@@ -1411,7 +1471,9 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_soft_kAHR= blenderobject->bsoft->kAHR; /* Anchors hardness [0,1] */
objprop.m_soft_collisionflags= blenderobject->bsoft->collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
objprop.m_soft_numclusteriterations= blenderobject->bsoft->numclusteriterations; /* number of iterations to refine collision clusters*/
-
+ objprop.m_soft_welding = blenderobject->bsoft->welding; /* welding */
+ objprop.m_margin = blenderobject->bsoft->margin;
+ objprop.m_contactProcessingThreshold = 0.f;
} else
{
objprop.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
@@ -1450,6 +1512,9 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_soft_kAHR= 0.7f;
objprop.m_soft_collisionflags= OB_BSB_COL_SDF_RS + OB_BSB_COL_VF_SS;
objprop.m_soft_numclusteriterations= 16;
+ objprop.m_soft_welding = 0.f;
+ objprop.m_margin = 0.f;
+ objprop.m_contactProcessingThreshold = 0.f;
}
}
@@ -1469,7 +1534,10 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
}
KX_BoxBounds bb;
- my_get_local_bounds(blenderobject,objprop.m_boundobject.box.m_center,bb.m_extends);
+ DerivedMesh* dm = NULL;
+ if (gameobj->GetDeformer())
+ dm = gameobj->GetDeformer()->GetFinalMesh();
+ my_get_local_bounds(blenderobject,dm,objprop.m_boundobject.box.m_center,bb.m_extends);
if (blenderobject->gameflag & OB_BOUNDS)
{
switch (blenderobject->boundtype)
@@ -1521,12 +1589,13 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
}
- if (parent && (parent->gameflag & OB_DYNAMIC)) {
-
+ if (parent/* && (parent->gameflag & OB_DYNAMIC)*/) {
+ // parented object cannot be dynamic
KX_GameObject *parentgameobject = converter->FindGameObject(parent);
objprop.m_dynamic_parent = parentgameobject;
//cannot be dynamic:
objprop.m_dyna = false;
+ objprop.m_softbody = false;
shapeprops->m_mass = 0.f;
}
@@ -1537,7 +1606,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
{
#ifdef USE_BULLET
case UseBullet:
- KX_ConvertBulletObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop);
+ KX_ConvertBulletObject(gameobj, meshobj, dm, kxscene, shapeprops, smmaterial, &objprop);
break;
#endif
@@ -1612,7 +1681,7 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l
static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) {
Camera* ca = static_cast<Camera*>(ob->data);
- RAS_CameraData camdata(ca->lens, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, dof_camera(ob));
+ RAS_CameraData camdata(ca->lens, ca->ortho_scale, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, dof_camera(ob));
KX_Camera *gamecamera;
gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata);
@@ -1660,14 +1729,9 @@ static KX_GameObject *gameobject_from_blenderobject(
case OB_MESH:
{
Mesh* mesh = static_cast<Mesh*>(ob->data);
- RAS_MeshObject* meshobj = converter->FindGameMesh(mesh, ob->lay);
float center[3], extents[3];
float radius = my_boundbox_mesh((Mesh*) ob->data, center, extents);
-
- if (!meshobj) {
- meshobj = BL_ConvertMesh(mesh,ob,rendertools,kxscene,converter);
- converter->RegisterGameMesh(meshobj, mesh);
- }
+ RAS_MeshObject* meshobj = BL_ConvertMesh(mesh,ob,rendertools,kxscene,converter);
// needed for python scripting
kxscene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
@@ -1689,8 +1753,15 @@ static KX_GameObject *gameobject_from_blenderobject(
bool bHasShapeKey = mesh->key != NULL && mesh->key->type==KEY_RELATIVE;
bool bHasDvert = mesh->dvert != NULL && ob->defbase.first;
bool bHasArmature = (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && bHasDvert);
+ bool bHasModifier = BL_ModifierDeformer::HasCompatibleDeformer(ob);
- if (bHasShapeKey) {
+ if (bHasModifier) {
+ BL_ModifierDeformer *dcont = new BL_ModifierDeformer((BL_DeformableGameObject *)gameobj,
+ blenderscene, ob, (BL_SkinMeshObject *)meshobj);
+ ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
+ if (bHasShapeKey && bHasArmature)
+ dcont->LoadShapeDrivers(ob->parent);
+ } else if (bHasShapeKey) {
// not that we can have shape keys without dvert!
BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj,
ob, (BL_SkinMeshObject*)meshobj);
@@ -1910,8 +1981,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
int activeLayerBitInfo = blenderscene->lay;
- // templist to find Root Parents (object with no parents)
- CListValue* templist = new CListValue();
+ // list of all object converted, active and inactive
CListValue* sumolist = new CListValue();
vector<parentChildLink> vec_parent_child;
@@ -2011,14 +2081,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
gameobj->SetName(blenderobject->id.name);
- // templist to find Root Parents (object with no parents)
- templist->Add(gameobj->AddRef());
-
// update children/parent hierarchy
if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame))
{
// blender has an additional 'parentinverse' offset in each object
- SG_Node* parentinversenode = new SG_Node(NULL,NULL,SG_Callbacks());
+ SG_Callbacks callback(NULL,NULL,NULL,KX_Scene::KX_ScenegraphUpdateFunc,KX_Scene::KX_ScenegraphRescheduleFunc);
+ SG_Node* parentinversenode = new SG_Node(NULL,kxscene,callback);
// define a normal parent relationship for this node.
KX_NormalParentRelation * parent_relation = KX_NormalParentRelation::New();
@@ -2205,14 +2273,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
gameobj->SetName(blenderobject->id.name);
- // templist to find Root Parents (object with no parents)
- templist->Add(gameobj->AddRef());
-
// update children/parent hierarchy
if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame))
{
// blender has an additional 'parentinverse' offset in each object
- SG_Node* parentinversenode = new SG_Node(NULL,NULL,SG_Callbacks());
+ SG_Callbacks callback(NULL,NULL,NULL,KX_Scene::KX_ScenegraphUpdateFunc,KX_Scene::KX_ScenegraphRescheduleFunc);
+ SG_Node* parentinversenode = new SG_Node(NULL,kxscene,callback);
// define a normal parent relationship for this node.
KX_NormalParentRelation * parent_relation = KX_NormalParentRelation::New();
@@ -2359,8 +2425,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
for ( i=0;i<childrenlist->GetCount();i++)
{
KX_GameObject* obj = static_cast<KX_GameObject*>(childrenlist->GetValue(i));
- if (templist->RemoveValue(obj))
- obj->Release();
if (sumolist->RemoveValue(obj))
obj->Release();
if (logicbrick_conversionlist->RemoveValue(obj))
@@ -2416,16 +2480,49 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
vec_parent_child.clear();
// find 'root' parents (object that has not parents in SceneGraph)
- for (i=0;i<templist->GetCount();++i)
+ for (i=0;i<sumolist->GetCount();++i)
{
- KX_GameObject* gameobj = (KX_GameObject*) templist->GetValue(i);
+ KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
if (gameobj->GetSGNode()->GetSGParent() == 0)
{
parentlist->Add(gameobj->AddRef());
gameobj->NodeUpdateGS(0);
}
}
-
+
+ // create graphic controller for culling
+ if (kxscene->GetDbvtCulling())
+ {
+ bool occlusion = false;
+ for (i=0; i<sumolist->GetCount();i++)
+ {
+ KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
+ if (gameobj->GetMeshCount() > 0)
+ {
+ MT_Point3 box[2];
+ gameobj->GetSGNode()->BBox().getmm(box, MT_Transform::Identity());
+ // box[0] is the min, box[1] is the max
+ bool isactive = objectlist->SearchValue(gameobj);
+ BL_CreateGraphicObjectNew(gameobj,box[0],box[1],kxscene,isactive,physics_engine);
+ if (gameobj->GetOccluder())
+ occlusion = true;
+ }
+ }
+ if (occlusion)
+ kxscene->SetDbvtOcclusionRes(blenderscene->world->occlusionRes);
+ }
+ if (blenderscene->world)
+ kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->world->physubstep);
+
+ // now that the scenegraph is complete, let's instantiate the deformers.
+ // We need that to create reusable derived mesh and physic shapes
+ for (i=0;i<sumolist->GetCount();++i)
+ {
+ KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
+ if (gameobj->GetDeformer())
+ gameobj->GetDeformer()->UpdateBuckets();
+ }
+
bool processCompoundChildren = false;
// create physics information
@@ -2459,28 +2556,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,physics_engine,converter,processCompoundChildren);
}
- // create graphic controller for culling
- if (kxscene->GetDbvtCulling())
- {
- bool occlusion = false;
- for (i=0; i<sumolist->GetCount();i++)
- {
- KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
- if (gameobj->GetMeshCount() > 0)
- {
- MT_Point3 box[2];
- gameobj->GetSGNode()->BBox().getmm(box, MT_Transform::Identity());
- // box[0] is the min, box[1] is the max
- bool isactive = objectlist->SearchValue(gameobj);
- BL_CreateGraphicObjectNew(gameobj,box[0],box[1],kxscene,isactive,physics_engine);
- if (gameobj->GetOccluder())
- occlusion = true;
- }
- }
- if (occlusion)
- kxscene->SetDbvtOcclusionRes(blenderscene->world->occlusionRes);
- }
-
//set ini linearVel and int angularVel //rcruiz
if (converter->addInitFromFrame)
for (i=0;i<sumolist->GetCount();i++)
@@ -2566,11 +2641,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
}
}
- templist->Release();
sumolist->Release();
- int executePriority=0; /* incremented by converter routines */
-
// convert global sound stuff
/* XXX, glob is the very very wrong place for this
@@ -2601,7 +2673,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
struct Object* blenderobj = converter->FindBlenderObject(gameobj);
int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
- BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,executePriority, layerMask,isInActiveLayer,rendertools,converter);
+ BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,layerMask,isInActiveLayer,rendertools,converter);
}
for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
{
@@ -2609,7 +2681,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
struct Object* blenderobj = converter->FindBlenderObject(gameobj);
int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
- BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,executePriority,layerMask,isInActiveLayer,converter);
+ BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,layerMask,isInActiveLayer,converter);
}
for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
{
@@ -2617,7 +2689,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
struct Object* blenderobj = converter->FindBlenderObject(gameobj);
int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
- BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,keydev,executePriority,layerMask,isInActiveLayer,canvas,converter);
+ BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,keydev,layerMask,isInActiveLayer,canvas,converter);
// set the init state to all objects
gameobj->SetInitState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state);
}
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp
index e2610d2b405..cb882f31e80 100644
--- a/source/gameengine/Converter/BL_DeformableGameObject.cpp
+++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp
@@ -30,6 +30,8 @@
#include "BL_DeformableGameObject.h"
#include "BL_ShapeDeformer.h"
#include "BL_ShapeActionActuator.h"
+#include "RAS_MaterialBucket.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -41,27 +43,19 @@ BL_DeformableGameObject::~BL_DeformableGameObject()
delete m_pDeformer; // __NLA : Temporary until we decide where to put this
}
-void BL_DeformableGameObject::ProcessReplica(KX_GameObject* replica)
+void BL_DeformableGameObject::ProcessReplica()
{
- BL_MeshDeformer *deformer;
- KX_GameObject::ProcessReplica(replica);
-
- if (m_pDeformer) {
- deformer = (BL_MeshDeformer*)m_pDeformer->GetReplica(replica);
- ((BL_DeformableGameObject*)replica)->m_pDeformer = deformer;
- }
+ KX_GameObject::ProcessReplica();
+ if (m_pDeformer)
+ m_pDeformer= (BL_MeshDeformer*)m_pDeformer->GetReplica();
}
CValue* BL_DeformableGameObject::GetReplica()
{
BL_DeformableGameObject* replica = new BL_DeformableGameObject(*this);//m_float,GetName());
-
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
- ProcessReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -109,3 +103,14 @@ bool BL_DeformableGameObject::GetShape(vector<float> &shape)
return !shape.empty();
}
+void BL_DeformableGameObject::SetDeformer(class RAS_Deformer* deformer)
+{
+ m_pDeformer = deformer;
+
+ SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
+ for(mit.begin(); !mit.end(); ++mit)
+ {
+ (*mit)->SetDeformer(deformer);
+ }
+}
+
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h
index 126a1fcb1e7..b20b8e81b37 100644
--- a/source/gameengine/Converter/BL_DeformableGameObject.h
+++ b/source/gameengine/Converter/BL_DeformableGameObject.h
@@ -62,7 +62,7 @@ public:
m_pDeformer->Relink (map);
KX_GameObject::Relink(map);
};
- void ProcessReplica(KX_GameObject* replica);
+ void ProcessReplica();
BL_DeformableGameObject(Object* blendobj, void* sgReplicationInfo, SG_Callbacks callbacks) :
KX_GameObject(sgReplicationInfo,callbacks),
@@ -83,10 +83,7 @@ public:
return (m_pDeformer) ? ((BL_MeshDeformer*)m_pDeformer)->GetMesh()->key : NULL;
}
- virtual void SetDeformer(class RAS_Deformer* deformer)
- {
- m_pDeformer = deformer;
- }
+ virtual void SetDeformer(class RAS_Deformer* deformer);
virtual class RAS_Deformer* GetDeformer()
{
return m_pDeformer;
diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp
index 80112346c72..d7012abe316 100644
--- a/source/gameengine/Converter/BL_MeshDeformer.cpp
+++ b/source/gameengine/Converter/BL_MeshDeformer.cpp
@@ -47,6 +47,7 @@
#include "GEN_Map.h"
#include "STR_HashedString.h"
+#include "BLI_arithb.h"
bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*)
{
@@ -90,6 +91,15 @@ BL_MeshDeformer::~BL_MeshDeformer()
delete [] m_transnors;
}
+void BL_MeshDeformer::ProcessReplica()
+{
+ m_transverts = NULL;
+ m_transnors = NULL;
+ m_tvtot = 0;
+ m_bDynamic=false;
+ m_lastDeformUpdate = -1;
+}
+
void BL_MeshDeformer::Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
{
void **h_obj = (*map)[m_gameobj];
@@ -133,9 +143,9 @@ void BL_MeshDeformer::RecalcNormals()
RAS_TexVert& v3 = it.vertex[it.index[i+2]];
RAS_TexVert *v4 = NULL;
- const float *co1 = v1.getXYZ();
- const float *co2 = v2.getXYZ();
- const float *co3 = v3.getXYZ();
+ const float *co1 = m_transverts[v1.getOrigIndex()];
+ const float *co2 = m_transverts[v2.getOrigIndex()];
+ const float *co3 = m_transverts[v3.getOrigIndex()];
const float *co4 = NULL;
/* compute face normal */
@@ -143,7 +153,7 @@ void BL_MeshDeformer::RecalcNormals()
if(nvert == 4) {
v4 = &it.vertex[it.index[i+3]];
- co4 = v4->getXYZ();
+ co4 = m_transverts[v4->getOrigIndex()];
n1[0]= co1[0]-co3[0];
n1[1]= co1[1]-co3[1];
@@ -166,6 +176,7 @@ void BL_MeshDeformer::RecalcNormals()
fnor[0]= n1[1]*n2[2] - n1[2]*n2[1];
fnor[1]= n1[2]*n2[0] - n1[0]*n2[2];
fnor[2]= n1[0]*n2[1] - n1[1]*n2[0];
+ Normalize(fnor);
/* add to vertices for smooth normals */
float *vn1 = m_transnors[v1.getOrigIndex()];
diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h
index 8de59c1cdf3..99ae5f9dea0 100644
--- a/source/gameengine/Converter/BL_MeshDeformer.h
+++ b/source/gameengine/Converter/BL_MeshDeformer.h
@@ -64,7 +64,9 @@ public:
virtual void SetSimulatedTime(double time){};
virtual bool Apply(class RAS_IPolyMaterial *mat);
virtual bool Update(void){ return false; };
- virtual RAS_Deformer* GetReplica(class KX_GameObject* replica){return NULL;};
+ virtual bool UpdateBuckets(void){ return false; };
+ virtual RAS_Deformer* GetReplica(){return NULL;};
+ virtual void ProcessReplica();
struct Mesh* GetMesh() { return m_bmesh; };
// virtual void InitDeform(double time){};
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp
new file mode 100644
index 00000000000..80165548ff2
--- /dev/null
+++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp
@@ -0,0 +1,183 @@
+/**
+ * $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 WIN32
+#pragma warning (disable : 4786)
+#endif //WIN32
+
+#include "MEM_guardedalloc.h"
+#include "BL_ModifierDeformer.h"
+#include "GEN_Map.h"
+#include "STR_HashedString.h"
+#include "RAS_IPolygonMaterial.h"
+#include "BL_SkinMeshObject.h"
+#include "PHY_IGraphicController.h"
+
+//#include "BL_ArmatureController.h"
+#include "DNA_armature_types.h"
+#include "DNA_action_types.h"
+#include "DNA_key_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#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"
+#include "BKE_ipo.h"
+#include "MT_Point3.h"
+
+extern "C"{
+ #include "BKE_customdata.h"
+ #include "BKE_DerivedMesh.h"
+ #include "BKE_lattice.h"
+ #include "BKE_modifier.h"
+}
+ #include "BKE_utildefines.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#define __NLA_DEFNORMALS
+//#undef __NLA_DEFNORMALS
+
+
+BL_ModifierDeformer::~BL_ModifierDeformer()
+{
+ if (m_dm) {
+ // deformedOnly is used as a user counter
+ if (--m_dm->deformedOnly == 0) {
+ m_dm->needsFree = 1;
+ m_dm->release(m_dm);
+ }
+ }
+};
+
+RAS_Deformer *BL_ModifierDeformer::GetReplica()
+{
+ BL_ModifierDeformer *result;
+
+ result = new BL_ModifierDeformer(*this);
+ result->ProcessReplica();
+ return result;
+}
+
+void BL_ModifierDeformer::ProcessReplica()
+{
+ /* Note! - This is not inherited from PyObjectPlus */
+ BL_ShapeDeformer::ProcessReplica();
+ if (m_dm)
+ // by default try to reuse mesh, deformedOnly is used as a user count
+ m_dm->deformedOnly++;
+ // this will force an update and if the mesh cannot be reused, a new one will be created
+ m_lastModifierUpdate = -1;
+}
+
+bool BL_ModifierDeformer::HasCompatibleDeformer(Object *ob)
+{
+ if (!ob->modifiers.first)
+ return false;
+ // soft body cannot use mesh modifiers
+ if ((ob->gameflag & OB_SOFT_BODY) != 0)
+ return false;
+ ModifierData* md;
+ for (md = (ModifierData*)ob->modifiers.first; md; md = (ModifierData*)md->next) {
+ if (modifier_dependsOnTime(md))
+ continue;
+ if (!(md->mode & eModifierMode_Realtime))
+ continue;
+ return true;
+ }
+ return false;
+}
+
+bool BL_ModifierDeformer::Update(void)
+{
+ bool bShapeUpdate = BL_ShapeDeformer::Update();
+
+ if (bShapeUpdate || m_lastModifierUpdate != m_gameobj->GetLastFrame()) {
+ // static derived mesh are not updated
+ if (m_dm == NULL || m_bDynamic) {
+ /* execute the modifiers */
+ Object* blendobj = m_gameobj->GetBlendObject();
+ /* hack: the modifiers require that the mesh is attached to the object
+ It may not be the case here because of replace mesh actuator */
+ Mesh *oldmesh = (Mesh*)blendobj->data;
+ blendobj->data = m_bmesh;
+ /* execute the modifiers */
+ 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) */
+ if (m_dm != NULL) {
+ // HACK! use deformedOnly as a user counter
+ if (--m_dm->deformedOnly == 0) {
+ m_dm->needsFree = 1;
+ m_dm->release(m_dm);
+ }
+ }
+ m_dm = dm;
+ // get rid of temporary data
+ m_dm->needsFree = 0;
+ m_dm->release(m_dm);
+ // HACK! use deformedOnly as a user counter
+ m_dm->deformedOnly = 1;
+ /* update the graphic controller */
+ PHY_IGraphicController *ctrl = m_gameobj->GetGraphicController();
+ if (ctrl) {
+ float min_r[3], max_r[3];
+ INIT_MINMAX(min_r, max_r);
+ m_dm->getMinMax(m_dm, min_r, max_r);
+ ctrl->setLocalAabb(min_r, max_r);
+ }
+ }
+ m_lastModifierUpdate=m_gameobj->GetLastFrame();
+ bShapeUpdate = true;
+ }
+ return bShapeUpdate;
+}
+
+bool BL_ModifierDeformer::Apply(RAS_IPolyMaterial *mat)
+{
+ if (!Update())
+ return false;
+
+ // drawing is based on derived mesh, must set it in the mesh slots
+ int nmat = m_pMeshObject->NumMaterials();
+ for (int imat=0; imat<nmat; imat++) {
+ RAS_MeshMaterial *mmat = m_pMeshObject->GetMeshMaterial(imat);
+ RAS_MeshSlot **slot = mmat->m_slots[(void*)m_gameobj];
+ if(!slot || !*slot)
+ continue;
+ (*slot)->m_pDerivedMesh = m_dm;
+ }
+ return true;
+}
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h
new file mode 100644
index 00000000000..b09cc2087ca
--- /dev/null
+++ b/source/gameengine/Converter/BL_ModifierDeformer.h
@@ -0,0 +1,107 @@
+/**
+ * $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 BL_MODIFIERDEFORMER
+#define BL_MODIFIERDEFORMER
+
+#ifdef WIN32
+#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
+#endif //WIN32
+
+#include "BL_ShapeDeformer.h"
+#include "BL_DeformableGameObject.h"
+#include <vector>
+
+struct DerivedMesh;
+struct Object;
+
+class BL_ModifierDeformer : public BL_ShapeDeformer
+{
+public:
+ static bool HasCompatibleDeformer(Object *ob);
+
+
+ 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;
+ };
+
+ /* 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,
+ bool release_object,
+ BL_ArmatureObject* arma = NULL)
+ :
+ BL_ShapeDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, false, arma),
+ m_lastModifierUpdate(-1),
+ m_scene(scene),
+ m_dm(NULL)
+ {
+ };
+
+ virtual void ProcessReplica();
+ virtual RAS_Deformer *GetReplica();
+ virtual ~BL_ModifierDeformer();
+ virtual bool UseVertexArray()
+ {
+ return false;
+ }
+
+ bool Update (void);
+ bool Apply(RAS_IPolyMaterial *mat);
+ void ForceUpdate()
+ {
+ m_lastModifierUpdate = -1.0;
+ };
+ virtual struct DerivedMesh* GetFinalMesh()
+ {
+ return m_dm;
+ }
+
+
+protected:
+ double m_lastModifierUpdate;
+ Scene *m_scene;
+ DerivedMesh *m_dm;
+
+};
+
+#endif
+
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
index b0c9e0f5694..7aa8714de3a 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
@@ -61,6 +61,7 @@ BL_ShapeActionActuator::~BL_ShapeActionActuator()
void BL_ShapeActionActuator::ProcessReplica()
{
+ SCA_IActuator::ProcessReplica();
m_localtime=m_startframe;
m_lastUpdate=-1;
}
@@ -74,9 +75,6 @@ CValue* BL_ShapeActionActuator::GetReplica()
{
BL_ShapeActionActuator* replica = new BL_ShapeActionActuator(*this);//m_float,GetName());
replica->ProcessReplica();
-
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
}
@@ -162,16 +160,9 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame)
// maybe there are events for us in the queue !
if (frame)
{
- for (vector<CValue*>::iterator i=m_events.begin(); !(i==m_events.end());i++)
- {
- if ((*i)->GetNumber() == 0.0f)
- bNegativeEvent = true;
- else
- bPositiveEvent= true;
- (*i)->Release();
-
- }
- m_events.clear();
+ bNegativeEvent = m_negevent;
+ bPositiveEvent = m_posevent;
+ RemoveAllEvents();
if (bPositiveEvent)
m_flag |= ACT_FLAG_ACTIVE;
@@ -420,8 +411,13 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject BL_ShapeActionActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"BL_ShapeActionActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -471,16 +467,16 @@ PyMethodDef BL_ShapeActionActuator::Methods[] = {
};
PyAttributeDef BL_ShapeActionActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ShapeActionActuator, m_startframe),
- KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ShapeActionActuator, m_endframe),
- KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendin),
+ KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, MAXFRAMEF, BL_ShapeActionActuator, m_startframe),
+ KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, MAXFRAMEF, BL_ShapeActionActuator, m_endframe),
+ KX_PYATTRIBUTE_FLOAT_RW("blendIn", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendin),
KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ShapeActionActuator, pyattr_get_action, pyattr_set_action),
KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ShapeActionActuator, m_priority),
KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ShapeActionActuator, m_localtime, CheckFrame),
- KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ShapeActionActuator, m_propname),
- KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ShapeActionActuator, m_framepropname),
+ KX_PYATTRIBUTE_STRING_RW("propName", 0, 31, false, BL_ShapeActionActuator, m_propname),
+ KX_PYATTRIBUTE_STRING_RW("framePropName", 0, 31, false, BL_ShapeActionActuator, m_framepropname),
KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendframe, CheckBlendTime),
- KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ShapeActionActuator,m_playtype,CheckType),
+ KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ShapeActionActuator,m_playtype,CheckType),
{ NULL } //Sentinel
};
@@ -489,6 +485,10 @@ 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);
}
@@ -870,7 +870,7 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE
if (!PyString_Check(value))
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, expected the string name of the action");
- return -1;
+ return PY_SET_ATTR_FAIL;
}
bAction *action= NULL;
@@ -882,11 +882,11 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE
if (action==NULL)
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, action not found!");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
}
self->SetAction(action);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h
index 3bc35ac9495..d268eef6d23 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.h
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.h
@@ -107,6 +107,7 @@ public:
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);
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp
index 8be612503bc..d39917b0e5c 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.cpp
+++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp
@@ -68,7 +68,7 @@ BL_ShapeDeformer::~BL_ShapeDeformer()
{
};
-RAS_Deformer *BL_ShapeDeformer::GetReplica(class KX_GameObject* replica)
+RAS_Deformer *BL_ShapeDeformer::GetReplica()
{
BL_ShapeDeformer *result;
@@ -79,6 +79,8 @@ RAS_Deformer *BL_ShapeDeformer::GetReplica(class KX_GameObject* replica)
void BL_ShapeDeformer::ProcessReplica()
{
+ BL_SkinDeformer::ProcessReplica();
+ m_lastShapeUpdate = -1;
}
bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
@@ -87,7 +89,7 @@ bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
m_shapeDrivers.clear();
// check if this mesh has armature driven shape keys
- if (m_bmesh->key->ipo) {
+ if (m_bmesh->key && m_bmesh->key->ipo) {
for(icu= (IpoCurve*)m_bmesh->key->ipo->curve.first; icu; icu= (IpoCurve*)icu->next) {
if(icu->driver &&
(icu->flag & IPO_MUTE) == 0 &&
@@ -125,7 +127,7 @@ bool BL_ShapeDeformer::ExecuteShapeDrivers(void)
ForceUpdate();
m_armobj->RestorePose();
-
+ m_bDynamic = true;
return true;
}
return false;
@@ -147,7 +149,11 @@ bool BL_ShapeDeformer::Update(void)
m_pMeshObject->CheckWeightCache(blendobj);
/* we will blend the key directly in mvert array: it is used by armature as the start position */
- do_rel_key(0, m_bmesh->totvert, m_bmesh->totvert, (char *)m_bmesh->mvert->co, m_bmesh->key, 0);
+ /* m_bmesh->key can be NULL in case of Modifier deformer */
+ if (m_bmesh->key) {
+ do_rel_key(0, m_bmesh->totvert, m_bmesh->totvert, (char *)m_bmesh->mvert->co, m_bmesh->key, 0);
+ m_bDynamic = true;
+ }
// Don't release the weight array as in Blender, it will most likely be reusable on next frame
// The weight array are ultimately deleted when the skin mesh is destroyed
@@ -163,7 +169,8 @@ bool BL_ShapeDeformer::Update(void)
// check for armature deform
bSkinUpdate = BL_SkinDeformer::Update();
- if (!bSkinUpdate && bShapeUpdate) {
+ // non dynamic deformer = Modifer without armature and shape keys, no need to create storage
+ if (!bSkinUpdate && bShapeUpdate && m_bDynamic) {
// this means that there is no armature, we still need to copy the vertex to m_transverts
// and update the normal (was not done after shape key calculation)
@@ -174,7 +181,8 @@ bool BL_ShapeDeformer::Update(void)
VECCOPY(m_transverts[v], m_bmesh->mvert[v].co);
#ifdef __NLA_DEFNORMALS
- RecalcNormals();
+ if (m_recalcNormal)
+ RecalcNormals();
#endif
bSkinUpdate = true;
}
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h
index 90b9f5caea1..949e5e1e3ad 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.h
+++ b/source/gameengine/Converter/BL_ShapeDeformer.h
@@ -58,15 +58,16 @@ public:
struct Object *bmeshobj_new,
class BL_SkinMeshObject *mesh,
bool release_object,
+ bool recalc_normal,
BL_ArmatureObject* arma = NULL)
:
- BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, arma),
+ BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, recalc_normal, arma),
m_lastShapeUpdate(-1)
{
};
+ virtual RAS_Deformer *GetReplica();
virtual void ProcessReplica();
- virtual RAS_Deformer *GetReplica(class KX_GameObject* replica);
virtual ~BL_ShapeDeformer();
bool Update (void);
diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp
index d8563763954..a13f78e1b27 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.cpp
+++ b/source/gameengine/Converter/BL_SkinDeformer.cpp
@@ -65,9 +65,10 @@ BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj,
BL_MeshDeformer(gameobj, bmeshobj, mesh),
m_armobj(arma),
m_lastArmaUpdate(-1),
- m_defbase(&bmeshobj->defbase),
+ //m_defbase(&bmeshobj->defbase),
m_releaseobject(false),
- m_poseApplied(false)
+ m_poseApplied(false),
+ m_recalcNormal(true)
{
Mat4CpyMat4(m_obmat, bmeshobj->obmat);
};
@@ -78,12 +79,14 @@ BL_SkinDeformer::BL_SkinDeformer(
struct Object *bmeshobj_new, // Blender object that owns the original mesh
class BL_SkinMeshObject *mesh,
bool release_object,
+ bool recalc_normal,
BL_ArmatureObject* arma) :
BL_MeshDeformer(gameobj, bmeshobj_old, mesh),
m_armobj(arma),
m_lastArmaUpdate(-1),
- m_defbase(&bmeshobj_old->defbase),
- m_releaseobject(release_object)
+ //m_defbase(&bmeshobj_old->defbase),
+ m_releaseobject(release_object),
+ m_recalcNormal(recalc_normal)
{
// this is needed to ensure correct deformation of mesh:
// the deformation is done with Blender's armature_deform_verts() function
@@ -105,7 +108,7 @@ void BL_SkinDeformer::Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
void **h_obj = (*map)[m_armobj];
if (h_obj)
- SetArmature( (BL_ArmatureObject*)(*h_obj) );
+ m_armobj = (BL_ArmatureObject*)(*h_obj);
else
m_armobj=NULL;
}
@@ -118,45 +121,53 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
RAS_MeshSlot::iterator it;
RAS_MeshMaterial *mmat;
RAS_MeshSlot *slot;
- size_t i;
+ size_t i, nmat, imat;
// update the vertex in m_transverts
- Update();
-
- // The vertex cache can only be updated for this deformer:
- // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object)
- // share the same mesh (=the same cache). As the rendering is done per polymaterial
- // cycling through the objects, the entire mesh cache cannot be updated in one shot.
- mmat = m_pMeshObject->GetMeshMaterial(mat);
- if(!mmat->m_slots[(void*)m_gameobj])
- return true;
-
- slot = *mmat->m_slots[(void*)m_gameobj];
-
- // for each array
- for(slot->begin(it); !slot->end(it); slot->next(it)) {
- // for each vertex
- // copy the untransformed data from the original mvert
- for(i=it.startvertex; i<it.endvertex; i++) {
- RAS_TexVert& v = it.vertex[i];
- v.SetXYZ(m_transverts[v.getOrigIndex()]);
+ if (!Update())
+ return false;
+
+ if (m_transverts) {
+ // the vertex cache is unique to this deformer, no need to update it
+ // if it wasn't updated! We must update all the materials at once
+ // because we will not get here again for the other material
+ nmat = m_pMeshObject->NumMaterials();
+ for (imat=0; imat<nmat; imat++) {
+ mmat = m_pMeshObject->GetMeshMaterial(imat);
+ if(!mmat->m_slots[(void*)m_gameobj])
+ continue;
+
+ slot = *mmat->m_slots[(void*)m_gameobj];
+
+ // for each array
+ for(slot->begin(it); !slot->end(it); slot->next(it)) {
+ // for each vertex
+ // copy the untransformed data from the original mvert
+ for(i=it.startvertex; i<it.endvertex; i++) {
+ RAS_TexVert& v = it.vertex[i];
+ v.SetXYZ(m_transverts[v.getOrigIndex()]);
+ }
+ }
}
}
-
return true;
}
-RAS_Deformer *BL_SkinDeformer::GetReplica(class KX_GameObject* replica)
+RAS_Deformer *BL_SkinDeformer::GetReplica()
{
BL_SkinDeformer *result;
result = new BL_SkinDeformer(*this);
+ /* there is m_armobj that must be fixed but we cannot do it now, it will be done in Relink */
result->ProcessReplica();
return result;
}
void BL_SkinDeformer::ProcessReplica()
{
+ BL_MeshDeformer::ProcessReplica();
+ m_lastArmaUpdate = -1;
+ m_releaseobject = false;
}
//void where_is_pose (Object *ob);
@@ -191,14 +202,16 @@ bool BL_SkinDeformer::Update(void)
Mat4CpyMat4(m_objMesh->obmat, obmat);
#ifdef __NLA_DEFNORMALS
- RecalcNormals();
+ if (m_recalcNormal)
+ RecalcNormals();
#endif
/* Update the current frame */
m_lastArmaUpdate=m_armobj->GetLastFrame();
m_armobj->RestorePose();
-
+ /* dynamic vertex, cannot use display list */
+ m_bDynamic = true;
/* indicate that the m_transverts and normals are up to date */
return true;
}
diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h
index f87860021c6..7c43246a9d7 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.h
+++ b/source/gameengine/Converter/BL_SkinDeformer.h
@@ -64,13 +64,20 @@ public:
struct Object *bmeshobj_new,
class BL_SkinMeshObject *mesh,
bool release_object,
+ bool recalc_normal,
BL_ArmatureObject* arma = NULL);
+ virtual RAS_Deformer *GetReplica();
virtual void ProcessReplica();
- virtual RAS_Deformer *GetReplica(class KX_GameObject* replica);
+
virtual ~BL_SkinDeformer();
bool Update (void);
bool Apply (class RAS_IPolyMaterial *polymat);
+ bool UpdateBuckets(void)
+ {
+ // update the deformer and all the mesh slots; Apply() does it well, so just call it.
+ return Apply(NULL);
+ }
bool PoseUpdated(void)
{
if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) {
@@ -83,15 +90,20 @@ public:
{
m_lastArmaUpdate = -1.0;
};
+ virtual bool ShareVertexArray()
+ {
+ return false;
+ }
protected:
BL_ArmatureObject* m_armobj; // Our parent object
float m_time;
double m_lastArmaUpdate;
- ListBase* m_defbase;
+ //ListBase* m_defbase;
float m_obmat[4][4]; // the reference matrix for skeleton deform
bool m_releaseobject;
bool m_poseApplied;
+ bool m_recalcNormal;
};
diff --git a/source/gameengine/Converter/BL_SkinMeshObject.cpp b/source/gameengine/Converter/BL_SkinMeshObject.cpp
index eb3f9d0588d..0a18296f261 100644
--- a/source/gameengine/Converter/BL_SkinMeshObject.cpp
+++ b/source/gameengine/Converter/BL_SkinMeshObject.cpp
@@ -87,7 +87,7 @@ void BL_SkinMeshObject::UpdateBuckets(void* clientobj,double* oglmatrix,bool use
continue;
RAS_MeshSlot *slot = *it->m_slots[clientobj];
- slot->m_pDeformer = ((BL_DeformableGameObject*)clientobj)->GetDeformer();
+ slot->SetDeformer(((BL_DeformableGameObject*)clientobj)->GetDeformer());
}
RAS_MeshObject::UpdateBuckets(clientobj, oglmatrix, useObjectColor, rgbavec, visible, culled);
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 60cf6a4a8ee..b13e3f7cadb 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -87,6 +87,7 @@ extern "C"
//XXX #include "BSE_editipo_types.h"
#include "DNA_ipo_types.h"
#include "BKE_global.h"
+#include "BKE_ipo.h" // eval_icu
#include "DNA_space_types.h"
}
@@ -549,12 +550,12 @@ void KX_BlenderSceneConverter::RegisterGameMesh(
RAS_MeshObject *KX_BlenderSceneConverter::FindGameMesh(
- struct Mesh *for_blendermesh,
- unsigned int onlayer)
+ struct Mesh *for_blendermesh/*,
+ unsigned int onlayer*/)
{
RAS_MeshObject** meshp = m_map_mesh_to_gamemesh[CHashedPtr(for_blendermesh)];
- if (meshp && onlayer==(*meshp)->GetLightLayer()) {
+ if (meshp/* && onlayer==(*meshp)->GetLightLayer()*/) {
return *meshp;
} else {
return NULL;
@@ -668,7 +669,9 @@ extern "C"
//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);
- void Mat3ToEul(float tmat[][3], float *eul);
+ float eval_icu(struct IpoCurve *icu, float ipotime);
+ //void Mat3ToEul(float tmat[][3], float *eul);
+ void Mat3ToCompatibleEul(float mat[][3], float *eul, float *oldrot);
}
IpoCurve* findIpoCurve(IpoCurve* first, const char* searchName)
@@ -818,7 +821,6 @@ void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo(){
}
}
-#define TEST_HANDLES_GAME2IPO 0
///this generates ipo curves for position, rotation, allowing to use game physics in animation
void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
@@ -842,138 +844,83 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
//KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
Object* blenderObject = FindBlenderObject(gameObj);
- if (blenderObject)
+ if (blenderObject && blenderObject->ipo)
{
-
+ const MT_Point3& position = gameObj->NodeGetWorldPosition();
+ //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
+
float eulerAngles[3];
+ float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f};
float tmat[3][3];
- for (int r=0;r<3;r++)
- {
- for (int c=0;c<3;c++)
- {
- tmat[r][c] = orn[c][r];
- }
- }
- Mat3ToEul(tmat, eulerAngles);
-
- for(int x = 0; x < 3; x++) {
- eulerAngles[x] *= (float) (180 / 3.14159265f);
- }
-
- eulerAngles[0]/=10.f;
- eulerAngles[1]/=10.f;
- eulerAngles[2]/=10.f;
-
-
-
- //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
- const MT_Point3& position = gameObj->NodeGetWorldPosition();
+ // XXX animato
+#if 0
Ipo* ipo = blenderObject->ipo;
- if (ipo)
- {
- //create the curves, if not existing
+ //create the curves, if not existing, set linear if new
- IpoCurve *icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X);
+ IpoCurve *icu_lx = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
+ if (!icu_lx) {
+ icu_lx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
+ if(icu_lx) icu_lx->ipo = IPO_LIN;
+ }
+ IpoCurve *icu_ly = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
+ if (!icu_ly) {
+ icu_ly = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
+ if(icu_ly) icu_ly->ipo = IPO_LIN;
+ }
+ IpoCurve *icu_lz = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
+ if (!icu_lz) {
+ icu_lz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
+ if(icu_lz) icu_lz->ipo = IPO_LIN;
+ }
+ IpoCurve *icu_rx = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
+ if (!icu_rx) {
+ icu_rx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
+ if(icu_rx) icu_rx->ipo = IPO_LIN;
+ }
+ IpoCurve *icu_ry = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
+ if (!icu_ry) {
+ icu_ry = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
+ if(icu_ry) icu_ry->ipo = IPO_LIN;
+ }
+ IpoCurve *icu_rz = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
+ if (!icu_rz) {
+ icu_rz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
+ if(icu_rz) icu_rz->ipo = IPO_LIN;
+ }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y);
+ if(icu_rx) eulerAnglesOld[0]= eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
+ if(icu_ry) eulerAnglesOld[1]= eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
+ if(icu_rz) eulerAnglesOld[2]= eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
+
+ // orn.getValue((float *)tmat); // uses the wrong ordering, cant use this
+ for (int r=0;r<3;r++)
+ for (int c=0;c<3;c++)
+ tmat[r][c] = orn[c][r];
+
+ // Mat3ToEul(tmat, eulerAngles); // better to use Mat3ToCompatibleEul
+ Mat3ToCompatibleEul(tmat, eulerAngles, eulerAnglesOld);
+
+ //eval_icu
+ for(int x = 0; x < 3; x++)
+ eulerAngles[x] *= (float) ((180 / 3.14159265f) / 10.0);
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z);
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X);
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y);
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z);
-
-
-
//fill the curves with data
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
- if (icu1)
- {
- float curVal = position.x();
- //XXX insert_vert_icu(icu1, frameNumber, curVal, 0);
-#ifdef TEST_HANDLES_GAME2IPO
- //XXX testhandles_ipocurve(icu1);
-#endif
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
- if (icu1)
- {
- float curVal = position.y();
- //XXX insert_vert_icu(icu1, frameNumber, curVal, 0);
-#ifdef TEST_HANDLES_GAME2IPO
-
- //XXX testhandles_ipocurve(icu1);
-#endif
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
- if (icu1)
- {
- float curVal = position.z();
- //XXX insert_vert_icu(icu1, frameNumber, curVal, 0);
-#ifdef TEST_HANDLES_GAME2IPO
- //XXX testhandles_ipocurve(icu1);
-#endif
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
- if (icu1)
- {
- float curVal = eulerAngles[0];
- //XXX insert_vert_icu(icu1, frameNumber, curVal, 0);
-#ifdef TEST_HANDLES_GAME2IPO
-
- //XXX testhandles_ipocurve(icu1);
-#endif
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
- if (icu1)
- {
- float curVal = eulerAngles[1];
- //XXX insert_vert_icu(icu1, frameNumber, curVal, 0);
-#ifdef TEST_HANDLES_GAME2IPO
-
- //XXX testhandles_ipocurve(icu1);
-#endif
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
- if (icu1)
- {
- float curVal = eulerAngles[2];
- //XXX insert_vert_icu(icu1, frameNumber, curVal, 0);
-#ifdef TEST_HANDLES_GAME2IPO
-
- //XXX testhandles_ipocurve(icu1);
+ if (icu_lx) insert_vert_icu(icu_lx, frameNumber, position.x(), 1);
+ if (icu_ly) insert_vert_icu(icu_ly, frameNumber, position.y(), 1);
+ if (icu_lz) insert_vert_icu(icu_lz, frameNumber, position.z(), 1);
+ if (icu_rx) insert_vert_icu(icu_rx, frameNumber, eulerAngles[0], 1);
+ if (icu_ry) insert_vert_icu(icu_ry, frameNumber, eulerAngles[1], 1);
+ if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1);
+
+ // Handles are corrected at the end, testhandles_ipocurve isnt needed yet
#endif
-
- }
-
- }
}
}
-
}
-
-
- }
-
-
+ }
}
@@ -998,100 +945,21 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
//KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
Object* blenderObject = FindBlenderObject(gameObj);
- if (blenderObject)
+ if (blenderObject && blenderObject->ipo)
{
-
- const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
- float eulerAngles[3];
- float tmat[3][3];
- for (int r=0;r<3;r++)
- {
- for (int c=0;c<3;c++)
- {
- tmat[r][c] = orn[c][r];
- }
- }
- Mat3ToEul(tmat, eulerAngles);
-
- for(int x = 0; x < 3; x++) {
- eulerAngles[x] *= (float) (180 / 3.14159265f);
- }
-
- eulerAngles[0]/=10.f;
- eulerAngles[1]/=10.f;
- eulerAngles[2]/=10.f;
-
-
-
- //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
- //const MT_Point3& position = gameObj->NodeGetWorldPosition();
-
+ // XXX animato
+#if 0
Ipo* ipo = blenderObject->ipo;
- if (ipo)
- {
-
- //create the curves, if not existing
-
- IpoCurve *icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X);
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y);
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z);
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X);
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y);
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
- //XXX if (!icu1)
- //XXX icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z);
-
-
-
- //fill the curves with data
-
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
- if (icu1)
- {
- //XXX testhandles_ipocurve(icu1);
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
- if (icu1)
- {
- //XXX testhandles_ipocurve(icu1);
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
- if (icu1)
- {
- //XXX testhandles_ipocurve(icu1);
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
- if (icu1)
- {
- //XXX testhandles_ipocurve(icu1);
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
- if (icu1)
- {
- //XXX testhandles_ipocurve(icu1);
- }
- icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
- if (icu1)
- {
- //XXX testhandles_ipocurve(icu1);
- }
-
- }
+ //create the curves, if not existing
+ //testhandles_ipocurve checks for NULL
+ testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocX"));
+ testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocY"));
+ testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ"));
+ 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 2317e952a0a..f7c1a506457 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h
@@ -115,7 +115,7 @@ public:
struct Object *FindBlenderObject(KX_GameObject *for_gameobject);
void RegisterGameMesh(RAS_MeshObject *gamemesh, struct Mesh *for_blendermesh);
- RAS_MeshObject *FindGameMesh(struct Mesh *for_blendermesh, unsigned int onlayer);
+ RAS_MeshObject *FindGameMesh(struct Mesh *for_blendermesh/*, unsigned int onlayer*/);
// void RegisterSumoShape(DT_ShapeHandle shape, RAS_MeshObject *for_gamemesh);
// DT_ShapeHandle FindSumoShape(RAS_MeshObject *for_gamemesh);
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index eb2d0a1c4b1..ea812a71fdd 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -38,7 +38,7 @@
#include "KX_BlenderSceneConverter.h"
#include "KX_ConvertActuators.h"
-
+#include "SND_Scene.h"
// Actuators
//SCA logiclibrary native logicbricks
#include "SCA_PropertyActuator.h"
@@ -105,7 +105,6 @@ void BL_ConvertActuators(char* maggiename,
SCA_LogicManager* logicmgr,
KX_Scene* scene,
KX_KetsjiEngine* ketsjiEngine,
- int & executePriority,
int activeLayerBitInfo,
bool isInActiveLayer,
RAS_IRenderTools* rendertools,
@@ -114,11 +113,20 @@ void BL_ConvertActuators(char* maggiename,
{
int uniqueint = 0;
+ int actcount = 0;
+ int executePriority = 0;
bActuator* bact = (bActuator*) blenderobject->actuators.first;
+ while (bact)
+ {
+ actcount++;
+ bact = bact->next;
+ }
+ gameobj->ReserveActuator(actcount);
+ bact = (bActuator*) blenderobject->actuators.first;
while(bact)
{
STR_String uniquename = bact->name;
- STR_String objectname = gameobj->GetName();
+ STR_String& objectname = gameobj->GetName();
SCA_IActuator* baseact = NULL;
switch (bact->type)
@@ -126,6 +134,7 @@ void BL_ConvertActuators(char* maggiename,
case ACT_OBJECT:
{
bObjectActuator* obact = (bObjectActuator*) bact->data;
+ KX_GameObject* obref = NULL;
MT_Vector3 forcevec(KX_BLENDERTRUNC(obact->forceloc[0]),
KX_BLENDERTRUNC(obact->forceloc[1]),
KX_BLENDERTRUNC(obact->forceloc[2]));
@@ -163,9 +172,13 @@ void BL_ConvertActuators(char* maggiename,
bitLocalFlag.AngularVelocity = bool((obact->flag & ACT_ANG_VEL_LOCAL)!=0);
bitLocalFlag.ServoControl = bool(obact->type == ACT_OBJECT_SERVO);
bitLocalFlag.AddOrSetLinV = bool((obact->flag & ACT_ADD_LIN_VEL)!=0);
-
+ if (obact->reference && bitLocalFlag.ServoControl)
+ {
+ obref = converter->FindGameObject(obact->reference);
+ }
KX_ObjectActuator* tmpbaseact = new KX_ObjectActuator(gameobj,
+ obref,
forcevec.getValue(),
torquevec.getValue(),
dlocvec.getValue(),
@@ -941,6 +954,11 @@ void BL_ConvertActuators(char* maggiename,
= (bRandomActuator *) bact->data;
unsigned long seedArg = randAct->seed;
+ if (seedArg == 0)
+ {
+ seedArg = (int)(ketsjiEngine->GetRealTime()*100000.0);
+ seedArg ^= (intptr_t)randAct;
+ }
SCA_RandomActuator::KX_RANDOMACT_MODE modeArg
= SCA_RandomActuator::KX_RANDOMACT_NODEF;
SCA_RandomActuator *tmprandomact;
@@ -1097,7 +1115,7 @@ void BL_ConvertActuators(char* maggiename,
buf = txt_to_buf(_2dfilter->text);
if (buf)
{
- tmp->SetShaderText(STR_String(buf));
+ tmp->SetShaderText(buf);
MEM_freeN(buf);
}
}
@@ -1110,6 +1128,8 @@ void BL_ConvertActuators(char* maggiename,
{
bParentActuator *parAct = (bParentActuator *) bact->data;
int mode = KX_ParentActuator::KX_PARENT_NODEF;
+ bool addToCompound = true;
+ bool ghost = true;
KX_GameObject *tmpgob = NULL;
switch(parAct->type)
@@ -1117,6 +1137,8 @@ void BL_ConvertActuators(char* maggiename,
case ACT_PARENT_SET:
mode = KX_ParentActuator::KX_PARENT_SET;
tmpgob = converter->FindGameObject(parAct->ob);
+ addToCompound = !(parAct->flag & ACT_PARENT_COMPOUND);
+ ghost = !(parAct->flag & ACT_PARENT_GHOST);
break;
case ACT_PARENT_REMOVE:
mode = KX_ParentActuator::KX_PARENT_REMOVE;
@@ -1127,6 +1149,8 @@ void BL_ConvertActuators(char* maggiename,
KX_ParentActuator *tmpparact
= new KX_ParentActuator(gameobj,
mode,
+ addToCompound,
+ ghost,
tmpgob);
baseact = tmpparact;
break;
@@ -1144,7 +1168,7 @@ void BL_ConvertActuators(char* maggiename,
CIntValue* uniqueval = new CIntValue(uniqueint);
uniquename += uniqueval->GetText();
uniqueval->Release();
- baseact->SetName(STR_String(bact->name));
+ baseact->SetName(bact->name);
//gameobj->SetProperty(uniquename,baseact);
gameobj->AddActuator(baseact);
diff --git a/source/gameengine/Converter/KX_ConvertActuators.h b/source/gameengine/Converter/KX_ConvertActuators.h
index 03ea0db99b9..e38a9c74efc 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.h
+++ b/source/gameengine/Converter/KX_ConvertActuators.h
@@ -35,7 +35,6 @@ void BL_ConvertActuators(char* maggiename,
class SCA_LogicManager* logicmgr,
class KX_Scene* scene,
class KX_KetsjiEngine* ketsjiEngine,
- int & executePriority,
int activeLayerBitInfo,
bool isInActiveLayer,
class RAS_IRenderTools* rendertools,
diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp
index fb100b0a68b..85ab8e4f8b8 100644
--- a/source/gameengine/Converter/KX_ConvertControllers.cpp
+++ b/source/gameengine/Converter/KX_ConvertControllers.cpp
@@ -76,6 +76,7 @@ LinkControllerToActuators(
// Iterate through the actuators of the game blender
// controller and find the corresponding ketsji actuator.
+ game_controller->ReserveActuator(bcontr->totlinks);
for (int i=0;i<bcontr->totlinks;i++)
{
bActuator* bact = (bActuator*) bcontr->links[i];
@@ -92,52 +93,54 @@ void BL_ConvertControllers(
class KX_GameObject* gameobj,
SCA_LogicManager* logicmgr,
PyObject* pythondictionary,
- int &executePriority,
int activeLayerBitInfo,
bool isInActiveLayer,
KX_BlenderSceneConverter* converter
) {
int uniqueint=0;
+ int count = 0;
+ int executePriority=0;
bController* bcontr = (bController*)blenderobject->controllers.first;
while (bcontr)
{
+ bcontr = bcontr->next;
+ count++;
+ }
+ gameobj->ReserveController(count);
+ bcontr = (bController*)blenderobject->controllers.first;
+ while (bcontr)
+ {
SCA_IController* gamecontroller = NULL;
switch(bcontr->type)
{
case CONT_LOGIC_AND:
{
gamecontroller = new SCA_ANDController(gameobj);
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
break;
}
case CONT_LOGIC_OR:
{
gamecontroller = new SCA_ORController(gameobj);
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
break;
}
case CONT_LOGIC_NAND:
{
gamecontroller = new SCA_NANDController(gameobj);
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
break;
}
case CONT_LOGIC_NOR:
{
gamecontroller = new SCA_NORController(gameobj);
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
break;
}
case CONT_LOGIC_XOR:
{
gamecontroller = new SCA_XORController(gameobj);
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
break;
}
case CONT_LOGIC_XNOR:
{
gamecontroller = new SCA_XNORController(gameobj);
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
break;
}
case CONT_EXPRESSION:
@@ -147,37 +150,43 @@ void BL_ConvertControllers(
if (expressiontext.Length() > 0)
{
gamecontroller = new SCA_ExpressionController(gameobj,expressiontext);
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
-
}
break;
}
case CONT_PYTHON:
{
-
- // we should create a Python controller here
-
- SCA_PythonController* pyctrl = new SCA_PythonController(gameobj);
- gamecontroller = pyctrl;
-
bPythonCont* pycont = (bPythonCont*) bcontr->data;
+ SCA_PythonController* pyctrl = new SCA_PythonController(gameobj, pycont->mode);
+ gamecontroller = pyctrl;
+
pyctrl->SetDictionary(pythondictionary);
-
- if (pycont->text)
- {
- char *buf;
- // this is some blender specific code
- buf= txt_to_buf(pycont->text);
- if (buf)
+
+ if(pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) {
+ if (pycont->text)
{
- pyctrl->SetScriptText(STR_String(buf));
- pyctrl->SetScriptName(pycont->text->id.name+2);
- MEM_freeN(buf);
+ char *buf;
+ // this is some blender specific code
+ buf= txt_to_buf(pycont->text);
+ if (buf)
+ {
+ pyctrl->SetScriptText(STR_String(buf));
+ pyctrl->SetScriptName(pycont->text->id.name+2);
+ MEM_freeN(buf);
+ }
+
}
-
}
-
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
+ else {
+ /* let the controller print any warnings here when importing */
+ pyctrl->SetScriptText(STR_String(pycont->module));
+ pyctrl->SetScriptName(pycont->module); /* will be something like module.func so using it as the name is OK */
+ }
+
+ if(pycont->flag & CONT_PY_DEBUG) {
+ printf("\nDebuging \"%s\", module for object %s\n\texpect worse performance.\n", pycont->module, blenderobject->id.name+2);
+ pyctrl->SetDebug(true);
+ }
+
break;
}
default:
@@ -188,7 +197,9 @@ void BL_ConvertControllers(
if (gamecontroller)
{
+ LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
gamecontroller->SetExecutePriority(executePriority++);
+ gamecontroller->SetBookmark((bcontr->flag & CONT_PRIO) != 0);
gamecontroller->SetState(bcontr->state_mask);
STR_String uniquename = bcontr->name;
uniquename += "#CONTR#";
@@ -202,9 +213,18 @@ void BL_ConvertControllers(
converter->RegisterGameController(gamecontroller, bcontr);
if (bcontr->type==CONT_PYTHON) {
+ SCA_PythonController *pyctrl= static_cast<SCA_PythonController*>(gamecontroller);
/* not strictly needed but gives syntax errors early on and
* gives more pradictable performance for larger scripts */
- (static_cast<SCA_PythonController*>(gamecontroller))->Compile();
+ if(pyctrl->m_mode==SCA_PythonController::SCA_PYEXEC_SCRIPT)
+ pyctrl->Compile();
+ else {
+ /* We cant do this because importing runs the script which could end up accessing
+ * internal BGE functions, this is unstable while we're converting the scene.
+ * This is a pitty because its useful to see errors at startup but cant help it */
+
+ // pyctrl->Import();
+ }
}
//done with gamecontroller
diff --git a/source/gameengine/Converter/KX_ConvertControllers.h b/source/gameengine/Converter/KX_ConvertControllers.h
index 3e8a87fc90b..d340778290c 100644
--- a/source/gameengine/Converter/KX_ConvertControllers.h
+++ b/source/gameengine/Converter/KX_ConvertControllers.h
@@ -36,7 +36,6 @@ void BL_ConvertControllers(
class KX_GameObject* gameobj,
class SCA_LogicManager* logicmgr,
PyObject* pythondictionary,
- int & executePriority,
int activeLayerBitInfo,
bool isInActiveLayer,
class KX_BlenderSceneConverter* converter
diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp
index 53769dc30a1..5e8d6f3cbf0 100644
--- a/source/gameengine/Converter/KX_ConvertProperties.cpp
+++ b/source/gameengine/Converter/KX_ConvertProperties.cpp
@@ -129,6 +129,22 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan
// done with propval, release it
propval->Release();
}
+
+
+ /* Warn if we double up on attributes, this isnt quite right since it wont find inherited attributes however there arnt many */
+ for(PyAttributeDef *attrdef = KX_GameObject::Attributes; attrdef->m_name; attrdef++) {
+ if(strcmp(prop->name, attrdef->m_name)==0) {
+ printf("Warning! user defined property name \"%s\" is also a python attribute for object \"%s\"\n\tUse ob[\"%s\"] syntax to avoid conflict\n", prop->name, object->id.name+2, prop->name);
+ break;
+ }
+ }
+ for(PyMethodDef *methdef = KX_GameObject::Methods; methdef->ml_name; methdef++) {
+ if(strcmp(prop->name, methdef->ml_name)==0) {
+ printf("Warning! user defined property name \"%s\" is also a python method for object \"%s\"\n\tUse ob[\"%s\"] syntax to avoid conflict\n", prop->name, object->id.name+2, prop->name);
+ break;
+ }
+ }
+ /* end warning check */
prop = prop->next;
}
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 7d43b358502..0b395cfd402 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -95,178 +95,194 @@ void BL_ConvertSensors(struct Object* blenderobject,
KX_Scene* kxscene,
KX_KetsjiEngine* kxengine,
SCA_IInputDevice* keydev,
- int & executePriority,
int activeLayerBitInfo,
bool isInActiveLayer,
RAS_ICanvas* canvas,
KX_BlenderSceneConverter* converter
)
{
+ static bool reverseTableConverted = false;
-
-
- /* The reverse table. In order to not confuse ourselves, we */
- /* immediately convert all events that come in to KX codes. */
- gReverseKeyTranslateTable[LEFTMOUSE ] = SCA_IInputDevice::KX_LEFTMOUSE;
- gReverseKeyTranslateTable[MIDDLEMOUSE ] = SCA_IInputDevice::KX_MIDDLEMOUSE;
- gReverseKeyTranslateTable[RIGHTMOUSE ] = SCA_IInputDevice::KX_RIGHTMOUSE;
- gReverseKeyTranslateTable[WHEELUPMOUSE ] = SCA_IInputDevice::KX_WHEELUPMOUSE;
- gReverseKeyTranslateTable[WHEELDOWNMOUSE ] = SCA_IInputDevice::KX_WHEELDOWNMOUSE;
- gReverseKeyTranslateTable[MOUSEX ] = SCA_IInputDevice::KX_MOUSEX;
- gReverseKeyTranslateTable[MOUSEY ] = SCA_IInputDevice::KX_MOUSEY;
-
- // TIMERS
-
- gReverseKeyTranslateTable[TIMER0 ] = SCA_IInputDevice::KX_TIMER0;
- gReverseKeyTranslateTable[TIMER1 ] = SCA_IInputDevice::KX_TIMER1;
- gReverseKeyTranslateTable[TIMER2 ] = SCA_IInputDevice::KX_TIMER2;
-
- // SYSTEM
-
+ if (!reverseTableConverted)
+ {
+ reverseTableConverted = true;
+
+ /* The reverse table. In order to not confuse ourselves, we */
+ /* immediately convert all events that come in to KX codes. */
+ gReverseKeyTranslateTable[LEFTMOUSE ] = SCA_IInputDevice::KX_LEFTMOUSE;
+ gReverseKeyTranslateTable[MIDDLEMOUSE ] = SCA_IInputDevice::KX_MIDDLEMOUSE;
+ gReverseKeyTranslateTable[RIGHTMOUSE ] = SCA_IInputDevice::KX_RIGHTMOUSE;
+ gReverseKeyTranslateTable[WHEELUPMOUSE ] = SCA_IInputDevice::KX_WHEELUPMOUSE;
+ gReverseKeyTranslateTable[WHEELDOWNMOUSE ] = SCA_IInputDevice::KX_WHEELDOWNMOUSE;
+ gReverseKeyTranslateTable[MOUSEX ] = SCA_IInputDevice::KX_MOUSEX;
+ gReverseKeyTranslateTable[MOUSEY ] = SCA_IInputDevice::KX_MOUSEY;
+
+ // TIMERS
+
+ gReverseKeyTranslateTable[TIMER0 ] = SCA_IInputDevice::KX_TIMER0;
+ gReverseKeyTranslateTable[TIMER1 ] = SCA_IInputDevice::KX_TIMER1;
+ gReverseKeyTranslateTable[TIMER2 ] = SCA_IInputDevice::KX_TIMER2;
+
+ // SYSTEM
+
#if 0
- /* **** XXX **** */
- gReverseKeyTranslateTable[KEYBD ] = SCA_IInputDevice::KX_KEYBD;
- gReverseKeyTranslateTable[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD;
- gReverseKeyTranslateTable[REDRAW ] = SCA_IInputDevice::KX_REDRAW;
- gReverseKeyTranslateTable[INPUTCHANGE ] = SCA_IInputDevice::KX_INPUTCHANGE;
- gReverseKeyTranslateTable[QFULL ] = SCA_IInputDevice::KX_QFULL;
- gReverseKeyTranslateTable[WINFREEZE ] = SCA_IInputDevice::KX_WINFREEZE;
- gReverseKeyTranslateTable[WINTHAW ] = SCA_IInputDevice::KX_WINTHAW;
- gReverseKeyTranslateTable[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE;
- gReverseKeyTranslateTable[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT;
- gReverseKeyTranslateTable[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME;
- /* **** XXX **** */
+ /* **** XXX **** */
+ gReverseKeyTranslateTable[KEYBD ] = SCA_IInputDevice::KX_KEYBD;
+ gReverseKeyTranslateTable[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD;
+ gReverseKeyTranslateTable[REDRAW ] = SCA_IInputDevice::KX_REDRAW;
+ gReverseKeyTranslateTable[INPUTCHANGE ] = SCA_IInputDevice::KX_INPUTCHANGE;
+ gReverseKeyTranslateTable[QFULL ] = SCA_IInputDevice::KX_QFULL;
+ gReverseKeyTranslateTable[WINFREEZE ] = SCA_IInputDevice::KX_WINFREEZE;
+ gReverseKeyTranslateTable[WINTHAW ] = SCA_IInputDevice::KX_WINTHAW;
+ gReverseKeyTranslateTable[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE;
+ gReverseKeyTranslateTable[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT;
+ gReverseKeyTranslateTable[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME;
+ /* **** XXX **** */
#endif
- // standard keyboard
-
- gReverseKeyTranslateTable[AKEY ] = SCA_IInputDevice::KX_AKEY;
- gReverseKeyTranslateTable[BKEY ] = SCA_IInputDevice::KX_BKEY;
- gReverseKeyTranslateTable[CKEY ] = SCA_IInputDevice::KX_CKEY;
- gReverseKeyTranslateTable[DKEY ] = SCA_IInputDevice::KX_DKEY;
- gReverseKeyTranslateTable[EKEY ] = SCA_IInputDevice::KX_EKEY;
- gReverseKeyTranslateTable[FKEY ] = SCA_IInputDevice::KX_FKEY;
- gReverseKeyTranslateTable[GKEY ] = SCA_IInputDevice::KX_GKEY;
+
+ // standard keyboard
+
+ gReverseKeyTranslateTable[AKEY ] = SCA_IInputDevice::KX_AKEY;
+ gReverseKeyTranslateTable[BKEY ] = SCA_IInputDevice::KX_BKEY;
+ gReverseKeyTranslateTable[CKEY ] = SCA_IInputDevice::KX_CKEY;
+ gReverseKeyTranslateTable[DKEY ] = SCA_IInputDevice::KX_DKEY;
+ 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;
+ 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;
- gReverseKeyTranslateTable[LKEY ] = SCA_IInputDevice::KX_LKEY;
- gReverseKeyTranslateTable[MKEY ] = SCA_IInputDevice::KX_MKEY;
- gReverseKeyTranslateTable[NKEY ] = SCA_IInputDevice::KX_NKEY;
- gReverseKeyTranslateTable[OKEY ] = SCA_IInputDevice::KX_OKEY;
- gReverseKeyTranslateTable[PKEY ] = SCA_IInputDevice::KX_PKEY;
- gReverseKeyTranslateTable[QKEY ] = SCA_IInputDevice::KX_QKEY;
- gReverseKeyTranslateTable[RKEY ] = SCA_IInputDevice::KX_RKEY;
- gReverseKeyTranslateTable[SKEY ] = SCA_IInputDevice::KX_SKEY;
- gReverseKeyTranslateTable[TKEY ] = SCA_IInputDevice::KX_TKEY;
- gReverseKeyTranslateTable[UKEY ] = SCA_IInputDevice::KX_UKEY;
- gReverseKeyTranslateTable[VKEY ] = SCA_IInputDevice::KX_VKEY;
- gReverseKeyTranslateTable[WKEY ] = SCA_IInputDevice::KX_WKEY;
- gReverseKeyTranslateTable[XKEY ] = SCA_IInputDevice::KX_XKEY;
- gReverseKeyTranslateTable[YKEY ] = SCA_IInputDevice::KX_YKEY;
- gReverseKeyTranslateTable[ZKEY ] = SCA_IInputDevice::KX_ZKEY;
-
- gReverseKeyTranslateTable[ZEROKEY ] = SCA_IInputDevice::KX_ZEROKEY;
- gReverseKeyTranslateTable[ONEKEY ] = SCA_IInputDevice::KX_ONEKEY;
- gReverseKeyTranslateTable[TWOKEY ] = SCA_IInputDevice::KX_TWOKEY;
- gReverseKeyTranslateTable[THREEKEY ] = SCA_IInputDevice::KX_THREEKEY;
- gReverseKeyTranslateTable[FOURKEY ] = SCA_IInputDevice::KX_FOURKEY;
- gReverseKeyTranslateTable[FIVEKEY ] = SCA_IInputDevice::KX_FIVEKEY;
- gReverseKeyTranslateTable[SIXKEY ] = SCA_IInputDevice::KX_SIXKEY;
- gReverseKeyTranslateTable[SEVENKEY ] = SCA_IInputDevice::KX_SEVENKEY;
- gReverseKeyTranslateTable[EIGHTKEY ] = SCA_IInputDevice::KX_EIGHTKEY;
- gReverseKeyTranslateTable[NINEKEY ] = SCA_IInputDevice::KX_NINEKEY;
-
- gReverseKeyTranslateTable[CAPSLOCKKEY ] = SCA_IInputDevice::KX_CAPSLOCKKEY;
-
- gReverseKeyTranslateTable[LEFTCTRLKEY ] = SCA_IInputDevice::KX_LEFTCTRLKEY;
- gReverseKeyTranslateTable[LEFTALTKEY ] = SCA_IInputDevice::KX_LEFTALTKEY;
- gReverseKeyTranslateTable[RIGHTALTKEY ] = SCA_IInputDevice::KX_RIGHTALTKEY;
- gReverseKeyTranslateTable[RIGHTCTRLKEY ] = SCA_IInputDevice::KX_RIGHTCTRLKEY;
- gReverseKeyTranslateTable[RIGHTSHIFTKEY ] = SCA_IInputDevice::KX_RIGHTSHIFTKEY;
- gReverseKeyTranslateTable[LEFTSHIFTKEY ] = SCA_IInputDevice::KX_LEFTSHIFTKEY;
-
- gReverseKeyTranslateTable[ESCKEY ] = SCA_IInputDevice::KX_ESCKEY;
- gReverseKeyTranslateTable[TABKEY ] = SCA_IInputDevice::KX_TABKEY;
- gReverseKeyTranslateTable[RETKEY ] = SCA_IInputDevice::KX_RETKEY;
- gReverseKeyTranslateTable[SPACEKEY ] = SCA_IInputDevice::KX_SPACEKEY;
- gReverseKeyTranslateTable[LINEFEEDKEY ] = SCA_IInputDevice::KX_LINEFEEDKEY;
- gReverseKeyTranslateTable[BACKSPACEKEY ] = SCA_IInputDevice::KX_BACKSPACEKEY;
- gReverseKeyTranslateTable[DELKEY ] = SCA_IInputDevice::KX_DELKEY;
- gReverseKeyTranslateTable[SEMICOLONKEY ] = SCA_IInputDevice::KX_SEMICOLONKEY;
- gReverseKeyTranslateTable[PERIODKEY ] = SCA_IInputDevice::KX_PERIODKEY;
- gReverseKeyTranslateTable[COMMAKEY ] = SCA_IInputDevice::KX_COMMAKEY;
- gReverseKeyTranslateTable[QUOTEKEY ] = SCA_IInputDevice::KX_QUOTEKEY;
- gReverseKeyTranslateTable[ACCENTGRAVEKEY ] = SCA_IInputDevice::KX_ACCENTGRAVEKEY;
- gReverseKeyTranslateTable[MINUSKEY ] = SCA_IInputDevice::KX_MINUSKEY;
- gReverseKeyTranslateTable[SLASHKEY ] = SCA_IInputDevice::KX_SLASHKEY;
- gReverseKeyTranslateTable[BACKSLASHKEY ] = SCA_IInputDevice::KX_BACKSLASHKEY;
- gReverseKeyTranslateTable[EQUALKEY ] = SCA_IInputDevice::KX_EQUALKEY;
- gReverseKeyTranslateTable[LEFTBRACKETKEY ] = SCA_IInputDevice::KX_LEFTBRACKETKEY;
- gReverseKeyTranslateTable[RIGHTBRACKETKEY ] = SCA_IInputDevice::KX_RIGHTBRACKETKEY;
-
- gReverseKeyTranslateTable[LEFTARROWKEY ] = SCA_IInputDevice::KX_LEFTARROWKEY;
- gReverseKeyTranslateTable[DOWNARROWKEY ] = SCA_IInputDevice::KX_DOWNARROWKEY;
- gReverseKeyTranslateTable[RIGHTARROWKEY ] = SCA_IInputDevice::KX_RIGHTARROWKEY;
- gReverseKeyTranslateTable[UPARROWKEY ] = SCA_IInputDevice::KX_UPARROWKEY;
-
- gReverseKeyTranslateTable[PAD2 ] = SCA_IInputDevice::KX_PAD2;
- gReverseKeyTranslateTable[PAD4 ] = SCA_IInputDevice::KX_PAD4;
- gReverseKeyTranslateTable[PAD6 ] = SCA_IInputDevice::KX_PAD6;
- gReverseKeyTranslateTable[PAD8 ] = SCA_IInputDevice::KX_PAD8;
-
- gReverseKeyTranslateTable[PAD1 ] = SCA_IInputDevice::KX_PAD1;
- gReverseKeyTranslateTable[PAD3 ] = SCA_IInputDevice::KX_PAD3;
- gReverseKeyTranslateTable[PAD5 ] = SCA_IInputDevice::KX_PAD5;
- gReverseKeyTranslateTable[PAD7 ] = SCA_IInputDevice::KX_PAD7;
- gReverseKeyTranslateTable[PAD9 ] = SCA_IInputDevice::KX_PAD9;
-
- gReverseKeyTranslateTable[PADPERIOD ] = SCA_IInputDevice::KX_PADPERIOD;
- gReverseKeyTranslateTable[PADSLASHKEY ] = SCA_IInputDevice::KX_PADSLASHKEY;
- gReverseKeyTranslateTable[PADASTERKEY ] = SCA_IInputDevice::KX_PADASTERKEY;
-
- gReverseKeyTranslateTable[PAD0 ] = SCA_IInputDevice::KX_PAD0;
- gReverseKeyTranslateTable[PADMINUS ] = SCA_IInputDevice::KX_PADMINUS;
- gReverseKeyTranslateTable[PADENTER ] = SCA_IInputDevice::KX_PADENTER;
- gReverseKeyTranslateTable[PADPLUSKEY ] = SCA_IInputDevice::KX_PADPLUSKEY;
-
-
- gReverseKeyTranslateTable[F1KEY ] = SCA_IInputDevice::KX_F1KEY;
- gReverseKeyTranslateTable[F2KEY ] = SCA_IInputDevice::KX_F2KEY;
- gReverseKeyTranslateTable[F3KEY ] = SCA_IInputDevice::KX_F3KEY;
- gReverseKeyTranslateTable[F4KEY ] = SCA_IInputDevice::KX_F4KEY;
- gReverseKeyTranslateTable[F5KEY ] = SCA_IInputDevice::KX_F5KEY;
- gReverseKeyTranslateTable[F6KEY ] = SCA_IInputDevice::KX_F6KEY;
- gReverseKeyTranslateTable[F7KEY ] = SCA_IInputDevice::KX_F7KEY;
- gReverseKeyTranslateTable[F8KEY ] = SCA_IInputDevice::KX_F8KEY;
- gReverseKeyTranslateTable[F9KEY ] = SCA_IInputDevice::KX_F9KEY;
- gReverseKeyTranslateTable[F10KEY ] = SCA_IInputDevice::KX_F10KEY;
- gReverseKeyTranslateTable[F11KEY ] = SCA_IInputDevice::KX_F11KEY;
- gReverseKeyTranslateTable[F12KEY ] = SCA_IInputDevice::KX_F12KEY;
-
- gReverseKeyTranslateTable[PAUSEKEY ] = SCA_IInputDevice::KX_PAUSEKEY;
- gReverseKeyTranslateTable[INSERTKEY ] = SCA_IInputDevice::KX_INSERTKEY;
- gReverseKeyTranslateTable[HOMEKEY ] = SCA_IInputDevice::KX_HOMEKEY;
- gReverseKeyTranslateTable[PAGEUPKEY ] = SCA_IInputDevice::KX_PAGEUPKEY;
- gReverseKeyTranslateTable[PAGEDOWNKEY ] = SCA_IInputDevice::KX_PAGEDOWNKEY;
- gReverseKeyTranslateTable[ENDKEY ] = SCA_IInputDevice::KX_ENDKEY;
-
+
+ gReverseKeyTranslateTable[IKEY ] = SCA_IInputDevice::KX_IKEY;
+ gReverseKeyTranslateTable[JKEY ] = SCA_IInputDevice::KX_JKEY;
+ gReverseKeyTranslateTable[KKEY ] = SCA_IInputDevice::KX_KKEY;
+ gReverseKeyTranslateTable[LKEY ] = SCA_IInputDevice::KX_LKEY;
+ gReverseKeyTranslateTable[MKEY ] = SCA_IInputDevice::KX_MKEY;
+ gReverseKeyTranslateTable[NKEY ] = SCA_IInputDevice::KX_NKEY;
+ gReverseKeyTranslateTable[OKEY ] = SCA_IInputDevice::KX_OKEY;
+ gReverseKeyTranslateTable[PKEY ] = SCA_IInputDevice::KX_PKEY;
+ gReverseKeyTranslateTable[QKEY ] = SCA_IInputDevice::KX_QKEY;
+ gReverseKeyTranslateTable[RKEY ] = SCA_IInputDevice::KX_RKEY;
+ gReverseKeyTranslateTable[SKEY ] = SCA_IInputDevice::KX_SKEY;
+ gReverseKeyTranslateTable[TKEY ] = SCA_IInputDevice::KX_TKEY;
+ gReverseKeyTranslateTable[UKEY ] = SCA_IInputDevice::KX_UKEY;
+ gReverseKeyTranslateTable[VKEY ] = SCA_IInputDevice::KX_VKEY;
+ gReverseKeyTranslateTable[WKEY ] = SCA_IInputDevice::KX_WKEY;
+ gReverseKeyTranslateTable[XKEY ] = SCA_IInputDevice::KX_XKEY;
+ gReverseKeyTranslateTable[YKEY ] = SCA_IInputDevice::KX_YKEY;
+ gReverseKeyTranslateTable[ZKEY ] = SCA_IInputDevice::KX_ZKEY;
+
+ gReverseKeyTranslateTable[ZEROKEY ] = SCA_IInputDevice::KX_ZEROKEY;
+ gReverseKeyTranslateTable[ONEKEY ] = SCA_IInputDevice::KX_ONEKEY;
+ gReverseKeyTranslateTable[TWOKEY ] = SCA_IInputDevice::KX_TWOKEY;
+ gReverseKeyTranslateTable[THREEKEY ] = SCA_IInputDevice::KX_THREEKEY;
+ gReverseKeyTranslateTable[FOURKEY ] = SCA_IInputDevice::KX_FOURKEY;
+ gReverseKeyTranslateTable[FIVEKEY ] = SCA_IInputDevice::KX_FIVEKEY;
+ gReverseKeyTranslateTable[SIXKEY ] = SCA_IInputDevice::KX_SIXKEY;
+ gReverseKeyTranslateTable[SEVENKEY ] = SCA_IInputDevice::KX_SEVENKEY;
+ gReverseKeyTranslateTable[EIGHTKEY ] = SCA_IInputDevice::KX_EIGHTKEY;
+ gReverseKeyTranslateTable[NINEKEY ] = SCA_IInputDevice::KX_NINEKEY;
+
+ gReverseKeyTranslateTable[CAPSLOCKKEY ] = SCA_IInputDevice::KX_CAPSLOCKKEY;
+
+ gReverseKeyTranslateTable[LEFTCTRLKEY ] = SCA_IInputDevice::KX_LEFTCTRLKEY;
+ gReverseKeyTranslateTable[LEFTALTKEY ] = SCA_IInputDevice::KX_LEFTALTKEY;
+ gReverseKeyTranslateTable[RIGHTALTKEY ] = SCA_IInputDevice::KX_RIGHTALTKEY;
+ gReverseKeyTranslateTable[RIGHTCTRLKEY ] = SCA_IInputDevice::KX_RIGHTCTRLKEY;
+ gReverseKeyTranslateTable[RIGHTSHIFTKEY ] = SCA_IInputDevice::KX_RIGHTSHIFTKEY;
+ gReverseKeyTranslateTable[LEFTSHIFTKEY ] = SCA_IInputDevice::KX_LEFTSHIFTKEY;
+
+ gReverseKeyTranslateTable[ESCKEY ] = SCA_IInputDevice::KX_ESCKEY;
+ gReverseKeyTranslateTable[TABKEY ] = SCA_IInputDevice::KX_TABKEY;
+ gReverseKeyTranslateTable[RETKEY ] = SCA_IInputDevice::KX_RETKEY;
+ gReverseKeyTranslateTable[SPACEKEY ] = SCA_IInputDevice::KX_SPACEKEY;
+ gReverseKeyTranslateTable[LINEFEEDKEY ] = SCA_IInputDevice::KX_LINEFEEDKEY;
+ gReverseKeyTranslateTable[BACKSPACEKEY ] = SCA_IInputDevice::KX_BACKSPACEKEY;
+ gReverseKeyTranslateTable[DELKEY ] = SCA_IInputDevice::KX_DELKEY;
+ gReverseKeyTranslateTable[SEMICOLONKEY ] = SCA_IInputDevice::KX_SEMICOLONKEY;
+ gReverseKeyTranslateTable[PERIODKEY ] = SCA_IInputDevice::KX_PERIODKEY;
+ gReverseKeyTranslateTable[COMMAKEY ] = SCA_IInputDevice::KX_COMMAKEY;
+ gReverseKeyTranslateTable[QUOTEKEY ] = SCA_IInputDevice::KX_QUOTEKEY;
+ gReverseKeyTranslateTable[ACCENTGRAVEKEY ] = SCA_IInputDevice::KX_ACCENTGRAVEKEY;
+ gReverseKeyTranslateTable[MINUSKEY ] = SCA_IInputDevice::KX_MINUSKEY;
+ gReverseKeyTranslateTable[SLASHKEY ] = SCA_IInputDevice::KX_SLASHKEY;
+ gReverseKeyTranslateTable[BACKSLASHKEY ] = SCA_IInputDevice::KX_BACKSLASHKEY;
+ gReverseKeyTranslateTable[EQUALKEY ] = SCA_IInputDevice::KX_EQUALKEY;
+ gReverseKeyTranslateTable[LEFTBRACKETKEY ] = SCA_IInputDevice::KX_LEFTBRACKETKEY;
+ gReverseKeyTranslateTable[RIGHTBRACKETKEY ] = SCA_IInputDevice::KX_RIGHTBRACKETKEY;
+
+ gReverseKeyTranslateTable[LEFTARROWKEY ] = SCA_IInputDevice::KX_LEFTARROWKEY;
+ gReverseKeyTranslateTable[DOWNARROWKEY ] = SCA_IInputDevice::KX_DOWNARROWKEY;
+ gReverseKeyTranslateTable[RIGHTARROWKEY ] = SCA_IInputDevice::KX_RIGHTARROWKEY;
+ gReverseKeyTranslateTable[UPARROWKEY ] = SCA_IInputDevice::KX_UPARROWKEY;
+
+ gReverseKeyTranslateTable[PAD2 ] = SCA_IInputDevice::KX_PAD2;
+ gReverseKeyTranslateTable[PAD4 ] = SCA_IInputDevice::KX_PAD4;
+ gReverseKeyTranslateTable[PAD6 ] = SCA_IInputDevice::KX_PAD6;
+ gReverseKeyTranslateTable[PAD8 ] = SCA_IInputDevice::KX_PAD8;
+
+ gReverseKeyTranslateTable[PAD1 ] = SCA_IInputDevice::KX_PAD1;
+ gReverseKeyTranslateTable[PAD3 ] = SCA_IInputDevice::KX_PAD3;
+ gReverseKeyTranslateTable[PAD5 ] = SCA_IInputDevice::KX_PAD5;
+ gReverseKeyTranslateTable[PAD7 ] = SCA_IInputDevice::KX_PAD7;
+ gReverseKeyTranslateTable[PAD9 ] = SCA_IInputDevice::KX_PAD9;
+
+ gReverseKeyTranslateTable[PADPERIOD ] = SCA_IInputDevice::KX_PADPERIOD;
+ gReverseKeyTranslateTable[PADSLASHKEY ] = SCA_IInputDevice::KX_PADSLASHKEY;
+ gReverseKeyTranslateTable[PADASTERKEY ] = SCA_IInputDevice::KX_PADASTERKEY;
+
+ gReverseKeyTranslateTable[PAD0 ] = SCA_IInputDevice::KX_PAD0;
+ gReverseKeyTranslateTable[PADMINUS ] = SCA_IInputDevice::KX_PADMINUS;
+ gReverseKeyTranslateTable[PADENTER ] = SCA_IInputDevice::KX_PADENTER;
+ gReverseKeyTranslateTable[PADPLUSKEY ] = SCA_IInputDevice::KX_PADPLUSKEY;
+
+
+ gReverseKeyTranslateTable[F1KEY ] = SCA_IInputDevice::KX_F1KEY;
+ gReverseKeyTranslateTable[F2KEY ] = SCA_IInputDevice::KX_F2KEY;
+ gReverseKeyTranslateTable[F3KEY ] = SCA_IInputDevice::KX_F3KEY;
+ gReverseKeyTranslateTable[F4KEY ] = SCA_IInputDevice::KX_F4KEY;
+ gReverseKeyTranslateTable[F5KEY ] = SCA_IInputDevice::KX_F5KEY;
+ gReverseKeyTranslateTable[F6KEY ] = SCA_IInputDevice::KX_F6KEY;
+ gReverseKeyTranslateTable[F7KEY ] = SCA_IInputDevice::KX_F7KEY;
+ gReverseKeyTranslateTable[F8KEY ] = SCA_IInputDevice::KX_F8KEY;
+ gReverseKeyTranslateTable[F9KEY ] = SCA_IInputDevice::KX_F9KEY;
+ gReverseKeyTranslateTable[F10KEY ] = SCA_IInputDevice::KX_F10KEY;
+ gReverseKeyTranslateTable[F11KEY ] = SCA_IInputDevice::KX_F11KEY;
+ gReverseKeyTranslateTable[F12KEY ] = SCA_IInputDevice::KX_F12KEY;
+
+ gReverseKeyTranslateTable[PAUSEKEY ] = SCA_IInputDevice::KX_PAUSEKEY;
+ gReverseKeyTranslateTable[INSERTKEY ] = SCA_IInputDevice::KX_INSERTKEY;
+ gReverseKeyTranslateTable[HOMEKEY ] = SCA_IInputDevice::KX_HOMEKEY;
+ gReverseKeyTranslateTable[PAGEUPKEY ] = SCA_IInputDevice::KX_PAGEUPKEY;
+ gReverseKeyTranslateTable[PAGEDOWNKEY ] = SCA_IInputDevice::KX_PAGEDOWNKEY;
+ gReverseKeyTranslateTable[ENDKEY ] = SCA_IInputDevice::KX_ENDKEY;
+ }
+
+ int executePriority = 0;
int uniqueint = 0;
+ int count = 0;
bSensor* sens = (bSensor*)blenderobject->sensors.first;
bool pos_pulsemode = false;
bool neg_pulsemode = false;
int frequency = 0;
bool invert = false;
bool level = false;
+ bool tap = false;
+ while (sens)
+ {
+ sens = sens->next;
+ count++;
+ }
+ gameobj->ReserveSensor(count);
+ sens = (bSensor*)blenderobject->sensors.first;
while(sens)
{
SCA_ISensor* gamesensor=NULL;
@@ -279,6 +295,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
frequency = sens->freq;
invert = !(sens->invert == 0);
level = !(sens->level == 0);
+ tap = !(sens->tap == 0);
switch (sens->type)
{
@@ -679,6 +696,11 @@ void BL_ConvertSensors(struct Object* blenderobject,
if (eventmgr)
{
int randomSeed = blenderrndsensor->seed;
+ if (randomSeed == 0)
+ {
+ randomSeed = (int)(kxengine->GetRealTime()*100000.0);
+ randomSeed ^= (intptr_t)blenderrndsensor;
+ }
gamesensor = new SCA_RandomSensor(eventmgr, gameobj, randomSeed);
}
}
@@ -766,7 +788,8 @@ void BL_ConvertSensors(struct Object* blenderobject,
frequency);
gamesensor->SetInvert(invert);
gamesensor->SetLevel(level);
- gamesensor->SetName(STR_String(sens->name));
+ gamesensor->SetTap(tap);
+ gamesensor->SetName(sens->name);
gameobj->AddSensor(gamesensor);
@@ -775,7 +798,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
//if (isInActiveLayer)
// gamesensor->RegisterToManager();
-
+ gamesensor->ReserveController(sens->totlinks);
for (int i=0;i<sens->totlinks;i++)
{
bController* linkedcont = (bController*) sens->links[i];
diff --git a/source/gameengine/Converter/KX_ConvertSensors.h b/source/gameengine/Converter/KX_ConvertSensors.h
index b18ffc10a2a..9162a866768 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.h
+++ b/source/gameengine/Converter/KX_ConvertSensors.h
@@ -35,7 +35,6 @@ void BL_ConvertSensors(struct Object* blenderobject,
class KX_Scene* kxscene,
class KX_KetsjiEngine* kxengine,
class SCA_IInputDevice* keydev,
- int & executePriority ,
int activeLayerBitInfo,
bool isInActiveLayer,
class RAS_ICanvas* canvas,
diff --git a/source/gameengine/Expressions/BoolValue.cpp b/source/gameengine/Expressions/BoolValue.cpp
index 13c870b68e5..d90da8b3a92 100644
--- a/source/gameengine/Expressions/BoolValue.cpp
+++ b/source/gameengine/Expressions/BoolValue.cpp
@@ -26,6 +26,9 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
+const STR_String CBoolValue::sTrueString = "TRUE";
+const STR_String CBoolValue::sFalseString = "FALSE";
+
CBoolValue::CBoolValue()
/*
@@ -45,7 +48,7 @@ CBoolValue::CBoolValue(bool inBool)
-CBoolValue::CBoolValue(bool innie,STR_String name,AllocationTYPE alloctype)
+CBoolValue::CBoolValue(bool innie,const char *name,AllocationTYPE alloctype)
{
m_bool = innie;
SetName(name);
@@ -190,9 +193,6 @@ double CBoolValue::GetNumber()
const STR_String& CBoolValue::GetText()
{
- static STR_String sTrueString = STR_String("TRUE");
- static STR_String sFalseString = STR_String("FALSE");
-
return m_bool ? sTrueString : sFalseString;
}
@@ -201,7 +201,7 @@ const STR_String& CBoolValue::GetText()
CValue* CBoolValue::GetReplica()
{
CBoolValue* replica = new CBoolValue(*this);
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
diff --git a/source/gameengine/Expressions/BoolValue.h b/source/gameengine/Expressions/BoolValue.h
index 9352b9d4b92..726619e7193 100644
--- a/source/gameengine/Expressions/BoolValue.h
+++ b/source/gameengine/Expressions/BoolValue.h
@@ -28,9 +28,12 @@ class CBoolValue : public CPropValue
//PLUGIN_DECLARE_SERIAL(CBoolValue,CValue)
public:
+ static const STR_String sTrueString;
+ static const STR_String sFalseString;
+
CBoolValue();
CBoolValue(bool inBool);
- CBoolValue(bool innie, STR_String name, AllocationTYPE alloctype = CValue::HEAPVALUE);
+ CBoolValue(bool innie, const char *name, AllocationTYPE alloctype = CValue::HEAPVALUE);
virtual const STR_String& GetText();
virtual double GetNumber();
diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt
index 6b2a835d648..e3942b46557 100644
--- a/source/gameengine/Expressions/CMakeLists.txt
+++ b/source/gameengine/Expressions/CMakeLists.txt
@@ -31,6 +31,7 @@ SET(INC
../../../source/kernel/gen_system
../../../intern/string
../../../intern/moto/include
+ ../../../source/gameengine/SceneGraph
${PYTHON_INC}
)
diff --git a/source/gameengine/Expressions/EmptyValue.cpp b/source/gameengine/Expressions/EmptyValue.cpp
index f72ddc47096..5d1273b5301 100644
--- a/source/gameengine/Expressions/EmptyValue.cpp
+++ b/source/gameengine/Expressions/EmptyValue.cpp
@@ -121,7 +121,7 @@ const STR_String & CEmptyValue::GetText()
CValue* CEmptyValue::GetReplica()
{
CEmptyValue* replica = new CEmptyValue(*this);
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
diff --git a/source/gameengine/Expressions/ErrorValue.cpp b/source/gameengine/Expressions/ErrorValue.cpp
index 651a772db19..a44abf8b22e 100644
--- a/source/gameengine/Expressions/ErrorValue.cpp
+++ b/source/gameengine/Expressions/ErrorValue.cpp
@@ -34,13 +34,15 @@ effect: constructs a new CErrorValue containing errormessage "Error"
-CErrorValue::CErrorValue(STR_String errmsg)
+CErrorValue::CErrorValue(const char *errmsg)
/*
pre:
effect: constructs a new CErrorValue containing errormessage errmsg
*/
{
- m_strErrorText = "[" + errmsg + "]";
+ m_strErrorText = "[";
+ m_strErrorText += errmsg;
+ m_strErrorText += "]";
SetError(true);
}
diff --git a/source/gameengine/Expressions/ErrorValue.h b/source/gameengine/Expressions/ErrorValue.h
index 5b5795196ba..b4b758feea7 100644
--- a/source/gameengine/Expressions/ErrorValue.h
+++ b/source/gameengine/Expressions/ErrorValue.h
@@ -25,7 +25,7 @@ public:
virtual const STR_String & GetText();
virtual double GetNumber();
CErrorValue();
- CErrorValue(STR_String errmsg);
+ CErrorValue(const char *errmsg);
virtual ~CErrorValue();
virtual CValue* Calc(VALUE_OPERATOR op, CValue* val);
virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
diff --git a/source/gameengine/Expressions/FloatValue.cpp b/source/gameengine/Expressions/FloatValue.cpp
index 212a55fe457..4de685a82c1 100644
--- a/source/gameengine/Expressions/FloatValue.cpp
+++ b/source/gameengine/Expressions/FloatValue.cpp
@@ -50,7 +50,7 @@ effect: constructs a new CFloatValue containing value fl
-CFloatValue::CFloatValue(float fl,STR_String name,AllocationTYPE alloctype)
+CFloatValue::CFloatValue(float fl,const char *name,AllocationTYPE alloctype)
/*
pre:
effect: constructs a new CFloatValue containing value fl
@@ -307,8 +307,8 @@ const STR_String & CFloatValue::GetText()
CValue* CFloatValue::GetReplica()
{
CFloatValue* replica = new CFloatValue(*this);
- replica->m_pstrRep = NULL;
- CValue::AddDataToReplica(replica);
+ replica->m_pstrRep = NULL; /* should be in CFloatValue::ProcessReplica() but its not defined, no matter */
+ replica->ProcessReplica();
return replica;
}
diff --git a/source/gameengine/Expressions/FloatValue.h b/source/gameengine/Expressions/FloatValue.h
index 41f70b5c54c..fb75b7c702b 100644
--- a/source/gameengine/Expressions/FloatValue.h
+++ b/source/gameengine/Expressions/FloatValue.h
@@ -23,7 +23,7 @@ class CFloatValue : public CPropValue
public:
CFloatValue();
CFloatValue(float fl);
- CFloatValue(float fl,STR_String name,AllocationTYPE alloctype=CValue::HEAPVALUE);
+ CFloatValue(float fl,const char *name,AllocationTYPE alloctype=CValue::HEAPVALUE);
virtual const STR_String & GetText();
diff --git a/source/gameengine/Expressions/IfExpr.cpp b/source/gameengine/Expressions/IfExpr.cpp
index 5d3eb3641ca..fcb37bff52d 100644
--- a/source/gameengine/Expressions/IfExpr.cpp
+++ b/source/gameengine/Expressions/IfExpr.cpp
@@ -15,6 +15,7 @@
#include "IfExpr.h"
#include "EmptyValue.h"
#include "ErrorValue.h"
+#include "BoolValue.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -72,14 +73,14 @@ ret: a new object containing the value of m_e1 if m_guard is a boolean TRUE
{
CValue *guardval;
guardval = m_guard->Calculate();
- STR_String text = guardval->GetText();
+ const STR_String& text = guardval->GetText();
guardval->Release();
- if (text == STR_String("TRUE"))
+ if (&text == &CBoolValue::sTrueString)
{
return m_e1->Calculate();
}
- else if (text == STR_String("FALSE"))
+ else if (&text == &CBoolValue::sFalseString)
{
return m_e2->Calculate();
}
diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp
index 66075dd8d42..b15b206a38a 100644
--- a/source/gameengine/Expressions/InputParser.cpp
+++ b/source/gameengine/Expressions/InputParser.cpp
@@ -38,7 +38,7 @@
// cool things like (IF(LOD==1,CCurvedValue,IF(LOD==2,CCurvedValue2)) etc...
#include "IfExpr.h"
-#if defined(WIN32) || defined(WIN64)
+#if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS)
#define strcasecmp _stricmp
#ifndef strtoll
@@ -66,7 +66,7 @@ CParser::~CParser()
-void CParser::ScanError(STR_String str)
+void CParser::ScanError(const char *str)
{
// sets the global variable errmsg to an errormessage with
// contents str, appending if it already exists
@@ -81,7 +81,7 @@ void CParser::ScanError(STR_String str)
-CExpression* CParser::Error(STR_String str)
+CExpression* CParser::Error(const char *str)
{
// makes and returns a new CConstExpr filled with an CErrorValue
// with string str
@@ -537,7 +537,7 @@ CExpression *CParser::Expr() {
}
CExpression* CParser::ProcessText
-(STR_String intext) {
+(const char *intext) {
// and parses the string in intext and returns it.
@@ -574,7 +574,7 @@ CExpression* CParser::ProcessText
-float CParser::GetFloat(STR_String txt)
+float CParser::GetFloat(STR_String& txt)
{
// returns parsed text into a float
// empty string returns -1
@@ -599,7 +599,7 @@ float CParser::GetFloat(STR_String txt)
return result;
}
-CValue* CParser::GetValue(STR_String txt, bool bFallbackToText)
+CValue* CParser::GetValue(STR_String& txt, bool bFallbackToText)
{
// returns parsed text into a value,
// empty string returns NULL value !
@@ -658,10 +658,41 @@ static PyMethodDef CParserMethods[] =
{ NULL,NULL} // Sentinel
};
+
+#if (PY_VERSION_HEX >= 0x03000000)
+static struct PyModuleDef Expression_module_def = {
+ {}, /* m_base */
+ "Expression", /* m_name */
+ 0, /* m_doc */
+ 0, /* m_size */
+ CParserMethods, /* m_methods */
+ 0, /* m_reload */
+ 0, /* m_traverse */
+ 0, /* m_clear */
+ 0, /* m_free */
+};
+#endif
+
extern "C" {
void initExpressionModule(void)
{
- Py_InitModule("Expression",CParserMethods);
+ PyObject *m;
+ /* Use existing module where possible
+ * be careful not to init any runtime vars after this */
+ m = PyImport_ImportModule( "Expression" );
+ if(m) {
+ Py_DECREF(m);
+ //return m;
+ }
+ else {
+ PyErr_Clear();
+
+#if (PY_VERSION_HEX >= 0x03000000)
+ PyModule_Create(&Expression_module_def);
+#else
+ Py_InitModule("Expression",CParserMethods);
+#endif
+ }
}
}
diff --git a/source/gameengine/Expressions/InputParser.h b/source/gameengine/Expressions/InputParser.h
index 3d517222639..810bdc244a8 100644
--- a/source/gameengine/Expressions/InputParser.h
+++ b/source/gameengine/Expressions/InputParser.h
@@ -27,9 +27,9 @@ public:
CParser();
virtual ~CParser();
- float GetFloat(STR_String txt);
- CValue* GetValue(STR_String txt, bool bFallbackToText=false);
- CExpression* ProcessText(STR_String intext);
+ float GetFloat(STR_String& txt);
+ CValue* GetValue(STR_String& txt, bool bFallbackToText=false);
+ CExpression* ProcessText(const char *intext);
void SetContext(CValue* context);
private:
@@ -86,8 +86,8 @@ private:
CValue* m_identifierContext;// context in which identifiers are looked up
- void ScanError(STR_String str);
- CExpression* Error(STR_String str);
+ void ScanError(const char *str);
+ CExpression* Error(const char *str);
void NextCh();
void TermChar(char c);
void DigRep();
diff --git a/source/gameengine/Expressions/IntValue.cpp b/source/gameengine/Expressions/IntValue.cpp
index 4e86f7bf789..227518e9439 100644
--- a/source/gameengine/Expressions/IntValue.cpp
+++ b/source/gameengine/Expressions/IntValue.cpp
@@ -54,7 +54,7 @@ effect: constructs a new CIntValue containing cInt innie
-CIntValue::CIntValue(cInt innie,STR_String name,AllocationTYPE alloctype)
+CIntValue::CIntValue(cInt innie,const char *name,AllocationTYPE alloctype)
{
m_int = innie;
SetName(name);
@@ -311,7 +311,7 @@ const STR_String & CIntValue::GetText()
CValue* CIntValue::GetReplica() {
CIntValue* replica = new CIntValue(*this);
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
replica->m_pstrRep = NULL;
return replica;
diff --git a/source/gameengine/Expressions/IntValue.h b/source/gameengine/Expressions/IntValue.h
index 0f3a38b274b..06bf1755749 100644
--- a/source/gameengine/Expressions/IntValue.h
+++ b/source/gameengine/Expressions/IntValue.h
@@ -32,7 +32,7 @@ public:
CIntValue();
CIntValue(cInt innie);
CIntValue(cInt innie,
- STR_String name,
+ const char *name,
AllocationTYPE alloctype=CValue::HEAPVALUE);
virtual CValue* Calc(VALUE_OPERATOR op,
diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp
index dd9b296dce1..a0d73c75d60 100644
--- a/source/gameengine/Expressions/ListValue.cpp
+++ b/source/gameengine/Expressions/ListValue.cpp
@@ -18,6 +18,7 @@
#include "StringValue.h"
#include "VoidValue.h"
#include <algorithm>
+#include "BoolValue.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -39,8 +40,10 @@ Py_ssize_t listvalue_bufferlen(PyObject* self)
PyObject* listvalue_buffer_item(PyObject* self, Py_ssize_t index)
{
CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self));
+ CValue *cval;
+
if (list==NULL) {
- PyErr_SetString(PyExc_IndexError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, "val = CList[i], "BGE_PROXY_ERROR_MSG);
return NULL;
}
@@ -49,43 +52,47 @@ PyObject* listvalue_buffer_item(PyObject* self, Py_ssize_t index)
if (index < 0)
index = count+index;
- if (index >= 0 && index < count)
- {
- PyObject* pyobj = list->GetValue(index)->ConvertValueToPython();
- if (pyobj)
- return pyobj;
- else
- return list->GetValue(index)->GetProxy();
-
+ if (index < 0 || index >= count) {
+ PyErr_SetString(PyExc_IndexError, "CList[i]: Python ListIndex out of range in CValueList");
+ return NULL;
}
- PyErr_SetString(PyExc_IndexError, "list[i]: Python ListIndex out of range in CValueList");
- return NULL;
+
+ cval= list->GetValue(index);
+
+ PyObject* pyobj = cval->ConvertValueToPython();
+ if (pyobj)
+ return pyobj;
+ else
+ return cval->GetProxy();
}
PyObject* listvalue_mapping_subscript(PyObject* self, PyObject* pyindex)
{
CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self));
if (list==NULL) {
- PyErr_SetString(PyExc_IndexError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, "value = CList[i], "BGE_PROXY_ERROR_MSG);
return NULL;
}
if (PyString_Check(pyindex))
{
- STR_String index(PyString_AsString(pyindex));
- CValue *item = ((CListValue*) list)->FindValue(index);
- if (item)
- return item->GetProxy();
-
+ CValue *item = ((CListValue*) list)->FindValue(PyString_AsString(pyindex));
+ if (item) {
+ PyObject* pyobj = item->ConvertValueToPython();
+ if(pyobj)
+ return pyobj;
+ else
+ return item->GetProxy();
+ }
}
- if (PyInt_Check(pyindex))
+ else if (PyInt_Check(pyindex))
{
int index = PyInt_AsLong(pyindex);
- return listvalue_buffer_item(self, index);
+ return listvalue_buffer_item(self, index); /* wont add a ref */
}
PyObject *pyindex_str = PyObject_Repr(pyindex); /* new ref */
- PyErr_Format(PyExc_KeyError, "list[key]: '%s' key not in list", PyString_AsString(pyindex_str));
+ PyErr_Format(PyExc_KeyError, "CList[key]: '%s' key not in list", PyString_AsString(pyindex_str));
Py_DECREF(pyindex_str);
return NULL;
}
@@ -96,7 +103,7 @@ PyObject* listvalue_buffer_slice(PyObject* self,Py_ssize_t ilow, Py_ssize_t ihig
{
CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self));
if (list==NULL) {
- PyErr_SetString(PyExc_IndexError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, "val = CList[i:j], "BGE_PROXY_ERROR_MSG);
return NULL;
}
@@ -127,73 +134,79 @@ PyObject* listvalue_buffer_slice(PyObject* self,Py_ssize_t ilow, Py_ssize_t ihig
}
-
-static PyObject *
-listvalue_buffer_concat(PyObject * self, PyObject * other)
+/* clist + list, return a list that python owns */
+static PyObject *listvalue_buffer_concat(PyObject * self, PyObject * other)
{
CListValue *listval= static_cast<CListValue *>(BGE_PROXY_REF(self));
+ int i, numitems, numitems_orig;
+
if (listval==NULL) {
- PyErr_SetString(PyExc_IndexError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, "CList+other, "BGE_PROXY_ERROR_MSG);
return NULL;
}
+ numitems_orig= listval->GetCount();
+
// for now, we support CListValue concatenated with items
// and CListValue concatenated to Python Lists
// and CListValue concatenated with another CListValue
- listval->AddRef();
- if (other->ob_type == &PyList_Type)
+ /* Shallow copy, dont use listval->GetReplica(), it will screw up with KX_GameObjects */
+ CListValue* listval_new = new CListValue();
+
+ if (PyList_Check(other))
{
+ CValue* listitemval;
bool error = false;
-
- int i;
- int numitems = PyList_Size(other);
+
+ numitems = PyList_Size(other);
+
+ /* copy the first part of the list */
+ listval_new->Resize(numitems_orig + numitems);
+ for (i=0;i<numitems_orig;i++)
+ listval_new->SetValue(i, listval->GetValue(i)->AddRef());
+
for (i=0;i<numitems;i++)
{
- PyObject* listitem = PyList_GetItem(other,i);
- CValue* listitemval = listval->ConvertPythonToValue(listitem);
- if (listitemval)
- {
- listval->Add(listitemval);
- } else
- {
- error = true;
+ listitemval = listval->ConvertPythonToValue(PyList_GetItem(other,i), "cList + pyList: CListValue, ");
+
+ if (listitemval) {
+ listval_new->SetValue(i+numitems_orig, listitemval);
+ } else {
+ error= true;
+ break;
}
}
-
+
if (error) {
- PyErr_SetString(PyExc_SystemError, "list.append(val): couldn't add one or more items to this CValueList");
- return NULL;
+ listval_new->Resize(numitems_orig+i); /* resize so we dont try release NULL pointers */
+ listval_new->Release();
+ return NULL; /* ConvertPythonToValue above sets the error */
}
-
- } else
- {
- if (other->ob_type == &CListValue::Type)
- {
- // add items from otherlist to this list
- CListValue* otherval = (CListValue*) other;
-
-
- for (int i=0;i<otherval->GetCount();i++)
- {
- otherval->Add(listval->GetValue(i)->AddRef());
- }
- }
- else
- {
- CValue* objval = listval->ConvertPythonToValue(other);
- if (objval)
- {
- listval->Add(objval);
- } else
- {
- PyErr_SetString(PyExc_SystemError, "list.append(i): couldn't add item to this CValueList");
- return NULL;
- }
+
+ }
+ else if (PyObject_TypeCheck(other, &CListValue::Type)) {
+ // add items from otherlist to this list
+ CListValue* otherval = static_cast<CListValue *>(BGE_PROXY_REF(other));
+ if(otherval==NULL) {
+ listval_new->Release();
+ PyErr_SetString(PyExc_SystemError, "CList+other, "BGE_PROXY_ERROR_MSG);
+ return NULL;
}
+
+ numitems = otherval->GetCount();
+
+ /* copy the first part of the list */
+ listval_new->Resize(numitems_orig + numitems); /* resize so we dont try release NULL pointers */
+ for (i=0;i<numitems_orig;i++)
+ listval_new->SetValue(i, listval->GetValue(i)->AddRef());
+
+ /* now copy the other part of the list */
+ for (i=0;i<numitems;i++)
+ listval_new->SetValue(i+numitems_orig, otherval->GetValue(i)->AddRef());
+
}
-
- return self;
+ return listval_new->NewProxy(true); /* python owns this list */
}
@@ -203,9 +216,15 @@ static PySequenceMethods listvalue_as_sequence = {
listvalue_buffer_concat, /*sq_concat*/
NULL, /*sq_repeat*/
listvalue_buffer_item, /*sq_item*/
+#if (PY_VERSION_HEX >= 0x03000000) // TODO, slicing in py3?
+ NULL,
+ NULL,
+ NULL,
+#else
listvalue_buffer_slice, /*sq_slice*/
NULL, /*sq_ass_item*/
- NULL /*sq_ass_slice*/
+ NULL, /*sq_ass_slice*/
+#endif
};
@@ -220,8 +239,13 @@ static PyMappingMethods instance_as_mapping = {
PyTypeObject CListValue::Type = {
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"CListValue", /*tp_name*/
sizeof(PyObjectPlus_Proxy), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -256,10 +280,17 @@ PyParentObject CListValue::Parents[] = {
PyMethodDef CListValue::Methods[] = {
+ /* List style access */
{"append", (PyCFunction)CListValue::sPyappend,METH_O},
{"reverse", (PyCFunction)CListValue::sPyreverse,METH_NOARGS},
{"index", (PyCFunction)CListValue::sPyindex,METH_O},
{"count", (PyCFunction)CListValue::sPycount,METH_O},
+
+ /* Dict style access */
+ {"get", (PyCFunction)CListValue::sPyget,METH_VARARGS},
+ {"has_key", (PyCFunction)CListValue::sPyhas_key,METH_O},
+
+ /* Own cvalue funcs */
{"from_id", (PyCFunction)CListValue::sPyfrom_id,METH_O},
{NULL,NULL} //Sentinel
@@ -273,6 +304,10 @@ PyObject* CListValue::py_getattro(PyObject* attr) {
py_getattro_up(CValue);
}
+PyObject* CListValue::py_getattro_dict() {
+ py_getattro_dict_up(CValue);
+}
+
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
@@ -320,7 +355,7 @@ const STR_String & CListValue::GetText()
CValue* CListValue::GetReplica() {
CListValue* replica = new CListValue(*this);
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
replica->m_bReleaseContents=true; // for copy, complete array is copied for now...
// copy all values
@@ -370,23 +405,21 @@ void CListValue::ReleaseAndRemoveAll()
CValue* CListValue::FindValue(const STR_String & name)
{
- CValue* resultval = NULL;
- int i=0;
+ for (int i=0; i < GetCount(); i++)
+ if (GetValue(i)->GetName() == name)
+ return GetValue(i);
- while (!resultval && i < GetCount())
- {
- CValue* myval = GetValue(i);
-
- if (myval->GetName() == name)
- resultval = GetValue(i)->AddRef(); // add referencecount
- else
- i++;
-
- }
- return resultval;
+ return NULL;
}
-
+CValue* CListValue::FindValue(const char * name)
+{
+ for (int i=0; i < GetCount(); i++)
+ if (GetValue(i)->GetName() == name)
+ return GetValue(i);
+
+ return NULL;
+}
bool CListValue::SearchValue(CValue *val)
{
@@ -433,14 +466,24 @@ void CListValue::MergeList(CListValue *otherlist)
{
SetValue(i+numelements,otherlist->GetValue(i)->AddRef());
}
-
}
-
PyObject* CListValue::Pyappend(PyObject* value)
{
- return listvalue_buffer_concat(m_proxy, value); /* m_proxy is the same as self */
+ CValue* objval = ConvertPythonToValue(value, "CList.append(i): CValueList, ");
+
+ if (!objval) /* ConvertPythonToValue sets the error */
+ return NULL;
+
+ if (!BGE_PROXY_PYOWNS(m_proxy)) {
+ PyErr_SetString(PyExc_TypeError, "CList.append(i): this CValueList is used internally for the game engine and can't be modified");
+ return NULL;
+ }
+
+ Add(objval);
+
+ Py_RETURN_NONE;
}
@@ -461,13 +504,12 @@ bool CListValue::CheckEqual(CValue* first,CValue* second)
if (eqval==NULL)
return false;
-
- STR_String txt = eqval->GetText();
- eqval->Release();
- if (txt=="TRUE")
+ const STR_String& text = eqval->GetText();
+ if (&text==&CBoolValue::sTrueString)
{
result = true;
}
+ eqval->Release();
return result;
}
@@ -478,7 +520,7 @@ PyObject* CListValue::Pyindex(PyObject *value)
{
PyObject* result = NULL;
- CValue* checkobj = ConvertPythonToValue(value);
+ CValue* checkobj = ConvertPythonToValue(value, "val = cList[i]: CValueList, ");
if (checkobj==NULL)
return NULL; /* ConvertPythonToValue sets the error */
@@ -495,7 +537,7 @@ PyObject* CListValue::Pyindex(PyObject *value)
checkobj->Release();
if (result==NULL) {
- PyErr_SetString(PyExc_ValueError, "list.index(x): x not in CListValue");
+ PyErr_SetString(PyExc_ValueError, "CList.index(x): x not in CListValue");
}
return result;
@@ -507,7 +549,7 @@ PyObject* CListValue::Pycount(PyObject* value)
{
int numfound = 0;
- CValue* checkobj = ConvertPythonToValue(value);
+ CValue* checkobj = ConvertPythonToValue(value, ""); /* error ignored */
if (checkobj==NULL) { /* in this case just return that there are no items in the list */
PyErr_Clear();
@@ -528,7 +570,35 @@ PyObject* CListValue::Pycount(PyObject* value)
return PyInt_FromLong(numfound);
}
+/* Matches python dict.get(key, [default]) */
+PyObject* CListValue::Pyget(PyObject *args)
+{
+ char *key;
+ PyObject* def = Py_None;
+
+ if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
+ return NULL;
+
+ CValue *item = FindValue((const char *)key);
+ if (item) {
+ PyObject* pyobj = item->ConvertValueToPython();
+ if (pyobj)
+ return pyobj;
+ else
+ return item->GetProxy();
+ }
+ Py_INCREF(def);
+ return def;
+}
+/* Matches python dict.has_key() */
+PyObject* CListValue::Pyhas_key(PyObject* value)
+{
+ if (PyString_Check(value) && FindValue((const char *)PyString_AsString(value)))
+ Py_RETURN_TRUE;
+
+ Py_RETURN_FALSE;
+}
PyObject* CListValue::Pyfrom_id(PyObject* value)
{
@@ -555,18 +625,24 @@ PyObject* CListValue::Pyfrom_id(PyObject* value)
CValue* CListValue::Calc(VALUE_OPERATOR op,CValue *val)
{
//assert(false); // todo: implement me!
- fprintf(stderr, "CValueList::Calc not yet implimented\n");
+ static int error_printed = 0;
+ if (error_printed==0) {
+ fprintf(stderr, "CValueList::Calc not yet implimented\n");
+ error_printed = 1;
+ }
return NULL;
}
-
-
CValue* CListValue::CalcFinal(VALUE_DATA_TYPE dtype,
VALUE_OPERATOR op,
CValue* val)
{
//assert(false); // todo: implement me!
- fprintf(stderr, "CValueList::CalcFinal not yet implimented\n");
+ static int error_printed = 0;
+ if (error_printed==0) {
+ fprintf(stderr, "CValueList::CalcFinal not yet implimented\n");
+ error_printed = 1;
+ }
return NULL;
}
diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h
index 2af5a330c43..68e900e25e0 100644
--- a/source/gameengine/Expressions/ListValue.h
+++ b/source/gameengine/Expressions/ListValue.h
@@ -46,6 +46,7 @@ public:
bool SearchValue(CValue* val);
CValue* FindValue(const STR_String & name);
+ CValue* FindValue(const char *name);
void ReleaseAndRemoveAll();
virtual void SetModified(bool bModified);
@@ -60,6 +61,7 @@ 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);
@@ -73,6 +75,8 @@ public:
KX_PYMETHOD_NOARGS(CListValue,reverse);
KX_PYMETHOD_O(CListValue,index);
KX_PYMETHOD_O(CListValue,count);
+ KX_PYMETHOD_VARARGS(CListValue,get);
+ KX_PYMETHOD_O(CListValue,has_key);
KX_PYMETHOD_O(CListValue,from_id);
diff --git a/source/gameengine/Expressions/Makefile b/source/gameengine/Expressions/Makefile
index 6736149bbcd..f46c0037200 100644
--- a/source/gameengine/Expressions/Makefile
+++ b/source/gameengine/Expressions/Makefile
@@ -41,4 +41,5 @@ CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../kernel/gen_system
+CPPFLAGS += -I../../gameengine/SceneGraph
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index 6cfa14ddc80..defb6853e67 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -50,14 +50,20 @@
#include "stdlib.h"
#include "PyObjectPlus.h"
#include "STR_String.h"
+#include "MT_Vector3.h"
/*------------------------------
* PyObjectPlus Type -- Every class, even the abstract one should have a Type
------------------------------*/
PyTypeObject PyObjectPlus::Type = {
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"PyObjectPlus", /*tp_name*/
sizeof(PyObjectPlus_Proxy), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -90,6 +96,7 @@ void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper
PyObjectPlus *self_plus= BGE_PROXY_REF(self);
if(self_plus) {
if(BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */
+ 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;
}
@@ -98,7 +105,7 @@ void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper
PyObject_DEL( self );
};
-PyObjectPlus::PyObjectPlus(PyTypeObject *T) // constructor
+PyObjectPlus::PyObjectPlus(PyTypeObject *T) : SG_QList() // constructor
{
MT_assert(T != NULL);
m_proxy= NULL;
@@ -113,13 +120,13 @@ PyMethodDef PyObjectPlus::Methods[] = {
};
PyAttributeDef PyObjectPlus::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("isValid", PyObjectPlus, pyattr_get_is_valid),
+ KX_PYATTRIBUTE_RO_FUNCTION("invalid", PyObjectPlus, pyattr_get_invalid),
{NULL} //Sentinel
};
-PyObject* PyObjectPlus::pyattr_get_is_valid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+PyObject* PyObjectPlus::pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
- Py_RETURN_TRUE;
+ Py_RETURN_FALSE;
}
/*------------------------------
@@ -137,13 +144,33 @@ PyObject *PyObjectPlus::py_base_getattro(PyObject * self, PyObject *attr)
{
PyObjectPlus *self_plus= BGE_PROXY_REF(self);
if(self_plus==NULL) {
- if(!strcmp("isValid", PyString_AsString(attr))) {
+ if(!strcmp("invalid", PyString_AsString(attr))) {
Py_RETURN_TRUE;
}
- PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
return NULL;
}
- return self_plus->py_getattro(attr);
+
+ 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;
}
/* This should be the entry in Type since it takes the C++ class from PyObjectPlus_Proxy */
@@ -151,7 +178,7 @@ int PyObjectPlus::py_base_setattro(PyObject *self, PyObject *attr, PyObject *val
{
PyObjectPlus *self_plus= BGE_PROXY_REF(self);
if(self_plus==NULL) {
- PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
return -1;
}
@@ -166,7 +193,7 @@ PyObject *PyObjectPlus::py_base_repr(PyObject *self) // This should be the ent
PyObjectPlus *self_plus= BGE_PROXY_REF(self);
if(self_plus==NULL) {
- PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
return NULL;
}
@@ -177,11 +204,7 @@ PyObject *PyObjectPlus::py_getattro(PyObject* attr)
{
PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
if (descr == NULL) {
- if (strcmp(PyString_AsString(attr), "__dict__")==0) {
- return py_getattr_dict(NULL, Type.tp_dict); /* no Attributes yet */
- }
- PyErr_Format(PyExc_AttributeError, "attribute \"%s\" not found", PyString_AsString(attr));
- return 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)) {
@@ -189,13 +212,16 @@ PyObject *PyObjectPlus::py_getattro(PyObject* attr)
} else if (descr->ob_type->tp_descr_get) {
return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, this->m_proxy);
} else {
- fprintf(stderr, "Unknown attribute type (PyObjectPlus::py_getattro)");
- return descr;
+ 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");
@@ -233,14 +259,14 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
{
bool *val = reinterpret_cast<bool*>(ptr);
ptr += sizeof(bool);
- PyList_SetItem(resultlist,i,PyInt_FromLong(*val));
+ PyList_SET_ITEM(resultlist,i,PyInt_FromLong(*val));
break;
}
case KX_PYATTRIBUTE_TYPE_SHORT:
{
short int *val = reinterpret_cast<short int*>(ptr);
ptr += sizeof(short int);
- PyList_SetItem(resultlist,i,PyInt_FromLong(*val));
+ PyList_SET_ITEM(resultlist,i,PyInt_FromLong(*val));
break;
}
case KX_PYATTRIBUTE_TYPE_ENUM:
@@ -255,14 +281,14 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
{
int *val = reinterpret_cast<int*>(ptr);
ptr += sizeof(int);
- PyList_SetItem(resultlist,i,PyInt_FromLong(*val));
+ PyList_SET_ITEM(resultlist,i,PyInt_FromLong(*val));
break;
}
case KX_PYATTRIBUTE_TYPE_FLOAT:
{
float *val = reinterpret_cast<float*>(ptr);
ptr += sizeof(float);
- PyList_SetItem(resultlist,i,PyFloat_FromDouble(*val));
+ PyList_SET_ITEM(resultlist,i,PyFloat_FromDouble(*val));
break;
}
default:
@@ -303,6 +329,16 @@ PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef
float *val = reinterpret_cast<float*>(ptr);
return PyFloat_FromDouble(*val);
}
+ case KX_PYATTRIBUTE_TYPE_VECTOR:
+ {
+ PyObject* resultlist = PyList_New(3);
+ MT_Vector3 *val = reinterpret_cast<MT_Vector3*>(ptr);
+ for (unsigned int i=0; i<3; i++)
+ {
+ PyList_SET_ITEM(resultlist,i,PyFloat_FromDouble((*val)[i]));
+ }
+ return resultlist;
+ }
case KX_PYATTRIBUTE_TYPE_STRING:
{
STR_String *val = reinterpret_cast<STR_String*>(ptr);
@@ -326,12 +362,12 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
if (!PySequence_Check(value))
{
PyErr_Format(PyExc_TypeError, "expected a sequence for attribute \"%s\"", attrdef->m_name);
- return 1;
+ return PY_SET_ATTR_FAIL;
}
if (PySequence_Size(value) != attrdef->m_length)
{
PyErr_Format(PyExc_TypeError, "incorrect number of elements in sequence for attribute \"%s\"", attrdef->m_name);
- return 1;
+ return PY_SET_ATTR_FAIL;
}
switch (attrdef->m_type)
{
@@ -339,7 +375,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
if (attrdef->m_setFunction == NULL)
{
PyErr_Format(PyExc_AttributeError, "function attribute without function for attribute \"%s\", report to blender.org", attrdef->m_name);
- return 1;
+ return PY_SET_ATTR_FAIL;
}
return (*attrdef->m_setFunction)(self, attrdef, value);
case KX_PYATTRIBUTE_TYPE_BOOL:
@@ -358,7 +394,7 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
default:
// should not happen
PyErr_Format(PyExc_AttributeError, "Unsupported attribute type for attribute \"%s\", report to blender.org", attrdef->m_name);
- return 1;
+ return PY_SET_ATTR_FAIL;
}
// let's implement a smart undo method
bufferSize *= attrdef->m_length;
@@ -495,6 +531,10 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
{
if ((*attrdef->m_checkFunction)(self, attrdef) != 0)
{
+ // if the checing function didnt set an error then set a generic one here so we dont set an error with no exception
+ if (PyErr_Occurred()==0)
+ PyErr_Format(PyExc_AttributeError, "type check error for attribute \"%s\", reasion unknown", attrdef->m_name);
+
// post check returned an error, restore values
UNDO_AND_ERROR:
if (undoBuffer)
@@ -502,12 +542,12 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
memcpy(sourceBuffer, undoBuffer, bufferSize);
free(undoBuffer);
}
- return 1;
+ return PY_SET_ATTR_FAIL;
}
}
if (undoBuffer)
free(undoBuffer);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
else // simple attribute value
{
@@ -516,11 +556,11 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
if (attrdef->m_setFunction == NULL)
{
PyErr_Format(PyExc_AttributeError, "function attribute without function \"%s\", report to blender.org", attrdef->m_name);
- return 1;
+ return PY_SET_ATTR_FAIL;
}
return (*attrdef->m_setFunction)(self, attrdef, value);
}
- if (attrdef->m_checkFunction != NULL)
+ if (attrdef->m_checkFunction != NULL || attrdef->m_type == KX_PYATTRIBUTE_TYPE_VECTOR)
{
// post check function is provided, prepare undo buffer
sourceBuffer = ptr;
@@ -544,9 +584,12 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
if (sourceBuffer)
bufferSize = strlen(reinterpret_cast<char*>(sourceBuffer))+1;
break;
+ case KX_PYATTRIBUTE_TYPE_VECTOR:
+ bufferSize = sizeof(MT_Vector3);
+ break;
default:
PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name);
- return 1;
+ return PY_SET_ATTR_FAIL;
}
if (bufferSize)
{
@@ -664,6 +707,42 @@ int PyObjectPlus::py_set_attrdef(void *self, const PyAttributeDef *attrdef, PyOb
*var = (float)val;
break;
}
+ case KX_PYATTRIBUTE_TYPE_VECTOR:
+ {
+ if (!PySequence_Check(value) || PySequence_Size(value) != 3)
+ {
+ PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name);
+ return PY_SET_ATTR_FAIL;
+ }
+ MT_Vector3 *var = reinterpret_cast<MT_Vector3*>(ptr);
+ for (int i=0; i<3; i++)
+ {
+ PyObject *item = PySequence_GetItem(value, i); /* new ref */
+ // we can decrement the reference immediately, the reference count
+ // is at least 1 because the item is part of an array
+ Py_DECREF(item);
+ double val = PyFloat_AsDouble(item);
+ if (val == -1.0 && PyErr_Occurred())
+ {
+ PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name);
+ goto RESTORE_AND_ERROR;
+ }
+ else if (attrdef->m_clamp)
+ {
+ if (val < attrdef->m_fmin)
+ val = attrdef->m_fmin;
+ else if (val > attrdef->m_fmax)
+ val = attrdef->m_fmax;
+ }
+ else if (val < attrdef->m_fmin || val > attrdef->m_fmax)
+ {
+ PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name);
+ goto RESTORE_AND_ERROR;
+ }
+ (*var)[i] = (MT_Scalar)val;
+ }
+ break;
+ }
case KX_PYATTRIBUTE_TYPE_STRING:
{
STR_String *var = reinterpret_cast<STR_String*>(ptr);
@@ -791,6 +870,31 @@ PyObject *PyObjectPlus::PyisA(PyObject *value) // Python wrapper for isA
return NULL;
}
+
+void PyObjectPlus::ProcessReplica()
+{
+ /* Clear the proxy, will be created again if needed with GetProxy()
+ * otherwise the PyObject will point to the wrong reference */
+ m_proxy= NULL;
+}
+
+/* Sometimes we might want to manually invalidate a BGE type even if
+ * it hasnt been released by the BGE, say for example when an object
+ * is removed from a scene, accessing it may cause problems.
+ *
+ * In this case the current proxy is made invalid, disowned,
+ * and will raise an error on access. However if python can get access
+ * to this class again it will make a new proxy and work as expected.
+ */
+void PyObjectPlus::InvalidateProxy() // check typename of each parent
+{
+ if(m_proxy) {
+ BGE_PROXY_REF(m_proxy)=NULL;
+ Py_DECREF(m_proxy);
+ m_proxy= NULL;
+ }
+}
+
/* 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
@@ -852,5 +956,80 @@ PyObject *PyObjectPlus::NewProxy_Ext(PyObjectPlus *self, PyTypeObject *tp, bool
return self->m_proxy;
}
+///////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////
+/* deprecation warning management */
+
+bool PyObjectPlus::m_ignore_deprecation_warnings(false);
+void PyObjectPlus::SetDeprecationWarnings(bool ignoreDeprecationWarnings)
+{
+ m_ignore_deprecation_warnings = ignoreDeprecationWarnings;
+}
+
+void PyObjectPlus::ShowDeprecationWarning_func(const char* old_way,const char* new_way)
+{
+ {
+ printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way);
+
+ // import sys; print '\t%s:%d' % (sys._getframe(0).f_code.co_filename, sys._getframe(0).f_lineno)
+
+ PyObject *getframe, *frame;
+ PyObject *f_lineno, *f_code, *co_filename;
+
+ getframe = PySys_GetObject((char *)"_getframe"); // borrowed
+ if (getframe) {
+ frame = PyObject_CallObject(getframe, NULL);
+ if (frame) {
+ f_lineno= PyObject_GetAttrString(frame, "f_lineno");
+ f_code= PyObject_GetAttrString(frame, "f_code");
+ if (f_lineno && f_code) {
+ 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));
+
+ Py_DECREF(f_lineno);
+ Py_DECREF(f_code);
+ Py_DECREF(co_filename);
+ Py_DECREF(frame);
+ return;
+ }
+ }
+
+ Py_XDECREF(f_lineno);
+ Py_XDECREF(f_code);
+ Py_DECREF(frame);
+ }
+
+ }
+ PyErr_Clear();
+ printf("\tERROR - Could not access sys._getframe(0).f_lineno or sys._getframe().f_code.co_filename\n");
+ }
+}
+
+void PyObjectPlus::ClearDeprecationWarning()
+{
+ WarnLink *wlink_next;
+ WarnLink *wlink = GetDeprecationWarningLinkFirst();
+
+ while(wlink)
+ {
+ wlink->warn_done= false; /* no need to NULL the link, its cleared before adding to the list next time round */
+ wlink_next= reinterpret_cast<WarnLink *>(wlink->link);
+ wlink->link= NULL;
+ wlink= wlink_next;
+ }
+ NullDeprecationWarning();
+}
+
+WarnLink* m_base_wlink_first= NULL;
+WarnLink* m_base_wlink_last= NULL;
+
+WarnLink* PyObjectPlus::GetDeprecationWarningLinkFirst(void) {return m_base_wlink_first;}
+WarnLink* PyObjectPlus::GetDeprecationWarningLinkLast(void) {return m_base_wlink_last;}
+void PyObjectPlus::SetDeprecationWarningFirst(WarnLink* wlink) {m_base_wlink_first= wlink;}
+void PyObjectPlus::SetDeprecationWarningLinkLast(WarnLink* wlink) {m_base_wlink_last= wlink;}
+void PyObjectPlus::NullDeprecationWarning() {m_base_wlink_first= m_base_wlink_last= NULL;}
+
#endif //NO_EXP_PYTHON_EMBEDDING
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index 370717a919b..369c00782cc 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -38,11 +38,30 @@
#include "KX_Python.h"
#include "STR_String.h"
+#include "MT_Vector3.h"
+#include "SG_QList.h"
/*------------------------------
* 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
+#endif
+
+
+
/*
Py_RETURN_NONE
Python 2.4 macro.
@@ -81,6 +100,36 @@ static inline void Py_Fatal(const char *M) {
exit(-1);
};
+
+/* Use with ShowDeprecationWarning macro */
+typedef struct {
+ bool warn_done;
+ void *link;
+} WarnLink;
+
+#define ShowDeprecationWarning(old_way, new_way) \
+{ \
+ static WarnLink wlink = {false, NULL}; \
+ if ((m_ignore_deprecation_warnings || wlink.warn_done)==0) \
+ { \
+ ShowDeprecationWarning_func(old_way, new_way); \
+ WarnLink *wlink_last= GetDeprecationWarningLinkLast(); \
+ ShowDeprecationWarning_func(old_way, new_way); \
+ wlink.warn_done = true; \
+ wlink.link = NULL; \
+ \
+ if(wlink_last) { \
+ wlink_last->link= (void *)&(wlink); \
+ SetDeprecationWarningLinkLast(&(wlink)); \
+ } else { \
+ SetDeprecationWarningFirst(&(wlink)); \
+ SetDeprecationWarningLinkLast(&(wlink)); \
+ } \
+ } \
+} \
+
+
+
typedef struct {
PyObject_HEAD /* required python macro */
class PyObjectPlus *ref;
@@ -92,7 +141,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 == py_base_dealloc)
+#define BGE_PROXY_CHECK_TYPE(_self) ((_self)->ob_type->tp_dealloc == PyObjectPlus::py_base_dealloc)
// This must be the first line of each
@@ -114,6 +163,9 @@ typedef struct {
// 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) \
\
@@ -125,21 +177,14 @@ typedef struct {
} else if (descr->ob_type->tp_descr_get) { \
return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, this->m_proxy); \
} else { \
- fprintf(stderr, "unknown attribute type"); \
- return descr; \
+ return NULL; \
} \
} else { \
- PyErr_Clear(); \
- PyObject *rvalue= Parent::py_getattro(attr); \
- \
- if (strcmp(PyString_AsString(attr), "__dict__")==0) { \
- return py_getattr_dict(rvalue, Type.tp_dict); \
- } \
- \
- return rvalue; \
- } \
- return NULL;
+ 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
@@ -182,30 +227,35 @@ typedef struct {
#define KX_PYMETHOD(class_name, method_name) \
PyObject* Py##method_name(PyObject* args, PyObject* kwds); \
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
+ if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \
}; \
#define KX_PYMETHOD_VARARGS(class_name, method_name) \
PyObject* Py##method_name(PyObject* args); \
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
+ if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \
}; \
#define KX_PYMETHOD_NOARGS(class_name, method_name) \
PyObject* Py##method_name(); \
static PyObject* sPy##method_name( PyObject* self) { \
+ if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \
}; \
#define KX_PYMETHOD_O(class_name, method_name) \
PyObject* Py##method_name(PyObject* value); \
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
+ if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \
}; \
#define KX_PYMETHOD_DOC(class_name, method_name) \
PyObject* Py##method_name(PyObject* args, PyObject* kwds); \
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
+ if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \
}; \
static const char method_name##_doc[]; \
@@ -213,6 +263,7 @@ typedef struct {
#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \
PyObject* Py##method_name(PyObject* args); \
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
+ if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \
}; \
static const char method_name##_doc[]; \
@@ -220,6 +271,7 @@ typedef struct {
#define KX_PYMETHOD_DOC_O(class_name, method_name) \
PyObject* Py##method_name(PyObject* value); \
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
+ if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \
}; \
static const char method_name##_doc[]; \
@@ -227,6 +279,7 @@ typedef struct {
#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \
PyObject* Py##method_name(); \
static PyObject* sPy##method_name( PyObject* self) { \
+ if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \
}; \
static const char method_name##_doc[]; \
@@ -276,6 +329,7 @@ enum KX_PYATTRIBUTE_TYPE {
KX_PYATTRIBUTE_TYPE_STRING,
KX_PYATTRIBUTE_TYPE_DUMMY,
KX_PYATTRIBUTE_TYPE_FUNCTION,
+ KX_PYATTRIBUTE_TYPE_VECTOR,
};
enum KX_PYATTRIBUTE_ACCESS {
@@ -313,97 +367,105 @@ typedef struct KX_PYATTRIBUTE_DEF {
int *m_intPtr;
float *m_floatPtr;
STR_String *m_stringPtr;
+ MT_Vector3 *m_vectorPtr;
} m_typeCheck;
} PyAttributeDef;
#define KX_PYATTRIBUTE_DUMMY(name) \
- { name, KX_PYATTRIBUTE_TYPE_DUMMY, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, 0, 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_DUMMY, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, 0, 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_BOOL_RW(name,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_BOOL_RW_CHECK(name,object,field,function) \
- { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_BOOL_RO(name,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RO, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RO, 0, 1, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
// enum field cannot be mapped to pointer (because we would need a pointer for each enum)
// use field size to verify mapping at runtime only, assuming enum size is equal to int size.
#define KX_PYATTRIBUTE_ENUM_RW(name,min,max,clamp,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_ENUM_RW_CHECK(name,min,max,clamp,object,field,function) \
- { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_ENUM_RO(name,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_SHORT_RW(name,min,max,clamp,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_SHORT_RW_CHECK(name,min,max,clamp,object,field,function) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_SHORT_RO(name,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_SHORT_ARRAY_RW(name,min,max,clamp,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_SHORT_ARRAY_RW_CHECK(name,min,max,clamp,object,field,length,function) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_SHORT_ARRAY_RO(name,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} }
// SHORT_LIST
#define KX_PYATTRIBUTE_SHORT_LIST_RW(name,min,max,clamp,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_SHORT_LIST_RW_CHECK(name,min,max,clamp,object,field,length,function) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_SHORT_LIST_RO(name,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_INT_RW(name,min,max,clamp,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_INT_RW_CHECK(name,min,max,clamp,object,field,function) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_INT_RO(name,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_INT_ARRAY_RW(name,min,max,clamp,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_INT_ARRAY_RW_CHECK(name,min,max,clamp,object,field,length,function) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_INT_ARRAY_RO(name,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
// INT_LIST
#define KX_PYATTRIBUTE_INT_LIST_RW(name,min,max,clamp,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_INT_LIST_RW_CHECK(name,min,max,clamp,object,field,length,function) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_INT_LIST_RO(name,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
// always clamp for float
#define KX_PYATTRIBUTE_FLOAT_RW(name,min,max,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} }
#define KX_PYATTRIBUTE_FLOAT_RW_CHECK(name,min,max,object,field,function) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} }
#define KX_PYATTRIBUTE_FLOAT_RO(name,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} }
#define KX_PYATTRIBUTE_FLOAT_ARRAY_RW(name,min,max,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL} }
#define KX_PYATTRIBUTE_FLOAT_ARRAY_RW_CHECK(name,min,max,object,field,length,function) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL} }
#define KX_PYATTRIBUTE_FLOAT_ARRAY_RO(name,object,field,length) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL} }
#define KX_PYATTRIBUTE_STRING_RW(name,min,max,clamp,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field} }
+ { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} }
#define KX_PYATTRIBUTE_STRING_RW_CHECK(name,min,max,clamp,object,field,function) \
- { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field} }
+ { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} }
#define KX_PYATTRIBUTE_STRING_RO(name,object,field) \
- { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field} }
+ { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} }
+
+#define KX_PYATTRIBUTE_VECTOR_RW(name,min,max,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field} }
+#define KX_PYATTRIBUTE_VECTOR_RW_CHECK(name,min,max,clamp,object,field,function) \
+ { name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field} }
+#define KX_PYATTRIBUTE_VECTOR_RO(name,object,field) \
+ { name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, offsetof(object,field), 0, 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field} }
#define KX_PYATTRIBUTE_RW_FUNCTION(name,object,getfunction,setfunction) \
- { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0.f, false, 0, 0, 1, NULL, &object::setfunction, &object::getfunction, {NULL, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0.f, false, 0, 0, 1, NULL, &object::setfunction, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_RO_FUNCTION(name,object,getfunction) \
- { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, 0, 0, 1, NULL, NULL, &object::getfunction, {NULL, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, 0, 0, 1, NULL, NULL, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_ARRAY_RW_FUNCTION(name,object,length,getfunction,setfunction) \
- { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0,f, false, 0, 0, length, NULL, &object::setfunction, &object::getfunction, {NULL, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0,f, false, 0, 0, length, NULL, &object::setfunction, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL} }
#define KX_PYATTRIBUTE_ARRAY_RO_FUNCTION(name,object,length,getfunction) \
- { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0,f, false, 0, 0, length, NULL, NULL, &object::getfunction, {NULL, NULL, NULL, NULL, NULL} }
+ { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0,f, false, 0, 0, length, NULL, NULL, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL} }
/*------------------------------
@@ -411,7 +473,18 @@ typedef struct KX_PYATTRIBUTE_DEF {
------------------------------*/
typedef PyTypeObject * PyParentObject; // Define the PyParent Object
-class PyObjectPlus
+// By making SG_QList the ultimate parent for PyObjectPlus objects, it
+// allows to put them in 2 different dynamic lists at the same time
+// The use of these links is interesting because they free of memory allocation
+// but it's very important not to mess up with them. If you decide that
+// the SG_QList or SG_DList component is used for something for a certain class,
+// they cannot can be used for anything else at a parent level!
+// What these lists are and what they are used for must be carefully documented
+// at the level where they are used.
+// DON'T MAKE ANY USE OF THESE LIST AT THIS LEVEL, they are already used
+// at SCA_IActuator, SCA_ISensor, SCA_IController level which rules out the
+// possibility to use them at SCA_ILogicBrick, CValue and PyObjectPlus level.
+class PyObjectPlus : public SG_QList
{ // The PyObjectPlus abstract class
Py_Header; // Always start with Py_Header
@@ -434,6 +507,7 @@ public:
/* 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);
@@ -449,12 +523,36 @@ public:
KX_PYMETHOD_O(PyObjectPlus,isA);
/* Kindof dumb, always returns True, the false case is checked for, before this function gets accessed */
- static PyObject* pyattr_get_is_valid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject *GetProxy_Ext(PyObjectPlus *self, PyTypeObject *tp);
static PyObject *NewProxy_Ext(PyObjectPlus *self, PyTypeObject *tp, bool py_owns);
+
+ void InvalidateProxy();
+
+ /**
+ * Makes sure any internal data owned by this class is deep copied.
+ */
+ virtual void ProcessReplica();
+
+
+ static bool m_ignore_deprecation_warnings;
+
+ static WarnLink* GetDeprecationWarningLinkFirst(void);
+ static WarnLink* GetDeprecationWarningLinkLast(void);
+ static void SetDeprecationWarningFirst(WarnLink* wlink);
+ static void SetDeprecationWarningLinkLast(WarnLink* wlink);
+ static void NullDeprecationWarning();
+
+ /** enable/disable display of deprecation warnings */
+ static void SetDeprecationWarnings(bool ignoreDeprecationWarnings);
+ /** Shows a deprecation warning */
+ static void ShowDeprecationWarning_func(const char* method,const char* prop);
+ static void ClearDeprecationWarning();
+
};
+
PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict);
#endif // _adr_py_lib_h_
diff --git a/source/gameengine/Expressions/SConscript b/source/gameengine/Expressions/SConscript
index 25adcf3e895..b5c69eafe6b 100644
--- a/source/gameengine/Expressions/SConscript
+++ b/source/gameengine/Expressions/SConscript
@@ -3,7 +3,7 @@ Import ('env')
sources = env.Glob('*.cpp')
-incs ='. #source/kernel/gen_system #intern/string #intern/moto/include'
+incs ='. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/SceneGraph'
incs += ' ' + env['BF_PYTHON_INC']
cxxflags = []
diff --git a/source/gameengine/Expressions/StringValue.cpp b/source/gameengine/Expressions/StringValue.cpp
index 2b3c62c411e..a7033fcf11c 100644
--- a/source/gameengine/Expressions/StringValue.cpp
+++ b/source/gameengine/Expressions/StringValue.cpp
@@ -34,7 +34,7 @@ effect: constructs a new CStringValue
m_strString = "[Illegal String constructor call]";
}
-CStringValue::CStringValue(STR_String txt,STR_String name,AllocationTYPE alloctype)
+CStringValue::CStringValue(const char *txt,const char *name,AllocationTYPE alloctype)
/*
pre:
effect: constructs a new CStringValue containing text txt
@@ -133,7 +133,7 @@ bool CStringValue::IsEqual(const STR_String & other)
CValue* CStringValue::GetReplica()
{
CStringValue* replica = new CStringValue(*this);
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
};
diff --git a/source/gameengine/Expressions/StringValue.h b/source/gameengine/Expressions/StringValue.h
index 16575ed7ffa..52f8a580f4d 100644
--- a/source/gameengine/Expressions/StringValue.h
+++ b/source/gameengine/Expressions/StringValue.h
@@ -26,7 +26,7 @@ class CStringValue : public CPropValue
public:
/// Construction / destruction
CStringValue();
- CStringValue (STR_String txt, STR_String name , AllocationTYPE alloctype = CValue::HEAPVALUE);
+ CStringValue (const char *txt, const char *name , AllocationTYPE alloctype = CValue::HEAPVALUE);
virtual ~CStringValue() {
};
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index 7cb97909119..e6ef9733da8 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -32,13 +32,17 @@
//////////////////////////////////////////////////////////////////////
double CValue::m_sZeroVec[3] = {0.0,0.0,0.0};
-bool CValue::m_ignore_deprecation_warnings(false);
#ifndef NO_EXP_PYTHON_EMBEDDING
PyTypeObject CValue::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"CValue",
sizeof(PyObjectPlus_Proxy),
0,
@@ -62,13 +66,14 @@ PyParentObject CValue::Parents[] = {
};
PyMethodDef CValue::Methods[] = {
-// { "printHello", (PyCFunction) CValue::sPyPrintHello, METH_VARARGS},
{ "getName", (PyCFunction) CValue::sPyGetName, METH_NOARGS},
{NULL,NULL} //Sentinel
};
PyObject* CValue::PyGetName()
{
+ ShowDeprecationWarning("getName()", "the name property");
+
return PyString_FromString(this->GetName());
}
@@ -287,13 +292,15 @@ CValue* CValue::GetProperty(const char *inName)
//
// Get text description of property with name <inName>, returns an empty string if there is no property named <inName>
//
-STR_String CValue::GetPropertyText(const STR_String & inName,const STR_String& deftext)
+const STR_String& CValue::GetPropertyText(const STR_String & inName)
{
+ const static STR_String sEmpty("");
+
CValue *property = GetProperty(inName);
if (property)
return property->GetText();
else
- return deftext;//String::sEmpty;
+ return sEmpty;
}
float CValue::GetPropertyNumber(const STR_String& inName,float defnumber)
@@ -439,27 +446,6 @@ int CValue::GetPropertyCount()
}
-
-
-
-void CValue::CloneProperties(CValue *replica)
-{
-
- if (m_pNamedPropertyArray)
- {
- replica->m_pNamedPropertyArray=NULL;
- std::map<STR_String,CValue*>::iterator it;
- for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++)
- {
- CValue *val = (*it).second->GetReplica();
- replica->SetProperty((*it).first,val);
- val->Release();
- }
- }
-
-
-}
-
double* CValue::GetVector3(bool bGetTransformedVec)
{
assertd(false); // don;t get vector from me
@@ -470,50 +456,12 @@ double* CValue::GetVector3(bool bGetTransformedVec)
/*---------------------------------------------------------------------------------------------------------------------
Reference Counting
---------------------------------------------------------------------------------------------------------------------*/
-//
-// Add a reference to this value
-//
-CValue *CValue::AddRef()
-{
- // Increase global reference count, used to see at the end of the program
- // if all CValue-derived classes have been dereferenced to 0
- //debug(gRefCountValue++);
-#ifdef _DEBUG
- //gRefCountValue++;
-#endif
- m_refcount++;
- return this;
-}
//
// Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
//
-int CValue::Release()
-{
- // Decrease global reference count, used to see at the end of the program
- // if all CValue-derived classes have been dereferenced to 0
- //debug(gRefCountValue--);
-#ifdef _DEBUG
- //gRefCountValue--;
-#endif
- // Decrease local reference count, if it reaches 0 the object should be freed
- if (--m_refcount > 0)
- {
- // Reference count normal, return new reference count
- return m_refcount;
- }
- else
- {
- // Reference count reached 0, delete ourselves and return 0
-// MT_assert(m_refcount==0, "Reference count reached sub-zero, object released too much");
-
- delete this;
- return 0;
- }
-
-}
@@ -534,23 +482,32 @@ void CValue::DisableRefCount()
-void CValue::AddDataToReplica(CValue *replica)
+void CValue::ProcessReplica() /* was AddDataToReplica in 2.48 */
{
- replica->m_refcount = 1;
-
+ m_refcount = 1;
+
#ifdef _DEBUG
//gRefCountValue++;
#endif
- replica->m_ValFlags.RefCountDisabled = false;
+ PyObjectPlus::ProcessReplica();
- replica->ReplicaSetName(GetName());
+ m_ValFlags.RefCountDisabled = false;
- //copy all props
- CloneProperties(replica);
+ /* copy all props */
+ if (m_pNamedPropertyArray)
+ {
+ std::map<STR_String,CValue*> *pOldArray = m_pNamedPropertyArray;
+ m_pNamedPropertyArray=NULL;
+ std::map<STR_String,CValue*>::iterator it;
+ for (it= pOldArray->begin(); (it != pOldArray->end()); it++)
+ {
+ CValue *val = (*it).second->GetReplica();
+ SetProperty((*it).first,val);
+ val->Release();
+ }
+ }
}
-
-
CValue* CValue::FindIdentifier(const STR_String& identifiername)
{
@@ -592,18 +549,22 @@ static PyMethodDef CValueMethods[] =
};
PyAttributeDef CValue::Attributes[] = {
+ KX_PYATTRIBUTE_RO_FUNCTION("name", CValue, pyattr_get_name),
{ 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
@@ -612,7 +573,16 @@ PyObject* CValue::py_getattro(PyObject *attr)
py_getattro_up(PyObjectPlus);
}
-CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
+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());
+}
+
+CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix)
{
CValue* vallie = NULL;
@@ -628,7 +598,7 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
for (i=0;i<numitems;i++)
{
PyObject* listitem = PyList_GetItem(pyobj,i); /* borrowed ref */
- CValue* listitemval = ConvertPythonToValue(listitem);
+ CValue* listitemval = ConvertPythonToValue(listitem, error_prefix);
if (listitemval)
{
listval->Add(listitemval);
@@ -665,13 +635,22 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
{
vallie = new CStringValue(PyString_AsString(pyobj),"");
} else
- if (pyobj->ob_type==&CValue::Type || pyobj->ob_type==&CListValue::Type)
+ if (BGE_PROXY_CHECK_TYPE(pyobj)) /* Note, dont let these get assigned to GameObject props, must check elsewhere */
{
- vallie = ((CValue*) pyobj)->AddRef();
+ 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);
+ }
} else
{
/* return an error value from the caller */
- PyErr_SetString(PyExc_TypeError, "This python type could not be converted to a to a game engine property");
+ PyErr_Format(PyExc_TypeError, "%scould convert python value to a game engine property", error_prefix);
}
return vallie;
@@ -679,21 +658,26 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
int CValue::py_delattro(PyObject *attr)
{
+ ShowDeprecationWarning("del ob.attr", "del ob['attr']");
+
char *attr_str= PyString_AsString(attr);
- if (RemoveProperty(STR_String(attr_str)))
+ if (RemoveProperty(attr_str))
return 0;
PyErr_Format(PyExc_AttributeError, "attribute \"%s\" dosnt exist", attr_str);
- return 1;
+ return PY_SET_ATTR_MISSING;
}
int CValue::py_setattro(PyObject *attr, PyObject* pyobj)
{
- char *attr_str= PyString_AsString(attr);
- CValue* oldprop = GetProperty(attr_str);
+ ShowDeprecationWarning("ob.attr = val", "ob['attr'] = val");
- CValue* vallie = ConvertPythonToValue(pyobj);
- if (vallie)
+ 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);
@@ -750,10 +734,40 @@ PyObject* CValue::PyMake(PyObject* ignored,PyObject* args)
}
*/
+#if (PY_VERSION_HEX >= 0x03000000)
+static struct PyModuleDef CValue_module_def = {
+ {}, /* m_base */
+ "CValue", /* m_name */
+ 0, /* m_doc */
+ 0, /* m_size */
+ CValueMethods, /* m_methods */
+ 0, /* m_reload */
+ 0, /* m_traverse */
+ 0, /* m_clear */
+ 0, /* m_free */
+};
+#endif
+
extern "C" {
void initCValue(void)
{
- Py_InitModule("CValue",CValueMethods);
+ PyObject *m;
+ /* Use existing module where possible
+ * be careful not to init any runtime vars after this */
+ m = PyImport_ImportModule( "CValue" );
+ if(m) {
+ Py_DECREF(m);
+ //return m;
+ }
+ else {
+ PyErr_Clear();
+
+#if (PY_VERSION_HEX >= 0x03000000)
+ PyModule_Create(&CValue_module_def);
+#else
+ Py_InitModule("CValue",CValueMethods);
+#endif
+ }
}
}
@@ -779,52 +793,3 @@ void CValue::SetValue(CValue* newval)
// no one should get here
assertd(newval->GetNumber() == 10121969);
}
-///////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-/* deprecation warning management */
-void CValue::SetDeprecationWarnings(bool ignoreDeprecationWarnings)
-{
- m_ignore_deprecation_warnings = ignoreDeprecationWarnings;
-}
-
-void CValue::ShowDeprecationWarning(const char* old_way,const char* new_way)
-{
- if (!m_ignore_deprecation_warnings) {
- printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way);
-
- // import sys; print '\t%s:%d' % (sys._getframe(0).f_code.co_filename, sys._getframe(0).f_lineno)
-
- PyObject *getframe, *frame;
- PyObject *f_lineno, *f_code, *co_filename;
-
- getframe = PySys_GetObject((char *)"_getframe"); // borrowed
- if (getframe) {
- frame = PyObject_CallObject(getframe, NULL);
- if (frame) {
- f_lineno= PyObject_GetAttrString(frame, "f_lineno");
- f_code= PyObject_GetAttrString(frame, "f_code");
- if (f_lineno && f_code) {
- 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));
-
- Py_DECREF(f_lineno);
- Py_DECREF(f_code);
- Py_DECREF(co_filename);
- Py_DECREF(frame);
- return;
- }
- }
-
- Py_XDECREF(f_lineno);
- Py_XDECREF(f_code);
- Py_DECREF(frame);
- }
-
- }
- PyErr_Clear();
- printf("\tERROR - Could not access sys._getframe(0).f_lineno or sys._getframe().f_code.co_filename\n");
- }
-}
-
diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h
index a687e1a493c..29ef19b46c9 100644
--- a/source/gameengine/Expressions/Value.h
+++ b/source/gameengine/Expressions/Value.h
@@ -225,16 +225,19 @@ public:
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual PyObject* ConvertValueToPython() {
return NULL;
}
- virtual CValue* ConvertPythonToValue(PyObject* pyobj);
+ 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);
+
virtual PyObject* ConvertKeysToPython( void );
KX_PYMETHOD_NOARGS(CValue,GetName);
@@ -258,17 +261,56 @@ public:
};
/// Reference Counting
- int GetRefCount() { return m_refcount; }
- virtual CValue* AddRef(); // Add a reference to this value
- virtual int Release(); // Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
-
+ int GetRefCount()
+ {
+ return m_refcount;
+ }
+
+ // Add a reference to this value
+ CValue* AddRef()
+ {
+ // Increase global reference count, used to see at the end of the program
+ // if all CValue-derived classes have been dereferenced to 0
+ //debug(gRefCountValue++);
+ #ifdef _DEBUG
+ //gRefCountValue++;
+ #endif
+ m_refcount++;
+ return this;
+ }
+
+ // Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
+ int Release()
+ {
+ // Decrease global reference count, used to see at the end of the program
+ // if all CValue-derived classes have been dereferenced to 0
+ //debug(gRefCountValue--);
+ #ifdef _DEBUG
+ //gRefCountValue--;
+ #endif
+ // Decrease local reference count, if it reaches 0 the object should be freed
+ if (--m_refcount > 0)
+ {
+ // Reference count normal, return new reference count
+ return m_refcount;
+ }
+ else
+ {
+ // Reference count reached 0, delete ourselves and return 0
+ // MT_assert(m_refcount==0, "Reference count reached sub-zero, object released too much");
+
+ delete this;
+ return 0;
+ }
+ }
+
/// Property Management
virtual void SetProperty(const STR_String& name,CValue* ioProperty); // Set property <ioProperty>, overwrites and releases a previous property with the same name if needed
virtual void SetProperty(const char* name,CValue* ioProperty);
virtual CValue* GetProperty(const char* inName); // Get pointer to a property with name <inName>, returns NULL if there is no property named <inName>
virtual CValue* GetProperty(const STR_String & inName);
- STR_String GetPropertyText(const STR_String & inName,const STR_String& deftext=""); // Get text description of property with name <inName>, returns an empty string if there is no property named <inName>
+ const STR_String& GetPropertyText(const STR_String & inName); // Get text description of property with name <inName>, returns an empty string if there is no property named <inName>
float GetPropertyNumber(const STR_String& inName,float defnumber);
virtual bool RemoveProperty(const char *inName); // Remove the property named <inName>, returns true if the property was succesfully removed, false if property was not found or could not be removed
virtual vector<STR_String> GetPropertyNames();
@@ -280,7 +322,6 @@ public:
virtual CValue* GetProperty(int inIndex); // Get property number <inIndex>
virtual int GetPropertyCount(); // Get the amount of properties assiocated with this value
- virtual void CloneProperties(CValue* replica);
virtual CValue* FindIdentifier(const STR_String& identifiername);
/** Set the wireframe color of this value depending on the CSG
* operator type <op>
@@ -292,21 +333,17 @@ public:
double* ZeroVector() { return m_sZeroVec; };
virtual double* GetVector3(bool bGetTransformedVec = false);
- virtual STR_String GetName() = 0; // Retrieve the name of the value
- virtual void SetName(STR_String name) = 0; // Set the name of the value
- virtual void ReplicaSetName(STR_String name) = 0;
+ virtual STR_String& GetName() = 0; // Retrieve the name of the value
+ virtual void SetName(const char *name) = 0; // Set the name of the value
/** Sets the value to this cvalue.
* @attention this particular function should never be called. Why not abstract? */
virtual void SetValue(CValue* newval);
virtual CValue* GetReplica() =0;
+ virtual void ProcessReplica();
//virtual CValue* Copy() = 0;
STR_String op2str(VALUE_OPERATOR op);
- /** enable/disable display of deprecation warnings */
- static void SetDeprecationWarnings(bool ignoreDeprecationWarnings);
- /** Shows a deprecation warning */
- static void ShowDeprecationWarning(const char* method,const char* prop);
// setting / getting flags
inline void SetSelected(bool bSelected) { m_ValFlags.Selected = bSelected; }
@@ -327,10 +364,10 @@ public:
virtual void SetCustomFlag2(bool bCustomFlag) { m_ValFlags.CustomFlag2 = bCustomFlag;};
virtual bool IsCustomFlag2() { return m_ValFlags.CustomFlag2;};
-
+
protected:
virtual void DisableRefCount(); // Disable reference counting for this value
- virtual void AddDataToReplica(CValue* replica);
+ //virtual void AddDataToReplica(CValue* replica);
virtual ~CValue();
private:
// Member variables
@@ -338,7 +375,6 @@ private:
ValueFlags m_ValFlags; // Frequently used flags in a bitfield (low memoryusage)
int m_refcount; // Reference Counter
static double m_sZeroVec[3];
- static bool m_ignore_deprecation_warnings;
};
@@ -386,49 +422,28 @@ public:
#else
CPropValue() :
#endif //NO_EXP_PYTHON_EMBEDDING
- m_pstrNewName(NULL)
+ m_strNewName()
{
}
virtual ~CPropValue()
{
- if (m_pstrNewName)
- {
- delete m_pstrNewName;
- m_pstrNewName = NULL;
- }
}
- virtual void SetName(STR_String name) {
- if (m_pstrNewName)
- {
- delete m_pstrNewName;
- m_pstrNewName = NULL;
- }
- if (name.Length())
- m_pstrNewName = new STR_String(name);
- }
- virtual void ReplicaSetName(STR_String name) {
- m_pstrNewName=NULL;
- if (name.Length())
- m_pstrNewName = new STR_String(name);
+ virtual void SetName(const char *name) {
+ m_strNewName = name;
}
- virtual STR_String GetName() {
+ virtual STR_String& GetName() {
//STR_String namefromprop = GetPropertyText("Name");
//if (namefromprop.Length() > 0)
// return namefromprop;
-
- if (m_pstrNewName)
- {
- return *m_pstrNewName;
- }
- return STR_String("");
+ return m_strNewName;
}; // name of Value
protected:
- STR_String* m_pstrNewName; // Identification
+ STR_String m_strNewName; // Identification
};
#endif // !defined _VALUEBASECLASS_H
diff --git a/source/gameengine/Expressions/VectorValue.cpp b/source/gameengine/Expressions/VectorValue.cpp
index 497a50b90e7..c58c78e6ebe 100644
--- a/source/gameengine/Expressions/VectorValue.cpp
+++ b/source/gameengine/Expressions/VectorValue.cpp
@@ -48,7 +48,7 @@ CVectorValue::CVectorValue(float x,float y,float z, AllocationTYPE alloctype)
m_vec[KX_Z] = m_transformedvec[KX_Z] = z;
}
-CVectorValue::CVectorValue(double vec[],STR_String name,AllocationTYPE alloctype) {
+CVectorValue::CVectorValue(double vec[],const char *name,AllocationTYPE alloctype) {
SetCustomFlag1(false);//FancyOutput=false;
@@ -204,7 +204,7 @@ const STR_String & CVectorValue::GetText()
CValue* CVectorValue::GetReplica() {
CVectorValue* replica = new CVectorValue(*this);
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
};
diff --git a/source/gameengine/Expressions/VectorValue.h b/source/gameengine/Expressions/VectorValue.h
index 99bf0abb11b..19c7dd30076 100644
--- a/source/gameengine/Expressions/VectorValue.h
+++ b/source/gameengine/Expressions/VectorValue.h
@@ -41,7 +41,7 @@ public:
CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
- CVectorValue(double vec[],STR_String name,AllocationTYPE alloctype=CValue::HEAPVALUE);
+ CVectorValue(double vec[],const char *name,AllocationTYPE alloctype=CValue::HEAPVALUE);
CVectorValue() {};
CVectorValue(double vec[],AllocationTYPE alloctype=CValue::HEAPVALUE);
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt
index a7519196d50..7e2bc85bd1f 100644
--- a/source/gameengine/GameLogic/CMakeLists.txt
+++ b/source/gameengine/GameLogic/CMakeLists.txt
@@ -31,6 +31,7 @@ SET(INC
../../../source/kernel/gen_system
../../../intern/string
../../../source/gameengine/Expressions
+ ../../../source/gameengine/SceneGraph
../../../intern/moto/include
../../../source/gameengine/Rasterizer
${PYTHON_INC}
diff --git a/source/gameengine/GameLogic/Joystick/Makefile b/source/gameengine/GameLogic/Joystick/Makefile
index 7016f1ed16f..02def1cec62 100644
--- a/source/gameengine/GameLogic/Joystick/Makefile
+++ b/source/gameengine/GameLogic/Joystick/Makefile
@@ -40,5 +40,5 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += $(NAN_SDLCFLAGS)
-
+CPPFLAGS += -I../../SceneGraph
CPPFLAGS += -I../../../kernel/gen_system
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
index c300baa9bd4..d83179d4f80 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
@@ -38,11 +38,9 @@ SCA_Joystick::SCA_Joystick(short int index)
:
m_joyindex(index),
m_prec(3200),
- m_buttonnum(-2),
m_axismax(-1),
m_buttonmax(-1),
m_hatmax(-1),
- m_hatdir(-2),
m_isinit(0),
m_istrig_axis(0),
m_istrig_button(0),
@@ -50,6 +48,10 @@ SCA_Joystick::SCA_Joystick(short int index)
{
for(int i=0; i<JOYAXIS_MAX; i++)
m_axis_array[i]= 0;
+
+ for(int i=0; i<JOYHAT_MAX; i++)
+ m_hat_array[i]= 0;
+
#ifndef DISABLE_SDL
m_private = new PrivateData();
#endif
@@ -65,6 +67,7 @@ SCA_Joystick::~SCA_Joystick()
}
SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX];
+int SCA_Joystick::m_joynum = 0;
int SCA_Joystick::m_refCount = 0;
SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
@@ -85,6 +88,9 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
echo("Error-Initializing-SDL: " << SDL_GetError());
return NULL;
}
+
+ m_joynum = SDL_NumJoysticks();
+
for (i=0; i<JOYINDEX_MAX; i++) {
m_instance[i] = new SCA_Joystick(i);
m_instance[i]->CreateJoystickDevice();
@@ -152,12 +158,13 @@ bool SCA_Joystick::aAxisIsPositive(int axis_single)
bool SCA_Joystick::aAnyButtonPressIsPositive(void)
{
- return (m_buttonnum==-2) ? false : true;
-}
-
-bool SCA_Joystick::aAnyButtonReleaseIsPositive(void)
-{
- return (m_buttonnum==-2) ? true : false;
+ /* this is needed for the "all events" option
+ * so we know if there are no buttons pressed */
+ for (int i=0; i<m_buttonmax; i++)
+ if (SDL_JoystickGetButton(m_private->m_joystick, i))
+ return true;
+
+ return false;
}
bool SCA_Joystick::aButtonPressIsPositive(int button)
@@ -184,20 +191,9 @@ bool SCA_Joystick::aButtonReleaseIsPositive(int button)
}
-bool SCA_Joystick::aHatIsPositive(int dir)
+bool SCA_Joystick::aHatIsPositive(int hatnum, int dir)
{
- bool result;
- int res = pGetHat(dir);
- res == dir? result = true : result = false;
- return result;
-}
-
-int SCA_Joystick::pGetHat(int direction)
-{
- if(direction == m_hatdir){
- return m_hatdir;
- }
- return 0;
+ return (GetHat(hatnum)==dir) ? true : false;
}
int SCA_Joystick::GetNumberOfAxes()
@@ -220,12 +216,17 @@ int SCA_Joystick::GetNumberOfHats()
bool SCA_Joystick::CreateJoystickDevice(void)
{
#ifdef DISABLE_SDL
+ m_isinit = true;
+ m_axismax = m_buttonmax = m_hatmax = 0;
return false;
#else
if(m_isinit == false){
- if (m_joyindex>=SDL_NumJoysticks()) {
+ if (m_joyindex>=m_joynum) {
// don't print a message, because this is done anyway
//echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)");
+
+ // Need this so python args can return empty lists
+ m_axismax = m_buttonmax = m_hatmax = 0;
return false;
}
@@ -237,11 +238,16 @@ bool SCA_Joystick::CreateJoystickDevice(void)
/* must run after being initialized */
m_axismax = SDL_JoystickNumAxes(m_private->m_joystick);
- if (m_axismax > JOYAXIS_MAX) m_axismax= JOYAXIS_MAX; /* very unlikely */
-
m_buttonmax = SDL_JoystickNumButtons(m_private->m_joystick);
m_hatmax = SDL_JoystickNumHats(m_private->m_joystick);
+ if (m_axismax > JOYAXIS_MAX) m_axismax= JOYAXIS_MAX; /* very unlikely */
+ else if (m_axismax < 0) m_axismax = 0;
+
+ if (m_hatmax > JOYHAT_MAX) m_hatmax= JOYHAT_MAX; /* very unlikely */
+ else if(m_hatmax<0) m_hatmax= 0;
+
+ if(m_buttonmax<0) m_buttonmax= 0;
}
return true;
@@ -271,15 +277,6 @@ int SCA_Joystick::Connected(void)
return 0;
}
-void SCA_Joystick::pFillAxes()
-{
-#ifndef DISABLE_SDL
- for(int i=0; i<m_axismax; i++)
- m_axis_array[i]= SDL_JoystickGetAxis(m_private->m_joystick, i);
-#endif
-}
-
-
int SCA_Joystick::pGetAxis(int axisnum, int udlr)
{
#ifndef DISABLE_SDL
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
index 53cd65cd495..6324b898247 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
@@ -44,6 +44,7 @@ class SCA_Joystick
{
static SCA_Joystick *m_instance[JOYINDEX_MAX];
+ static int m_joynum;
static int m_refCount;
class PrivateData;
@@ -53,9 +54,14 @@ class SCA_Joystick
int m_joyindex;
/*
- *support for 2 axes
+ *support for JOYAXIS_MAX axes (in pairs)
*/
int m_axis_array[JOYAXIS_MAX];
+
+ /*
+ *support for JOYHAT_MAX hats (each is a direction)
+ */
+ int m_hat_array[JOYHAT_MAX];
/*
* Precision or range of the axes
@@ -63,24 +69,6 @@ class SCA_Joystick
int m_prec;
/*
- * multiple axis values stored here
- */
- int m_axisnum;
- int m_axisvalue;
-
- /*
- * max # of axes avail
- */
- /*disabled
- int m_axismax;
- */
-
- /*
- * button values stored here
- */
- int m_buttonnum;
-
- /*
* max # of buttons avail
*/
@@ -88,18 +76,6 @@ class SCA_Joystick
int m_buttonmax;
int m_hatmax;
- /*
- * hat values stored here
- */
- int m_hatnum;
- int m_hatdir;
-
- /*
-
- * max # of hats avail
- disabled
- int m_hatmax;
- */
/* is the joystick initialized ?*/
bool m_isinit;
@@ -136,7 +112,6 @@ class SCA_Joystick
/*
* fills the axis mnember values
*/
- void pFillAxes(void);
void pFillButtons(void);
/*
@@ -149,11 +124,6 @@ class SCA_Joystick
*/
int pGetAxis(int axisnum, int udlr);
- /*
- * gets the current hat direction
- */
- int pGetHat(int direction);
-
SCA_Joystick(short int index);
~SCA_Joystick();
@@ -172,10 +142,9 @@ public:
bool aAxisIsPositive(int axis_single); /* check a single axis only */
bool aAnyButtonPressIsPositive(void);
- bool aAnyButtonReleaseIsPositive(void);
bool aButtonPressIsPositive(int button);
bool aButtonReleaseIsPositive(int button);
- bool aHatIsPositive(int dir);
+ bool aHatIsPositive(int hatnum, int dir);
/*
* precision is default '3200' which is overridden by input
@@ -186,13 +155,9 @@ public:
int GetAxisPosition(int index){
return m_axis_array[index];
}
-
- int GetButton(void){
- return m_buttonnum;
- }
- int GetHat(void){
- return m_hatdir;
+ int GetHat(int index){
+ return m_hat_array[index];
}
int GetThreshold(void){
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
index 636c4dd5a42..70619ff337a 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
@@ -40,6 +40,8 @@
#define JOYINDEX_MAX 8
#define JOYAXIS_MAX 16
+#define JOYBUT_MAX 18
+#define JOYHAT_MAX 4
#define JOYAXIS_RIGHT 0
#define JOYAXIS_UP 1
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
index 8e190060e95..53d3be35f92 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
@@ -35,44 +35,37 @@
#ifndef DISABLE_SDL
void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event)
{
- pFillAxes();
- m_axisnum = sdl_event->jaxis.axis;
- m_axisvalue = sdl_event->jaxis.value;
+ if(sdl_event->jaxis.axis >= JOYAXIS_MAX)
+ return;
+
+ m_axis_array[sdl_event->jaxis.axis]= sdl_event->jaxis.value;
m_istrig_axis = 1;
}
-
+/* See notes below in the event loop */
void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event)
{
- m_hatdir = sdl_event->jhat.value;
- m_hatnum = sdl_event->jhat.hat;
+ if(sdl_event->jhat.hat >= JOYHAT_MAX)
+ return;
+
+ m_hat_array[sdl_event->jhat.hat]= sdl_event->jhat.value;
m_istrig_hat = 1;
}
+/* See notes below in the event loop */
void SCA_Joystick::OnButtonUp(SDL_Event* sdl_event)
{
m_istrig_button = 1;
-
- /* this is needed for the "all events" option
- * so we know if there are no buttons pressed */
- int i;
- for (i=0; i<m_buttonmax; i++) {
- if (SDL_JoystickGetButton(m_private->m_joystick, i)) {
- m_buttonnum = i;
- return;
- }
- }
- m_buttonnum = -2;
}
void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event)
{
- if(sdl_event->jbutton.button <= m_buttonmax) /* unsigned int so always above 0 */
- {
- m_istrig_button = 1;
- m_buttonnum = sdl_event->jbutton.button;
- }
+ //if(sdl_event->jbutton.button > m_buttonmax) /* unsigned int so always above 0 */
+ // return;
+ // sdl_event->jbutton.button;
+
+ m_istrig_button = 1;
}
@@ -81,22 +74,27 @@ void SCA_Joystick::OnNothing(SDL_Event* sdl_event)
m_istrig_axis = m_istrig_button = m_istrig_hat = 0;
}
-/* only handle events for 1 joystick */
-
void SCA_Joystick::HandleEvents(void)
{
SDL_Event sdl_event;
int i;
- for (i=0; i<JOYINDEX_MAX; i++) {
+ for (i=0; i<m_joynum; i++) { /* could use JOYINDEX_MAX but no reason to */
if(SCA_Joystick::m_instance[i])
SCA_Joystick::m_instance[i]->OnNothing(&sdl_event);
}
- if(SDL_PollEvent(&sdl_event))
+ while(SDL_PollEvent(&sdl_event))
{
/* Note! m_instance[sdl_event.jaxis.which]
* will segfault if over JOYINDEX_MAX, not too nice but what are the chances? */
+
+ /* Note!, with buttons, this wont care which button is pressed,
+ * only to set 'm_istrig_button', actual pressed buttons are detected by SDL_JoystickGetButton */
+
+ /* Note!, if you manage to press and release a button within 1 logic tick
+ * it wont work as it should */
+
switch(sdl_event.type)
{
case SDL_JOYAXISMOTION:
diff --git a/source/gameengine/GameLogic/Makefile b/source/gameengine/GameLogic/Makefile
index 355ece6e8bd..a1794a60452 100644
--- a/source/gameengine/GameLogic/Makefile
+++ b/source/gameengine/GameLogic/Makefile
@@ -39,6 +39,7 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I../Expressions
+CPPFLAGS += -I../SceneGraph
CPPFLAGS += -I../Rasterizer
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
index 251a586308e..caed85b9938 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
@@ -64,8 +64,6 @@ CValue* SCA_2DFilterActuator::GetReplica()
{
SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this);
replica->ProcessReplica();
- CValue::AddDataToReplica(replica);
-
return replica;
}
@@ -97,7 +95,7 @@ bool SCA_2DFilterActuator::Update()
}
-void SCA_2DFilterActuator::SetShaderText(STR_String text)
+void SCA_2DFilterActuator::SetShaderText(const char *text)
{
m_shaderText = text;
}
@@ -110,8 +108,13 @@ void SCA_2DFilterActuator::SetShaderText(STR_String text)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_2DFilterActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_2DFilterActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -146,8 +149,8 @@ PyMethodDef SCA_2DFilterActuator::Methods[] = {
PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
KX_PYATTRIBUTE_STRING_RW("shaderText", 0, 64000, false, SCA_2DFilterActuator, m_shaderText),
KX_PYATTRIBUTE_SHORT_RW("disableMotionBlur", 0, 1, true, SCA_2DFilterActuator, m_disableMotionBlur),
- KX_PYATTRIBUTE_ENUM_RW("type",RAS_2DFilterManager::RAS_2DFILTER_ENABLED,RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS,false,SCA_2DFilterActuator,m_type),
- KX_PYATTRIBUTE_INT_RW("passNb", 0, 100, true, SCA_2DFilterActuator, m_int_arg),
+ KX_PYATTRIBUTE_ENUM_RW("mode",RAS_2DFilterManager::RAS_2DFILTER_ENABLED,RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS,false,SCA_2DFilterActuator,m_type),
+ KX_PYATTRIBUTE_INT_RW("passNumber", 0, 100, true, SCA_2DFilterActuator, m_int_arg),
KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg),
{ NULL } //Sentinel
};
@@ -157,6 +160,10 @@ 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 de0201a4b19..13b9997a010 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
@@ -60,7 +60,7 @@ public:
PyTypeObject* T=&Type
);
- void SetShaderText(STR_String text);
+ void SetShaderText(const char *text);
virtual ~SCA_2DFilterActuator();
virtual bool Update();
@@ -71,6 +71,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject* value);
};
diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp
index 1cb03f375cb..87f7c612e7c 100644
--- a/source/gameengine/GameLogic/SCA_ANDController.cpp
+++ b/source/gameengine/GameLogic/SCA_ANDController.cpp
@@ -66,26 +66,19 @@ void SCA_ANDController::Trigger(SCA_LogicManager* logicmgr)
!(is==m_linkedsensors.end());is++)
{
SCA_ISensor* sensor = *is;
- if (!sensor->IsPositiveTrigger())
+ if (!sensor->GetState())
{
sensorresult = false;
break;
}
}
- CValue* newevent = new CBoolValue(sensorresult);
-
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
!(i==m_linkedactuators.end());i++)
{
- SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
- logicmgr->AddActiveActuator(actua,newevent);
+ SCA_IActuator* actua = *i;
+ logicmgr->AddActiveActuator(actua,sensorresult);
}
-
- // every actuator that needs the event, has a it's own reference to it now so
- // release it (so to be clear: if there is no actuator, it's deleted right now)
- newevent->Release();
-
}
@@ -94,7 +87,7 @@ CValue* SCA_ANDController::GetReplica()
{
CValue* replica = new SCA_ANDController(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -107,8 +100,13 @@ CValue* SCA_ANDController::GetReplica()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_ANDController::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_ANDController",
sizeof(PyObjectPlus_Proxy),
0,
@@ -145,4 +143,8 @@ 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 fdb93d0fc42..9a359d57cb4 100644
--- a/source/gameengine/GameLogic/SCA_ANDController.h
+++ b/source/gameengine/GameLogic/SCA_ANDController.h
@@ -49,6 +49,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
};
diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
index 768a3a45937..a80b2af55c8 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
@@ -51,17 +51,19 @@ SCA_ActuatorEventManager::~SCA_ActuatorEventManager()
void SCA_ActuatorEventManager::NextFrame()
{
// check for changed actuator
- for (set<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- (*it)->Activate(m_logicmgr,NULL);
+ (*it)->Activate(m_logicmgr);
}
}
void SCA_ActuatorEventManager::UpdateFrame()
{
// update the state of actuator before executing them
- for (set<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
+ SG_DList::iterator<SCA_ActuatorSensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- ((SCA_ActuatorSensor*)(*it))->Update();
+ (*it)->Update();
}
} \ No newline at end of file
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
index acd906ef9dd..4dad65c5a25 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
@@ -60,7 +60,7 @@ CValue* SCA_ActuatorSensor::GetReplica()
{
SCA_ActuatorSensor* replica = new SCA_ActuatorSensor(*this);
// m_range_expr must be recalculated on replica!
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
replica->Init();
return replica;
@@ -89,7 +89,7 @@ SCA_ActuatorSensor::~SCA_ActuatorSensor()
-bool SCA_ActuatorSensor::Evaluate(CValue* event)
+bool SCA_ActuatorSensor::Evaluate()
{
if (m_actuator)
{
@@ -122,8 +122,13 @@ void SCA_ActuatorSensor::Update()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_ActuatorSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_ActuatorSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -165,6 +170,10 @@ 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);
}
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
index 21960993497..6655e08dc70 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
@@ -52,7 +52,7 @@ public:
virtual ~SCA_ActuatorSensor();
virtual CValue* GetReplica();
virtual void Init();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void ReParent(SCA_IObject* parent);
void Update();
@@ -62,6 +62,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
/* 3. setProperty */
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
index 4cd2dfba994..dd3b55abcc9 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
@@ -51,9 +51,10 @@ SCA_AlwaysEventManager::SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr)
void SCA_AlwaysEventManager::NextFrame()
{
- for (set<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- (*i)->Activate(m_logicmgr, NULL);
+ (*it)->Activate(m_logicmgr);
}
}
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
index b7ecb0233a1..ff02680f191 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
@@ -72,7 +72,7 @@ CValue* SCA_AlwaysSensor::GetReplica()
{
CValue* replica = new SCA_AlwaysSensor(*this);//m_float,GetName());
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -86,7 +86,7 @@ bool SCA_AlwaysSensor::IsPositiveTrigger()
-bool SCA_AlwaysSensor::Evaluate(CValue* event)
+bool SCA_AlwaysSensor::Evaluate()
{
/* Nice! :) */
//return true;
@@ -105,8 +105,13 @@ bool SCA_AlwaysSensor::Evaluate(CValue* event)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_AlwaysSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_AlwaysSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -143,4 +148,8 @@ 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 87949babf59..0f85a641ef1 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.h
@@ -43,7 +43,7 @@ public:
PyTypeObject* T =&Type);
virtual ~SCA_AlwaysSensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
@@ -53,7 +53,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
-
+ virtual PyObject* py_getattro_dict();
};
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
index 44a0175d916..dcdae0b4e75 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
@@ -77,7 +77,7 @@ CValue* SCA_DelaySensor::GetReplica()
{
CValue* replica = new SCA_DelaySensor(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -89,7 +89,7 @@ bool SCA_DelaySensor::IsPositiveTrigger()
return (m_invert ? !m_lastResult : m_lastResult);
}
-bool SCA_DelaySensor::Evaluate(CValue* event)
+bool SCA_DelaySensor::Evaluate()
{
bool trigger = false;
bool result;
@@ -131,8 +131,13 @@ bool SCA_DelaySensor::Evaluate(CValue* event)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_DelaySensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_DelaySensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -182,6 +187,10 @@ 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);
}
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h
index 8da76ff7189..5ccb33f8a16 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.h
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.h
@@ -51,7 +51,7 @@ public:
PyTypeObject* T =&Type);
virtual ~SCA_DelaySensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
@@ -61,6 +61,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
/* setProperty */
diff --git a/source/gameengine/GameLogic/SCA_EventManager.cpp b/source/gameengine/GameLogic/SCA_EventManager.cpp
index e4fd0379597..d1301541a0a 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_EventManager.cpp
@@ -28,6 +28,7 @@
#include <assert.h>
#include "SCA_EventManager.h"
+#include "SCA_ISensor.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -43,16 +44,18 @@ SCA_EventManager::SCA_EventManager(EVENT_MANAGER_TYPE mgrtype)
SCA_EventManager::~SCA_EventManager()
{
+ // all sensors should be removed
+ assert(m_sensors.Empty());
}
void SCA_EventManager::RegisterSensor(class SCA_ISensor* sensor)
{
- m_sensors.insert(sensor);
+ m_sensors.AddBack(sensor);
}
void SCA_EventManager::RemoveSensor(class SCA_ISensor* sensor)
{
- m_sensors.erase(sensor);
+ sensor->Delink();
}
void SCA_EventManager::NextFrame(double curtime, double fixedtime)
diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h
index 9dbb5a6d24f..5ff55849bfe 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.h
+++ b/source/gameengine/GameLogic/SCA_EventManager.h
@@ -33,11 +33,14 @@
#include <set>
#include <algorithm>
+#include "SG_DList.h"
+
class SCA_EventManager
{
protected:
// use a set to speed-up insertion/removal
- std::set <class SCA_ISensor*> m_sensors;
+ //std::set <class SCA_ISensor*> m_sensors;
+ SG_DList m_sensors;
public:
enum EVENT_MANAGER_TYPE {
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
index 352a39a6fea..8e044b89c71 100644
--- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp
+++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
@@ -70,7 +70,7 @@ CValue* SCA_ExpressionController::GetReplica()
replica->m_exprText = m_exprText;
replica->m_exprCache = NULL;
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -115,37 +115,14 @@ void SCA_ExpressionController::Trigger(SCA_LogicManager* logicmgr)
value->Release();
}
- //m_exprCache->Release();
- //m_exprCache = NULL;
}
- /*
-
- for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
- !(is==m_linkedsensors.end());is++)
- {
- SCA_ISensor* sensor = *is;
- if (!sensor->IsPositiveTrigger())
- {
- sensorresult = false;
- break;
- }
- }
-
- */
-
- CValue* newevent = new CBoolValue(expressionresult);
-
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
!(i==m_linkedactuators.end());i++)
{
SCA_IActuator* actua = *i;
- logicmgr->AddActiveActuator(actua,newevent);
+ logicmgr->AddActiveActuator(actua,expressionresult);
}
- //printf("expr %d.",expressionresult);
- // every actuator that needs the event, has a it's own reference to it now so
- // release it (so to be clear: if there is no actuator, it's deleted right now)
- newevent->Release();
}
@@ -161,7 +138,7 @@ CValue* SCA_ExpressionController::FindIdentifier(const STR_String& identifiernam
SCA_ISensor* sensor = *is;
if (sensor->GetName() == identifiername)
{
- identifierval = new CBoolValue(sensor->IsPositiveTrigger());
+ identifierval = new CBoolValue(sensor->GetState());
//identifierval = sensor->AddRef();
}
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h
index 2936742be19..6a34d7b2dff 100644
--- a/source/gameengine/GameLogic/SCA_ExpressionController.h
+++ b/source/gameengine/GameLogic/SCA_ExpressionController.h
@@ -60,6 +60,7 @@ public:
/* --------------------------------------------------------------------- */
// virtual PyObject* py_getattro(PyObject *attr);
+// virtual PyObject* py_getattro_dict();
};
diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp
index 309f3108418..be7c2651686 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_IActuator.cpp
@@ -37,53 +37,13 @@ using namespace std;
SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj,
PyTypeObject* T) :
SCA_ILogicBrick(gameobj,T),
- m_links(0)
+ m_links(0),
+ m_posevent(false),
+ m_negevent(false)
{
// nothing to do
}
-
-
-void SCA_IActuator::AddEvent(CValue* event)
-{
- m_events.push_back(event);
-}
-
-
-
-void SCA_IActuator::RemoveAllEvents()
-{ // remove event queue!
- for (vector<CValue*>::iterator i=m_events.begin(); !(i==m_events.end());i++)
- {
- (*i)->Release();
- }
- m_events.clear();
-}
-
-
-
-
-
-bool SCA_IActuator::IsNegativeEvent() const
-{
- bool bPositiveEvent(false);
- bool bNegativeEvent(false);
-
- for (vector<CValue*>::const_iterator i=m_events.begin(); i!=m_events.end();++i)
- {
- if ((*i)->GetNumber() == 0.0f)
- {
- bNegativeEvent = true;
- } else {
- bPositiveEvent = true;
- }
- }
-
- // if at least 1 positive event, return false
-
- return !bPositiveEvent && bNegativeEvent;
-}
-
bool SCA_IActuator::Update(double curtime, bool frame)
{
if (frame)
@@ -98,9 +58,34 @@ bool SCA_IActuator::Update()
return false;
}
+void SCA_IActuator::Activate(SG_DList& head)
+{
+ if (QEmpty())
+ {
+ InsertActiveQList(m_gameobj->m_activeActuators);
+ head.AddBack(&m_gameobj->m_activeActuators);
+ }
+}
+
+// this function is only used to deactivate actuators outside the logic loop
+// e.g. when an object is deleted.
+void SCA_IActuator::Deactivate()
+{
+ if (QDelink())
+ {
+ // the actuator was in the active list
+ if (m_gameobj->m_activeActuators.QEmpty())
+ // the owner object has no more active actuators, remove it from the global list
+ m_gameobj->m_activeActuators.Delink();
+ }
+}
+
+
void SCA_IActuator::ProcessReplica()
{
- m_events.clear();
+ SCA_ILogicBrick::ProcessReplica();
+ RemoveAllEvents();
+ m_linkedcontrollers.clear();
}
@@ -119,3 +104,36 @@ void SCA_IActuator::DecLink()
m_links = 0;
}
}
+
+void SCA_IActuator::LinkToController(SCA_IController* controller)
+{
+ m_linkedcontrollers.push_back(controller);
+}
+
+void SCA_IActuator::UnlinkController(SCA_IController* controller)
+{
+ std::vector<class SCA_IController*>::iterator contit;
+ for (contit = m_linkedcontrollers.begin();!(contit==m_linkedcontrollers.end());++contit)
+ {
+ if ((*contit) == controller)
+ {
+ *contit = m_linkedcontrollers.back();
+ m_linkedcontrollers.pop_back();
+ return;
+ }
+ }
+ printf("Missing link from actuator %s:%s to controller %s:%s\n",
+ m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(),
+ controller->GetParent()->GetName().ReadPtr(), controller->GetName().ReadPtr());
+}
+
+void SCA_IActuator::UnlinkAllControllers()
+{
+ std::vector<class SCA_IController*>::iterator contit;
+ for (contit = m_linkedcontrollers.begin();!(contit==m_linkedcontrollers.end());++contit)
+ {
+ (*contit)->UnlinkActuator(this);
+ }
+ m_linkedcontrollers.clear();
+}
+
diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h
index 51bd6454d92..27afcbc386b 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.h
+++ b/source/gameengine/GameLogic/SCA_IActuator.h
@@ -29,17 +29,32 @@
#ifndef __KX_IACTUATOR
#define __KX_IACTUATOR
-#include "SCA_ILogicBrick.h"
+#include "SCA_IController.h"
#include <vector>
+/*
+ * Use of SG_DList : None
+ * Use of SG_QList : element of activated actuator list of their owner
+ * Head: SCA_IObject::m_activeActuators
+ */
class SCA_IActuator : public SCA_ILogicBrick
{
friend class SCA_LogicManager;
protected:
int m_links; // number of active links to controllers
// when 0, the actuator is automatically stopped
- std::vector<CValue*> m_events;
- void RemoveAllEvents();
+ //std::vector<CValue*> m_events;
+ bool m_posevent;
+ bool m_negevent;
+
+ std::vector<class SCA_IController*> m_linkedcontrollers;
+
+ void RemoveAllEvents()
+ {
+ m_posevent = false;
+ m_negevent = false;
+ }
+
public:
/**
@@ -75,7 +90,15 @@ public:
/**
* Add an event to an actuator.
*/
- void AddEvent(CValue* event);
+ //void AddEvent(CValue* event)
+ void AddEvent(bool event)
+ {
+ if (event)
+ m_posevent = true;
+ else
+ m_negevent = true;
+ }
+
virtual void ProcessReplica();
/**
@@ -84,9 +107,23 @@ public:
* not immediately clear. But usually refers to key-up events
* or events where no action is required.
*/
- bool IsNegativeEvent() const;
+ bool IsNegativeEvent() const
+ {
+ return !m_posevent && m_negevent;
+ }
+
virtual ~SCA_IActuator();
+ /**
+ * remove this actuator from the list of active actuators
+ */
+ virtual void Deactivate();
+ virtual void Activate(SG_DList& head);
+
+ void LinkToController(SCA_IController* controller);
+ void UnlinkController(class SCA_IController* cont);
+ void UnlinkAllControllers();
+
void ClrLink() { m_links=0; }
void IncLink() { m_links++; }
void DecLink();
diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp
index f9c192cae5c..f2c3c83a2d9 100644
--- a/source/gameengine/GameLogic/SCA_IController.cpp
+++ b/source/gameengine/GameLogic/SCA_IController.cpp
@@ -30,6 +30,8 @@
#include "SCA_LogicManager.h"
#include "SCA_IActuator.h"
#include "SCA_ISensor.h"
+#include "PyObjectPlus.h"
+#include "../Ketsji/KX_PythonSeq.h" /* not nice, only need for KX_PythonSeq_CreatePyObject */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -39,7 +41,8 @@ SCA_IController::SCA_IController(SCA_IObject* gameobj,
PyTypeObject* T)
:
SCA_ILogicBrick(gameobj,T),
- m_statemask(0)
+ m_statemask(0),
+ m_justActivated(false)
{
}
@@ -47,19 +50,19 @@ SCA_IController::SCA_IController(SCA_IObject* gameobj,
SCA_IController::~SCA_IController()
{
- UnlinkAllActuators();
+ //UnlinkAllActuators();
}
-const std::vector<class SCA_ISensor*>& SCA_IController::GetLinkedSensors()
+std::vector<class SCA_ISensor*>& SCA_IController::GetLinkedSensors()
{
return m_linkedsensors;
}
-const std::vector<class SCA_IActuator*>& SCA_IController::GetLinkedActuators()
+std::vector<class SCA_IActuator*>& SCA_IController::GetLinkedActuators()
{
return m_linkedactuators;
}
@@ -68,13 +71,14 @@ const std::vector<class SCA_IActuator*>& SCA_IController::GetLinkedActuators()
void SCA_IController::UnlinkAllSensors()
{
- if (IsActive())
+ std::vector<class SCA_ISensor*>::iterator sensit;
+ for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
{
- std::vector<class SCA_ISensor*>::iterator sensit;
- for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
+ if (IsActive())
{
(*sensit)->DecLink();
}
+ (*sensit)->UnlinkController(this);
}
m_linkedsensors.clear();
}
@@ -83,34 +87,18 @@ void SCA_IController::UnlinkAllSensors()
void SCA_IController::UnlinkAllActuators()
{
- if (IsActive())
+ std::vector<class SCA_IActuator*>::iterator actit;
+ for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
{
- std::vector<class SCA_IActuator*>::iterator actit;
- for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
+ if (IsActive())
{
(*actit)->DecLink();
}
+ (*actit)->UnlinkController(this);
}
m_linkedactuators.clear();
}
-
-
-/*
-void SCA_IController::Trigger(SCA_LogicManager* logicmgr)
-{
- //for (int i=0;i<m_linkedactuators.size();i++)
- for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
- !(i==m_linkedactuators.end());i++)
- {
- SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
-
- logicmgr->AddActiveActuator(actua);
- }
-
-}
-*/
-
void SCA_IController::LinkToActuator(SCA_IActuator* actua)
{
m_linkedactuators.push_back(actua);
@@ -127,18 +115,18 @@ void SCA_IController::UnlinkActuator(class SCA_IActuator* actua)
{
if ((*actit) == actua)
{
- break;
- }
-
- }
- if (!(actit==m_linkedactuators.end()))
- {
- if (IsActive())
- {
- (*actit)->DecLink();
+ if (IsActive())
+ {
+ (*actit)->DecLink();
+ }
+ *actit = m_linkedactuators.back();
+ m_linkedactuators.pop_back();
+ return;
}
- m_linkedactuators.erase(actit);
}
+ printf("Missing link from controller %s:%s to actuator %s:%s\n",
+ m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(),
+ actua->GetParent()->GetName().ReadPtr(), actua->GetName().ReadPtr());
}
void SCA_IController::LinkToSensor(SCA_ISensor* sensor)
@@ -157,20 +145,21 @@ void SCA_IController::UnlinkSensor(class SCA_ISensor* sensor)
{
if ((*sensit) == sensor)
{
- break;
- }
-
- }
- if (!(sensit==m_linkedsensors.end()))
- {
- if (IsActive())
- {
- (*sensit)->DecLink();
+ if (IsActive())
+ {
+ sensor->DecLink();
+ }
+ *sensit = m_linkedsensors.back();
+ m_linkedsensors.pop_back();
+ return;
}
- m_linkedsensors.erase(sensit);
}
+ printf("Missing link from controller %s:%s to sensor %s:%s\n",
+ m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(),
+ sensor->GetParent()->GetName().ReadPtr(), sensor->GetName().ReadPtr());
}
+
void SCA_IController::ApplyState(unsigned int state)
{
std::vector<class SCA_IActuator*>::iterator actit;
@@ -185,13 +174,13 @@ void SCA_IController::ApplyState(unsigned int state)
{
(*actit)->IncLink();
}
+
for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
{
(*sensit)->IncLink();
- // remember that this controller just activated that sensor
- (*sensit)->AddNewController(this);
}
SetActive(true);
+ m_justActivated = true;
}
} else if (IsActive())
{
@@ -204,6 +193,168 @@ void SCA_IController::ApplyState(unsigned int state)
(*sensit)->DecLink();
}
SetActive(false);
+ m_justActivated = false;
}
}
+/* Python api */
+
+PyTypeObject SCA_IController::Type = {
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
+ "SCA_IController",
+ sizeof(PyObjectPlus_Proxy),
+ 0,
+ py_base_dealloc,
+ 0,
+ 0,
+ 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
+};
+
+PyMethodDef SCA_IController::Methods[] = {
+ //Deprecated functions ------>
+ {"getSensor", (PyCFunction) SCA_IController::sPyGetSensor, METH_O},
+ {"getActuator", (PyCFunction) SCA_IController::sPyGetActuator, METH_O},
+ {"getSensors", (PyCFunction) SCA_IController::sPyGetSensors, METH_NOARGS},
+ {"getActuators", (PyCFunction) SCA_IController::sPyGetActuators, METH_NOARGS},
+ {"getState", (PyCFunction) SCA_IController::sPyGetState, METH_NOARGS},
+ //<----- Deprecated
+ {NULL,NULL} //Sentinel
+};
+
+PyAttributeDef SCA_IController::Attributes[] = {
+ KX_PYATTRIBUTE_RO_FUNCTION("state", SCA_IController, pyattr_get_state),
+ KX_PYATTRIBUTE_RO_FUNCTION("sensors", SCA_IController, pyattr_get_sensors),
+ KX_PYATTRIBUTE_RO_FUNCTION("actuators", SCA_IController, pyattr_get_actuators),
+ KX_PYATTRIBUTE_BOOL_RW("useHighPriority",SCA_IController,m_bookmark),
+ { 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");
+
+ PyObject* resultlist = PyList_New(m_linkedactuators.size());
+ for (unsigned int index=0;index<m_linkedactuators.size();index++)
+ {
+ PyList_SET_ITEM(resultlist,index, m_linkedactuators[index]->GetProxy());
+ }
+
+ return resultlist;
+}
+
+PyObject* SCA_IController::PyGetSensor(PyObject* value)
+{
+ ShowDeprecationWarning("getSensor(string)", "the sensors[string] property");
+
+ char *scriptArg = PyString_AsString(value);
+ if (scriptArg==NULL) {
+ PyErr_SetString(PyExc_TypeError, "controller.getSensor(string): Python Controller, expected a string (sensor name)");
+ return NULL;
+ }
+
+ for (unsigned int index=0;index<m_linkedsensors.size();index++)
+ {
+ SCA_ISensor* sensor = m_linkedsensors[index];
+ STR_String& realname = sensor->GetName();
+ if (realname == scriptArg)
+ {
+ return sensor->GetProxy();
+ }
+ }
+
+ PyErr_Format(PyExc_AttributeError, "controller.getSensor(string): Python Controller, unable to find requested sensor \"%s\"", scriptArg);
+ return NULL;
+}
+
+PyObject* SCA_IController::PyGetActuator(PyObject* value)
+{
+ ShowDeprecationWarning("getActuator(string)", "the actuators[string] property");
+
+ char *scriptArg = PyString_AsString(value);
+ if (scriptArg==NULL) {
+ PyErr_SetString(PyExc_TypeError, "controller.getActuator(string): Python Controller, expected a string (actuator name)");
+ return NULL;
+ }
+
+ for (unsigned int index=0;index<m_linkedactuators.size();index++)
+ {
+ SCA_IActuator* actua = m_linkedactuators[index];
+ if (actua->GetName() == scriptArg)
+ {
+ return actua->GetProxy();
+ }
+ }
+
+ PyErr_Format(PyExc_AttributeError, "controller.getActuator(string): Python Controller, unable to find requested actuator \"%s\"", scriptArg);
+ return NULL;
+}
+
+PyObject* SCA_IController::PyGetSensors()
+{
+ ShowDeprecationWarning("getSensors()", "the sensors property");
+
+ PyObject* resultlist = PyList_New(m_linkedsensors.size());
+ for (unsigned int index=0;index<m_linkedsensors.size();index++)
+ {
+ PyList_SET_ITEM(resultlist,index, m_linkedsensors[index]->GetProxy());
+ }
+
+ return resultlist;
+}
+
+PyObject* SCA_IController::PyGetState()
+{
+ ShowDeprecationWarning("getState()", "the state property");
+ return PyInt_FromLong(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);
+}
+
+PyObject* SCA_IController::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ return KX_PythonSeq_CreatePyObject((static_cast<SCA_IController*>(self_v))->m_proxy, KX_PYGENSEQ_CONT_TYPE_SENSORS);
+}
+
+PyObject* SCA_IController::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ return KX_PythonSeq_CreatePyObject((static_cast<SCA_IController*>(self_v))->m_proxy, KX_PYGENSEQ_CONT_TYPE_ACTUATORS);
+}
diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h
index f67c0942eb4..a52c57ab3ed 100644
--- a/source/gameengine/GameLogic/SCA_IController.h
+++ b/source/gameengine/GameLogic/SCA_IController.h
@@ -30,28 +30,87 @@
#define __KX_ICONTROLLER
#include "SCA_ILogicBrick.h"
+#include "PyObjectPlus.h"
+/*
+ * Use of SG_DList element: none
+ * Use of SG_QList element: build ordered list of activated controller on the owner object
+ * Head: SCA_IObject::m_activeControllers
+ */
class SCA_IController : public SCA_ILogicBrick
{
+ Py_Header;
protected:
std::vector<class SCA_ISensor*> m_linkedsensors;
std::vector<class SCA_IActuator*> m_linkedactuators;
unsigned int m_statemask;
+ bool m_justActivated;
+ bool m_bookmark;
public:
SCA_IController(SCA_IObject* gameobj,PyTypeObject* T);
virtual ~SCA_IController();
virtual void Trigger(class SCA_LogicManager* logicmgr)=0;
void LinkToSensor(SCA_ISensor* sensor);
void LinkToActuator(SCA_IActuator*);
- const std::vector<class SCA_ISensor*>& GetLinkedSensors();
- const std::vector<class SCA_IActuator*>& GetLinkedActuators();
+ std::vector<class SCA_ISensor*>& GetLinkedSensors();
+ std::vector<class SCA_IActuator*>& GetLinkedActuators();
+ void ReserveActuator(int num)
+ {
+ m_linkedactuators.reserve(num);
+ }
void UnlinkAllSensors();
void UnlinkAllActuators();
void UnlinkActuator(class SCA_IActuator* actua);
void UnlinkSensor(class SCA_ISensor* sensor);
void SetState(unsigned int state) { m_statemask = state; }
void ApplyState(unsigned int state);
+ void Deactivate()
+ {
+ // the controller can only be part of a sensor m_newControllers list
+ Delink();
+ }
+ bool IsJustActivated()
+ {
+ return m_justActivated;
+ }
+ void ClrJustActivated()
+ {
+ m_justActivated = false;
+ }
+ void SetBookmark(bool bookmark)
+ {
+ m_bookmark = bookmark;
+ }
+ void Activate(SG_DList& head)
+ {
+ if (QEmpty())
+ {
+ if (m_bookmark)
+ {
+ m_gameobj->m_activeBookmarkedControllers.QAddBack(this);
+ head.AddFront(&m_gameobj->m_activeBookmarkedControllers);
+ }
+ else
+ {
+ InsertActiveQList(m_gameobj->m_activeControllers);
+ head.AddBack(&m_gameobj->m_activeControllers);
+ }
+ }
+ }
+ 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);
+ KX_PYMETHOD_O(SCA_IController,GetActuator);
+ KX_PYMETHOD_NOARGS(SCA_IController,GetState);
+
+ static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
};
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
index 3cd750ff63b..2dc80f54568 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
@@ -71,13 +71,6 @@ void SCA_ILogicBrick::SetUeberExecutePriority(int execute_Priority)
-SCA_IObject* SCA_ILogicBrick::GetParent()
-{
- return m_gameobj;
-}
-
-
-
void SCA_ILogicBrick::ReParent(SCA_IObject* parent)
{
m_gameobj = parent;
@@ -130,33 +123,17 @@ double SCA_ILogicBrick::GetNumber()
-STR_String SCA_ILogicBrick::GetName()
+STR_String& SCA_ILogicBrick::GetName()
{
return m_name;
}
-void SCA_ILogicBrick::SetName(STR_String name)
-{
- m_name = name;
-}
-
-
-
-void SCA_ILogicBrick::ReplicaSetName(STR_String name)
+void SCA_ILogicBrick::SetName(const char *name)
{
m_name = name;
}
-
-
-
-bool SCA_ILogicBrick::IsActive()
-{
- return m_bActive;
-}
-
-
bool SCA_ILogicBrick::LessComparedTo(SCA_ILogicBrick* other)
{
@@ -165,22 +142,6 @@ bool SCA_ILogicBrick::LessComparedTo(SCA_ILogicBrick* other)
(this->m_Execute_Priority < other->m_Execute_Priority));
}
-
-
-void SCA_ILogicBrick::SetActive(bool active)
-{
- m_bActive=active;
- if (active)
- {
- //m_gameobj->SetDebugColor(GetDrawColor());
- } else
- {
- //m_gameobj->ResetDebugColor();
- }
-}
-
-
-
void SCA_ILogicBrick::RegisterEvent(CValue* eventval)
{
if (m_eventval)
@@ -217,8 +178,13 @@ CValue* SCA_ILogicBrick::GetEvent()
/* python stuff */
PyTypeObject SCA_ILogicBrick::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_ILogicBrick",
sizeof(PyObjectPlus_Proxy),
0,
@@ -256,7 +222,8 @@ PyMethodDef SCA_ILogicBrick::Methods[] = {
PyAttributeDef SCA_ILogicBrick::Attributes[] = {
KX_PYATTRIBUTE_RO_FUNCTION("owner", SCA_ILogicBrick, pyattr_get_owner),
- KX_PYATTRIBUTE_INT_RW("executePriority",0,100000,false,SCA_ILogicBrick,m_Execute_Ueber_Priority),
+ KX_PYATTRIBUTE_INT_RW("executePriority",0,100000,false,SCA_ILogicBrick,m_Execute_Priority),
+ KX_PYATTRIBUTE_STRING_RO("name", SCA_ILogicBrick, m_name),
{NULL} //Sentinel
};
@@ -278,12 +245,15 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
return 0;
}
-PyObject*
-SCA_ILogicBrick::py_getattro(PyObject *attr)
+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);
@@ -316,7 +286,7 @@ PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* args)
return NULL;
}
- m_Execute_Ueber_Priority = priority;
+ m_Execute_Priority = priority;
Py_RETURN_NONE;
}
@@ -326,7 +296,7 @@ PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* args)
PyObject* SCA_ILogicBrick::PyGetExecutePriority()
{
ShowDeprecationWarning("getExecutePriority()", "the executePriority property");
- return PyInt_FromLong(m_Execute_Ueber_Priority);
+ return PyInt_FromLong(m_Execute_Priority);
}
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h
index e59d05ea051..779e5397a6a 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.h
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h
@@ -59,7 +59,8 @@ public:
void SetExecutePriority(int execute_Priority);
void SetUeberExecutePriority(int execute_Priority);
- SCA_IObject* GetParent();
+ SCA_IObject* GetParent() { return m_gameobj; }
+
virtual void ReParent(SCA_IObject* parent);
virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
virtual void Delete() { Release(); }
@@ -70,16 +71,59 @@ public:
virtual const STR_String & GetText();
virtual double GetNumber();
- virtual STR_String GetName();
- virtual void SetName(STR_String name);
- virtual void ReplicaSetName(STR_String name);
+ virtual STR_String& GetName();
+ virtual void SetName(const char *);
- bool IsActive();
- void SetActive(bool active) ;
+ bool IsActive()
+ {
+ return m_bActive;
+ }
+
+ void SetActive(bool active)
+ {
+ m_bActive=active;
+ }
+
+ // insert in a QList at position corresponding to m_Execute_Priority
+ void InsertActiveQList(SG_QList& head)
+ {
+ SG_QList::iterator<SCA_ILogicBrick> it(head);
+ for(it.begin(); !it.end() && m_Execute_Priority > (*it)->m_Execute_Priority; ++it);
+ it.add_back(this);
+ }
+
+ // insert in a QList at position corresponding to m_Execute_Priority
+ // inside a longer list that contains elements of other objects.
+ // Sorting is done only between the elements of the same object.
+ // head is the head of the combined list
+ // current points to the first element of the object in the list, NULL if none yet
+ void InsertSelfActiveQList(SG_QList& head, SG_QList** current)
+ {
+ if (!*current)
+ {
+ // first element can be put anywhere
+ head.QAddBack(this);
+ *current = this;
+ return;
+ }
+ // note: we assume current points actually to one o our element, skip the tests
+ SG_QList::iterator<SCA_ILogicBrick> it(head,*current);
+ if (m_Execute_Priority <= (*it)->m_Execute_Priority)
+ {
+ // this element comes before the first
+ *current = this;
+ }
+ else
+ {
+ for(++it; !it.end() && (*it)->m_gameobj == m_gameobj && m_Execute_Priority > (*it)->m_Execute_Priority; ++it);
+ }
+ it.add_back(this);
+ }
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 75804525e7a..9876f2512c0 100644
--- a/source/gameengine/GameLogic/SCA_IObject.cpp
+++ b/source/gameengine/GameLogic/SCA_IObject.cpp
@@ -39,13 +39,13 @@
#endif
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(PyTypeObject* T): CValue(T), m_initState(0), m_state(0)
{
m_suspended = false;
}
-
-
SCA_IObject::~SCA_IObject()
{
@@ -70,7 +70,7 @@ SCA_IObject::~SCA_IObject()
}
for (ita = m_actuators.begin(); !(ita==m_actuators.end()); ++ita)
{
- ((CValue*)(*ita))->Release();
+ (*ita)->Delete();
}
//T_InterpolatorList::iterator i;
@@ -79,29 +79,6 @@ SCA_IObject::~SCA_IObject()
//}
}
-
-
-SCA_ControllerList& SCA_IObject::GetControllers()
-{
- return m_controllers;
-}
-
-
-
-SCA_SensorList& SCA_IObject::GetSensors()
-{
- return m_sensors;
-}
-
-
-
-SCA_ActuatorList& SCA_IObject::GetActuators()
-{
- return m_actuators;
-}
-
-
-
void SCA_IObject::AddSensor(SCA_ISensor* act)
{
act->AddRef();
@@ -133,7 +110,7 @@ void SCA_IObject::RegisterActuator(SCA_IActuator* act)
void SCA_IObject::UnregisterActuator(SCA_IActuator* act)
{
SCA_ActuatorList::iterator ita;
- for (ita = m_registeredActuators.begin(); ita != m_registeredActuators.end(); ita++)
+ for (ita = m_registeredActuators.begin(); ita != m_registeredActuators.end(); ++ita)
{
if ((*ita) == act) {
(*ita) = m_registeredActuators.back();
@@ -143,20 +120,6 @@ void SCA_IObject::UnregisterActuator(SCA_IActuator* act)
}
}
-void SCA_IObject::SetIgnoreActivityCulling(bool b)
-{
- m_ignore_activity_culling = b;
-}
-
-
-
-bool SCA_IObject::GetIgnoreActivityCulling()
-{
- return m_ignore_activity_culling;
-}
-
-
-
void SCA_IObject::ReParentLogic()
{
SCA_ActuatorList& oldactuators = GetActuators();
@@ -208,7 +171,7 @@ SCA_ISensor* SCA_IObject::FindSensor(const STR_String& sensorname)
{
SCA_ISensor* foundsensor = NULL;
- for (SCA_SensorList::iterator its = m_sensors.begin();!(its==m_sensors.end());its++)
+ for (SCA_SensorList::iterator its = m_sensors.begin();!(its==m_sensors.end());++its)
{
if ((*its)->GetName() == sensorname)
{
@@ -225,7 +188,7 @@ SCA_IController* SCA_IObject::FindController(const STR_String& controllername)
{
SCA_IController* foundcontroller = NULL;
- for (SCA_ControllerList::iterator itc = m_controllers.begin();!(itc==m_controllers.end());itc++)
+ for (SCA_ControllerList::iterator itc = m_controllers.begin();!(itc==m_controllers.end());++itc)
{
if ((*itc)->GetName() == controllername)
{
@@ -242,7 +205,7 @@ SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname)
{
SCA_IActuator* foundactuator = NULL;
- for (SCA_ActuatorList::iterator ita = m_actuators.begin();!(ita==m_actuators.end());ita++)
+ for (SCA_ActuatorList::iterator ita = m_actuators.begin();!(ita==m_actuators.end());++ita)
{
if ((*ita)->GetName() == actuatorname)
{
@@ -256,14 +219,6 @@ SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname)
-void SCA_IObject::SetCurrentTime(float currentTime) {
- //T_InterpolatorList::iterator i;
- //for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- // (*i)->Execute(currentTime);
- //}
-}
-
-
#if 0
const MT_Point3& SCA_IObject::ConvertPythonPylist(PyObject* pylist)
{
@@ -317,7 +272,7 @@ void SCA_IObject::Suspend()
SCA_SensorList::iterator i = m_sensors.begin();
while (i != m_sensors.end()) {
(*i)->Suspend();
- i++;
+ ++i;
}
}
}
@@ -332,7 +287,7 @@ void SCA_IObject::Resume(void)
SCA_SensorList::iterator i = m_sensors.begin();
while (i != m_sensors.end()) {
(*i)->Resume();
- i++;
+ ++i;
}
}
}
@@ -352,7 +307,7 @@ void SCA_IObject::SetState(unsigned int state)
if (tmpstate != m_state)
{
// update the status of the controllers
- for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++)
+ for (contit = m_controllers.begin(); contit != m_controllers.end(); ++contit)
{
(*contit)->ApplyState(tmpstate);
}
@@ -360,7 +315,7 @@ void SCA_IObject::SetState(unsigned int state)
m_state = state;
if (m_state != tmpstate)
{
- for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++)
+ for (contit = m_controllers.begin(); contit != m_controllers.end(); ++contit)
{
(*contit)->ApplyState(m_state);
}
@@ -375,8 +330,13 @@ void SCA_IObject::SetState(unsigned int state)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_IObject::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_IObject",
sizeof(PyObjectPlus_Proxy),
0,
@@ -418,3 +378,6 @@ 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 44ed3c8f3fe..eae427741ca 100644
--- a/source/gameengine/GameLogic/SCA_IObject.h
+++ b/source/gameengine/GameLogic/SCA_IObject.h
@@ -52,10 +52,30 @@ class SCA_IObject : public CValue
Py_Header;
protected:
+ friend class KX_StateActuator;
+ friend class SCA_IActuator;
+ friend class SCA_IController;
SCA_SensorList m_sensors;
SCA_ControllerList m_controllers;
SCA_ActuatorList m_actuators;
SCA_ActuatorList m_registeredActuators; // actuators that use a pointer to this object
+
+ // SG_Dlist: element of objects with active actuators
+ // Head: SCA_LogicManager::m_activeActuators
+ // SG_QList: Head of active actuators list on this object
+ // Elements: SCA_IActuator
+ SG_QList m_activeActuators;
+ // SG_Dlist: element of list os lists with active controllers
+ // Head: SCA_LogicManager::m_activeControllers
+ // SG_QList: Head of active controller list on this object
+ // Elements: SCA_IController
+ SG_QList m_activeControllers;
+ // SG_Dlist: element of list of lists of active controllers
+ // Head: SCA_LogicManager::m_activeControllers
+ // SG_QList: Head of active bookmarked controller list globally
+ // Elements: SCA_IController with bookmark option
+ static SG_QList m_activeBookmarkedControllers;
+
static class MT_Point3 m_sDummy;
/**
@@ -78,18 +98,48 @@ protected:
*/
unsigned int m_state;
+ /**
+ * pointer inside state actuator list for sorting
+ */
+ SG_QList* m_firstState;
+
public:
SCA_IObject(PyTypeObject* T=&Type);
virtual ~SCA_IObject();
- SCA_ControllerList& GetControllers();
- SCA_SensorList& GetSensors();
- SCA_ActuatorList& GetActuators();
+ SCA_ControllerList& GetControllers()
+ {
+ return m_controllers;
+ }
+ SCA_SensorList& GetSensors()
+ {
+ return m_sensors;
+ }
+ SCA_ActuatorList& GetActuators()
+ {
+ return m_actuators;
+ }
+ SG_QList& GetActiveActuators()
+ {
+ return m_activeActuators;
+ }
void AddSensor(SCA_ISensor* act);
+ void ReserveSensor(int num)
+ {
+ m_sensors.reserve(num);
+ }
void AddController(SCA_IController* act);
+ void ReserveController(int num)
+ {
+ m_controllers.reserve(num);
+ }
void AddActuator(SCA_IActuator* act);
+ void ReserveActuator(int num)
+ {
+ m_actuators.reserve(num);
+ }
void RegisterActuator(SCA_IActuator* act);
void UnregisterActuator(SCA_IActuator* act);
@@ -97,20 +147,26 @@ public:
SCA_IActuator* FindActuator(const STR_String& actuatorname);
SCA_IController* FindController(const STR_String& controllername);
- void SetCurrentTime(float currentTime);
+ void SetCurrentTime(float currentTime) {}
void ReParentLogic();
/**
* Set whether or not to ignore activity culling requests
*/
- void SetIgnoreActivityCulling(bool b);
+ void SetIgnoreActivityCulling(bool b)
+ {
+ m_ignore_activity_culling = b;
+ }
/**
* Set whether or not this object wants to ignore activity culling
* requests
*/
- bool GetIgnoreActivityCulling();
+ bool GetIgnoreActivityCulling()
+ {
+ return m_ignore_activity_culling;
+ }
/**
* Suspend all progress.
@@ -146,6 +202,7 @@ public:
// here come the python forwarded methods
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int GetGameObjectType() {return -1;}
diff --git a/source/gameengine/GameLogic/SCA_IScene.cpp b/source/gameengine/GameLogic/SCA_IScene.cpp
index 9fbeb706910..86b176a38b0 100644
--- a/source/gameengine/GameLogic/SCA_IScene.cpp
+++ b/source/gameengine/GameLogic/SCA_IScene.cpp
@@ -50,7 +50,7 @@ SCA_IScene::SCA_IScene()
void SCA_IScene::RemoveAllDebugProperties()
{
for (std::vector<SCA_DebugProp*>::iterator it = m_debugList.begin();
- !(it==m_debugList.end());it++)
+ !(it==m_debugList.end());++it)
{
delete (*it);
}
diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h
index d18778a37c2..b641efc6ee1 100644
--- a/source/gameengine/GameLogic/SCA_IScene.h
+++ b/source/gameengine/GameLogic/SCA_IScene.h
@@ -52,7 +52,7 @@ public:
int lifespan=0)=0;
virtual void RemoveObject(class CValue* gameobj)=0;
virtual void DelayedRemoveObject(class CValue* gameobj)=0;
- virtual void DelayedReleaseObject(class CValue* gameobj)=0;
+ //virtual void DelayedReleaseObject(class CValue* gameobj)=0;
virtual void ReplaceMesh(class CValue* gameobj,
void* meshobj)=0;
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
index 68f5653d53a..2783bf14600 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ISensor.cpp
@@ -45,26 +45,28 @@ void SCA_ISensor::ReParent(SCA_IObject* parent)
SCA_ILogicBrick::ReParent(parent);
// will be done when the sensor is activated
//m_eventmgr->RegisterSensor(this);
- this->SetActive(false);
+ //this->SetActive(false);
}
SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj,
class SCA_EventManager* eventmgr,
PyTypeObject* T ) :
- SCA_ILogicBrick(gameobj,T),
- m_triggered(false)
+ SCA_ILogicBrick(gameobj,T)
{
m_links = 0;
m_suspended = false;
m_invert = false;
m_level = false;
+ m_tap = false;
m_reset = false;
m_pos_ticks = 0;
m_neg_ticks = 0;
m_pos_pulsemode = false;
m_neg_pulsemode = false;
m_pulse_frequency = 0;
+ m_state = false;
+ m_prev_state = false;
m_eventmgr = eventmgr;
}
@@ -75,6 +77,12 @@ SCA_ISensor::~SCA_ISensor()
// intentionally empty
}
+void SCA_ISensor::ProcessReplica()
+{
+ SCA_ILogicBrick::ProcessReplica();
+ m_linkedcontrollers.clear();
+}
+
bool SCA_ISensor::IsPositiveTrigger() {
bool result = false;
@@ -104,9 +112,13 @@ void SCA_ISensor::SetLevel(bool lvl) {
m_level = lvl;
}
+void SCA_ISensor::SetTap(bool tap) {
+ m_tap = tap;
+}
+
double SCA_ISensor::GetNumber() {
- return IsPositiveTrigger();
+ return GetState();
}
void SCA_ISensor::Suspend() {
@@ -143,27 +155,80 @@ void SCA_ISensor::RegisterToManager()
{
// sensor is just activated, initialize it
Init();
- m_newControllers.erase(m_newControllers.begin(), m_newControllers.end());
+ m_state = false;
m_eventmgr->RegisterSensor(this);
}
+void SCA_ISensor::LinkToController(SCA_IController* controller)
+{
+ m_linkedcontrollers.push_back(controller);
+}
+
+void SCA_ISensor::UnlinkController(SCA_IController* controller)
+{
+ std::vector<class SCA_IController*>::iterator contit;
+ for (contit = m_linkedcontrollers.begin();!(contit==m_linkedcontrollers.end());++contit)
+ {
+ if ((*contit) == controller)
+ {
+ *contit = m_linkedcontrollers.back();
+ m_linkedcontrollers.pop_back();
+ return;
+ }
+ }
+ printf("Missing link from sensor %s:%s to controller %s:%s\n",
+ m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(),
+ controller->GetParent()->GetName().ReadPtr(), controller->GetName().ReadPtr());
+}
+
+void SCA_ISensor::UnlinkAllControllers()
+{
+ std::vector<class SCA_IController*>::iterator contit;
+ for (contit = m_linkedcontrollers.begin();!(contit==m_linkedcontrollers.end());++contit)
+ {
+ (*contit)->UnlinkSensor(this);
+ }
+ m_linkedcontrollers.clear();
+}
+
void SCA_ISensor::UnregisterToManager()
{
m_eventmgr->RemoveSensor(this);
+ m_links = 0;
+}
+
+void SCA_ISensor::ActivateControllers(class SCA_LogicManager* logicmgr)
+{
+ for(vector<SCA_IController*>::const_iterator c= m_linkedcontrollers.begin();
+ c!=m_linkedcontrollers.end();++c)
+ {
+ SCA_IController* contr = *c;
+ if (contr->IsActive())
+ logicmgr->AddTriggeredController(contr, this);
+ }
}
-void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event)
+void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr)
{
// calculate if a __triggering__ is wanted
// don't evaluate a sensor that is not connected to any controller
if (m_links && !m_suspended) {
- bool result = this->Evaluate(event);
+ bool result = this->Evaluate();
+ // store the state for the rest of the logic system
+ m_prev_state = m_state;
+ m_state = this->IsPositiveTrigger();
if (result) {
- logicmgr->AddActivatedSensor(this);
- // reset these counters so that pulse are synchronized with transition
- m_pos_ticks = 0;
- m_neg_ticks = 0;
+ // the sensor triggered this frame
+ if (m_state || !m_tap) {
+ ActivateControllers(logicmgr);
+ // reset these counters so that pulse are synchronized with transition
+ m_pos_ticks = 0;
+ m_neg_ticks = 0;
+ } else
+ {
+ result = false;
+ }
} else
{
/* First, the pulsing behaviour, if pulse mode is
@@ -172,41 +237,55 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event)
if (m_pos_pulsemode) {
m_pos_ticks++;
if (m_pos_ticks > m_pulse_frequency) {
- if ( this->IsPositiveTrigger() )
+ if ( m_state )
{
- logicmgr->AddActivatedSensor(this);
+ ActivateControllers(logicmgr);
+ result = true;
}
m_pos_ticks = 0;
}
}
-
- if (m_neg_pulsemode)
+ // negative pulse doesn't make sense in tap mode, skip
+ if (m_neg_pulsemode && !m_tap)
{
m_neg_ticks++;
if (m_neg_ticks > m_pulse_frequency) {
- if (!this->IsPositiveTrigger() )
+ if (!m_state )
{
- logicmgr->AddActivatedSensor(this);
+ ActivateControllers(logicmgr);
+ result = true;
}
m_neg_ticks = 0;
}
}
}
- if (!m_newControllers.empty())
+ if (m_tap)
{
- if (!IsActive() && m_level)
+ // in tap mode: we send always a negative pulse immediately after a positive pulse
+ if (!result)
{
- // This level sensor is connected to at least one controller that was just made
- // active but it did not generate an event yet, do it now to those controllers only
- for (std::vector<SCA_IController*>::iterator ci=m_newControllers.begin();
- ci != m_newControllers.end(); ci++)
+ // the sensor did not trigger on this frame
+ if (m_prev_state)
{
- logicmgr->AddTriggeredController(*ci, this);
+ // but it triggered on previous frame => send a negative pulse
+ ActivateControllers(logicmgr);
+ result = true;
}
+ // in any case, absence of trigger means sensor off
+ m_state = false;
+ }
+ }
+ if (!result && m_level)
+ {
+ // This level sensor is connected to at least one controller that was just made
+ // active but it did not generate an event yet, do it now to those controllers only
+ for(vector<SCA_IController*>::const_iterator c= m_linkedcontrollers.begin();
+ c!=m_linkedcontrollers.end();++c)
+ {
+ SCA_IController* contr = *c;
+ if (contr->IsJustActivated())
+ logicmgr->AddTriggeredController(contr, this);
}
- // clear the list. Instead of using clear, which also release the memory,
- // use erase, which keeps the memory available for next time.
- m_newControllers.erase(m_newControllers.begin(), m_newControllers.end());
}
}
}
@@ -221,7 +300,7 @@ const char SCA_ISensor::IsPositive_doc[] =
PyObject* SCA_ISensor::PyIsPositive()
{
ShowDeprecationWarning("isPositive()", "the read-only positive property");
- int retval = IsPositiveTrigger();
+ int retval = GetState();
return PyInt_FromLong(retval);
}
@@ -385,6 +464,7 @@ KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
"\tThe sensor is put in its initial state as if it was just activated.\n")
{
Init();
+ m_prev_state = false;
Py_RETURN_NONE;
}
@@ -393,8 +473,13 @@ KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
/* ----------------------------------------------- */
PyTypeObject SCA_ISensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_ISensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -453,18 +538,25 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
KX_PYATTRIBUTE_BOOL_RW("useNegPulseMode",SCA_ISensor,m_neg_pulsemode),
KX_PYATTRIBUTE_INT_RW("frequency",0,100000,true,SCA_ISensor,m_pulse_frequency),
KX_PYATTRIBUTE_BOOL_RW("invert",SCA_ISensor,m_invert),
- KX_PYATTRIBUTE_BOOL_RW("level",SCA_ISensor,m_level),
+ KX_PYATTRIBUTE_BOOL_RW_CHECK("level",SCA_ISensor,m_level,pyattr_check_level),
+ KX_PYATTRIBUTE_BOOL_RW_CHECK("tap",SCA_ISensor,m_tap,pyattr_check_tap),
KX_PYATTRIBUTE_RO_FUNCTION("triggered", SCA_ISensor, pyattr_get_triggered),
KX_PYATTRIBUTE_RO_FUNCTION("positive", SCA_ISensor, pyattr_get_positive),
+ //KX_PYATTRIBUTE_TODO("links"),
+ //KX_PYATTRIBUTE_TODO("posTicks"),
+ //KX_PYATTRIBUTE_TODO("negTicks"),
{ NULL } //Sentinel
};
-PyObject*
-SCA_ISensor::py_getattro(PyObject *attr)
+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);
@@ -482,7 +574,23 @@ PyObject* SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_D
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->IsPositiveTrigger());
+ return PyInt_FromLong(self->GetState());
+}
+
+int SCA_ISensor::pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);
+ if (self->m_level)
+ self->m_tap = false;
+ return 0;
+}
+
+int SCA_ISensor::pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);
+ if (self->m_tap)
+ self->m_level = false;
+ return 0;
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
index 6b1c8cca104..9bbd6ed41e4 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ b/source/gameengine/GameLogic/SCA_ISensor.h
@@ -32,18 +32,22 @@
#ifndef __SCA_ISENSOR
#define __SCA_ISENSOR
-#include "SCA_ILogicBrick.h"
+#include "SCA_IController.h"
#include <vector>
/**
* Interface Class for all logic Sensors. Implements
- * pulsemode,pulsefrequency */
+ * pulsemode,pulsefrequency
+ * Use of SG_DList element: link sensors to their respective event manager
+ * Head: SCA_EventManager::m_sensors
+ * Use of SG_QList element: not used
+ */
class SCA_ISensor : public SCA_ILogicBrick
{
Py_Header;
+protected:
class SCA_EventManager* m_eventmgr;
- bool m_triggered;
/** Pulse positive pulses? */
bool m_pos_pulsemode;
@@ -66,6 +70,9 @@ class SCA_ISensor : public SCA_ILogicBrick
/** detect level instead of edge*/
bool m_level;
+ /** tap mode */
+ bool m_tap;
+
/** sensor has been reset */
bool m_reset;
@@ -75,10 +82,24 @@ class SCA_ISensor : public SCA_ILogicBrick
/** number of connections to controller */
int m_links;
- /** list of controllers that have just activated this sensor because of a state change */
- std::vector<class SCA_IController*> m_newControllers;
+ /** current sensor state */
+ bool m_state;
+
+ /** previous state (for tap option) */
+ bool m_prev_state;
+
+ std::vector<class SCA_IController*> m_linkedcontrollers;
public:
+
+ enum sensortype {
+ ST_NONE = 0,
+ ST_TOUCH,
+ ST_NEAR,
+ ST_RADAR,
+ // to be updated as needed
+ };
+
SCA_ISensor(SCA_IObject* gameobj,
class SCA_EventManager* eventmgr,
PyTypeObject* T );;
@@ -89,8 +110,8 @@ public:
/* an implementation on this level. It requires an evaluate on the lower */
/* level of individual sensors. Mapping the old activate()s is easy. */
/* The IsPosTrig() also has to change, to keep things consistent. */
- void Activate(class SCA_LogicManager* logicmgr,CValue* event);
- virtual bool Evaluate(CValue* event) = 0;
+ void Activate(class SCA_LogicManager* logicmgr);
+ virtual bool Evaluate() = 0;
virtual bool IsPositiveTrigger();
virtual void Init();
@@ -109,23 +130,40 @@ public:
void SetInvert(bool inv);
/** set the level detection on or off */
void SetLevel(bool lvl);
+ void SetTap(bool tap);
virtual void RegisterToManager();
virtual void UnregisterToManager();
+ void ReserveController(int num)
+ {
+ m_linkedcontrollers.reserve(num);
+ }
+ void LinkToController(SCA_IController* controller);
+ void UnlinkController(SCA_IController* controller);
+ void UnlinkAllControllers();
+ void ActivateControllers(class SCA_LogicManager* logicmgr);
+
+ virtual void ProcessReplica();
virtual double GetNumber();
+ virtual sensortype GetSensorType() { return ST_NONE; }
+
/** Stop sensing for a while. */
void Suspend();
/** Is this sensor switched off? */
bool IsSuspended();
+ /** get the state of the sensor: positive or negative */
+ bool GetState()
+ {
+ return m_state;
+ }
+
/** Resume sensing. */
void Resume();
- void AddNewController(class SCA_IController* controller)
- { m_newControllers.push_back(controller); }
void ClrLink()
{ m_links = 0; }
void IncLink()
@@ -137,6 +175,7 @@ public:
/* Python functions: */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
//Deprecated functions ----->
@@ -157,6 +196,8 @@ public:
static PyObject* pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
};
#endif //__SCA_ISENSOR
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
index f3ce549a637..ff8f3b1c81f 100644
--- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
@@ -59,20 +59,21 @@ SCA_JoystickManager::~SCA_JoystickManager()
void SCA_JoystickManager::NextFrame(double curtime,double deltatime)
{
- if (m_sensors.size()==0) {
+ if (m_sensors.Empty()) {
return;
}
else {
- set<SCA_ISensor*>::iterator it;
+ ;
#ifndef DISABLE_SDL
SCA_Joystick::HandleEvents(); /* Handle all SDL Joystick events */
#endif
- for (it = m_sensors.begin(); it != m_sensors.end(); it++)
+ SG_DList::iterator<SCA_JoystickSensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it);
+ SCA_JoystickSensor* joysensor = *it;
if(!joysensor->IsSuspended())
{
- joysensor->Activate(m_logicmgr, NULL);
+ joysensor->Activate(m_logicmgr);
}
}
}
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 1c601eded81..336529667d7 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -87,7 +87,7 @@ CValue* SCA_JoystickSensor::GetReplica()
{
SCA_JoystickSensor* replica = new SCA_JoystickSensor(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
replica->Init();
return replica;
}
@@ -102,7 +102,7 @@ bool SCA_JoystickSensor::IsPositiveTrigger()
}
-bool SCA_JoystickSensor::Evaluate(CValue* event)
+bool SCA_JoystickSensor::Evaluate()
{
SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
bool result = false;
@@ -198,33 +198,20 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
case KX_JOYSENSORMODE_HAT:
{
/* what is what!
- numberof = m_hat -- max 2
+ numberof = m_hat -- max 4
direction= m_hatf -- max 12
*/
if (!js->IsTrigHat() && !reset) /* No events from SDL? - dont bother */
return false;
- if(m_hat == 1){
- if(js->aHatIsPositive(m_hatf)){
- m_istrig = 1;
- result = true;
- }else{
- if(m_istrig){
- m_istrig = 0;
- result = true;
- }
- }
- }
- if(m_hat == 2){
- if(js->aHatIsPositive(m_hatf)){
- m_istrig = 1;
+ if((m_bAllEvents && js->GetHat(m_hat-1)) || js->aHatIsPositive(m_hat-1, m_hatf)) {
+ m_istrig = 1;
+ result = true;
+ }else{
+ if(m_istrig){
+ m_istrig = 0;
result = true;
- }else{
- if(m_istrig){
- m_istrig = 0;
- result = true;
- }
}
}
break;
@@ -266,8 +253,13 @@ bool SCA_JoystickSensor::isValid(SCA_JoystickSensor::KX_JOYSENSORMODE m)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_JoystickSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_JoystickSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -326,11 +318,13 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
KX_PYATTRIBUTE_INT_LIST_RW_CHECK("hat",0,12,true,SCA_JoystickSensor,m_hat,2,CheckHat),
KX_PYATTRIBUTE_RO_FUNCTION("axisValues", SCA_JoystickSensor, pyattr_get_axis_values),
KX_PYATTRIBUTE_RO_FUNCTION("axisSingle", SCA_JoystickSensor, pyattr_get_axis_single),
+ KX_PYATTRIBUTE_RO_FUNCTION("hatValues", SCA_JoystickSensor, pyattr_get_hat_values),
+ KX_PYATTRIBUTE_RO_FUNCTION("hatSingle", SCA_JoystickSensor, pyattr_get_hat_single),
KX_PYATTRIBUTE_RO_FUNCTION("numAxis", SCA_JoystickSensor, pyattr_get_num_axis),
KX_PYATTRIBUTE_RO_FUNCTION("numButtons", SCA_JoystickSensor, pyattr_get_num_buttons),
KX_PYATTRIBUTE_RO_FUNCTION("numHats", SCA_JoystickSensor, pyattr_get_num_hats),
KX_PYATTRIBUTE_RO_FUNCTION("connected", SCA_JoystickSensor, pyattr_get_connected),
-
+ //KX_PYATTRIBUTE_TODO("events"),
{ NULL } //Sentinel
};
@@ -339,6 +333,10 @@ 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);
@@ -394,6 +392,8 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* args ) {
}
m_axis = axis;
m_axisf = axisflag;
+
+ CheckAxis((void *)this, NULL); /* clamp values */
Py_RETURN_NONE;
}
@@ -535,6 +535,8 @@ PyObject* SCA_JoystickSensor::PySetHat( PyObject* args ) {
}
m_hat = hat;
m_hatf = hatflag;
+
+ CheckHat((void *)this, NULL); /* clamp values */
Py_RETURN_NONE;
}
@@ -608,6 +610,29 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT
return PyInt_FromLong(joy->GetAxisPosition(self->m_axis-1));
}
+PyObject* SCA_JoystickSensor::pyattr_get_hat_values(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);
+
+ int hat_index= joy->GetNumberOfHats();
+ PyObject *list= PyList_New(hat_index);
+
+ while(hat_index--) {
+ PyList_SET_ITEM(list, hat_index, PyInt_FromLong(joy->GetHat(hat_index)));
+ }
+
+ return list;
+}
+
+PyObject* SCA_JoystickSensor::pyattr_get_hat_single(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->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);
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index cf3e7e74414..e6a1d2eef32 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -30,6 +30,7 @@
#define __JOYSENSOR_H
#include "SCA_ISensor.h"
+#include "./Joystick/SCA_JoystickDefines.h"
class SCA_JoystickSensor :public SCA_ISensor
{
@@ -37,7 +38,7 @@ class SCA_JoystickSensor :public SCA_ISensor
class SCA_JoystickManager* m_pJoystickMgr;
/**
- * Axis 1-or-2, MUST be followed by m_axisf
+ * Axis 1-JOYAXIS_MAX, MUST be followed by m_axisf
*/
int m_axis;
/**
@@ -53,11 +54,11 @@ class SCA_JoystickSensor :public SCA_ISensor
*/
int m_buttonf;
/**
- * The actual hat. MUST be followed by m_hatf
+ * The actual hat 1-JOYHAT_MAX. MUST be followed by m_hatf
*/
int m_hat;
/**
- * Flag to find direction 0-11, MUST be an int
+ * Flag to find direction 1-12, MUST be an int
*/
int m_hatf;
/**
@@ -110,7 +111,7 @@ public:
virtual ~SCA_JoystickSensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
@@ -123,6 +124,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
/* Joystick Index */
@@ -151,6 +153,8 @@ public:
static PyObject* pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_hat_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
@@ -163,8 +167,8 @@ public:
SCA_JoystickSensor* sensor = reinterpret_cast<SCA_JoystickSensor*>(self);
if (sensor->m_axis < 1)
sensor->m_axis = 1;
- else if (sensor->m_axis > 2)
- sensor->m_axis = 2;
+ else if (sensor->m_axis > JOYAXIS_MAX)
+ sensor->m_axis = JOYAXIS_MAX;
return 0;
}
static int CheckHat(void *self, const PyAttributeDef*)
@@ -172,8 +176,8 @@ public:
SCA_JoystickSensor* sensor = reinterpret_cast<SCA_JoystickSensor*>(self);
if (sensor->m_hat < 1)
sensor->m_hat = 1;
- else if (sensor->m_hat > 2)
- sensor->m_hat = 2;
+ else if (sensor->m_hat > JOYHAT_MAX)
+ sensor->m_hat = JOYHAT_MAX;
return 0;
}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
index 6a96442b124..279adab94d8 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
@@ -62,12 +62,11 @@ void SCA_KeyboardManager::NextFrame()
{
//const SCA_InputEvent& event = GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
// cerr << "SCA_KeyboardManager::NextFrame"<< endl;
- set<SCA_ISensor*>::iterator it;
- for (it=m_sensors.begin(); it != m_sensors.end(); it++)
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- (*it)->Activate(m_logicmanager,NULL);
+ (*it)->Activate(m_logicmanager);
}
-
}
bool SCA_KeyboardManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index c946156283f..f8ee8ed8b41 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -85,7 +85,7 @@ CValue* SCA_KeyboardSensor::GetReplica()
{
SCA_KeyboardSensor* replica = new SCA_KeyboardSensor(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
replica->Init();
return replica;
}
@@ -118,7 +118,7 @@ bool SCA_KeyboardSensor::TriggerOnAllKeys()
-bool SCA_KeyboardSensor::Evaluate(CValue* eventval)
+bool SCA_KeyboardSensor::Evaluate()
{
bool result = false;
bool reset = m_reset && m_level;
@@ -195,6 +195,9 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval)
}
}
}
+ if (m_tap)
+ // special case for tap mode: only generate event for new activation
+ result = false;
}
@@ -612,8 +615,13 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
/* ------------------------------------------------------------------------- */
PyTypeObject SCA_KeyboardSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_KeyboardSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -664,12 +672,15 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject*
-SCA_KeyboardSensor::py_getattro(PyObject *attr)
+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);
@@ -691,7 +702,7 @@ PyObject* SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBU
{
PyObject* keypair = PyList_New(2);
PyList_SET_ITEM(keypair,0,PyInt_FromLong(i));
- PyList_SetItem(keypair,1,PyInt_FromLong(inevent.m_status));
+ PyList_SET_ITEM(keypair,1,PyInt_FromLong(inevent.m_status));
PyList_Append(resultlist,keypair);
}
}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
index 073b3e6dbe0..033225cd9be 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
@@ -102,7 +102,7 @@ public:
short int GetHotkey();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
bool TriggerOnAllKeys();
@@ -111,6 +111,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
//Deprecated functions ----->
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp
index b584b37180f..83271288154 100644
--- a/source/gameengine/GameLogic/SCA_LogicManager.cpp
+++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp
@@ -49,37 +49,14 @@ SCA_LogicManager::SCA_LogicManager()
SCA_LogicManager::~SCA_LogicManager()
{
- /* AddRef() is not used when the objects are added to m_mapStringToGameObjects
- so Release() should not be used either. The memory leak big is fixed
- in BL_ConvertBlenderObjects()
-
- int numgameobj = m_mapStringToGameObjects.size();
- for (int i = 0; i < numgameobj; i++)
- {
- CValue** gameobjptr = m_mapStringToGameObjects.at(i);
- assert(gameobjptr);
- if (gameobjptr)
- (*gameobjptr)->Release();
-
- }
- */
- /*for (int i=0;i<m_sensorcontrollermap.size();i++)
- {
- vector<SCA_IController*>* controllerarray = *(m_sensorcontrollermap[i]);
- delete controllerarray;
- }
- */
- for (vector<SCA_EventManager*>::iterator it = m_eventmanagers.begin();!(it==m_eventmanagers.end());it++)
+ for (vector<SCA_EventManager*>::iterator it = m_eventmanagers.begin();!(it==m_eventmanagers.end());++it)
{
delete (*it);
}
m_eventmanagers.clear();
- m_sensorcontrollermapje.clear();
- m_removedActuators.clear();
- m_activeActuators.clear();
+ assert(m_activeActuators.Empty());
}
-
/*
// this kind of fixes bug 398 but breakes games, so better leave it out for now.
// a removed object's gameobject (and logicbricks and stuff) didn't get released
@@ -171,12 +148,7 @@ void* SCA_LogicManager::FindBlendObjByGameMeshName(const STR_String& gamemeshnam
void SCA_LogicManager::RemoveSensor(SCA_ISensor* sensor)
{
- controllerlist contlist = m_sensorcontrollermapje[sensor];
- for (controllerlist::const_iterator c= contlist.begin();!(c==contlist.end());c++)
- {
- (*c)->UnlinkSensor(sensor);
- }
- m_sensorcontrollermapje.erase(sensor);
+ sensor->UnlinkAllControllers();
sensor->UnregisterToManager();
}
@@ -184,35 +156,22 @@ void SCA_LogicManager::RemoveController(SCA_IController* controller)
{
controller->UnlinkAllSensors();
controller->UnlinkAllActuators();
- std::map<SCA_ISensor*,controllerlist>::iterator sit;
- for (sit = m_sensorcontrollermapje.begin();!(sit==m_sensorcontrollermapje.end());++sit)
- {
- (*sit).second.remove(controller);
- }
+ controller->Deactivate();
}
-void SCA_LogicManager::RemoveDestroyedActuator(SCA_IActuator* actuator)
+void SCA_LogicManager::RemoveActuator(SCA_IActuator* actuator)
{
- m_removedActuators.push_back(SmartActuatorPtr(actuator,0));
- // take care that no controller can use this actuator again !
-
- std::map<SCA_ISensor*,controllerlist>::const_iterator sit;
- for (sit = m_sensorcontrollermapje.begin();!(sit==m_sensorcontrollermapje.end());++sit)
- {
- controllerlist contlist = (*sit).second;
- for (list<SCA_IController*>::const_iterator c= contlist.begin();!(c==contlist.end());c++)
- {
- (*c)->UnlinkActuator(actuator);
- }
- }
+ actuator->UnlinkAllControllers();
+ actuator->Deactivate();
+ actuator->SetActive(false);
}
void SCA_LogicManager::RegisterToSensor(SCA_IController* controller,SCA_ISensor* sensor)
{
- m_sensorcontrollermapje[sensor].push_back(controller);
+ sensor->LinkToController(controller);
controller->LinkToSensor(sensor);
}
@@ -220,6 +179,7 @@ void SCA_LogicManager::RegisterToSensor(SCA_IController* controller,SCA_ISensor*
void SCA_LogicManager::RegisterToActuator(SCA_IController* controller,SCA_IActuator* actua)
{
+ actua->LinkToController(controller);
controller->LinkToActuator(actua);
}
@@ -230,88 +190,62 @@ void SCA_LogicManager::BeginFrame(double curtime, double fixedtime)
for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin(); !(ie==m_eventmanagers.end()); ie++)
(*ie)->NextFrame(curtime, fixedtime);
- // for this frame, look up for activated sensors, and build the collection of triggered controllers
- // int numsensors = this->m_activatedsensors.size(); /*unused*/
-
- for (vector<SCA_ISensor*>::const_iterator is=m_activatedsensors.begin();
- !(is==m_activatedsensors.end());is++)
+ for(SG_QList* obj = (SG_QList*)m_triggeredControllerSet.Remove();
+ obj != NULL;
+ obj = (SG_QList*)m_triggeredControllerSet.Remove())
{
- SCA_ISensor* sensor = *is;
- controllerlist contlist = m_sensorcontrollermapje[sensor];
- for (list<SCA_IController*>::const_iterator c= contlist.begin();
- !(c==contlist.end());c++)
+ for(SCA_IController* contr = (SCA_IController*)obj->QRemove();
+ contr != NULL;
+ contr = (SCA_IController*)obj->QRemove())
{
- SCA_IController* contr = *c;//controllerarray->at(c);
- if (contr->IsActive())
- {
- m_triggeredControllerSet.insert(SmartControllerPtr(contr,0));
- // So that the controller knows which sensor has activited it.
- // Only needed for the python controller though.
- if (contr->GetType() == &SCA_PythonController::Type)
- {
- SCA_PythonController* pythonController = (SCA_PythonController*)contr;
- pythonController->AddTriggeredSensor(sensor);
- }
- }
+ contr->Trigger(this);
+ contr->ClrJustActivated();
}
- //sensor->SetActive(false);
}
-
-
- // int numtriggered = triggeredControllerSet.size(); /*unused*/
- for (set<SmartControllerPtr>::iterator tit=m_triggeredControllerSet.begin();
- !(tit==m_triggeredControllerSet.end());tit++)
- {
- (*tit)->Trigger(this);
- }
- m_triggeredControllerSet.clear();
}
void SCA_LogicManager::UpdateFrame(double curtime, bool frame)
{
- vector<SmartActuatorPtr>::iterator ra;
- for (ra = m_removedActuators.begin(); !(ra == m_removedActuators.end()); ra++)
- {
- m_activeActuators.erase(*ra);
- (*ra)->SetActive(false);
- }
- m_removedActuators.clear();
-
- // About to run actuators, but before update the sensors for those which depends on actuators
for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin(); !(ie==m_eventmanagers.end()); ie++)
(*ie)->UpdateFrame();
- for (set<SmartActuatorPtr>::iterator ia = m_activeActuators.begin();!(ia==m_activeActuators.end());ia++)
+ SG_DList::iterator<SG_QList> io(m_activeActuators);
+ for (io.begin(); !io.end(); )
{
- //SCA_IActuator* actua = *ia;
- if (!(*ia)->Update(curtime, frame))
+ SG_QList* ahead = *io;
+ // increment now so that we can remove the current element
+ ++io;
+ SG_QList::iterator<SCA_IActuator> ia(*ahead);
+ for (ia.begin(); !ia.end(); )
{
- //*ia = m_activeactuators.back();
- m_removedActuators.push_back(*ia);
-
- (*ia)->SetActive(false);
- //m_activeactuators.pop_back();
- } else if ((*ia)->IsNoLink())
+ SCA_IActuator* actua = *ia;
+ // increment first to allow removal of inactive actuators.
+ ++ia;
+ if (!actua->Update(curtime, frame))
+ {
+ // this actuator is not active anymore, remove
+ actua->QDelink();
+ actua->SetActive(false);
+ } else if (actua->IsNoLink())
+ {
+ // This actuator has no more links but it still active
+ // make sure it will get a negative event on next frame to stop it
+ // Do this check after Update() rather than before to make sure
+ // that all the actuators that are activated at same time than a state
+ // actuator have a chance to execute.
+ bool event = false;
+ actua->RemoveAllEvents();
+ actua->AddEvent(event);
+ }
+ }
+ if (ahead->QEmpty())
{
- // This actuator has no more links but it still active
- // make sure it will get a negative event on next frame to stop it
- // Do this check after Update() rather than before to make sure
- // that all the actuators that are activated at same time than a state
- // actuator have a chance to execute.
- CValue* event = new CBoolValue(false);
- (*ia)->RemoveAllEvents();
- (*ia)->AddEvent(event);
+ // no more active controller, remove from main list
+ ahead->Delink();
}
}
-
- for ( ra = m_removedActuators.begin(); !(ra == m_removedActuators.end()); ra++)
- {
- m_activeActuators.erase(*ra);
- (*ra)->SetActive(false);
- }
- m_removedActuators.clear();
}
@@ -360,39 +294,17 @@ void SCA_LogicManager::RegisterActionName(const STR_String& actname,void* action
void SCA_LogicManager::EndFrame()
{
- for (vector<SCA_ISensor*>::const_iterator is=m_activatedsensors.begin();
- !(is==m_activatedsensors.end());is++)
- {
- SCA_ISensor* sensor = *is;
- sensor->SetActive(false);
- }
- m_activatedsensors.clear();
-
for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin();
!(ie==m_eventmanagers.end());ie++)
{
(*ie)->EndFrame();
}
-
-
}
-
-void SCA_LogicManager::AddActivatedSensor(SCA_ISensor* sensor)
-{
- // each frame, only add sensor once, and to avoid a seek, or bloated container
- // hold a flag in each sensor, with the 'framenr'
- if (!sensor->IsActive())
- {
- sensor->SetActive(true);
- m_activatedsensors.push_back(sensor);
- }
-}
-
void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor)
{
- m_triggeredControllerSet.insert(SmartControllerPtr(controller,0));
+ controller->Activate(m_triggeredControllerSet);
// so that the controller knows which sensor has activited it
// only needed for python controller
if (controller->GetType() == &SCA_PythonController::Type)
@@ -402,19 +314,6 @@ void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_I
}
}
-
-void SCA_LogicManager::AddActiveActuator(SCA_IActuator* actua,CValue* event)
-{
- if (!actua->IsActive())
- {
- actua->SetActive(true);
- m_activeActuators.insert(SmartActuatorPtr(actua,0));
- }
- actua->AddEvent(event->AddRef());
-}
-
-
-
SCA_EventManager* SCA_LogicManager::FindEventManager(int eventmgrtype)
{
// find an eventmanager of a certain type
@@ -432,109 +331,3 @@ SCA_EventManager* SCA_LogicManager::FindEventManager(int eventmgrtype)
}
return eventmgr;
}
-
-
-
-SmartActuatorPtr::SmartActuatorPtr(const SmartActuatorPtr& other)
-{
- this->m_actuator = other.m_actuator;
- this->m_actuator->AddRef();
-}
-
-
-
-SmartActuatorPtr::SmartActuatorPtr(SCA_IActuator* actua,int dummy)
-: m_actuator(actua)
-{
- actua->AddRef();
-}
-
-
-
-SmartActuatorPtr::~SmartActuatorPtr()
-{
- m_actuator->Release();
-}
-
-
-
-bool SmartActuatorPtr::operator <(const SmartActuatorPtr& other) const
-{
-
- return m_actuator->LessComparedTo(*other);
-}
-
-
-
-bool SmartActuatorPtr::operator ==(const SmartActuatorPtr& other) const
-{
- bool result2 = other->LessComparedTo(m_actuator);
- return (m_actuator->LessComparedTo(*other) && result2);
-}
-
-
-
-SCA_IActuator* SmartActuatorPtr::operator->() const
-{
- return m_actuator;
-}
-
-
-
-SCA_IActuator* SmartActuatorPtr::operator*() const
-{
- return m_actuator;
-}
-
-
-
-SmartControllerPtr::SmartControllerPtr(const SmartControllerPtr& copy)
-{
- this->m_controller = copy.m_controller;
- this->m_controller->AddRef();
-}
-
-
-
-SmartControllerPtr::SmartControllerPtr(SCA_IController* contr,int dummy)
-: m_controller(contr)
-{
- m_controller->AddRef();
-}
-
-
-
-SmartControllerPtr::~SmartControllerPtr()
-{
- m_controller->Release();
-}
-
-
-
-bool SmartControllerPtr::operator <(const SmartControllerPtr& other) const
-{
- return m_controller->LessComparedTo(*other);
-}
-
-
-
-bool SmartControllerPtr::operator ==(const SmartControllerPtr& other) const
-{
- return (m_controller->LessComparedTo(*other) && other->LessComparedTo(m_controller));
-}
-
-
-
-SCA_IController* SmartControllerPtr::operator->() const
-{
- return m_controller;
-}
-
-
-
-SCA_IController* SmartControllerPtr::operator*() const
-{
- return m_controller;
-}
-
-
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h
index 50383879d8f..53e75e1eaee 100644
--- a/source/gameengine/GameLogic/SCA_LogicManager.h
+++ b/source/gameengine/GameLogic/SCA_LogicManager.h
@@ -43,11 +43,13 @@
#include "GEN_Map.h"
#include "STR_HashedString.h"
#include "Value.h"
+#include "SG_QList.h"
#include "KX_HashedPtr.h"
using namespace std;
-typedef list<class SCA_IController*> controllerlist;
+typedef std::list<class SCA_IController*> controllerlist;
+typedef std::map<class SCA_ISensor*,controllerlist > sensormap_t;
/**
* This manager handles sensor, controllers and actuators.
@@ -63,45 +65,19 @@ typedef list<class SCA_IController*> controllerlist;
*/
#include "SCA_ILogicBrick.h"
+#include "SCA_IActuator.h"
-// todo: make this into a template, but first I want to think about what exactly to put in
-class SmartActuatorPtr
-{
- SCA_IActuator* m_actuator;
-public:
- SmartActuatorPtr(SCA_IActuator* actua,int dummy);
- SmartActuatorPtr(const SmartActuatorPtr& other);
- virtual ~SmartActuatorPtr();
- bool operator <(const SmartActuatorPtr& other) const;
- bool operator ==(const SmartActuatorPtr& other) const;
- SCA_IActuator* operator->() const;
- SCA_IActuator* operator*() const;
-
-};
-
-class SmartControllerPtr
-{
- SCA_IController* m_controller;
-public:
- SmartControllerPtr(const SmartControllerPtr& copy);
- SmartControllerPtr(SCA_IController* contr,int dummy);
- virtual ~SmartControllerPtr();
- bool operator <(const SmartControllerPtr& other) const;
- bool operator ==(const SmartControllerPtr& other) const;
- SCA_IController* operator->() const;
- SCA_IController* operator*() const;
-
-};
class SCA_LogicManager
{
vector<class SCA_EventManager*> m_eventmanagers;
- vector<class SCA_ISensor*> m_activatedsensors;
- set<class SmartActuatorPtr> m_activeActuators;
- set<class SmartControllerPtr> m_triggeredControllerSet;
-
- map<SCA_ISensor*,controllerlist > m_sensorcontrollermapje;
+ // SG_DList: Head of objects having activated actuators
+ // element: SCA_IObject::m_activeActuators
+ SG_DList m_activeActuators;
+ // SG_DList: Head of objects having activated controllers
+ // element: SCA_IObject::m_activeControllers
+ SG_DList m_triggeredControllerSet;
// need to find better way for this
// also known as FactoryManager...
@@ -111,11 +87,10 @@ class SCA_LogicManager
GEN_Map<STR_HashedString,void*> m_map_gamemeshname_to_blendobj;
GEN_Map<CHashedPtr,void*> m_map_blendobj_to_gameobj;
-
- vector<SmartActuatorPtr> m_removedActuators;
public:
SCA_LogicManager();
virtual ~SCA_LogicManager();
+
//void SetKeyboardManager(SCA_KeyboardManager* keyboardmgr) { m_keyboardmgr=keyboardmgr;}
void RegisterEventManager(SCA_EventManager* eventmgr);
void RegisterToSensor(SCA_IController* controller,
@@ -126,8 +101,13 @@ public:
void BeginFrame(double curtime, double fixedtime);
void UpdateFrame(double curtime, bool frame);
void EndFrame();
- void AddActivatedSensor(SCA_ISensor* sensor);
- void AddActiveActuator(SCA_IActuator* sensor,class CValue* event);
+ void AddActiveActuator(SCA_IActuator* actua,bool event)
+ {
+ actua->SetActive(true);
+ actua->Activate(m_activeActuators);
+ actua->AddEvent(event);
+ }
+
void AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor);
SCA_EventManager* FindEventManager(int eventmgrtype);
@@ -138,7 +118,7 @@ public:
*/
void RemoveSensor(SCA_ISensor* sensor);
void RemoveController(SCA_IController* controller);
- void RemoveDestroyedActuator(SCA_IActuator* actuator);
+ void RemoveActuator(SCA_IActuator* actuator);
// for the scripting... needs a FactoryManager later (if we would have time... ;)
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp
index ca875dad07c..d407647cec3 100644
--- a/source/gameengine/GameLogic/SCA_MouseManager.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp
@@ -75,8 +75,8 @@ void SCA_MouseManager::NextFrame()
{
if (m_mousedevice)
{
- set<SCA_ISensor*>::iterator it;
- for (it=m_sensors.begin(); it!=m_sensors.end(); it++)
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
SCA_MouseSensor* mousesensor = (SCA_MouseSensor*)(*it);
// (0,0) is the Upper Left corner in our local window
@@ -93,7 +93,7 @@ void SCA_MouseManager::NextFrame()
mousesensor->setX(mx);
mousesensor->setY(my);
- mousesensor->Activate(m_logicmanager,NULL);
+ mousesensor->Activate(m_logicmanager);
}
}
}
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
index 4dbeb156e63..c5e1c3c0441 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
@@ -111,7 +111,7 @@ CValue* SCA_MouseSensor::GetReplica()
{
SCA_MouseSensor* replica = new SCA_MouseSensor(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
replica->Init();
return replica;
@@ -144,7 +144,7 @@ SCA_IInputDevice::KX_EnumInputs SCA_MouseSensor::GetHotKey()
-bool SCA_MouseSensor::Evaluate(CValue* event)
+bool SCA_MouseSensor::Evaluate()
{
bool result = false;
bool reset = m_reset && m_level;
@@ -296,8 +296,13 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
/* ------------------------------------------------------------------------- */
PyTypeObject SCA_MouseSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_MouseSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -342,6 +347,10 @@ 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);
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h
index 2d1c496029d..6d6302b514a 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.h
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.h
@@ -97,7 +97,7 @@ class SCA_MouseSensor : public SCA_ISensor
virtual ~SCA_MouseSensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual void Init();
virtual bool IsPositiveTrigger();
short int GetModeKey();
@@ -110,6 +110,7 @@ class SCA_MouseSensor : public SCA_ISensor
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
//Deprecated functions ----->
diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp
index 703c9c1bbaf..d27aea5e6f7 100644
--- a/source/gameengine/GameLogic/SCA_NANDController.cpp
+++ b/source/gameengine/GameLogic/SCA_NANDController.cpp
@@ -66,26 +66,19 @@ void SCA_NANDController::Trigger(SCA_LogicManager* logicmgr)
!(is==m_linkedsensors.end());is++)
{
SCA_ISensor* sensor = *is;
- if (!sensor->IsPositiveTrigger())
+ if (!sensor->GetState())
{
sensorresult = true;
break;
}
}
- CValue* newevent = new CBoolValue(sensorresult);
-
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
!(i==m_linkedactuators.end());i++)
{
- SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
- logicmgr->AddActiveActuator(actua,newevent);
+ SCA_IActuator* actua = *i;
+ logicmgr->AddActiveActuator(actua,sensorresult);
}
-
- // every actuator that needs the event, has a it's own reference to it now so
- // release it (so to be clear: if there is no actuator, it's deleted right now)
- newevent->Release();
-
}
@@ -94,7 +87,7 @@ CValue* SCA_NANDController::GetReplica()
{
CValue* replica = new SCA_NANDController(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -107,8 +100,13 @@ CValue* SCA_NANDController::GetReplica()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_NANDController::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_NANDController",
sizeof(PyObjectPlus_Proxy),
0,
@@ -145,4 +143,8 @@ 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 11600914a1a..0ae0ff19745 100644
--- a/source/gameengine/GameLogic/SCA_NANDController.h
+++ b/source/gameengine/GameLogic/SCA_NANDController.h
@@ -49,6 +49,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
};
diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp
index 06acae5a81a..6c9141636b2 100644
--- a/source/gameengine/GameLogic/SCA_NORController.cpp
+++ b/source/gameengine/GameLogic/SCA_NORController.cpp
@@ -66,26 +66,19 @@ void SCA_NORController::Trigger(SCA_LogicManager* logicmgr)
!(is==m_linkedsensors.end());is++)
{
SCA_ISensor* sensor = *is;
- if (sensor->IsPositiveTrigger())
+ if (sensor->GetState())
{
sensorresult = false;
break;
}
}
- CValue* newevent = new CBoolValue(sensorresult);
-
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
!(i==m_linkedactuators.end());i++)
{
- SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
- logicmgr->AddActiveActuator(actua,newevent);
+ SCA_IActuator* actua = *i;
+ logicmgr->AddActiveActuator(actua,sensorresult);
}
-
- // every actuator that needs the event, has a it's own reference to it now so
- // release it (so to be clear: if there is no actuator, it's deleted right now)
- newevent->Release();
-
}
@@ -94,7 +87,7 @@ CValue* SCA_NORController::GetReplica()
{
CValue* replica = new SCA_NORController(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -107,8 +100,13 @@ CValue* SCA_NORController::GetReplica()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_NORController::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_NORController",
sizeof(PyObjectPlus_Proxy),
0,
@@ -145,4 +143,8 @@ 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 fc814e28d37..06cbb70a489 100644
--- a/source/gameengine/GameLogic/SCA_NORController.h
+++ b/source/gameengine/GameLogic/SCA_NORController.h
@@ -49,6 +49,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
};
diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp
index 319ff04f776..42c0a67d657 100644
--- a/source/gameengine/GameLogic/SCA_ORController.cpp
+++ b/source/gameengine/GameLogic/SCA_ORController.cpp
@@ -60,7 +60,7 @@ CValue* SCA_ORController::GetReplica()
{
CValue* replica = new SCA_ORController(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -76,21 +76,16 @@ void SCA_ORController::Trigger(SCA_LogicManager* logicmgr)
while ( (!sensorresult) && (!(is==m_linkedsensors.end())) )
{
sensor = *is;
- if (sensor->IsPositiveTrigger()) sensorresult = true;
+ if (sensor->GetState()) sensorresult = true;
is++;
}
- CValue* newevent = new CBoolValue(sensorresult);
-
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
!(i==m_linkedactuators.end());i++)
{
- SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
- logicmgr->AddActiveActuator(actua,newevent);
+ SCA_IActuator* actua = *i;
+ logicmgr->AddActiveActuator(actua,sensorresult);
}
-
-
- newevent->Release();
}
/* ------------------------------------------------------------------------- */
@@ -99,8 +94,13 @@ void SCA_ORController::Trigger(SCA_LogicManager* logicmgr)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_ORController::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_ORController",
sizeof(PyObjectPlus_Proxy),
0,
@@ -138,4 +138,8 @@ 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 fdc81486e74..66f772c739e 100644
--- a/source/gameengine/GameLogic/SCA_ORController.h
+++ b/source/gameengine/GameLogic/SCA_ORController.h
@@ -50,6 +50,7 @@ public:
/* --------------------------------------------------------------------- */
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 c4db723ee89..4faa4b55d4a 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -186,11 +186,6 @@ GetReplica() {
SCA_PropertyActuator* replica = new SCA_PropertyActuator(*this);
replica->ProcessReplica();
-
- // this will copy properties and so on...
-
- CValue::AddDataToReplica(replica);
-
return replica;
};
@@ -233,8 +228,13 @@ void SCA_PropertyActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_PropertyActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_PropertyActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -270,8 +270,9 @@ PyMethodDef SCA_PropertyActuator::Methods[] = {
};
PyAttributeDef SCA_PropertyActuator::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW_CHECK("property",0,100,false,SCA_PropertyActuator,m_propname,CheckProperty),
+ KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,100,false,SCA_PropertyActuator,m_propname,CheckProperty),
KX_PYATTRIBUTE_STRING_RW("value",0,100,false,SCA_PropertyActuator,m_exprtxt),
+ KX_PYATTRIBUTE_INT_RW("mode", KX_ACT_PROP_NODEF+1, KX_ACT_PROP_MAX-1, false, SCA_PropertyActuator, m_type), /* ATTR_TODO add constents to game logic dict */
{ NULL } //Sentinel
};
@@ -279,6 +280,10 @@ 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);
}
@@ -291,7 +296,7 @@ const char SCA_PropertyActuator::SetProperty_doc[] =
"\tof this name, the call is ignored.\n";
PyObject* SCA_PropertyActuator::PySetProperty(PyObject* args, PyObject* kwds)
{
- ShowDeprecationWarning("setProperty()", "the 'property' property");
+ ShowDeprecationWarning("setProperty()", "the 'propName' property");
/* Check whether the name exists first ! */
char *nameArg;
if (!PyArg_ParseTuple(args, "s:setProperty", &nameArg)) {
@@ -316,7 +321,7 @@ const char SCA_PropertyActuator::GetProperty_doc[] =
"\tReturn the property on which the actuator operates.\n";
PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* args, PyObject* kwds)
{
- ShowDeprecationWarning("getProperty()", "the 'property' property");
+ ShowDeprecationWarning("getProperty()", "the 'propName' property");
return PyString_FromString(m_propname);
}
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index bb841cf88ad..a8df08dfc6e 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -87,6 +87,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
// python wrapped methods
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
index e5e3f9cced5..764465309df 100644
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
@@ -50,8 +50,9 @@ SCA_PropertyEventManager::~SCA_PropertyEventManager()
void SCA_PropertyEventManager::NextFrame()
{
// check for changed properties
- for (set<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- (*it)->Activate(m_logicmgr,NULL);
+ (*it)->Activate(m_logicmgr);
}
}
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index de8a9fcf03e..3b343af3cba 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -37,6 +37,7 @@
#include "StringValue.h"
#include "SCA_EventManager.h"
#include "SCA_LogicManager.h"
+#include "BoolValue.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -111,7 +112,7 @@ CValue* SCA_PropertySensor::GetReplica()
{
SCA_PropertySensor* replica = new SCA_PropertySensor(*this);
// m_range_expr must be recalculated on replica!
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
replica->Init();
replica->m_range_expr = NULL;
@@ -152,7 +153,7 @@ SCA_PropertySensor::~SCA_PropertySensor()
-bool SCA_PropertySensor::Evaluate(CValue* event)
+bool SCA_PropertySensor::Evaluate()
{
bool result = CheckPropertyCondition();
bool reset = m_reset && m_level;
@@ -182,17 +183,14 @@ bool SCA_PropertySensor::CheckPropertyCondition()
CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
if (!orgprop->IsError())
{
- STR_String testprop = orgprop->GetText();
+ const STR_String& testprop = orgprop->GetText();
// Force strings to upper case, to avoid confusion in
// bool tests. It's stupid the prop's identity is lost
// on the way here...
- if ((testprop == "TRUE") || (testprop == "FALSE")) {
- STR_String checkprop = m_checkpropval;
- checkprop.Upper();
- result = (testprop == checkprop);
- } else {
- result = (orgprop->GetText() == m_checkpropval);
+ if ((&testprop == &CBoolValue::sTrueString) || (&testprop == &CBoolValue::sFalseString)) {
+ m_checkpropval.Upper();
}
+ result = (testprop == m_checkpropval);
}
orgprop->Release();
@@ -232,8 +230,8 @@ bool SCA_PropertySensor::CheckPropertyCondition()
CValue* vallie = m_range_expr->Calculate();
if (vallie)
{
- STR_String errtext = vallie->GetText();
- if (errtext == "TRUE")
+ const STR_String& errtext = vallie->GetText();
+ if (&errtext == &CBoolValue::sTrueString)
{
result = true;
} else
@@ -295,9 +293,8 @@ CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername)
int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*)
{
- bool result = true;
/* There is no type checking at this moment, unfortunately... */
- return result;
+ return 0;
}
/* ------------------------------------------------------------------------- */
@@ -306,8 +303,13 @@ int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_PropertySensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_PropertySensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -345,8 +347,8 @@ PyMethodDef SCA_PropertySensor::Methods[] = {
};
PyAttributeDef SCA_PropertySensor::Attributes[] = {
- KX_PYATTRIBUTE_INT_RW("type",KX_PROPSENSOR_NODEF,KX_PROPSENSOR_MAX-1,false,SCA_PropertySensor,m_checktype),
- KX_PYATTRIBUTE_STRING_RW_CHECK("property",0,100,false,SCA_PropertySensor,m_checkpropname,CheckProperty),
+ KX_PYATTRIBUTE_INT_RW("mode",KX_PROPSENSOR_NODEF,KX_PROPSENSOR_MAX-1,false,SCA_PropertySensor,m_checktype),
+ KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,100,false,SCA_PropertySensor,m_checkpropname,CheckProperty),
KX_PYATTRIBUTE_STRING_RW_CHECK("value",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty),
{ NULL } //Sentinel
};
@@ -356,6 +358,10 @@ 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);
}
@@ -366,7 +372,7 @@ const char SCA_PropertySensor::GetType_doc[] =
"\tReturns the type of check this sensor performs.\n";
PyObject* SCA_PropertySensor::PyGetType()
{
- ShowDeprecationWarning("getType()", "the type property");
+ ShowDeprecationWarning("getType()", "the mode property");
return PyInt_FromLong(m_checktype);
}
@@ -379,7 +385,7 @@ const char SCA_PropertySensor::SetType_doc[] =
"\tSet the type of check to perform.\n";
PyObject* SCA_PropertySensor::PySetType(PyObject* args)
{
- ShowDeprecationWarning("setType()", "the type property");
+ ShowDeprecationWarning("setType()", "the mode property");
int typeArg;
if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) {
@@ -400,7 +406,7 @@ const char SCA_PropertySensor::GetProperty_doc[] =
"\tReturn the property with which the sensor operates.\n";
PyObject* SCA_PropertySensor::PyGetProperty()
{
- ShowDeprecationWarning("getProperty()", "the 'property' property");
+ ShowDeprecationWarning("getProperty()", "the 'propName' property");
return PyString_FromString(m_checkpropname);
}
@@ -412,7 +418,7 @@ const char SCA_PropertySensor::SetProperty_doc[] =
"\tof this name, the call is ignored.\n";
PyObject* SCA_PropertySensor::PySetProperty(PyObject* args)
{
- ShowDeprecationWarning("setProperty()", "the 'property' property");
+ ShowDeprecationWarning("setProperty()", "the 'propName' property");
/* We should query whether the name exists. Or should we create a prop */
/* on the fly? */
char *propNameArg = NULL;
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h
index e1e378a973c..538ecd65949 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.h
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.h
@@ -81,7 +81,7 @@ public:
void PrecalculateRangeExpression();
bool CheckPropertyCondition();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual CValue* FindIdentifier(const STR_String& identifiername);
@@ -90,6 +90,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
/* 1. getType */
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index b8052555528..80e4f54c9c5 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -48,12 +48,18 @@ SCA_PythonController* SCA_PythonController::m_sCurrentController = NULL;
SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj,
+ int mode,
PyTypeObject* T)
: SCA_IController(gameobj, T),
m_bytecode(NULL),
+ m_function(NULL),
+ m_function_argc(0),
m_bModified(true),
+ m_debug(false),
+ m_mode(mode),
m_pythondictionary(NULL)
{
+
}
/*
@@ -74,15 +80,12 @@ int SCA_PythonController::Release()
SCA_PythonController::~SCA_PythonController()
{
- if (m_bytecode)
- {
- //
- //printf("released python byte script\n");
- Py_DECREF(m_bytecode);
- }
+ //printf("released python byte script\n");
- if (m_pythondictionary)
- {
+ Py_XDECREF(m_bytecode);
+ Py_XDECREF(m_function);
+
+ if (m_pythondictionary) {
// break any circular references in the dictionary
PyDict_Clear(m_pythondictionary);
Py_DECREF(m_pythondictionary);
@@ -94,8 +97,12 @@ SCA_PythonController::~SCA_PythonController()
CValue* SCA_PythonController::GetReplica()
{
SCA_PythonController* replica = new SCA_PythonController(*this);
- // Copy the compiled bytecode if possible.
+
+ /* why is this needed at all??? - m_bytecode is NULL'd below so this doesnt make sense
+ * but removing it crashes blender (with YoFrankie). so leave in for now - Campbell */
Py_XINCREF(replica->m_bytecode);
+
+ Py_XINCREF(replica->m_function); // this is ok since its not set to NULL
replica->m_bModified = replica->m_bytecode == NULL;
// The replica->m_pythondictionary is stolen - replace with a copy.
@@ -110,7 +117,7 @@ CValue* SCA_PythonController::GetReplica()
*/
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -140,6 +147,11 @@ void SCA_PythonController::SetDictionary(PyObject* pythondictionary)
Py_DECREF(m_pythondictionary);
}
m_pythondictionary = PyDict_Copy(pythondictionary); /* new reference */
+
+ /* 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()));
+
}
int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor)
@@ -150,13 +162,14 @@ int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor)
return 0;
}
-#if 0
-static const char* sPyGetCurrentController__doc__;
-#endif
-
/* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */
PyObject* SCA_PythonController::sPyGetCurrentController(PyObject *self)
{
+ if(m_sCurrentController==NULL)
+ {
+ PyErr_SetString(PyExc_SystemError, "GameLogic.getCurrentController(), this function is being run outside the python controllers context, or blenders internal state is corrupt.");
+ return NULL;
+ }
return m_sCurrentController->GetProxy();
}
@@ -170,15 +183,15 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
if (PyString_Check(value)) {
/* get the actuator from the name */
char *name= PyString_AsString(value);
- for(it = lacts.begin(); it!= lacts.end(); it++) {
+ for(it = lacts.begin(); it!= lacts.end(); ++it) {
if( name == (*it)->GetName() ) {
return *it;
}
}
}
else if (BGE_PROXY_CHECK_TYPE(value)) {
- PyObjectPlus *value_plus= BGE_PROXY_REF(value); /* Expecting an actuator type */ // XXX TODO - CHECK TYPE
- for(it = lacts.begin(); it!= lacts.end(); it++) {
+ PyObjectPlus *value_plus= BGE_PROXY_REF(value);
+ for(it = lacts.begin(); it!= lacts.end(); ++it) {
if( static_cast<SCA_IActuator*>(value_plus) == (*it) ) {
return *it;
}
@@ -193,13 +206,11 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
return false;
}
-#if 0
-static const char* sPyAddActiveActuator__doc__;
-#endif
-
/* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */
PyObject* SCA_PythonController::sPyAddActiveActuator(PyObject* self, PyObject* args)
{
+ ShowDeprecationWarning("GameLogic.addActiveActuator(act, bool)", "controller.activate(act) or controller.deactivate(act)");
+
PyObject* ob1;
int activate;
if (!PyArg_ParseTuple(args, "Oi:addActiveActuator", &ob1,&activate))
@@ -209,20 +220,22 @@ PyObject* SCA_PythonController::sPyAddActiveActuator(PyObject* self, PyObject* a
if(actu==NULL)
return NULL;
- CValue* boolval = new CBoolValue(activate!=0);
+ bool boolval = (activate!=0);
m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu,boolval);
- boolval->Release();
Py_RETURN_NONE;
}
-
const char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentController()";
const char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuator(actuator,bool)";
-const char SCA_PythonController::GetActuators_doc[] = "getActuator";
PyTypeObject SCA_PythonController::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_PythonController",
sizeof(PyObjectPlus_Proxy),
0,
@@ -249,59 +262,137 @@ PyMethodDef SCA_PythonController::Methods[] = {
{"activate", (PyCFunction) SCA_PythonController::sPyActivate, METH_O},
{"deactivate", (PyCFunction) SCA_PythonController::sPyDeActivate, METH_O},
- {"getActuators", (PyCFunction) SCA_PythonController::sPyGetActuators, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetActuators_doc},
- {"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, METH_O, (PY_METHODCHAR)SCA_PythonController::GetActuator_doc},
- {"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetSensors_doc},
- {"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, METH_O, (PY_METHODCHAR)SCA_PythonController::GetSensor_doc},
//Deprecated functions ------>
{"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O},
{"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS},
- {"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_NOARGS},
//<----- Deprecated
{NULL,NULL} //Sentinel
};
PyAttributeDef SCA_PythonController::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("state", SCA_PythonController, pyattr_get_state),
KX_PYATTRIBUTE_RW_FUNCTION("script", SCA_PythonController, pyattr_get_script, pyattr_set_script),
+ KX_PYATTRIBUTE_INT_RO("mode", SCA_PythonController, m_mode),
{ NULL } //Sentinel
};
-bool SCA_PythonController::Compile()
+void SCA_PythonController::ErrorPrint(const char *error_msg)
{
+ // didn't compile, so instead of compile, complain
+ // something is wrong, tell the user what went wrong
+ printf("%s - controller \"%s\":\n", error_msg, GetName().Ptr());
+ //PyRun_SimpleString(m_scriptText.Ptr());
+ PyErr_Print();
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( (char *)"last_traceback", NULL);
+ PyErr_Clear(); /* just to be sure */
+}
+
+bool SCA_PythonController::Compile()
+{
//printf("py script modified '%s'\n", m_scriptName.Ptr());
+ m_bModified= false;
// if a script already exists, decref it before replace the pointer to a new script
- if (m_bytecode)
- {
+ if (m_bytecode) {
Py_DECREF(m_bytecode);
m_bytecode=NULL;
}
+
// recompile the scripttext into bytecode
m_bytecode = Py_CompileString(m_scriptText.Ptr(), m_scriptName.Ptr(), Py_file_input);
- m_bModified=false;
- if (m_bytecode)
- {
-
+ if (m_bytecode) {
return true;
+ } else {
+ ErrorPrint("Python error compiling script");
+ return false;
}
- else {
- // didn't compile, so instead of compile, complain
- // something is wrong, tell the user what went wrong
- printf("Python compile error from controller \"%s\": \n", GetName().Ptr());
- //PyRun_SimpleString(m_scriptText.Ptr());
- PyErr_Print();
+}
+
+bool SCA_PythonController::Import()
+{
+ //printf("py module modified '%s'\n", m_scriptName.Ptr());
+ m_bModified= false;
+
+ /* incase we re-import */
+ Py_XDECREF(m_function);
+ m_function= NULL;
+
+ vector<STR_String> py_function_path = m_scriptText.Explode('.');
+
+ if(py_function_path.size() < 2) {
+ printf("Python module name formatting error \"%s\":\n\texpected \"SomeModule.Func\", got \"%s\"\n", GetName().Ptr(), m_scriptText.Ptr());
+ return false;
+ }
+
+ PyObject *mod = PyImport_ImportModule((char *)py_function_path[0].Ptr());
+ /* Dont reload yet, do this within the loop so packages reload too */
+
+ if(mod==NULL) {
+ ErrorPrint("Python module not found");
+ return false;
+ }
+ /* 'mod' will be DECREF'd as 'base'
+ * 'm_function' will be left holding a reference that the controller owns */
+
+ PyObject *base= mod;
+
+ for(unsigned int i=1; i < py_function_path.size(); i++) {
+ if(m_debug && PyModule_Check(base)) { /* base could be a class */
+ Py_DECREF(base); /* getting a new one so dont hold a ref to the old one */
+ base= PyImport_ReloadModule(base);
+ if (base==NULL) {
+ m_function= NULL;
+ break;
+ }
+ }
- /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
- * their user count. Not to mention holding references to wrapped data.
- * This is especially bad when the PyObject for the wrapped data is free'd, after blender
- * has alredy dealocated the pointer */
- PySys_SetObject( (char *)"last_traceback", NULL);
- PyErr_Clear(); /* just to be sure */
+ m_function = PyObject_GetAttrString(base, py_function_path[i].Ptr());
+ Py_DECREF(base);
+ base = m_function; /* for the next loop if there is on */
+ if(m_function==NULL) {
+ break;
+ }
+ }
+
+ if(m_function==NULL) {
+ if(PyErr_Occurred())
+ ErrorPrint("Python controller found the module but could not access the function");
+ else
+ printf("Python module error \"%s\":\n \"%s\" module found but function missing\n", GetName().Ptr(), m_scriptText.Ptr());
+ return false;
+ }
+
+ if(!PyCallable_Check(m_function)) {
+ Py_DECREF(m_function);
+ printf("Python module function error \"%s\":\n \"%s\" not callable\n", GetName().Ptr(), m_scriptText.Ptr());
+ return false;
+ }
+
+ m_function_argc = 0; /* rare cases this could be a function that isnt defined in python, assume zero args */
+ if (PyFunction_Check(m_function)) {
+ PyObject *py_arg_count = PyObject_GetAttrString(PyFunction_GET_CODE(m_function), "co_argcount");
+ if(py_arg_count) {
+ m_function_argc = PyLong_AsLong(py_arg_count);
+ Py_DECREF(py_arg_count);
+ }
+ else {
+ PyErr_Clear(); /* unlikely to fail but just incase */
+ }
+ }
+
+ if(m_function_argc > 1) {
+ Py_DECREF(m_function);
+ printf("Python module function has \"%s\":\n \"%s\" takes %d args, should be zero or 1 controller arg\n", GetName().Ptr(), m_scriptText.Ptr(), m_function_argc);
return false;
}
+
+ return true;
}
void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
@@ -309,16 +400,18 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
m_sCurrentController = this;
m_sCurrentLogicManager = logicmgr;
- if (m_bModified)
+ PyObject *excdict= NULL;
+ PyObject* resultobj= NULL;
+
+ switch(m_mode) {
+ case SCA_PYEXEC_SCRIPT:
{
- if (Compile()==false) // sets m_bModified to false
+ if (m_bModified)
+ if (Compile()==false) // sets m_bModified to false
+ return;
+ if (!m_bytecode)
return;
- }
- if (!m_bytecode) {
- return;
- }
-
/*
* This part here with excdict is a temporary patch
* to avoid python/gameengine crashes when python
@@ -337,10 +430,36 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
* should always ensure excdict is cleared).
*/
- PyObject *excdict= PyDict_Copy(m_pythondictionary);
- PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
- excdict, excdict);
-
+ excdict= PyDict_Copy(m_pythondictionary);
+ resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, excdict, excdict);
+ /* PyRun_SimpleString(m_scriptText.Ptr()); */
+ break;
+ }
+ case SCA_PYEXEC_MODULE:
+ {
+ if (m_bModified || m_debug)
+ if (Import()==false) // sets m_bModified to false
+ return;
+ if (!m_function)
+ return;
+
+ PyObject *args= NULL;
+
+ if(m_function_argc==1) {
+ args = PyTuple_New(1);
+ PyTuple_SET_ITEM(args, 0, GetProxy());
+ }
+
+ resultobj = PyObject_CallObject(m_function, args);
+ Py_XDECREF(args);
+ break;
+ }
+
+ } /* end switch */
+
+
+
+ /* Free the return value and print the error */
if (resultobj)
{
Py_DECREF(resultobj);
@@ -348,7 +467,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
else
{
// something is wrong, tell the user what went wrong
- printf("Python script error from controller \"%s\": \n", GetName().Ptr());
+ printf("Python script error from controller \"%s\":\n", GetName().Ptr());
PyErr_Print();
/* Added in 2.48a, the last_traceback can reference Objects for example, increasing
@@ -357,15 +476,17 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
* has alredy dealocated the pointer */
PySys_SetObject( (char *)"last_traceback", NULL);
PyErr_Clear(); /* just to be sure */
-
- //PyRun_SimpleString(m_scriptText.Ptr());
}
-
- // clear after PyErrPrint - seems it can be using
- // something in this dictionary and crash?
- PyDict_Clear(excdict);
- Py_DECREF(excdict);
- m_triggeredSensors.erase(m_triggeredSensors.begin(), m_triggeredSensors.end());
+
+ if(excdict) /* Only for SCA_PYEXEC_SCRIPT types */
+ {
+ /* clear after PyErrPrint - seems it can be using
+ * something in this dictionary and crash? */
+ PyDict_Clear(excdict);
+ Py_DECREF(excdict);
+ }
+
+ m_triggeredSensors.clear();
m_sCurrentController = NULL;
}
@@ -376,6 +497,10 @@ 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);
@@ -383,104 +508,32 @@ int SCA_PythonController::py_setattro(PyObject *attr, PyObject *value)
PyObject* SCA_PythonController::PyActivate(PyObject *value)
{
- SCA_IActuator* actu = LinkedActuatorFromPy(value);
- if(actu==NULL)
+ if(m_sCurrentController != this) {
+ PyErr_SetString(PyExc_SystemError, "Cannot add an actuator from a non-active controller");
return NULL;
+ }
- CValue* boolval = new CBoolValue(true);
- m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, boolval);
- boolval->Release();
- Py_RETURN_NONE;
-}
-
-PyObject* SCA_PythonController::PyDeActivate(PyObject *value)
-{
SCA_IActuator* actu = LinkedActuatorFromPy(value);
if(actu==NULL)
return NULL;
- CValue* boolval = new CBoolValue(false);
- m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, boolval);
- boolval->Release();
+ m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, true);
Py_RETURN_NONE;
}
-PyObject* SCA_PythonController::PyGetActuators()
-{
- PyObject* resultlist = PyList_New(m_linkedactuators.size());
- for (unsigned int index=0;index<m_linkedactuators.size();index++)
- {
- PyList_SET_ITEM(resultlist,index, m_linkedactuators[index]->GetProxy());
- }
-
- return resultlist;
-}
-
-const char SCA_PythonController::GetSensor_doc[] =
-"getSensor (char sensorname) return linked sensor that is named [sensorname]\n";
-PyObject*
-SCA_PythonController::PyGetSensor(PyObject* value)
+PyObject* SCA_PythonController::PyDeActivate(PyObject *value)
{
-
- char *scriptArg = PyString_AsString(value);
- if (scriptArg==NULL) {
- PyErr_SetString(PyExc_TypeError, "controller.getSensor(string): Python Controller, expected a string (sensor name)");
+ if(m_sCurrentController != this) {
+ PyErr_SetString(PyExc_SystemError, "Cannot add an actuator from a non-active controller");
return NULL;
}
- for (unsigned int index=0;index<m_linkedsensors.size();index++)
- {
- SCA_ISensor* sensor = m_linkedsensors[index];
- STR_String realname = sensor->GetName();
- if (realname == scriptArg)
- {
- return sensor->GetProxy();
- }
- }
-
- PyErr_Format(PyExc_AttributeError, "controller.getSensor(string): Python Controller, unable to find requested sensor \"%s\"", scriptArg);
- return NULL;
-}
-
-
-
-const char SCA_PythonController::GetActuator_doc[] =
-"getActuator (char sensorname) return linked actuator that is named [actuatorname]\n";
-PyObject*
-SCA_PythonController::PyGetActuator(PyObject* value)
-{
-
- char *scriptArg = PyString_AsString(value);
- if (scriptArg==NULL) {
- PyErr_SetString(PyExc_TypeError, "controller.getActuator(string): Python Controller, expected a string (actuator name)");
+ SCA_IActuator* actu = LinkedActuatorFromPy(value);
+ if(actu==NULL)
return NULL;
- }
- for (unsigned int index=0;index<m_linkedactuators.size();index++)
- {
- SCA_IActuator* actua = m_linkedactuators[index];
- if (actua->GetName() == scriptArg)
- {
- return actua->GetProxy();
- }
- }
-
- PyErr_Format(PyExc_AttributeError, "controller.getActuator(string): Python Controller, unable to find requested actuator \"%s\"", scriptArg);
- return NULL;
-}
-
-
-const char SCA_PythonController::GetSensors_doc[] = "getSensors returns a list of all attached sensors";
-PyObject*
-SCA_PythonController::PyGetSensors()
-{
- PyObject* resultlist = PyList_New(m_linkedsensors.size());
- for (unsigned int index=0;index<m_linkedsensors.size();index++)
- {
- PyList_SET_ITEM(resultlist,index, m_linkedsensors[index]->GetProxy());
- }
-
- return resultlist;
+ m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, false);
+ Py_RETURN_NONE;
}
/* 1. getScript */
@@ -510,19 +563,6 @@ PyObject* SCA_PythonController::PySetScript(PyObject* value)
Py_RETURN_NONE;
}
-/* 1. getScript */
-PyObject* SCA_PythonController::PyGetState()
-{
- ShowDeprecationWarning("getState()", "the state property");
- return PyInt_FromLong(m_statemask);
-}
-
-PyObject* SCA_PythonController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v);
- return PyInt_FromLong(self->m_statemask);
-}
-
PyObject* SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v);
@@ -537,14 +577,14 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D
if (scriptArg==NULL) {
PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text");
- return -1;
+ return PY_SET_ATTR_FAIL;
}
/* set scripttext sets m_bModified to true,
so next time the script is needed, a reparse into byte code is done */
self->SetScriptText(scriptArg);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h
index f10c4e47ebb..0c2af79c3a3 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.h
+++ b/source/gameengine/GameLogic/SCA_PythonController.h
@@ -42,23 +42,37 @@ class SCA_IObject;
class SCA_PythonController : public SCA_IController
{
Py_Header;
- struct _object * m_bytecode;
+ struct _object * m_bytecode; /* SCA_PYEXEC_SCRIPT only */
+ PyObject* m_function; /* SCA_PYEXEC_MODULE only */
+ int m_function_argc;
bool m_bModified;
+ bool m_debug; /* use with SCA_PYEXEC_MODULE for reloading every logic run */
+ int m_mode;
+
protected:
STR_String m_scriptText;
STR_String m_scriptName;
- PyObject* m_pythondictionary;
+ PyObject* m_pythondictionary; /* for SCA_PYEXEC_SCRIPT only */
+ PyObject* m_pythonfunction; /* for SCA_PYEXEC_MODULE only */
+
std::vector<class SCA_ISensor*> m_triggeredSensors;
+
+ public:
+ enum SCA_PyExecMode
+ {
+ SCA_PYEXEC_SCRIPT = 0,
+ SCA_PYEXEC_MODULE,
+ SCA_PYEXEC_MAX
+ };
- public:
static SCA_PythonController* m_sCurrentController; // protected !!!
//for debugging
//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,PyTypeObject* T = &Type);
+ SCA_PythonController(SCA_IObject* gameobj, int mode, PyTypeObject* T = &Type);
virtual ~SCA_PythonController();
virtual CValue* GetReplica();
@@ -67,10 +81,14 @@ class SCA_PythonController : public SCA_IController
void SetScriptText(const STR_String& text);
void SetScriptName(const STR_String& name);
void SetDictionary(PyObject* pythondictionary);
+ void SetDebug(bool debug) { m_debug = debug; }
void AddTriggeredSensor(class SCA_ISensor* sensor)
{ m_triggeredSensors.push_back(sensor); }
int IsTriggered(class SCA_ISensor* sensor);
bool Compile();
+ bool Import();
+ void ErrorPrint(const char *error_msg);
+
static const char* sPyGetCurrentController__doc__;
static PyObject* sPyGetCurrentController(PyObject* self);
@@ -78,21 +96,18 @@ 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);
KX_PYMETHOD_O(SCA_PythonController,DeActivate);
- KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetSensors);
- KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetActuators);
- KX_PYMETHOD_DOC_O(SCA_PythonController,GetSensor);
- KX_PYMETHOD_DOC_O(SCA_PythonController,GetActuator);
KX_PYMETHOD_O(SCA_PythonController,SetScript);
KX_PYMETHOD_NOARGS(SCA_PythonController,GetScript);
- KX_PYMETHOD_NOARGS(SCA_PythonController,GetState);
+
- static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index 3a72d9b7652..a722590dd10 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -58,7 +58,6 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
m_parameter2(para2),
m_distribution(mode)
{
- // m_base is never deleted, probably a memory leak!
m_base = new SCA_RandomNumberGenerator(seed);
m_counter = 0;
enforceConstraints();
@@ -68,7 +67,7 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
SCA_RandomActuator::~SCA_RandomActuator()
{
- /* intentionally empty */
+ m_base->Release();
}
@@ -78,11 +77,16 @@ CValue* SCA_RandomActuator::GetReplica()
SCA_RandomActuator* replica = new SCA_RandomActuator(*this);
// replication just copy the m_base pointer => common random generator
replica->ProcessReplica();
- CValue::AddDataToReplica(replica);
-
return replica;
}
+void SCA_RandomActuator::ProcessReplica()
+{
+ SCA_IActuator::ProcessReplica();
+ // increment reference count so that we can release the generator at the end
+ m_base->AddRef();
+}
+
bool SCA_RandomActuator::Update()
@@ -312,8 +316,13 @@ void SCA_RandomActuator::enforceConstraints() {
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_RandomActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_RandomActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -367,7 +376,7 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = {
KX_PYATTRIBUTE_FLOAT_RO("para1",SCA_RandomActuator,m_parameter1),
KX_PYATTRIBUTE_FLOAT_RO("para2",SCA_RandomActuator,m_parameter2),
KX_PYATTRIBUTE_ENUM_RO("distribution",SCA_RandomActuator,m_distribution),
- KX_PYATTRIBUTE_STRING_RW_CHECK("property",0,100,false,SCA_RandomActuator,m_propname,CheckProperty),
+ KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,100,false,SCA_RandomActuator,m_propname,CheckProperty),
KX_PYATTRIBUTE_RW_FUNCTION("seed",SCA_RandomActuator,pyattr_get_seed,pyattr_set_seed),
{ NULL } //Sentinel
};
@@ -384,10 +393,10 @@ int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_
if (PyInt_Check(value)) {
int ival = PyInt_AsLong(value);
act->m_base->SetSeed(ival);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
} else {
PyErr_SetString(PyExc_TypeError, "actuator.seed = int: Random Actuator, expected an integer");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
}
@@ -395,6 +404,10 @@ 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);
@@ -470,7 +483,7 @@ const char SCA_RandomActuator::SetProperty_doc[] =
"\tSet the property to which the random value is assigned. If the \n"
"\tgenerator and property types do not match, the assignment is ignored.\n";
PyObject* SCA_RandomActuator::PySetProperty(PyObject* args) {
- ShowDeprecationWarning("setProperty()", "the 'property' property");
+ ShowDeprecationWarning("setProperty()", "the 'propName' property");
char *nameArg;
if (!PyArg_ParseTuple(args, "s:setProperty", &nameArg)) {
return NULL;
@@ -494,7 +507,7 @@ const char SCA_RandomActuator::GetProperty_doc[] =
"\tgenerator and property types do not match, the assignment is ignored.\n";
PyObject* SCA_RandomActuator::PyGetProperty()
{
- ShowDeprecationWarning("getProperty()", "the 'property' property");
+ ShowDeprecationWarning("getProperty()", "the 'propName' property");
return PyString_FromString(m_propname);
}
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h
index 8f58ed0dcec..59863589b60 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.h
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.h
@@ -91,12 +91,14 @@ class SCA_RandomActuator : public SCA_IActuator
virtual bool Update();
virtual CValue* GetReplica();
+ virtual void ProcessReplica();
/* --------------------------------------------------------------------- */
/* 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);
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
index 156478d866d..976597aa812 100644
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
@@ -50,9 +50,10 @@ SCA_RandomEventManager::SCA_RandomEventManager(class SCA_LogicManager* logicmgr)
void SCA_RandomEventManager::NextFrame()
{
- for (set<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- (*i)->Activate(m_logicmgr, NULL);
+ (*it)->Activate(m_logicmgr);
}
}
diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp
index 06b5cca6ce9..0267cc8ebbf 100644
--- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp
@@ -59,6 +59,7 @@
SCA_RandomNumberGenerator::SCA_RandomNumberGenerator(long seed) {
// int mti = N + 1; /*unused*/
m_seed = seed;
+ m_refcount = 1;
SetStartVector();
}
diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h
index b9311d31af6..842a0331752 100644
--- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h
+++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h
@@ -36,6 +36,9 @@
class SCA_RandomNumberGenerator {
+ /* reference counted for memleak */
+ int m_refcount;
+
/** base seed */
long m_seed;
@@ -56,6 +59,16 @@ class SCA_RandomNumberGenerator {
float DrawFloat();
long GetSeed();
void SetSeed(long newseed);
+ SCA_RandomNumberGenerator* AddRef()
+ {
+ ++m_refcount;
+ return this;
+ }
+ void Release()
+ {
+ if (--m_refcount == 0)
+ delete this;
+ }
};
#endif /* __KX_RANDOMNUMBERGENERATOR */
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index 5ead82db428..d5cbeef01ae 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -50,7 +50,6 @@ SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr,
PyTypeObject* T)
: SCA_ISensor(gameobj,eventmgr, T)
{
- // m_basegenerator is never deleted => memory leak
m_basegenerator = new SCA_RandomNumberGenerator(startseed);
Init();
}
@@ -59,7 +58,7 @@ SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr,
SCA_RandomSensor::~SCA_RandomSensor()
{
- /* Nothing to be done here. */
+ m_basegenerator->Release();
}
void SCA_RandomSensor::Init()
@@ -74,13 +73,18 @@ void SCA_RandomSensor::Init()
CValue* SCA_RandomSensor::GetReplica()
{
CValue* replica = new SCA_RandomSensor(*this);
- // replication copies m_basegenerator pointer => share same generator
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
+void SCA_RandomSensor::ProcessReplica()
+{
+ SCA_ISensor::ProcessReplica();
+ // increment reference count so that we can release the generator at this end
+ m_basegenerator->AddRef();
+}
bool SCA_RandomSensor::IsPositiveTrigger()
@@ -89,7 +93,7 @@ bool SCA_RandomSensor::IsPositiveTrigger()
}
-bool SCA_RandomSensor::Evaluate(CValue* event)
+bool SCA_RandomSensor::Evaluate()
{
/* Random generator is the generator from Line 25 of Table 1 in */
/* [KNUTH 1981, The Art of Computer Programming Vol. 2 */
@@ -127,8 +131,13 @@ bool SCA_RandomSensor::Evaluate(CValue* event)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_RandomSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_RandomSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -154,9 +163,11 @@ PyParentObject SCA_RandomSensor::Parents[] = {
};
PyMethodDef SCA_RandomSensor::Methods[] = {
+ //Deprecated functions ----->
{"setSeed", (PyCFunction) SCA_RandomSensor::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc},
{"getSeed", (PyCFunction) SCA_RandomSensor::sPyGetSeed, METH_NOARGS, (PY_METHODCHAR)GetSeed_doc},
{"getLastDraw", (PyCFunction) SCA_RandomSensor::sPyGetLastDraw, METH_NOARGS, (PY_METHODCHAR)GetLastDraw_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
@@ -170,6 +181,10 @@ 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);
@@ -225,10 +240,10 @@ int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *at
SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v);
if (!PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError, "sensor.seed = int: Random Sensor, expected an integer");
- return -1;
+ return PY_SET_ATTR_FAIL;
}
self->m_basegenerator->SetSeed(PyInt_AsLong(value));
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h
index 764692600c3..b2bf2440966 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.h
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.h
@@ -52,7 +52,8 @@ public:
PyTypeObject* T=&Type);
virtual ~SCA_RandomSensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual void ProcessReplica();
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
@@ -61,6 +62,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
/* 1. setSeed */
diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
index b7fadd3d62c..911ea772bef 100644
--- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
@@ -52,7 +52,7 @@ SCA_TimeEventManager::SCA_TimeEventManager(SCA_LogicManager* logicmgr)
SCA_TimeEventManager::~SCA_TimeEventManager()
{
for (vector<CValue*>::iterator it = m_timevalues.begin();
- !(it == m_timevalues.end()); it++)
+ !(it == m_timevalues.end()); ++it)
{
(*it)->Release();
}
@@ -80,7 +80,7 @@ void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime)
// update sensors, but ... need deltatime !
for (vector<CValue*>::iterator it = m_timevalues.begin();
- !(it == m_timevalues.end()); it++)
+ !(it == m_timevalues.end()); ++it)
{
float newtime = (*it)->GetNumber() + fixedtime;
floatval->SetFloat(newtime);
@@ -104,7 +104,7 @@ void SCA_TimeEventManager::AddTimeProperty(CValue* timeval)
void SCA_TimeEventManager::RemoveTimeProperty(CValue* timeval)
{
for (vector<CValue*>::iterator it = m_timevalues.begin();
- !(it == m_timevalues.end()); it++)
+ !(it == m_timevalues.end()); ++it)
{
if ((*it) == timeval)
{
diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp
index e9bb37ee958..aee8e26c21a 100644
--- a/source/gameengine/GameLogic/SCA_XNORController.cpp
+++ b/source/gameengine/GameLogic/SCA_XNORController.cpp
@@ -66,7 +66,7 @@ void SCA_XNORController::Trigger(SCA_LogicManager* logicmgr)
!(is==m_linkedsensors.end());is++)
{
SCA_ISensor* sensor = *is;
- if (sensor->IsPositiveTrigger())
+ if (sensor->GetState())
{
if (sensorresult == false)
{
@@ -77,19 +77,12 @@ void SCA_XNORController::Trigger(SCA_LogicManager* logicmgr)
}
}
- CValue* newevent = new CBoolValue(sensorresult);
-
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
!(i==m_linkedactuators.end());i++)
{
- SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
- logicmgr->AddActiveActuator(actua,newevent);
+ SCA_IActuator* actua = *i;
+ logicmgr->AddActiveActuator(actua,sensorresult);
}
-
- // every actuator that needs the event, has a it's own reference to it now so
- // release it (so to be clear: if there is no actuator, it's deleted right now)
- newevent->Release();
-
}
@@ -98,7 +91,7 @@ CValue* SCA_XNORController::GetReplica()
{
CValue* replica = new SCA_XNORController(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -111,8 +104,13 @@ CValue* SCA_XNORController::GetReplica()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_XNORController::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_XNORController",
sizeof(PyObjectPlus_Proxy),
0,
@@ -149,4 +147,8 @@ 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 c992d5f1834..4aad5763cb0 100644
--- a/source/gameengine/GameLogic/SCA_XNORController.h
+++ b/source/gameengine/GameLogic/SCA_XNORController.h
@@ -49,6 +49,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
};
diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp
index 791a139975f..5afb3a750f5 100644
--- a/source/gameengine/GameLogic/SCA_XORController.cpp
+++ b/source/gameengine/GameLogic/SCA_XORController.cpp
@@ -66,7 +66,7 @@ void SCA_XORController::Trigger(SCA_LogicManager* logicmgr)
!(is==m_linkedsensors.end());is++)
{
SCA_ISensor* sensor = *is;
- if (sensor->IsPositiveTrigger())
+ if (sensor->GetState())
{
if (sensorresult == true)
{
@@ -77,19 +77,12 @@ void SCA_XORController::Trigger(SCA_LogicManager* logicmgr)
}
}
- CValue* newevent = new CBoolValue(sensorresult);
-
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
!(i==m_linkedactuators.end());i++)
{
- SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
- logicmgr->AddActiveActuator(actua,newevent);
+ SCA_IActuator* actua = *i;
+ logicmgr->AddActiveActuator(actua,sensorresult);
}
-
- // every actuator that needs the event, has a it's own reference to it now so
- // release it (so to be clear: if there is no actuator, it's deleted right now)
- newevent->Release();
-
}
@@ -98,7 +91,7 @@ CValue* SCA_XORController::GetReplica()
{
CValue* replica = new SCA_XORController(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -111,8 +104,13 @@ CValue* SCA_XORController::GetReplica()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_XORController::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"SCA_XORController",
sizeof(PyObjectPlus_Proxy),
0,
@@ -149,4 +147,8 @@ 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 065b31fd901..feb9f2ed07c 100644
--- a/source/gameengine/GameLogic/SCA_XORController.h
+++ b/source/gameengine/GameLogic/SCA_XORController.h
@@ -49,6 +49,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
};
diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript
index 88e5f7e87cc..91843eef586 100644
--- a/source/gameengine/GameLogic/SConscript
+++ b/source/gameengine/GameLogic/SConscript
@@ -5,7 +5,7 @@ sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp')
incs = '. #/source/kernel/gen_system #/intern/string'
incs += ' #/source/gameengine/Expressions #/intern/moto/include'
-incs += ' #/source/gameengine/Rasterizer'
+incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph'
incs += ' ' + env['BF_PYTHON_INC']
diff --git a/source/gameengine/GamePlayer/CMakeLists.txt b/source/gameengine/GamePlayer/CMakeLists.txt
index fc5912155cf..134f8fce3b2 100644
--- a/source/gameengine/GamePlayer/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/CMakeLists.txt
@@ -24,8 +24,9 @@
#
# ***** END GPL LICENSE BLOCK *****
-SUBDIRS(common ghost)
+ADD_SUBDIRECTORY(common)
+ADD_SUBDIRECTORY(ghost)
IF(WITH_WEBPLUGIN)
- SUBDIRS(xembed)
+ ADD_SUBDIRECTORY(xembed)
ENDIF(WITH_WEBPLUGIN)
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
index de30bbfcf3a..c5c9dcc6c0f 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
@@ -74,8 +74,8 @@ void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty)
{
m_clientobject = NULL;
m_lastlightlayer = -1;
- m_lastlighting = false;
m_lastauxinfo = NULL;
+ m_lastlighting = true; /* force disable in DisableOpenGLLights() */
DisableOpenGLLights();
}
@@ -286,10 +286,7 @@ void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
int height)
{
STR_String tmpstr(text);
- int lines;
char* s = tmpstr.Ptr();
- char* p;
-
// Save and change OpenGL settings
int texture2D;
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index 109ed3790ff..bdee8a78cfe 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -693,6 +693,7 @@ bool GPG_Application::startEngine(void)
initGameKeys();
initPythonConstraintBinding();
initMathutils();
+ initGeometry();
initBGL();
#ifdef WITH_FFMPEG
initVideoTexture();
@@ -700,7 +701,7 @@ bool GPG_Application::startEngine(void)
//initialize Dome Settings
if(m_startScene->r.stereomode == RAS_IRasterizer::RAS_STEREO_DOME)
- m_ketsjiengine->InitDome(m_startScene->r.domesize, m_startScene->r.domeres, m_startScene->r.domemode, m_startScene->r.domeangle, m_startScene->r.domeresbuf, m_startScene->r.dometext);
+ 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);
// Set the GameLogic.globalDict from marshal'd data, so we can
// load new blend files and keep data in GameLogic.globalDict
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 97b21d13e90..b69188e5476 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -703,10 +703,10 @@ int main(int argc, char** argv)
BLI_strncpy(pathname, maggie->name, sizeof(pathname));
BLI_strncpy(G.sce, maggie->name, sizeof(G.sce));
+ setGamePythonPath(G.sce);
if (firstTimeRunning)
{
- setGamePythonPath(G.sce);
firstTimeRunning = false;
if (fullScreen)
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp
index 3df483b0598..a0a61d01bb2 100644
--- a/source/gameengine/Ketsji/BL_BlenderShader.cpp
+++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp
@@ -20,41 +20,33 @@ BL_BlenderShader::BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lig
:
mScene(scene),
mMat(ma),
- mLightLayer(lightlayer)
+ mLightLayer(lightlayer),
+ mGPUMat(NULL)
{
mBlenderScene = scene->GetBlenderScene();
mBlendMode = GPU_BLEND_SOLID;
- if(mMat)
- GPU_material_from_blender(mBlenderScene, mMat);
+ ReloadMaterial();
}
BL_BlenderShader::~BL_BlenderShader()
{
- if(mMat && GPU_material_from_blender(mBlenderScene, mMat))
- GPU_material_unbind(GPU_material_from_blender(mBlenderScene, mMat));
+ if(mGPUMat)
+ GPU_material_unbind(mGPUMat);
}
-bool BL_BlenderShader::Ok()
+void BL_BlenderShader::ReloadMaterial()
{
- return VerifyShader();
-}
-
-bool BL_BlenderShader::VerifyShader()
-{
- if(mMat)
- return (GPU_material_from_blender(mBlenderScene, mMat) != 0);
- else
- return false;
+ mGPUMat = (mMat) ? GPU_material_from_blender(mBlenderScene, mMat) : NULL;
}
void BL_BlenderShader::SetProg(bool enable, double time)
{
if(VerifyShader()) {
if(enable)
- GPU_material_bind(GPU_material_from_blender(mBlenderScene, mMat), mLightLayer, mBlenderScene->lay, time);
+ GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time);
else
- GPU_material_unbind(GPU_material_from_blender(mBlenderScene, mMat));
+ GPU_material_unbind(mGPUMat);
}
}
@@ -66,7 +58,7 @@ int BL_BlenderShader::GetAttribNum()
if(!VerifyShader())
return enabled;
- GPU_material_vertex_attributes(GPU_material_from_blender(mBlenderScene, mMat), &attribs);
+ GPU_material_vertex_attributes(mGPUMat, &attribs);
for(i = 0; i < attribs.totlayer; i++)
if(attribs.layer[i].glindex+1 > enabled)
@@ -89,7 +81,7 @@ void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat)
if(!VerifyShader())
return;
- gpumat = GPU_material_from_blender(mBlenderScene, mMat);
+ gpumat = mGPUMat;
if(ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) {
GPU_material_vertex_attributes(gpumat, &attribs);
@@ -131,7 +123,7 @@ void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty )
float obmat[4][4], viewmat[4][4], viewinvmat[4][4], obcol[4];
GPUMaterial *gpumat;
- gpumat = GPU_material_from_blender(mBlenderScene, mMat);
+ gpumat = mGPUMat;
if(!gpumat || !GPU_material_bound(gpumat))
return;
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h
index 5c1f59f94ad..9af53bfc863 100644
--- a/source/gameengine/Ketsji/BL_BlenderShader.h
+++ b/source/gameengine/Ketsji/BL_BlenderShader.h
@@ -32,19 +32,28 @@ private:
struct Material *mMat;
int mLightLayer;
int mBlendMode;
+ GPUMaterial *mGPUMat;
- bool VerifyShader();
+ bool VerifyShader()
+ {
+ return (NULL != mGPUMat);
+ }
public:
BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer);
virtual ~BL_BlenderShader();
- bool Ok();
+ bool Ok()
+ {
+ // same as VerifyShared
+ return (NULL != mGPUMat);
+ }
void SetProg(bool enable, double time=0.0);
int GetAttribNum();
void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat);
void Update(const class RAS_MeshSlot & ms, class RAS_IRasterizer* rasty);
+ void ReloadMaterial();
int GetBlendMode();
bool Equals(BL_BlenderShader *blshader);
diff --git a/source/gameengine/Ketsji/BL_Material.cpp b/source/gameengine/Ketsji/BL_Material.cpp
index 7e3d6984f19..c63b9d55306 100644
--- a/source/gameengine/Ketsji/BL_Material.cpp
+++ b/source/gameengine/Ketsji/BL_Material.cpp
@@ -28,6 +28,11 @@ int getNumTexChannels( Material *mat )
BL_Material::BL_Material()
{
+ Initialize();
+}
+
+void BL_Material::Initialize()
+{
rgb[0] = 0;
rgb[1] = 0;
rgb[2] = 0;
@@ -52,7 +57,7 @@ BL_Material::BL_Material()
mode = 0;
material = 0;
tface = 0;
- material_index = 0;
+ materialindex = 0;
amb=0.5f;
num_enabled = 0;
num_users = 1;
diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h
index 0eaa234566c..4f572f95891 100644
--- a/source/gameengine/Ketsji/BL_Material.h
+++ b/source/gameengine/Ketsji/BL_Material.h
@@ -44,6 +44,7 @@ private:
public:
// -----------------------------------
BL_Material();
+ void Initialize();
int IdMode;
unsigned int ras_mode;
@@ -54,6 +55,7 @@ public:
int tile,tilexrep[MAXTEX],tileyrep[MAXTEX];
STR_String matname;
STR_String mtexname[MAXTEX];
+ int materialindex;
float matcolor[4];
float speccolor[3];
@@ -68,8 +70,6 @@ public:
int mode;
int num_enabled;
- int material_index;
-
BL_Mapping mapping[MAXTEX];
STR_String imageId[MAXTEX];
diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp
index 88d920043e0..c5c517c8a65 100644
--- a/source/gameengine/Ketsji/BL_Shader.cpp
+++ b/source/gameengine/Ketsji/BL_Shader.cpp
@@ -734,6 +734,10 @@ 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[] =
{
@@ -772,8 +776,13 @@ PyAttributeDef BL_Shader::Attributes[] = {
};
PyTypeObject BL_Shader::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"BL_Shader",
sizeof(PyObjectPlus_Proxy),
0,
diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h
index 08cad5071fd..7db40e778ae 100644
--- a/source/gameengine/Ketsji/BL_Shader.h
+++ b/source/gameengine/Ketsji/BL_Shader.h
@@ -203,6 +203,7 @@ public:
// 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); }
// -----------------------------------
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index ca9ce4dc50c..4aaa49a8493 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -30,11 +30,10 @@ 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/gen_utils.c
# ../../../source/blender/python/api2_2x/matrix.c
-# ../../../source/blender/python/api2_2x/point.c
# ../../../source/blender/python/api2_2x/quat.c
# ../../../source/blender/python/api2_2x/vector.c
# ../../../source/blender/python/api2_2x/bpy_internal_import.c
diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
index fa0ca378c6b..d9a9fc54f4b 100644
--- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
+++ b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
@@ -30,9 +30,11 @@ SET(INC
.
../../../../source/kernel/gen_system
../../../../intern/string
+ ../../../../intern/moto/include
../../../../source/gameengine/Ketsji
../../../../source/gameengine/GameLogic
../../../../source/gameengine/Expressions
+ ../../../../source/gameengine/SceneGraph
../../../../source/gameengine/Network
${PYTHON_INC}
)
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
index eee8e9f6827..738f64713b0 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
@@ -61,12 +61,12 @@ void KX_NetworkEventManager::NextFrame()
// each frame, the logicmanager will call the network
// eventmanager to look for network events, and process it's
// 'network' sensors
- set<class SCA_ISensor*>::iterator it;
-
- for (it = m_sensors.begin(); !(it==m_sensors.end()); it++) {
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
+ {
// printf("KX_NetworkEventManager::proceed sensor %.2f\n", curtime);
// process queue
- (*it)->Activate(m_logicmgr, NULL);
+ (*it)->Activate(m_logicmgr);
}
// now a list of triggerer sensors has been built
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
index 2483a6bfb39..63773352d96 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
@@ -75,7 +75,7 @@ bool KX_NetworkMessageActuator::Update()
m_toPropName,
GetParent()->GetName(),
m_subject,
- GetParent()->GetPropertyText(m_body,""));
+ GetParent()->GetPropertyText(m_body));
} else
{
m_networkscene->SendMessage(
@@ -93,9 +93,6 @@ CValue* KX_NetworkMessageActuator::GetReplica()
new KX_NetworkMessageActuator(*this);
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
return replica;
}
@@ -105,8 +102,13 @@ CValue* KX_NetworkMessageActuator::GetReplica()
/* Integration hooks -------------------------------------------------- */
PyTypeObject KX_NetworkMessageActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_NetworkMessageActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -157,6 +159,10 @@ 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);
}
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
index 850f825b8f3..cf92fd46fe0 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
@@ -62,6 +62,7 @@ public:
/* ------------------------------------------------------------ */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
// Deprecated ----->
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
index 7782567943e..8ddcd87b66f 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
@@ -79,15 +79,13 @@ CValue* KX_NetworkMessageSensor::GetReplica() {
CValue* replica = new KX_NetworkMessageSensor(*this);
if (replica == NULL) return NULL;
-
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
// Return true only for flank (UP and DOWN)
-bool KX_NetworkMessageSensor::Evaluate(CValue* event)
+bool KX_NetworkMessageSensor::Evaluate()
{
bool result = false;
bool WasUp = m_IsUp;
@@ -104,8 +102,8 @@ bool KX_NetworkMessageSensor::Evaluate(CValue* event)
m_SubjectList = NULL;
}
- STR_String toname=GetParent()->GetName();
- STR_String subject = this->m_subject;
+ STR_String& toname=GetParent()->GetName();
+ STR_String& subject = this->m_subject;
vector<NG_NetworkMessage*> messages =
m_NetworkScene->FindMessages(toname,"",subject,true);
@@ -125,9 +123,9 @@ bool KX_NetworkMessageSensor::Evaluate(CValue* event)
for (mesit=messages.begin();mesit!=messages.end();mesit++)
{
// save the body
- STR_String body = (*mesit)->GetMessageText();
+ const STR_String& body = (*mesit)->GetMessageText();
// save the subject
- STR_String messub = (*mesit)->GetSubject();
+ const STR_String& messub = (*mesit)->GetSubject();
#ifdef NAN_NET_DEBUG
if (body) {
cout << "body [" << body << "]\n";
@@ -168,8 +166,13 @@ bool KX_NetworkMessageSensor::IsPositiveTrigger()
/* Integration hooks --------------------------------------------------- */
PyTypeObject KX_NetworkMessageSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_NetworkMessageSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -227,6 +230,10 @@ 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);
}
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
index ac0e880d25c..53183f33826 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
@@ -63,7 +63,7 @@ public:
virtual ~KX_NetworkMessageSensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
void EndFrame();
@@ -73,6 +73,7 @@ public:
/* ------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
// Deprecated ----->
diff --git a/source/gameengine/Ketsji/KXNetwork/Makefile b/source/gameengine/Ketsji/KXNetwork/Makefile
index ddcb03600d5..365ed8fc9c3 100644
--- a/source/gameengine/Ketsji/KXNetwork/Makefile
+++ b/source/gameengine/Ketsji/KXNetwork/Makefile
@@ -38,8 +38,10 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I$(NAN_STRING)/include
+CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../Expressions
CPPFLAGS += -I../../GameLogic
+CPPFLAGS += -I../../SceneGraph
CPPFLAGS += -I../../Network
CPPFLAGS += -I../../../kernel/gen_system
CPPFLAGS += -I..
diff --git a/source/gameengine/Ketsji/KXNetwork/SConscript b/source/gameengine/Ketsji/KXNetwork/SConscript
index b417edf6413..f350b2ce25a 100644
--- a/source/gameengine/Ketsji/KXNetwork/SConscript
+++ b/source/gameengine/Ketsji/KXNetwork/SConscript
@@ -3,9 +3,9 @@ Import ('env')
sources = env.Glob('*.cpp')
-incs = '. #source/kernel/gen_system #intern/string #source/gameengine/Ketsji'
+incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Ketsji'
incs += ' #source/gameengine/GameLogic #source/gameengine/Expressions'
-incs += ' #source/gameengine/Network'
+incs += ' #source/gameengine/Network #source/gameengine/SceneGraph'
incs += ' ' + env['BF_PYTHON_INC']
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
index 849332008ce..30057fc039d 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
@@ -43,35 +43,48 @@ BL_BlenderShader *KX_BlenderMaterial::mLastBlenderShader = NULL;
//static PyObject *gTextureDict = 0;
KX_BlenderMaterial::KX_BlenderMaterial(
- KX_Scene *scene,
- BL_Material *data,
- bool skin,
- int lightlayer,
PyTypeObject *T
)
: PyObjectPlus(T),
- RAS_IPolyMaterial(
- STR_String( data->texname[0] ),
- STR_String( data->matname ), // needed for physics!
- data->tile,
- data->tilexrep[0],
- data->tileyrep[0],
- data->mode,
- data->transp,
- ((data->ras_mode &ALPHA)!=0),
- ((data->ras_mode &ZSORT)!=0),
- lightlayer
- ),
- mMaterial(data),
+ RAS_IPolyMaterial(),
+ mMaterial(NULL),
mShader(0),
mBlenderShader(0),
- mScene(scene),
+ mScene(NULL),
mUserDefBlend(0),
mModified(0),
mConstructed(false),
mPass(0)
+{
+}
+void KX_BlenderMaterial::Initialize(
+ KX_Scene *scene,
+ BL_Material *data,
+ bool skin,
+ int lightlayer)
{
+ RAS_IPolyMaterial::Initialize(
+ data->texname[0],
+ data->matname,
+ data->materialindex,
+ data->tile,
+ data->tilexrep[0],
+ data->tileyrep[0],
+ data->mode,
+ data->transp,
+ ((data->ras_mode &ALPHA)!=0),
+ ((data->ras_mode &ZSORT)!=0),
+ lightlayer
+ );
+ mMaterial = data;
+ mShader = 0;
+ mBlenderShader = 0;
+ mScene = scene;
+ mUserDefBlend = 0;
+ mModified = 0;
+ mConstructed = false;
+ mPass = 0;
// --------------------------------
// RAS_IPolyMaterial variables...
m_flag |= RAS_BLENDERMAT;
@@ -95,7 +108,6 @@ KX_BlenderMaterial::KX_BlenderMaterial(
);
}
m_multimode += mMaterial->IdMode+ (mMaterial->ras_mode & ~(COLLIDER|USE_LIGHT));
-
}
KX_BlenderMaterial::~KX_BlenderMaterial()
@@ -106,7 +118,6 @@ KX_BlenderMaterial::~KX_BlenderMaterial()
OnExit();
}
-
MTFace* KX_BlenderMaterial::GetMTFace(void) const
{
// fonts on polys
@@ -120,14 +131,41 @@ unsigned int* KX_BlenderMaterial::GetMCol(void) const
return mMaterial->rgb;
}
-void KX_BlenderMaterial::OnConstruction()
+void KX_BlenderMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
+{
+ if (mMaterial) {
+ *rgba++ = (unsigned char) (mMaterial->matcolor[0]*255.0);
+ *rgba++ = (unsigned char) (mMaterial->matcolor[1]*255.0);
+ *rgba++ = (unsigned char) (mMaterial->matcolor[2]*255.0);
+ *rgba++ = (unsigned char) (mMaterial->matcolor[3]*255.0);
+ } else
+ RAS_IPolyMaterial::GetMaterialRGBAColor(rgba);
+}
+
+Material *KX_BlenderMaterial::GetBlenderMaterial() const
+{
+ return mMaterial->material;
+}
+
+Scene* KX_BlenderMaterial::GetBlenderScene() const
+{
+ return mScene->GetBlenderScene();
+}
+
+void KX_BlenderMaterial::ReleaseMaterial()
+{
+ if (mBlenderShader)
+ mBlenderShader->ReloadMaterial();
+}
+
+void KX_BlenderMaterial::OnConstruction(int layer)
{
if (mConstructed)
// when material are reused between objects
return;
if(mMaterial->glslmat)
- SetBlenderGLSLShader();
+ SetBlenderGLSLShader(layer);
// for each unique material...
int i;
@@ -377,10 +415,12 @@ KX_BlenderMaterial::ActivatShaders(
}
else
rasty->SetLines(false);
+ ActivatGLMaterials(rasty);
+ ActivateTexGen(rasty);
}
- ActivatGLMaterials(rasty);
- ActivateTexGen(rasty);
+ //ActivatGLMaterials(rasty);
+ //ActivateTexGen(rasty);
}
void
@@ -469,10 +509,12 @@ KX_BlenderMaterial::ActivateMat(
}
else
rasty->SetLines(false);
+ ActivatGLMaterials(rasty);
+ ActivateTexGen(rasty);
}
- ActivatGLMaterials(rasty);
- ActivateTexGen(rasty);
+ //ActivatGLMaterials(rasty);
+ //ActivateTexGen(rasty);
}
bool
@@ -601,8 +643,7 @@ void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const
if (mode &USECUSTOMUV)
{
- STR_String str = mMaterial->mapping[i].uvCoName;
- if (!str.IsEmpty())
+ if (!mMaterial->mapping[i].uvCoName.IsEmpty())
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV2, i);
continue;
}
@@ -749,12 +790,20 @@ PyMethodDef KX_BlenderMaterial::Methods[] =
};
PyAttributeDef KX_BlenderMaterial::Attributes[] = {
+ //KX_PYATTRIBUTE_TODO("shader"),
+ //KX_PYATTRIBUTE_TODO("materialIndex"),
+ //KX_PYATTRIBUTE_TODO("blending"),
{ NULL } //Sentinel
};
PyTypeObject KX_BlenderMaterial::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_BlenderMaterial",
sizeof(PyObjectPlus_Proxy),
0,
@@ -784,6 +833,10 @@ 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);
@@ -846,10 +899,10 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
}
-void KX_BlenderMaterial::SetBlenderGLSLShader(void)
+void KX_BlenderMaterial::SetBlenderGLSLShader(int layer)
{
if(!mBlenderShader)
- mBlenderShader = new BL_BlenderShader(mScene, mMaterial->material, m_lightlayer);
+ mBlenderShader = new BL_BlenderShader(mScene, mMaterial->material, layer);
if(!mBlenderShader->Ok()) {
delete mBlenderShader;
@@ -859,7 +912,7 @@ void KX_BlenderMaterial::SetBlenderGLSLShader(void)
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()")
{
- return PyInt_FromLong( mMaterial->material_index );
+ return PyInt_FromLong( 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 48d4730ab07..b29f2df98db 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.h
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h
@@ -24,11 +24,13 @@ class KX_BlenderMaterial : public PyObjectPlus, public RAS_IPolyMaterial
public:
// --------------------------------
KX_BlenderMaterial(
+ PyTypeObject* T=&Type
+ );
+ void Initialize(
class KX_Scene* scene,
BL_Material* mat,
bool skin,
- int lightlayer,
- PyTypeObject* T=&Type
+ int lightlayer
);
virtual ~KX_BlenderMaterial();
@@ -73,7 +75,6 @@ public:
Image * getImage (unsigned int idx) {
return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : NULL;
}
-
// for ipos
void UpdateIPO(
MT_Vector4 rgba, MT_Vector3 specrgb,
@@ -83,6 +84,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()); }
@@ -95,7 +97,7 @@ public:
// --------------------------------
// pre calculate to avoid pops/lag at startup
- virtual void OnConstruction( );
+ virtual void OnConstruction(int layer);
static void EndFrame();
@@ -110,12 +112,16 @@ private:
bool mModified;
bool mConstructed; // if false, don't clean on exit
- void SetBlenderGLSLShader();
+ void SetBlenderGLSLShader(int layer);
void ActivatGLMaterials( RAS_IRasterizer* rasty )const;
void ActivateTexGen( RAS_IRasterizer *ras ) const;
bool UsesLighting(RAS_IRasterizer *rasty) const;
+ void GetMaterialRGBAColor(unsigned char *rgba) const;
+ Material* GetBlenderMaterial() const;
+ Scene* GetBlenderScene() const;
+ void ReleaseMaterial();
// message centers
void setTexData( bool enable,RAS_IRasterizer *ras);
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
index 831f9241fec..748b0667061 100644
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
@@ -17,13 +17,17 @@
#include "BulletSoftBody/btSoftBody.h"
-KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool compound)
-: KX_IPhysicsController(dyna,compound,(PHY_IPhysicsController*)this),
+KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool compound)
+: KX_IPhysicsController(dyna,sensor,compound,(PHY_IPhysicsController*)this),
CcdPhysicsController(ci),
m_savedCollisionFlags(0),
+m_savedCollisionFilterGroup(0),
+m_savedCollisionFilterMask(0),
+m_savedMass(0.0),
+m_savedDyna(false),
+m_suspended(false),
m_bulletChildShape(NULL)
{
-
}
KX_BulletPhysicsController::~KX_BulletPhysicsController ()
@@ -88,7 +92,13 @@ void KX_BulletPhysicsController::SetObject (SG_IObject* object)
gameobj->SetPhysicsController(this,gameobj->IsDynamic());
CcdPhysicsController::setNewClientInfo(gameobj->getClientInfo());
-
+ if (m_bSensor)
+ {
+ // use a different callback function for sensor object,
+ // bullet will not synchronize, we must do it explicitely
+ SG_Callbacks& callbacks = gameobj->GetSGNode()->GetCallBackFunctions();
+ callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc;
+ }
}
MT_Scalar KX_BulletPhysicsController::GetRadius()
@@ -170,6 +180,20 @@ void KX_BulletPhysicsController::setScaling(const MT_Vector3& scaling)
{
CcdPhysicsController::setScaling(scaling.x(),scaling.y(),scaling.z());
}
+void KX_BulletPhysicsController::SetTransform()
+{
+ btVector3 pos;
+ btVector3 scale;
+ float ori[12];
+ m_MotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+ m_MotionState->getWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]);
+ m_MotionState->getWorldOrientation(ori);
+ btMatrix3x3 rot(ori[0], ori[4], ori[8],
+ ori[1], ori[5], ori[9],
+ ori[2], ori[6], ori[10]);
+ CcdPhysicsController::forceWorldTransform(rot, pos);
+}
+
MT_Scalar KX_BulletPhysicsController::GetMass()
{
if (GetSoftBody())
@@ -258,7 +282,7 @@ void KX_BulletPhysicsController::AddCompoundChild(KX_IPhysicsController* chil
// add to parent compound shapeinfo
GetShapeInfo()->AddShape(proxyShapeInfo);
// create new bullet collision shape from the object shapeinfo and set scaling
- btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape();
+ btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape(childCtrl->GetMargin());
newChildShape->setLocalScaling(relativeScale);
// add bullet collision shape to parent compound collision shape
compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape);
@@ -337,8 +361,7 @@ void KX_BulletPhysicsController::RemoveCompoundChild(KX_IPhysicsController* c
void KX_BulletPhysicsController::SetMass(MT_Scalar newmass)
{
btRigidBody *body = GetRigidBody();
- if (body && body->getActivationState() != DISABLE_SIMULATION &&
- newmass>MT_EPSILON && GetMass()>MT_EPSILON)
+ if (body && !m_suspended && newmass>MT_EPSILON && GetMass()>MT_EPSILON)
{
btVector3 grav = body->getGravity();
btVector3 accel = grav / GetMass();
@@ -356,34 +379,37 @@ void KX_BulletPhysicsController::SetMass(MT_Scalar newmass)
void KX_BulletPhysicsController::SuspendDynamics(bool ghost)
{
btRigidBody *body = GetRigidBody();
- if (body && body->getActivationState() != DISABLE_SIMULATION)
+ if (body && !m_suspended && !IsSensor())
{
btBroadphaseProxy* handle = body->getBroadphaseHandle();
m_savedCollisionFlags = body->getCollisionFlags();
m_savedMass = GetMass();
+ m_savedDyna = m_bDyna;
m_savedCollisionFilterGroup = handle->m_collisionFilterGroup;
m_savedCollisionFilterMask = handle->m_collisionFilterMask;
- m_savedActivationState = body->getActivationState();
- body->forceActivationState(DISABLE_SIMULATION);
+ m_suspended = true;
GetPhysicsEnvironment()->updateCcdPhysicsController(this,
0.0,
btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)),
btBroadphaseProxy::StaticFilter,
btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
+ m_bDyna = false;
}
}
void KX_BulletPhysicsController::RestoreDynamics()
{
btRigidBody *body = GetRigidBody();
- if (body && body->getActivationState() == DISABLE_SIMULATION)
+ if (body && m_suspended)
{
GetPhysicsEnvironment()->updateCcdPhysicsController(this,
m_savedMass,
m_savedCollisionFlags,
m_savedCollisionFilterGroup,
m_savedCollisionFilterMask);
- body->forceActivationState(m_savedActivationState);
+ body->activate();
+ m_bDyna = m_savedDyna;
+ m_suspended = false;
}
}
@@ -438,12 +464,12 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
void KX_BulletPhysicsController::SetSumoTransform(bool nondynaonly)
{
- if (GetRigidBody())
- GetRigidBody()->activate(true);
- if (!m_bDyna)
+ if (!m_bDyna && !m_bSensor)
{
- GetCollisionObject()->setCollisionFlags(GetRigidBody()->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ btCollisionObject* object = GetRigidBody();
+ object->setActivationState(ACTIVE_TAG);
+ object->setCollisionFlags(object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
} else
{
if (!nondynaonly)
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
index b39098206f7..755b1cbd780 100644
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
@@ -13,11 +13,13 @@ private:
short int m_savedCollisionFilterGroup;
short int m_savedCollisionFilterMask;
MT_Scalar m_savedMass;
+ bool m_savedDyna;
+ bool m_suspended;
btCollisionShape* m_bulletChildShape;
public:
- KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool compound);
+ KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool compound);
virtual ~KX_BulletPhysicsController ();
///////////////////////////////////
@@ -40,6 +42,7 @@ public:
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 void SetMass(MT_Scalar newmass);
virtual MT_Vector3 GetLocalInertia();
diff --git a/source/gameengine/Ketsji/KX_CDActuator.cpp b/source/gameengine/Ketsji/KX_CDActuator.cpp
index 121d4512265..8511526fd5f 100644
--- a/source/gameengine/Ketsji/KX_CDActuator.cpp
+++ b/source/gameengine/Ketsji/KX_CDActuator.cpp
@@ -74,9 +74,6 @@ CValue* KX_CDActuator::GetReplica()
{
KX_CDActuator* replica = new KX_CDActuator(*this);
replica->ProcessReplica();
-
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
};
@@ -158,8 +155,13 @@ bool KX_CDActuator::Update()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_CDActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_SoundActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -212,7 +214,7 @@ int KX_CDActuator::pyattr_setGain(void *self, const struct KX_PYATTRIBUTE_DEF *a
{
KX_CDActuator* act = static_cast<KX_CDActuator*>(self);
SND_CDObject::Instance()->SetGain(act->m_gain);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_CDActuator::py_getattro(PyObject *attr)
@@ -220,6 +222,10 @@ 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);
diff --git a/source/gameengine/Ketsji/KX_CDActuator.h b/source/gameengine/Ketsji/KX_CDActuator.h
index b674755e59f..2fd05ab72e5 100644
--- a/source/gameengine/Ketsji/KX_CDActuator.h
+++ b/source/gameengine/Ketsji/KX_CDActuator.h
@@ -82,6 +82,7 @@ public:
/* -------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
// Deprecated ----->
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index c8575424751..ba4d6e22872 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -28,6 +28,7 @@
* Camera in the gameengine. Cameras are also used for views.
*/
+#include "GL/glew.h"
#include "KX_Camera.h"
#include "KX_Scene.h"
#include "KX_PythonInit.h"
@@ -41,15 +42,17 @@ KX_Camera::KX_Camera(void* sgReplicationInfo,
SG_Callbacks callbacks,
const RAS_CameraData& camdata,
bool frustum_culling,
+ bool delete_node,
PyTypeObject *T)
:
KX_GameObject(sgReplicationInfo,callbacks,T),
m_camdata(camdata),
m_dirty(true),
m_normalized(false),
- m_frustum_culling(frustum_culling && camdata.m_perspective),
+ m_frustum_culling(frustum_culling),
m_set_projection_matrix(false),
- m_set_frustum_center(false)
+ m_set_frustum_center(false),
+ m_delete_node(delete_node)
{
// setting a name would be nice...
m_name = "cam";
@@ -63,6 +66,12 @@ KX_Camera::KX_Camera(void* sgReplicationInfo,
KX_Camera::~KX_Camera()
{
+ if (m_delete_node && m_pSGNode)
+ {
+ // for shadow camera, avoids memleak
+ delete m_pSGNode;
+ m_pSGNode = NULL;
+ }
}
@@ -71,15 +80,16 @@ CValue* KX_Camera::GetReplica()
KX_Camera* replica = new KX_Camera(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
- ProcessReplica(replica);
+ replica->ProcessReplica();
return replica;
}
-
-void KX_Camera::ProcessReplica(KX_Camera* replica)
+
+void KX_Camera::ProcessReplica()
{
- KX_GameObject::ProcessReplica(replica);
+ KX_GameObject::ProcessReplica();
+ // replicated camera are always registered in the scene
+ m_delete_node = false;
}
MT_Transform KX_Camera::GetWorldToCamera() const
@@ -190,6 +200,11 @@ float KX_Camera::GetLens() const
return m_camdata.m_lens;
}
+float KX_Camera::GetScale() const
+{
+ return m_camdata.m_scale;
+}
+
float KX_Camera::GetCameraNear() const
@@ -270,80 +285,83 @@ void KX_Camera::ExtractFrustumSphere()
MT_Matrix4x4 clip_camcs_matrix = m_projection_matrix;
clip_camcs_matrix.invert();
- // detect which of the corner of the far clipping plane is the farthest to the origin
- MT_Vector4 nfar; // far point in device normalized coordinate
- MT_Point3 farpoint; // most extreme far point in camera coordinate
- MT_Point3 nearpoint;// most extreme near point in camera coordinate
- MT_Point3 farcenter(0.,0.,0.);// center of far cliping plane in camera coordinate
- MT_Scalar F=1.0, N; // square distance of far and near point to origin
- MT_Scalar f, n; // distance of far and near point to z axis. f is always > 0 but n can be < 0
- MT_Scalar e, s; // far and near clipping distance (<0)
- MT_Scalar c; // slope of center line = distance of far clipping center to z axis / far clipping distance
- MT_Scalar z; // projection of sphere center on z axis (<0)
- // tmp value
- MT_Vector4 npoint(1., 1., 1., 1.);
- MT_Vector4 hpoint;
- MT_Point3 point;
- MT_Scalar len;
- for (int i=0; i<4; i++)
- {
- hpoint = clip_camcs_matrix*npoint;
- point.setValue(hpoint[0]/hpoint[3], hpoint[1]/hpoint[3], hpoint[2]/hpoint[3]);
- len = point.dot(point);
- if (len > F)
- {
- nfar = npoint;
- farpoint = point;
- F = len;
- }
- // rotate by 90 degree along the z axis to walk through the 4 extreme points of the far clipping plane
- len = npoint[0];
- npoint[0] = -npoint[1];
- npoint[1] = len;
- farcenter += point;
- }
- // the far center is the average of the far clipping points
- farcenter *= 0.25;
- // the extreme near point is the opposite point on the near clipping plane
- nfar.setValue(-nfar[0], -nfar[1], -1., 1.);
- nfar = clip_camcs_matrix*nfar;
- nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]);
- N = nearpoint.dot(nearpoint);
- e = farpoint[2];
- s = nearpoint[2];
- // projection on XY plane for distance to axis computation
- MT_Point2 farxy(farpoint[0], farpoint[1]);
- // f is forced positive by construction
- f = farxy.length();
- // get corresponding point on the near plane
- farxy *= s/e;
- // this formula preserve the sign of n
- n = f*s/e - MT_Point2(nearpoint[0]-farxy[0], nearpoint[1]-farxy[1]).length();
- c = MT_Point2(farcenter[0], farcenter[1]).length()/e;
- // the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case
- z = (F-N)/(2.0*(e-s+c*(f-n)));
- m_frustum_center = MT_Point3(farcenter[0]*z/e, farcenter[1]*z/e, z);
- m_frustum_radius = m_frustum_center.distance(farpoint);
-
-#if 0
- // The most extreme points on the near and far plane. (normalized device coords)
- MT_Vector4 hnear(1., 1., 0., 1.), hfar(1., 1., 1., 1.);
-
- // Transform to hom camera local space
- hnear = clip_camcs_matrix*hnear;
- hfar = clip_camcs_matrix*hfar;
-
- // Tranform to 3d camera local space.
- MT_Point3 nearpoint(hnear[0]/hnear[3], hnear[1]/hnear[3], hnear[2]/hnear[3]);
- MT_Point3 farpoint(hfar[0]/hfar[3], hfar[1]/hfar[3], hfar[2]/hfar[3]);
-
- // Compute center
- // don't use camera data in case the user specifies the matrix directly
- m_frustum_center = MT_Point3(0., 0.,
- (nearpoint.dot(nearpoint) - farpoint.dot(farpoint))/(2.0*(nearpoint[2]-farpoint[2] /*m_camdata.m_clipend - m_camdata.m_clipstart*/)));
- m_frustum_radius = m_frustum_center.distance(farpoint);
-#endif
-
+ if (m_projection_matrix[3][3] == MT_Scalar(0.0))
+ {
+ // frustrum projection
+ // detect which of the corner of the far clipping plane is the farthest to the origin
+ MT_Vector4 nfar; // far point in device normalized coordinate
+ MT_Point3 farpoint; // most extreme far point in camera coordinate
+ MT_Point3 nearpoint;// most extreme near point in camera coordinate
+ MT_Point3 farcenter(0.,0.,0.);// center of far cliping plane in camera coordinate
+ MT_Scalar F=-1.0, N; // square distance of far and near point to origin
+ MT_Scalar f, n; // distance of far and near point to z axis. f is always > 0 but n can be < 0
+ MT_Scalar e, s; // far and near clipping distance (<0)
+ MT_Scalar c; // slope of center line = distance of far clipping center to z axis / far clipping distance
+ MT_Scalar z; // projection of sphere center on z axis (<0)
+ // tmp value
+ MT_Vector4 npoint(1., 1., 1., 1.);
+ MT_Vector4 hpoint;
+ MT_Point3 point;
+ MT_Scalar len;
+ for (int i=0; i<4; i++)
+ {
+ hpoint = clip_camcs_matrix*npoint;
+ point.setValue(hpoint[0]/hpoint[3], hpoint[1]/hpoint[3], hpoint[2]/hpoint[3]);
+ len = point.dot(point);
+ if (len > F)
+ {
+ nfar = npoint;
+ farpoint = point;
+ F = len;
+ }
+ // rotate by 90 degree along the z axis to walk through the 4 extreme points of the far clipping plane
+ len = npoint[0];
+ npoint[0] = -npoint[1];
+ npoint[1] = len;
+ farcenter += point;
+ }
+ // the far center is the average of the far clipping points
+ farcenter *= 0.25;
+ // the extreme near point is the opposite point on the near clipping plane
+ nfar.setValue(-nfar[0], -nfar[1], -1., 1.);
+ nfar = clip_camcs_matrix*nfar;
+ nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]);
+ // this is a frustrum projection
+ N = nearpoint.dot(nearpoint);
+ e = farpoint[2];
+ s = nearpoint[2];
+ // projection on XY plane for distance to axis computation
+ MT_Point2 farxy(farpoint[0], farpoint[1]);
+ // f is forced positive by construction
+ f = farxy.length();
+ // get corresponding point on the near plane
+ farxy *= s/e;
+ // this formula preserve the sign of n
+ n = f*s/e - MT_Point2(nearpoint[0]-farxy[0], nearpoint[1]-farxy[1]).length();
+ c = MT_Point2(farcenter[0], farcenter[1]).length()/e;
+ // the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case
+ z = (F-N)/(2.0*(e-s+c*(f-n)));
+ m_frustum_center = MT_Point3(farcenter[0]*z/e, farcenter[1]*z/e, z);
+ m_frustum_radius = m_frustum_center.distance(farpoint);
+ }
+ else
+ {
+ // orthographic projection
+ // The most extreme points on the near and far plane. (normalized device coords)
+ MT_Vector4 hnear(1., 1., 1., 1.), hfar(-1., -1., -1., 1.);
+
+ // Transform to hom camera local space
+ hnear = clip_camcs_matrix*hnear;
+ hfar = clip_camcs_matrix*hfar;
+
+ // Tranform to 3d camera local space.
+ MT_Point3 nearpoint(hnear[0]/hnear[3], hnear[1]/hnear[3], hnear[2]/hnear[3]);
+ MT_Point3 farpoint(hfar[0]/hfar[3], hfar[1]/hfar[3], hfar[2]/hfar[3]);
+
+ // just use mediant point
+ m_frustum_center = (farpoint + nearpoint)*0.5;
+ m_frustum_radius = m_frustum_center.distance(farpoint);
+ }
// Transform to world space.
m_frustum_center = GetCameraToWorld()(m_frustum_center);
m_frustum_radius /= fabs(NodeGetWorldScaling()[NodeGetWorldScaling().closestAxis()]);
@@ -474,11 +492,16 @@ PyMethodDef KX_Camera::Methods[] = {
KX_PYMETHODTABLE_O(KX_Camera, pointInsideFrustum),
KX_PYMETHODTABLE_NOARGS(KX_Camera, getCameraToWorld),
KX_PYMETHODTABLE_NOARGS(KX_Camera, getWorldToCamera),
- KX_PYMETHODTABLE_NOARGS(KX_Camera, getProjectionMatrix),
- KX_PYMETHODTABLE_O(KX_Camera, setProjectionMatrix),
- KX_PYMETHODTABLE_O(KX_Camera, enableViewport),
KX_PYMETHODTABLE(KX_Camera, setViewport),
KX_PYMETHODTABLE_NOARGS(KX_Camera, setOnTop),
+ KX_PYMETHODTABLE_O(KX_Camera, getScreenPosition),
+ KX_PYMETHODTABLE(KX_Camera, getScreenVect),
+ KX_PYMETHODTABLE(KX_Camera, getScreenRay),
+
+ // DEPRECATED
+ KX_PYMETHODTABLE_O(KX_Camera, enableViewport),
+ KX_PYMETHODTABLE_NOARGS(KX_Camera, getProjectionMatrix),
+ KX_PYMETHODTABLE_O(KX_Camera, setProjectionMatrix),
{NULL,NULL} //Sentinel
};
@@ -492,7 +515,9 @@ PyAttributeDef KX_Camera::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("near", KX_Camera, pyattr_get_near, pyattr_set_near),
KX_PYATTRIBUTE_RW_FUNCTION("far", KX_Camera, pyattr_get_far, pyattr_set_far),
- KX_PYATTRIBUTE_RO_FUNCTION("projection_matrix", KX_Camera, pyattr_get_projection_matrix),
+ KX_PYATTRIBUTE_RW_FUNCTION("useViewport", KX_Camera, pyattr_get_use_viewport, pyattr_set_use_viewport),
+
+ KX_PYATTRIBUTE_RW_FUNCTION("projection_matrix", KX_Camera, pyattr_get_projection_matrix, pyattr_set_projection_matrix),
KX_PYATTRIBUTE_RO_FUNCTION("modelview_matrix", KX_Camera, pyattr_get_modelview_matrix),
KX_PYATTRIBUTE_RO_FUNCTION("camera_to_world", KX_Camera, pyattr_get_camera_to_world),
KX_PYATTRIBUTE_RO_FUNCTION("world_to_camera", KX_Camera, pyattr_get_world_to_camera),
@@ -506,8 +531,13 @@ PyAttributeDef KX_Camera::Attributes[] = {
};
PyTypeObject KX_Camera::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_Camera",
sizeof(PyObjectPlus_Proxy),
0,
@@ -544,6 +574,10 @@ 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);
@@ -678,6 +712,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, getProjectionMatrix,
"\tie: [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])\n"
)
{
+ ShowDeprecationWarning("getProjectionMatrix()", "the projection_matrix property");
return PyObjectFrom(GetProjectionMatrix()); /* new ref */
}
@@ -723,6 +758,8 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, setProjectionMatrix,
"\tcam = co.getOwner()\n"
"\tcam.setProjectionMatrix(Perspective(-1.0, 1.0, -1.0, 1.0, 0.1, 1))\n")
{
+ ShowDeprecationWarning("setProjectionMatrix(mat)", "the projection_matrix property");
+
MT_Matrix4x4 mat;
if (!PyMatTo(value, mat))
{
@@ -739,8 +776,9 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, enableViewport,
"Sets this camera's viewport status\n"
)
{
- int viewport = PyObject_IsTrue(value);
+ ShowDeprecationWarning("enableViewport(bool)", "the useViewport property");
+ int viewport = PyObject_IsTrue(value);
if (viewport == -1) {
PyErr_SetString(PyExc_ValueError, "camera.enableViewport(bool): KX_Camera, expected True/False or 0/1");
return NULL;
@@ -770,10 +808,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, setOnTop,
"setOnTop()\n"
"Sets this camera's viewport on top\n")
{
- class KX_Scene* scene;
-
- scene = KX_GetActiveScene();
- MT_assert(scene);
+ class KX_Scene* scene = KX_GetActiveScene();
scene->SetCameraOnTop(this);
Py_RETURN_NONE;
}
@@ -790,11 +825,11 @@ int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *at
int param = PyObject_IsTrue( value );
if (param == -1) {
PyErr_SetString(PyExc_AttributeError, "camera.perspective = bool: KX_Camera, expected True/False or 0/1");
- return -1;
+ return PY_SET_ATTR_FAIL;
}
self->m_camdata.m_perspective= param;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_Camera::pyattr_get_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -809,12 +844,12 @@ int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef,
float param = PyFloat_AsDouble(value);
if (param == -1) {
PyErr_SetString(PyExc_AttributeError, "camera.lens = float: KX_Camera, expected a float greater then zero");
- return -1;
+ return PY_SET_ATTR_FAIL;
}
self->m_camdata.m_lens= param;
self->m_set_projection_matrix = false;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_Camera::pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -829,12 +864,12 @@ int KX_Camera::pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef,
float param = PyFloat_AsDouble(value);
if (param == -1) {
PyErr_SetString(PyExc_AttributeError, "camera.near = float: KX_Camera, expected a float greater then zero");
- return -1;
+ return PY_SET_ATTR_FAIL;
}
self->m_camdata.m_clipstart= param;
self->m_set_projection_matrix = false;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_Camera::pyattr_get_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -849,14 +884,34 @@ int KX_Camera::pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, P
float param = PyFloat_AsDouble(value);
if (param == -1) {
PyErr_SetString(PyExc_AttributeError, "camera.far = float: KX_Camera, expected a float greater then zero");
- return -1;
+ return PY_SET_ATTR_FAIL;
}
self->m_camdata.m_clipend= param;
self->m_set_projection_matrix = false;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
+}
+
+
+PyObject* KX_Camera::pyattr_get_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_Camera* self= static_cast<KX_Camera*>(self_v);
+ return PyBool_FromLong(self->GetViewport());
+}
+
+int KX_Camera::pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_Camera* self= static_cast<KX_Camera*>(self_v);
+ int param = PyObject_IsTrue( value );
+ if (param == -1) {
+ PyErr_SetString(PyExc_AttributeError, "camera.useViewport = bool: KX_Camera, expected True or False");
+ return PY_SET_ATTR_FAIL;
+ }
+ self->EnableViewport((bool)param);
+ return PY_SET_ATTR_SUCCESS;
}
+
PyObject* KX_Camera::pyattr_get_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_Camera* self= static_cast<KX_Camera*>(self_v);
@@ -868,10 +923,10 @@ int KX_Camera::pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_D
KX_Camera* self= static_cast<KX_Camera*>(self_v);
MT_Matrix4x4 mat;
if (!PyMatTo(value, mat))
- return -1;
+ return PY_SET_ATTR_FAIL;
self->SetProjectionMatrix(mat);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_Camera::pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -900,3 +955,197 @@ PyObject* KX_Camera::pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *
PyObject* KX_Camera::pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{ return PyInt_FromLong(INTERSECT); }
+
+bool ConvertPythonToCamera(PyObject * value, KX_Camera **object, bool py_none_ok, const char *error_prefix)
+{
+ if (value==NULL) {
+ PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix);
+ *object = NULL;
+ return false;
+ }
+
+ if (value==Py_None) {
+ *object = NULL;
+
+ if (py_none_ok) {
+ return true;
+ } else {
+ PyErr_Format(PyExc_TypeError, "%s, expected KX_Camera or a KX_Camera name, None is invalid", error_prefix);
+ return false;
+ }
+ }
+
+ if (PyString_Check(value)) {
+ STR_String value_str = PyString_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));
+ return false;
+ }
+ }
+
+ if (PyObject_TypeCheck(value, &KX_Camera::Type)) {
+ *object = static_cast<KX_Camera*>BGE_PROXY_REF(value);
+
+ /* sets the error */
+ if (*object==NULL) {
+ PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix);
+ return false;
+ }
+
+ return true;
+ }
+
+ *object = NULL;
+
+ if (py_none_ok) {
+ PyErr_Format(PyExc_TypeError, "%s, expect a KX_Camera, a string or None", error_prefix);
+ } else {
+ PyErr_Format(PyExc_TypeError, "%s, expect a KX_Camera or a string", error_prefix);
+ }
+
+ return false;
+}
+
+KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition,
+"getScreenPosition()\n"
+)
+
+{
+ MT_Vector3 vect;
+ KX_GameObject *obj = NULL;
+
+ if (!PyVecTo(value, vect))
+ {
+ if(ConvertPythonToGameObject(value, &obj, true, ""))
+ {
+ PyErr_Clear();
+ vect = MT_Vector3(obj->NodeGetWorldPosition());
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "Error in getScreenPosition. Expected a Vector3 or a KX_GameObject or a string for a name of a KX_GameObject");
+ return NULL;
+ }
+ }
+
+ GLint viewport[4];
+ GLdouble win[3];
+ GLdouble modelmatrix[16];
+ GLdouble projmatrix[16];
+
+ MT_Matrix4x4 m_modelmatrix = this->GetModelviewMatrix();
+ MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
+
+ m_modelmatrix.getValue(modelmatrix);
+ m_projmatrix.getValue(projmatrix);
+
+ glGetIntegerv(GL_VIEWPORT, viewport);
+
+ gluProject(vect[0], vect[1], vect[2], modelmatrix, projmatrix, viewport, &win[0], &win[1], &win[2]);
+
+ vect[0] = (win[0] - viewport[0]) / viewport[2];
+ vect[1] = (win[1] - viewport[1]) / viewport[3];
+
+ vect[1] = 1.0 - vect[1]; //to follow Blender window coordinate system (Top-Down)
+
+ PyObject* ret = PyTuple_New(2);
+ if(ret){
+ PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(vect[0]));
+ PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(vect[1]));
+ return ret;
+ }
+
+ return NULL;
+}
+
+KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect,
+"getScreenVect()\n"
+)
+{
+ double x,y;
+ if (!PyArg_ParseTuple(args,"dd:getScreenVect",&x,&y))
+ return NULL;
+
+ y = 1.0 - y; //to follow Blender window coordinate system (Top-Down)
+
+ MT_Vector3 vect;
+ MT_Point3 campos, screenpos;
+
+ GLint viewport[4];
+ GLdouble win[3];
+ GLdouble modelmatrix[16];
+ GLdouble projmatrix[16];
+
+ MT_Matrix4x4 m_modelmatrix = this->GetModelviewMatrix();
+ MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
+
+ m_modelmatrix.getValue(modelmatrix);
+ m_projmatrix.getValue(projmatrix);
+
+ glGetIntegerv(GL_VIEWPORT, viewport);
+
+ vect[0] = x * viewport[2];
+ vect[1] = y * viewport[3];
+
+ vect[0] += viewport[0];
+ vect[1] += viewport[1];
+
+ glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &vect[2]);
+ gluUnProject(vect[0], vect[1], vect[2], modelmatrix, projmatrix, viewport, &win[0], &win[1], &win[2]);
+
+ campos = this->GetCameraLocation();
+ screenpos = MT_Point3(win[0], win[1], win[2]);
+ vect = campos-screenpos;
+
+ vect.normalize();
+ return PyObjectFrom(vect);
+}
+
+KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenRay,
+"getScreenRay()\n"
+)
+{
+ MT_Vector3 vect;
+ double x,y,dist;
+ char *propName = NULL;
+
+ if (!PyArg_ParseTuple(args,"ddd|s:getScreenRay",&x,&y,&dist,&propName))
+ return NULL;
+
+ PyObject* argValue = PyTuple_New(2);
+ if (argValue) {
+ PyTuple_SET_ITEM(argValue, 0, PyFloat_FromDouble(x));
+ PyTuple_SET_ITEM(argValue, 1, PyFloat_FromDouble(y));
+ }
+
+ if(!PyVecTo(PygetScreenVect(argValue), vect))
+ {
+ Py_DECREF(argValue);
+ PyErr_SetString(PyExc_TypeError,
+ "Error in getScreenRay. Invalid 2D coordinate. Expected a normalized 2D screen coordinate, a distance and an optional property argument");
+ return NULL;
+ }
+ Py_DECREF(argValue);
+
+ dist = -dist;
+ vect += this->GetCameraLocation();
+
+ argValue = (propName?PyTuple_New(3):PyTuple_New(2));
+ if (argValue) {
+ 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));
+
+ PyObject* ret= this->PyrayCastTo(argValue,NULL);
+ Py_DECREF(argValue);
+ return ret;
+ }
+
+ return NULL;
+}
+
diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h
index 4accd4bc2f1..aef21cd91e4 100644
--- a/source/gameengine/Ketsji/KX_Camera.h
+++ b/source/gameengine/Ketsji/KX_Camera.h
@@ -41,6 +41,9 @@
#include "IntValue.h"
#include "RAS_CameraData.h"
+/* utility conversion function */
+bool ConvertPythonToCamera(PyObject * value, KX_Camera **object, bool py_none_ok, const char *error_prefix);
+
class KX_Camera : public KX_GameObject
{
Py_Header;
@@ -110,6 +113,11 @@ protected:
bool m_set_frustum_center;
/**
+ * whether the camera should delete the node itself (only for shadow camera)
+ */
+ bool m_delete_node;
+
+ /**
* Extracts the camera clip frames from the projection and world-to-camera matrices.
*/
void ExtractClipPlanes();
@@ -135,7 +143,7 @@ public:
enum { INSIDE, INTERSECT, OUTSIDE } ;
- KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, PyTypeObject *T = &Type);
+ KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, bool delete_node = false, PyTypeObject *T = &Type);
virtual ~KX_Camera();
/**
@@ -146,15 +154,7 @@ public:
virtual CValue*
GetReplica(
);
-
- /**
- * Inherited from CValue -- Makes sure any internal
- * data owned by this class is deep copied. Called internally
- */
- virtual void
- ProcessReplica(
- KX_Camera* replica
- );
+ virtual void ProcessReplica();
MT_Transform GetWorldToCamera() const;
MT_Transform GetCameraToWorld() const;
@@ -193,6 +193,8 @@ public:
/** Gets the aperture. */
float GetLens() const;
+ /** Gets the ortho scale. */
+ float GetScale() const;
/** Gets the near clip distance. */
float GetCameraNear() const;
/** Gets the far clip distance. */
@@ -277,7 +279,12 @@ public:
KX_PYMETHOD_DOC_VARARGS(KX_Camera, setViewport);
KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop);
+ 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);
@@ -290,6 +297,9 @@ public:
static PyObject* pyattr_get_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+
static PyObject* pyattr_get_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_projection_matrix(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 8ef9f318142..f8557dac2c4 100644
--- a/source/gameengine/Ketsji/KX_CameraActuator.cpp
+++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp
@@ -82,8 +82,6 @@ GetReplica(
) {
KX_CameraActuator* replica = new KX_CameraActuator(*this);
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
};
@@ -371,8 +369,13 @@ bool KX_CameraActuator::string2axischoice(const char *axisString)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_CameraActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_CameraActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -416,7 +419,7 @@ PyAttributeDef KX_CameraActuator::Attributes[] = {
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("xy",KX_CameraActuator,m_x),
+ KX_PYATTRIBUTE_BOOL_RW("useXY",KX_CameraActuator,m_x),
KX_PYATTRIBUTE_RW_FUNCTION("object", KX_CameraActuator, pyattr_get_object, pyattr_set_object),
{NULL}
};
@@ -425,6 +428,10 @@ 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);
}
@@ -447,7 +454,7 @@ PyObject* KX_CameraActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_ob->GetName());
+ return PyString_FromString(m_ob->GetName().ReadPtr());
else
return m_ob->GetProxy();
}
@@ -554,7 +561,7 @@ const char KX_CameraActuator::SetXY_doc[] =
"\t1=x, 0=y\n";
PyObject* KX_CameraActuator::PySetXY(PyObject* args)
{
- ShowDeprecationWarning("setXY()", "the xy property");
+ ShowDeprecationWarning("setXY()", "the useXY property");
int value;
if(PyArg_ParseTuple(args,"i:setXY", &value))
{
@@ -590,7 +597,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF
KX_GameObject *gameobj;
if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_CameraActuator"))
- return 1; // ConvertPythonToGameObject sets the error
+ return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
if (self->m_ob)
self->m_ob->UnregisterActuator(self);
@@ -598,7 +605,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF
if ((self->m_ob = (SCA_IObject*)gameobj))
self->m_ob->RegisterActuator(self);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
/* eof */
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h
index 9298e1e868d..efa4e2f38d7 100644
--- a/source/gameengine/Ketsji/KX_CameraActuator.h
+++ b/source/gameengine/Ketsji/KX_CameraActuator.h
@@ -121,6 +121,7 @@ private :
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject* value);
/* set object to look at */
diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
index 7345edb054b..077ac96f0ac 100644
--- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h
+++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
@@ -50,8 +50,9 @@ struct KX_ClientObjectInfo
STATIC,
ACTOR,
RESERVED1,
- RADAR,
- NEAR
+ SENSOR,
+ OBSENSOR,
+ OBACTORSENSOR
} m_type;
KX_GameObject* m_gameobject;
void* m_auxilary_info;
@@ -84,6 +85,7 @@ public:
}
bool isActor() { return m_type <= ACTOR; }
+ bool isSensor() { return m_type >= SENSOR && m_type <= OBACTORSENSOR; }
};
#endif //__KX_CLIENTOBJECT_INFO_H
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
index c2b4db2de8e..bd03dea486b 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
@@ -565,8 +565,13 @@ bool KX_ConstraintActuator::IsValidMode(KX_ConstraintActuator::KX_CONSTRAINTTYPE
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_ConstraintActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_ConstraintActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -625,7 +630,7 @@ PyAttributeDef KX_ConstraintActuator::Attributes[] = {
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("property",0,32,true,KX_ConstraintActuator,m_property),
+ KX_PYATTRIBUTE_STRING_RW("propName",0,32,true,KX_ConstraintActuator,m_property),
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),
@@ -639,6 +644,10 @@ 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);
@@ -749,9 +758,9 @@ PyObject* KX_ConstraintActuator::PyGetDirection(){
ShowDeprecationWarning("getDirection()", "the direction property");
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_refDirection[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_refDirection[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_refDirection[2]));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_refDirection[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_refDirection[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_refDirection[2]));
return retVal;
}
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h
index 98f6fcd7906..40607b44947 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.h
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h
@@ -132,8 +132,6 @@ protected:
virtual CValue* GetReplica() {
KX_ConstraintActuator* replica = new KX_ConstraintActuator(*this);
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
};
@@ -144,6 +142,7 @@ protected:
/* --------------------------------------------------------------------- */
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);
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
index 7c3abb49159..c5cf67af67d 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
@@ -48,24 +48,48 @@ KX_ConstraintWrapper::KX_ConstraintWrapper(
KX_ConstraintWrapper::~KX_ConstraintWrapper()
{
}
-//python integration methods
-PyObject* KX_ConstraintWrapper::PyTestMethod(PyObject* args, PyObject* kwds)
-{
- Py_RETURN_NONE;
-}
-PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* args, PyObject* kwds)
+PyObject* KX_ConstraintWrapper::PyGetConstraintId()
{
return PyInt_FromLong(m_constraintId);
}
+PyObject* KX_ConstraintWrapper::PyGetParam(PyObject* args, PyObject* kwds)
+{
+ int dof;
+ float value;
+
+ if (!PyArg_ParseTuple(args,"i:getParam",&dof))
+ return NULL;
+
+ value = m_physenv->getConstraintParam(m_constraintId,dof);
+ return PyFloat_FromDouble(value);
+
+}
+
+PyObject* KX_ConstraintWrapper::PySetParam(PyObject* args, PyObject* kwds)
+{
+ int dof;
+ float minLimit,maxLimit;
+
+ if (!PyArg_ParseTuple(args,"iff:setParam",&dof,&minLimit,&maxLimit))
+ return NULL;
+
+ m_physenv->setConstraintParam(m_constraintId,dof,minLimit,maxLimit);
+ Py_RETURN_NONE;
+}
//python specific stuff
PyTypeObject KX_ConstraintWrapper::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_ConstraintWrapper",
sizeof(PyObjectPlus_Proxy),
0,
@@ -87,45 +111,33 @@ PyParentObject KX_ConstraintWrapper::Parents[] = {
NULL
};
-PyObject* KX_ConstraintWrapper::py_getattro(PyObject *attr)
+//here you can search for existing data members (like mass,friction etc.)
+PyObject* KX_ConstraintWrapper::py_getattro(PyObject *attr)
{
- //here you can search for existing data members (like mass,friction etc.)
py_getattro_up(PyObjectPlus);
}
-int KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
+PyObject* KX_ConstraintWrapper::py_getattro_dict() {
+ py_getattro_dict_up(PyObjectPlus);
+}
+
+int KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* value)
{
- int result = 1;
- /* what the heck is this supposed to do?, needs attention */
- if (PyList_Check(pyobj))
- {
- result = 0;
- }
- if (PyFloat_Check(pyobj))
- {
- result = 0;
-
- }
- if (PyInt_Check(pyobj))
- {
- result = 0;
- }
- if (PyString_Check(pyobj))
- {
- result = 0;
- }
- if (result)
- result = PyObjectPlus::py_setattro(attr,pyobj);
- return result;
+ py_setattro_up(PyObjectPlus);
};
+
+
+
PyMethodDef KX_ConstraintWrapper::Methods[] = {
- {"testMethod",(PyCFunction) KX_ConstraintWrapper::sPyTestMethod, METH_VARARGS},
- {"getConstraintId",(PyCFunction) KX_ConstraintWrapper::sPyGetConstraintId, METH_VARARGS},
+ {"getConstraintId",(PyCFunction) KX_ConstraintWrapper::sPyGetConstraintId, METH_NOARGS},
+ {"setParam",(PyCFunction) KX_ConstraintWrapper::sPySetParam, METH_VARARGS},
+ {"getParam",(PyCFunction) KX_ConstraintWrapper::sPyGetParam, METH_VARARGS},
{NULL,NULL} //Sentinel
};
PyAttributeDef KX_ConstraintWrapper::Attributes[] = {
+ //KX_PYATTRIBUTE_TODO("constraintId"),
{ NULL } //Sentinel
};
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h
index 6e67d842cb6..03813e0f167 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h
@@ -36,14 +36,16 @@ 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);
virtual ~KX_ConstraintWrapper ();
int getConstraintId() { return m_constraintId;};
- KX_PYMETHOD(KX_ConstraintWrapper,TestMethod);
- KX_PYMETHOD(KX_ConstraintWrapper,GetConstraintId);
+ KX_PYMETHOD_NOARGS(KX_ConstraintWrapper,GetConstraintId);
+ KX_PYMETHOD(KX_ConstraintWrapper,SetParam);
+ KX_PYMETHOD(KX_ConstraintWrapper,GetParam);
private:
int m_constraintId;
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
index 3534500e619..74042366bae 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
@@ -47,6 +47,7 @@
class RAS_MeshObject;
class KX_Scene;
+struct DerivedMesh;
typedef enum {
KX_BOUNDBOX,
@@ -82,6 +83,7 @@ struct KX_ObjectProperties
bool m_ghost;
class KX_GameObject* m_dynamic_parent;
bool m_isactor;
+ bool m_sensor;
bool m_concave;
bool m_isdeformable;
bool m_disableSleeping;
@@ -124,6 +126,7 @@ struct KX_ObjectProperties
float m_soft_kAHR; /* Anchors hardness [0,1] */
int m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
int m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
+ float m_soft_welding; /* threshold to remove duplicate/nearby vertices */
/////////////////////////
@@ -136,6 +139,8 @@ struct KX_ObjectProperties
/////////////////////////
double m_margin;
+ float m_contactProcessingThreshold;
+
KX_BoundBoxClass m_boundclass;
union {
KX_BoxBounds box;
@@ -182,6 +187,7 @@ bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj);
void KX_ConvertBulletObject( class KX_GameObject* gameobj,
class RAS_MeshObject* meshobj,
+ struct DerivedMesh* dm,
class KX_Scene* kxscene,
struct PHY_ShapeProps* shapeprops,
struct PHY_MaterialProps* smmaterial,
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 08e2ea30414..51c41c0686d 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -34,7 +34,7 @@
// defines USE_ODE to choose physics engine
#include "KX_ConvertPhysicsObject.h"
-#include "KX_GameObject.h"
+#include "BL_DeformableGameObject.h"
#include "RAS_MeshObject.h"
#include "KX_Scene.h"
#include "SYS_System.h"
@@ -52,6 +52,10 @@
#include "KX_MotionState.h" // bridge between motionstate and scenegraph node
+extern "C"{
+ #include "BKE_DerivedMesh.h"
+}
+
#ifdef USE_ODE
#include "KX_OdePhysicsController.h"
@@ -670,11 +674,11 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
class KX_SoftBodyDeformer : public RAS_Deformer
{
- class RAS_MeshObject* m_pMeshObject;
- class KX_GameObject* m_gameobj;
+ class RAS_MeshObject* m_pMeshObject;
+ class BL_DeformableGameObject* m_gameobj;
public:
- KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,KX_GameObject* gameobj)
+ KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,BL_DeformableGameObject* gameobj)
:m_pMeshObject(pMeshObject),
m_gameobj(gameobj)
{
@@ -687,7 +691,15 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
};
virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
{
- //printf("relink\n");
+ void **h_obj = (*map)[m_gameobj];
+
+ if (h_obj) {
+ m_gameobj = (BL_DeformableGameObject*)(*h_obj);
+ m_pMeshObject = m_gameobj->GetMesh(0);
+ } else {
+ m_gameobj = NULL;
+ m_pMeshObject = NULL;
+ }
}
virtual bool Apply(class RAS_IPolyMaterial *polymat)
{
@@ -749,14 +761,27 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
virtual bool Update(void)
{
//printf("update\n");
+ m_bDynamic = true;
return true;//??
}
- virtual RAS_Deformer *GetReplica(class KX_GameObject* replica)
+ virtual bool UpdateBuckets(void)
{
- KX_SoftBodyDeformer* deformer = new KX_SoftBodyDeformer(replica->GetMesh(0),replica);
- return deformer;
+ // this is to update the mesh slots outside the rasterizer,
+ // no need to do it for this deformer, it's done in any case in Apply()
+ return false;
}
+ virtual RAS_Deformer *GetReplica()
+ {
+ KX_SoftBodyDeformer* deformer = new KX_SoftBodyDeformer(*this);
+ deformer->ProcessReplica();
+ return deformer;
+ }
+ virtual void ProcessReplica()
+ {
+ // we have two pointers to deal with but we cannot do it now, will be done in Relink
+ m_bDynamic = false;
+ }
virtual bool SkipVertexTransform()
{
return true;
@@ -771,6 +796,7 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
void KX_ConvertBulletObject( class KX_GameObject* gameobj,
class RAS_MeshObject* meshobj,
+ struct DerivedMesh* dm,
class KX_Scene* kxscene,
struct PHY_ShapeProps* shapeprops,
struct PHY_MaterialProps* smmaterial,
@@ -782,12 +808,12 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
bool isbulletdyna = false;
+ bool isbulletsensor = false;
CcdConstructionInfo ci;
class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo();
-
if (!objprop->m_dyna)
{
ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
@@ -806,6 +832,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_margin = objprop->m_margin;
shapeInfo->m_radius = objprop->m_radius;
isbulletdyna = objprop->m_dyna;
+ isbulletsensor = objprop->m_sensor;
ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f);
@@ -825,7 +852,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
//bm = new MultiSphereShape(inertiaHalfExtents,,&trans.getOrigin(),&radius,1);
shapeInfo->m_shapeType = PHY_SHAPE_SPHERE;
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
};
case KX_BOUNDBOX:
@@ -838,7 +865,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
shapeInfo->m_halfExtend /= 2.0;
shapeInfo->m_halfExtend = shapeInfo->m_halfExtend.absolute();
shapeInfo->m_shapeType = PHY_SHAPE_BOX;
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
};
case KX_BOUNDCYLINDER:
@@ -849,7 +876,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
objprop->m_boundobject.c.m_height * 0.5f
);
shapeInfo->m_shapeType = PHY_SHAPE_CYLINDER;
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
}
@@ -858,45 +885,41 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
shapeInfo->m_radius = objprop->m_boundobject.c.m_radius;
shapeInfo->m_height = objprop->m_boundobject.c.m_height;
shapeInfo->m_shapeType = PHY_SHAPE_CONE;
- bm = shapeInfo->CreateBulletShape();
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
}
case KX_BOUNDPOLYTOPE:
{
- shapeInfo->SetMesh(meshobj, true,false);
- bm = shapeInfo->CreateBulletShape();
+ shapeInfo->SetMesh(meshobj, dm,true,false);
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
}
case KX_BOUNDMESH:
{
-
- if (!ci.m_mass ||objprop->m_softbody)
- {
- // mesh shapes can be shared, check first if we already have a shape on that mesh
- class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, false);
- if (sharedShapeInfo != NULL)
- {
- delete shapeInfo;
- shapeInfo = sharedShapeInfo;
- shapeInfo->AddRef();
- } else
- {
- shapeInfo->SetMesh(meshobj, false,false);
- }
-
- // Soft bodies require welding. Only avoid remove doubles for non-soft bodies!
- if (objprop->m_softbody)
- shapeInfo->setVertexWeldingThreshold1(0.01f); //todo: expose this to the UI
+ bool useGimpact = ((ci.m_mass || isbulletsensor) && !objprop->m_softbody);
- bm = shapeInfo->CreateBulletShape();
- //no moving concave meshes, so don't bother calculating inertia
- //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+ // mesh shapes can be shared, check first if we already have a shape on that mesh
+ class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, dm, false,useGimpact);
+ if (sharedShapeInfo != NULL)
+ {
+ delete shapeInfo;
+ shapeInfo = sharedShapeInfo;
+ shapeInfo->AddRef();
} else
{
- shapeInfo->SetMesh(meshobj, false,true);
- bm = shapeInfo->CreateBulletShape();
+ shapeInfo->SetMesh(meshobj, dm, false,useGimpact);
+ }
+
+ // Soft bodies require welding. Only avoid remove doubles for non-soft bodies!
+ if (objprop->m_softbody)
+ {
+ shapeInfo->setVertexWeldingThreshold1(objprop->m_soft_welding); //todo: expose this to the UI
}
+ bm = shapeInfo->CreateBulletShape(ci.m_margin);
+ //should we compute inertia for dynamic shape?
+ //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+
break;
}
}
@@ -911,7 +934,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
return;
}
- bm->setMargin(ci.m_margin);
+ //bm->setMargin(ci.m_margin);
if (objprop->m_isCompoundChild)
@@ -926,39 +949,27 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
assert(colShape->isCompound());
btCompoundShape* compoundShape = (btCompoundShape*)colShape;
- // compute the local transform from parent, this may include a parent inverse node
+ // compute the local transform from parent, this may include several node in the chain
SG_Node* gameNode = gameobj->GetSGNode();
- SG_Node* parentInverseNode = gameNode->GetSGParent();
- if (parentInverseNode && parentInverseNode->GetSGClientObject() != NULL)
- // this is not a parent inverse node, cancel it
- parentInverseNode = NULL;
- // now combine the parent inverse node and the game node
- MT_Point3 childPos = gameNode->GetLocalPosition();
- MT_Matrix3x3 childRot = gameNode->GetLocalOrientation();
- MT_Vector3 childScale = gameNode->GetLocalScale();
- if (parentInverseNode)
- {
- const MT_Point3& parentInversePos = parentInverseNode->GetLocalPosition();
- const MT_Matrix3x3& parentInverseRot = parentInverseNode->GetLocalOrientation();
- const MT_Vector3& parentInverseScale = parentInverseNode->GetLocalScale();
- childRot = parentInverseRot * childRot;
- childScale = parentInverseScale * childScale;
- childPos = parentInversePos+parentInverseScale*(parentInverseRot*childPos);
- }
-
- shapeInfo->m_childScale.setValue(childScale.x(),childScale.y(),childScale.z());
+ SG_Node* parentNode = objprop->m_dynamic_parent->GetSGNode();
+ // relative transform
+ MT_Vector3 parentScale = parentNode->GetWorldScaling();
+ parentScale[0] = MT_Scalar(1.0)/parentScale[0];
+ parentScale[1] = MT_Scalar(1.0)/parentScale[1];
+ parentScale[2] = MT_Scalar(1.0)/parentScale[2];
+ MT_Vector3 relativeScale = gameNode->GetWorldScaling() * parentScale;
+ MT_Matrix3x3 parentInvRot = parentNode->GetWorldOrientation().transposed();
+ MT_Vector3 relativePos = parentInvRot*((gameNode->GetWorldPosition()-parentNode->GetWorldPosition())*parentScale);
+ MT_Matrix3x3 relativeRot = parentInvRot*gameNode->GetWorldOrientation();
+
+ shapeInfo->m_childScale.setValue(relativeScale[0],relativeScale[1],relativeScale[2]);
bm->setLocalScaling(shapeInfo->m_childScale);
-
- shapeInfo->m_childTrans.setOrigin(btVector3(childPos.x(),childPos.y(),childPos.z()));
- float rotval[12];
- childRot.getValue(rotval);
- btMatrix3x3 newRot;
- newRot.setValue(rotval[0],rotval[1],rotval[2],rotval[4],rotval[5],rotval[6],rotval[8],rotval[9],rotval[10]);
- newRot = newRot.transpose();
-
- shapeInfo->m_childTrans.setBasis(newRot);
+ shapeInfo->m_childTrans.getOrigin().setValue(relativePos[0],relativePos[1],relativePos[2]);
+ float rot[12];
+ relativeRot.getValue(rot);
+ shapeInfo->m_childTrans.getBasis().setFromOpenGLSubMatrix(rot);
+
parentShapeInfo->AddShape(shapeInfo);
-
compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
//do some recalc?
//recalc inertia for rigidbody
@@ -969,6 +980,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
compoundShape->calculateLocalInertia(mass,localInertia);
rigidbody->setMassProps(mass,localInertia);
}
+ // delete motionstate as it's not used
+ delete motionstate;
return;
}
@@ -1081,26 +1094,32 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_soft_numclusteriterations= objprop->m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
////////////////////
-
- ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter);
- ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
+ ci.m_collisionFilterGroup =
+ (isbulletsensor) ? short(CcdConstructionInfo::SensorFilter) :
+ (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) :
+ short(CcdConstructionInfo::StaticFilter);
+ ci.m_collisionFilterMask =
+ (isbulletsensor) ? short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter) :
+ (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) :
+ short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody;
+
+ ci.m_contactProcessingThreshold = objprop->m_contactProcessingThreshold;//todo: expose this in advanced settings, just like margin, default to 10000 or so
ci.m_bSoft = objprop->m_softbody;
+ ci.m_bSensor = isbulletsensor;
MT_Vector3 scaling = gameobj->NodeGetWorldScaling();
ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]);
- KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna,objprop->m_hasCompoundChildren);
+ KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna,isbulletsensor,objprop->m_hasCompoundChildren);
// shapeInfo is reference counted, decrement now as we don't use it anymore
if (shapeInfo)
shapeInfo->Release();
- if (objprop->m_in_active_layer)
+ gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
+ // don't add automatically sensor object, they are added when a collision sensor is registered
+ if (!isbulletsensor && objprop->m_in_active_layer)
{
env->addCcdPhysicsController( physicscontroller);
}
-
-
-
- gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
physicscontroller->setNewClientInfo(gameobj->getClientInfo());
{
btRigidBody* rbody = physicscontroller->GetRigidBody();
@@ -1159,7 +1178,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
}
bool isActor = objprop->m_isactor;
- gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC);
+ gameobj->getClientInfo()->m_type =
+ (isbulletsensor) ? ((isActor) ? KX_ClientObjectInfo::OBACTORSENSOR : KX_ClientObjectInfo::OBSENSOR) :
+ (isActor) ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC;
// store materialname in auxinfo, needed for touchsensors
if (meshobj)
{
@@ -1187,9 +1208,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
if (softBody && gameobj->GetMesh(0))//only the first mesh, if any
{
//should be a mesh then, so add a soft body deformer
- KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),gameobj);
+ KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj);
gameobj->SetDeformer(softbodyDeformer);
-
}
}
diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp
index 321370f9f3f..daa31379985 100644
--- a/source/gameengine/Ketsji/KX_Dome.cpp
+++ b/source/gameengine/Ketsji/KX_Dome.cpp
@@ -43,29 +43,30 @@ KX_Dome::KX_Dome (
RAS_IRenderTools* rendertools,
/// engine
KX_KetsjiEngine* engine,
-
- float size, //size for adjustments
+
short res, //resolution of the mesh
short mode, //mode - fisheye, truncated, warped, panoramic, ...
short angle,
float resbuf, //size adjustment of the buffer
+ short tilt,
struct Text* warptext
):
- m_canvas(canvas),
- m_rasterizer(rasterizer),
- m_rendertools(rendertools),
- m_engine(engine),
+ dlistSupported(false),
+ canvaswidth(-1), canvasheight(-1),
m_drawingmode(engine->GetDrawType()),
- m_size(size),
m_resolution(res),
m_mode(mode),
m_angle(angle),
m_resbuffer(resbuf),
- canvaswidth(-1), canvasheight(-1),
- dlistSupported(false)
+ m_tilt(tilt),
+ m_canvas(canvas),
+ m_rasterizer(rasterizer),
+ m_rendertools(rendertools),
+ m_engine(engine)
{
warp.usemesh = false;
+ fboSupported = false;
if (mode >= DOME_NUM_MODES)
m_mode = DOME_FISHEYE;
@@ -107,15 +108,9 @@ KX_Dome::KX_Dome (
CreateMeshDome250();
m_numfaces = 5;
} break;
- case DOME_TRUNCATED:
- cubetop.resize(1);
- cubebottom.resize(1);
- cubeleft.resize(2);
- cuberight.resize(2);
-
- m_angle = 180;
- CreateMeshDome180();
- m_numfaces = 4;
+ case DOME_ENVMAP:
+ m_angle = 360;
+ m_numfaces = 6;
break;
case DOME_PANORAM_SPH:
cubeleft.resize(2);
@@ -129,6 +124,25 @@ KX_Dome::KX_Dome (
CreateMeshPanorama();
m_numfaces = 6;
break;
+ default: //DOME_TRUNCATED_FRONT and DOME_TRUNCATED_REAR
+ if (m_angle <= 180){
+ cubetop.resize(1);
+ cubebottom.resize(1);
+ cubeleft.resize(2);
+ cuberight.resize(2);
+
+ CreateMeshDome180();
+ m_numfaces = 4;
+ }else if (m_angle > 180){
+ cubetop.resize(2);
+ cubebottom.resize(2);
+ cubeleft.resize(2);
+ cubefront.resize(2);
+ cuberight.resize(2);
+
+ CreateMeshDome250();
+ m_numfaces = 5;
+ } break;
}
m_numimages =(warp.usemesh?m_numfaces+1:m_numfaces);
@@ -137,23 +151,27 @@ KX_Dome::KX_Dome (
CreateGLImages();
+ if(warp.usemesh)
+ fboSupported = CreateFBO();
+
dlistSupported = CreateDL();
}
// destructor
KX_Dome::~KX_Dome (void)
{
- GLuint m_numimages = m_numfaces;
-
ClearGLImages();
+ if(fboSupported)
+ glDeleteFramebuffersEXT(1, &warp.fboId);
+
if(dlistSupported)
glDeleteLists(dlistId, (GLsizei) m_numimages);
}
void KX_Dome::SetViewPort(GLuint viewport[4])
{
- if(canvaswidth != m_canvas->GetWidth() || canvasheight != m_canvas->GetHeight())
+ if(canvaswidth != m_viewport.GetWidth() || canvasheight != m_viewport.GetHeight())
{
m_viewport.SetLeft(viewport[0]);
m_viewport.SetBottom(viewport[1]);
@@ -180,9 +198,9 @@ void KX_Dome::CreateGLImages(void)
}
if(warp.usemesh){
glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, warp.imagewidth, warp.imageheight, 0, GL_RGB8,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, warp.imagesize, warp.imagesize, 0, GL_RGB8,
GL_UNSIGNED_BYTE, 0);
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, warp.imagewidth, warp.imageheight, 0);
+ glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, warp.imagesize, warp.imagesize, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -207,12 +225,25 @@ void KX_Dome::CalculateImageSize(void)
- reduce the buffer for better performace
- create a power of 2 texture bigger than the buffer
*/
+/*
+Blender handles Canvas size differently when in fullscreen mode.
+We are manually checking for that. Although it's a hack, it works.
+
+Bug reported here: #18655 - Inconsistency of pixels in canvas dimensions when in maximized mode (affecting BGE Dome)
+http://projects.blender.org/tracker/?func=detail&aid=18655&group_id=9&atid=125
+*/
canvaswidth = m_canvas->GetWidth();
canvasheight = m_canvas->GetHeight();
+ bool fullscreen(false); //XXX HACK
+ fullscreen = (canvaswidth != m_viewport.GetWidth());
+
m_buffersize = (canvaswidth > canvasheight?canvasheight:canvaswidth);
- m_buffersize *= m_resbuffer; //reduce buffer size for better performance
+ m_buffersize = (int)(m_buffersize*m_resbuffer); //reduce buffer size for better performance
+
+ if (fullscreen) //XXX HACK
+ m_buffersize --;
int i = 0;
while ((1 << i) <= m_buffersize)
@@ -220,27 +251,25 @@ void KX_Dome::CalculateImageSize(void)
m_imagesize = (1 << i);
if (warp.usemesh){
- warp.bufferwidth = canvaswidth;
- warp.bufferheight = canvasheight;
-
- i = 0;
- while ((1 << i) <= warp.bufferwidth)
- i++;
- warp.imagewidth = (1 << i);
+ // warp FBO needs to be up to twice as big as m_buffersize to get more resolution
+ warp.imagesize = m_imagesize;
+ if (m_buffersize == m_imagesize)
+ warp.imagesize *= 2;
- i = 0;
- while ((1 << i) <= warp.bufferheight)
- i++;
- warp.imageheight = (1 << i);
+ //if FBO is not working/supported, we use the canvas dimension as buffer
+ warp.bufferwidth = canvaswidth;
+ warp.bufferheight = canvasheight;
}
+
+ //XXX HACK
+ canvaswidth = m_viewport.GetWidth();
+ canvasheight = m_viewport.GetHeight();
}
bool KX_Dome::CreateDL(){
- int i,j;
-
dlistId = glGenLists((GLsizei) m_numimages);
if (dlistId != 0) {
- if(m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED){
+ if(m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR){
glNewList(dlistId, GL_COMPILE);
GLDrawTriangles(cubetop, nfacestop);
glEndList();
@@ -312,6 +341,46 @@ bool KX_Dome::CreateDL(){
return true;
}
+bool KX_Dome::CreateFBO(void)
+{
+ if (!GLEW_EXT_framebuffer_object)
+ {
+ printf("Dome Error: FrameBuffer unsupported. Using low resolution warp image.");
+ return false;
+ }
+
+ glGenFramebuffersEXT(1, &warp.fboId);
+ if(warp.fboId==0)
+ {
+ printf("Dome Error: Invalid frame buffer object. Using low resolution warp image.");
+ return false;
+ }
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, warp.fboId);
+
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, domefacesId[m_numfaces], 0);
+
+ GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+
+ if(status == GL_FRAMEBUFFER_UNSUPPORTED_EXT)
+ {
+ printf("Dome Error: FrameBuffer settings unsupported. Using low resolution warp image.");
+ return false;
+ }
+ else if(status != GL_FRAMEBUFFER_COMPLETE_EXT)
+ {
+ glDeleteFramebuffersEXT(1, &warp.fboId);
+ return false;
+ }
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+
+ //nothing failed: we can use the whole FBO as buffersize
+ warp.bufferwidth = warp.bufferheight = warp.imagesize;
+ return true;
+}
+
void KX_Dome::GLDrawTriangles(vector <DomeFace>& face, int nfaces)
{
int i,j;
@@ -328,8 +397,9 @@ void KX_Dome::GLDrawTriangles(vector <DomeFace>& face, int nfaces)
void KX_Dome::GLDrawWarpQuads(void)
{
int i, j, i2;
- float uv_width = (float)(warp.bufferwidth-1) / warp.imagewidth;
- float uv_height = (float)(warp.bufferheight-1) / warp.imageheight;
+
+ float uv_width = (float)(warp.bufferwidth) / warp.imagesize;
+ float uv_height = (float)(warp.bufferheight) / warp.imagesize;
if(warp.mode ==2 ){
glBegin(GL_QUADS);
@@ -386,7 +456,7 @@ void KX_Dome::GLDrawWarpQuads(void)
}
glEnd();
} else{
- printf("Error: Warp Mode unsupported. Try 1 for Polar Mesh or 2 for Fisheye.\n");
+ printf("Dome Error: Warp Mode %d unsupported. Try 1 for Polar Mesh or 2 for Fisheye.\n", warp.mode);
}
}
@@ -415,20 +485,22 @@ y varies from -1 to 1
u and v vary from 0 to 1
i ranges from 0 to 1, if negative don't draw that mesh node
*/
- int i,j,k;
+ int i;
int nodeX=0, nodeY=0;
vector<STR_String> columns, lines;
lines = text.Explode('\n');
if(lines.size() < 6){
- printf("Error: Warp Mesh File with insufficient data!\n");
+ printf("Dome Error: Warp Mesh File with insufficient data!\n");
return false;
}
columns = lines[1].Explode(' ');
+ if(columns.size() == 1)
+ columns = lines[1].Explode('\t');
if(columns.size() !=2){
- printf("Error: Warp Mesh File incorrect. The second line should contain: width height.\n");
+ printf("Dome Error: Warp Mesh File incorrect. The second line should contain: width height.\n");
return false;
}
@@ -437,14 +509,16 @@ i ranges from 0 to 1, if negative don't draw that mesh node
warp.n_width = atoi(columns[0]);
warp.n_height = atoi(columns[1]);
- if (lines.size() < 2 + (warp.n_width * warp.n_height)){
- printf("Error: Warp Mesh File with insufficient data!\n");
+ if ((int)lines.size() < 2 + (warp.n_width * warp.n_height)){
+ printf("Dome Error: Warp Mesh File with insufficient data!\n");
return false;
}else{
warp.nodes = vector<vector<WarpMeshNode> > (warp.n_height, vector<WarpMeshNode>(warp.n_width));
for(i=2; i-2 < (warp.n_width*warp.n_height); i++){
columns = lines[i].Explode(' ');
+ if(columns.size() == 1)
+ columns = lines[i].Explode('\t');
if (columns.size() == 5){
nodeX = (i-2)%warp.n_width;
@@ -458,7 +532,7 @@ i ranges from 0 to 1, if negative don't draw that mesh node
}
else{
warp.nodes.clear();
- printf("Error: Warp Mesh File with wrong number of fields. You should use 5: x y u v i.\n");
+ printf("Dome Error: Warp Mesh File with wrong number of fields. You should use 5: x y u v i.\n");
return false;
}
}
@@ -1373,7 +1447,7 @@ void KX_Dome::CalculateFrustum(KX_Camera * cam)
/*
// manually creating a 90º Field of View Frustum
- the original formula:
+ the original formula:
top = tan(fov*3.14159/360.0) * near [for fov in degrees]
fov*0.5 = arctan ((top-bottom)*0.5 / near) [for fov in radians]
bottom = -top
@@ -1411,11 +1485,14 @@ Uses 4 cameras for angles up to 180º
Uses 5 cameras for angles up to 250º
Uses 6 cameras for angles up to 360º
*/
+ int i;
float deg45 = MT_PI / 4;
MT_Scalar c = cos(deg45);
MT_Scalar s = sin(deg45);
- if ((m_mode == DOME_FISHEYE && m_angle <= 180)|| m_mode == DOME_TRUNCATED){
+ if (m_angle <= 180 && (m_mode == DOME_FISHEYE
+ || m_mode == DOME_TRUNCATED_FRONT
+ || m_mode == DOME_TRUNCATED_REAR)){
m_locRot[0] = MT_Matrix3x3( // 90º - Top
c, -s, 0.0,
@@ -1437,7 +1514,9 @@ Uses 6 cameras for angles up to 360º
0.0, 1.0, 0.0,
s, 0.0, c);
- } else if ((m_mode == DOME_FISHEYE && m_angle > 180)){
+ } else if (m_mode == DOME_ENVMAP || (m_angle > 180 && (m_mode == DOME_FISHEYE
+ || m_mode == DOME_TRUNCATED_FRONT
+ || m_mode == DOME_TRUNCATED_REAR))){
m_locRot[0] = MT_Matrix3x3( // 90º - Top
1.0, 0.0, 0.0,
@@ -1464,7 +1543,7 @@ Uses 6 cameras for angles up to 360º
0.0, 1.0, 0.0,
0.0, 0.0, 1.0);
- m_locRot[5] = MT_Matrix3x3( // 180º - Back - NOT USING
+ m_locRot[5] = MT_Matrix3x3( // 180º - Back - USED for ENVMAP only
-1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0,-1.0);
@@ -1501,6 +1580,23 @@ Uses 6 cameras for angles up to 360º
0.0, 1.0, 0.0,
s, 0.0, c);
}
+
+ // rotating the camera in horizontal axis
+ if (m_tilt)
+ {
+ float tiltdeg = ((m_tilt % 360) * 2 * MT_PI) / 360;
+ c = cos(tiltdeg);
+ s = sin(tiltdeg);
+
+ MT_Matrix3x3 tilt_mat = MT_Matrix3x3(
+ 1.0, 0.0, 0.0,
+ 0.0, c, -s,
+ 0.0, s, c
+ );
+
+ for (i =0;i<6;i++)
+ m_locRot[i] = tilt_mat * m_locRot[i];
+ }
}
void KX_Dome::RotateCamera(KX_Camera* cam, int i)
@@ -1515,8 +1611,7 @@ void KX_Dome::RotateCamera(KX_Camera* cam, int i)
MT_Transform camtrans(cam->GetWorldToCamera());
MT_Matrix4x4 viewmat(camtrans);
- m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldPosition(),
- cam->GetCameraLocation(), cam->GetCameraOrientation());
+ m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->GetCameraData()->m_perspective);
cam->SetModelviewMatrix(viewmat);
// restore the original orientation
@@ -1527,30 +1622,49 @@ void KX_Dome::RotateCamera(KX_Camera* cam, int i)
void KX_Dome::Draw(void)
{
+ if (fboSupported){
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, warp.fboId);
+
+ glViewport(0,0,warp.imagesize, warp.imagesize);
+ glScissor(0,0,warp.imagesize, warp.imagesize);
+ }
+
switch(m_mode){
case DOME_FISHEYE:
DrawDomeFisheye();
break;
- case DOME_TRUNCATED:
- DrawDomeFisheye();
+ case DOME_ENVMAP:
+ DrawEnvMap();
break;
case DOME_PANORAM_SPH:
DrawPanorama();
break;
+ case DOME_TRUNCATED_FRONT:
+ DrawDomeFisheye();
+ break;
+ case DOME_TRUNCATED_REAR:
+ DrawDomeFisheye();
+ break;
}
if(warp.usemesh)
{
- glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]);
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_viewport.GetLeft(), m_viewport.GetBottom(), warp.bufferwidth, warp.bufferheight);
+ if(fboSupported)
+ {
+ m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ }
+ else
+ {
+ glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]);
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_viewport.GetLeft(), m_viewport.GetBottom(), warp.bufferwidth, warp.bufferheight);
+ }
DrawDomeWarped();
}
}
-void KX_Dome::DrawDomeFisheye(void)
+void KX_Dome::DrawEnvMap(void)
{
- int i,j;
-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -1563,28 +1677,17 @@ void KX_Dome::DrawDomeFisheye(void)
float ortho_width, ortho_height;
if (warp.usemesh)
- glOrtho((-1.0), 1.0, (-1.0), 1.0, -20.0, 10.0); //stretch the image to reduce resolution lost
+ glOrtho((-1.0), 1.0, (-0.66), 0.66, -20.0, 10.0); //stretch the image to reduce resolution lost
- else if(m_mode == DOME_TRUNCATED){
- ortho_width = 1.0;
- ortho_height = 2 * ((float)can_height/can_width) - 1.0 ;
-
- ortho_width /= m_size;
- ortho_height /= m_size;
-
- glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_width, -20.0, 10.0);
- } else {
- if (can_width < can_height){
+ else {
+ if (can_width/3 <= can_height/2){
ortho_width = 1.0;
ortho_height = (float)can_height/can_width;
}else{
- ortho_width = (float)can_width/can_height;
- ortho_height = 1.0;
+ ortho_height = 2.0f / 3;
+ ortho_width = (float)can_width/can_height * ortho_height;
}
- ortho_width /= m_size;
- ortho_height /= m_size;
-
glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0);
}
@@ -1592,6 +1695,150 @@ void KX_Dome::DrawDomeFisheye(void)
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
+ gluLookAt(0.0,0.0,1.0, 0.0,0.0,0.0, 0.0,1.0,0.0);
+
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glShadeModel(GL_SMOOTH);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_DEPTH_TEST);
+
+ glEnable(GL_TEXTURE_2D);
+ glColor3f(1.0,1.0,1.0);
+
+ float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
+ double onebythree = 1.0f / 3;
+
+ // domefacesId[0] => (top)
+ glBindTexture(GL_TEXTURE_2D, domefacesId[0]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(uv_ratio,uv_ratio);
+ glVertex3f( onebythree, 0.0f, 3.0f);
+ glTexCoord2f(0.0,uv_ratio);
+ glVertex3f(-onebythree, 0.0f, 3.0f);
+ glTexCoord2f(0.0,0.0);
+ glVertex3f(-onebythree,-2 * onebythree, 3.0f);
+ glTexCoord2f(uv_ratio,0.0);
+ glVertex3f(onebythree,-2 * onebythree, 3.0f);
+ glEnd();
+
+ // domefacesId[1] => (bottom)
+ glBindTexture(GL_TEXTURE_2D, domefacesId[1]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(uv_ratio,uv_ratio);
+ glVertex3f(-onebythree, 0.0f, 3.0f);
+ glTexCoord2f(0.0,uv_ratio);
+ glVertex3f(-1.0f, 0.0f, 3.0f);
+ glTexCoord2f(0.0,0.0);
+ glVertex3f(-1.0f,-2 * onebythree, 3.0f);
+ glTexCoord2f(uv_ratio,0.0);
+ glVertex3f(-onebythree,-2 * onebythree, 3.0f);
+ glEnd();
+
+ // domefacesId[2] => -90º (left)
+ glBindTexture(GL_TEXTURE_2D, domefacesId[2]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(uv_ratio,uv_ratio);
+ glVertex3f(-onebythree, 2 * onebythree, 3.0f);
+ glTexCoord2f(0.0,uv_ratio);
+ glVertex3f(-1.0f, 2 * onebythree, 3.0f);
+ glTexCoord2f(0.0,0.0);
+ glVertex3f(-1.0f, 0.0f, 3.0f);
+ glTexCoord2f(uv_ratio,0.0);
+ glVertex3f(-onebythree, 0.0f, 3.0f);
+ glEnd();
+
+ // domefacesId[3] => 90º (right)
+ glBindTexture(GL_TEXTURE_2D, domefacesId[3]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(uv_ratio,uv_ratio);
+ glVertex3f( 1.0f, 2 * onebythree, 3.0f);
+ glTexCoord2f(0.0,uv_ratio);
+ glVertex3f( onebythree, 2 * onebythree, 3.0f);
+ glTexCoord2f(0.0,0.0);
+ glVertex3f( onebythree, 0.0f, 3.0f);
+ glTexCoord2f(uv_ratio,0.0);
+ glVertex3f(1.0f, 0.0f, 3.0f);
+ glEnd();
+
+ // domefacesId[4] => 0º (front)
+ glBindTexture(GL_TEXTURE_2D, domefacesId[4]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(uv_ratio,uv_ratio);
+ glVertex3f( 1.0f, 0.0f, 3.0f);
+ glTexCoord2f(0.0,uv_ratio);
+ glVertex3f( onebythree, 0.0f, 3.0f);
+ glTexCoord2f(0.0,0.0);
+ glVertex3f( onebythree,-2 * onebythree, 3.0f);
+ glTexCoord2f(uv_ratio,0.0);
+ glVertex3f(1.0f, -2 * onebythree, 3.0f);
+ glEnd();
+
+ // domefacesId[5] => 180º (back)
+ glBindTexture(GL_TEXTURE_2D, domefacesId[5]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(uv_ratio,uv_ratio);
+ glVertex3f( onebythree, 2 * onebythree, 3.0f);
+ glTexCoord2f(0.0,uv_ratio);
+ glVertex3f(-onebythree, 2 * onebythree, 3.0f);
+ glTexCoord2f(0.0,0.0);
+ glVertex3f(-onebythree, 0.0f, 3.0f);
+ glTexCoord2f(uv_ratio,0.0);
+ glVertex3f(onebythree, 0.0f, 3.0f);
+ glEnd();
+
+ glDisable(GL_TEXTURE_2D);
+ glEnable(GL_DEPTH_TEST);
+}
+
+void KX_Dome::DrawDomeFisheye(void)
+{
+ int i;
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ // Making the viewport always square
+
+ int can_width = m_viewport.GetRight();
+ int can_height = m_viewport.GetTop();
+
+ float ortho_width, ortho_height;
+
+ if(m_mode == DOME_FISHEYE) {
+ if (warp.usemesh)
+ glOrtho((-1.0), 1.0, (-1.0), 1.0, -20.0, 10.0); //stretch the image to reduce resolution lost
+
+ else {
+ if (can_width < can_height){
+ ortho_width = 1.0;
+ ortho_height = (float)can_height/can_width;
+ }else{
+ ortho_width = (float)can_width/can_height;
+ ortho_height = 1.0;
+ }
+
+ glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0);
+ }
+ }
+ else if(m_mode == DOME_TRUNCATED_FRONT)
+ {
+ ortho_width = 1.0;
+ ortho_height = 2 * ((float)can_height/can_width) - 1.0 ;
+
+ glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_width, -20.0, 10.0);
+ }
+ else { //m_mode == DOME_TRUNCATED_REAR
+ ortho_width = 1.0;
+ ortho_height = 2 * ((float)can_height/can_width) - 1.0 ;
+
+ glOrtho((-ortho_width), ortho_width, (-ortho_width), ortho_height, -20.0, 10.0);
+ }
+
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
gluLookAt(0.0,-1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0);
if(m_drawingmode == RAS_IRasterizer::KX_WIREFRAME)
@@ -1641,7 +1888,7 @@ void KX_Dome::DrawDomeFisheye(void)
void KX_Dome::DrawPanorama(void)
{
- int i,j;
+ int i;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -1666,9 +1913,6 @@ void KX_Dome::DrawPanorama(void)
ortho_width = (float)can_width/can_height * 0.5;
ortho_height = 0.5;
}
-
- ortho_width /= m_size;
- ortho_height /= m_size;
glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0, 10.0);
}
@@ -1728,8 +1972,6 @@ void KX_Dome::DrawPanorama(void)
void KX_Dome::DrawDomeWarped(void)
{
- int i,j;
-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -1739,7 +1981,6 @@ void KX_Dome::DrawDomeWarped(void)
int can_height = m_viewport.GetTop();
double screen_ratio = can_width/ (double) can_height;
- screen_ratio /= m_size;
glOrtho(-screen_ratio,screen_ratio,-1.0,1.0,-20.0,10.0);
@@ -1762,10 +2003,6 @@ void KX_Dome::DrawDomeWarped(void)
glEnable(GL_TEXTURE_2D);
glColor3f(1.0,1.0,1.0);
-
- float uv_width = (float)(warp.bufferwidth-1) / warp.imagewidth;
- float uv_height = (float)(warp.bufferheight-1) / warp.imageheight;
-
if (dlistSupported){
glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]);
glCallList(dlistId + m_numfaces);
@@ -1806,8 +2043,7 @@ void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i)
MT_Transform camtrans(cam->GetWorldToCamera());
MT_Matrix4x4 viewmat(camtrans);
- m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldPosition(),
- cam->GetCameraLocation(), cam->GetCameraOrientation());
+ m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), 1.0);
cam->SetModelviewMatrix(viewmat);
scene->CalculateVisibleMeshes(m_rasterizer,cam);
@@ -1816,4 +2052,5 @@ void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i)
// restore the original orientation
cam->NodeSetLocalOrientation(camori);
cam->NodeUpdateGS(0.f);
-} \ No newline at end of file
+}
+
diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h
index 786e04b4385..20b60ef0173 100644
--- a/source/gameengine/Ketsji/KX_Dome.h
+++ b/source/gameengine/Ketsji/KX_Dome.h
@@ -38,13 +38,14 @@ Developed as part of a Research and Development project for SAT - La Société des
#include "MEM_guardedalloc.h"
#include "BKE_text.h"
-//#include "BLI_blenlib.h"
//Dome modes: limit hardcoded in buttons_scene.c
-#define DOME_FISHEYE 1
-#define DOME_TRUNCATED 2
-#define DOME_PANORAM_SPH 3
-#define DOME_NUM_MODES 4
+#define DOME_FISHEYE 1
+#define DOME_TRUNCATED_FRONT 2
+#define DOME_TRUNCATED_REAR 3
+#define DOME_ENVMAP 4
+#define DOME_PANORAM_SPH 5
+#define DOME_NUM_MODES 6
/// class for render 3d scene
@@ -60,12 +61,12 @@ public:
RAS_IRenderTools* m_rendertools,
/// engine
KX_KetsjiEngine* m_engine,
-
- float size,
+
short res,
short mode,
short angle,
float resbuf,
+ short tilt,
struct Text* warptext
);
@@ -74,6 +75,7 @@ public:
//openGL checks:
bool dlistSupported;
+ bool fboSupported;
//openGL names:
GLuint domefacesId[7]; // ID of the images -- room for 7 images, using only 4 for 180º x 360º dome, 6 for panoramic and +1 for warp mesh
@@ -93,8 +95,9 @@ public:
bool usemesh;
int mode;
int n_width, n_height; //nodes width and height
- int imagewidth, imageheight;
+ int imagesize;
int bufferwidth, bufferheight;
+ GLuint fboId;
vector <vector <WarpMeshNode> > nodes;
} warp;
@@ -116,7 +119,7 @@ public:
void CalculateFrustum(KX_Camera* cam);
void RotateCamera(KX_Camera* cam, int i);
- //Mesh Creating Functions
+ //Mesh creation Functions
void CreateMeshDome180(void);
void CreateMeshDome250(void);
void CreateMeshPanorama(void);
@@ -131,6 +134,7 @@ public:
void GLDrawWarpQuads(void);
void Draw(void);
void DrawDomeFisheye(void);
+ void DrawEnvMap(void);
void DrawPanorama(void);
void DrawDomeWarped(void);
@@ -139,6 +143,8 @@ public:
void ClearGLImages(void);//called on resize
bool CreateDL(void); //create Display Lists
void ClearDL(void); //remove Display Lists
+ bool CreateFBO(void);//create FBO (for warp mesh)
+ void ClearFBO(void); //remove FBO
void CalculateCameraOrientation();
void CalculateImageSize(); //set m_imagesize
@@ -153,13 +159,13 @@ protected:
int m_buffersize; // canvas small dimension
int m_numfaces; // 4 to 6 depending on the kind of dome image
int m_numimages; //numfaces +1 if we have warp mesh
-
- float m_size; // size to adjust
+
short m_resolution; //resolution to tesselate the mesh
short m_mode; // the mode (truncated, warped, panoramic,...)
short m_angle; //the angle of the fisheye
float m_radangle; //the angle of the fisheye in radians
float m_resbuffer; //the resolution of the buffer
+ short m_tilt; //the dome tilt (camera rotation on horizontal axis)
RAS_Rect m_viewport;
@@ -181,3 +187,4 @@ protected:
};
#endif
+
diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp
index 8b587c6f7de..28bf12f5e87 100644
--- a/source/gameengine/Ketsji/KX_GameActuator.cpp
+++ b/source/gameengine/Ketsji/KX_GameActuator.cpp
@@ -73,8 +73,6 @@ CValue* KX_GameActuator::GetReplica()
{
KX_GameActuator* replica = new KX_GameActuator(*this);
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
}
@@ -151,6 +149,8 @@ bool KX_GameActuator::Update()
} else {
printf("Warning: could not create marshal buffer\n");
}
+ if (marshal_buffer)
+ delete [] marshal_buffer;
}
break;
}
@@ -208,8 +208,13 @@ bool KX_GameActuator::Update()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_GameActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_GameActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -249,16 +254,20 @@ PyMethodDef KX_GameActuator::Methods[] =
};
PyAttributeDef KX_GameActuator::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW("file",0,100,false,KX_GameActuator,m_filename),
+ KX_PYATTRIBUTE_STRING_RW("fileName",0,100,false,KX_GameActuator,m_filename),
+ KX_PYATTRIBUTE_INT_RW("mode", KX_GAME_NODEF+1, KX_GAME_MAX-1, true, KX_GameActuator, m_mode),
{ NULL } //Sentinel
};
-PyObject*
-KX_GameActuator::py_getattro(PyObject *attr)
+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);
@@ -272,7 +281,7 @@ const char KX_GameActuator::GetFile_doc[] =
"get the name of the file to start.\n";
PyObject* KX_GameActuator::PyGetFile(PyObject* args, PyObject* kwds)
{
- ShowDeprecationWarning("getFile()", "the file property");
+ ShowDeprecationWarning("getFile()", "the fileName property");
return PyString_FromString(m_filename);
}
@@ -284,7 +293,7 @@ PyObject* KX_GameActuator::PySetFile(PyObject* args, PyObject* kwds)
{
char* new_file;
- ShowDeprecationWarning("setFile()", "the file property");
+ ShowDeprecationWarning("setFile()", "the fileName property");
if (!PyArg_ParseTuple(args, "s:setFile", &new_file))
{
diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h
index 570cb2e68ef..b2b1d6ec2b9 100644
--- a/source/gameengine/Ketsji/KX_GameActuator.h
+++ b/source/gameengine/Ketsji/KX_GameActuator.h
@@ -78,6 +78,7 @@ protected:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
// Deprecated functions ----->
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index bea0fcff2af..7f417b325c8 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -49,6 +49,8 @@ typedef unsigned long uint_ptr;
#include "RAS_IPolygonMaterial.h"
#include "KX_BlenderMaterial.h"
#include "KX_GameObject.h"
+#include "KX_Camera.h" // only for their ::Type
+#include "KX_Light.h" // only for their ::Type
#include "RAS_MeshObject.h"
#include "KX_MeshProxy.h"
#include "KX_PolyProxy.h"
@@ -63,6 +65,7 @@ typedef unsigned long uint_ptr;
#include "KX_RayCast.h"
#include "KX_PythonInit.h"
#include "KX_PyMath.h"
+#include "KX_PythonSeq.h"
#include "SCA_IActuator.h"
#include "SCA_ISensor.h"
#include "SCA_IController.h"
@@ -187,38 +190,23 @@ double KX_GameObject::GetNumber()
-STR_String KX_GameObject::GetName()
+STR_String& KX_GameObject::GetName()
{
return m_name;
}
-void KX_GameObject::SetName(STR_String name)
+void KX_GameObject::SetName(const char *name)
{
m_name = name;
}; // Set the name of the value
-
-
-void KX_GameObject::ReplicaSetName(STR_String name)
-{
-}
-
-
-
-
-
-
KX_IPhysicsController* KX_GameObject::GetPhysicsController()
{
return m_pPhysicsController1;
}
-
-
-
-
KX_GameObject* KX_GameObject::GetParent()
{
KX_GameObject* result = NULL;
@@ -238,7 +226,7 @@ KX_GameObject* KX_GameObject::GetParent()
}
-void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj)
+void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCompound, bool ghost)
{
// check on valid node in case a python controller holds a reference to a deleted object
if (obj && GetSGNode() && obj->GetSGNode() && GetSGNode()->GetSGParent() != obj->GetSGNode())
@@ -259,7 +247,7 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj)
if (m_pPhysicsController1)
{
- m_pPhysicsController1->SuspendDynamics(true);
+ m_pPhysicsController1->SuspendDynamics(ghost);
}
// Set us to our new scale, position, and orientation
scale2[0] = 1.0/scale2[0];
@@ -280,7 +268,7 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj)
Release();
// if the new parent is a compound object, add this object shape to the compound shape.
// step 0: verify this object has physical controller
- if (m_pPhysicsController1)
+ if (m_pPhysicsController1 && addToCompound)
{
// step 1: find the top parent (not necessarily obj)
KX_GameObject* rootobj = (KX_GameObject*)obj->GetSGNode()->GetRootSGParent()->GetSGClientObject();
@@ -326,33 +314,75 @@ void KX_GameObject::RemoveParent(KX_Scene *scene)
rootobj->m_pPhysicsController1->RemoveCompoundChild(m_pPhysicsController1);
}
m_pPhysicsController1->RestoreDynamics();
+ if (m_pPhysicsController1->IsDyna() && rootobj->m_pPhysicsController1)
+ {
+ // dynamic object should remember the velocity they had while being parented
+ MT_Point3 childPoint = GetSGNode()->GetWorldPosition();
+ MT_Point3 rootPoint = rootobj->GetSGNode()->GetWorldPosition();
+ MT_Point3 relPoint;
+ relPoint = (childPoint-rootPoint);
+ MT_Vector3 linVel = rootobj->m_pPhysicsController1->GetVelocity(relPoint);
+ MT_Vector3 angVel = rootobj->m_pPhysicsController1->GetAngularVelocity();
+ m_pPhysicsController1->SetLinearVelocity(linVel, false);
+ m_pPhysicsController1->SetAngularVelocity(angVel, false);
+ }
}
// graphically, the object hasn't change place, no need to update m_pGraphicController
}
}
-void KX_GameObject::ProcessReplica(KX_GameObject* replica)
+void KX_GameObject::ProcessReplica()
{
- replica->m_pPhysicsController1 = NULL;
- replica->m_pGraphicController = NULL;
- replica->m_pSGNode = NULL;
- replica->m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info);
- replica->m_pClient_info->m_gameobject = replica;
- replica->m_state = 0;
+ SCA_IObject::ProcessReplica();
+
+ m_pPhysicsController1 = NULL;
+ m_pGraphicController = NULL;
+ m_pSGNode = NULL;
+ m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info);
+ m_pClient_info->m_gameobject = this;
+ m_state = 0;
if(m_attr_dict)
- replica->m_attr_dict= PyDict_Copy(m_attr_dict);
+ m_attr_dict= PyDict_Copy(m_attr_dict);
+
+}
+
+static void setGraphicController_recursive(SG_Node* node)
+{
+ NodeList& children = node->GetSGChildren();
+
+ for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
+ {
+ SG_Node* childnode = (*childit);
+ KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
+ if (clientgameobj != NULL) // This is a GameObject
+ clientgameobj->ActivateGraphicController(false);
+ // if the childobj is NULL then this may be an inverse parent link
+ // so a non recursive search should still look down this node.
+ setGraphicController_recursive(childnode);
+ }
}
+void KX_GameObject::ActivateGraphicController(bool recurse)
+{
+ if (m_pGraphicController)
+ {
+ m_pGraphicController->Activate(m_bVisible);
+ }
+ if (recurse)
+ {
+ setGraphicController_recursive(GetSGNode());
+ }
+}
+
CValue* KX_GameObject::GetReplica()
{
KX_GameObject* replica = new KX_GameObject(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
- ProcessReplica(replica);
+ replica->ProcessReplica();
return replica;
}
@@ -421,6 +451,7 @@ double* KX_GameObject::GetOpenGLMatrix()
m_bIsNegativeScaling = ((scaling[0] < 0.0) ^ (scaling[1] < 0.0) ^ (scaling[2] < 0.0)) ? true : false;
trans.scale(scaling[0], scaling[1], scaling[2]);
trans.getValue(fl);
+ GetSGNode()->ClearDirty();
}
return fl;
}
@@ -428,8 +459,18 @@ double* KX_GameObject::GetOpenGLMatrix()
void KX_GameObject::AddMeshUser()
{
for (size_t i=0;i<m_meshes.size();i++)
- m_meshes[i]->AddMeshUser(this);
-
+ {
+ m_meshes[i]->AddMeshUser(this, &m_meshSlots, GetDeformer());
+ }
+ // set the part of the mesh slot that never change
+ double* fl = GetOpenGLMatrixPtr()->getPointer();
+
+ SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
+ RAS_MeshSlot* ms;
+ for(mit.begin(); !mit.end(); ++mit)
+ {
+ (*mit)->m_OpenGLMatrix = fl;
+ }
UpdateBuckets(false);
}
@@ -453,10 +494,27 @@ static void UpdateBuckets_recursive(SG_Node* node)
void KX_GameObject::UpdateBuckets( bool recursive )
{
if (GetSGNode()) {
- double* fl = GetOpenGLMatrixPtr()->getPointer();
+ RAS_MeshSlot *ms;
+
+ if (GetSGNode()->IsDirty())
+ GetOpenGLMatrix();
- for (size_t i=0;i<m_meshes.size();i++)
- m_meshes[i]->UpdateBuckets(this, fl, m_bUseObjectColor, m_objectColor, m_bVisible, m_bCulled);
+ SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
+ for(mit.begin(); !mit.end(); ++mit)
+ {
+ ms = *mit;
+ ms->m_bObjectColor = m_bUseObjectColor;
+ ms->m_RGBAcolor = m_objectColor;
+ ms->m_bVisible = m_bVisible;
+ ms->m_bCulled = m_bCulled || !m_bVisible;
+ if (!ms->m_bCulled)
+ ms->m_bucket->ActivateMesh(ms);
+
+ /* split if necessary */
+#ifdef USE_SPLIT
+ ms->Split();
+#endif
+ }
if (recursive) {
UpdateBuckets_recursive(GetSGNode());
@@ -476,11 +534,11 @@ void KX_GameObject::RemoveMeshes()
void KX_GameObject::UpdateTransform()
{
- if (m_pPhysicsController1)
- // only update the transform of static object, dynamic object are handled differently
- // note that for bullet, this does not even update the transform of static object
+ // HACK: saves function call for dynamic object, they are handled differently
+ if (m_pPhysicsController1 && !m_pPhysicsController1->IsDyna())
+ // Note that for Bullet, this does not even update the transform of static object
// but merely sets there collision flag to "kinematic" because the synchronization is
- // done differently during physics simulation
+ // done during physics simulation
m_pPhysicsController1->SetSumoTransform(true);
if (m_pGraphicController)
// update the culling tree
@@ -493,6 +551,20 @@ void KX_GameObject::UpdateTransformFunc(SG_IObject* node, void* gameobj, void* s
((KX_GameObject*)gameobj)->UpdateTransform();
}
+void KX_GameObject::SynchronizeTransform()
+{
+ // only used for sensor object, do full synchronization as bullet doesn't do it
+ if (m_pPhysicsController1)
+ m_pPhysicsController1->SetTransform();
+ if (m_pGraphicController)
+ m_pGraphicController->SetGraphicTransform();
+}
+
+void KX_GameObject::SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene)
+{
+ ((KX_GameObject*)gameobj)->SynchronizeTransform();
+}
+
void KX_GameObject::SetDebugColor(unsigned int bgra)
{
@@ -613,6 +685,8 @@ KX_GameObject::SetVisible(
{
if (GetSGNode()) {
m_bVisible = v;
+ if (m_pGraphicController)
+ m_pGraphicController->Activate(m_bVisible);
if (recursive)
setVisible_recursive(GetSGNode(), v);
}
@@ -1081,7 +1155,6 @@ CListValue* KX_GameObject::GetChildrenRecursive()
/* ------- python stuff ---------------------------------------------------*/
PyMethodDef KX_GameObject::Methods[] = {
- {"setWorldPosition", (PyCFunction) KX_GameObject::sPySetWorldPosition, METH_O},
{"applyForce", (PyCFunction) KX_GameObject::sPyApplyForce, METH_VARARGS},
{"applyTorque", (PyCFunction) KX_GameObject::sPyApplyTorque, METH_VARARGS},
{"applyRotation", (PyCFunction) KX_GameObject::sPyApplyRotation, METH_VARARGS},
@@ -1100,7 +1173,7 @@ PyMethodDef KX_GameObject::Methods[] = {
{"disableRigidBody", (PyCFunction)KX_GameObject::sPyDisableRigidBody,METH_NOARGS},
{"applyImpulse", (PyCFunction) KX_GameObject::sPyApplyImpulse, METH_VARARGS},
{"setCollisionMargin", (PyCFunction) KX_GameObject::sPySetCollisionMargin, METH_O},
- {"setParent", (PyCFunction)KX_GameObject::sPySetParent,METH_O},
+ {"setParent", (PyCFunction)KX_GameObject::sPySetParent,METH_VARARGS},
{"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS},
{"setOcclusion",(PyCFunction) KX_GameObject::sPySetOcclusion, METH_VARARGS},
{"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_NOARGS},
@@ -1116,10 +1189,15 @@ PyMethodDef KX_GameObject::Methods[] = {
KX_PYMETHODTABLE_O(KX_GameObject, getDistanceTo),
KX_PYMETHODTABLE_O(KX_GameObject, getVectTo),
KX_PYMETHODTABLE(KX_GameObject, sendMessage),
-
+
+ // dict style access for props
+ {"has_key",(PyCFunction) KX_GameObject::sPyhas_key, METH_O},
+ {"get",(PyCFunction) KX_GameObject::sPyget, METH_VARARGS},
+
// deprecated
{"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_NOARGS},
{"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_O},
+ {"setWorldPosition", (PyCFunction) KX_GameObject::sPySetWorldPosition, METH_O},
{"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_NOARGS},
{"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_O},
{"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_NOARGS},
@@ -1147,13 +1225,14 @@ PyAttributeDef KX_GameObject::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("state", KX_GameObject, pyattr_get_state, pyattr_set_state),
KX_PYATTRIBUTE_RO_FUNCTION("meshes", KX_GameObject, pyattr_get_meshes),
KX_PYATTRIBUTE_RW_FUNCTION("localOrientation",KX_GameObject,pyattr_get_localOrientation,pyattr_set_localOrientation),
- KX_PYATTRIBUTE_RO_FUNCTION("worldOrientation",KX_GameObject,pyattr_get_worldOrientation),
+ KX_PYATTRIBUTE_RW_FUNCTION("worldOrientation",KX_GameObject,pyattr_get_worldOrientation,pyattr_set_worldOrientation),
KX_PYATTRIBUTE_RW_FUNCTION("localPosition", KX_GameObject, pyattr_get_localPosition, pyattr_set_localPosition),
KX_PYATTRIBUTE_RW_FUNCTION("worldPosition", KX_GameObject, pyattr_get_worldPosition, pyattr_set_worldPosition),
- KX_PYATTRIBUTE_RW_FUNCTION("localScaling", KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling),
- KX_PYATTRIBUTE_RO_FUNCTION("worldScaling", KX_GameObject, pyattr_get_worldScaling),
-
- KX_PYATTRIBUTE_RO_FUNCTION("__dict__", KX_GameObject, pyattr_get_dir_dict),
+ KX_PYATTRIBUTE_RW_FUNCTION("localScale", KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling),
+ KX_PYATTRIBUTE_RO_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling),
+ KX_PYATTRIBUTE_RO_FUNCTION("children", KX_GameObject, pyattr_get_children),
+ KX_PYATTRIBUTE_RO_FUNCTION("childrenRecursive", KX_GameObject, pyattr_get_children_recursive),
+ KX_PYATTRIBUTE_RO_FUNCTION("attrDict", KX_GameObject, pyattr_get_attrDict),
/* Experemental, dont rely on these yet */
KX_PYATTRIBUTE_RO_FUNCTION("sensors", KX_GameObject, pyattr_get_sensors),
@@ -1193,8 +1272,8 @@ PyObject* KX_GameObject::PyReplaceMesh(PyObject* value)
PyObject* KX_GameObject::PyEndObject()
{
-
KX_Scene *scene = KX_GetActiveScene();
+
scene->DelayedRemoveObject(this);
Py_RETURN_NONE;
@@ -1208,21 +1287,6 @@ PyObject* KX_GameObject::PyGetPosition()
return PyObjectFrom(NodeGetWorldPosition());
}
-
-Py_ssize_t KX_GameObject::Map_Len(PyObject* self_v)
-{
- KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
-
- if (self==NULL) /* not sure what to do here */
- return 0;
-
- Py_ssize_t len= self->GetPropertyCount();
- if(self->m_attr_dict)
- len += PyDict_Size(self->m_attr_dict);
- return len;
-}
-
-
PyObject *KX_GameObject::Map_GetItem(PyObject *self_v, PyObject *item)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
@@ -1231,7 +1295,7 @@ PyObject *KX_GameObject::Map_GetItem(PyObject *self_v, PyObject *item)
PyObject* pyconvert;
if (self==NULL) {
- PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
return NULL;
}
@@ -1265,7 +1329,7 @@ int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
PyErr_Clear();
if (self==NULL) {
- PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
return -1;
}
@@ -1281,7 +1345,7 @@ int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
if (del==0) {
if(attr_str) PyErr_Format(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key \"%s\" could not be set", attr_str);
- else PyErr_SetString(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key could not be set");
+ else PyErr_SetString(PyExc_KeyError, "del gameOb[key]: KX_GameObject, key could not be deleted");
return -1;
}
else if (self->m_attr_dict) {
@@ -1292,9 +1356,9 @@ int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
int set= 0;
/* as CValue */
- if(attr_str)
+ if(attr_str && BGE_PROXY_CHECK_TYPE(val)==0) /* dont allow GameObjects for eg to be assigned to CValue props */
{
- CValue* vallie = self->ConvertPythonToValue(val);
+ CValue* vallie = self->ConvertPythonToValue(val, ""); /* error unused */
if(vallie)
{
@@ -1345,17 +1409,21 @@ int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
return 0; /* success */
}
-
+/* Cant set the len otherwise it can evaluate as false */
PyMappingMethods KX_GameObject::Mapping = {
- (lenfunc)KX_GameObject::Map_Len, /*inquiry mp_length */
+ (lenfunc)NULL , /*inquiry mp_length */
(binaryfunc)KX_GameObject::Map_GetItem, /*binaryfunc mp_subscript */
(objobjargproc)KX_GameObject::Map_SetItem, /*objobjargproc mp_ass_subscript */
};
-
PyTypeObject KX_GameObject::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_GameObject",
sizeof(PyObjectPlus_Proxy),
0,
@@ -1396,8 +1464,10 @@ PyObject* KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DE
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
KX_GameObject* parent = self->GetParent();
- if (parent)
+ if (parent) {
+ parent->Release(); /* self->GetParent() AddRef's */
return parent->GetProxy();
+ }
Py_RETURN_NONE;
}
@@ -1415,13 +1485,13 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd
MT_Scalar val = PyFloat_AsDouble(value);
if (val < 0.0f) { /* also accounts for non float */
PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
if (spc)
spc->SetMass(val);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1438,13 +1508,13 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF
MT_Scalar val = PyFloat_AsDouble(value);
if (val < 0.0f) { /* also accounts for non float */
PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
if (spc)
spc->SetLinVelocityMin(val);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1461,13 +1531,13 @@ int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF
MT_Scalar val = PyFloat_AsDouble(value);
if (val < 0.0f) { /* also accounts for non float */
PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
if (spc)
spc->SetLinVelocityMax(val);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
@@ -1483,12 +1553,12 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at
int param = PyObject_IsTrue( value );
if (param == -1) {
PyErr_SetString(PyExc_AttributeError, "gameOb.visible = bool: KX_GameObject, expected True or False");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
self->SetVisible(param, false);
self->UpdateBuckets(false);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1502,11 +1572,11 @@ int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_D
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
MT_Point3 pos;
if (!PyVecTo(value, pos))
- return 1;
+ return PY_SET_ATTR_FAIL;
self->NodeSetWorldPosition(pos);
self->NodeUpdateGS(0.f);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1523,11 +1593,11 @@ int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_D
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
MT_Point3 pos;
if (!PyVecTo(value, pos))
- return 1;
+ return PY_SET_ATTR_FAIL;
self->NodeSetLocalPosition(pos);
self->NodeUpdateGS(0.f);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1546,6 +1616,26 @@ PyObject* KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYAT
return PyObjectFrom(self->NodeGetWorldOrientation());
}
+int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+
+ /* if value is not a sequence PyOrientationTo makes an error */
+ MT_Matrix3x3 rot;
+ 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->NodeUpdateGS(0.f);
+ return PY_SET_ATTR_SUCCESS;
+}
+
PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
@@ -1561,12 +1651,12 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT
/* if value is not a sequence PyOrientationTo makes an error */
MT_Matrix3x3 rot;
- if (!PyOrientationTo(value, rot, "gameOb.orientation = sequence: KX_GameObject, "))
- return NULL;
+ if (!PyOrientationTo(value, rot, "gameOb.localOrientation = sequence: KX_GameObject, "))
+ return PY_SET_ATTR_FAIL;
self->NodeSetLocalOrientation(rot);
self->NodeUpdateGS(0.f);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1589,11 +1679,11 @@ int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DE
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
MT_Vector3 scale;
if (!PyVecTo(value, scale))
- return 1;
+ return PY_SET_ATTR_FAIL;
self->NodeSetLocalScale(scale);
self->NodeUpdateGS(0.f);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1615,12 +1705,12 @@ int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF
SG_Node* sg_parent= self->GetSGNode()->GetSGParent();
if (val < 0.0f) { /* also accounts for non float */
PyErr_SetString(PyExc_AttributeError, "gameOb.timeOffset = float: KX_GameObject, expected a float zero or above");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
if (sg_parent && sg_parent->IsSlowParent())
static_cast<KX_SlowParentRelation *>(sg_parent->GetParentRelation())->SetTimeOffset(val);
}
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1639,16 +1729,16 @@ int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attr
if (state_i == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "gameOb.state = int: KX_GameObject, expected an int bit field");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
state |= state_i;
if ((state & ((1<<30)-1)) == 0) {
PyErr_SetString(PyExc_AttributeError, "gameOb.state = int: KX_GameObject, state bitfield was not between 0 and 30 (1<<0 and 1<<29)");
- return 1;
+ return PY_SET_ATTR_FAIL;
}
self->SetState(state);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1657,10 +1747,10 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE
PyObject *meshes= PyList_New(self->m_meshes.size());
int i;
- for(i=0; i < self->m_meshes.size(); i++)
+ for(i=0; i < (int)self->m_meshes.size(); i++)
{
KX_MeshProxy* meshproxy = new KX_MeshProxy(self->m_meshes[i]);
- PyList_SET_ITEM(meshes, i, meshproxy->GetProxy());
+ PyList_SET_ITEM(meshes, i, meshproxy->NewProxy(true));
}
return meshes;
@@ -1669,69 +1759,40 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE
/* experemental! */
PyObject* KX_GameObject::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
- KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- SCA_SensorList& sensors= self->GetSensors();
- PyObject* resultlist = PyList_New(sensors.size());
-
- for (unsigned int index=0;index<sensors.size();index++)
- PyList_SET_ITEM(resultlist, index, sensors[index]->GetProxy());
-
- return resultlist;
+ return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_SENSORS);
}
PyObject* KX_GameObject::pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
- KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- SCA_ControllerList& controllers= self->GetControllers();
- PyObject* resultlist = PyList_New(controllers.size());
-
- for (unsigned int index=0;index<controllers.size();index++)
- PyList_SET_ITEM(resultlist, index, controllers[index]->GetProxy());
-
- return resultlist;
+ return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_CONTROLLERS);
}
PyObject* KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
+ return KX_PythonSeq_CreatePyObject((static_cast<KX_GameObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_ACTUATORS);
+}
+
+PyObject* KX_GameObject::pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- SCA_ActuatorList& actuators= self->GetActuators();
- PyObject* resultlist = PyList_New(actuators.size());
-
- for (unsigned int index=0;index<actuators.size();index++)
- PyList_SET_ITEM(resultlist, index, actuators[index]->GetProxy());
-
- return resultlist;
+ return self->GetChildren()->NewProxy(true);
}
-/* __dict__ only for the purpose of giving useful dir() results */
-PyObject* KX_GameObject::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+PyObject* KX_GameObject::pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
+ return self->GetChildrenRecursive()->NewProxy(true);
+}
+
+PyObject* KX_GameObject::pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
- PyObject *dict_str = PyString_FromString("__dict__");
- PyObject *dict= py_getattr_dict(self->SCA_IObject::py_getattro(dict_str), Type.tp_dict);
- Py_DECREF(dict_str);
-
- if(dict==NULL)
- return NULL;
-
- /* Not super fast getting as a list then making into dict keys but its only for dir() */
- PyObject *list= self->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(self->m_attr_dict)
- PyDict_Update(dict, self->m_attr_dict);
+ if(self->m_attr_dict==NULL)
+ self->m_attr_dict= PyDict_New();
- return dict;
+ Py_INCREF(self->m_attr_dict);
+ return self->m_attr_dict;
}
/* We need these because the macros have a return in them */
@@ -1772,11 +1833,38 @@ PyObject* KX_GameObject::py_getattro(PyObject *attr)
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;
-
- ret= py_setattro__internal(attr, value);
+ int ret= py_setattro__internal(attr, value);
if (ret==PY_SET_ATTR_SUCCESS) {
/* remove attribute in our own dict to avoid double ups */
@@ -1789,7 +1877,7 @@ int KX_GameObject::py_setattro(PyObject *attr, PyObject *value) // py_setattro m
if (ret==PY_SET_ATTR_COERCE_FAIL) {
/* CValue attribute exists, remove CValue and add PyDict value */
- RemoveProperty(STR_String(PyString_AsString(attr)));
+ RemoveProperty(PyString_AsString(attr));
ret= PY_SET_ATTR_MISSING;
}
@@ -1814,16 +1902,18 @@ int KX_GameObject::py_setattro(PyObject *attr, PyObject *value) // py_setattro m
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(STR_String(attr_str))) // XXX - should call CValues instead but its only 2 lines here
- return 0;
+ 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 0;
+ return PY_SET_ATTR_SUCCESS;
PyErr_Format(PyExc_AttributeError, "del gameOb.myAttr: KX_GameObject, attribute \"%s\" dosnt exist", attr_str);
- return 1;
+ return PY_SET_ATTR_MISSING;
}
@@ -2008,14 +2098,8 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* args)
MT_Point3 point(0.0,0.0,0.0);
PyObject* pypos = NULL;
- if (PyArg_ParseTuple(args, "|O:getVelocity", &pypos))
- {
- if (pypos)
- PyVecTo(pypos, point);
- }
- else {
+ if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point)))
return NULL;
- }
if (m_pPhysicsController1)
{
@@ -2075,35 +2159,49 @@ PyObject* KX_GameObject::PyGetParent()
{
ShowDeprecationWarning("getParent()", "the parent property");
KX_GameObject* parent = this->GetParent();
- if (parent)
+ if (parent) {
+ parent->Release(); /* self->GetParent() AddRef's */
return parent->GetProxy();
+ }
Py_RETURN_NONE;
}
-PyObject* KX_GameObject::PySetParent(PyObject* value)
+PyObject* KX_GameObject::PySetParent(PyObject* args)
{
+ KX_Scene *scene = KX_GetActiveScene();
+ PyObject* pyobj;
KX_GameObject *obj;
- if (!ConvertPythonToGameObject(value, &obj, false, "gameOb.setParent(value): KX_GameObject"))
- return NULL;
+ int addToCompound=1, ghost=1;
- this->SetParent(KX_GetActiveScene(), obj);
+ if (!PyArg_ParseTuple(args,"O|ii:setParent", &pyobj, &addToCompound, &ghost)) {
+ return NULL; // Python sets a simple error
+ }
+ if (!ConvertPythonToGameObject(pyobj, &obj, true, "gameOb.setParent(obj): KX_GameObject"))
+ return NULL;
+ if (obj)
+ this->SetParent(scene, obj, addToCompound, ghost);
Py_RETURN_NONE;
}
PyObject* KX_GameObject::PyRemoveParent()
{
KX_Scene *scene = KX_GetActiveScene();
+
this->RemoveParent(scene);
Py_RETURN_NONE;
}
PyObject* KX_GameObject::PyGetChildren()
{
+ ShowDeprecationWarning("getChildren()", "the children property");
+
return GetChildren()->NewProxy(true);
}
PyObject* KX_GameObject::PyGetChildrenRecursive()
{
+ ShowDeprecationWarning("getChildrenRecursive()", "the childrenRecursive property");
+
return GetChildrenRecursive()->NewProxy(true);
}
@@ -2203,23 +2301,15 @@ PyObject* KX_GameObject::PyGetOrientation() //keywords
PyObject* KX_GameObject::PySetOrientation(PyObject* value)
{
ShowDeprecationWarning("setOrientation()", "the orientation property");
- MT_Matrix3x3 matrix;
- if (PyObject_IsMT_Matrix(value, 3) && PyMatTo(value, matrix))
- {
- NodeSetLocalOrientation(matrix);
- NodeUpdateGS(0.f);
- Py_RETURN_NONE;
- }
+ MT_Matrix3x3 rot;
+
+ /* if value is not a sequence PyOrientationTo makes an error */
+ if (!PyOrientationTo(value, rot, "gameOb.setOrientation(sequence): KX_GameObject, "))
+ return NULL;
- MT_Quaternion quat;
- if (PyVecTo(value, quat))
- {
- matrix.setRotation(quat);
- NodeSetLocalOrientation(matrix);
- NodeUpdateGS(0.f);
- Py_RETURN_NONE;
- }
- return NULL;
+ NodeSetLocalOrientation(rot);
+ NodeUpdateGS(0.f);
+ Py_RETURN_NONE;
}
PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* args)
@@ -2256,7 +2346,7 @@ PyObject* KX_GameObject::PyGetAxisVect(PyObject* value)
PyObject* KX_GameObject::PySetPosition(PyObject* value)
{
- ShowDeprecationWarning("setPosition()", "the position property");
+ ShowDeprecationWarning("setPosition()", "the localPosition property");
MT_Point3 pos;
if (PyVecTo(value, pos))
{
@@ -2270,6 +2360,7 @@ PyObject* KX_GameObject::PySetPosition(PyObject* value)
PyObject* KX_GameObject::PySetWorldPosition(PyObject* value)
{
+ ShowDeprecationWarning("setWorldPosition()", "the worldPosition property");
MT_Point3 pos;
if (PyVecTo(value, pos))
{
@@ -2474,6 +2565,34 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
Py_RETURN_NONE;
}
+/* faster then Py_BuildValue since some scripts call raycast a lot */
+static PyObject *none_tuple_3()
+{
+ PyObject *ret= PyTuple_New(3);
+ PyTuple_SET_ITEM(ret, 0, Py_None);
+ PyTuple_SET_ITEM(ret, 1, Py_None);
+ PyTuple_SET_ITEM(ret, 2, Py_None);
+
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ return ret;
+}
+static PyObject *none_tuple_4()
+{
+ PyObject *ret= PyTuple_New(4);
+ PyTuple_SET_ITEM(ret, 0, Py_None);
+ PyTuple_SET_ITEM(ret, 1, Py_None);
+ PyTuple_SET_ITEM(ret, 2, Py_None);
+ PyTuple_SET_ITEM(ret, 3, Py_None);
+
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ return ret;
+}
+
KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
"rayCast(to,from,dist,prop,face,xray,poly): cast a ray and return 3-tuple (object,hit,normal) or 4-tuple (object,hit,normal,polygon) of contact point with object within dist that matches prop.\n"
" If no hit, return (None,None,None) or (None,None,None,None).\n"
@@ -2541,12 +2660,14 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
if (dist != 0.0f) {
MT_Vector3 toDir = toPoint-fromPoint;
if (MT_fuzzyZero(toDir.length2())) {
- return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+ //return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+ return none_tuple_3();
}
toDir.normalize();
toPoint = fromPoint + (dist) * toDir;
} else if (MT_fuzzyZero((toPoint-fromPoint).length2())) {
- return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+ //return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+ return none_tuple_3();
}
PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment();
@@ -2594,9 +2715,11 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
}
// no hit
if (poly)
- return Py_BuildValue("OOOO", Py_None, Py_None, Py_None, Py_None);
+ //return Py_BuildValue("OOOO", Py_None, Py_None, Py_None, Py_None);
+ return none_tuple_4();
else
- return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+ //return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+ return none_tuple_3();
}
KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage,
@@ -2606,6 +2729,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage,
"body = Message body (string)"
"to = Name of object to send the message to")
{
+ KX_Scene *scene = KX_GetActiveScene();
char* subject;
char* body = (char *)"";
char* to = (char *)"";
@@ -2613,12 +2737,58 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage,
if (!PyArg_ParseTuple(args, "s|sss:sendMessage", &subject, &body, &to))
return NULL;
+
+ scene->GetNetworkScene()->SendMessage(to, from, subject, body);
+ Py_RETURN_NONE;
+}
- KX_GetActiveScene()->GetNetworkScene()->SendMessage(to, from, subject, body);
+/* dict style access */
- Py_RETURN_NONE;
+
+/* Matches python dict.get(key, [default]) */
+PyObject* KX_GameObject::Pyget(PyObject *args)
+{
+ PyObject *key;
+ PyObject* def = Py_None;
+ PyObject* ret;
+
+ if (!PyArg_ParseTuple(args, "O|O:get", &key, &def))
+ return NULL;
+
+
+ if(PyString_Check(key)) {
+ CValue *item = GetProperty(PyString_AsString(key));
+ if (item) {
+ ret = item->ConvertValueToPython();
+ if(ret)
+ return ret;
+ else
+ return item->GetProxy();
+ }
+ }
+
+ if (m_attr_dict && (ret=PyDict_GetItem(m_attr_dict, key))) {
+ Py_INCREF(ret);
+ return ret;
+ }
+
+ Py_INCREF(def);
+ return def;
+}
+
+/* Matches python dict.has_key() */
+PyObject* KX_GameObject::Pyhas_key(PyObject* value)
+{
+ if(PyString_Check(value) && GetProperty(PyString_AsString(value)))
+ Py_RETURN_TRUE;
+
+ if (m_attr_dict && PyDict_GetItem(m_attr_dict, value))
+ Py_RETURN_TRUE;
+
+ Py_RETURN_FALSE;
}
+
/* ---------------------------------------------------------------------
* Some stuff taken from the header
* --------------------------------------------------------------------- */
@@ -2641,6 +2811,7 @@ void KX_GameObject::Relink(GEN_Map<GEN_HashedPtr, void*> *map_parameter)
}
}
+
bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok, const char *error_prefix)
{
if (value==NULL) {
@@ -2671,12 +2842,15 @@ bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py
}
}
- if (PyObject_TypeCheck(value, &KX_GameObject::Type)) {
+ if ( PyObject_TypeCheck(value, &KX_GameObject::Type) ||
+ PyObject_TypeCheck(value, &KX_LightObject::Type) ||
+ PyObject_TypeCheck(value, &KX_Camera::Type) )
+ {
*object = static_cast<KX_GameObject*>BGE_PROXY_REF(value);
/* sets the error */
if (*object==NULL) {
- PyErr_Format(PyExc_RuntimeError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix);
+ PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix);
return false;
}
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index ec02dc17b75..dbdea97031d 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -77,6 +77,7 @@ protected:
STR_String m_text;
int m_layer;
std::vector<RAS_MeshObject*> m_meshes;
+ SG_QList m_meshSlots; // head of mesh slots of this
struct Object* m_pBlenderObject;
struct Object* m_pBlenderGroupObject;
@@ -170,7 +171,7 @@ public:
/**
* Sets the parent of this object to a game object
*/
- void SetParent(KX_Scene *scene, KX_GameObject *obj);
+ void SetParent(KX_Scene *scene, KX_GameObject *obj, bool addToCompound=true, bool ghost=true);
/**
* Removes the parent of this object to a game object
@@ -192,11 +193,6 @@ public:
~KX_GameObject(
);
- CValue*
- AddRef() {
- /* temporarily to find memleaks */ return CValue::AddRef();
- }
-
/**
* @section Stuff which is here due to poor design.
* Inherited from CValue and needs an implementation.
@@ -245,7 +241,7 @@ public:
/**
* Inherited from CValue -- returns the name of this object.
*/
- STR_String
+ STR_String&
GetName(
);
@@ -254,15 +250,7 @@ public:
*/
void
SetName(
- STR_String name
- );
-
- /**
- * Inherited from CValue -- does nothing.
- */
- void
- ReplicaSetName(
- STR_String name
+ const char *name
);
/**
@@ -279,9 +267,7 @@ public:
* data owned by this class is deep copied. Called internally
*/
virtual void
- ProcessReplica(
- KX_GameObject* replica
- );
+ ProcessReplica();
/**
* Return the linear velocity of the game object.
@@ -395,6 +381,10 @@ public:
{
m_pGraphicController = graphiccontroller;
}
+ /*
+ * @add/remove the graphic controller to the physic system
+ */
+ void ActivateGraphicController(bool recurse);
/**
* @section Coordinate system manipulation functions
@@ -570,6 +560,13 @@ public:
static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
/**
+ * only used for sensor objects
+ */
+ void SynchronizeTransform();
+
+ static void SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene);
+
+ /**
* Function to set IPO option at start of IPO
*/
void
@@ -816,6 +813,7 @@ public:
*/
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)
@@ -860,7 +858,7 @@ public:
KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
- KX_PYMETHOD_O(KX_GameObject,SetParent);
+ KX_PYMETHOD_VARARGS(KX_GameObject,SetParent);
KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);
KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
@@ -874,6 +872,11 @@ public:
KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
+
+ /* Dict access */
+ KX_PYMETHOD_VARARGS(KX_GameObject,get);
+ KX_PYMETHOD_O(KX_GameObject,has_key);
+
/* attributes */
static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
@@ -893,6 +896,7 @@ public:
static PyObject* pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
@@ -903,9 +907,9 @@ public:
static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- /* for dir(), python3 uses __dir__() */
- static PyObject* pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
/* Experemental! */
static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
index 55a7e2ade60..bd7e09d1dda 100644
--- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp
+++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
@@ -194,7 +194,8 @@ bool KX_IpoSGController::Update(double currentTime)
else
newPosition = m_ipo_start_point + newPosition;
}
- ob->SetLocalPosition(newPosition);
+ if (m_game_object)
+ m_game_object->NodeSetLocalPosition(newPosition);
}
}
//modifies orientation?
@@ -233,7 +234,8 @@ bool KX_IpoSGController::Update(double currentTime)
rotation = m_ipo_start_orient * rotation;
else
rotation = rotation * m_ipo_start_orient;
- ob->SetLocalOrientation(rotation);
+ if (m_game_object)
+ m_game_object->NodeSetLocalOrientation(rotation);
}
} else if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z]) {
if (m_ipo_euler_initialized) {
@@ -265,7 +267,8 @@ bool KX_IpoSGController::Update(double currentTime)
else if (m_ipo_channels_active[OB_DROT_Z]) {
roll += m_ipo_xform.GetDeltaEulerAngles()[2];
}
- ob->SetLocalOrientation(MT_Vector3(yaw, pitch, roll));
+ if (m_game_object)
+ m_game_object->NodeSetLocalOrientation(MT_Vector3(yaw, pitch, roll));
}
} else if (m_ipo_start_initialized) {
// only DROT, treat as Add
@@ -286,7 +289,8 @@ bool KX_IpoSGController::Update(double currentTime)
// dRot are always local
MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll));
rotation = m_ipo_start_orient * rotation;
- ob->SetLocalOrientation(rotation);
+ if (m_game_object)
+ m_game_object->NodeSetLocalOrientation(rotation);
}
}
//modifies scale?
@@ -322,8 +326,8 @@ bool KX_IpoSGController::Update(double currentTime)
if (m_ipo_add) {
newScale = m_ipo_start_scale * newScale;
}
-
- ob->SetLocalScale(newScale);
+ if (m_game_object)
+ m_game_object->NodeSetLocalScale(newScale);
}
m_modified=false;
@@ -342,6 +346,7 @@ SG_Controller* KX_IpoSGController::GetReplica(class SG_Node* destnode)
KX_IpoSGController* iporeplica = new KX_IpoSGController(*this);
// clear object that ipo acts on in the replica.
iporeplica->ClearObject();
+ iporeplica->SetGameObject((KX_GameObject*)destnode->GetSGClientObject());
// dirty hack, ask Gino for a better solution in the ipo implementation
// hacken en zagen, in what we call datahiding, not written for replication :(
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.cpp b/source/gameengine/Ketsji/KX_IPhysicsController.cpp
index a38222c5f7e..673acabd774 100644
--- a/source/gameengine/Ketsji/KX_IPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_IPhysicsController.cpp
@@ -35,9 +35,10 @@
#include "PHY_DynamicTypes.h"
-KX_IPhysicsController::KX_IPhysicsController(bool dyna, bool compound, void* userdata)
+KX_IPhysicsController::KX_IPhysicsController(bool dyna, bool sensor, bool compound, void* userdata)
: m_bDyna(dyna),
+ m_bSensor(sensor),
m_bCompound(compound),
m_suspendDynamics(false),
m_userdata(userdata)
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h
index 10b66da7b76..81c01045071 100644
--- a/source/gameengine/Ketsji/KX_IPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_IPhysicsController.h
@@ -49,11 +49,12 @@ class KX_IPhysicsController : public SG_Controller
{
protected:
bool m_bDyna;
+ bool m_bSensor;
bool m_bCompound;
bool m_suspendDynamics;
void* m_userdata;
public:
- KX_IPhysicsController(bool dyna,bool compound, void* userdata);
+ KX_IPhysicsController(bool dyna,bool sensor,bool compound, void* userdata);
virtual ~KX_IPhysicsController();
@@ -74,6 +75,7 @@ public:
virtual void getOrientation(MT_Quaternion& orn)=0;
virtual void setOrientation(const MT_Matrix3x3& orn)=0;
+ virtual void SetTransform()=0;
//virtual void setOrientation(const MT_Quaternion& orn)=0;
virtual void setPosition(const MT_Point3& pos)=0;
virtual void setScaling(const MT_Vector3& scaling)=0;
@@ -100,10 +102,18 @@ public:
m_bDyna = isDynamic;
}
+ void SetSensor(bool isSensor) {
+ m_bSensor = isSensor;
+ }
+
bool IsDyna(void) {
return m_bDyna;
}
+ bool IsSensor(void) {
+ return m_bSensor;
+ }
+
bool IsCompound(void) {
return m_bCompound;
}
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp
index f04e3c79a8e..3ec0598ac03 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.cpp
+++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp
@@ -164,14 +164,14 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
// result = true if animation has to be continued, false if animation stops
// maybe there are events for us in the queue !
bool bNegativeEvent = false;
- int numevents = 0;
+ bool numevents = false;
bool bIpoStart = false;
curtime -= KX_KetsjiEngine::GetSuspendedDelta();
if (frame)
{
- numevents = m_events.size();
+ numevents = m_posevent || m_negevent;
bNegativeEvent = IsNegativeEvent();
RemoveAllEvents();
}
@@ -273,7 +273,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
{
result = false;
m_bNegativeEvent = false;
- numevents = 0;
+ numevents = false;
}
if (!m_bIpoPlaying)
{
@@ -413,8 +413,13 @@ int KX_IpoActuator::string2mode(char* modename) {
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_IpoActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_IpoActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -440,9 +445,8 @@ PyParentObject KX_IpoActuator::Parents[] = {
};
PyMethodDef KX_IpoActuator::Methods[] = {
- {"set", (PyCFunction) KX_IpoActuator::sPySet, METH_VARARGS, (PY_METHODCHAR)Set_doc},
-
// deprecated
+ {"set", (PyCFunction) KX_IpoActuator::sPySet, METH_VARARGS, (PY_METHODCHAR)Set_doc},
{"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
{"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc},
@@ -460,11 +464,11 @@ PyMethodDef KX_IpoActuator::Methods[] = {
};
PyAttributeDef KX_IpoActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW("startFrame", 0, 300000, KX_IpoActuator, m_startframe),
- KX_PYATTRIBUTE_FLOAT_RW("endFrame", 0, 300000, KX_IpoActuator, m_endframe),
+ KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, 300000, KX_IpoActuator, m_startframe),
+ KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, 300000, KX_IpoActuator, m_endframe),
KX_PYATTRIBUTE_STRING_RW("propName", 0, 64, false, KX_IpoActuator, m_propname),
KX_PYATTRIBUTE_STRING_RW("framePropName", 0, 64, false, KX_IpoActuator, m_framepropname),
- KX_PYATTRIBUTE_INT_RW("type", KX_ACT_IPO_NODEF+1, KX_ACT_IPO_MAX-1, true, KX_IpoActuator, m_type),
+ KX_PYATTRIBUTE_INT_RW("mode", KX_ACT_IPO_NODEF+1, KX_ACT_IPO_MAX-1, true, KX_IpoActuator, m_type),
KX_PYATTRIBUTE_BOOL_RW("useIpoAsForce", KX_IpoActuator, m_ipo_as_force),
KX_PYATTRIBUTE_BOOL_RW("useIpoAdd", KX_IpoActuator, m_ipo_add),
KX_PYATTRIBUTE_BOOL_RW("useIpoLocal", KX_IpoActuator, m_ipo_local),
@@ -477,6 +481,10 @@ 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);
@@ -492,7 +500,7 @@ const char KX_IpoActuator::Set_doc[] =
"\tSet the properties of the actuator.\n";
PyObject* KX_IpoActuator::PySet(PyObject* args) {
- ShowDeprecationWarning("set()", "a number properties");
+ ShowDeprecationWarning("set()", "a range properties");
/* sets modes PLAY, PINGPONG, FLIPPER, LOOPSTOP, LOOPEND */
/* arg 1 = mode string, arg 2 = startframe, arg3 = stopframe, */
@@ -554,7 +562,7 @@ const char KX_IpoActuator::SetStart_doc[] =
"\tSet the frame from which the ipo starts playing.\n";
PyObject* KX_IpoActuator::PySetStart(PyObject* args) {
- ShowDeprecationWarning("setStart()", "the startFrame property");
+ ShowDeprecationWarning("setStart()", "the frameStart property");
float startArg;
if(!PyArg_ParseTuple(args, "f:setStart", &startArg)) {
@@ -570,7 +578,7 @@ const char KX_IpoActuator::GetStart_doc[] =
"getStart()\n"
"\tReturns the frame from which the ipo starts playing.\n";
PyObject* KX_IpoActuator::PyGetStart() {
- ShowDeprecationWarning("getStart()", "the startFrame property");
+ ShowDeprecationWarning("getStart()", "the frameStart property");
return PyFloat_FromDouble(m_startframe);
}
@@ -580,7 +588,7 @@ const char KX_IpoActuator::SetEnd_doc[] =
"\t - frame: last frame to use (int)\n"
"\tSet the frame at which the ipo stops playing.\n";
PyObject* KX_IpoActuator::PySetEnd(PyObject* args) {
- ShowDeprecationWarning("setEnd()", "the endFrame property");
+ ShowDeprecationWarning("setEnd()", "the frameEnd property");
float endArg;
if(!PyArg_ParseTuple(args, "f:setEnd", &endArg)) {
return NULL;
@@ -595,7 +603,7 @@ const char KX_IpoActuator::GetEnd_doc[] =
"getEnd()\n"
"\tReturns the frame at which the ipo stops playing.\n";
PyObject* KX_IpoActuator::PyGetEnd() {
- ShowDeprecationWarning("getEnd()", "the endFrame property");
+ ShowDeprecationWarning("getEnd()", "the frameEnd property");
return PyFloat_FromDouble(m_endframe);
}
@@ -661,7 +669,7 @@ const char KX_IpoActuator::SetType_doc[] =
"\t - mode: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n"
"\tSet the operation mode of the actuator.\n";
PyObject* KX_IpoActuator::PySetType(PyObject* args) {
- ShowDeprecationWarning("setType()", "the type property");
+ ShowDeprecationWarning("setType()", "the mode property");
int typeArg;
if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) {
@@ -680,7 +688,7 @@ const char KX_IpoActuator::GetType_doc[] =
"getType()\n"
"\tReturns the operation mode of the actuator.\n";
PyObject* KX_IpoActuator::PyGetType() {
- ShowDeprecationWarning("getType()", "the type property");
+ ShowDeprecationWarning("getType()", "the mode property");
return PyInt_FromLong(m_type);
}
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h
index 184ad5512de..9ea597def1e 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.h
+++ b/source/gameengine/Ketsji/KX_IpoActuator.h
@@ -128,8 +128,6 @@ public:
virtual CValue* GetReplica() {
KX_IpoActuator* replica = new KX_IpoActuator(*this);//m_float,GetName());
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
};
@@ -142,6 +140,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
//KX_PYMETHOD_DOC
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 83a2fa8a448..b30b79e7f23 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -77,6 +77,8 @@
#include "RAS_FramingManager.h"
#include "stdio.h"
+#include "DNA_world_types.h"
+#include "DNA_scene_types.h"
// If define: little test for Nzc: guarded drawing. If the canvas is
// not valid, skip rendering this frame.
@@ -97,6 +99,8 @@ const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
};
double KX_KetsjiEngine::m_ticrate = DEFAULT_LOGIC_TIC_RATE;
+int KX_KetsjiEngine::m_maxLogicFrame = 5;
+int KX_KetsjiEngine::m_maxPhysicsFrame = 5;
double KX_KetsjiEngine::m_anim_framerate = 25.0;
double KX_KetsjiEngine::m_suspendedtime = 0.0;
double KX_KetsjiEngine::m_suspendeddelta = 0.0;
@@ -145,8 +149,6 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
m_stereo(false),
m_curreye(0),
- m_usedome(false),
-
m_logger(NULL),
// Set up timing info display variables
@@ -164,7 +166,9 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
m_overrideFrameColor(false),
m_overrideFrameColorR(0.0),
m_overrideFrameColorG(0.0),
- m_overrideFrameColorB(0.0)
+ m_overrideFrameColorB(0.0),
+
+ m_usedome(false)
{
// Initialize the time logger
m_logger = new KX_TimeCategoryLogger (25);
@@ -261,9 +265,9 @@ void KX_KetsjiEngine::SetSceneConverter(KX_ISceneConverter* sceneconverter)
m_sceneconverter = sceneconverter;
}
-void KX_KetsjiEngine::InitDome(float size, short res, short mode, short angle, float resbuf, struct Text* text)
+void KX_KetsjiEngine::InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text)
{
- m_dome = new KX_Dome(m_canvas, m_rasterizer, m_rendertools,this, size, res, mode, angle, resbuf, text);
+ m_dome = new KX_Dome(m_canvas, m_rasterizer, m_rendertools,this, res, mode, angle, resbuf, tilt, text);
m_usedome = true;
}
@@ -271,7 +275,6 @@ void KX_KetsjiEngine::RenderDome()
{
GLuint viewport[4]={0};
glGetIntegerv(GL_VIEWPORT,(GLint *)viewport);
-// unsigned int m_viewport[4] = {viewport[0], viewport[1], viewport[2], viewport[3]};
m_dome->SetViewPort(viewport);
@@ -295,11 +298,6 @@ void KX_KetsjiEngine::RenderDome()
return;
KX_SceneList::iterator sceneit;
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
- {
- // do this only once per scene
- (*sceneit)->UpdateMeshTransformations();
- }
int n_renders=m_dome->GetNumberRenders();// usually 4 or 6
for (int i=0;i<n_renders;i++){
@@ -353,7 +351,6 @@ void KX_KetsjiEngine::RenderDome()
m_dome->BindImages(i);
}
-// m_dome->Dome_PostRender(scene, cam, stereomode);
m_canvas->EndFrame();//XXX do we really need that?
m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
@@ -381,7 +378,8 @@ void KX_KetsjiEngine::RenderDome()
m_dome->Draw();
- //run 2dfilters
+ // run the 2dfilters and motion blur once for all the scenes
+ PostRenderFrame();
EndFrame();
}
@@ -398,7 +396,20 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo)
m_firstframe = true;
m_bInitialized = true;
- m_ticrate = DEFAULT_LOGIC_TIC_RATE;
+ // there is always one scene enabled at startup
+ World* world = m_scenes[0]->GetBlenderScene()->world;
+ if (world)
+ {
+ m_ticrate = world->ticrate;
+ m_maxLogicFrame = world->maxlogicstep;
+ m_maxPhysicsFrame = world->maxphystep;
+ }
+ else
+ {
+ m_ticrate = DEFAULT_LOGIC_TIC_RATE;
+ m_maxLogicFrame = 5;
+ m_maxPhysicsFrame = 5;
+ }
if (m_game2ipo)
{
@@ -511,7 +522,8 @@ void KX_KetsjiEngine::EndFrame()
bool KX_KetsjiEngine::NextFrame()
{
-
+ double timestep = 1.0/m_ticrate;
+ double framestep = timestep;
// static hidden::Clock sClock;
m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(),true);
@@ -520,7 +532,7 @@ m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(),true);
//sClock.reset();
if (m_bFixedTime)
- m_clockTime += 1./m_ticrate;
+ m_clockTime += timestep;
else
{
@@ -548,24 +560,29 @@ else
// PIL_sleep_ms(1);
KX_SceneList::iterator sceneit;
- int frameOut = 5;
- if (frames>frameOut)
+ if (frames>m_maxPhysicsFrame)
{
// printf("framedOut: %d\n",frames);
- m_frameTime+=(frames-frameOut)*(1.0/m_ticrate);
- frames = frameOut;
+ m_frameTime+=(frames-m_maxPhysicsFrame)*timestep;
+ frames = m_maxPhysicsFrame;
}
bool doRender = frames>0;
+ if (frames > m_maxLogicFrame)
+ {
+ framestep = (frames*timestep)/m_maxLogicFrame;
+ frames = m_maxLogicFrame;
+ }
+
while (frames)
{
- m_frameTime += 1.0/m_ticrate;
+ m_frameTime += framestep;
for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit)
// for each scene, call the proceed functions
@@ -644,7 +661,7 @@ else
// Perform physics calculations on the scene. This can involve
// many iterations of the physics solver.
- scene->GetPhysicsEnvironment()->proceedDeltaTime(m_frameTime,1.0/m_ticrate);//m_deltatimerealDeltaTime);
+ scene->GetPhysicsEnvironment()->proceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime);
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
SG_SetActiveStage(SG_STAGE_PHYSICS2_UPDATE);
@@ -717,7 +734,7 @@ else
// Perform physics calculations on the scene. This can involve
// many iterations of the physics solver.
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
- scene->GetPhysicsEnvironment()->proceedDeltaTime(m_clockTime,0.f);
+ scene->GetPhysicsEnvironment()->proceedDeltaTime(m_clockTime,timestep,timestep);
// Update scenegraph after physics step. This maps physics calculations
// into node positions.
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
@@ -817,8 +834,8 @@ void KX_KetsjiEngine::Render()
// pass the scene's worldsettings to the rasterizer
SetWorldSettings(scene->GetWorldInfo());
- // do this only once per scene
- scene->UpdateMeshTransformations();
+ // this is now done incrementatlly in KX_Scene::CalculateVisibleMeshes
+ //scene->UpdateMeshTransformations();
// shadow buffers
RenderShadowBuffers(scene);
@@ -906,9 +923,6 @@ void KX_KetsjiEngine::Render()
}
} // if(m_rasterizer->Stereo())
- // run the 2dfilters and motion blur once for all the scenes
- PostRenderFrame();
-
EndFrame();
}
@@ -1000,7 +1014,7 @@ void KX_KetsjiEngine::SetWorldSettings(KX_WorldInfo* wi)
wi->getAmbientColorBlue()
);
- if (m_drawingmode == RAS_IRasterizer::KX_TEXTURED)
+ if (m_drawingmode >= RAS_IRasterizer::KX_SOLID)
{
if (wi->hasMist())
{
@@ -1012,10 +1026,6 @@ void KX_KetsjiEngine::SetWorldSettings(KX_WorldInfo* wi)
wi->getMistColorBlue()
);
}
- else
- {
- m_rasterizer->DisableFog();
- }
}
}
}
@@ -1097,7 +1107,7 @@ void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect
area = userviewport;
}
- else if ( m_overrideCam || (scene->GetName() != m_overrideSceneName) || m_overrideCamUseOrtho ) {
+ else if ( !m_overrideCam || (scene->GetName() != m_overrideSceneName) || m_overrideCamUseOrtho ) {
RAS_FramingManager::ComputeViewport(
scene->GetFramingType(),
m_canvas->GetDisplayArea(),
@@ -1117,16 +1127,13 @@ void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect
void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
{
- CListValue *objectlist = scene->GetObjectList();
+ CListValue *lightlist = scene->GetLightList();
int i, drawmode;
m_rendertools->SetAuxilaryClientInfo(scene);
- for(i=0; i<objectlist->GetCount(); i++) {
- KX_GameObject *gameobj = (KX_GameObject*)objectlist->GetValue(i);
-
- if(!gameobj->IsLight())
- continue;
+ for(i=0; i<lightlist->GetCount(); i++) {
+ KX_GameObject *gameobj = (KX_GameObject*)lightlist->GetValue(i);
KX_LightObject *light = (KX_LightObject*)gameobj;
@@ -1135,7 +1142,7 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
if(m_drawingmode == RAS_IRasterizer::KX_TEXTURED && light->HasShadowBuffer()) {
/* make temporary camera */
RAS_CameraData camdata = RAS_CameraData();
- KX_Camera *cam = new KX_Camera(scene, scene->m_callbacks, camdata, false);
+ KX_Camera *cam = new KX_Camera(scene, scene->m_callbacks, camdata, true, true);
cam->SetName("__shadow__cam__");
MT_Transform camtrans;
@@ -1167,13 +1174,11 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
{
bool override_camera;
RAS_Rect viewport, area;
- float left, right, bottom, top, nearfrust, farfrust, focallength;
- const float ortho = 100.0;
+ float nearfrust, farfrust, focallength;
// KX_Camera* cam = scene->GetActiveCamera();
if (!cam)
return;
-
GetSceneViewport(scene, cam, area, viewport);
// store the computed viewport in the scene
@@ -1191,19 +1196,24 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
override_camera = override_camera && (cam->GetName() == "__default__cam__");
if (override_camera && m_overrideCamUseOrtho) {
- MT_CmMatrix4x4 projmat = m_overrideCamProjMat;
- m_rasterizer->SetProjectionMatrix(projmat);
+ m_rasterizer->SetProjectionMatrix(m_overrideCamProjMat);
+ if (!cam->hasValidProjectionMatrix()) {
+ // needed to get frustrum planes for culling
+ MT_Matrix4x4 projmat;
+ projmat.setValue(m_overrideCamProjMat.getPointer());
+ cam->SetProjectionMatrix(projmat);
+ }
} else if (cam->hasValidProjectionMatrix() && !cam->GetViewport() )
{
m_rasterizer->SetProjectionMatrix(cam->GetProjectionMatrix());
} else
{
RAS_FrameFrustum frustum;
- float lens = cam->GetLens();
bool orthographic = !cam->GetCameraData()->m_perspective;
nearfrust = cam->GetCameraNear();
farfrust = cam->GetCameraFar();
focallength = cam->GetFocalLength();
+ MT_Matrix4x4 projmat;
if(override_camera) {
nearfrust = m_overrideCamNear;
@@ -1211,50 +1221,58 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
}
if (orthographic) {
- lens *= ortho;
- nearfrust = (nearfrust + 1.0)*ortho;
- farfrust *= ortho;
- }
-
- RAS_FramingManager::ComputeFrustum(
- scene->GetFramingType(),
- area,
- viewport,
- lens,
- nearfrust,
- farfrust,
- frustum
- );
- left = frustum.x1 * m_cameraZoom;
- right = frustum.x2 * m_cameraZoom;
- bottom = frustum.y1 * m_cameraZoom;
- top = frustum.y2 * m_cameraZoom;
- nearfrust = frustum.camnear;
- farfrust = frustum.camfar;
+ RAS_FramingManager::ComputeOrtho(
+ scene->GetFramingType(),
+ area,
+ viewport,
+ cam->GetScale(),
+ nearfrust,
+ farfrust,
+ frustum
+ );
+ if (!cam->GetViewport()) {
+ frustum.x1 *= m_cameraZoom;
+ frustum.x2 *= m_cameraZoom;
+ frustum.y1 *= m_cameraZoom;
+ frustum.y2 *= m_cameraZoom;
+ }
+ projmat = m_rasterizer->GetOrthoMatrix(
+ frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
- MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix(
- left, right, bottom, top, nearfrust, farfrust, focallength);
+ } else {
+ RAS_FramingManager::ComputeFrustum(
+ scene->GetFramingType(),
+ area,
+ viewport,
+ cam->GetLens(),
+ nearfrust,
+ farfrust,
+ frustum
+ );
+ if (!cam->GetViewport()) {
+ frustum.x1 *= m_cameraZoom;
+ frustum.x2 *= m_cameraZoom;
+ frustum.y1 *= m_cameraZoom;
+ frustum.y2 *= m_cameraZoom;
+ }
+ projmat = m_rasterizer->GetFrustumMatrix(
+ frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar, focallength);
+ }
cam->SetProjectionMatrix(projmat);
// Otherwise the projection matrix for each eye will be the same...
- if (m_rasterizer->Stereo())
+ if (!orthographic && m_rasterizer->Stereo())
cam->InvalidateProjectionMatrix();
}
MT_Transform camtrans(cam->GetWorldToCamera());
- if (!cam->GetCameraData()->m_perspective)
- camtrans.getOrigin()[2] *= ortho;
MT_Matrix4x4 viewmat(camtrans);
- m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldPosition(),
- cam->GetCameraLocation(), cam->GetCameraOrientation());
+ m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->GetCameraData()->m_perspective);
cam->SetModelviewMatrix(viewmat);
- //redundant, already done in Render()
- //scene->UpdateMeshTransformations();
-
// The following actually reschedules all vertices to be
// redrawn. There is a cache between the actual rescheduling
// and this call though. Visibility is imparted when this call
@@ -1274,6 +1292,9 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
scene->GetPhysicsEnvironment()->debugDrawWorld();
m_rasterizer->FlushDebugLines();
+
+ //it's running once for every scene (i.e. overlay scenes have it running twice). That's not the ideal.
+ PostRenderFrame();
}
void KX_KetsjiEngine::PostRenderFrame()
@@ -1401,7 +1422,7 @@ void KX_KetsjiEngine::RenderDebugProperties()
m_canvas->GetWidth(),
m_canvas->GetHeight());
double time = m_logger->GetAverage((KX_TimeCategory)j);
- debugtxt.Format("%2.2f %%", time/tottime * 100.f);
+ debugtxt.Format("%.3fms (%2.2f %%)", time*1000.f, time/tottime * 100.f);
m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
debugtxt.Ptr(),
xcoord + 60 ,ycoord,
@@ -1719,6 +1740,26 @@ void KX_KetsjiEngine::SetTicRate(double ticrate)
m_ticrate = ticrate;
}
+int KX_KetsjiEngine::GetMaxLogicFrame()
+{
+ return m_maxLogicFrame;
+}
+
+void KX_KetsjiEngine::SetMaxLogicFrame(int frame)
+{
+ m_maxLogicFrame = frame;
+}
+
+int KX_KetsjiEngine::GetMaxPhysicsFrame()
+{
+ return m_maxPhysicsFrame;
+}
+
+void KX_KetsjiEngine::SetMaxPhysicsFrame(int frame)
+{
+ m_maxPhysicsFrame = frame;
+}
+
double KX_KetsjiEngine::GetAnimFrameRate()
{
return m_anim_framerate;
@@ -1729,6 +1770,11 @@ double KX_KetsjiEngine::GetClockTime(void) const
return m_clockTime;
}
+double KX_KetsjiEngine::GetRealTime(void) const
+{
+ return m_kxsystem->GetTimeInSeconds();
+}
+
void KX_KetsjiEngine::SetAnimFrameRate(double framerate)
{
m_anim_framerate = framerate;
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h
index a8ccd6100d7..6fa379e551a 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.h
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h
@@ -103,6 +103,8 @@ private:
double m_previousClockTime;//previous clock time
double m_remainingTime;
+ static int m_maxLogicFrame; /* maximum number of consecutive logic frame */
+ static int m_maxPhysicsFrame; /* maximum number of consecutive physics frame */
static double m_ticrate;
static double m_anim_framerate; /* for animation playback only - ipo and action */
@@ -210,7 +212,7 @@ public:
RAS_IRenderTools* GetRenderTools(){return m_rendertools;};
/// Dome functions
- void InitDome(float size, short res, short mode, short angle, float resbuf, struct Text* text);
+ void InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text);
void EndDome();
void RenderDome();
bool m_usedome;
@@ -269,6 +271,7 @@ public:
*/
double GetClockTime(void) const;
+ double GetRealTime(void) const;
/**
* Returns the difference between the local time of the scene (when it
* was running and not suspended) and the "curtime"
@@ -283,6 +286,22 @@ public:
* Sets the number of logic updates per second.
*/
static void SetTicRate(double ticrate);
+ /**
+ * Gets the maximum number of logic frame before render frame
+ */
+ static int GetMaxLogicFrame();
+ /**
+ * Sets the maximum number of logic frame before render frame
+ */
+ static void SetMaxLogicFrame(int frame);
+ /**
+ * Gets the maximum number of physics frame before render frame
+ */
+ static int GetMaxPhysicsFrame();
+ /**
+ * Sets the maximum number of physics frame before render frame
+ */
+ static void SetMaxPhysicsFrame(int frame);
/**
* Gets the framerate for playing animations. (actions and ipos)
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index 713838c88ec..fe575384a35 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -82,10 +82,7 @@ CValue* KX_LightObject::GetReplica()
KX_LightObject* replica = new KX_LightObject(*this);
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
- ProcessReplica(replica);
+ replica->ProcessReplica();
replica->m_lightobj.m_worldmatrix = replica->GetOpenGLMatrixPtr();
m_rendertools->AddLight(&replica->m_lightobj);
@@ -105,8 +102,11 @@ void KX_LightObject::Update()
{
GPULamp *lamp;
- if((lamp = GetGPULamp())) {
+ if((lamp = GetGPULamp()) != NULL && GetSGNode()) {
float obmat[4][4];
+ // lights don't get their openGL matrix updated, do it now
+ if (GetSGNode()->IsDirty())
+ GetOpenGLMatrix();
double *dobmat = GetOpenGLMatrixPtr()->getPointer();
for(int i=0; i<4; i++)
@@ -114,6 +114,8 @@ void KX_LightObject::Update()
obmat[i][j] = (float)*dobmat;
GPU_lamp_update(lamp, m_lightobj.m_layer, obmat);
+ GPU_lamp_update_colors(lamp, m_lightobj.m_red, m_lightobj.m_green,
+ m_lightobj.m_blue, m_lightobj.m_energy);
}
}
@@ -163,8 +165,7 @@ void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_T
/* setup rasterizer transformations */
ras->SetProjectionMatrix(projectionmat);
- ras->SetViewMatrix(modelviewmat, cam->NodeGetWorldPosition(),
- cam->GetCameraLocation(), cam->GetCameraOrientation());
+ ras->SetViewMatrix(modelviewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->GetCameraData()->m_perspective);
}
void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras)
@@ -173,160 +174,23 @@ void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras)
GPU_lamp_shadow_buffer_unbind(lamp);
}
-PyObject* KX_LightObject::py_getattro(PyObject *attr)
-{
- char *attr_str= PyString_AsString(attr);
-
- if (!strcmp(attr_str, "layer"))
- return PyInt_FromLong(m_lightobj.m_layer);
-
- if (!strcmp(attr_str, "energy"))
- return PyFloat_FromDouble(m_lightobj.m_energy);
-
- if (!strcmp(attr_str, "distance"))
- return PyFloat_FromDouble(m_lightobj.m_distance);
-
- if (!strcmp(attr_str, "colour") || !strcmp(attr_str, "color"))
- return Py_BuildValue("[fff]", m_lightobj.m_red, m_lightobj.m_green, m_lightobj.m_blue);
-
- if (!strcmp(attr_str, "lin_attenuation"))
- return PyFloat_FromDouble(m_lightobj.m_att1);
-
- if (!strcmp(attr_str, "quad_attenuation"))
- return PyFloat_FromDouble(m_lightobj.m_att2);
-
- if (!strcmp(attr_str, "spotsize"))
- return PyFloat_FromDouble(m_lightobj.m_spotsize);
-
- if (!strcmp(attr_str, "spotblend"))
- return PyFloat_FromDouble(m_lightobj.m_spotblend);
-
- if (!strcmp(attr_str, "SPOT"))
- return PyInt_FromLong(RAS_LightObject::LIGHT_SPOT);
-
- if (!strcmp(attr_str, "SUN"))
- return PyInt_FromLong(RAS_LightObject::LIGHT_SUN);
-
- if (!strcmp(attr_str, "NORMAL"))
- return PyInt_FromLong(RAS_LightObject::LIGHT_NORMAL);
-
- if (!strcmp(attr_str, "type"))
- return PyInt_FromLong(m_lightobj.m_type);
-
- py_getattro_up(KX_GameObject);
-}
-
+/* ------------------------------------------------------------------------- */
+/* Python Integration Hooks */
+/* ------------------------------------------------------------------------- */
-int KX_LightObject::py_setattro(PyObject *attr, PyObject *pyvalue)
-{
- char *attr_str= PyString_AsString(attr);
-
- if (PyInt_Check(pyvalue))
- {
- int value = PyInt_AsLong(pyvalue);
- if (!strcmp(attr_str, "layer"))
- {
- m_lightobj.m_layer = value;
- return PY_SET_ATTR_SUCCESS;
- }
-
- if (!strcmp(attr_str, "type"))
- {
- if (value >= RAS_LightObject::LIGHT_SPOT && value <= RAS_LightObject::LIGHT_NORMAL)
- m_lightobj.m_type = (RAS_LightObject::LightType) value;
- return PY_SET_ATTR_SUCCESS;
- }
- }
-
- if (PyFloat_Check(pyvalue) || PyInt_Check(pyvalue))
- {
- float value = PyFloat_AsDouble(pyvalue);
- if (!strcmp(attr_str, "energy"))
- {
- m_lightobj.m_energy = value;
- return PY_SET_ATTR_SUCCESS;
- }
-
- if (!strcmp(attr_str, "distance"))
- {
- m_lightobj.m_distance = value;
- return PY_SET_ATTR_SUCCESS;
- }
-
- if (!strcmp(attr_str, "lin_attenuation"))
- {
- m_lightobj.m_att1 = value;
- return PY_SET_ATTR_SUCCESS;
- }
-
- if (!strcmp(attr_str, "quad_attenuation"))
- {
- m_lightobj.m_att2 = value;
- return PY_SET_ATTR_SUCCESS;
- }
-
- if (!strcmp(attr_str, "spotsize"))
- {
- m_lightobj.m_spotsize = value;
- return PY_SET_ATTR_SUCCESS;
- }
-
- if (!strcmp(attr_str, "spotblend"))
- {
- m_lightobj.m_spotblend = value;
- return PY_SET_ATTR_SUCCESS;
- }
- }
-
- if (PySequence_Check(pyvalue))
- {
- if (!strcmp(attr_str, "colour") || !strcmp(attr_str, "color"))
- {
- MT_Vector3 color;
- if (PyVecTo(pyvalue, color))
- {
- m_lightobj.m_red = color[0];
- m_lightobj.m_green = color[1];
- m_lightobj.m_blue = color[2];
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
- }
- }
-
- if (!strcmp(attr_str, "SPOT") || !strcmp(attr_str, "SUN") || !strcmp(attr_str, "NORMAL"))
- {
- PyErr_Format(PyExc_RuntimeError, "Attribute %s is read only.", attr_str);
- return PY_SET_ATTR_FAIL;
- }
-
- return KX_GameObject::py_setattro(attr, pyvalue);
+PyObject* KX_LightObject::py_getattro_dict() {
+ py_getattro_dict_up(KX_GameObject);
}
-PyMethodDef KX_LightObject::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_LightObject::Attributes[] = {
- KX_PYATTRIBUTE_DUMMY("layer"),
- KX_PYATTRIBUTE_DUMMY("energy"),
- KX_PYATTRIBUTE_DUMMY("distance"),
- KX_PYATTRIBUTE_DUMMY("colour"),
- KX_PYATTRIBUTE_DUMMY("color"),
- KX_PYATTRIBUTE_DUMMY("lin_attenuation"),
- KX_PYATTRIBUTE_DUMMY("quad_attenuation"),
- KX_PYATTRIBUTE_DUMMY("spotsize"),
- KX_PYATTRIBUTE_DUMMY("spotblend"),
- KX_PYATTRIBUTE_DUMMY("SPOT"),
- KX_PYATTRIBUTE_DUMMY("SUN"),
- KX_PYATTRIBUTE_DUMMY("NORMAL"),
- KX_PYATTRIBUTE_DUMMY("type"),
- { NULL } //Sentinel
-};
PyTypeObject KX_LightObject::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_LightObject",
sizeof(PyObjectPlus_Proxy),
0,
@@ -352,3 +216,103 @@ PyParentObject KX_LightObject::Parents[] = {
&CValue::Type,
NULL
};
+
+PyMethodDef KX_LightObject::Methods[] = {
+ {NULL,NULL} //Sentinel
+};
+
+PyAttributeDef KX_LightObject::Attributes[] = {
+ KX_PYATTRIBUTE_INT_RW("layer", 1, 20, true, KX_LightObject, m_lightobj.m_layer),
+ KX_PYATTRIBUTE_FLOAT_RW("energy", 0, 10, KX_LightObject, m_lightobj.m_energy),
+ KX_PYATTRIBUTE_FLOAT_RW("distance", 0.01, 5000, KX_LightObject, m_lightobj.m_distance),
+ KX_PYATTRIBUTE_RW_FUNCTION("color", KX_LightObject, pyattr_get_color, pyattr_set_color),
+ KX_PYATTRIBUTE_RW_FUNCTION("colour", KX_LightObject, pyattr_get_color, pyattr_set_color),
+ KX_PYATTRIBUTE_FLOAT_RW("lin_attenuation", 0, 1, KX_LightObject, m_lightobj.m_att1),
+ KX_PYATTRIBUTE_FLOAT_RW("quad_attenuation", 0, 1, KX_LightObject, m_lightobj.m_att2),
+ KX_PYATTRIBUTE_FLOAT_RW("spotsize", 1, 180, KX_LightObject, m_lightobj.m_spotsize),
+ KX_PYATTRIBUTE_FLOAT_RW("spotblend", 0, 1, KX_LightObject, m_lightobj.m_spotblend),
+ KX_PYATTRIBUTE_RO_FUNCTION("SPOT", KX_LightObject, pyattr_get_typeconst),
+ KX_PYATTRIBUTE_RO_FUNCTION("SUN", KX_LightObject, pyattr_get_typeconst),
+ KX_PYATTRIBUTE_RO_FUNCTION("NORMAL", KX_LightObject, pyattr_get_typeconst),
+ KX_PYATTRIBUTE_RW_FUNCTION("type", KX_LightObject, pyattr_get_type, pyattr_set_type),
+ { NULL } //Sentinel
+};
+
+PyObject* KX_LightObject::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
+ return Py_BuildValue("[fff]", self->m_lightobj.m_red, self->m_lightobj.m_green, self->m_lightobj.m_blue);
+}
+
+int KX_LightObject::pyattr_set_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
+
+ MT_Vector3 color;
+ if (PyVecTo(value, color))
+ {
+ self->m_lightobj.m_red = color[0];
+ self->m_lightobj.m_green = color[1];
+ self->m_lightobj.m_blue = color[2];
+ return PY_SET_ATTR_SUCCESS;
+ }
+ return PY_SET_ATTR_FAIL;
+}
+
+PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ PyObject* retvalue;
+
+ const char* type = attrdef->m_name;
+
+ if(strcmp(type, "SPOT")) {
+ retvalue = PyInt_FromLong(RAS_LightObject::LIGHT_SPOT);
+ } else if (strcmp(type, "SUN")) {
+ retvalue = PyInt_FromLong(RAS_LightObject::LIGHT_SUN);
+ } else if (strcmp(type, "NORMAL")) {
+ retvalue = PyInt_FromLong(RAS_LightObject::LIGHT_NORMAL);
+ }
+
+ return retvalue;
+}
+
+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);
+}
+
+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);
+ 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;
+ }
+
+ switch(val) {
+ case 0:
+ self->m_lightobj.m_type = self->m_lightobj.LIGHT_SPOT;
+ break;
+ case 1:
+ self->m_lightobj.m_type = self->m_lightobj.LIGHT_SUN;
+ break;
+ case 2:
+ self->m_lightobj.m_type = self->m_lightobj.LIGHT_NORMAL;
+ break;
+ }
+
+ 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 4559954c8d7..35f25515e3b 100644
--- a/source/gameengine/Ketsji/KX_Light.h
+++ b/source/gameengine/Ketsji/KX_Light.h
@@ -63,8 +63,16 @@ public:
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);
+ static int pyattr_set_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value);
+ static PyObject* pyattr_get_typeconst(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value);
+
virtual bool IsLight(void) { return true; }
};
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index 6be1da55ff8..11effa1ca98 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -46,8 +46,13 @@
#include "PyObjectPlus.h"
PyTypeObject KX_MeshProxy::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_MeshProxy",
sizeof(PyObjectPlus_Proxy),
0,
@@ -66,7 +71,6 @@ PyTypeObject KX_MeshProxy::Type = {
PyParentObject KX_MeshProxy::Parents[] = {
&KX_MeshProxy::Type,
- &SCA_IObject::Type,
&CValue::Type,
&PyObjectPlus::Type,
NULL
@@ -105,17 +109,21 @@ void KX_MeshProxy::SetMeshModified(bool v)
PyObject* KX_MeshProxy::py_getattro(PyObject *attr)
{
- py_getattro_up(SCA_IObject);
+ 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(SCA_IObject);
+ py_setattro_up(CValue);
}
KX_MeshProxy::KX_MeshProxy(RAS_MeshObject* mesh)
- : SCA_IObject(&Type), m_meshobj(mesh)
+ : CValue(&Type), m_meshobj(mesh)
{
}
@@ -131,10 +139,9 @@ CValue* KX_MeshProxy::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValu
const STR_String & KX_MeshProxy::GetText() {return m_meshobj->GetName();};
double KX_MeshProxy::GetNumber() { return -1;}
-STR_String KX_MeshProxy::GetName() { return m_meshobj->GetName();}
-void KX_MeshProxy::SetName(STR_String name) { };
+STR_String& KX_MeshProxy::GetName() { return m_meshobj->GetName();}
+void KX_MeshProxy::SetName(const char *name) { };
CValue* KX_MeshProxy::GetReplica() { return NULL;}
-void KX_MeshProxy::ReplicaSetName(STR_String name) {};
// stuff for python integration
@@ -213,24 +220,20 @@ PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* args, PyObject* kwds)
PyObject* KX_MeshProxy::PyGetVertex(PyObject* args, PyObject* kwds)
{
- int vertexindex= 1;
- int matindex= 1;
- PyObject* vertexob = NULL;
+ int vertexindex;
+ int matindex;
- if (PyArg_ParseTuple(args,"ii:getVertex",&matindex,&vertexindex))
- {
- RAS_TexVert* vertex = m_meshobj->GetVertex(matindex,vertexindex);
- if (vertex)
- {
- vertexob = (new KX_VertexProxy(this, vertex))->NewProxy(true);
- }
- }
- else {
+ if (!PyArg_ParseTuple(args,"ii:getVertex",&matindex,&vertexindex))
+ return NULL;
+
+ RAS_TexVert* vertex = m_meshobj->GetVertex(matindex,vertexindex);
+
+ if(vertex==NULL) {
+ PyErr_SetString(PyExc_ValueError, "mesh.getVertex(mat_idx, vert_idx): KX_MeshProxy, could not get a vertex at the given indicies");
return NULL;
}
-
- return vertexob;
-
+
+ return (new KX_VertexProxy(this, vertex))->NewProxy(true);
}
PyObject* KX_MeshProxy::PyGetPolygon(PyObject* args, PyObject* kwds)
@@ -262,8 +265,12 @@ PyObject* KX_MeshProxy::PyGetPolygon(PyObject* args, PyObject* kwds)
KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh,
"Reinstance the physics mesh.")
{
+#if 0
//this needs to be reviewed, it is dependend on Sumo/Solid. Who is using this ?
- Py_RETURN_NONE;//(KX_ReInstanceShapeFromMesh(m_meshobj)) ? Py_RETURN_TRUE : Py_RETURN_FALSE;
+ if(KX_ReInstanceShapeFromMesh(m_meshobj))
+ Py_RETURN_TRUE;
+#endif
+ Py_RETURN_FALSE;
}
PyObject* KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -341,7 +348,7 @@ bool ConvertPythonToMesh(PyObject * value, RAS_MeshObject **object, bool py_none
/* sets the error */
if (*object==NULL) {
- PyErr_Format(PyExc_RuntimeError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix);
+ PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix);
return false;
}
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h
index aeecefc09e6..bfdd4be4118 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.h
+++ b/source/gameengine/Ketsji/KX_MeshProxy.h
@@ -34,7 +34,7 @@
/* utility conversion function */
bool ConvertPythonToMesh(PyObject * value, class RAS_MeshObject **object, bool py_none_ok, const char *error_prefix);
-class KX_MeshProxy : public SCA_IObject
+class KX_MeshProxy : public CValue
{
Py_Header;
@@ -51,13 +51,13 @@ public:
virtual const STR_String & GetText();
virtual double GetNumber();
virtual RAS_MeshObject* GetMesh() { return m_meshobj; }
- virtual STR_String GetName();
- virtual void SetName(STR_String name); // Set the name of the value
- virtual void ReplicaSetName(STR_String name);
+ virtual STR_String& GetName();
+ virtual void SetName(const char *name); // Set the name of the value
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
diff --git a/source/gameengine/Ketsji/KX_MotionState.cpp b/source/gameengine/Ketsji/KX_MotionState.cpp
index b4d58dccfdf..60455d33312 100644
--- a/source/gameengine/Ketsji/KX_MotionState.cpp
+++ b/source/gameengine/Ketsji/KX_MotionState.cpp
@@ -73,6 +73,11 @@ void KX_MotionState::getWorldOrientation(float* ori)
mat.getValue(ori);
}
+void KX_MotionState::setWorldOrientation(const float* ori)
+{
+ m_node->SetLocalOrientation(ori);
+}
+
void KX_MotionState::setWorldPosition(float posX,float posY,float posZ)
{
m_node->SetLocalPosition(MT_Point3(posX,posY,posZ));
diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h
index 7ba3ca2f85c..0e43e88fbeb 100644
--- a/source/gameengine/Ketsji/KX_MotionState.h
+++ b/source/gameengine/Ketsji/KX_MotionState.h
@@ -45,6 +45,7 @@ public:
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();
};
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index 87b5c81392d..fde10a493db 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -86,7 +86,7 @@ void KX_MouseFocusSensor::Init()
m_hitNormal.setValue(0,0,1);
}
-bool KX_MouseFocusSensor::Evaluate(CValue* event)
+bool KX_MouseFocusSensor::Evaluate()
{
bool result = false;
bool obHasFocus = false;
@@ -119,7 +119,7 @@ bool KX_MouseFocusSensor::Evaluate(CValue* event)
* mode is never used, because the converter never makes this
* sensor for a mouse-key event. It is here for
* completeness. */
- result = SCA_MouseSensor::Evaluate(event);
+ result = SCA_MouseSensor::Evaluate();
m_positive_event = (m_val!=0);
}
@@ -197,13 +197,15 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam)
* division by 0.0...*/
RAS_Rect area, viewport;
+ short m_y_inv = m_kxengine->GetCanvas()->GetHeight()-m_y;
+
m_kxengine->GetSceneViewport(m_kxscene, cam, area, viewport);
/* Check if the mouse is in the viewport */
if (( m_x < viewport.m_x2 && // less then right
m_x > viewport.m_x1 && // more then then left
- m_y < viewport.m_y2 && // below top
- m_y > viewport.m_y1) == 0) // above bottom
+ m_y_inv < viewport.m_y2 && // below top
+ m_y_inv > viewport.m_y1) == 0) // above bottom
{
return false;
}
@@ -217,6 +219,10 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam)
MT_Vector4 frompoint;
MT_Vector4 topoint;
+ /* m_y_inv - inverting for a bounds check is only part of it, now make relative to view bounds */
+ m_y_inv = (viewport.m_y2 - m_y_inv) + viewport.m_y1;
+
+
/* There's some strangeness I don't fully get here... These values
* _should_ be wrong! - see from point Z values */
@@ -229,19 +235,18 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam)
* behind of the near and far clip planes.
*/
frompoint.setValue( (2 * (m_x-x_lb) / width) - 1.0,
- 1.0 - (2 * (m_y - y_lb) / height),
+ 1.0 - (2 * (m_y_inv - y_lb) / height),
+ /*cam->GetCameraData()->m_perspective ? 0.0:cdata->m_clipstart,*/ /* real clipstart is scaled in ortho for some reason, zero is ok */
0.0, /* nearclip, see above comments */
1.0 );
topoint.setValue( (2 * (m_x-x_lb) / width) - 1.0,
- 1.0 - (2 * (m_y-y_lb) / height),
- 1.0, /* farclip, see above comments */
+ 1.0 - (2 * (m_y_inv-y_lb) / height),
+ cam->GetCameraData()->m_perspective ? 1.0:cam->GetCameraData()->m_clipend, /* farclip, see above comments */
1.0 );
/* camera to world */
MT_Transform wcs_camcs_tranform = cam->GetWorldToCamera();
- if (!cam->GetCameraData()->m_perspective)
- wcs_camcs_tranform.getOrigin()[2] *= 100.0;
MT_Transform cams_wcs_transform;
cams_wcs_transform.invert(wcs_camcs_tranform);
@@ -335,8 +340,13 @@ const MT_Vector3& KX_MouseFocusSensor::HitNormal() const
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_MouseFocusSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_MouseFocusSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -387,6 +397,10 @@ 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"
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
index 8de1f88c5c3..29d674eb305 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
@@ -63,13 +63,13 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
virtual CValue* GetReplica() {
CValue* replica = new KX_MouseFocusSensor(*this);
// this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
};
/**
* @attention Overrides default evaluate.
*/
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual void Init();
virtual bool IsPositiveTrigger() {
@@ -89,7 +89,8 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* py_getattro(PyObject *attr);
+ 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 0489b7090e9..44842b7f5b3 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ b/source/gameengine/Ketsji/KX_NearSensor.cpp
@@ -36,6 +36,7 @@
#include "KX_Scene.h" // needed to create a replica
#include "PHY_IPhysicsEnvironment.h"
#include "PHY_IPhysicsController.h"
+#include "PHY_IMotionState.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -62,7 +63,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
{
gameobj->getClientInfo()->m_sensors.remove(this);
- m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::NEAR);
+ m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::SENSOR);
m_client_info->m_sensors.push_back(this);
//DT_ShapeHandle shape = (DT_ShapeHandle) vshape;
@@ -81,81 +82,50 @@ void KX_NearSensor::SynchronizeTransform()
// not linked to the parent object, must synchronize it.
if (m_physCtrl)
{
+ PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
KX_GameObject* parent = ((KX_GameObject*)GetParent());
- MT_Vector3 pos = parent->NodeGetWorldPosition();
- MT_Quaternion orn = parent->NodeGetWorldOrientation().getRotation();
- m_physCtrl->setPosition(pos.x(),pos.y(),pos.z());
- m_physCtrl->setOrientation(orn.x(),orn.y(),orn.z(),orn.w());
- m_physCtrl->calcXform();
+ const MT_Point3& pos = parent->NodeGetWorldPosition();
+ float ori[12];
+ parent->NodeGetWorldOrientation().getValue(ori);
+ motionState->setWorldPosition(pos[0], pos[1], pos[2]);
+ motionState->setWorldOrientation(ori);
+ m_physCtrl->WriteMotionStateToDynamics(true);
}
}
-void KX_NearSensor::RegisterSumo(KX_TouchEventManager *touchman)
-{
- if (m_physCtrl)
- {
- touchman->GetPhysicsEnvironment()->addSensor(m_physCtrl);
- }
-}
-
-void KX_NearSensor::UnregisterSumo(KX_TouchEventManager* touchman)
+CValue* KX_NearSensor::GetReplica()
{
- if (m_physCtrl)
- {
- touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl);
- }
+ KX_NearSensor* replica = new KX_NearSensor(*this);
+ replica->ProcessReplica();
+ return replica;
}
-CValue* KX_NearSensor::GetReplica()
+void KX_NearSensor::ProcessReplica()
{
- KX_NearSensor* replica = new KX_NearSensor(*this);
- replica->m_colliders = new CListValue();
- replica->Init();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ KX_TouchSensor::ProcessReplica();
- replica->m_client_info = new KX_ClientObjectInfo(m_client_info->m_gameobject, KX_ClientObjectInfo::NEAR);
+ m_client_info = new KX_ClientObjectInfo(m_client_info->m_gameobject, KX_ClientObjectInfo::SENSOR);
- if (replica->m_physCtrl)
+ if (m_physCtrl)
{
- replica->m_physCtrl = replica->m_physCtrl->GetReplica();
- if (replica->m_physCtrl)
+ m_physCtrl = m_physCtrl->GetReplica();
+ if (m_physCtrl)
{
//static_cast<KX_TouchEventManager*>(m_eventmgr)->GetPhysicsEnvironment()->addSensor(replica->m_physCtrl);
- replica->m_physCtrl->SetMargin(m_Margin);
- replica->m_physCtrl->setNewClientInfo(replica->m_client_info);
+ m_physCtrl->SetMargin(m_Margin);
+ m_physCtrl->setNewClientInfo(m_client_info);
}
}
- //Wrong: the parent object could be a child, this code works only if it is a root parent.
- //Anyway, at this stage, the parent object is already synchronized, nothing to do.
- //bool parentUpdated = false;
- //((KX_GameObject*)replica->GetParent())->GetSGNode()->ComputeWorldTransforms(NULL, parentUpdated);
- replica->SynchronizeTransform();
-
- return replica;
}
-
-
void KX_NearSensor::ReParent(SCA_IObject* parent)
{
+ SCA_ISensor::ReParent(parent);
m_client_info->m_gameobject = static_cast<KX_GameObject*>(parent);
m_client_info->m_sensors.push_back(this);
-
-
-/* KX_ClientObjectInfo *client_info = gameobj->getClientInfo();
- client_info->m_gameobject = gameobj;
- client_info->m_auxilary_info = NULL;
-
- client_info->m_sensors.push_back(this);
- SCA_ISensor::ReParent(parent);
-*/
- //Not needed, was done in GetReplica() already
- //bool parentUpdated = false;
- //((KX_GameObject*)GetParent())->GetSGNode()->ComputeWorldTransforms(NULL,parentUpdated);
- //SynchronizeTransform();
- SCA_ISensor::ReParent(parent);
+ //Synchronize here with the actual parent.
+ SynchronizeTransform();
}
@@ -177,7 +147,7 @@ KX_NearSensor::~KX_NearSensor()
}
-bool KX_NearSensor::Evaluate(CValue* event)
+bool KX_NearSensor::Evaluate()
{
bool result = false;
// KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
@@ -286,8 +256,13 @@ bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData
/* ------------------------------------------------------------------------- */
PyTypeObject KX_NearSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_NearSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -334,6 +309,10 @@ 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 26c5feb4e67..63099e181a0 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.h
+++ b/source/gameengine/Ketsji/KX_NearSensor.h
@@ -70,19 +70,21 @@ public:
virtual ~KX_NearSensor();
virtual void SynchronizeTransform();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual void ProcessReplica();
+ virtual bool Evaluate();
virtual void ReParent(SCA_IObject* parent);
virtual bool NewHandleCollision(void* obj1,void* obj2,
const PHY_CollData * coll_data);
virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2);
- virtual void RegisterSumo(KX_TouchEventManager *touchman);
- virtual void UnregisterSumo(KX_TouchEventManager* touchman);
+ virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2) { return false; };
+ virtual sensortype GetSensorType() { return ST_NEAR; }
/* --------------------------------------------------------------------- */
/* 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 861c5757971..eaae04d406d 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
@@ -31,6 +31,7 @@
#include "KX_ObjectActuator.h"
#include "KX_GameObject.h"
+#include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus?
#include "KX_IPhysicsController.h"
#ifdef HAVE_CONFIG_H
@@ -44,6 +45,7 @@
KX_ObjectActuator::
KX_ObjectActuator(
SCA_IObject* gameobj,
+ KX_GameObject* refobj,
const MT_Vector3& force,
const MT_Vector3& torque,
const MT_Vector3& dloc,
@@ -68,6 +70,7 @@ KX_ObjectActuator(
m_previous_error(0.0,0.0,0.0),
m_error_accumulator(0.0,0.0,0.0),
m_bitLocalFlag (flag),
+ m_reference(refobj),
m_active_combined_velocity (false),
m_linear_damping_active(false),
m_angular_damping_active(false)
@@ -76,10 +79,20 @@ KX_ObjectActuator(
{
// in servo motion, the force is local if the target velocity is local
m_bitLocalFlag.Force = m_bitLocalFlag.LinearVelocity;
+
+ m_pid = m_torque;
}
+ if (m_reference)
+ m_reference->RegisterActuator(this);
UpdateFuzzyFlags();
}
+KX_ObjectActuator::~KX_ObjectActuator()
+{
+ if (m_reference)
+ m_reference->UnregisterActuator(this);
+}
+
bool KX_ObjectActuator::Update()
{
@@ -128,11 +141,23 @@ bool KX_ObjectActuator::Update()
if (mass < MT_EPSILON)
return false;
MT_Vector3 v = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
+ if (m_reference)
+ {
+ const MT_Point3& mypos = parent->NodeGetWorldPosition();
+ const MT_Point3& refpos = m_reference->NodeGetWorldPosition();
+ MT_Point3 relpos;
+ relpos = (mypos-refpos);
+ MT_Vector3 vel= m_reference->GetVelocity(relpos);
+ if (m_bitLocalFlag.LinearVelocity)
+ // must convert in local space
+ vel = parent->NodeGetWorldOrientation().transposed()*vel;
+ v -= vel;
+ }
MT_Vector3 e = m_linear_velocity - v;
MT_Vector3 dv = e - m_previous_error;
MT_Vector3 I = m_error_accumulator + e;
- m_force = m_torque.x()*e+m_torque.y()*I+m_torque.z()*dv;
+ m_force = m_pid.x()*e+m_pid.y()*I+m_pid.z()*dv;
// to automatically adapt the PID coefficient to mass;
m_force *= mass;
if (m_bitLocalFlag.Torque)
@@ -253,13 +278,37 @@ CValue* KX_ObjectActuator::GetReplica()
KX_ObjectActuator* replica = new KX_ObjectActuator(*this);//m_float,GetName());
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
return replica;
}
+void KX_ObjectActuator::ProcessReplica()
+{
+ SCA_IActuator::ProcessReplica();
+ if (m_reference)
+ m_reference->RegisterActuator(this);
+}
+bool KX_ObjectActuator::UnlinkObject(SCA_IObject* clientobj)
+{
+ if (clientobj == (SCA_IObject*)m_reference)
+ {
+ // this object is being deleted, we cannot continue to use it as reference.
+ m_reference = NULL;
+ return true;
+ }
+ return false;
+}
+
+void KX_ObjectActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
+{
+ void **h_obj = (*obj_map)[m_reference];
+ if (h_obj) {
+ if (m_reference)
+ m_reference->UnregisterActuator(this);
+ m_reference = (KX_GameObject*)(*h_obj);
+ m_reference->RegisterActuator(this);
+ }
+}
/* some 'standard' utilities... */
bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type)
@@ -277,8 +326,13 @@ bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_ObjectActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_ObjectActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -304,6 +358,7 @@ PyParentObject KX_ObjectActuator::Parents[] = {
};
PyMethodDef KX_ObjectActuator::Methods[] = {
+ // Deprecated ----->
{"getForce", (PyCFunction) KX_ObjectActuator::sPyGetForce, METH_NOARGS},
{"setForce", (PyCFunction) KX_ObjectActuator::sPySetForce, METH_VARARGS},
{"getTorque", (PyCFunction) KX_ObjectActuator::sPyGetTorque, METH_NOARGS},
@@ -327,18 +382,188 @@ PyMethodDef KX_ObjectActuator::Methods[] = {
{"setPID", (PyCFunction) KX_ObjectActuator::sPyGetPID, METH_NOARGS},
{"getPID", (PyCFunction) KX_ObjectActuator::sPySetPID, METH_VARARGS},
-
+ // <----- Deprecated
{NULL,NULL} //Sentinel
};
PyAttributeDef KX_ObjectActuator::Attributes[] = {
+ KX_PYATTRIBUTE_VECTOR_RW_CHECK("force", -1000, 1000, false, KX_ObjectActuator, m_force, PyUpdateFuzzyFlags),
+ KX_PYATTRIBUTE_BOOL_RW("useLocalForce", KX_ObjectActuator, m_bitLocalFlag.Force),
+ KX_PYATTRIBUTE_VECTOR_RW_CHECK("torque", -1000, 1000, false, KX_ObjectActuator, m_torque, PyUpdateFuzzyFlags),
+ KX_PYATTRIBUTE_BOOL_RW("useLocalTorque", KX_ObjectActuator, m_bitLocalFlag.Torque),
+ KX_PYATTRIBUTE_VECTOR_RW_CHECK("dLoc", -1000, 1000, false, KX_ObjectActuator, m_dloc, PyUpdateFuzzyFlags),
+ 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),
+ 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),
+ 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),
+ KX_PYATTRIBUTE_RW_FUNCTION("forceLimitY", KX_ObjectActuator, pyattr_get_forceLimitY, pyattr_set_forceLimitY),
+ KX_PYATTRIBUTE_RW_FUNCTION("forceLimitZ", KX_ObjectActuator, pyattr_get_forceLimitZ, pyattr_set_forceLimitZ),
+ KX_PYATTRIBUTE_VECTOR_RW_CHECK("pid", -100, 200, true, KX_ObjectActuator, m_pid, PyCheckPid),
+ KX_PYATTRIBUTE_RW_FUNCTION("reference", KX_ObjectActuator,pyattr_get_reference,pyattr_set_reference),
{ NULL } //Sentinel
};
PyObject* KX_ObjectActuator::py_getattro(PyObject *attr) {
py_getattro_up(SCA_IActuator);
-};
+}
+
+
+PyObject* KX_ObjectActuator::py_getattro_dict() {
+ py_getattro_dict_up(SCA_IActuator);
+}
+
+int KX_ObjectActuator::py_setattro(PyObject *attr, PyObject *value)
+{
+ py_setattro_up(SCA_IActuator);
+}
+
+/* Attribute get/set functions */
+
+PyObject* KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[0]));
+ PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.Torque));
+
+ return retVal;
+}
+
+int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
+
+ PyObject* seq = PySequence_Fast(value, "");
+ if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
+ {
+ 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);
+
+ if (!PyErr_Occurred())
+ {
+ Py_DECREF(seq);
+ return PY_SET_ATTR_SUCCESS;
+ }
+ }
+
+ Py_XDECREF(seq);
+
+ PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
+ return PY_SET_ATTR_FAIL;
+}
+
+PyObject* KX_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[1]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[1]));
+ PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DLoc));
+
+ return retVal;
+}
+
+int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
+
+ PyObject* seq = PySequence_Fast(value, "");
+ if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
+ {
+ 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);
+
+ if (!PyErr_Occurred())
+ {
+ Py_DECREF(seq);
+ return PY_SET_ATTR_SUCCESS;
+ }
+ }
+
+ Py_XDECREF(seq);
+
+ PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
+ return PY_SET_ATTR_FAIL;
+}
+
+PyObject* KX_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[2]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[2]));
+ PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DRot));
+
+ return retVal;
+}
+
+int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
+
+ PyObject* seq = PySequence_Fast(value, "");
+ if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
+ {
+ 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);
+
+ if (!PyErr_Occurred())
+ {
+ Py_DECREF(seq);
+ return PY_SET_ATTR_SUCCESS;
+ }
+ }
+
+ Py_XDECREF(seq);
+
+ PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
+ return PY_SET_ATTR_FAIL;
+}
+
+PyObject* KX_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self);
+ if (!actuator->m_reference)
+ Py_RETURN_NONE;
+
+ return actuator->m_reference->GetProxy();
+}
+
+int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self);
+ KX_GameObject *refOb;
+
+ if (!ConvertPythonToGameObject(value, &refOb, true, "actu.reference = value: KX_ObjectActuator"))
+ return PY_SET_ATTR_FAIL;
+
+ if (actuator->m_reference)
+ actuator->m_reference->UnregisterActuator(actuator);
+
+ if(refOb==NULL) {
+ actuator->m_reference= NULL;
+ }
+ else {
+ actuator->m_reference = refOb;
+ actuator->m_reference->RegisterActuator(actuator);
+ }
+
+ return PY_SET_ATTR_SUCCESS;
+}
+
/* 1. set ------------------------------------------------------------------ */
/* Removed! */
@@ -346,18 +571,20 @@ PyObject* KX_ObjectActuator::py_getattro(PyObject *attr) {
/* 2. getForce */
PyObject* KX_ObjectActuator::PyGetForce()
{
+ ShowDeprecationWarning("getForce()", "the force and the useLocalForce properties");
PyObject *retVal = PyList_New(4);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_force[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_force[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_force[2]));
- PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.Force));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_force[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_force[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_force[2]));
+ PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.Force));
return retVal;
}
/* 3. setForce */
PyObject* KX_ObjectActuator::PySetForce(PyObject* args)
{
+ ShowDeprecationWarning("setForce()", "the force and the useLocalForce properties");
float vecArg[3];
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi:setForce", &vecArg[0], &vecArg[1],
@@ -373,18 +600,20 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* args)
/* 4. getTorque */
PyObject* KX_ObjectActuator::PyGetTorque()
{
+ ShowDeprecationWarning("getTorque()", "the torque and the useLocalTorque properties");
PyObject *retVal = PyList_New(4);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_torque[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_torque[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_torque[2]));
- PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.Torque));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_torque[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_torque[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_torque[2]));
+ PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.Torque));
return retVal;
}
/* 5. setTorque */
PyObject* KX_ObjectActuator::PySetTorque(PyObject* args)
{
+ ShowDeprecationWarning("setTorque()", "the torque and the useLocalTorque properties");
float vecArg[3];
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi:setTorque", &vecArg[0], &vecArg[1],
@@ -400,18 +629,20 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* args)
/* 6. getDLoc */
PyObject* KX_ObjectActuator::PyGetDLoc()
{
+ ShowDeprecationWarning("getDLoc()", "the dLoc and the useLocalDLoc properties");
PyObject *retVal = PyList_New(4);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_dloc[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_dloc[2]));
- PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.DLoc));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_dloc[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_dloc[2]));
+ PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.DLoc));
return retVal;
}
/* 7. setDLoc */
PyObject* KX_ObjectActuator::PySetDLoc(PyObject* args)
{
+ ShowDeprecationWarning("setDLoc()", "the dLoc and the useLocalDLoc properties");
float vecArg[3];
int bToggle = 0;
if(!PyArg_ParseTuple(args, "fffi:setDLoc", &vecArg[0], &vecArg[1],
@@ -427,18 +658,20 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* args)
/* 8. getDRot */
PyObject* KX_ObjectActuator::PyGetDRot()
{
+ ShowDeprecationWarning("getDRot()", "the dRot and the useLocalDRot properties");
PyObject *retVal = PyList_New(4);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_drot[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_drot[2]));
- PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.DRot));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_drot[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_drot[2]));
+ PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.DRot));
return retVal;
}
/* 9. setDRot */
PyObject* KX_ObjectActuator::PySetDRot(PyObject* args)
{
+ ShowDeprecationWarning("setDRot()", "the dRot and the useLocalDRot properties");
float vecArg[3];
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi:setDRot", &vecArg[0], &vecArg[1],
@@ -453,18 +686,20 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* args)
/* 10. getLinearVelocity */
PyObject* KX_ObjectActuator::PyGetLinearVelocity() {
+ ShowDeprecationWarning("getLinearVelocity()", "the linV and the useLocalLinV properties");
PyObject *retVal = PyList_New(4);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2]));
- PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.LinearVelocity));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2]));
+ PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.LinearVelocity));
return retVal;
}
/* 11. setLinearVelocity */
PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* args) {
+ ShowDeprecationWarning("setLinearVelocity()", "the linV and the useLocalLinV properties");
float vecArg[3];
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi:setLinearVelocity", &vecArg[0], &vecArg[1],
@@ -480,17 +715,19 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* args) {
/* 12. getAngularVelocity */
PyObject* KX_ObjectActuator::PyGetAngularVelocity() {
+ ShowDeprecationWarning("getAngularVelocity()", "the angV and the useLocalAngV properties");
PyObject *retVal = PyList_New(4);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2]));
- PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.AngularVelocity));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2]));
+ PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.AngularVelocity));
return retVal;
}
/* 13. setAngularVelocity */
PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* args) {
+ ShowDeprecationWarning("setAngularVelocity()", "the angV and the useLocalAngV properties");
float vecArg[3];
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi:setAngularVelocity", &vecArg[0], &vecArg[1],
@@ -505,6 +742,7 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* args) {
/* 13. setDamping */
PyObject* KX_ObjectActuator::PySetDamping(PyObject* args) {
+ ShowDeprecationWarning("setDamping()", "the damping property");
int damping = 0;
if (!PyArg_ParseTuple(args, "i:setDamping", &damping) || damping < 0 || damping > 1000) {
return NULL;
@@ -515,22 +753,25 @@ PyObject* KX_ObjectActuator::PySetDamping(PyObject* args) {
/* 13. getVelocityDamping */
PyObject* KX_ObjectActuator::PyGetDamping() {
+ ShowDeprecationWarning("getDamping()", "the damping property");
return Py_BuildValue("i",m_damping);
}
/* 6. getForceLimitX */
PyObject* KX_ObjectActuator::PyGetForceLimitX()
{
+ ShowDeprecationWarning("getForceLimitX()", "the forceLimitX property");
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[0]));
- PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.Torque));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[0]));
+ PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.Torque));
return retVal;
}
/* 7. setForceLimitX */
PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* args)
{
+ ShowDeprecationWarning("setForceLimitX()", "the forceLimitX property");
float vecArg[2];
int bToggle = 0;
if(!PyArg_ParseTuple(args, "ffi:setForceLimitX", &vecArg[0], &vecArg[1], &bToggle)) {
@@ -545,17 +786,19 @@ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* args)
/* 6. getForceLimitY */
PyObject* KX_ObjectActuator::PyGetForceLimitY()
{
+ ShowDeprecationWarning("getForceLimitY()", "the forceLimitY property");
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[1]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[1]));
- PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.DLoc));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[1]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[1]));
+ PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.DLoc));
return retVal;
}
/* 7. setForceLimitY */
PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* args)
{
+ ShowDeprecationWarning("setForceLimitY()", "the forceLimitY property");
float vecArg[2];
int bToggle = 0;
if(!PyArg_ParseTuple(args, "ffi:setForceLimitY", &vecArg[0], &vecArg[1], &bToggle)) {
@@ -570,17 +813,19 @@ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* args)
/* 6. getForceLimitZ */
PyObject* KX_ObjectActuator::PyGetForceLimitZ()
{
+ ShowDeprecationWarning("getForceLimitZ()", "the forceLimitZ property");
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[2]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[2]));
- PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.DRot));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[2]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[2]));
+ PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.DRot));
return retVal;
}
/* 7. setForceLimitZ */
PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* args)
{
+ ShowDeprecationWarning("setForceLimitZ()", "the forceLimitZ property");
float vecArg[2];
int bToggle = 0;
if(!PyArg_ParseTuple(args, "ffi:setForceLimitZ", &vecArg[0], &vecArg[1], &bToggle)) {
@@ -595,22 +840,24 @@ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* args)
/* 4. getPID */
PyObject* KX_ObjectActuator::PyGetPID()
{
+ ShowDeprecationWarning("getPID()", "the pid property");
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_torque[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_torque[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_torque[2]));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_pid[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_pid[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_pid[2]));
return retVal;
}
/* 5. setPID */
PyObject* KX_ObjectActuator::PySetPID(PyObject* args)
{
+ ShowDeprecationWarning("setPID()", "the pid property");
float vecArg[3];
if (!PyArg_ParseTuple(args, "fff:setPID", &vecArg[0], &vecArg[1], &vecArg[2])) {
return NULL;
}
- m_torque.setValue(vecArg);
+ m_pid.setValue(vecArg);
Py_RETURN_NONE;
}
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h
index a812942a0ae..f9bd2a0c748 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.h
@@ -35,8 +35,10 @@
#include "SCA_IActuator.h"
#include "MT_Vector3.h"
+class KX_GameObject;
+
//
-// Bitfield that stores the flags for each CValue derived class
+// Stores the flags for each CValue derived class
//
struct KX_LocalFlags {
KX_LocalFlags() :
@@ -55,20 +57,20 @@ struct KX_LocalFlags {
{
}
- unsigned short Force : 1;
- unsigned short Torque : 1;
- unsigned short DRot : 1;
- unsigned short DLoc : 1;
- unsigned short LinearVelocity : 1;
- unsigned short AngularVelocity : 1;
- unsigned short AddOrSetLinV : 1;
- unsigned short ServoControl : 1;
- unsigned short ZeroForce : 1;
- unsigned short ZeroTorque : 1;
- unsigned short ZeroDRot : 1;
- unsigned short ZeroDLoc : 1;
- unsigned short ZeroLinearVelocity : 1;
- unsigned short ZeroAngularVelocity : 1;
+ bool Force;
+ bool Torque;
+ bool DRot;
+ bool DLoc;
+ bool LinearVelocity;
+ bool AngularVelocity;
+ bool AddOrSetLinV;
+ bool ServoControl;
+ bool ZeroForce;
+ bool ZeroTorque;
+ bool ZeroDRot;
+ bool ZeroDLoc;
+ bool ZeroLinearVelocity;
+ bool ZeroAngularVelocity;
};
class KX_ObjectActuator : public SCA_IActuator
@@ -80,7 +82,8 @@ class KX_ObjectActuator : public SCA_IActuator
MT_Vector3 m_dloc;
MT_Vector3 m_drot;
MT_Vector3 m_linear_velocity;
- MT_Vector3 m_angular_velocity;
+ MT_Vector3 m_angular_velocity;
+ MT_Vector3 m_pid;
MT_Scalar m_linear_length2;
MT_Scalar m_angular_length2;
// used in damping
@@ -91,7 +94,7 @@ class KX_ObjectActuator : public SCA_IActuator
MT_Vector3 m_previous_error;
MT_Vector3 m_error_accumulator;
KX_LocalFlags m_bitLocalFlag;
-
+ KX_GameObject* m_reference;
// A hack bool -- oh no sorry everyone
// This bool is used to check if we have informed
// the physics object that we are no longer
@@ -120,6 +123,7 @@ public:
KX_ObjectActuator(
SCA_IObject* gameobj,
+ KX_GameObject* refobj,
const MT_Vector3& force,
const MT_Vector3& torque,
const MT_Vector3& dloc,
@@ -130,8 +134,11 @@ public:
const KX_LocalFlags& flag,
PyTypeObject* T=&Type
);
-
+ ~KX_ObjectActuator();
CValue* GetReplica();
+ void ProcessReplica();
+ bool UnlinkObject(SCA_IObject* clientobj);
+ void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
void SetForceLoc(const double force[3]) { /*m_force=force;*/ }
void UpdateFuzzyFlags()
@@ -154,6 +161,8 @@ public:
/* --------------------------------------------------------------------- */
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);
@@ -177,6 +186,53 @@ public:
KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForceLimitZ);
KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetPID);
KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetPID);
+
+ /* Attributes */
+ static PyObject* pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ 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);
+
+ // This lets the attribute macros use UpdateFuzzyFlags()
+ static int PyUpdateFuzzyFlags(void *self, const PyAttributeDef *attrdef)
+ {
+ KX_ObjectActuator* act = reinterpret_cast<KX_ObjectActuator*>(self);
+ act->UpdateFuzzyFlags();
+ return 0;
+ }
+
+ // This is the keep the PID values in check after they are assigned with Python
+ static int PyCheckPid(void *self, const PyAttributeDef *attrdef)
+ {
+ KX_ObjectActuator* act = reinterpret_cast<KX_ObjectActuator*>(self);
+
+ //P 0 to 200
+ if (act->m_pid[0] < 0) {
+ act->m_pid[0] = 0;
+ } else if (act->m_pid[0] > 200) {
+ act->m_pid[0] = 200;
+ }
+
+ //I 0 to 3
+ if (act->m_pid[1] < 0) {
+ act->m_pid[1] = 0;
+ } else if (act->m_pid[1] > 3) {
+ act->m_pid[1] = 3;
+ }
+
+ //D -100 to 100
+ if (act->m_pid[2] < -100) {
+ act->m_pid[2] = -100;
+ } else if (act->m_pid[2] > 100) {
+ act->m_pid[2] = 100;
+ }
+
+ return 0;
+ }
};
#endif //__KX_OBJECTACTUATOR
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h
index 21b7e632d83..8c3974c38a3 100644
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.h
+++ b/source/gameengine/Ketsji/KX_OdePhysicsController.h
@@ -70,6 +70,7 @@ public:
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);
diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp
index 0093cf5f313..cd2ed456c48 100644
--- a/source/gameengine/Ketsji/KX_ParentActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp
@@ -48,10 +48,14 @@
KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj,
int mode,
+ bool addToCompound,
+ bool ghost,
SCA_IObject *ob,
PyTypeObject* T)
: SCA_IActuator(gameobj, T),
m_mode(mode),
+ m_addToCompound(addToCompound),
+ m_ghost(ghost),
m_ob(ob)
{
if (m_ob)
@@ -73,8 +77,6 @@ CValue* KX_ParentActuator::GetReplica()
KX_ParentActuator* replica = new KX_ParentActuator(*this);
// replication just copy the m_base pointer => common random generator
replica->ProcessReplica();
- CValue::AddDataToReplica(replica);
-
return replica;
}
@@ -123,7 +125,7 @@ bool KX_ParentActuator::Update()
switch (m_mode) {
case KX_PARENT_SET:
if (m_ob)
- obj->SetParent(scene, (KX_GameObject*)m_ob);
+ obj->SetParent(scene, (KX_GameObject*)m_ob, m_addToCompound, m_ghost);
break;
case KX_PARENT_REMOVE:
obj->RemoveParent(scene);
@@ -139,8 +141,13 @@ bool KX_ParentActuator::Update()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_ParentActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_ParentActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -175,6 +182,9 @@ PyMethodDef KX_ParentActuator::Methods[] = {
PyAttributeDef KX_ParentActuator::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("object", KX_ParentActuator, pyattr_get_object, pyattr_set_object),
+ KX_PYATTRIBUTE_INT_RW("mode", KX_PARENT_NODEF+1, KX_PARENT_MAX-1, true, KX_ParentActuator, m_mode),
+ KX_PYATTRIBUTE_BOOL_RW("compound", KX_ParentActuator, m_addToCompound),
+ KX_PYATTRIBUTE_BOOL_RW("ghost", KX_ParentActuator, m_ghost),
{ NULL } //Sentinel
};
@@ -193,7 +203,7 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE
KX_GameObject *gameobj;
if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_ParentActuator"))
- return 1; // ConvertPythonToGameObject sets the error
+ return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
if (actuator->m_ob != NULL)
actuator->m_ob->UnregisterActuator(actuator);
@@ -203,7 +213,7 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE
if (actuator->m_ob)
actuator->m_ob->RegisterActuator(actuator);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
@@ -211,6 +221,10 @@ 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);
}
@@ -259,7 +273,7 @@ PyObject* KX_ParentActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_ob->GetName());
+ return PyString_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 f9f0b73b876..148375e994c 100644
--- a/source/gameengine/Ketsji/KX_ParentActuator.h
+++ b/source/gameengine/Ketsji/KX_ParentActuator.h
@@ -46,6 +46,9 @@ class KX_ParentActuator : public SCA_IActuator
/** Mode */
int m_mode;
+ /** option */
+ bool m_addToCompound;
+ bool m_ghost;
/** Object to set as parent */
SCA_IObject *m_ob;
@@ -57,11 +60,14 @@ class KX_ParentActuator : public SCA_IActuator
KX_PARENT_NODEF = 0,
KX_PARENT_SET,
KX_PARENT_REMOVE,
+ KX_PARENT_MAX
};
KX_ParentActuator(class SCA_IObject* gameobj,
int mode,
+ bool addToCompound,
+ bool ghost,
SCA_IObject *ob,
PyTypeObject* T=&Type);
virtual ~KX_ParentActuator();
@@ -77,6 +83,7 @@ class KX_ParentActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
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 */
diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
index fda639c09e0..c968e50957e 100644
--- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
@@ -113,8 +113,13 @@ PyAttributeDef KX_PhysicsObjectWrapper::Attributes[] = {
//python specific stuff
PyTypeObject KX_PhysicsObjectWrapper::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_PhysicsObjectWrapper",
sizeof(PyObjectPlus_Proxy),
0,
@@ -136,11 +141,14 @@ PyParentObject KX_PhysicsObjectWrapper::Parents[] = {
NULL
};
-PyObject* KX_PhysicsObjectWrapper::py_getattro(PyObject *attr)
+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)
{
diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h
index 7e10dc3ccf4..1b59686babc 100644
--- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h
+++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h
@@ -37,6 +37,7 @@ 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);
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
index 2e5dd72db0e..b56b5500c39 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.cpp
+++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp
@@ -39,8 +39,13 @@
#include "KX_PyMath.h"
PyTypeObject KX_PolyProxy::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_PolyProxy",
sizeof(PyObjectPlus_Proxy),
0,
@@ -59,8 +64,8 @@ PyTypeObject KX_PolyProxy::Type = {
PyParentObject KX_PolyProxy::Parents[] = {
&KX_PolyProxy::Type,
- &SCA_IObject::Type,
&CValue::Type,
+ &PyObjectPlus::Type,
NULL
};
@@ -79,6 +84,7 @@ PyMethodDef KX_PolyProxy::Methods[] = {
PyAttributeDef KX_PolyProxy::Attributes[] = {
/* All dummy's so they come up in a dir() */
+ //KX_PYATTRIBUTE_TODO("DummyProps"),
KX_PYATTRIBUTE_DUMMY("matname"),
KX_PYATTRIBUTE_DUMMY("texture"),
KX_PYATTRIBUTE_DUMMY("material"),
@@ -156,7 +162,11 @@ PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
{
return PyInt_FromLong(m_polygon->IsCollider());
}
- py_getattro_up(SCA_IObject);
+ py_getattro_up(CValue);
+}
+
+PyObject* KX_PolyProxy::py_getattro_dict() {
+ py_getattro_dict_up(CValue);
}
KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
@@ -176,11 +186,9 @@ CValue* KX_PolyProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { re
STR_String sPolyName="polygone";
const STR_String & KX_PolyProxy::GetText() {return sPolyName;};
double KX_PolyProxy::GetNumber() { return -1;}
-STR_String KX_PolyProxy::GetName() { return sPolyName;}
-void KX_PolyProxy::SetName(STR_String) { };
+STR_String& KX_PolyProxy::GetName() { return sPolyName;}
+void KX_PolyProxy::SetName(const char *) { };
CValue* KX_PolyProxy::GetReplica() { return NULL;}
-void KX_PolyProxy::ReplicaSetName(STR_String) {};
-
// stuff for python integration
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h
index 275e65da810..d8fd36fec6c 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.h
+++ b/source/gameengine/Ketsji/KX_PolyProxy.h
@@ -31,7 +31,7 @@
#include "SCA_IObject.h"
-class KX_PolyProxy : public SCA_IObject
+class KX_PolyProxy : public CValue
{
Py_Header;
protected:
@@ -46,14 +46,14 @@ public:
CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
const STR_String & GetText();
double GetNumber();
- STR_String GetName();
- void SetName(STR_String name); // Set the name of the value
- void ReplicaSetName(STR_String name);
+ STR_String& GetName();
+ void SetName(const char *name); // Set the name of the value
CValue* GetReplica();
// 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 46d04486cc6..506c167a905 100644
--- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
@@ -51,22 +51,37 @@
#include "KX_PyMath.h"
-KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname,
- Material *material,
- int tile,
- int tilexrep,
- int tileyrep,
- int mode,
- int transp,
- bool alpha,
- bool zsort,
- int lightlayer,
- struct MTFace* tface,
- unsigned int* mcol,
- PyTypeObject *T)
+KX_PolygonMaterial::KX_PolygonMaterial(PyTypeObject *T)
: PyObjectPlus(T),
- RAS_IPolyMaterial(texname,
- STR_String(material?material->id.name:""),
+ RAS_IPolyMaterial(),
+
+ m_tface(NULL),
+ m_mcol(NULL),
+ m_material(NULL),
+ m_pymaterial(NULL),
+ m_pass(0)
+{
+}
+
+void KX_PolygonMaterial::Initialize(
+ const STR_String &texname,
+ Material* ma,
+ int materialindex,
+ int tile,
+ int tilexrep,
+ int tileyrep,
+ int mode,
+ int transp,
+ bool alpha,
+ bool zsort,
+ int lightlayer,
+ struct MTFace* tface,
+ unsigned int* mcol)
+{
+ RAS_IPolyMaterial::Initialize(
+ texname,
+ ma?ma->id.name:"",
+ materialindex,
tile,
tilexrep,
tileyrep,
@@ -74,13 +89,12 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname,
transp,
alpha,
zsort,
- lightlayer),
- m_tface(tface),
- m_mcol(mcol),
- m_material(material),
- m_pymaterial(0),
- m_pass(0)
-{
+ lightlayer);
+ m_tface = tface;
+ m_mcol = mcol;
+ m_material = ma;
+ m_pymaterial = 0;
+ m_pass = 0;
}
KX_PolygonMaterial::~KX_PolygonMaterial()
@@ -158,15 +172,32 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c
rasty->SetLines(true);
else
rasty->SetLines(false);
+ 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);
+ if (m_material)
+ rasty->SetPolygonOffset(-m_material->zoffs, 0.0);
}
- 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);
- if (m_material)
- rasty->SetPolygonOffset(-m_material->zoffs, 0.0);
+ //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);
+ //if (m_material)
+ // rasty->SetPolygonOffset(-m_material->zoffs, 0.0);
+}
+
+void KX_PolygonMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
+{
+ if (m_material) {
+ *rgba++ = (unsigned char) (m_material->r*255.0);
+ *rgba++ = (unsigned char) (m_material->g*255.0);
+ *rgba++ = (unsigned char) (m_material->b*255.0);
+ *rgba++ = (unsigned char) (m_material->alpha*255.0);
+ } else
+ RAS_IPolyMaterial::GetMaterialRGBAColor(rgba);
}
+
//----------------------------------------------------------------------------
//Python
@@ -189,7 +220,7 @@ PyAttributeDef KX_PolygonMaterial::Attributes[] = {
KX_PYATTRIBUTE_INT_RW("tilexrep", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tilexrep),
KX_PYATTRIBUTE_INT_RW("tileyrep", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tileyrep),
KX_PYATTRIBUTE_INT_RW("drawingmode", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_drawingmode),
- KX_PYATTRIBUTE_INT_RW("lightlayer", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_lightlayer),
+ //KX_PYATTRIBUTE_INT_RW("lightlayer", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_lightlayer),
KX_PYATTRIBUTE_BOOL_RW("transparent", KX_PolygonMaterial, m_alpha),
KX_PYATTRIBUTE_BOOL_RW("zsort", KX_PolygonMaterial, m_zsort),
@@ -208,8 +239,13 @@ PyAttributeDef KX_PolygonMaterial::Attributes[] = {
};
PyTypeObject KX_PolygonMaterial::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_PolygonMaterial",
sizeof(PyObjectPlus_Proxy),
0,
@@ -237,6 +273,10 @@ 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);
@@ -346,10 +386,10 @@ int KX_PolygonMaterial::pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DE
MT_Vector3 vec;
if (!PyVecTo(value, vec))
- return -1;
+ return PY_SET_ATTR_FAIL;
self->m_diffuse= vec;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_PolygonMaterial::pyattr_get_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -364,8 +404,8 @@ int KX_PolygonMaterial::pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_D
MT_Vector3 vec;
if (!PyVecTo(value, vec))
- return -1;
+ return PY_SET_ATTR_FAIL;
self->m_specular= vec;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h
index 9865a66e836..89ecb026da9 100644
--- a/source/gameengine/Ketsji/KX_PolygonMaterial.h
+++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h
@@ -53,14 +53,14 @@ private:
MTFace* m_tface;
unsigned int* m_mcol;
Material* m_material;
-
PyObject* m_pymaterial;
mutable int m_pass;
public:
-
- KX_PolygonMaterial(const STR_String &texname,
+ KX_PolygonMaterial(PyTypeObject *T = &Type);
+ void Initialize(const STR_String &texname,
Material* ma,
+ int materialindex,
int tile,
int tilexrep,
int tileyrep,
@@ -70,8 +70,8 @@ public:
bool zsort,
int lightlayer,
struct MTFace* tface,
- unsigned int* mcol,
- PyTypeObject *T = &Type);
+ unsigned int* mcol);
+
virtual ~KX_PolygonMaterial();
/**
@@ -107,8 +107,8 @@ public:
{
return m_mcol;
}
-
-
+ virtual void GetMaterialRGBAColor(unsigned char *rgba) const;
+
KX_PYMETHOD_DOC(KX_PolygonMaterial, updateTexture);
KX_PYMETHOD_DOC(KX_PolygonMaterial, setTexture);
KX_PYMETHOD_DOC(KX_PolygonMaterial, activate);
@@ -117,6 +117,7 @@ public:
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 : ""); }
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
index 2c65c184a9c..a098d99864f 100644
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
@@ -33,6 +33,7 @@
#include "KX_PhysicsObjectWrapper.h"
#include "PHY_IPhysicsController.h"
#include "PHY_IVehicle.h"
+#include "MT_Matrix3x3.h"
#include "PyObjectPlus.h"
@@ -404,6 +405,8 @@ static PyObject* gPyCreateConstraint(PyObject* self,
int physicsid=0,physicsid2 = 0,constrainttype=0,extrainfo=0;
int len = PyTuple_Size(args);
int success = 1;
+ int flag = 0;
+
float pivotX=1,pivotY=1,pivotZ=1,axisX=0,axisY=0,axisZ=1;
if (len == 3)
{
@@ -420,6 +423,11 @@ static PyObject* gPyCreateConstraint(PyObject* self,
success = PyArg_ParseTuple(args,"iiiffffff",&physicsid,&physicsid2,&constrainttype,
&pivotX,&pivotY,&pivotZ,&axisX,&axisY,&axisZ);
}
+ else if (len == 10)
+ {
+ success = PyArg_ParseTuple(args,"iiiffffffi",&physicsid,&physicsid2,&constrainttype,
+ &pivotX,&pivotY,&pivotZ,&axisX,&axisY,&axisZ,&flag);
+ }
else if (len==4)
{
success = PyArg_ParseTuple(args,"iiii",&physicsid,&physicsid2,&constrainttype,&extrainfo);
@@ -435,7 +443,31 @@ static PyObject* gPyCreateConstraint(PyObject* self,
PHY_IPhysicsController* physctrl2 = (PHY_IPhysicsController*) physicsid2;
if (physctrl) //TODO:check for existance of this pointer!
{
- int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
+ PHY_ConstraintType ct = (PHY_ConstraintType) constrainttype;
+ int constraintid =0;
+
+ if (ct == PHY_GENERIC_6DOF_CONSTRAINT)
+ {
+ //convert from euler angle into axis
+ float radsPerDeg = 6.283185307179586232f / 360.f;
+
+ //we need to pass a full constraint frame, not just axis
+ //localConstraintFrameBasis
+ MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*axisX,radsPerDeg*axisY,radsPerDeg*axisZ));
+ MT_Vector3 axis0 = localCFrame.getColumn(0);
+ MT_Vector3 axis1 = localCFrame.getColumn(1);
+ MT_Vector3 axis2 = localCFrame.getColumn(2);
+
+ constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,
+ pivotX,pivotY,pivotZ,
+ (float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
+ (float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
+ (float)axis2.x(),(float)axis2.y(),(float)axis2.z(),flag);
+
+ } else
+ {
+ constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
+ }
KX_ConstraintWrapper* wrap = new KX_ConstraintWrapper((enum PHY_ConstraintType)constrainttype,constraintid,PHY_GetActiveEnvironment());
@@ -565,6 +597,19 @@ static struct PyMethodDef physicsconstraints_methods[] = {
};
+#if (PY_VERSION_HEX >= 0x03000000)
+static struct PyModuleDef PhysicsConstraints_module_def = {
+ {}, /* m_base */
+ "PhysicsConstraints", /* m_name */
+ PhysicsConstraints_module_documentation, /* m_doc */
+ 0, /* m_size */
+ physicsconstraints_methods, /* m_methods */
+ 0, /* m_reload */
+ 0, /* m_traverse */
+ 0, /* m_clear */
+ 0, /* m_free */
+};
+#endif
PyObject* initPythonConstraintBinding()
{
@@ -573,10 +618,24 @@ PyObject* initPythonConstraintBinding()
PyObject* m;
PyObject* d;
-
- m = Py_InitModule4("PhysicsConstraints", physicsconstraints_methods,
+ /* Use existing module where possible
+ * be careful not to init any runtime vars after this */
+ m = PyImport_ImportModule( "PhysicsConstraints" );
+ if(m) {
+ Py_DECREF(m);
+ return m;
+ }
+ else {
+ PyErr_Clear();
+
+#if (PY_VERSION_HEX >= 0x03000000)
+ m = PyModule_Create(&PhysicsConstraints_module_def);
+#else
+ m = Py_InitModule4("PhysicsConstraints", physicsconstraints_methods,
PhysicsConstraints_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
+#endif
+ }
// Add some symbolic constants to the module
d = PyModule_GetDict(m);
diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp
index 0093a72808e..051d7ae7dba 100644
--- a/source/gameengine/Ketsji/KX_PyMath.cpp
+++ b/source/gameengine/Ketsji/KX_PyMath.cpp
@@ -75,9 +75,8 @@ bool PyObject_IsMT_Matrix(PyObject *pymat, unsigned int rank)
return false;
}
-bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &mat, const char *error_prefix)
+bool PyOrientationTo(PyObject* pyval, MT_Matrix3x3 &rot, const char *error_prefix)
{
- MT_Matrix3x3 rot;
int size= PySequence_Size(pyval);
if (size == 4)
diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h
index 00f7c5cad93..a7ce4bc6930 100644
--- a/source/gameengine/Ketsji/KX_PyMath.h
+++ b/source/gameengine/Ketsji/KX_PyMath.h
@@ -40,6 +40,7 @@
#include "MT_Matrix4x4.h"
#include "KX_Python.h"
+#include "PyObjectPlus.h"
inline unsigned int Size(const MT_Matrix4x4&) { return 4; }
inline unsigned int Size(const MT_Matrix3x3&) { return 3; }
@@ -116,6 +117,19 @@ bool PyVecTo(PyObject* pyval, T& vec)
return true;
}
+ else if (BGE_PROXY_CHECK_TYPE(pyval))
+ { /* 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.
+ * GameObjects are often used as an alternative to vectors so this is a common case
+ * better to do a quick check for it, likely the error below will be ignored.
+ *
+ * This is not 'correct' since we have proxy type CListValues's which could
+ * contain floats/ints but there no cases of CValueLists being this way
+ */
+ PyErr_Format(PyExc_AttributeError, "expected a sequence type");
+ return false;
+ }
else if (PySequence_Check(pyval))
{
unsigned int numitems = PySequence_Size(pyval);
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index ffcf7d7162e..fc3e48f504c 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -49,6 +49,9 @@
#include "KX_KetsjiEngine.h"
#include "KX_RadarSensor.h"
#include "KX_RaySensor.h"
+#include "KX_SceneActuator.h"
+#include "KX_GameActuator.h"
+#include "KX_ParentActuator.h"
#include "KX_SCA_DynamicActuator.h"
#include "SCA_IInputDevice.h"
@@ -83,10 +86,16 @@
#include "KX_PythonInitTypes.h"
+/* we only need this to get a list of libraries from the main struct */
+#include "DNA_ID.h"
+
extern "C" {
- #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use.
#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
}
#endif
@@ -100,13 +109,13 @@ extern "C" {
//#include "BPY_extern.h"
#endif
+#include "BKE_main.h"
#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BLI_blenlib.h"
#include "GPU_material.h"
static void setSandbox(TPythonSecurityLevel level);
-static void clearGameModules();
// 'local' copy of canvas ptr, for window height/width python scripts
static RAS_ICanvas* gp_Canvas = NULL;
@@ -114,6 +123,9 @@ static KX_Scene* gp_KetsjiScene = NULL;
static KX_KetsjiEngine* gp_KetsjiEngine = NULL;
static RAS_IRasterizer* gp_Rasterizer = NULL;
static char gp_GamePythonPath[FILE_MAXDIR + FILE_MAXFILE] = "";
+static char gp_GamePythonPathOrig[FILE_MAXDIR + FILE_MAXFILE] = ""; // not super happy about this, but we need to remember the first loaded file for the global/dict load save
+static PyObject *gp_OrigPythonSysPath= NULL;
+static PyObject *gp_OrigPythonSysModules= NULL;
void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)
{
@@ -220,13 +232,13 @@ static PyObject* gPyGetSpectrum(PyObject*)
for (int index = 0; index < 512; index++)
{
- PyList_SetItem(resultlist, index, PyFloat_FromDouble(spectrum[index]));
+ PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(spectrum[index]));
}
}
else {
for (int index = 0; index < 512; index++)
{
- PyList_SetItem(resultlist, index, PyFloat_FromDouble(0.0));
+ PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0));
}
}
@@ -286,6 +298,36 @@ static PyObject* gPyGetLogicTicRate(PyObject*)
return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate());
}
+static PyObject* gPySetMaxLogicFrame(PyObject*, PyObject* args)
+{
+ int frame;
+ if (!PyArg_ParseTuple(args, "i:setMaxLogicFrame", &frame))
+ return NULL;
+
+ KX_KetsjiEngine::SetMaxLogicFrame(frame);
+ Py_RETURN_NONE;
+}
+
+static PyObject* gPyGetMaxLogicFrame(PyObject*)
+{
+ return PyInt_FromLong(KX_KetsjiEngine::GetMaxLogicFrame());
+}
+
+static PyObject* gPySetMaxPhysicsFrame(PyObject*, PyObject* args)
+{
+ int frame;
+ if (!PyArg_ParseTuple(args, "i:setMaxPhysicsFrame", &frame))
+ return NULL;
+
+ KX_KetsjiEngine::SetMaxPhysicsFrame(frame);
+ Py_RETURN_NONE;
+}
+
+static PyObject* gPyGetMaxPhysicsFrame(PyObject*)
+{
+ return PyInt_FromLong(KX_KetsjiEngine::GetMaxPhysicsFrame());
+}
+
static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args)
{
float ticrate;
@@ -477,6 +519,10 @@ static struct PyMethodDef game_methods[] = {
{"setGravity",(PyCFunction) gPySetGravity, METH_O, (PY_METHODCHAR)"set Gravitation"},
{"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS, (PY_METHODCHAR)"get audio spectrum"},
{"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS, (PY_METHODCHAR)"stop using the audio dsp (for performance reasons)"},
+ {"getMaxLogicFrame", (PyCFunction) gPyGetMaxLogicFrame, METH_NOARGS, (PY_METHODCHAR)"Gets the max number of logic frame per render frame"},
+ {"setMaxLogicFrame", (PyCFunction) gPySetMaxLogicFrame, METH_VARARGS, (PY_METHODCHAR)"Sets the max number of logic frame per render frame"},
+ {"getMaxPhysicsFrame", (PyCFunction) gPyGetMaxPhysicsFrame, METH_NOARGS, (PY_METHODCHAR)"Gets the max number of physics frame per render frame"},
+ {"setMaxPhysicsFrame", (PyCFunction) gPySetMaxPhysicsFrame, METH_VARARGS, (PY_METHODCHAR)"Sets the max number of physics farme per render frame"},
{"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the logic tic rate"},
{"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, (PY_METHODCHAR)"Sets the logic tic rate"},
{"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the physics tic rate"},
@@ -487,7 +533,6 @@ static struct PyMethodDef game_methods[] = {
{NULL, (PyCFunction) NULL, 0, NULL }
};
-
static PyObject* gPyGetWindowHeight(PyObject*, PyObject* args)
{
return PyInt_FromLong((gp_Canvas ? gp_Canvas->GetHeight() : 0));
@@ -636,6 +681,17 @@ static PyObject* gPySetMistColor(PyObject*, PyObject* value)
Py_RETURN_NONE;
}
+static PyObject* gPyDisableMist(PyObject*)
+{
+
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMistColor(color), Rasterizer not available");
+ return NULL;
+ }
+ gp_Rasterizer->DisableFog();
+
+ Py_RETURN_NONE;
+}
static PyObject* gPySetMistStart(PyObject*, PyObject* args)
@@ -724,7 +780,7 @@ static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args)
Py_RETURN_NONE;
}
-static PyObject* gPyDisableMotionBlur(PyObject*, PyObject* args)
+static PyObject* gPyDisableMotionBlur(PyObject*)
{
if (!gp_Rasterizer) {
PyErr_SetString(PyExc_RuntimeError, "Rasterizer.disableMotionBlur(), Rasterizer not available");
@@ -780,16 +836,17 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*,
/* display lists and GLSL materials need to be remade */
if(G.fileflags != fileflags) {
+ GPU_materials_free();
if(gp_KetsjiEngine) {
KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes();
KX_SceneList::iterator it;
for(it=scenes->begin(); it!=scenes->end(); it++)
- if((*it)->GetBucketManager())
+ if((*it)->GetBucketManager()) {
(*it)->GetBucketManager()->ReleaseDisplayLists();
+ (*it)->GetBucketManager()->ReleaseMaterials();
+ }
}
-
- GPU_materials_free();
}
Py_RETURN_NONE;
@@ -850,7 +907,7 @@ static PyObject* gPyGetMaterialType(PyObject*)
{
int flag;
- if(G.fileflags & (G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL))
+ if(G.fileflags & G_FILE_GAME_MAT_GLSL)
flag = KX_BLENDER_GLSL_MATERIAL;
else if(G.fileflags & G_FILE_GAME_MAT)
flag = KX_BLENDER_MULTITEX_MATERIAL;
@@ -904,11 +961,12 @@ static struct PyMethodDef rasterizer_methods[] = {
METH_VARARGS, "setMousePosition(int x,int y)"},
{"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_O,"set Background Color (rgb)"},
{"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_O,"set Ambient Color (rgb)"},
+ {"disableMist",(PyCFunction)gPyDisableMist,METH_NOARGS,"turn off mist"},
{"setMistColor",(PyCFunction)gPySetMistColor,METH_O,"set Mist Color (rgb)"},
{"setMistStart",(PyCFunction)gPySetMistStart,METH_VARARGS,"set Mist Start(rgb)"},
{"setMistEnd",(PyCFunction)gPySetMistEnd,METH_VARARGS,"set Mist End(rgb)"},
{"enableMotionBlur",(PyCFunction)gPyEnableMotionBlur,METH_VARARGS,"enable motion blur"},
- {"disableMotionBlur",(PyCFunction)gPyDisableMotionBlur,METH_VARARGS,"disable motion blur"},
+ {"disableMotionBlur",(PyCFunction)gPyDisableMotionBlur,METH_NOARGS,"disable motion blur"},
{"setEyeSeparation", (PyCFunction) gPySetEyeSeparation, METH_VARARGS, "set the eye separation for stereo mode"},
@@ -938,7 +996,19 @@ static char Rasterizer_module_documentation[] =
"This is the Python API for the game engine of Rasterizer"
;
-
+#if (PY_VERSION_HEX >= 0x03000000)
+static struct PyModuleDef GameLogic_module_def = {
+ {}, /* m_base */
+ "GameLogic", /* m_name */
+ GameLogic_module_documentation, /* m_doc */
+ 0, /* m_size */
+ game_methods, /* m_methods */
+ 0, /* m_reload */
+ 0, /* m_traverse */
+ 0, /* m_clear */
+ 0, /* m_free */
+};
+#endif
PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack to get gravity hook
{
@@ -950,12 +1020,29 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
gp_KetsjiScene = scene;
gUseVisibilityTemp=false;
-
- // Create the module and add the functions
- m = Py_InitModule4("GameLogic", game_methods,
- GameLogic_module_documentation,
- (PyObject*)NULL,PYTHON_API_VERSION);
-
+
+ PyObjectPlus::ClearDeprecationWarning(); /* Not that nice to call here but makes sure warnings are reset between loading scenes */
+
+ /* Use existing module where possible
+ * be careful not to init any runtime vars after this */
+ m = PyImport_ImportModule( "GameLogic" );
+ if(m) {
+ Py_DECREF(m);
+ return m;
+ }
+ else {
+ PyErr_Clear();
+
+ // Create the module and add the functions
+#if (PY_VERSION_HEX >= 0x03000000)
+ m = PyModule_Create(&GameLogic_module_def);
+#else
+ m = Py_InitModule4("GameLogic", game_methods,
+ GameLogic_module_documentation,
+ (PyObject*)NULL,PYTHON_API_VERSION);
+#endif
+ }
+
// Add some symbolic constants to the module
d = PyModule_GetDict(m);
@@ -1172,6 +1259,28 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
KX_MACRO_addTypesToDict(d, KX_ACT_CONSTRAINT_LOCAL, KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCAL);
KX_MACRO_addTypesToDict(d, KX_ACT_CONSTRAINT_DOROTFH, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DOROTFH);
+ /* Game Actuator Modes */
+ KX_MACRO_addTypesToDict(d, KX_GAME_LOAD, KX_GameActuator::KX_GAME_LOAD);
+ KX_MACRO_addTypesToDict(d, KX_GAME_START, KX_GameActuator::KX_GAME_START);
+ KX_MACRO_addTypesToDict(d, KX_GAME_RESTART, KX_GameActuator::KX_GAME_RESTART);
+ KX_MACRO_addTypesToDict(d, KX_GAME_QUIT, KX_GameActuator::KX_GAME_QUIT);
+ KX_MACRO_addTypesToDict(d, KX_GAME_SAVECFG, KX_GameActuator::KX_GAME_SAVECFG);
+ KX_MACRO_addTypesToDict(d, KX_GAME_LOADCFG, KX_GameActuator::KX_GAME_LOADCFG);
+
+ /* Scene Actuator Modes */
+ KX_MACRO_addTypesToDict(d, KX_SCENE_RESTART, KX_SceneActuator::KX_SCENE_RESTART);
+ KX_MACRO_addTypesToDict(d, KX_SCENE_SET_SCENE, KX_SceneActuator::KX_SCENE_SET_SCENE);
+ KX_MACRO_addTypesToDict(d, KX_SCENE_SET_CAMERA, KX_SceneActuator::KX_SCENE_SET_CAMERA);
+ KX_MACRO_addTypesToDict(d, KX_SCENE_ADD_FRONT_SCENE, KX_SceneActuator::KX_SCENE_ADD_FRONT_SCENE);
+ KX_MACRO_addTypesToDict(d, KX_SCENE_ADD_BACK_SCENE, KX_SceneActuator::KX_SCENE_ADD_BACK_SCENE);
+ KX_MACRO_addTypesToDict(d, KX_SCENE_REMOVE_SCENE, KX_SceneActuator::KX_SCENE_REMOVE_SCENE);
+ KX_MACRO_addTypesToDict(d, KX_SCENE_SUSPEND, KX_SceneActuator::KX_SCENE_SUSPEND);
+ KX_MACRO_addTypesToDict(d, KX_SCENE_RESUME, KX_SceneActuator::KX_SCENE_RESUME);
+
+ /* Parent Actuator Modes */
+ KX_MACRO_addTypesToDict(d, KX_PARENT_SET, KX_ParentActuator::KX_PARENT_SET);
+ KX_MACRO_addTypesToDict(d, KX_PARENT_REMOVE, KX_ParentActuator::KX_PARENT_REMOVE);
+
// Check for errors
if (PyErr_Occurred())
{
@@ -1238,7 +1347,7 @@ PyObject *KXpy_import(PyObject *self, PyObject *args)
/* quick hack for GamePython modules
TODO: register builtin modules properly by ExtendInittab */
if (!strcmp(name, "GameLogic") || !strcmp(name, "GameKeys") || !strcmp(name, "PhysicsConstraints") ||
- !strcmp(name, "Rasterizer") || !strcmp(name, "Mathutils") || !strcmp(name, "BGL")) {
+ !strcmp(name, "Rasterizer") || !strcmp(name, "Mathutils") || !strcmp(name, "BGL") || !strcmp(name, "Geometry")) {
return PyImport_ImportModuleEx(name, globals, locals, fromlist);
}
@@ -1359,20 +1468,141 @@ void setSandbox(TPythonSecurityLevel level)
}
}
+/* Explanation of
+ *
+ * - backupPySysObjects() : stores sys.path in gp_OrigPythonSysPath
+ * - initPySysObjects(main) : initializes the blendfile and library paths
+ * - restorePySysObjects() : restores sys.path from gp_OrigPythonSysPath
+ *
+ * These exist so the current blend dir "//" can always be used to import modules from.
+ * the reason we need a few functions for this is that python is not only used by the game engine
+ * so we cant just add to sys.path all the time, it would leave pythons state in a mess.
+ * It would also be incorrect since loading blend files for new levels etc would alwasy add to sys.path
+ *
+ * To play nice with blenders python, the sys.path is backed up and the current blendfile along
+ * with all its lib paths are added to the sys path.
+ * When loading a new blendfile, the original sys.path is restored and the new paths are added over the top.
+ */
+
+/**
+ * So we can have external modules mixed with our blend files.
+ */
+static void backupPySysObjects(void)
+{
+ PyObject *sys_path= PySys_GetObject("path"); /* should never fail */
+ PyObject *sys_mods= PySys_GetObject("modules"); /* should never fail */
+
+ /* paths */
+ Py_XDECREF(gp_OrigPythonSysPath); /* just incase its set */
+ gp_OrigPythonSysPath = PyList_GetSlice(sys_path, 0, INT_MAX); /* copy the list */
+
+ /* modules */
+ Py_XDECREF(gp_OrigPythonSysModules); /* just incase its set */
+ gp_OrigPythonSysModules = PyDict_Copy(sys_mods); /* copy the list */
+
+}
+
+/* for initPySysObjects only,
+ * takes a blend path and adds a scripts dir from it
+ *
+ * "/home/me/foo.blend" -> "/home/me/scripts"
+ */
+static void initPySysObjects__append(PyObject *sys_path, char *filename)
+{
+ PyObject *item;
+ char expanded[FILE_MAXDIR + FILE_MAXFILE];
+
+ 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);
+
+// printf("SysPath - '%s', '%s', '%s'\n", expanded, filename, gp_GamePythonPath);
+
+ if(PySequence_Index(sys_path, item) == -1) {
+ PyErr_Clear(); /* PySequence_Index sets a ValueError */
+ PyList_Insert(sys_path, 0, item);
+ }
+
+ Py_DECREF(item);
+}
+static void initPySysObjects(Main *maggie)
+{
+ PyObject *sys_path= PySys_GetObject("path"); /* should never fail */
+
+ if (gp_OrigPythonSysPath==NULL) {
+ /* backup */
+ backupPySysObjects();
+ }
+ else {
+ /* get the original sys path when the BGE started */
+ PyList_SetSlice(sys_path, 0, INT_MAX, gp_OrigPythonSysPath);
+ }
+
+ Library *lib= (Library *)maggie->library.first;
+
+ while(lib) {
+ /* lib->name wont work in some cases (on win32),
+ * even when expanding with gp_GamePythonPath, using lib->filename is less trouble */
+ initPySysObjects__append(sys_path, lib->filename);
+ lib= (Library *)lib->id.next;
+ }
+
+ initPySysObjects__append(sys_path, gp_GamePythonPath);
+
+// fprintf(stderr, "\nNew Path: %d ", PyList_Size(sys_path));
+// PyObject_Print(sys_path, stderr, 0);
+}
+
+static void restorePySysObjects(void)
+{
+ if (gp_OrigPythonSysPath==NULL)
+ return;
+
+ PyObject *sys_path= PySys_GetObject("path"); /* should never fail */
+ PyObject *sys_mods= PySys_GetObject("modules"); /* should never fail */
+
+ /* paths */
+ PyList_SetSlice(sys_path, 0, INT_MAX, gp_OrigPythonSysPath);
+ Py_DECREF(gp_OrigPythonSysPath);
+ gp_OrigPythonSysPath= NULL;
+
+ /* modules */
+ PyDict_Clear(sys_mods);
+ PyDict_Update(sys_mods, gp_OrigPythonSysModules);
+ Py_DECREF(gp_OrigPythonSysModules);
+ gp_OrigPythonSysModules= NULL;
+
+
+// fprintf(stderr, "\nRestore Path: %d ", PyList_Size(sys_path));
+// PyObject_Print(sys_path, stderr, 0);
+}
+
/**
* Python is not initialised.
*/
PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie, int argc, char** argv)
{
+ /* Yet another gotcha in the py api
+ * Cant run PySys_SetArgv more then once because this adds the
+ * binary dir to the sys.path each time.
+ * Id have thaught python being totally restarted would make this ok but
+ * somehow it remembers the sys.path - Campbell
+ */
+ static bool first_time = true;
+
+#if (PY_VERSION_HEX < 0x03000000)
STR_String pname = progname;
Py_SetProgramName(pname.Ptr());
+#endif
Py_NoSiteFlag=1;
Py_FrozenFlag=1;
Py_Initialize();
- if(argv) /* 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);
-
+#endif
//importBlenderModules()
setSandbox(level);
@@ -1380,24 +1610,37 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur
/* XXX 2.5 bpy_import_main_set(maggie); */
+ initPySysObjects(maggie);
+
+ first_time = false;
+
+ PyObjectPlus::ClearDeprecationWarning();
+
PyObject* moduleobj = PyImport_AddModule("__main__");
return PyModule_GetDict(moduleobj);
}
void exitGamePlayerPythonScripting()
-{
- //clearGameModules(); // were closing python anyway
+{
+ /* since python restarts we cant let the python backup of the sys.path hang around in a global pointer */
+ restorePySysObjects(); /* get back the original sys.path and clear the backup */
+
Py_Finalize();
/* XXX 2.5 bpy_import_main_set(NULL); */
+ PyObjectPlus::ClearDeprecationWarning();
}
+
+
/**
* Python is already initialized.
*/
PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie)
{
+#if (PY_VERSION_HEX < 0x03000000)
STR_String pname = progname;
Py_SetProgramName(pname.Ptr());
+#endif
Py_NoSiteFlag=1;
Py_FrozenFlag=1;
@@ -1406,53 +1649,35 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev
/* XXX 2.5 bpy_import_main_set(maggie); */
- /* run this to clear game modules and user modules which
- * may contain references to in game data */
- clearGameModules();
+ initPySysObjects(maggie);
+ PyObjectPlus::NullDeprecationWarning();
+
PyObject* moduleobj = PyImport_AddModule("__main__");
return PyModule_GetDict(moduleobj);
}
-static void clearModule(PyObject *modules, const char *name)
-{
- PyObject *mod= PyDict_GetItemString(modules, name);
-
- if (mod==NULL)
- return;
-
- PyDict_Clear(PyModule_GetDict(mod)); /* incase there are any circular refs */
- PyDict_DelItemString(modules, name);
-}
-
-static void clearGameModules()
-{
- /* Note, user modules could still reference these modules
- * but since the dict's are cleared their members wont be accessible */
-
- PyObject *modules= PySys_GetObject((char *)"modules");
- clearModule(modules, "Expression");
- clearModule(modules, "CValue");
- clearModule(modules, "PhysicsConstraints");
- clearModule(modules, "GameLogic");
- clearModule(modules, "Rasterizer");
- clearModule(modules, "GameKeys");
- clearModule(modules, "VideoTexture");
- clearModule(modules, "Mathutils");
- clearModule(modules, "BGL");
- PyErr_Clear(); // incase some of these were alredy removed.
-
- /* clear user defined modules */
- /* XXX 2.5 bpy_text_clear_modules(); */
-}
-
void exitGamePythonScripting()
{
- clearGameModules();
+ restorePySysObjects(); /* get back the original sys.path and clear the backup */
/* XXX 2.5 bpy_import_main_set(NULL); */
+ PyObjectPlus::ClearDeprecationWarning();
}
+#if (PY_VERSION_HEX >= 0x03000000)
+static struct PyModuleDef Rasterizer_module_def = {
+ {}, /* m_base */
+ "Rasterizer", /* m_name */
+ Rasterizer_module_documentation, /* m_doc */
+ 0, /* m_size */
+ rasterizer_methods, /* m_methods */
+ 0, /* m_reload */
+ 0, /* m_traverse */
+ 0, /* m_clear */
+ 0, /* m_free */
+};
+#endif
PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
{
@@ -1464,10 +1689,25 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
PyObject* d;
PyObject* item;
- // Create the module and add the functions
- m = Py_InitModule4("Rasterizer", rasterizer_methods,
+ /* Use existing module where possible
+ * be careful not to init any runtime vars after this */
+ m = PyImport_ImportModule( "Rasterizer" );
+ if(m) {
+ Py_DECREF(m);
+ return m;
+ }
+ else {
+ PyErr_Clear();
+
+ // Create the module and add the functions
+#if (PY_VERSION_HEX >= 0x03000000)
+ m = PyModule_Create(&Rasterizer_module_def);
+#else
+ m = Py_InitModule4("Rasterizer", rasterizer_methods,
Rasterizer_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
+#endif
+ }
// Add some symbolic constants to the module
d = PyModule_GetDict(m);
@@ -1517,7 +1757,12 @@ static PyObject* gPyEventToString(PyObject*, PyObject* value)
dict = PyModule_GetDict(mod);
while (PyDict_Next(dict, &pos, &key, &val)) {
+#if (PY_VERSION_HEX >= 0x03000000)
+ if (PyObject_RichCompareBool(value, val, Py_EQ)) {
+#else
if (PyObject_Compare(value, val)==0) {
+#endif
+
ret = key;
break;
}
@@ -1559,17 +1804,44 @@ static struct PyMethodDef gamekeys_methods[] = {
};
+#if (PY_VERSION_HEX >= 0x03000000)
+static struct PyModuleDef GameKeys_module_def = {
+ {}, /* m_base */
+ "GameKeys", /* m_name */
+ GameKeys_module_documentation, /* m_doc */
+ 0, /* m_size */
+ gamekeys_methods, /* m_methods */
+ 0, /* m_reload */
+ 0, /* m_traverse */
+ 0, /* m_clear */
+ 0, /* m_free */
+};
+#endif
PyObject* initGameKeys()
{
PyObject* m;
PyObject* d;
PyObject* item;
-
- // Create the module and add the functions
- m = Py_InitModule4("GameKeys", gamekeys_methods,
+
+ /* Use existing module where possible */
+ m = PyImport_ImportModule( "GameKeys" );
+ if(m) {
+ Py_DECREF(m);
+ return m;
+ }
+ else {
+ PyErr_Clear();
+
+ // Create the module and add the functions
+#if (PY_VERSION_HEX >= 0x03000000)
+ m = PyModule_Create(&GameKeys_module_def);
+#else
+ m = Py_InitModule4("GameKeys", gamekeys_methods,
GameKeys_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
+#endif
+ }
// Add some symbolic constants to the module
d = PyModule_GetDict(m);
@@ -1698,15 +1970,26 @@ PyObject* initGameKeys()
return d;
}
+#if PY_VERSION_HEX < 0x03000000
PyObject* initMathutils()
{
return NULL; //XXX Mathutils_Init("Mathutils"); // Use as a top level module in BGE
}
+PyObject* initGeometry()
+{
+ return NULL; // XXX Geometry_Init("Geometry"); // Use as a top level module in BGE
+}
+
PyObject* initBGL()
{
return NULL; // XXX 2.5 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)
{
@@ -1794,9 +2077,9 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length)
void pathGamePythonConfig( char *path )
{
- int len = strlen(gp_GamePythonPath);
+ int len = strlen(gp_GamePythonPathOrig); // Always use the first loaded blend filename
- BLI_strncpy(path, gp_GamePythonPath, sizeof(gp_GamePythonPath));
+ BLI_strncpy(path, gp_GamePythonPathOrig, sizeof(gp_GamePythonPathOrig));
/* replace extension */
if (BLI_testextensie(path, ".blend")) {
@@ -1809,5 +2092,16 @@ void pathGamePythonConfig( char *path )
void setGamePythonPath(char *path)
{
BLI_strncpy(gp_GamePythonPath, path, sizeof(gp_GamePythonPath));
+ BLI_cleanup_file(NULL, gp_GamePythonPath); /* not absolutely needed but makes resolving path problems less confusing later */
+
+ if (gp_GamePythonPathOrig[0] == '\0')
+ BLI_strncpy(gp_GamePythonPathOrig, path, sizeof(gp_GamePythonPathOrig));
}
+// we need this so while blender is open (not blenderplayer)
+// loading new blendfiles will reset this on starting the
+// engine but loading blend files within the BGE wont overwrite gp_GamePythonPathOrig
+void resetGamePythonPath()
+{
+ gp_GamePythonPathOrig[0] == '\0';
+}
diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h
index 11360197b95..8f102d13a18 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.h
+++ b/source/gameengine/Ketsji/KX_PythonInit.h
@@ -45,6 +45,7 @@ PyObject* initGameKeys();
PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas);
PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie, int argc, char** argv);
PyObject* initMathutils();
+PyObject* initGeometry();
PyObject* initBGL();
PyObject* initVideoTexture(void);
void exitGamePlayerPythonScripting();
@@ -52,6 +53,7 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev
void exitGamePythonScripting();
void setGamePythonPath(char *path);
+void resetGamePythonPath();
void pathGamePythonConfig( char *path );
int saveGamePythonConfig( char **marshal_buffer);
int loadGamePythonConfig(char *marshal_buffer, int marshal_length);
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
index dcd11b551a1..83c4dcbb34c 100644
--- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
@@ -51,6 +51,7 @@
#include "KX_PhysicsObjectWrapper.h"
#include "KX_PolyProxy.h"
#include "KX_PolygonMaterial.h"
+#include "KX_PythonSeq.h"
#include "KX_SCA_AddObjectActuator.h"
#include "KX_SCA_EndObjectActuator.h"
#include "KX_SCA_ReplaceMeshActuator.h"
@@ -84,6 +85,7 @@
#include "SCA_PropertySensor.h"
#include "SCA_PythonController.h"
#include "SCA_RandomActuator.h"
+#include "SCA_IController.h"
void initPyObjectPlusType(PyTypeObject **parents)
@@ -225,9 +227,10 @@ void initPyTypes(void)
PyType_Ready_Attr(dict, SCA_RandomSensor);
PyType_Ready_Attr(dict, SCA_XNORController);
PyType_Ready_Attr(dict, SCA_XORController);
+ PyType_Ready_Attr(dict, SCA_IController);
-
-
+ /* Normal python type */
+ PyType_Ready(&KX_PythonSeq_Type);
}
#endif \ No newline at end of file
diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp
new file mode 100644
index 00000000000..cc8021fc2e4
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp
@@ -0,0 +1,382 @@
+/**
+ * $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: none of this file.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * Readonly sequence wrapper for lookups on logic bricks
+ */
+
+
+#include "KX_PythonSeq.h"
+#include "KX_GameObject.h"
+#include "SCA_ISensor.h"
+#include "SCA_IController.h"
+#include "SCA_IActuator.h"
+
+
+PyObject *KX_PythonSeq_CreatePyObject( PyObject *base, short type )
+{
+ KX_PythonSeq *seq = PyObject_NEW( KX_PythonSeq, &KX_PythonSeq_Type);
+ seq->base = base;
+ Py_INCREF(base); /* so we can always access to check if its valid */
+ seq->type = type;
+ seq->iter = -1; /* init */
+ return (PyObject *)seq;
+ }
+
+ static void KX_PythonSeq_dealloc( KX_PythonSeq * self )
+{
+ Py_DECREF(self->base);
+ PyObject_DEL( self );
+}
+
+static Py_ssize_t KX_PythonSeq_len( PyObject * self )
+{
+ PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base);
+
+ if(self_plus==NULL) {
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
+ return -1;
+ }
+
+ switch(((KX_PythonSeq *)self)->type) {
+ case KX_PYGENSEQ_CONT_TYPE_SENSORS:
+ return ((SCA_IController *)self_plus)->GetLinkedSensors().size();
+ case KX_PYGENSEQ_CONT_TYPE_ACTUATORS:
+ return ((SCA_IController *)self_plus)->GetLinkedActuators().size();
+ case KX_PYGENSEQ_OB_TYPE_SENSORS:
+ return ((KX_GameObject *)self_plus)->GetSensors().size();
+ case KX_PYGENSEQ_OB_TYPE_CONTROLLERS:
+ return ((KX_GameObject *)self_plus)->GetControllers().size();
+ case KX_PYGENSEQ_OB_TYPE_ACTUATORS:
+ return ((KX_GameObject *)self_plus)->GetActuators().size();
+ default:
+ /* Should never happen */
+ PyErr_SetString(PyExc_SystemError, "invalid type, internal error");
+ return -1;
+ }
+}
+
+static PyObject *KX_PythonSeq_getIndex(PyObject* self, int index)
+{
+ PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base);
+
+ if(self_plus==NULL) {
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
+ return NULL;
+ }
+
+ switch(((KX_PythonSeq *)self)->type) {
+ case KX_PYGENSEQ_CONT_TYPE_SENSORS:
+ {
+ vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors();
+ if(index<0) index += linkedsensors.size();
+ if(index<0 || index>= linkedsensors.size()) {
+ PyErr_SetString(PyExc_IndexError, "seq[i]: index out of range");
+ return NULL;
+ }
+ return linkedsensors[index]->GetProxy();
+ }
+ case KX_PYGENSEQ_CONT_TYPE_ACTUATORS:
+ {
+ vector<SCA_IActuator*>& linkedactuators = ((SCA_IController *)self_plus)->GetLinkedActuators();
+ if(index<0) index += linkedactuators.size();
+ if(index<0 || index>= linkedactuators.size()) {
+ PyErr_SetString(PyExc_IndexError, "seq[i]: index out of range");
+ return NULL;
+ }
+ return linkedactuators[index]->GetProxy();
+ }
+ case KX_PYGENSEQ_OB_TYPE_SENSORS:
+ {
+ SCA_SensorList& linkedsensors= ((KX_GameObject *)self_plus)->GetSensors();
+ if(index<0) index += linkedsensors.size();
+ if(index<0 || index>= linkedsensors.size()) {
+ PyErr_SetString(PyExc_IndexError, "seq[i]: index out of range");
+ return NULL;
+ }
+ return linkedsensors[index]->GetProxy();
+ }
+ case KX_PYGENSEQ_OB_TYPE_CONTROLLERS:
+ {
+ SCA_ControllerList& linkedcontrollers= ((KX_GameObject *)self_plus)->GetControllers();
+ if(index<0) index += linkedcontrollers.size();
+ if(index<0 || index>= linkedcontrollers.size()) {
+ PyErr_SetString(PyExc_IndexError, "seq[i]: index out of range");
+ return NULL;
+ }
+ return linkedcontrollers[index]->GetProxy();
+ }
+ case KX_PYGENSEQ_OB_TYPE_ACTUATORS:
+ {
+ SCA_ActuatorList& linkedactuators= ((KX_GameObject *)self_plus)->GetActuators();
+ if(index<0) index += linkedactuators.size();
+ if(index<0 || index>= linkedactuators.size()) {
+ PyErr_SetString(PyExc_IndexError, "seq[i]: index out of range");
+ return NULL;
+ }
+ return linkedactuators[index]->GetProxy();
+ }
+ }
+
+ PyErr_SetString(PyExc_SystemError, "invalid sequence type, this is a bug");
+ return NULL;
+}
+
+
+static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key)
+{
+ PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base);
+ char *name = NULL;
+
+ if(self_plus==NULL) {
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
+ return NULL;
+ }
+
+ if (PyInt_Check(key)) {
+ return KX_PythonSeq_getIndex(self, PyInt_AS_LONG( key ));
+ } else if ( PyString_Check(key) ) {
+ name = PyString_AsString( key );
+ } else {
+ PyErr_SetString( PyExc_TypeError, "expected a string or an index" );
+ return NULL;
+ }
+
+ switch(((KX_PythonSeq *)self)->type) {
+ case KX_PYGENSEQ_CONT_TYPE_SENSORS:
+ {
+ vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors();
+ SCA_ISensor* sensor;
+ for (unsigned int index=0;index<linkedsensors.size();index++) {
+ sensor = linkedsensors[index];
+ if (sensor->GetName() == name)
+ return sensor->GetProxy();
+ }
+ break;
+ }
+ case KX_PYGENSEQ_CONT_TYPE_ACTUATORS:
+ {
+ vector<SCA_IActuator*>& linkedactuators = ((SCA_IController *)self_plus)->GetLinkedActuators();
+ SCA_IActuator* actuator;
+ for (unsigned int index=0;index<linkedactuators.size();index++) {
+ actuator = linkedactuators[index];
+ if (actuator->GetName() == name)
+ return actuator->GetProxy();
+ }
+ break;
+ }
+ case KX_PYGENSEQ_OB_TYPE_SENSORS:
+ {
+ SCA_SensorList& linkedsensors= ((KX_GameObject *)self_plus)->GetSensors();
+ SCA_ISensor *sensor;
+ for (unsigned int index=0;index<linkedsensors.size();index++) {
+ sensor= linkedsensors[index];
+ if (sensor->GetName() == name)
+ return sensor->GetProxy();
+ }
+ break;
+ }
+ case KX_PYGENSEQ_OB_TYPE_CONTROLLERS:
+ {
+ SCA_ControllerList& linkedcontrollers= ((KX_GameObject *)self_plus)->GetControllers();
+ SCA_IController *controller;
+ for (unsigned int index=0;index<linkedcontrollers.size();index++) {
+ controller= linkedcontrollers[index];
+ if (controller->GetName() == name)
+ return controller->GetProxy();
+ }
+ break;
+ }
+ case KX_PYGENSEQ_OB_TYPE_ACTUATORS:
+ {
+ SCA_ActuatorList& linkedactuators= ((KX_GameObject *)self_plus)->GetActuators();
+ SCA_IActuator *actuator;
+ for (unsigned int index=0;index<linkedactuators.size();index++) {
+ actuator= linkedactuators[index];
+ if (actuator->GetName() == name)
+ return actuator->GetProxy();
+ }
+ break;
+ }
+ }
+
+ PyErr_Format( PyExc_KeyError, "requested item \"%s\" does not exist", name);
+ return NULL;
+}
+
+static PyMappingMethods KX_PythonSeq_as_mapping = {
+ KX_PythonSeq_len, /* mp_length */
+ KX_PythonSeq_subscript, /* mp_subscript */
+ 0, /* mp_ass_subscript */
+};
+
+
+/*
+ * Initialize the interator index
+ */
+
+static PyObject *KX_PythonSeq_getIter(KX_PythonSeq *self)
+{
+ if(BGE_PROXY_REF(self->base)==NULL) {
+ PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
+ return NULL;
+ }
+
+ /* create a new iterator if were alredy using this one */
+ if (self->iter == -1) {
+ self->iter = 0;
+ Py_INCREF(self);
+ return (PyObject *)self;
+ } else {
+ return KX_PythonSeq_CreatePyObject(self->base, self->type);
+ }
+ }
+
+
+/*
+ * Return next KX_PythonSeq iter.
+ */
+
+static PyObject *KX_PythonSeq_nextIter(KX_PythonSeq *self)
+{
+ PyObject *object = KX_PythonSeq_getIndex((PyObject *)self, self->iter);
+
+ self->iter++;
+ if( object==NULL ) {
+ self->iter= -1; /* for reuse */
+ PyErr_SetString(PyExc_StopIteration, "iterator at end");
+ }
+ return object; /* can be NULL for end of iterator */
+}
+
+
+static int KX_PythonSeq_compare( KX_PythonSeq * a, KX_PythonSeq * b ) /* TODO - python3.x wants richcmp */
+{
+ return ( a->type == b->type && a->base == b->base) ? 0 : -1;
+}
+
+/*
+ * repr function
+ * convert to a list and get its string value
+ */
+static PyObject *KX_PythonSeq_repr( KX_PythonSeq * self )
+{
+ PyObject *list = PySequence_List((PyObject *)self);
+ PyObject *repr = PyObject_Repr(list);
+ Py_DECREF(list);
+ return repr;
+}
+
+
+/*****************************************************************************/
+/* Python KX_PythonSeq_Type structure definition: */
+/*****************************************************************************/
+PyTypeObject KX_PythonSeq_Type = {
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
+ /* For printing, in format "<module>.<name>" */
+ "KX_PythonSeq", /* char *tp_name; */
+ sizeof( KX_PythonSeq ), /* int tp_basicsize; */
+ 0, /* tp_itemsize; For allocation */
+
+ /* Methods to implement standard operations */
+
+ ( destructor ) KX_PythonSeq_dealloc, /* destructor tp_dealloc; */
+ NULL, /* printfunc tp_print; */
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
+ ( cmpfunc ) KX_PythonSeq_compare, /* cmpfunc tp_compare; */
+ ( reprfunc ) KX_PythonSeq_repr, /* reprfunc tp_repr; */
+
+ /* Method suites for standard classes */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ &KX_PythonSeq_as_mapping, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ ( getiterfunc) KX_PythonSeq_getIter, /* getiterfunc tp_iter; */
+ ( iternextfunc ) KX_PythonSeq_nextIter, /* iternextfunc tp_iternext; */
+
+ /*** Attribute descriptor and subclassing stuff ***/
+ NULL, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ NULL, /* struct PyGetSetDef *tp_getset; */
+ NULL, /* struct _typeobject *tp_base; */
+ NULL, /* PyObject *tp_dict; */
+ NULL, /* descrgetfunc tp_descr_get; */
+ NULL, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ NULL, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ NULL, /* newfunc tp_new; */
+ /* Low-level free-memory routine */
+ NULL, /* freefunc tp_free; */
+ /* For PyObject_IS_GC */
+ NULL, /* inquiry tp_is_gc; */
+ NULL, /* PyObject *tp_bases; */
+ /* method resolution order */
+ NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_cache; */
+ NULL, /* PyObject *tp_subclasses; */
+ NULL, /* PyObject *tp_weaklist; */
+ NULL
+};
diff --git a/source/gameengine/Ketsji/KX_PythonSeq.h b/source/gameengine/Ketsji/KX_PythonSeq.h
new file mode 100644
index 00000000000..15a016224a9
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_PythonSeq.h
@@ -0,0 +1,60 @@
+/**
+ * $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): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * Readonly sequence wrapper for lookups on logic bricks
+ */
+
+#ifndef _adr_py_seq_h_ // only process once,
+#define _adr_py_seq_h_ // even if multiply included
+
+#include "PyObjectPlus.h"
+
+// -------------------------
+enum KX_PYGENSEQ_TYPE {
+ KX_PYGENSEQ_CONT_TYPE_SENSORS,
+ KX_PYGENSEQ_CONT_TYPE_ACTUATORS,
+ KX_PYGENSEQ_OB_TYPE_SENSORS,
+ KX_PYGENSEQ_OB_TYPE_CONTROLLERS,
+ KX_PYGENSEQ_OB_TYPE_ACTUATORS
+};
+
+/* The Main PyType Object defined in Main.c */
+extern PyTypeObject KX_PythonSeq_Type;
+
+#define BPy_KX_PythonSeq_Check(v) \
+ ((v)->ob_type == &KX_PythonSeq_Type)
+
+typedef struct {
+ PyObject_VAR_HEAD
+ PyObject *base;
+ short type;
+ short iter;
+} KX_PythonSeq;
+
+PyObject *KX_PythonSeq_CreatePyObject(PyObject *base, short type);
+
+#endif // _adr_py_seq_h_
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
index 8277e7ef19c..064dc9126ac 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp
@@ -30,6 +30,7 @@
#include "KX_GameObject.h"
#include "KX_PyMath.h"
#include "PHY_IPhysicsController.h"
+#include "PHY_IMotionState.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -66,7 +67,7 @@ KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr,
m_coneheight(coneheight),
m_axis(axis)
{
- m_client_info->m_type = KX_ClientObjectInfo::RADAR;
+ m_client_info->m_type = KX_ClientObjectInfo::SENSOR;
//m_client_info->m_clientobject = gameobj;
//m_client_info->m_auxilary_info = NULL;
//sumoObj->setClientObject(&m_client_info);
@@ -80,35 +81,10 @@ KX_RadarSensor::~KX_RadarSensor()
CValue* KX_RadarSensor::GetReplica()
{
KX_RadarSensor* replica = new KX_RadarSensor(*this);
- replica->m_colliders = new CListValue();
- replica->Init();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
- replica->m_client_info = new KX_ClientObjectInfo(m_client_info->m_gameobject, KX_ClientObjectInfo::RADAR);
-
- if (replica->m_physCtrl)
- {
- replica->m_physCtrl = replica->m_physCtrl->GetReplica();
- if (replica->m_physCtrl)
- {
- replica->m_physCtrl->setNewClientInfo(replica->m_client_info);
- }
- }
-
- //todo: make sure replication works fine!
- //>m_sumoObj = new SM_Object(DT_NewCone(m_coneradius, m_coneheight),NULL,NULL,NULL);
- //replica->m_sumoObj->setMargin(m_Margin);
- //replica->m_sumoObj->setClientObject(replica->m_client_info);
- //Wrong: see KX_TouchSensor
- //bool parentUpdated = false;
- //((KX_GameObject*)replica->GetParent())->GetSGNode()->ComputeWorldTransforms(NULL,parentUpdated);
- replica->SynchronizeTransform();
-
+ replica->ProcessReplica();
return replica;
}
-
/**
* Transforms the collision object. A cone is not correctly centered
* for usage. */
@@ -188,11 +164,13 @@ void KX_RadarSensor::SynchronizeTransform()
if (m_physCtrl)
{
- MT_Quaternion orn = trans.getRotation();
- MT_Point3 pos = trans.getOrigin();
- m_physCtrl->setPosition(pos[0],pos[1],pos[2]);
- m_physCtrl->setOrientation(orn[0],orn[1],orn[2],orn[3]);
- m_physCtrl->calcXform();
+ PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
+ const MT_Point3& pos = trans.getOrigin();
+ float ori[12];
+ trans.getBasis().getValue(ori);
+ motionState->setWorldPosition(pos[0], pos[1], pos[2]);
+ motionState->setWorldOrientation(ori);
+ m_physCtrl->WriteMotionStateToDynamics(true);
}
}
@@ -212,9 +190,9 @@ PyObject* KX_RadarSensor::PyGetConeOrigin() {
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_cone_origin[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_cone_origin[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_cone_origin[2]));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_cone_origin[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_cone_origin[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_cone_origin[2]));
return retVal;
}
@@ -228,9 +206,9 @@ PyObject* KX_RadarSensor::PyGetConeTarget() {
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_cone_target[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_cone_target[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_cone_target[2]));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_cone_target[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_cone_target[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_cone_target[2]));
return retVal;
}
@@ -251,8 +229,13 @@ PyObject* KX_RadarSensor::PyGetConeHeight() {
/* Python Integration Hooks */
/* ------------------------------------------------------------------------- */
PyTypeObject KX_RadarSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_RadarSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -294,6 +277,7 @@ PyMethodDef KX_RadarSensor::Methods[] = {
PyAttributeDef KX_RadarSensor::Attributes[] = {
KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneOrigin", KX_RadarSensor, m_cone_origin, 3),
KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneTarget", KX_RadarSensor, m_cone_target, 3),
+ KX_PYATTRIBUTE_FLOAT_RO("distance", KX_RadarSensor, m_coneheight),
KX_PYATTRIBUTE_FLOAT_RW("angle", 0, 360, KX_RadarSensor, m_coneradius),
KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RadarSensor, m_axis),
{NULL} //Sentinel
@@ -304,6 +288,10 @@ 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 c3a941696ce..2e5a0e68bed 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.h
+++ b/source/gameengine/Ketsji/KX_RadarSensor.h
@@ -90,7 +90,9 @@ public:
};
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject* value);
+ virtual sensortype GetSensorType() { return ST_RADAR; }
//Deprecated ----->
KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeOrigin);
diff --git a/source/gameengine/Ketsji/KX_RayEventManager.cpp b/source/gameengine/Ketsji/KX_RayEventManager.cpp
index 1af29151adf..50fa4f5e310 100644
--- a/source/gameengine/Ketsji/KX_RayEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_RayEventManager.cpp
@@ -44,9 +44,10 @@ using namespace std;
void KX_RayEventManager::NextFrame()
{
- for (set<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- (*i)->Activate(m_logicmgr, NULL);
+ (*it)->Activate(m_logicmgr);
}
}
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 06c04dbf10d..78a61e9d95e 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -88,8 +88,7 @@ KX_RaySensor::~KX_RaySensor()
CValue* KX_RaySensor::GetReplica()
{
KX_RaySensor* replica = new KX_RaySensor(*this);
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
replica->Init();
return replica;
@@ -179,7 +178,7 @@ bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo* client)
return true;
}
-bool KX_RaySensor::Evaluate(CValue* event)
+bool KX_RaySensor::Evaluate()
{
bool result = false;
bool reset = m_reset && m_level;
@@ -321,8 +320,13 @@ bool KX_RaySensor::Evaluate(CValue* event)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_RaySensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_RaySensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -362,7 +366,7 @@ PyAttributeDef KX_RaySensor::Attributes[] = {
KX_PYATTRIBUTE_BOOL_RW("useMaterial", KX_RaySensor, m_bFindMaterial),
KX_PYATTRIBUTE_BOOL_RW("useXRay", KX_RaySensor, m_bXRay),
KX_PYATTRIBUTE_FLOAT_RW("range", 0, 10000, KX_RaySensor, m_distance),
- KX_PYATTRIBUTE_STRING_RW("property", 0, 100, false, KX_RaySensor, m_propertyname),
+ KX_PYATTRIBUTE_STRING_RW("propName", 0, 100, false, KX_RaySensor, m_propertyname),
KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RaySensor, m_axis),
KX_PYATTRIBUTE_FLOAT_ARRAY_RO("hitPosition", KX_RaySensor, m_hitPosition, 3),
KX_PYATTRIBUTE_FLOAT_ARRAY_RO("rayDirection", KX_RaySensor, m_rayDirection, 3),
@@ -404,9 +408,9 @@ PyObject* KX_RaySensor::PyGetHitPosition()
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_hitPosition[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_hitPosition[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_hitPosition[2]));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_hitPosition[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_hitPosition[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_hitPosition[2]));
return retVal;
}
@@ -420,9 +424,9 @@ PyObject* KX_RaySensor::PyGetRayDirection()
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_rayDirection[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_rayDirection[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_rayDirection[2]));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_rayDirection[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_rayDirection[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_rayDirection[2]));
return retVal;
}
@@ -436,9 +440,9 @@ PyObject* KX_RaySensor::PyGetHitNormal()
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_hitNormal[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_hitNormal[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_hitNormal[2]));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_hitNormal[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_hitNormal[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_hitNormal[2]));
return retVal;
}
@@ -449,6 +453,10 @@ 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);
}
diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h
index a5d7d15c60c..9efb046742f 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.h
+++ b/source/gameengine/Ketsji/KX_RaySensor.h
@@ -67,7 +67,7 @@ public:
virtual ~KX_RaySensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
@@ -87,6 +87,7 @@ public:
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
// Deprecated ----->
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index c45d89a2815..75435b97797 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -86,7 +86,7 @@ KX_SCA_AddObjectActuator::~KX_SCA_AddObjectActuator()
if (m_OriginalObject)
m_OriginalObject->UnregisterActuator(this);
if (m_lastCreatedObject)
- m_lastCreatedObject->Release();
+ m_lastCreatedObject->UnregisterActuator(this);
}
@@ -124,7 +124,6 @@ CValue* KX_SCA_AddObjectActuator::GetReplica()
// this will copy properties and so on...
replica->ProcessReplica();
- CValue::AddDataToReplica(replica);
return replica;
}
@@ -145,6 +144,12 @@ bool KX_SCA_AddObjectActuator::UnlinkObject(SCA_IObject* clientobj)
m_OriginalObject = NULL;
return true;
}
+ if (clientobj == m_lastCreatedObject)
+ {
+ // this object is being deleted, we cannot continue to track it.
+ m_lastCreatedObject = NULL;
+ return true;
+ }
return false;
}
@@ -166,8 +171,13 @@ void KX_SCA_AddObjectActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_SCA_AddObjectActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_SCA_AddObjectActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -231,7 +241,7 @@ int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYAT
KX_GameObject *gameobj;
if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_SCA_AddObjectActuator"))
- return 1; // ConvertPythonToGameObject sets the error
+ return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
if (actuator->m_OriginalObject != NULL)
actuator->m_OriginalObject->UnregisterActuator(actuator);
@@ -241,7 +251,7 @@ int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYAT
if (actuator->m_OriginalObject)
actuator->m_OriginalObject->RegisterActuator(actuator);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
@@ -259,6 +269,10 @@ 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);
@@ -347,7 +361,7 @@ PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_OriginalObject->GetName());
+ return PyString_FromString(m_OriginalObject->GetName().ReadPtr());
else
return m_OriginalObject->GetProxy();
}
@@ -455,13 +469,21 @@ void KX_SCA_AddObjectActuator::InstantAddObject()
// keep a copy of the last object, to allow python scripters to change it
if (m_lastCreatedObject)
{
- //careful with destruction, it might still have outstanding collision callbacks
- m_scene->DelayedReleaseObject(m_lastCreatedObject);
- m_lastCreatedObject->Release();
+ //Let's not keep a reference to the object: it's bad, if the object is deleted
+ //this will force to keep a "zombie" in the game for no good reason.
+ //m_scene->DelayedReleaseObject(m_lastCreatedObject);
+ //m_lastCreatedObject->Release();
+
+ //Instead we use the registration mechanism
+ m_lastCreatedObject->UnregisterActuator(this);
+ m_lastCreatedObject = NULL;
}
m_lastCreatedObject = replica;
- m_lastCreatedObject->AddRef();
+ // no reference
+ //m_lastCreatedObject->AddRef();
+ // but registration
+ m_lastCreatedObject->RegisterActuator(this);
// finished using replica? then release it
replica->Release();
}
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
index 4ece5a6d83b..6746b7d1bc6 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
@@ -111,6 +111,7 @@ public:
Update();
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject* value);
SCA_IObject*
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
index 83dfdc2484c..a50764a54e6 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
@@ -50,8 +50,13 @@
PyTypeObject
KX_SCA_DynamicActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_SCA_DynamicActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -85,7 +90,7 @@ PyMethodDef KX_SCA_DynamicActuator::Methods[] = {
};
PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = {
- KX_PYATTRIBUTE_SHORT_RW("operation",0,4,false,KX_SCA_DynamicActuator,m_dyn_operation),
+ KX_PYATTRIBUTE_SHORT_RW("mode",0,4,false,KX_SCA_DynamicActuator,m_dyn_operation),
KX_PYATTRIBUTE_FLOAT_RW("mass",0.0,FLT_MAX,KX_SCA_DynamicActuator,m_setmass),
{ NULL } //Sentinel
};
@@ -96,6 +101,10 @@ 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);
@@ -112,7 +121,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, setOperation,
"\t 3 = disable rigid body\n"
"Change the dynamic status of the parent object.\n")
{
- ShowDeprecationWarning("setOperation()", "the operation property");
+ ShowDeprecationWarning("setOperation()", "the mode property");
int dyn_operation;
if (!PyArg_ParseTuple(args, "i:setOperation", &dyn_operation))
@@ -132,7 +141,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, getOperation,
"Returns the operation type of this actuator.\n"
)
{
- ShowDeprecationWarning("getOperation()", "the operation property");
+ ShowDeprecationWarning("getOperation()", "the mode property");
return PyInt_FromLong((long)m_dyn_operation);
}
@@ -210,10 +219,6 @@ CValue* KX_SCA_DynamicActuator::GetReplica()
return NULL;
replica->ProcessReplica();
-
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
return replica;
};
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
index 99855124bdb..4add707f8cd 100644
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
@@ -75,6 +75,7 @@ class KX_SCA_DynamicActuator : public SCA_IActuator
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
/* 1. setOperation */
diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
index 3b42577810e..728254e7f48 100644
--- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
@@ -82,8 +82,6 @@ CValue* KX_SCA_EndObjectActuator::GetReplica()
if (replica == NULL) return NULL;
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
};
@@ -94,8 +92,13 @@ CValue* KX_SCA_EndObjectActuator::GetReplica()
/* ------------------------------------------------------------------------- */
PyTypeObject KX_SCA_EndObjectActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_SCA_EndObjectActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -136,4 +139,8 @@ 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 2940246f443..70d72f1f8da 100644
--- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
@@ -65,6 +65,7 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
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 38f8d581d55..00842d7012a 100644
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
@@ -53,8 +53,13 @@
PyTypeObject
KX_SCA_ReplaceMeshActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_SCA_ReplaceMeshActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -99,6 +104,10 @@ 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);
@@ -119,10 +128,10 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT
RAS_MeshObject* new_mesh;
if (!ConvertPythonToMesh(value, &new_mesh, true, "actuator.mesh = value: KX_SCA_ReplaceMeshActuator"))
- return 1;
+ return PY_SET_ATTR_FAIL;
actuator->m_mesh = new_mesh;
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
/* 1. setMesh */
@@ -213,9 +222,6 @@ CValue* KX_SCA_ReplaceMeshActuator::GetReplica()
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
return replica;
};
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
index 7a18df2356d..0e7f7852701 100644
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
@@ -72,6 +72,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);
static PyObject* pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
index 0e7571031e8..cb933419c57 100644
--- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
+++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
@@ -125,7 +125,9 @@ UpdateChildCoordinates(
else {
child->SetWorldFromLocalTransform();
}
- child->SetModified(false);
+ child->ClearModified();
+ // this node must always be updated, so reschedule it for next time
+ child->ActivateRecheduleUpdateCallback();
return valid_parent_transform;
}
diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp
index c3b0c21c8e0..c49b6d671a7 100644
--- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp
+++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp
@@ -63,7 +63,7 @@ UpdateChildCoordinates(
if (parent==NULL) { /* Simple case */
child->SetWorldFromLocalTransform();
- child->SetModified(false);
+ child->ClearModified();
return true; //false;
}
else {
@@ -75,7 +75,7 @@ UpdateChildCoordinates(
child->SetWorldScale(p_world_scale * child->GetLocalScale());
child->SetWorldOrientation(p_world_rotation * child->GetLocalOrientation());
child->SetWorldPosition(p_world_pos + p_world_scale * (p_world_rotation * child->GetLocalPosition()));
- child->SetModified(false);
+ child->ClearModified();
return true;
}
}
@@ -137,7 +137,7 @@ UpdateChildCoordinates(
child->SetWorldPosition(child->GetLocalPosition());
child->SetWorldOrientation(child->GetLocalOrientation());
- child->SetModified(false);
+ child->ClearModified();
return true; //parent != NULL;
}
@@ -259,7 +259,9 @@ UpdateChildCoordinates(
child->SetWorldScale(child_w_scale);
child->SetWorldPosition(child_w_pos);
child->SetWorldOrientation(child_w_rotation);
- child->SetModified(false);
+ child->ClearModified();
+ // this node must always be updated, so reschedule it for next time
+ child->ActivateRecheduleUpdateCallback();
return true; //parent != NULL;
}
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index aa7bd65f240..c0d8a7090c4 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -34,7 +34,7 @@
#include "KX_Scene.h"
#include "MT_assert.h"
-
+#include "SND_Scene.h"
#include "KX_KetsjiEngine.h"
#include "KX_BlenderMaterial.h"
#include "RAS_IPolygonMaterial.h"
@@ -80,6 +80,7 @@
#include "KX_BlenderSceneConverter.h"
#include "KX_MotionState.h"
+#include "BL_ModifierDeformer.h"
#include "BL_ShapeDeformer.h"
#include "BL_DeformableGameObject.h"
@@ -110,7 +111,22 @@ void* KX_SceneDestructionFunc(SG_IObject* node,void* gameobj,void* scene)
return NULL;
};
-SG_Callbacks KX_Scene::m_callbacks = SG_Callbacks(KX_SceneReplicationFunc,KX_SceneDestructionFunc,KX_GameObject::UpdateTransformFunc);
+bool KX_Scene::KX_ScenegraphUpdateFunc(SG_IObject* node,void* gameobj,void* scene)
+{
+ return ((SG_Node*)node)->Schedule(((KX_Scene*)scene)->m_sghead);
+}
+
+bool KX_Scene::KX_ScenegraphRescheduleFunc(SG_IObject* node,void* gameobj,void* scene)
+{
+ return ((SG_Node*)node)->Reschedule(((KX_Scene*)scene)->m_sghead);
+}
+
+SG_Callbacks KX_Scene::m_callbacks = SG_Callbacks(
+ KX_SceneReplicationFunc,
+ KX_SceneDestructionFunc,
+ KX_GameObject::UpdateTransformFunc,
+ KX_Scene::KX_ScenegraphUpdateFunc,
+ KX_Scene::KX_ScenegraphRescheduleFunc);
// temporarily var until there is a button in the userinterface
// (defined in KX_PythonInit.cpp)
@@ -148,7 +164,6 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
m_lightlist= new CListValue();
m_inactivelist = new CListValue();
m_euthanasyobjects = new CListValue();
- m_delayReleaseObjects = new CListValue();
m_logicmgr = new SCA_LogicManager();
@@ -192,9 +207,6 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
m_rootnode = NULL;
m_bucketmanager=new RAS_BucketManager();
-
- m_canvasDesignWidth = 0;
- m_canvasDesignHeight = 0;
m_attr_dict = PyDict_New(); /* new ref */
}
@@ -231,8 +243,6 @@ KX_Scene::~KX_Scene()
if (m_euthanasyobjects)
m_euthanasyobjects->Release();
- if (m_delayReleaseObjects)
- m_delayReleaseObjects->Release();
if (m_logicmgr)
delete m_logicmgr;
@@ -254,13 +264,6 @@ KX_Scene::~KX_Scene()
Py_DECREF(m_attr_dict);
}
-void KX_Scene::SetProjectionMatrix(MT_CmMatrix4x4& pmat)
-{
- m_projectionmat = pmat;
-}
-
-
-
RAS_BucketManager* KX_Scene::GetBucketManager()
{
return m_bucketmanager;
@@ -408,11 +411,11 @@ void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gam
KX_GameObject* orgobj = (KX_GameObject*)gameobj;
if (NewRemoveObject(orgobj) != 0)
{
- // object is not yet deleted (this can happen when it hangs in an add object actuator
- // last object created reference. It's a bad situation, don't know how to fix it exactly
- // The least I can do, is remove the reference to the node in the object as the node
- // will in any case be deleted. This ensures that the object will not try to use the node
- // when it is finally deleted (see KX_GameObject destructor)
+ // object is not yet deleted because a reference is hanging somewhere.
+ // This should not happen anymore since we use proxy object for Python
+ // confident enough to put an assert?
+ //assert(false);
+ printf("Zombie object! name=%s\n", orgobj->GetName().ReadPtr());
orgobj->SetSGNode(NULL);
PHY_IGraphicController* ctrl = orgobj->GetGraphicController();
if (ctrl)
@@ -477,6 +480,8 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
// this is the list of object that are send to the graphics pipeline
m_objectlist->Add(newobj->AddRef());
+ if (newobj->IsLight())
+ m_lightlist->Add(newobj->AddRef());
newobj->AddMeshUser();
// logic cannot be replicated, until the whole hierarchy is replicated.
@@ -537,8 +542,9 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
vector<SCA_IActuator*> linkedactuators = cont->GetLinkedActuators();
// disconnect the sensors and actuators
- cont->UnlinkAllSensors();
- cont->UnlinkAllActuators();
+ // do it directly on the list at this controller is not connected to anything at this stage
+ cont->GetLinkedSensors().clear();
+ cont->GetLinkedActuators().clear();
// now relink each sensor
for (vector<SCA_ISensor*>::iterator its = linkedsensors.begin();!(its==linkedsensors.end());its++)
@@ -716,16 +722,20 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
// set the replica's relative scale with the rootnode's scale
replica->NodeSetRelativeScale(newscale);
- MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldOrientation();
- replica->NodeSetLocalOrientation(newori);
MT_Point3 offset(group->dupli_ofs);
MT_Point3 newpos = groupobj->NodeGetWorldPosition() +
newscale*(groupobj->NodeGetWorldOrientation() * (gameobj->NodeGetWorldPosition()-offset));
replica->NodeSetLocalPosition(newpos);
-
+ // set the orientation after position for softbody!
+ MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldOrientation();
+ replica->NodeSetLocalOrientation(newori);
+ // update scenegraph for entire tree of children
replica->GetSGNode()->UpdateWorldData(0);
replica->GetSGNode()->SetBBox(gameobj->GetSGNode()->BBox());
replica->GetSGNode()->SetRadius(gameobj->GetSGNode()->Radius());
+ // we can now add the graphic controller to the physic engine
+ replica->ActivateGraphicController(true);
+
// done with replica
replica->Release();
}
@@ -836,6 +846,8 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
replica->GetSGNode()->UpdateWorldData(0);
replica->GetSGNode()->SetBBox(originalobj->GetSGNode()->BBox());
replica->GetSGNode()->SetRadius(originalobj->GetSGNode()->Radius());
+ // the size is correct, we can add the graphic controller to the physic engine
+ replica->ActivateGraphicController(true);
// now replicate logic
vector<KX_GameObject*>::iterator git;
@@ -889,7 +901,7 @@ void KX_Scene::RemoveObject(class CValue* gameobj)
{
KX_GameObject* newobj = (KX_GameObject*) gameobj;
- // first disconnect child from parent
+ // disconnect child from parent
SG_Node* node = newobj->GetSGNode();
if (node)
@@ -903,12 +915,6 @@ void KX_Scene::RemoveObject(class CValue* gameobj)
//newobj->SetSGNode(0);
}
-void KX_Scene::DelayedReleaseObject(CValue* gameobj)
-{
- m_delayReleaseObjects->Add(gameobj->AddRef());
-}
-
-
void KX_Scene::DelayedRemoveObject(class CValue* gameobj)
{
//KX_GameObject* newobj = (KX_GameObject*) gameobj;
@@ -925,6 +931,13 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
int ret;
KX_GameObject* newobj = (KX_GameObject*) gameobj;
+ /* Invalidate the python reference, since the object may exist in script lists
+ * its possible that it wont be automatically invalidated, so do it manually here,
+ *
+ * if for some reason the object is added back into the scene python can always get a new Proxy
+ */
+ newobj->InvalidateProxy();
+
// keep the blender->game object association up to date
// note that all the replicas of an object will have the same
// blender object, that's why we need to check the game object
@@ -954,7 +967,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
for (SCA_ActuatorList::iterator ita = actuators.begin();
!(ita==actuators.end());ita++)
{
- m_logicmgr->RemoveDestroyedActuator(*ita);
+ m_logicmgr->RemoveActuator(*ita);
}
// the sensors/controllers/actuators must also be released, this is done in ~SCA_IObject
@@ -1038,6 +1051,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
Object* oldblendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName()));
Mesh* blendmesh = mesh->GetMesh();
+ bool bHasModifier = BL_ModifierDeformer::HasCompatibleDeformer(blendobj);
bool bHasShapeKey = blendmesh->key != NULL && blendmesh->key->type==KEY_RELATIVE;
bool bHasDvert = blendmesh->dvert != NULL;
bool bHasArmature =
@@ -1053,10 +1067,39 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
if (oldblendobj==NULL) {
std::cout << "warning: ReplaceMesh() new mesh is not used in an object from the current scene, you will get incorrect behavior" << std::endl;
- bHasShapeKey= bHasDvert= bHasArmature= false;
+ bHasShapeKey= bHasDvert= bHasArmature=bHasModifier= false;
}
- if (bHasShapeKey)
+ if (bHasModifier)
+ {
+ BL_ModifierDeformer* modifierDeformer;
+ if (bHasShapeKey || bHasArmature)
+ {
+ modifierDeformer = new BL_ModifierDeformer(
+ newobj,
+ m_blenderScene,
+ oldblendobj, blendobj,
+ static_cast<BL_SkinMeshObject*>(mesh),
+ true,
+ static_cast<BL_ArmatureObject*>( parentobj )
+ );
+ releaseParent= false;
+ modifierDeformer->LoadShapeDrivers(blendobj->parent);
+ }
+ else
+ {
+ modifierDeformer = new BL_ModifierDeformer(
+ newobj,
+ m_blenderScene,
+ oldblendobj, blendobj,
+ static_cast<BL_SkinMeshObject*>(mesh),
+ false,
+ NULL
+ );
+ }
+ newobj->SetDeformer(modifierDeformer);
+ }
+ else if (bHasShapeKey)
{
BL_ShapeDeformer* shapeDeformer;
if (bHasArmature)
@@ -1066,6 +1109,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
oldblendobj, blendobj,
static_cast<BL_SkinMeshObject*>(mesh),
true,
+ true,
static_cast<BL_ArmatureObject*>( parentobj )
);
releaseParent= false;
@@ -1078,6 +1122,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
oldblendobj, blendobj,
static_cast<BL_SkinMeshObject*>(mesh),
false,
+ true,
NULL
);
}
@@ -1090,6 +1135,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
oldblendobj, blendobj,
static_cast<BL_SkinMeshObject*>(mesh),
true,
+ true,
static_cast<BL_ArmatureObject*>( parentobj )
);
releaseParent= false;
@@ -1112,24 +1158,6 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
gameobj->AddMeshUser();
}
-
-
-MT_CmMatrix4x4& KX_Scene::GetViewMatrix()
-{
- MT_Scalar cammat[16];
- m_active_camera->GetWorldToCamera().getValue(cammat);
- m_viewmat = cammat;
- return m_viewmat;
-}
-
-
-
-MT_CmMatrix4x4& KX_Scene::GetProjectionMatrix()
-{
- return m_projectionmat;
-}
-
-
KX_Camera* KX_Scene::FindCamera(KX_Camera* cam)
{
list<KX_Camera*>::iterator it = m_cameras.begin();
@@ -1423,24 +1451,17 @@ void KX_Scene::LogicEndFrame()
{
m_logicmgr->EndFrame();
int numobj = m_euthanasyobjects->GetCount();
- int i;
- for (i = numobj - 1; i >= 0; i--)
- {
- KX_GameObject* gameobj = (KX_GameObject*)m_euthanasyobjects->GetValue(i);
- // KX_Scene::RemoveObject will also remove the object from this list
- // that's why we start from the end
- this->RemoveObject(gameobj);
- }
- numobj= m_delayReleaseObjects->GetCount();
- for (i = numobj-1;i>=0;i--)
+ KX_GameObject* obj;
+
+ while ((numobj = m_euthanasyobjects->GetCount()) > 0)
{
- KX_GameObject* gameobj = (KX_GameObject*)m_delayReleaseObjects->GetValue(i);
- // This list is not for object removal, but just object release
- gameobj->Release();
+ // remove the object from this list to make sure we will not hit it again
+ obj = (KX_GameObject*)m_euthanasyobjects->GetValue(numobj-1);
+ m_euthanasyobjects->Remove(numobj-1);
+ obj->Release();
+ RemoveObject(obj);
}
- // empty the list as we have removed all references
- m_delayReleaseObjects->Resize(0);
}
@@ -1450,15 +1471,28 @@ void KX_Scene::LogicEndFrame()
*/
void KX_Scene::UpdateParents(double curtime)
{
-// int numrootobjects = GetRootParentList()->GetCount();
+ // we use the SG dynamic list
+ SG_Node* node;
- for (int i=0; i<GetRootParentList()->GetCount(); i++)
+ while ((node = SG_Node::GetNextScheduled(m_sghead)) != NULL)
{
- KX_GameObject* parentobj = (KX_GameObject*)GetRootParentList()->GetValue(i);
- parentobj->NodeUpdateGS(curtime);
+ node->UpdateWorldData(curtime);
}
-}
+ //for (int i=0; i<GetRootParentList()->GetCount(); i++)
+ //{
+ // KX_GameObject* parentobj = (KX_GameObject*)GetRootParentList()->GetValue(i);
+ // parentobj->NodeUpdateGS(curtime);
+ //}
+
+ // the list must be empty here
+ assert(m_sghead.Empty());
+ // some nodes may be ready for reschedule, move them to schedule list for next time
+ while ((node = SG_Node::GetNextRescheduled(m_sghead)) != NULL)
+ {
+ node->Schedule(m_sghead);
+ }
+}
RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool &bucketCreated)
@@ -1579,8 +1613,13 @@ double KX_Scene::getSuspendedDelta()
//Python
PyTypeObject KX_Scene::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_Scene",
sizeof(PyObjectPlus_Proxy),
0,
@@ -1604,9 +1643,9 @@ PyParentObject KX_Scene::Parents[] = {
};
PyMethodDef KX_Scene::Methods[] = {
- KX_PYMETHODTABLE(KX_Scene, getLightList),
- KX_PYMETHODTABLE(KX_Scene, getObjectList),
- KX_PYMETHODTABLE(KX_Scene, getName),
+ KX_PYMETHODTABLE_NOARGS(KX_Scene, getLightList),
+ KX_PYMETHODTABLE_NOARGS(KX_Scene, getObjectList),
+ KX_PYMETHODTABLE_NOARGS(KX_Scene, getName),
KX_PYMETHODTABLE(KX_Scene, addObject),
{NULL,NULL} //Sentinel
@@ -1624,46 +1663,81 @@ PyObject* KX_Scene::pyattr_get_objects(void *self_v, const KX_PYATTRIBUTE_DEF *a
return self->GetObjectList()->GetProxy();
}
+PyObject* KX_Scene::pyattr_get_objects_inactive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_Scene* self= static_cast<KX_Scene*>(self_v);
+ return self->GetInactiveList()->GetProxy();
+}
+
+PyObject* KX_Scene::pyattr_get_lights(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_Scene* self= static_cast<KX_Scene*>(self_v);
+ return self->GetLightList()->GetProxy();
+}
+
+PyObject* KX_Scene::pyattr_get_cameras(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ /* With refcounts in this case...
+ * the new CListValue is owned by python, so its possible python holds onto it longer then the BGE
+ * however this is the same with "scene.objects + []", when you make a copy by adding lists.
+ */
+
+ KX_Scene* self= static_cast<KX_Scene*>(self_v);
+ CListValue* clist = new CListValue();
+
+ /* return self->GetCameras()->GetProxy(); */
+
+ list<KX_Camera*>::iterator it = self->GetCameras()->begin();
+ while (it != self->GetCameras()->end()) {
+ clist->Add((*it)->AddRef());
+ it++;
+ }
+
+ return clist->NewProxy(true);
+}
+
PyObject* KX_Scene::pyattr_get_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_Scene* self= static_cast<KX_Scene*>(self_v);
return self->GetActiveCamera()->GetProxy();
}
-/* __dict__ only for the purpose of giving useful dir() results */
-PyObject* KX_Scene::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+
+int KX_Scene::pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
KX_Scene* self= static_cast<KX_Scene*>(self_v);
- /* Useually done by py_getattro_up but in this case we want to include m_attr_dict dict */
- PyObject *dict_str= PyString_FromString("__dict__");
- PyObject *dict= py_getattr_dict(self->PyObjectPlus::py_getattro(dict_str), Type.tp_dict);
- Py_DECREF(dict_str);
+ KX_Camera *camOb;
- PyDict_Update(dict, self->m_attr_dict);
- return dict;
+ if (!ConvertPythonToCamera(value, &camOb, false, "scene.active_camera = value: KX_Scene"))
+ return PY_SET_ATTR_FAIL;
+
+ self->SetActiveCamera(camOb);
+ return PY_SET_ATTR_SUCCESS;
}
+
PyAttributeDef KX_Scene::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("name", KX_Scene, pyattr_get_name),
- KX_PYATTRIBUTE_RO_FUNCTION("objects", KX_Scene, pyattr_get_objects),
- KX_PYATTRIBUTE_RO_FUNCTION("active_camera", KX_Scene, pyattr_get_active_camera),
- KX_PYATTRIBUTE_BOOL_RO("suspended", KX_Scene, m_suspend),
- KX_PYATTRIBUTE_BOOL_RO("activity_culling", KX_Scene, m_activity_culling),
+ KX_PYATTRIBUTE_RO_FUNCTION("name", KX_Scene, pyattr_get_name),
+ KX_PYATTRIBUTE_RO_FUNCTION("objects", KX_Scene, pyattr_get_objects),
+ KX_PYATTRIBUTE_RO_FUNCTION("objectsInactive", KX_Scene, pyattr_get_objects_inactive), KX_PYATTRIBUTE_RO_FUNCTION("lights", KX_Scene, pyattr_get_lights),
+ KX_PYATTRIBUTE_RO_FUNCTION("cameras", KX_Scene, pyattr_get_cameras),
+ KX_PYATTRIBUTE_RO_FUNCTION("lights", KX_Scene, pyattr_get_lights),
+ KX_PYATTRIBUTE_RW_FUNCTION("active_camera", KX_Scene, pyattr_get_active_camera, pyattr_set_active_camera),
+ KX_PYATTRIBUTE_BOOL_RO("suspended", KX_Scene, m_suspend),
+ KX_PYATTRIBUTE_BOOL_RO("activity_culling", KX_Scene, m_activity_culling),
KX_PYATTRIBUTE_FLOAT_RW("activity_culling_radius", 0.5f, FLT_MAX, KX_Scene, m_activity_box_radius),
- KX_PYATTRIBUTE_BOOL_RO("dbvt_culling", KX_Scene, m_dbvt_culling),
- KX_PYATTRIBUTE_RO_FUNCTION("__dict__", KX_Scene, pyattr_get_dir_dict),
+ KX_PYATTRIBUTE_BOOL_RO("dbvt_culling", KX_Scene, m_dbvt_culling),
{ NULL } //Sentinel
};
-
PyObject* KX_Scene::py_getattro__internal(PyObject *attr)
{
py_getattro_up(PyObjectPlus);
}
-int KX_Scene::py_setattro__internal(PyObject *attr, PyObject *pyvalue)
+int KX_Scene::py_setattro__internal(PyObject *attr, PyObject *value)
{
- return PyObjectPlus::py_setattro(attr, pyvalue);
+ py_setattro_up(PyObjectPlus);
}
PyObject* KX_Scene::py_getattro(PyObject *attr)
@@ -1685,6 +1759,18 @@ PyObject* KX_Scene::py_getattro(PyObject *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)
{
@@ -1715,6 +1801,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getLightList,
"Returns a list of all lights in the scene.\n"
)
{
+ ShowDeprecationWarning("getLightList()", "the lights property");
return m_lightlist->GetProxy();
}
@@ -1723,7 +1810,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getObjectList,
"Returns a list of all game objects in the scene.\n"
)
{
- // ShowDeprecationWarning("getObjectList()", "the objects property"); // XXX Grr, why doesnt this work?
+ ShowDeprecationWarning("getObjectList()", "the objects property");
return m_objectlist->GetProxy();
}
@@ -1732,6 +1819,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getName,
"Returns the name of the scene.\n"
)
{
+ ShowDeprecationWarning("getName()", "the name property");
return PyString_FromString(GetName());
}
@@ -1753,5 +1841,9 @@ KX_PYMETHODDEF_DOC(KX_Scene, addObject,
SCA_IObject* replica = AddReplicaObject((SCA_IObject*)ob, other, time);
+
+ // release here because AddReplicaObject AddRef's
+ // 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 a06c66ec5dd..79d3f7fd828 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -32,8 +32,6 @@
#include "KX_PhysicsEngineEnums.h"
-#include "MT_CmMatrix4x4.h"
-
#include <vector>
#include <set>
#include <list>
@@ -43,7 +41,7 @@
#include "SG_IObject.h"
#include "SCA_IScene.h"
#include "MT_Transform.h"
-#include "SND_Scene.h"
+
#include "RAS_FramingManager.h"
#include "RAS_Rect.h"
@@ -110,16 +108,16 @@ protected:
* LogicEndFrame() via a call to RemoveObject().
*/
CListValue* m_euthanasyobjects;
- /**
- * The list of objects that couldn't be released during logic update.
- * for example, AddObject actuator sometimes releases an object that was cached from previous frame
- */
- CListValue* m_delayReleaseObjects;
CListValue* m_objectlist;
CListValue* m_parentlist; // all 'root' parents
CListValue* m_lightlist;
CListValue* m_inactivelist; // all objects that are not in the active layer
+
+ SG_QList m_sghead; // list of nodes that needs scenegraph update
+ // the Dlist is not object that must be updated
+ // the Qlist is for objects that needs to be rescheduled
+ // for updates after udpate is over (slow parent, bone parent)
/**
* The tree of objects in the scene.
@@ -191,20 +189,6 @@ protected:
*/
KX_Camera* m_active_camera;
- /**
- * The projection and view matrices of this scene
- * The projection matrix is computed externally by KX_Engine
- * The view mat is stored as a side effect of GetViewMatrix()
- * and is totally unnessary.
- */
- MT_CmMatrix4x4 m_projectionmat;
- MT_CmMatrix4x4 m_viewmat;
-
- /** Desired canvas width set at design time. */
- unsigned int m_canvasDesignWidth;
- /** Desired canvas height set at design time. */
- unsigned int m_canvasDesignHeight;
-
/**
* Another temporary variable outstaying its welcome
* used in AddReplicaObject to map game objects to their
@@ -318,6 +302,8 @@ public:
/**
* Update all transforms according to the scenegraph.
*/
+ static bool KX_ScenegraphUpdateFunc(SG_IObject* node,void* gameobj,void* scene);
+ static bool KX_ScenegraphRescheduleFunc(SG_IObject* node,void* gameobj,void* scene);
void UpdateParents(double curtime);
void DupliGroupRecurse(CValue* gameobj, int level);
bool IsObjectInGroup(CValue* gameobj)
@@ -335,8 +321,6 @@ public:
void RemoveObject(CValue* gameobj);
void DelayedRemoveObject(CValue* gameobj);
- void DelayedReleaseObject(CValue* gameobj);
-
int NewRemoveObject(CValue* gameobj);
void ReplaceMesh(CValue* gameobj,
void* meshobj);
@@ -422,25 +406,6 @@ public:
class KX_Camera*
);
- /** Return the viewmatrix as used by the last frame. */
- MT_CmMatrix4x4&
- GetViewMatrix(
- );
-
- /**
- * Return the projectionmatrix as used by the last frame. This is
- * set by hand :)
- */
- MT_CmMatrix4x4&
- GetProjectionMatrix(
- );
-
- /** Sets the projection matrix. */
- void
- SetProjectionMatrix(
- MT_CmMatrix4x4& pmat
- );
-
/**
* Activates new desired canvas width set at design time.
* @param width The new desired width.
@@ -592,14 +557,16 @@ public:
/* attributes */
static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_objects(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_objects_inactive(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_lights(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_cameras(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_active_camera(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- /* for dir(), python3 uses __dir__() */
- static PyObject* pyattr_get_dir_dict(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 int py_setattro(PyObject *attr, PyObject *pyvalue);
+ 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()); }
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp
index f54d8542260..1b790ec9824 100644
--- a/source/gameengine/Ketsji/KX_SceneActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp
@@ -76,9 +76,6 @@ CValue* KX_SceneActuator::GetReplica()
{
KX_SceneActuator* replica = new KX_SceneActuator(*this);
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
-
return replica;
}
@@ -226,8 +223,13 @@ KX_Scene* KX_SceneActuator::FindScene(char * sceneName)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_SceneActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_SceneActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -262,7 +264,7 @@ PyMethodDef KX_SceneActuator::Methods[] =
//Deprecated functions ------>
{"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (PY_METHODCHAR)SetUseRestart_doc},
{"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (PY_METHODCHAR)SetScene_doc},
- {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_VARARGS, (PY_METHODCHAR)SetCamera_doc},
+ {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_O, (PY_METHODCHAR)SetCamera_doc},
{"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_NOARGS, (PY_METHODCHAR)GetUseRestart_doc},
{"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_NOARGS, (PY_METHODCHAR)GetScene_doc},
{"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_NOARGS, (PY_METHODCHAR)GetCamera_doc},
@@ -273,6 +275,8 @@ PyMethodDef KX_SceneActuator::Methods[] =
PyAttributeDef KX_SceneActuator::Attributes[] = {
KX_PYATTRIBUTE_STRING_RW("scene",0,32,true,KX_SceneActuator,m_nextSceneName),
KX_PYATTRIBUTE_RW_FUNCTION("camera",KX_SceneActuator,pyattr_get_camera,pyattr_set_camera),
+ KX_PYATTRIBUTE_BOOL_RW("useRestart", KX_SceneActuator, m_restart),
+ KX_PYATTRIBUTE_INT_RW("mode", KX_SCENE_NODEF+1, KX_SCENE_MAX-1, true, KX_SceneActuator, m_mode),
{ NULL } //Sentinel
};
@@ -281,6 +285,10 @@ 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);
@@ -300,51 +308,21 @@ int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_
KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self);
KX_Camera *camOb;
- if(value==Py_None)
- {
- if (actuator->m_camera)
- actuator->m_camera->UnregisterActuator(actuator);
-
+ if (!ConvertPythonToCamera(value, &camOb, true, "actu.camera = value: KX_SceneActuator"))
+ return PY_SET_ATTR_FAIL;
+
+ if (actuator->m_camera)
+ actuator->m_camera->UnregisterActuator(actuator);
+
+ if(camOb==NULL) {
actuator->m_camera= NULL;
- return 0;
}
-
- if (PyObject_TypeCheck(value, &KX_Camera::Type))
- {
- KX_Camera *camOb= static_cast<KX_Camera*>BGE_PROXY_REF(value);
-
- if(camOb==NULL)
- {
- PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
- return 1;
- }
-
- if (actuator->m_camera)
- actuator->m_camera->UnregisterActuator(actuator);
-
+ else {
actuator->m_camera = camOb;
actuator->m_camera->RegisterActuator(actuator);
- return 0;
- }
-
- if (PyString_Check(value))
- {
- char *camName = PyString_AsString(value);
-
- camOb = actuator->FindCamera(camName);
- if (camOb)
- {
- if (actuator->m_camera)
- actuator->m_camera->UnregisterActuator(actuator);
- actuator->m_camera = camOb;
- actuator->m_camera->RegisterActuator(actuator);
- return 0;
- }
- PyErr_SetString(PyExc_TypeError, "not a valid camera name");
- return 1;
}
- PyErr_SetString(PyExc_TypeError, "expected a string or a camera object reference");
- return 1;
+
+ return PY_SET_ATTR_SUCCESS;
}
@@ -355,7 +333,7 @@ const char KX_SceneActuator::SetUseRestart_doc[] =
"\tSet flag to 1 to restart the scene.\n" ;
PyObject* KX_SceneActuator::PySetUseRestart(PyObject* args)
{
- ShowDeprecationWarning("setUseRestart()", "(no replacement)");
+ ShowDeprecationWarning("setUseRestart()", "the useRestart property");
int boolArg;
if (!PyArg_ParseTuple(args, "i:setUseRestart", &boolArg))
@@ -376,7 +354,7 @@ const char KX_SceneActuator::GetUseRestart_doc[] =
"\tReturn whether the scene will be restarted.\n" ;
PyObject* KX_SceneActuator::PyGetUseRestart()
{
- ShowDeprecationWarning("getUseRestart()", "(no replacement)");
+ ShowDeprecationWarning("getUseRestart()", "the useRestart property");
return PyInt_FromLong(!(m_restart == 0));
}
@@ -423,47 +401,24 @@ const char KX_SceneActuator::SetCamera_doc[] =
"setCamera(camera)\n"
"\t- camera: string\n"
"\tSet the camera to switch to.\n" ;
-PyObject* KX_SceneActuator::PySetCamera(PyObject* args)
+PyObject* KX_SceneActuator::PySetCamera(PyObject* value)
{
ShowDeprecationWarning("setCamera()", "the camera property");
- PyObject *cam;
- if (PyArg_ParseTuple(args, "O!:setCamera", &KX_Camera::Type, &cam))
- {
- KX_Camera *new_camera;
-
- new_camera = static_cast<KX_Camera*>BGE_PROXY_REF(cam);
- if(new_camera==NULL)
- {
- PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- if (m_camera)
- m_camera->UnregisterActuator(this);
-
- m_camera= new_camera;
-
- m_camera->RegisterActuator(this);
- Py_RETURN_NONE;
- }
- PyErr_Clear();
-
- /* one argument: a scene, ignore the rest */
- char *camName;
- if(!PyArg_ParseTuple(args, "s:setCamera", &camName))
- {
+ KX_Camera *camOb;
+
+ if (!ConvertPythonToCamera(value, &camOb, true, "actu.setCamera(value): KX_SceneActuator"))
return NULL;
+
+ if (m_camera)
+ m_camera->UnregisterActuator(this);
+
+ if(camOb==NULL) {
+ m_camera= NULL;
}
-
- KX_Camera *camOb = FindCamera(camName);
- if (camOb)
- {
- if (m_camera)
- m_camera->UnregisterActuator(this);
+ else {
m_camera = camOb;
m_camera->RegisterActuator(this);
}
-
Py_RETURN_NONE;
}
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h
index 803c5106a60..2412dd02590 100644
--- a/source/gameengine/Ketsji/KX_SceneActuator.h
+++ b/source/gameengine/Ketsji/KX_SceneActuator.h
@@ -93,6 +93,7 @@ class KX_SceneActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
/* 1. set */
@@ -107,7 +108,7 @@ class KX_SceneActuator : public SCA_IActuator
/* 5. getScene: */
KX_PYMETHOD_DOC_NOARGS(KX_SceneActuator,GetScene);
/* 6. setCamera: */
- KX_PYMETHOD_DOC_VARARGS(KX_SceneActuator,SetCamera);
+ KX_PYMETHOD_DOC_O(KX_SceneActuator,SetCamera);
/* 7. getCamera: */
KX_PYMETHOD_DOC_NOARGS(KX_SceneActuator,GetCamera);
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index 412be497c5a..5c02a2db646 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -83,19 +83,19 @@ CValue* KX_SoundActuator::GetReplica()
{
KX_SoundActuator* replica = new KX_SoundActuator(*this);
replica->ProcessReplica();
+ return replica;
+};
+
+void KX_SoundActuator::ProcessReplica()
+{
+ SCA_IActuator::ProcessReplica();
if (m_soundObject)
{
SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject);
- replica->setSoundObject(soundobj);
+ setSoundObject(soundobj);
m_soundScene->AddObject(soundobj);
}
-
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
- return replica;
-};
-
-
+}
bool KX_SoundActuator::Update(double curtime, bool frame)
{
@@ -234,8 +234,13 @@ void KX_SoundActuator::setSoundObject(class SND_SoundObject* soundobject)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_SoundActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_SoundActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -290,7 +295,7 @@ PyMethodDef KX_SoundActuator::Methods[] = {
};
PyAttributeDef KX_SoundActuator::Attributes[] = {
- KX_PYATTRIBUTE_RW_FUNCTION("filename", KX_SoundActuator, pyattr_get_filename, pyattr_set_filename),
+ KX_PYATTRIBUTE_RW_FUNCTION("fileName", KX_SoundActuator, pyattr_get_filename, pyattr_set_filename),
KX_PYATTRIBUTE_RW_FUNCTION("volume", KX_SoundActuator, pyattr_get_gain, pyattr_set_gain),
KX_PYATTRIBUTE_RW_FUNCTION("pitch", KX_SoundActuator, pyattr_get_pitch, pyattr_set_pitch),
KX_PYATTRIBUTE_RW_FUNCTION("rollOffFactor", KX_SoundActuator, pyattr_get_rollOffFactor, pyattr_set_rollOffFactor),
@@ -298,7 +303,7 @@ PyAttributeDef KX_SoundActuator::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("position", KX_SoundActuator, pyattr_get_position, pyattr_set_position),
KX_PYATTRIBUTE_RW_FUNCTION("velocity", KX_SoundActuator, pyattr_get_velocity, pyattr_set_velocity),
KX_PYATTRIBUTE_RW_FUNCTION("orientation", KX_SoundActuator, pyattr_get_orientation, pyattr_set_orientation),
- KX_PYATTRIBUTE_ENUM_RW("type",KX_SoundActuator::KX_SOUNDACT_NODEF+1,KX_SoundActuator::KX_SOUNDACT_MAX-1,false,KX_SoundActuator,m_type),
+ KX_PYATTRIBUTE_ENUM_RW("mode",KX_SoundActuator::KX_SOUNDACT_NODEF+1,KX_SoundActuator::KX_SOUNDACT_MAX-1,false,KX_SoundActuator,m_type),
{ NULL } //Sentinel
};
@@ -340,6 +345,10 @@ 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);
}
@@ -355,7 +364,7 @@ PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYAT
char* name = objectname.Ptr();
if (!name) {
- PyErr_SetString(PyExc_RuntimeError, "value = actuator.filename: KX_SoundActuator, unable to get sound filename");
+ PyErr_SetString(PyExc_RuntimeError, "value = actuator.fileName: KX_SoundActuator, unable to get sound fileName");
return NULL;
} else
return PyString_FromString(name);
@@ -441,13 +450,13 @@ int KX_SoundActuator::pyattr_set_filename(void *self, const struct KX_PYATTRIBUT
// void *soundPointer = NULL; /*unused*/
if (!PyArg_Parse(value, "s", &soundName))
- return 1;
+ return PY_SET_ATTR_FAIL;
if (actuator->m_soundObject) {
actuator->m_soundObject->SetObjectName(soundName);
}
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
@@ -456,12 +465,12 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE
float gain = 1.0;
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
if (!PyArg_Parse(value, "f", &gain))
- return 1;
+ return PY_SET_ATTR_FAIL;
if (actuator->m_soundObject)
actuator->m_soundObject->SetGain(gain);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -469,12 +478,12 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D
float pitch = 1.0;
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
if (!PyArg_Parse(value, "f", &pitch))
- return 1;
+ return PY_SET_ATTR_FAIL;
if (actuator->m_soundObject)
actuator->m_soundObject->SetPitch(pitch);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -482,12 +491,12 @@ int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATT
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
float rollofffactor = 1.0;
if (!PyArg_Parse(value, "f", &rollofffactor))
- return 1;
+ return PY_SET_ATTR_FAIL;
if (actuator->m_soundObject)
actuator->m_soundObject->SetRollOffFactor(rollofffactor);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -495,12 +504,12 @@ int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
int looping = 1;
if (!PyArg_Parse(value, "i", &looping))
- return 1;
+ return PY_SET_ATTR_FAIL;
if (actuator->m_soundObject)
actuator->m_soundObject->SetLoopMode(looping);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -510,12 +519,12 @@ int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUT
KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
if (!PyArg_ParseTuple(value, "fff", &pos[0], &pos[1], &pos[2]))
- return 1;
+ return PY_SET_ATTR_FAIL;
if (actuator->m_soundObject)
actuator->m_soundObject->SetPosition(MT_Vector3(pos));
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -525,12 +534,12 @@ int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUT
if (!PyArg_ParseTuple(value, "fff", &vel[0], &vel[1], &vel[2]))
- return 1;
+ return PY_SET_ATTR_FAIL;
if (actuator->m_soundObject)
actuator->m_soundObject->SetVelocity(MT_Vector3(vel));
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
@@ -542,21 +551,22 @@ int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRI
/* if value is not a sequence PyOrientationTo makes an error */
if (!PyOrientationTo(value, rot, "actuator.orientation = value: KX_SoundActuator"))
- return NULL;
+ return PY_SET_ATTR_FAIL;
+ /* Since not having m_soundObject didn't do anything in the old version,
+ * it probably should be kept that way */
if (!actuator->m_soundObject)
- return 0; /* Since not having m_soundObject didn't do anything in the old version,
- * it probably should be kept that way */
+ return PY_SET_ATTR_SUCCESS;
actuator->m_soundObject->SetOrientation(rot);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
// Deprecated ----->
PyObject* KX_SoundActuator::PySetFilename(PyObject* args)
{
char *soundName = NULL;
- ShowDeprecationWarning("setFilename()", "the filename property");
+ ShowDeprecationWarning("setFilename()", "the fileName property");
// void *soundPointer = NULL; /*unused*/
if (!PyArg_ParseTuple(args, "s", &soundName))
@@ -567,7 +577,7 @@ PyObject* KX_SoundActuator::PySetFilename(PyObject* args)
PyObject* KX_SoundActuator::PyGetFilename()
{
- ShowDeprecationWarning("getFilename()", "the filename property");
+ ShowDeprecationWarning("getFilename()", "the fileName property");
if (!m_soundObject)
{
return PyString_FromString("");
@@ -576,7 +586,7 @@ PyObject* KX_SoundActuator::PyGetFilename()
char* name = objectname.Ptr();
if (!name) {
- PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename");
+ PyErr_SetString(PyExc_RuntimeError, "Unable to get sound fileName");
return NULL;
} else
return PyString_FromString(name);
@@ -750,7 +760,7 @@ PyObject* KX_SoundActuator::PySetOrientation(PyObject* args)
PyObject* KX_SoundActuator::PySetType(PyObject* args)
{
int typeArg;
- ShowDeprecationWarning("setType()", "the type property");
+ ShowDeprecationWarning("setType()", "the mode property");
if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) {
return NULL;
@@ -766,7 +776,7 @@ PyObject* KX_SoundActuator::PySetType(PyObject* args)
PyObject* KX_SoundActuator::PyGetType()
{
- ShowDeprecationWarning("getType()", "the type property");
+ ShowDeprecationWarning("getType()", "the mode property");
return PyInt_FromLong(m_type);
}
// <-----
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h
index d5e678bbecd..a7491355667 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.h
+++ b/source/gameengine/Ketsji/KX_SoundActuator.h
@@ -75,12 +75,14 @@ public:
virtual bool Update(double curtime, bool frame);
CValue* GetReplica();
+ void ProcessReplica();
/* -------------------------------------------------------------------- */
/* 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);
diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp
index 976e7ea5204..f6979eee0f4 100644
--- a/source/gameengine/Ketsji/KX_StateActuator.cpp
+++ b/source/gameengine/Ketsji/KX_StateActuator.cpp
@@ -55,6 +55,9 @@ KX_StateActuator::~KX_StateActuator(
// intentionally empty
}
+// used to put state actuator to be executed before any other actuators
+SG_QList KX_StateActuator::m_stateActuatorHead;
+
CValue*
KX_StateActuator::GetReplica(
void
@@ -62,8 +65,6 @@ KX_StateActuator::GetReplica(
{
KX_StateActuator* replica = new KX_StateActuator(*this);
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
}
@@ -72,7 +73,10 @@ KX_StateActuator::Update()
{
bool bNegativeEvent = IsNegativeEvent();
unsigned int objMask;
-
+
+ // execution of state actuator means that we are in the execution phase, reset this pointer
+ // because all the active actuator of this object will be removed for sure.
+ m_gameobj->m_firstState = NULL;
RemoveAllEvents();
if (bNegativeEvent) return false;
@@ -101,6 +105,31 @@ KX_StateActuator::Update()
return false;
}
+// this function is only used to deactivate actuators outside the logic loop
+// e.g. when an object is deleted.
+void KX_StateActuator::Deactivate()
+{
+ if (QDelink())
+ {
+ // the actuator was in the active list
+ if (m_stateActuatorHead.QEmpty())
+ // no more state object active
+ m_stateActuatorHead.Delink();
+ }
+}
+
+void KX_StateActuator::Activate(SG_DList& head)
+{
+ // sort the state actuators per object on the global list
+ if (QEmpty())
+ {
+ InsertSelfActiveQList(m_stateActuatorHead, &m_gameobj->m_firstState);
+ // add front to make sure it runs before other actuators
+ head.AddFront(&m_stateActuatorHead);
+ }
+}
+
+
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
@@ -109,8 +138,13 @@ KX_StateActuator::Update()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_StateActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_StateActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -156,7 +190,11 @@ PyAttributeDef KX_StateActuator::Attributes[] = {
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)
{
diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h
index 4a64894259d..a4191a4c5fd 100644
--- a/source/gameengine/Ketsji/KX_StateActuator.h
+++ b/source/gameengine/Ketsji/KX_StateActuator.h
@@ -33,6 +33,13 @@
#include "SCA_IActuator.h"
+
+/*
+ * Use of SG_DList : element of actuator being deactivated
+ * Head: SCA_LogicManager::m_removedActuators
+ * Use of SG_QList : element of global activated state actuator list
+ * Head: KX_StateActuator::m_stateActuatorHead
+ */
class KX_StateActuator : public SCA_IActuator
{
Py_Header;
@@ -46,6 +53,11 @@ class KX_StateActuator : public SCA_IActuator
OP_NEG,
OP_COUNT
};
+ // SG_Dlist: element of objects with active actuators, always put in front of the list
+ // Head: SCA_LogicManager::m_activeActuators
+ // SG_QList: Head of active state actuators list globally
+ // Elements: KX_StateActuator
+ static SG_QList m_stateActuatorHead;
int m_operation;
int m_mask;
@@ -71,11 +83,15 @@ class KX_StateActuator : public SCA_IActuator
virtual bool
Update();
+ virtual void Deactivate();
+ virtual void Activate(SG_DList& head);
+
/* --------------------------------------------------------------------- */
/* 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);
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
index 083d89896f6..278994c6ae7 100644
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
@@ -53,7 +53,7 @@ public:
class SM_Object* sumoObj,
class PHY_IMotionState* motionstate
,bool dyna)
- : KX_IPhysicsController(dyna,false,NULL) ,
+ : KX_IPhysicsController(dyna,false,false,NULL) ,
SumoPhysicsController(sumoScene,/*solidscene,*/sumoObj,motionstate,dyna)
{
};
@@ -83,6 +83,7 @@ public:
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);
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
index 48d4cf59a2b..712a512995e 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
@@ -85,14 +85,35 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data,
PHY_IPhysicsController* ctrl = static_cast<PHY_IPhysicsController*>(object1);
KX_ClientObjectInfo* info = (ctrl) ? static_cast<KX_ClientObjectInfo*>(ctrl->getNewClientInfo()) : NULL;
// This call back should only be called for controllers of Near and Radar sensor
- if (info &&
- info->m_sensors.size() == 1 &&
- (info->m_type == KX_ClientObjectInfo::NEAR ||
- info->m_type == KX_ClientObjectInfo::RADAR))
+ if (!info)
+ return true;
+
+ switch (info->m_type)
{
- // only one sensor for this type of object
- KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*info->m_sensors.begin());
- return touchsensor->BroadPhaseFilterCollision(object1,object2);
+ case KX_ClientObjectInfo::SENSOR:
+ if (info->m_sensors.size() == 1)
+ {
+ // only one sensor for this type of object
+ KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*info->m_sensors.begin());
+ return touchsensor->BroadPhaseFilterCollision(object1,object2);
+ }
+ break;
+ case KX_ClientObjectInfo::OBSENSOR:
+ case KX_ClientObjectInfo::OBACTORSENSOR:
+ // this object may have multiple collision sensors,
+ // check is any of them is interested in this object
+ for(std::list<SCA_ISensor*>::iterator it = info->m_sensors.begin();
+ it != info->m_sensors.end();
+ ++it)
+ {
+ if ((*it)->GetSensorType() == SCA_ISensor::ST_TOUCH)
+ {
+ KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*it);
+ if (touchsensor->BroadPhaseSensorFilterCollision(object1, object2))
+ return true;
+ }
+ }
+ return false;
}
return true;
}
@@ -100,7 +121,7 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data,
void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor)
{
KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
- if (m_sensors.insert(touchsensor).second)
+ if (m_sensors.AddBack(touchsensor))
// the sensor was effectively inserted, register it
touchsensor->RegisterSumo(this);
}
@@ -108,7 +129,7 @@ void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor)
void KX_TouchEventManager::RemoveSensor(SCA_ISensor* sensor)
{
KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
- if (m_sensors.erase(touchsensor))
+ if (touchsensor->Delink())
// the sensor was effectively removed, unregister it
touchsensor->UnregisterSumo(this);
}
@@ -117,12 +138,10 @@ void KX_TouchEventManager::RemoveSensor(SCA_ISensor* sensor)
void KX_TouchEventManager::EndFrame()
{
- set<SCA_ISensor*>::iterator it;
- for ( it = m_sensors.begin();
- !(it==m_sensors.end());it++)
+ SG_DList::iterator<KX_TouchSensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- ((KX_TouchSensor*)*it)->EndFrame();
-
+ (*it)->EndFrame();
}
}
@@ -130,12 +149,11 @@ void KX_TouchEventManager::EndFrame()
void KX_TouchEventManager::NextFrame()
{
- if (m_sensors.size() > 0)
+ if (!m_sensors.Empty())
{
- set<SCA_ISensor*>::iterator it;
-
- for (it = m_sensors.begin();!(it==m_sensors.end());++it)
- static_cast<KX_TouchSensor*>(*it)->SynchronizeTransform();
+ SG_DList::iterator<KX_TouchSensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
+ (*it)->SynchronizeTransform();
for (std::set<NewCollision>::iterator cit = m_newCollisions.begin(); cit != m_newCollisions.end(); ++cit)
{
@@ -161,7 +179,7 @@ void KX_TouchEventManager::NextFrame()
m_newCollisions.clear();
- for (it = m_sensors.begin();!(it==m_sensors.end());++it)
- (*it)->Activate(m_logicmgr,NULL);
+ for (it.begin();!it.end();++it)
+ (*it)->Activate(m_logicmgr);
}
}
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index 5a6e8e6f501..c06acd4a873 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -66,10 +66,10 @@ void KX_TouchSensor::UnregisterToManager()
{
// before unregistering the sensor, make sure we release all references
EndFrame();
- m_eventmgr->RemoveSensor(this);
+ SCA_ISensor::UnregisterToManager();
}
-bool KX_TouchSensor::Evaluate(CValue* event)
+bool KX_TouchSensor::Evaluate()
{
bool result = false;
bool reset = m_reset && m_level;
@@ -142,13 +142,17 @@ KX_TouchSensor::~KX_TouchSensor()
CValue* KX_TouchSensor::GetReplica()
{
KX_TouchSensor* replica = new KX_TouchSensor(*this);
- replica->m_colliders = new CListValue();
- replica->Init();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
+ replica->ProcessReplica();
return replica;
}
+void KX_TouchSensor::ProcessReplica()
+{
+ SCA_ISensor::ProcessReplica();
+ m_colliders = new CListValue();
+ Init();
+}
+
void KX_TouchSensor::ReParent(SCA_IObject* parent)
{
KX_GameObject *gameobj = static_cast<KX_GameObject *>(parent);
@@ -169,21 +173,69 @@ void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman)
{
if (m_physCtrl)
{
- touchman->GetPhysicsEnvironment()->requestCollisionCallback(m_physCtrl);
- // collision
- // Deprecated
-
+ if (touchman->GetPhysicsEnvironment()->requestCollisionCallback(m_physCtrl))
+ {
+ KX_ClientObjectInfo* client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+ if (client_info->isSensor())
+ touchman->GetPhysicsEnvironment()->addSensor(m_physCtrl);
+ }
}
}
-
void KX_TouchSensor::UnregisterSumo(KX_TouchEventManager* touchman)
{
if (m_physCtrl)
{
- touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl);
+ if (touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl))
+ {
+ // no more sensor on the controller, can remove it if it is a sensor object
+ KX_ClientObjectInfo* client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+ if (client_info->isSensor())
+ touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl);
+ }
}
}
+// this function is called only for sensor objects
+// return true if the controller can collide with the object
+bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2)
+{
+ assert(obj1==m_physCtrl && obj2);
+
+ KX_GameObject* myobj = (KX_GameObject*)GetParent();
+ KX_GameObject* myparent = myobj->GetParent();
+ KX_ClientObjectInfo* client_info = static_cast<KX_ClientObjectInfo*>(((PHY_IPhysicsController*)obj2)->getNewClientInfo());
+ KX_ClientObjectInfo* my_client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->getNewClientInfo());
+ KX_GameObject* otherobj = ( client_info ? client_info->m_gameobject : NULL);
+
+ // first, decrement refcount as GetParent() increases it
+ if (myparent)
+ myparent->Release();
+
+ // we can only check on persistent characteristic: m_link and m_suspended are not
+ // good candidate because they are transient. That must be handled at another level
+ if (!otherobj ||
+ otherobj == myparent || // don't interact with our parent
+ (my_client_info->m_type == KX_ClientObjectInfo::OBACTORSENSOR &&
+ client_info->m_type != KX_ClientObjectInfo::ACTOR)) // only with actor objects
+ return false;
+
+ bool found = m_touchedpropname.IsEmpty();
+ if (!found)
+ {
+ if (m_bFindMaterial)
+ {
+ if (client_info->m_auxilary_info)
+ {
+ found = (!strcmp(m_touchedpropname.Ptr(), (char*)client_info->m_auxilary_info));
+ }
+ } else
+ {
+ found = (otherobj->GetProperty(m_touchedpropname) != NULL);
+ }
+ }
+ return found;
+}
+
bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_CollData* colldata)
{
// KX_TouchEventManager* toucheventmgr = (KX_TouchEventManager*)m_eventmgr;
@@ -242,8 +294,13 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll
/* ------------------------------------------------------------------------- */
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_TouchSensor::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_TouchSensor",
sizeof(PyObjectPlus_Proxy),
0,
@@ -283,11 +340,11 @@ PyMethodDef KX_TouchSensor::Methods[] = {
};
PyAttributeDef KX_TouchSensor::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW("property",0,100,false,KX_TouchSensor,m_touchedpropname),
+ KX_PYATTRIBUTE_STRING_RW("propName",0,100,false,KX_TouchSensor,m_touchedpropname),
KX_PYATTRIBUTE_BOOL_RW("useMaterial",KX_TouchSensor,m_bFindMaterial),
- KX_PYATTRIBUTE_BOOL_RW("pulseCollisions",KX_TouchSensor,m_bTouchPulse),
- KX_PYATTRIBUTE_RO_FUNCTION("objectHit", KX_TouchSensor, pyattr_get_object_hit),
- KX_PYATTRIBUTE_RO_FUNCTION("objectHitList", KX_TouchSensor, pyattr_get_object_hit_list),
+ KX_PYATTRIBUTE_BOOL_RW("usePulseCollision",KX_TouchSensor,m_bTouchPulse),
+ KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_TouchSensor, pyattr_get_object_hit),
+ KX_PYATTRIBUTE_RO_FUNCTION("hitObjectList", KX_TouchSensor, pyattr_get_object_hit_list),
{ NULL } //Sentinel
};
@@ -296,6 +353,10 @@ 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);
@@ -312,7 +373,7 @@ const char KX_TouchSensor::SetProperty_doc[] =
"\tmaterials.";
PyObject* KX_TouchSensor::PySetProperty(PyObject* value)
{
- ShowDeprecationWarning("setProperty()", "the propertyName property");
+ ShowDeprecationWarning("setProperty()", "the propName property");
char *nameArg= PyString_AsString(value);
if (nameArg==NULL) {
PyErr_SetString(PyExc_ValueError, "expected a ");
@@ -329,6 +390,8 @@ const char KX_TouchSensor::GetProperty_doc[] =
"\tgetTouchMaterial() to find out whether this sensor\n"
"\tlooks for properties or materials.";
PyObject* KX_TouchSensor::PyGetProperty() {
+ ShowDeprecationWarning("getProperty()", "the propName property");
+
return PyString_FromString(m_touchedpropname);
}
@@ -337,7 +400,7 @@ const char KX_TouchSensor::GetHitObject_doc[] =
;
PyObject* KX_TouchSensor::PyGetHitObject()
{
- ShowDeprecationWarning("getHitObject()", "the objectHit property");
+ ShowDeprecationWarning("getHitObject()", "the hitObject property");
/* to do: do Py_IncRef if the object is already known in Python */
/* otherwise, this leaks memory */
if (m_hitObject)
@@ -353,7 +416,7 @@ const char KX_TouchSensor::GetHitObjectList_doc[] =
"\tbut only those matching the property/material condition.\n";
PyObject* KX_TouchSensor::PyGetHitObjectList()
{
- ShowDeprecationWarning("getHitObjectList()", "the objectHitList property");
+ ShowDeprecationWarning("getHitObjectList()", "the hitObjectList property");
/* to do: do Py_IncRef if the object is already known in Python */
/* otherwise, this leaks memory */ /* Edit, this seems ok and not to leak memory - Campbell */
return m_colliders->GetProxy();
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h
index 15ef653c1b2..476c63e89db 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.h
+++ b/source/gameengine/Ketsji/KX_TouchSensor.h
@@ -84,8 +84,9 @@ public:
virtual ~KX_TouchSensor();
virtual CValue* GetReplica();
+ virtual void ProcessReplica();
virtual void SynchronizeTransform();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual void Init();
virtual void ReParent(SCA_IObject* parent);
@@ -102,7 +103,8 @@ public:
// obj1 = sensor physical controller, obj2 = physical controller of second object
// return value = true if collision should be checked on pair of object
virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2) { return true; }
-
+ virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2);
+ virtual sensortype GetSensorType() { return ST_TOUCH; }
virtual bool IsPositiveTrigger() {
@@ -121,6 +123,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
//Deprecated ----->
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index fbf43de6cf4..5a50d0fb944 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -83,6 +83,10 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
// if so, store the initial local rotation
// this is needed to revert the effect of the parent inverse node (TBC)
m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
+ // use registration mechanism rather than AddRef, it creates zombie objects
+ m_parentobj->RegisterActuator(this);
+ // GetParent did AddRef, undo here
+ m_parentobj->Release();
}
}
}
@@ -189,7 +193,7 @@ KX_TrackToActuator::~KX_TrackToActuator()
if (m_object)
m_object->UnregisterActuator(this);
if (m_parentobj)
- m_parentobj->Release();
+ m_parentobj->UnregisterActuator(this);
} /* end of destructor */
void KX_TrackToActuator::ProcessReplica()
@@ -198,7 +202,7 @@ void KX_TrackToActuator::ProcessReplica()
if (m_object)
m_object->RegisterActuator(this);
if (m_parentobj)
- m_parentobj->AddRef();
+ m_parentobj->RegisterActuator(this);
SCA_IActuator::ProcessReplica();
}
@@ -211,6 +215,11 @@ bool KX_TrackToActuator::UnlinkObject(SCA_IObject* clientobj)
m_object = NULL;
return true;
}
+ if (clientobj == m_parentobj)
+ {
+ m_parentobj = NULL;
+ return true;
+ }
return false;
}
@@ -227,9 +236,9 @@ void KX_TrackToActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
void **h_parobj = (*obj_map)[m_parentobj];
if (h_parobj) {
if (m_parentobj)
- m_parentobj->Release();
+ m_parentobj->UnregisterActuator(this);
m_parentobj= (KX_GameObject*)(*h_parobj);
- m_parentobj->AddRef();
+ m_parentobj->RegisterActuator(this);
}
}
@@ -425,8 +434,13 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_TrackToActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_TrackToActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -490,7 +504,7 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT
KX_GameObject *gameobj;
if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_TrackToActuator"))
- return 1; // ConvertPythonToGameObject sets the error
+ return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
if (actuator->m_object != NULL)
actuator->m_object->UnregisterActuator(actuator);
@@ -500,7 +514,7 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT
if (actuator->m_object)
actuator->m_object->RegisterActuator(actuator);
- return 0;
+ return PY_SET_ATTR_SUCCESS;
}
@@ -509,6 +523,10 @@ 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);
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h
index 99505f93cfe..c4cc2b1f062 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.h
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.h
@@ -61,8 +61,6 @@ class KX_TrackToActuator : public SCA_IActuator
virtual CValue* GetReplica() {
KX_TrackToActuator* replica = new KX_TrackToActuator(*this);
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
};
@@ -73,6 +71,7 @@ class KX_TrackToActuator : public SCA_IActuator
/* 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 */
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
index 1a6fb196db5..8146d04a878 100644
--- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
@@ -273,8 +273,13 @@ PyObject* KX_VehicleWrapper::PyGetConstraintType(PyObject* args)
//python specific stuff
PyTypeObject KX_VehicleWrapper::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_VehicleWrapper",
sizeof(PyObjectPlus_Proxy),
0,
@@ -303,32 +308,13 @@ PyObject* KX_VehicleWrapper::py_getattro(PyObject *attr)
py_getattro_up(PyObjectPlus);
}
-int KX_VehicleWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
-{
- /* TODO - strange setattr, needs updating */
- PyTypeObject* type = pyobj->ob_type;
- int result = 1;
-
- if (type == &PyList_Type)
- {
- result = 0;
- }
- if (type == &PyFloat_Type)
- {
- result = 0;
+PyObject* KX_VehicleWrapper::py_getattro_dict() {
+ py_getattro_dict_up(PyObjectPlus);
+}
- }
- if (type == &PyInt_Type)
- {
- result = 0;
- }
- if (type == &PyString_Type)
- {
- result = 0;
- }
- if (result)
- result = PyObjectPlus::py_setattro(attr,pyobj);
- return result;
+int KX_VehicleWrapper::py_setattro(PyObject *attr,PyObject* value)
+{
+ py_setattro_up(PyObjectPlus);
};
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.h b/source/gameengine/Ketsji/KX_VehicleWrapper.h
index de7fe75cfba..c2b5e3d9251 100644
--- a/source/gameengine/Ketsji/KX_VehicleWrapper.h
+++ b/source/gameengine/Ketsji/KX_VehicleWrapper.h
@@ -13,6 +13,7 @@ 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;
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp
index 88f63334285..4b0ad083473 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.cpp
+++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp
@@ -37,8 +37,13 @@
#include "KX_PyMath.h"
PyTypeObject KX_VertexProxy::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_VertexProxy",
sizeof(PyObjectPlus_Proxy),
0,
@@ -57,8 +62,8 @@ PyTypeObject KX_VertexProxy::Type = {
PyParentObject KX_VertexProxy::Parents[] = {
&KX_VertexProxy::Type,
- &SCA_IObject::Type,
&CValue::Type,
+ &PyObjectPlus::Type,
NULL
};
@@ -79,6 +84,7 @@ PyMethodDef KX_VertexProxy::Methods[] = {
};
PyAttributeDef KX_VertexProxy::Attributes[] = {
+ //KX_PYATTRIBUTE_TODO("DummyProps"),
KX_PYATTRIBUTE_DUMMY("x"),
KX_PYATTRIBUTE_DUMMY("y"),
@@ -156,7 +162,11 @@ KX_VertexProxy::py_getattro(PyObject *attr)
return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
}
- py_getattro_up(SCA_IObject);
+ py_getattro_up(CValue);
+}
+
+PyObject* KX_VertexProxy::py_getattro_dict() {
+ py_getattro_dict_up(CValue);
}
int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
@@ -312,7 +322,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
}
}
- return SCA_IObject::py_setattro(attr, pyvalue);
+ return CValue::py_setattro(attr, pyvalue);
}
KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
@@ -333,11 +343,9 @@ CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) {
STR_String sVertexName="vertex";
const STR_String & KX_VertexProxy::GetText() {return sVertexName;};
double KX_VertexProxy::GetNumber() { return -1;}
-STR_String KX_VertexProxy::GetName() { return sVertexName;}
-void KX_VertexProxy::SetName(STR_String) { };
+STR_String& KX_VertexProxy::GetName() { return sVertexName;}
+void KX_VertexProxy::SetName(const char *) { };
CValue* KX_VertexProxy::GetReplica() { return NULL;}
-void KX_VertexProxy::ReplicaSetName(STR_String) {};
-
// stuff for python integration
@@ -427,9 +435,10 @@ PyObject* KX_VertexProxy::PyGetUV2()
PyObject* KX_VertexProxy::PySetUV2(PyObject* args)
{
MT_Point2 vec;
- unsigned int unit=0;
+ unsigned int unit= RAS_TexVert::SECOND_UV;
+
PyObject* list= NULL;
- if(!PyArg_ParseTuple(args, "Oi:setUV2", &list, &unit))
+ if(!PyArg_ParseTuple(args, "O|i:setUV2", &list, &unit))
return NULL;
if (!PyVecTo(list, vec))
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h
index 67a15d96768..42db5fbc322 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.h
+++ b/source/gameengine/Ketsji/KX_VertexProxy.h
@@ -31,7 +31,7 @@
#include "SCA_IObject.h"
-class KX_VertexProxy : public SCA_IObject
+class KX_VertexProxy : public CValue
{
Py_Header;
protected:
@@ -47,14 +47,14 @@ public:
CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
const STR_String & GetText();
double GetNumber();
- STR_String GetName();
- void SetName(STR_String name); // Set the name of the value
- void ReplicaSetName(STR_String name);
+ STR_String& GetName();
+ void SetName(const char *name); // Set the name of the value
CValue* GetReplica();
// 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);
diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
index ba59d0d3d47..d848065ad73 100644
--- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
+++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
@@ -64,8 +64,6 @@ KX_VisibilityActuator::GetReplica(
{
KX_VisibilityActuator* replica = new KX_VisibilityActuator(*this);
replica->ProcessReplica();
- // this will copy properties and so on...
- CValue::AddDataToReplica(replica);
return replica;
}
@@ -94,8 +92,13 @@ KX_VisibilityActuator::Update()
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_VisibilityActuator::Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+#endif
"KX_VisibilityActuator",
sizeof(PyObjectPlus_Proxy),
0,
@@ -133,8 +136,8 @@ KX_VisibilityActuator::Methods[] = {
PyAttributeDef KX_VisibilityActuator::Attributes[] = {
KX_PYATTRIBUTE_BOOL_RW("visibility", KX_VisibilityActuator, m_visible),
- KX_PYATTRIBUTE_BOOL_RW("occlusion", KX_VisibilityActuator, m_occlusion),
- KX_PYATTRIBUTE_BOOL_RW("recursion", KX_VisibilityActuator, m_recursive),
+ KX_PYATTRIBUTE_BOOL_RW("useOcclusion", KX_VisibilityActuator, m_occlusion),
+ KX_PYATTRIBUTE_BOOL_RW("useRecursion", KX_VisibilityActuator, m_recursive),
{ NULL } //Sentinel
};
@@ -143,6 +146,10 @@ 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);
diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h
index 04633bce665..45aba50f645 100644
--- a/source/gameengine/Ketsji/KX_VisibilityActuator.h
+++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h
@@ -70,6 +70,7 @@ class KX_VisibilityActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
virtual PyObject* py_getattro(PyObject *attr);
+ virtual PyObject* py_getattro_dict();
virtual int py_setattro(PyObject *attr, PyObject *value);
// Deprecated ----->
diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript
index 921aba9c11f..5ab15c9eab3 100644
--- a/source/gameengine/Ketsji/SConscript
+++ b/source/gameengine/Ketsji/SConscript
@@ -8,25 +8,28 @@ defs = ''
# XXX 2.5
# Mathutils C files.
-#sources.extend([\
-# '#source/blender/python/api2_2x/Mathutils.c',\
-# '#source/blender/python/api2_2x/constant.c',\
-# '#source/blender/python/api2_2x/euler.c',\
-# '#source/blender/python/api2_2x/gen_utils.c',\
-# '#source/blender/python/api2_2x/matrix.c',\
-# '#source/blender/python/api2_2x/point.c',\
-# '#source/blender/python/api2_2x/quat.c',\
-# '#source/blender/python/api2_2x/vector.c',\
-#])
-#
-#sources.extend([\
-# '#source/blender/python/api2_2x/bpy_internal_import.c'
-#])
-#
-#
-#sources.extend([\
-# '#source/blender/python/api2_2x/BGL.c'
-#])
+"""
+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'
+])
+"""
+
incs = '. #source/blender/python/api2_2x' # Only for Mathutils! and bpy_internal_import.h, be very careful
diff --git a/source/gameengine/Network/NG_NetworkScene.cpp b/source/gameengine/Network/NG_NetworkScene.cpp
index 22263a2bdda..f8e489a8f48 100644
--- a/source/gameengine/Network/NG_NetworkScene.cpp
+++ b/source/gameengine/Network/NG_NetworkScene.cpp
@@ -119,7 +119,7 @@ void NG_NetworkScene::AddObject(NG_NetworkObject* object)
{
if (! m_networkdevice->IsOnline()) return;
- STR_String name = object->GetName();
+ const STR_String& name = object->GetName();
m_networkObjects.insert(name, object);
}
@@ -130,7 +130,7 @@ void NG_NetworkScene::RemoveObject(NG_NetworkObject* object)
{
if (! m_networkdevice->IsOnline()) return;
- STR_String name = object->GetName();
+ const STR_String& name = object->GetName();
m_networkObjects.remove(name);
}
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
index efe4554d970..5efd0994311 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
+++ b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
@@ -379,7 +379,10 @@ bool ODEPhysicsController::SynchronizeMotionStates(float time)
return false; //it update the worldpos
}
-
+PHY_IMotionState* ODEPhysicsController::GetMotionState()
+{
+ return m_MotionState;
+}
// kinematic methods
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.h b/source/gameengine/Physics/BlOde/OdePhysicsController.h
index e97afdb68c3..544d11da2ca 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.h
+++ b/source/gameengine/Physics/BlOde/OdePhysicsController.h
@@ -102,6 +102,7 @@ public:
virtual void WriteDynamicsToMotionState() {};
virtual void WriteMotionStateToDynamics(bool nondynaonly);
+ virtual class PHY_IMotionState* GetMotionState();
/**
call from Scene Graph Node to 'update'.
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
index 2e8ee31058f..54e97858b7f 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
@@ -75,7 +75,7 @@ float ODEPhysicsEnvironment::getFixedTimeStep()
-bool ODEPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep1)
+bool ODEPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep1,float interval)
{
float deltaTime = timeStep1;
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
index 2e4709cf420..54e4f7f90e1 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
+++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
@@ -44,7 +44,7 @@ public:
// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep);
+ virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
virtual float getFixedTimeStep();
@@ -64,8 +64,8 @@ public:
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
{
}
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl) {}
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl) {}
+ 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;}
diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt
index ec2cdede683..02f2aa635af 100644
--- a/source/gameengine/Physics/Bullet/CMakeLists.txt
+++ b/source/gameengine/Physics/Bullet/CMakeLists.txt
@@ -32,6 +32,7 @@ SET(INC
../../../../extern/bullet2/src
../../../../extern/glew/include
../../../../intern/moto/include
+ ../../../../intern/guardedalloc
../../../kernel/gen_system
../../../../intern/string
../../../../intern/SoundSystem
@@ -41,6 +42,8 @@ SET(INC
../../GameLogic
../../SceneGraph
../../../../source/blender/makesdna
+ ../../../../source/blender/blenlib
+ ../../../../source/blender/blenkernel
${PYTHON_INC}
)
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
index caf18fd28ba..2dbbb7fa4a0 100644
--- a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
@@ -47,11 +47,24 @@ void CcdGraphicController::setLocalAabb(const btVector3& aabbMin,const btVector3
void CcdGraphicController::setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax)
{
- m_localAabbMin = btVector3(aabbMin[0],aabbMin[1],aabbMin[2]);
- m_localAabbMax = btVector3(aabbMax[0],aabbMax[1],aabbMax[2]);
+ m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
+ m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
SetGraphicTransform();
}
+void CcdGraphicController::setLocalAabb(const PHY__Vector3& aabbMin,const PHY__Vector3& aabbMax)
+{
+ m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
+ m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
+ SetGraphicTransform();
+}
+
+void CcdGraphicController::setLocalAabb(const float* aabbMin,const float* aabbMax)
+{
+ m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]);
+ m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]);
+ SetGraphicTransform();
+}
void CcdGraphicController::getAabb(btVector3& aabbMin, btVector3& aabbMax)
{
@@ -105,8 +118,17 @@ PHY_IGraphicController* CcdGraphicController::GetReplica(class PHY_IMotionState*
replica->m_motionState = motionState;
replica->m_newClientInfo = NULL;
replica->m_handle = NULL;
- m_phyEnv->addCcdGraphicController(replica);
+ // don't add the graphic controller now: work around a bug in Bullet with rescaling,
+ // (the scale of the controller is not yet defined).
+ //m_phyEnv->addCcdGraphicController(replica);
return replica;
}
+void CcdGraphicController::Activate(bool active)
+{
+ if (active)
+ m_phyEnv->addCcdGraphicController(this);
+ else
+ m_phyEnv->removeCcdGraphicController(this);
+}
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h
index 8faa0944313..b0626f902c2 100644
--- a/source/gameengine/Physics/Bullet/CcdGraphicController.h
+++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h
@@ -38,6 +38,8 @@ public:
void setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax);
void setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax);
+ virtual void setLocalAabb(const PHY__Vector3& aabbMin,const PHY__Vector3& aabbMax);
+ virtual void setLocalAabb(const float aabbMin[3],const float aabbMax[3]);
PHY_IMotionState* GetMotionState() { return m_motionState; }
void getAabb(btVector3& aabbMin, btVector3& aabbMax);
@@ -53,6 +55,10 @@ public:
* Updates the Aabb based on the motion state
*/
virtual bool SetGraphicTransform();
+ /**
+ * Add/remove to environment
+ */
+ virtual void Activate(bool active);
// client info for culling
virtual void* getNewClientInfo() { return m_newClientInfo; }
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 0b9da8f46d3..d22c09b4d3e 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -35,6 +35,10 @@ subject to the following restrictions:
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+extern "C"{
+#include "BKE_cdderivedmesh.h"
+}
+
class BP_Proxy;
///todo: fill all the empty CcdPhysicsController methods, hook them up to the btRigidBody class
@@ -88,16 +92,19 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
}
-btTransform CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* motionState)
+btTransform& CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* motionState)
{
- btTransform trans;
- float tmp[3];
- motionState->getWorldPosition(tmp[0],tmp[1],tmp[2]);
- trans.setOrigin(btVector3(tmp[0],tmp[1],tmp[2]));
-
- btQuaternion orn;
- motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
- trans.setRotation(orn);
+ static btTransform trans;
+ btVector3 tmp;
+ motionState->getWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]);
+ trans.setOrigin(tmp);
+
+ float ori[12];
+ motionState->getWorldOrientation(ori);
+ trans.getBasis().setFromOpenGLSubMatrix(ori);
+ //btQuaternion orn;
+ //motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
+ //trans.setRotation(orn);
return trans;
}
@@ -114,18 +121,18 @@ public:
}
- virtual void getWorldTransform(btTransform& worldTrans ) const
+ void getWorldTransform(btTransform& worldTrans ) const
{
- float pos[3];
- float quatOrn[4];
+ btVector3 pos;
+ float ori[12];
- m_blenderMotionState->getWorldPosition(pos[0],pos[1],pos[2]);
- m_blenderMotionState->getWorldOrientation(quatOrn[0],quatOrn[1],quatOrn[2],quatOrn[3]);
- worldTrans.setOrigin(btVector3(pos[0],pos[1],pos[2]));
- worldTrans.setBasis(btMatrix3x3(btQuaternion(quatOrn[0],quatOrn[1],quatOrn[2],quatOrn[3])));
+ m_blenderMotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]);
+ m_blenderMotionState->getWorldOrientation(ori);
+ worldTrans.setOrigin(pos);
+ worldTrans.getBasis().setFromOpenGLSubMatrix(ori);
}
- virtual void setWorldTransform(const btTransform& worldTrans)
+ void setWorldTransform(const btTransform& worldTrans)
{
m_blenderMotionState->setWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ());
btQuaternion rotQuat = worldTrans.getRotation();
@@ -178,12 +185,12 @@ void CcdPhysicsController::CreateRigidbody()
rbci.m_restitution = m_cci.m_restitution;
- int nodecount = 0;
+
+
- int numtriangles = 1;
btVector3 p(0,0,0);// = getOrigin();
- btScalar h = 1.f;
+
btSoftRigidDynamicsWorld* softDynaWorld = (btSoftRigidDynamicsWorld*)m_cci.m_physicsEnv->getDynamicsWorld();
@@ -289,7 +296,11 @@ void CcdPhysicsController::CreateRigidbody()
}
}
-
+ if (m_cci.m_margin > 0.f)
+ {
+ psb->getCollisionShape()->setMargin(m_cci.m_margin);
+ psb->updateBounds();
+ }
m_object = psb;
@@ -489,10 +500,12 @@ void CcdPhysicsController::CreateRigidbody()
//convert collision flags!
//special case: a near/radar sensor controller should not be defined static or it will
//generate loads of static-static collision messages on the console
- if ((m_cci.m_collisionFilterGroup & CcdConstructionInfo::SensorFilter) != 0)
+ if (m_cci.m_bSensor)
{
// reset the flags that have been set so far
GetCollisionObject()->setCollisionFlags(0);
+ // sensor must never go to sleep: they need to detect continously
+ GetCollisionObject()->setActivationState(DISABLE_DEACTIVATION);
}
GetCollisionObject()->setCollisionFlags(m_object->getCollisionFlags() | m_cci.m_collisionFlags);
btRigidBody* body = GetRigidBody();
@@ -506,6 +519,8 @@ void CcdPhysicsController::CreateRigidbody()
{
body->setAngularFactor(0.f);
}
+ body->setContactProcessingThreshold(m_cci.m_contactProcessingThreshold);
+
}
if (m_object && m_cci.m_do_anisotropic)
{
@@ -572,10 +587,22 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
btSoftBody* sb = GetSoftBody();
if (sb)
{
- btVector3 aabbMin,aabbMax;
- sb->getAabb(aabbMin,aabbMax);
- btVector3 worldPos = (aabbMax+aabbMin)*0.5f;
- m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+ if (sb->m_pose.m_bframe)
+ {
+ btVector3 worldPos = sb->m_pose.m_com;
+ btQuaternion worldquat;
+ btMatrix3x3 trs = sb->m_pose.m_rot*sb->m_pose.m_scl;
+ trs.getRotation(worldquat);
+ m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+ m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
+ }
+ else
+ {
+ btVector3 aabbMin,aabbMax;
+ sb->getAabb(aabbMin,aabbMax);
+ btVector3 worldPos = (aabbMax+aabbMin)*0.5f;
+ m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+ }
m_MotionState->calculateWorldTransformations();
return true;
}
@@ -597,12 +624,13 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
body->setLinearVelocity(linvel * (m_cci.m_clamp_vel_min / len));
}
- const btVector3& worldPos = body->getCenterOfMassPosition();
+ const btTransform& xform = body->getCenterOfMassTransform();
+ const btMatrix3x3& worldOri = xform.getBasis();
+ const btVector3& worldPos = xform.getOrigin();
+ float ori[12];
+ worldOri.getOpenGLSubMatrix(ori);
+ m_MotionState->setWorldOrientation(ori);
m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
-
- const btQuaternion& worldquat = body->getOrientation();
- m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
-
m_MotionState->calculateWorldTransformations();
float scale[3];
@@ -639,8 +667,10 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
void CcdPhysicsController::WriteMotionStateToDynamics(bool nondynaonly)
{
-
+ btTransform& xform = CcdPhysicsController::GetTransformFromMotionState(m_MotionState);
+ SetCenterOfMassTransform(xform);
}
+
void CcdPhysicsController::WriteDynamicsToMotionState()
{
}
@@ -657,12 +687,12 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta
if (m_shapeInfo)
{
m_shapeInfo->AddRef();
- m_collisionShape = m_shapeInfo->CreateBulletShape();
+ m_collisionShape = m_shapeInfo->CreateBulletShape(m_cci.m_margin);
if (m_collisionShape)
{
// new shape has no scaling, apply initial scaling
- m_collisionShape->setMargin(m_cci.m_margin);
+ //m_collisionShape->setMargin(m_cci.m_margin);
m_collisionShape->setLocalScaling(m_cci.m_scaling);
if (m_cci.m_mass)
@@ -670,19 +700,29 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta
}
}
+ // load some characterists that are not
+ btRigidBody* oldbody = GetRigidBody();
m_object = 0;
CreateRigidbody();
-
btRigidBody* body = GetRigidBody();
-
if (body)
{
if (m_cci.m_mass)
{
body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
}
- }
- m_cci.m_physicsEnv->addCcdPhysicsController(this);
+
+ if (oldbody)
+ {
+ body->setLinearFactor(oldbody->getLinearFactor());
+ body->setAngularFactor(oldbody->getAngularFactor());
+ if (oldbody->getActivationState() == DISABLE_DEACTIVATION)
+ body->setActivationState(DISABLE_DEACTIVATION);
+ }
+ }
+ // sensor object are added when needed
+ if (!m_cci.m_bSensor)
+ m_cci.m_physicsEnv->addCcdPhysicsController(this);
/* SM_Object* dynaparent=0;
@@ -759,10 +799,13 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
m_object->activate(true);
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ // kinematic object should not set the transform, it disturbs the velocity interpolation
+ return;
}
- btRigidBody* body = GetRigidBody();
+ // btRigidBody* body = GetRigidBody(); // not used anymore
btVector3 dloc(dlocX,dlocY,dlocZ);
btTransform xform = m_object->getWorldTransform();
@@ -785,7 +828,10 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
m_object->activate(true);
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ // kinematic object should not set the transform, it disturbs the velocity interpolation
+ return;
}
btMatrix3x3 drotmat( rotval[0],rotval[4],rotval[8],
@@ -808,10 +854,9 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat)
{
- float orn[4];
- m_MotionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
- btQuaternion quat(orn[0],orn[1],orn[2],orn[3]);
- mat.setRotation(quat);
+ float ori[12];
+ m_MotionState->getWorldOrientation(ori);
+ mat.setFromOpenGLSubMatrix(ori);
}
void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
@@ -829,7 +874,10 @@ void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float
m_object->activate(true);
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ // kinematic object should not set the transform, it disturbs the velocity interpolation
+ return;
}
// not required
//m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
@@ -850,7 +898,7 @@ void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn)
if (m_object)
{
m_object->activate(true);
- if (m_object->isStaticObject())
+ if (m_object->isStaticObject() && !m_cci.m_bSensor)
{
m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
@@ -881,7 +929,10 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
m_object->activate(true);
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ // kinematic object should not set the transform, it disturbs the velocity interpolation
+ return;
}
// not required, this function is only used to update the physic controller
//m_MotionState->setWorldPosition(posX,posY,posZ);
@@ -893,9 +944,19 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
// not required
//m_bulletMotionState->setWorldTransform(xform);
}
+}
-
+void CcdPhysicsController::forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos)
+{
+ if (m_object)
+ {
+ btTransform& xform = m_object->getWorldTransform();
+ xform.setBasis(mat);
+ xform.setOrigin(pos);
+ }
}
+
+
void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
{
}
@@ -945,14 +1006,24 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque
m_object->activate();
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
}
if (local)
{
torque = xform.getBasis()*torque;
}
if (body)
+ {
+ //workaround for incompatibility between 'DYNAMIC' game object, and angular factor
+ //a DYNAMIC object has some inconsistency: it has no angular effect due to collisions, but still has torque
+ const btVector3& angFac = body->getAngularFactor();
+ btVector3 tmpFac(0,0,1);
+ body->setAngularFactor(tmpFac);
body->applyTorque(torque);
+ body->setAngularFactor(angFac);
+ }
}
}
@@ -966,27 +1037,26 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo
m_object->activate();
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
}
-
+ btTransform xform = m_object->getWorldTransform();
+
+ if (local)
+ {
+ force = xform.getBasis()*force;
+ }
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ body->applyCentralForce(force);
+ btSoftBody* soft = GetSoftBody();
+ if (soft)
{
- btTransform xform = m_object->getWorldTransform();
-
- if (local)
- {
- force = xform.getBasis()*force;
- }
- btRigidBody* body = GetRigidBody();
- if (body)
- body->applyCentralForce(force);
- btSoftBody* soft = GetSoftBody();
- if (soft)
- {
- // the force is applied on each node, must reduce it in the same extend
- if (soft->m_nodes.size() > 0)
- force /= soft->m_nodes.size();
- soft->addForce(force);
- }
+ // the force is applied on each node, must reduce it in the same extend
+ if (soft->m_nodes.size() > 0)
+ force /= soft->m_nodes.size();
+ soft->addForce(force);
}
}
}
@@ -998,19 +1068,18 @@ void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo
m_object->activate(true);
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- } else
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
+ }
+ btTransform xform = m_object->getWorldTransform();
+ if (local)
{
- btTransform xform = m_object->getWorldTransform();
- if (local)
- {
- angvel = xform.getBasis()*angvel;
- }
- btRigidBody* body = GetRigidBody();
- if (body)
- body->setAngularVelocity(angvel);
-
+ angvel = xform.getBasis()*angvel;
}
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ body->setAngularVelocity(angvel);
}
}
@@ -1023,7 +1092,8 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa
m_object->activate(true);
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
return;
}
@@ -1057,7 +1127,9 @@ void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac
m_object->activate();
if (m_object->isStaticObject())
{
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ if (!m_cci.m_bSensor)
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
}
btVector3 pos(attachX,attachY,attachZ);
@@ -1184,7 +1256,7 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplica()
if (m_shapeInfo)
{
// This situation does not normally happen
- cinfo.m_collisionShape = m_shapeInfo->CreateBulletShape();
+ cinfo.m_collisionShape = m_shapeInfo->CreateBulletShape(0.01);
}
else if (m_collisionShape)
{
@@ -1251,28 +1323,22 @@ void DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scal
void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
{
- quatIma0 = m_worldTransform.getRotation().x();
- quatIma1 = m_worldTransform.getRotation().y();
- quatIma2 = m_worldTransform.getRotation().z();
- quatReal = m_worldTransform.getRotation()[3];
+ btQuaternion quat = m_worldTransform.getRotation();
+ quatIma0 = quat.x();
+ quatIma1 = quat.y();
+ quatIma2 = quat.z();
+ quatReal = quat[3];
}
void DefaultMotionState::getWorldOrientation(float* ori)
{
- *ori++ = m_worldTransform.getBasis()[0].x();
- *ori++ = m_worldTransform.getBasis()[1].x();
- *ori++ = m_worldTransform.getBasis()[1].x();
- *ori++ = 0.f;
- *ori++ = m_worldTransform.getBasis()[0].y();
- *ori++ = m_worldTransform.getBasis()[1].y();
- *ori++ = m_worldTransform.getBasis()[1].y();
- *ori++ = 0.f;
- *ori++ = m_worldTransform.getBasis()[0].z();
- *ori++ = m_worldTransform.getBasis()[1].z();
- *ori++ = m_worldTransform.getBasis()[1].z();
- *ori++ = 0.f;
+ m_worldTransform.getBasis().getOpenGLSubMatrix(ori);
}
+void DefaultMotionState::setWorldOrientation(const float* ori)
+{
+ m_worldTransform.getBasis().setFromOpenGLSubMatrix(ori);
+}
void DefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
{
btVector3 pos(posX,posY,posZ);
@@ -1293,9 +1359,9 @@ void DefaultMotionState::calculateWorldTransformations()
// Shape constructor
std::map<RAS_MeshObject*, CcdShapeConstructionInfo*> CcdShapeConstructionInfo::m_meshShapeMap;
-CcdShapeConstructionInfo* CcdShapeConstructionInfo::FindMesh(RAS_MeshObject* mesh, bool polytope)
+CcdShapeConstructionInfo* CcdShapeConstructionInfo::FindMesh(RAS_MeshObject* mesh, struct DerivedMesh* dm, bool polytope, bool gimpact)
{
- if (polytope)
+ if (polytope || dm || gimpact)
// not yet supported
return NULL;
@@ -1305,9 +1371,9 @@ CcdShapeConstructionInfo* CcdShapeConstructionInfo::FindMesh(RAS_MeshObject* mes
return NULL;
}
-bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bool useGimpact)
+bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, bool polytope,bool useGimpact)
{
- int numpolys;
+ int numpolys, numverts;
m_useGimpact = useGimpact;
@@ -1316,6 +1382,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo
assert(IsUnused());
m_shapeType = PHY_SHAPE_NONE;
m_meshObject = NULL;
+ bool free_dm = false;
// No mesh object or mesh has no polys
if (!meshobj || meshobj->HasColliderPolygon()==false) {
@@ -1325,164 +1392,182 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo
return false;
}
- numpolys = meshobj->NumPolygons();
+ if (!dm) {
+ free_dm = true;
+ dm = CDDM_from_mesh(meshobj->GetMesh(), NULL);
+ }
+
+ MVert *mvert = dm->getVertArray(dm);
+ MFace *mface = dm->getFaceArray(dm);
+ numpolys = dm->getNumFaces(dm);
+ numverts = dm->getNumVerts(dm);
+ int* index = (int*)dm->getFaceDataArray(dm, CD_ORIGINDEX);
m_shapeType = (polytope) ? PHY_SHAPE_POLYTOPE : PHY_SHAPE_MESH;
/* Convert blender geometry into bullet mesh, need these vars for mapping */
- vector<bool> vert_tag_array(meshobj->GetMesh()->totvert, false);
+ vector<bool> vert_tag_array(numverts, false);
unsigned int tot_bt_verts= 0;
- unsigned int orig_index;
- int i;
if (polytope)
{
// Tag verts we're using
for (int p2=0; p2<numpolys; p2++)
{
- RAS_Polygon* poly= meshobj->GetPolygon(p2);
+ MFace* mf = &mface[p2];
+ RAS_Polygon* poly = meshobj->GetPolygon(index[p2]);
// only add polygons that have the collision flag set
if (poly->IsCollider())
{
- for(i=0; i<poly->VertexCount(); i++) {
- orig_index= poly->GetVertex(i)->getOrigIndex();
- if (vert_tag_array[orig_index]==false)
- {
- vert_tag_array[orig_index]= true;
- tot_bt_verts++;
- }
- }
+ if (vert_tag_array[mf->v1]==false) {vert_tag_array[mf->v1]= true;tot_bt_verts++;}
+ if (vert_tag_array[mf->v2]==false) {vert_tag_array[mf->v2]= true;tot_bt_verts++;}
+ if (vert_tag_array[mf->v3]==false) {vert_tag_array[mf->v3]= true;tot_bt_verts++;}
+ if (mf->v4 && vert_tag_array[mf->v4]==false) {vert_tag_array[mf->v4]= true;tot_bt_verts++;}
}
}
- m_vertexArray.resize(tot_bt_verts);
+ m_vertexArray.resize(tot_bt_verts*3);
- btVector3 *bt= &m_vertexArray[0];
+ btScalar *bt= &m_vertexArray[0];
for (int p2=0; p2<numpolys; p2++)
{
- RAS_Polygon* poly= meshobj->GetPolygon(p2);
+ MFace* mf = &mface[p2];
+ RAS_Polygon* poly= meshobj->GetPolygon(index[p2]);
// only add polygons that have the collisionflag set
if (poly->IsCollider())
{
- for(i=0; i<poly->VertexCount(); i++) {
- RAS_TexVert *v= poly->GetVertex(i);
- orig_index= v->getOrigIndex();
-
- if (vert_tag_array[orig_index]==true)
- {
- const float* vtx = v->getXYZ();
- vert_tag_array[orig_index]= false;
-
- bt->setX(vtx[0]); bt->setY(vtx[1]); bt->setZ(vtx[2]);
- bt++;
- }
+ if (vert_tag_array[mf->v1]==true)
+ {
+ const float* vtx = mvert[mf->v1].co;
+ vert_tag_array[mf->v1]= false;
+ *bt++ = vtx[0];
+ *bt++ = vtx[1];
+ *bt++ = vtx[2];
+ }
+ if (vert_tag_array[mf->v2]==true)
+ {
+ const float* vtx = mvert[mf->v2].co;
+ vert_tag_array[mf->v2]= false;
+ *bt++ = vtx[0];
+ *bt++ = vtx[1];
+ *bt++ = vtx[2];
+ }
+ if (vert_tag_array[mf->v3]==true)
+ {
+ const float* vtx = mvert[mf->v3].co;
+ vert_tag_array[mf->v3]= false;
+ *bt++ = vtx[0];
+ *bt++ = vtx[1];
+ *bt++ = vtx[2];
+ }
+ if (mf->v4 && vert_tag_array[mf->v4]==true)
+ {
+ const float* vtx = mvert[mf->v4].co;
+ vert_tag_array[mf->v4]= false;
+ *bt++ = vtx[0];
+ *bt++ = vtx[1];
+ *bt++ = vtx[2];
}
}
}
}
else {
unsigned int tot_bt_tris= 0;
- vector<int> vert_remap_array(meshobj->GetMesh()->totvert, 0);
+ vector<int> vert_remap_array(numverts, 0);
// Tag verts we're using
for (int p2=0; p2<numpolys; p2++)
{
- RAS_Polygon* poly= meshobj->GetPolygon(p2);
+ MFace* mf = &mface[p2];
+ RAS_Polygon* poly= meshobj->GetPolygon(index[p2]);
// only add polygons that have the collision flag set
if (poly->IsCollider())
{
- for(i=0; i<poly->VertexCount(); i++) {
- orig_index= poly->GetVertex(i)->getOrigIndex();
- if (vert_tag_array[orig_index]==false)
- {
- vert_tag_array[orig_index]= true;
- vert_remap_array[orig_index]= tot_bt_verts;
- tot_bt_verts++;
- }
- }
-
- tot_bt_tris += (i==4 ? 2:1); /* a quad or a tri */
+ if (vert_tag_array[mf->v1]==false)
+ {vert_tag_array[mf->v1]= true;vert_remap_array[mf->v1]= tot_bt_verts;tot_bt_verts++;}
+ if (vert_tag_array[mf->v2]==false)
+ {vert_tag_array[mf->v2]= true;vert_remap_array[mf->v2]= tot_bt_verts;tot_bt_verts++;}
+ if (vert_tag_array[mf->v3]==false)
+ {vert_tag_array[mf->v3]= true;vert_remap_array[mf->v3]= tot_bt_verts;tot_bt_verts++;}
+ if (mf->v4 && vert_tag_array[mf->v4]==false)
+ {vert_tag_array[mf->v4]= true;vert_remap_array[mf->v4]= tot_bt_verts;tot_bt_verts++;}
+ tot_bt_tris += (mf->v4 ? 2:1); /* a quad or a tri */
}
}
- m_vertexArray.resize(tot_bt_verts);
+ m_vertexArray.resize(tot_bt_verts*3);
m_polygonIndexArray.resize(tot_bt_tris);
m_triFaceArray.resize(tot_bt_tris*3);
- btVector3 *bt= &m_vertexArray[0];
+ btScalar *bt= &m_vertexArray[0];
int *poly_index_pt= &m_polygonIndexArray[0];
int *tri_pt= &m_triFaceArray[0];
-
for (int p2=0; p2<numpolys; p2++)
{
- RAS_Polygon* poly= meshobj->GetPolygon(p2);
+ MFace* mf = &mface[p2];
+ RAS_Polygon* poly= meshobj->GetPolygon(index[p2]);
// only add polygons that have the collisionflag set
if (poly->IsCollider())
{
- RAS_TexVert *v1= poly->GetVertex(0);
- RAS_TexVert *v2= poly->GetVertex(1);
- RAS_TexVert *v3= poly->GetVertex(2);
- int i1= v1->getOrigIndex();
- int i2= v2->getOrigIndex();
- int i3= v3->getOrigIndex();
- const float* vtx;
+ MVert *v1= &mvert[mf->v1];
+ MVert *v2= &mvert[mf->v2];
+ MVert *v3= &mvert[mf->v3];
// the face indicies
- tri_pt[0]= vert_remap_array[i1];
- tri_pt[1]= vert_remap_array[i2];
- tri_pt[2]= vert_remap_array[i3];
+ tri_pt[0]= vert_remap_array[mf->v1];
+ tri_pt[1]= vert_remap_array[mf->v2];
+ tri_pt[2]= vert_remap_array[mf->v3];
tri_pt= tri_pt+3;
// m_polygonIndexArray
- *poly_index_pt= p2;
+ *poly_index_pt= index[p2];
poly_index_pt++;
// the vertex location
- if (vert_tag_array[i1]==true) { /* *** v1 *** */
- vert_tag_array[i1]= false;
- vtx = v1->getXYZ();
- bt->setX(vtx[0]); bt->setY( vtx[1]); bt->setZ(vtx[2]);
- bt++;
+ if (vert_tag_array[mf->v1]==true) { /* *** v1 *** */
+ vert_tag_array[mf->v1]= false;
+ *bt++ = v1->co[0];
+ *bt++ = v1->co[1];
+ *bt++ = v1->co[2];
}
- if (vert_tag_array[i2]==true) { /* *** v2 *** */
- vert_tag_array[i2]= false;
- vtx = v2->getXYZ();
- bt->setX(vtx[0]); bt->setY(vtx[1]); bt->setZ(vtx[2]);
- bt++;
+ if (vert_tag_array[mf->v2]==true) { /* *** v2 *** */
+ vert_tag_array[mf->v2]= false;
+ *bt++ = v2->co[0];
+ *bt++ = v2->co[1];
+ *bt++ = v2->co[2];
}
- if (vert_tag_array[i3]==true) { /* *** v3 *** */
- vert_tag_array[i3]= false;
- vtx = v3->getXYZ();
- bt->setX(vtx[0]); bt->setY(vtx[1]); bt->setZ(vtx[2]);
- bt++;
+ if (vert_tag_array[mf->v3]==true) { /* *** v3 *** */
+ vert_tag_array[mf->v3]= false;
+ *bt++ = v3->co[0];
+ *bt++ = v3->co[1];
+ *bt++ = v3->co[2];
}
- if (poly->VertexCount()==4)
+ if (mf->v4)
{
- RAS_TexVert *v4= poly->GetVertex(3);
- int i4= v4->getOrigIndex();
+ MVert *v4= &mvert[mf->v4];
- tri_pt[0]= vert_remap_array[i1];
- tri_pt[1]= vert_remap_array[i3];
- tri_pt[2]= vert_remap_array[i4];
+ tri_pt[0]= vert_remap_array[mf->v1];
+ tri_pt[1]= vert_remap_array[mf->v3];
+ tri_pt[2]= vert_remap_array[mf->v4];
tri_pt= tri_pt+3;
// m_polygonIndexArray
- *poly_index_pt= p2;
+ *poly_index_pt= index[p2];
poly_index_pt++;
// the vertex location
- if (vert_tag_array[i4]==true) { /* *** v4 *** */
- vert_tag_array[i4]= false;
- vtx = v4->getXYZ();
- bt->setX(vtx[0]); bt->setY(vtx[1]); bt->setZ(vtx[2]);
- bt++;
+ if (vert_tag_array[mf->v4]==true) { /* *** v4 *** */
+ vert_tag_array[mf->v4]= false;
+ *bt++ = v4->co[0];
+ *bt++ = v4->co[1];
+ *bt++ = v4->co[2];
}
}
}
@@ -1514,7 +1599,13 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo
#endif
m_meshObject = meshobj;
- if (!polytope)
+ if (free_dm) {
+ dm->release(dm);
+ dm = NULL;
+ }
+
+ // sharing only on static mesh at present, if you change that, you must also change in FindMesh
+ if (!polytope && !dm && !useGimpact)
{
// triangle shape can be shared, store the mesh object in the map
m_meshShapeMap.insert(std::pair<RAS_MeshObject*,CcdShapeConstructionInfo*>(meshobj,this));
@@ -1533,15 +1624,13 @@ bool CcdShapeConstructionInfo::SetProxy(CcdShapeConstructionInfo* shapeInfo)
return true;
}
-btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
+btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin)
{
btCollisionShape* collisionShape = 0;
- btTriangleMeshShape* concaveShape = 0;
- btCompoundShape* compoundShape = 0;
- CcdShapeConstructionInfo* nextShapeInfo;
+ btCompoundShape* compoundShape = 0;
if (m_shapeType == PHY_SHAPE_PROXY && m_shapeProxy != NULL)
- return m_shapeProxy->CreateBulletShape();
+ return m_shapeProxy->CreateBulletShape(margin);
switch (m_shapeType)
{
@@ -1550,22 +1639,27 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
case PHY_SHAPE_BOX:
collisionShape = new btBoxShape(m_halfExtend);
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_SPHERE:
collisionShape = new btSphereShape(m_radius);
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_CYLINDER:
collisionShape = new btCylinderShapeZ(m_halfExtend);
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_CONE:
collisionShape = new btConeShapeZ(m_radius, m_height);
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_POLYTOPE:
- collisionShape = new btConvexHullShape(&m_vertexArray[0].getX(), m_vertexArray.size());
+ collisionShape = new btConvexHullShape(&m_vertexArray[0], m_vertexArray.size()/3, 3*sizeof(btScalar));
+ collisionShape->setMargin(margin);
break;
case PHY_SHAPE_MESH:
@@ -1582,13 +1676,13 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
m_polygonIndexArray.size(),
&m_triFaceArray[0],
3*sizeof(int),
- m_vertexArray.size(),
- (btScalar*) &m_vertexArray[0].x(),
- sizeof(btVector3)
+ m_vertexArray.size()/3,
+ &m_vertexArray[0],
+ 3*sizeof(btScalar)
);
btGImpactMeshShape* gimpactShape = new btGImpactMeshShape(indexVertexArrays);
-
+ gimpactShape->setMargin(margin);
collisionShape = gimpactShape;
gimpactShape->updateBound();
@@ -1606,13 +1700,14 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
collisionMeshData->m_weldingThreshold = m_weldingThreshold1;
bool removeDuplicateVertices=true;
// m_vertexArray not in multiple of 3 anymore, use m_triFaceArray
- for(int i=0; i<m_triFaceArray.size(); i+=3) {
- collisionMeshData->addTriangle(
- m_vertexArray[m_triFaceArray[i]],
- m_vertexArray[m_triFaceArray[i+1]],
- m_vertexArray[m_triFaceArray[i+2]],
- removeDuplicateVertices
- );
+ for(unsigned int i=0; i<m_triFaceArray.size(); i+=3) {
+ btScalar *bt = &m_vertexArray[3*m_triFaceArray[i]];
+ btVector3 v1(bt[0], bt[1], bt[2]);
+ bt = &m_vertexArray[3*m_triFaceArray[i+1]];
+ btVector3 v2(bt[0], bt[1], bt[2]);
+ bt = &m_vertexArray[3*m_triFaceArray[i+2]];
+ btVector3 v3(bt[0], bt[1], bt[2]);
+ collisionMeshData->addTriangle(v1, v2, v3, removeDuplicateVertices);
}
indexVertexArrays = collisionMeshData;
@@ -1622,9 +1717,9 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
m_polygonIndexArray.size(),
&m_triFaceArray[0],
3*sizeof(int),
- m_vertexArray.size(),
- (btScalar*) &m_vertexArray[0].x(),
- sizeof(btVector3));
+ m_vertexArray.size()/3,
+ &m_vertexArray[0],
+ 3*sizeof(btScalar));
}
// this shape will be shared and not deleted until shapeInfo is deleted
@@ -1632,6 +1727,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
m_unscaledShape->recalcLocalAabb();
}
collisionShape = new btScaledBvhTriangleMeshShape(m_unscaledShape, btVector3(1.0f,1.0f,1.0f));
+ collisionShape->setMargin(margin);
}
break;
@@ -1643,7 +1739,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
sit != m_shapeArray.end();
sit++)
{
- collisionShape = (*sit)->CreateBulletShape();
+ collisionShape = (*sit)->CreateBulletShape(margin);
if (collisionShape)
{
collisionShape->setLocalScaling((*sit)->m_childScale);
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 4510bbddf65..d73759bac76 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -36,6 +36,7 @@ extern bool gDisableDeactivation;
class CcdPhysicsEnvironment;
class btMotionState;
class RAS_MeshObject;
+struct DerivedMesh;
class btCollisionShape;
@@ -59,7 +60,7 @@ class CcdShapeConstructionInfo
public:
- static CcdShapeConstructionInfo* FindMesh(RAS_MeshObject* mesh, bool polytope);
+ static CcdShapeConstructionInfo* FindMesh(class RAS_MeshObject* mesh, struct DerivedMesh* dm, bool polytope, bool gimpact);
CcdShapeConstructionInfo() :
m_shapeType(PHY_SHAPE_NONE),
@@ -139,7 +140,7 @@ public:
return true;
}
- bool SetMesh(RAS_MeshObject* mesh, bool polytope,bool useGimpact);
+ bool SetMesh(class RAS_MeshObject* mesh, struct DerivedMesh* dm, bool polytope,bool useGimpact);
RAS_MeshObject* GetMesh(void)
{
return m_meshObject;
@@ -151,7 +152,7 @@ public:
return m_shapeProxy;
}
- btCollisionShape* CreateBulletShape();
+ btCollisionShape* CreateBulletShape(btScalar margin);
// member variables
PHY_ShapeType m_shapeType;
@@ -161,8 +162,8 @@ public:
btTransform m_childTrans;
btVector3 m_childScale;
void* m_userData;
- btAlignedObjectArray<btVector3> m_vertexArray; // Contains both vertex array for polytope shape and
- // triangle array for concave mesh shape.
+ btAlignedObjectArray<btScalar> m_vertexArray; // Contains both vertex array for polytope shape and
+ // triangle array for concave mesh shape. Each vertex is 3 consecutive values
// In this case a triangle is made of 3 consecutive points
std::vector<int> m_polygonIndexArray; // Contains the array of polygon index in the
// original mesh that correspond to shape triangles.
@@ -173,11 +174,7 @@ public:
void setVertexWeldingThreshold1(float threshold)
{
- m_weldingThreshold1 = threshold;
- }
- float getVertexWeldingThreshold1() const
- {
- return m_weldingThreshold1;
+ m_weldingThreshold1 = threshold*threshold;
}
protected:
static std::map<RAS_MeshObject*, CcdShapeConstructionInfo*> m_meshShapeMap;
@@ -225,6 +222,7 @@ struct CcdConstructionInfo
m_collisionFlags(0),
m_bRigid(false),
m_bSoft(false),
+ m_bSensor(false),
m_collisionFilterGroup(DefaultFilter),
m_collisionFilterMask(AllFilter),
m_collisionShape(0),
@@ -233,7 +231,8 @@ struct CcdConstructionInfo
m_physicsEnv(0),
m_inertiaFactor(1.f),
m_do_anisotropic(false),
- m_anisotropicFriction(1.f,1.f,1.f)
+ m_anisotropicFriction(1.f,1.f,1.f),
+ m_contactProcessingThreshold(1e10)
{
}
@@ -291,6 +290,7 @@ struct CcdConstructionInfo
int m_collisionFlags;
bool m_bRigid;
bool m_bSoft;
+ bool m_bSensor;
///optional use of collision group/mask:
///only collision with object goups that match the collision mask.
@@ -318,6 +318,13 @@ struct CcdConstructionInfo
btScalar m_fh_distance; ///< The range above the surface where Fh is active.
bool m_fh_normal; ///< Should the object slide off slopes?
float m_radius;//for fh backwards compatibility
+
+ ///m_contactProcessingThreshold allows to process contact points with positive distance
+ ///normally only contacts with negative distance (penetration) are solved
+ ///however, rigid body stacking is more stable when positive contacts are still passed into the constraint solver
+ ///this might sometimes lead to collisions with 'internal edges' such as a sliding character controller
+ ///so disable/set m_contactProcessingThreshold to zero for sliding characters etc.
+ float m_contactProcessingThreshold;///< Process contacts with positive distance in range [0..INF]
};
@@ -329,7 +336,7 @@ class btSoftBody;
///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution.
class CcdPhysicsController : public PHY_IPhysicsController
{
-
+protected:
btCollisionObject* m_object;
@@ -364,8 +371,8 @@ class CcdPhysicsController : public PHY_IPhysicsController
return (--m_registerCount == 0) ? true : false;
}
- protected:
- void setWorldOrientation(const btMatrix3x3& mat);
+ void setWorldOrientation(const btMatrix3x3& mat);
+ void forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos);
public:
@@ -410,6 +417,7 @@ class CcdPhysicsController : public PHY_IPhysicsController
virtual void WriteMotionStateToDynamics(bool nondynaonly);
virtual void WriteDynamicsToMotionState();
+
// controller replication
virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl);
@@ -508,7 +516,7 @@ class CcdPhysicsController : public PHY_IPhysicsController
void SetCenterOfMassTransform(btTransform& xform);
- static btTransform GetTransformFromMotionState(PHY_IMotionState* motionState);
+ static btTransform& GetTransformFromMotionState(PHY_IMotionState* motionState);
void setAabb(const btVector3& aabbMin,const btVector3& aabbMax);
@@ -566,6 +574,7 @@ class DefaultMotionState : public PHY_IMotionState
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();
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 3e1e0294321..bc7ccacc39b 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -415,61 +415,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
obj->setActivationState(ISLAND_SLEEPING);
}
-
- //CollisionObject(body,ctrl->GetCollisionFilterGroup(),ctrl->GetCollisionFilterMask());
-
assert(obj->getBroadphaseHandle());
-
- btBroadphaseInterface* scene = getBroadphase();
-
-
- btCollisionShape* shapeinterface = ctrl->GetCollisionShape();
-
- assert(shapeinterface);
-
- const btTransform& t = ctrl->GetCollisionObject()->getWorldTransform();
-
-
- btVector3 minAabb,maxAabb;
-
- shapeinterface->getAabb(t,minAabb,maxAabb);
-
- float timeStep = 0.02f;
-
-
- //extent it with the motion
-
- if (body)
- {
- btVector3 linMotion = body->getLinearVelocity()*timeStep;
-
- float maxAabbx = maxAabb.getX();
- float maxAabby = maxAabb.getY();
- float maxAabbz = maxAabb.getZ();
- float minAabbx = minAabb.getX();
- float minAabby = minAabb.getY();
- float minAabbz = minAabb.getZ();
-
- if (linMotion.x() > 0.f)
- maxAabbx += linMotion.x();
- else
- minAabbx += linMotion.x();
- if (linMotion.y() > 0.f)
- maxAabby += linMotion.y();
- else
- minAabby += linMotion.y();
- if (linMotion.z() > 0.f)
- maxAabbz += linMotion.z();
- else
- minAabbz += linMotion.z();
-
-
- minAabb = btVector3(minAabbx,minAabby,minAabbz);
- maxAabb = btVector3(maxAabbx,maxAabby,maxAabbz);
- }
-
-
-
}
@@ -480,6 +426,13 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
btRigidBody* body = ctrl->GetRigidBody();
if (body)
{
+ for (int i=body->getNumConstraintRefs()-1;i>=0;i--)
+ {
+ btTypedConstraint* con = body->getConstraintRef(i);
+ m_dynamicsWorld->removeConstraint(con);
+ body->removeConstraintRef(con);
+ //delete con; //might be kept by python KX_ConstraintWrapper
+ }
m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody());
} else
{
@@ -533,6 +486,12 @@ void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctr
{
btCollisionObject* obj = ctrl->GetCollisionObject();
obj->setUserPointer(ctrl);
+ // update the position of the object from the user
+ if (ctrl->GetMotionState())
+ {
+ btTransform xform = CcdPhysicsController::GetTransformFromMotionState(ctrl->GetMotionState());
+ ctrl->SetCenterOfMassTransform(xform);
+ }
m_dynamicsWorld->addCollisionObject(obj,
ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask());
}
@@ -573,7 +532,7 @@ void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ct
void CcdPhysicsEnvironment::addCcdGraphicController(CcdGraphicController* ctrl)
{
- if (m_cullingTree)
+ if (m_cullingTree && !ctrl->getBroadphaseHandle())
{
btVector3 minAabb;
btVector3 maxAabb;
@@ -617,7 +576,7 @@ void CcdPhysicsEnvironment::debugDrawWorld()
m_dynamicsWorld->debugDrawWorld();
}
-bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
+bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval)
{
std::set<CcdPhysicsController*>::iterator it;
int i;
@@ -627,14 +586,9 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
(*it)->SynchronizeMotionStates(timeStep);
}
- processFhSprings(curTime,timeStep);
-
float subStep = timeStep / float(m_numTimeSubSteps);
- for (i=0;i<m_numTimeSubSteps;i++)
- {
-// m_dynamicsWorld->stepSimulation(subStep,20,1./240.);//perform always a full simulation step
- m_dynamicsWorld->stepSimulation(subStep,0);//perform always a full simulation step
- }
+ i = m_dynamicsWorld->stepSimulation(interval,25,subStep);//perform always a full simulation step
+ processFhSprings(curTime,i*subStep);
for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
{
@@ -686,9 +640,11 @@ public:
};
-void CcdPhysicsEnvironment::processFhSprings(double curTime,float timeStep)
+void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval)
{
std::set<CcdPhysicsController*>::iterator it;
+ // dynamic of Fh spring is based on a timestep of 1/60
+ int numIter = (int)(interval*60.0001f);
for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
{
@@ -700,8 +656,6 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float timeStep)
//printf("has Fh or RotFh\n");
//re-implement SM_FhObject.cpp using btCollisionWorld::rayTest and info from ctrl->getConstructionInfo()
//send a ray from {0.0, 0.0, 0.0} towards {0.0, 0.0, -10.0}, in local coordinates
-
-
CcdPhysicsController* parentCtrl = ctrl->getParentCtrl();
btRigidBody* parentBody = parentCtrl?parentCtrl->GetRigidBody() : 0;
btRigidBody* cl_object = parentBody ? parentBody : body;
@@ -748,82 +702,78 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float timeStep)
btVector3 normal = resultCallback.m_hitNormalWorld;
normal.normalize();
-
- if (ctrl->getConstructionInfo().m_do_fh)
+ for (int i=0; i<numIter; i++)
{
- btVector3 lspot = cl_object->getCenterOfMassPosition()
- + rayDirLocal * resultCallback.m_closestHitFraction;
+ if (ctrl->getConstructionInfo().m_do_fh)
+ {
+ btVector3 lspot = cl_object->getCenterOfMassPosition()
+ + rayDirLocal * resultCallback.m_closestHitFraction;
+
+
+ lspot -= hit_object->getCenterOfMassPosition();
+ btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot);
+ btScalar rel_vel_ray = ray_dir.dot(rel_vel);
+ btScalar spring_extent = 1.0 - distance / hitObjShapeProps.m_fh_distance;
+
+ btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring;
+ btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping;
+
+ cl_object->setLinearVelocity(cl_object->getLinearVelocity() + (-(i_spring + i_damp) * ray_dir));
+ if (hitObjShapeProps.m_fh_normal)
+ {
+ cl_object->setLinearVelocity(cl_object->getLinearVelocity()+(i_spring + i_damp) *(normal - normal.dot(ray_dir) * ray_dir));
+ }
+ btVector3 lateral = rel_vel - rel_vel_ray * ray_dir;
+
+
+ if (ctrl->getConstructionInfo().m_do_anisotropic) {
+ //Bullet basis contains no scaling/shear etc.
+ const btMatrix3x3& lcs = cl_object->getCenterOfMassTransform().getBasis();
+ btVector3 loc_lateral = lateral * lcs;
+ const btVector3& friction_scaling = cl_object->getAnisotropicFriction();
+ loc_lateral *= friction_scaling;
+ lateral = lcs * loc_lateral;
+ }
- lspot -= hit_object->getCenterOfMassPosition();
- btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot);
- btScalar rel_vel_ray = ray_dir.dot(rel_vel);
- btScalar spring_extent = 1.0 - distance / hitObjShapeProps.m_fh_distance;
-
- btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring;
- btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping;
-
- cl_object->setLinearVelocity(cl_object->getLinearVelocity() + (-(i_spring + i_damp) * ray_dir));
- if (hitObjShapeProps.m_fh_normal)
- {
- cl_object->setLinearVelocity(cl_object->getLinearVelocity()+(i_spring + i_damp) *(normal - normal.dot(ray_dir) * ray_dir));
- }
-
- btVector3 lateral = rel_vel - rel_vel_ray * ray_dir;
-
-
- if (ctrl->getConstructionInfo().m_do_anisotropic) {
- //Bullet basis contains no scaling/shear etc.
- const btMatrix3x3& lcs = cl_object->getCenterOfMassTransform().getBasis();
- btVector3 loc_lateral = lateral * lcs;
- const btVector3& friction_scaling = cl_object->getAnisotropicFriction();
- loc_lateral *= friction_scaling;
- lateral = lcs * loc_lateral;
+ btScalar rel_vel_lateral = lateral.length();
+
+ if (rel_vel_lateral > SIMD_EPSILON) {
+ btScalar friction_factor = hit_object->getFriction();//cl_object->getFriction();
+
+ btScalar max_friction = friction_factor * btMax(btScalar(0.0), i_spring);
+
+ btScalar rel_mom_lateral = rel_vel_lateral / cl_object->getInvMass();
+
+ btVector3 friction = (rel_mom_lateral > max_friction) ?
+ -lateral * (max_friction / rel_vel_lateral) :
+ -lateral;
+
+ cl_object->applyCentralImpulse(friction);
+ }
}
- btScalar rel_vel_lateral = lateral.length();
- if (rel_vel_lateral > SIMD_EPSILON) {
- btScalar friction_factor = hit_object->getFriction();//cl_object->getFriction();
+ if (ctrl->getConstructionInfo().m_do_rot_fh) {
+ btVector3 up2 = cl_object->getWorldTransform().getBasis().getColumn(2);
- btScalar max_friction = friction_factor * btMax(btScalar(0.0), i_spring);
+ btVector3 t_spring = up2.cross(normal) * hitObjShapeProps.m_fh_spring;
+ btVector3 ang_vel = cl_object->getAngularVelocity();
- btScalar rel_mom_lateral = rel_vel_lateral / cl_object->getInvMass();
+ // only rotations that tilt relative to the normal are damped
+ ang_vel -= ang_vel.dot(normal) * normal;
- btVector3 friction = (rel_mom_lateral > max_friction) ?
- -lateral * (max_friction / rel_vel_lateral) :
- -lateral;
+ btVector3 t_damp = ang_vel * hitObjShapeProps.m_fh_damping;
- cl_object->applyCentralImpulse(friction);
+ cl_object->setAngularVelocity(cl_object->getAngularVelocity() + (t_spring - t_damp));
}
}
-
-
- if (ctrl->getConstructionInfo().m_do_rot_fh) {
- btVector3 up2 = cl_object->getWorldTransform().getBasis().getColumn(2);
-
- btVector3 t_spring = up2.cross(normal) * hitObjShapeProps.m_fh_spring;
- btVector3 ang_vel = cl_object->getAngularVelocity();
-
- // only rotations that tilt relative to the normal are damped
- ang_vel -= ang_vel.dot(normal) * normal;
-
- btVector3 t_damp = ang_vel * hitObjShapeProps.m_fh_damping;
-
- cl_object->setAngularVelocity(cl_object->getAngularVelocity() + (t_spring - t_damp));
- }
-
}
-
-
}
-
-
}
}
-
}
void CcdPhysicsEnvironment::setDebugMode(int debugMode)
@@ -972,7 +922,7 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint(
bool useReferenceFrameA = true;
- genericConstraint = new btGeneric6DofConstraint(
+ genericConstraint = new btGeneric6DofSpringConstraint(
*rb0,*rb1,
frameInA,frameInB,useReferenceFrameA);
genericConstraint->setLinearLowerLimit(linearMinLimits);
@@ -1053,7 +1003,7 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace)
{
- CcdPhysicsController* curHit = static_cast<CcdPhysicsController*>(rayResult.m_collisionObject->getUserPointer());
+ //CcdPhysicsController* curHit = static_cast<CcdPhysicsController*>(rayResult.m_collisionObject->getUserPointer());
// save shape information as ClosestRayResultCallback::AddSingleResult() does not do it
if (rayResult.m_localShapeInfo)
{
@@ -1071,10 +1021,6 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul
PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
{
-
-
- float minFraction = 1.f;
-
btVector3 rayFrom(fromX,fromY,fromZ);
btVector3 rayTo(toX,toY,toZ);
@@ -1224,7 +1170,7 @@ struct OcclusionBuffer
{
m_initialized=false;
m_occlusion = false;
- m_buffer == NULL;
+ m_buffer = NULL;
m_bufferSize = 0;
}
// multiplication of column major matrices: m=m1*m2
@@ -1332,8 +1278,7 @@ struct OcclusionBuffer
static bool project(btVector4* p,int n)
{
for(int i=0;i<n;++i)
- {
- const btScalar iw=1/p[i][3];
+ {
p[i][2]=1/p[i][3];
p[i][0]*=p[i][2];
p[i][1]*=p[i][2];
@@ -1651,7 +1596,7 @@ struct OcclusionBuffer
6,5,1,2,
7,6,2,3,
5,4,0,1};
- for(int i=0;i<(sizeof(d)/sizeof(d[0]));)
+ for(unsigned int i=0;i<(sizeof(d)/sizeof(d[0]));)
{
const btVector4 p[]={ x[d[i++]],
x[d[i++]],
@@ -1841,6 +1786,45 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment()
}
+float CcdPhysicsEnvironment::getConstraintParam(int constraintId,int param)
+{
+ btTypedConstraint* typedConstraint = getConstraintById(constraintId);
+ switch (typedConstraint->getUserConstraintType())
+ {
+ case PHY_GENERIC_6DOF_CONSTRAINT:
+ {
+
+ switch (param)
+ {
+ case 0: case 1: case 2:
+ {
+ //param = 0..2 are linear constraint values
+ btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
+ genCons->calculateTransforms();
+ return genCons->getRelativePivotPosition(param);
+ break;
+ }
+ case 3: case 4: case 5:
+ {
+ //param = 3..5 are relative constraint (Euler) angles
+ btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
+ genCons->calculateTransforms();
+ return genCons->getAngle(param-3);
+ break;
+ }
+ default:
+ {
+ }
+ }
+ break;
+ };
+ default:
+ {
+ };
+ };
+ return 0.f;
+}
+
void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float value0,float value1)
{
btTypedConstraint* typedConstraint = getConstraintById(constraintId);
@@ -1848,9 +1832,63 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float
{
case PHY_GENERIC_6DOF_CONSTRAINT:
{
- //param = 1..12, min0,max0,min1,max1...min6,max6
- btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
- genCons->setLimit(param,value0,value1);
+
+ switch (param)
+ {
+ case 0: case 1: case 2: case 3: case 4: case 5:
+ {
+ //param = 0..5 are constraint limits, with low/high limit value
+ btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
+ genCons->setLimit(param,value0,value1);
+ break;
+ }
+ case 6: case 7: case 8:
+ {
+ //param = 6,7,8 are translational motors, with value0=target velocity, value1 = max motor force
+ btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
+ int transMotorIndex = param-6;
+ btTranslationalLimitMotor* transMotor = genCons->getTranslationalLimitMotor();
+ transMotor->m_targetVelocity[transMotorIndex]= value0;
+ transMotor->m_maxMotorForce[transMotorIndex]=value1;
+ transMotor->m_enableMotor[transMotorIndex] = (value1>0.f);
+ break;
+ }
+ case 9: case 10: case 11:
+ {
+ //param = 9,10,11 are rotational motors, with value0=target velocity, value1 = max motor force
+ btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
+ int angMotorIndex = param-9;
+ btRotationalLimitMotor* rotMotor = genCons->getRotationalLimitMotor(angMotorIndex);
+ rotMotor->m_enableMotor = (value1 > 0.f);
+ rotMotor->m_targetVelocity = value0;
+ rotMotor->m_maxMotorForce = value1;
+ break;
+ }
+
+ case 12: case 13: case 14: case 15: case 16: case 17:
+ {
+ //param 13-17 are for motorized springs on each of the degrees of freedom
+ btGeneric6DofSpringConstraint* genCons = (btGeneric6DofSpringConstraint*)typedConstraint;
+ int springIndex = param-12;
+ if (value0!=0.f)
+ {
+ bool springEnabled = true;
+ genCons->setStiffness(springIndex,value0);
+ genCons->setDamping(springIndex,value1);
+ genCons->enableSpring(springIndex,springEnabled);
+ genCons->setEquilibriumPoint(springIndex);
+ } else
+ {
+ bool springEnabled = false;
+ genCons->enableSpring(springIndex,springEnabled);
+ }
+ break;
+ }
+
+ default:
+ {
+ }
+ }
break;
};
default:
@@ -1887,29 +1925,20 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
// addCcdPhysicsController(ctrl1);
//}
enableCcdPhysicsController(ctrl1);
-
- //Collision filter/mask is now set at the time of the creation of the controller
- //force collision detection with everything, including static objects (might hurt performance!)
- //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask = btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::SensorTrigger;
- //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterGroup = btBroadphaseProxy::SensorTrigger;
- //todo: make this 'sensor'!
-
- requestCollisionCallback(ctrl);
- //printf("addSensor\n");
}
-void CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl;
- if (ccdCtrl->Unregister())
- m_triggerControllers.erase(ccdCtrl);
+ if (!ccdCtrl->Unregister())
+ return false;
+ m_triggerControllers.erase(ccdCtrl);
+ return true;
}
void CcdPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl)
{
- removeCollisionCallback(ctrl);
-
disableCcdPhysicsController((CcdPhysicsController*)ctrl);
}
@@ -1945,19 +1974,18 @@ void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCal
m_triggerCallbacksUserPtrs[response_class] = user;
}
-void CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
+bool CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ccdCtrl = static_cast<CcdPhysicsController*>(ctrl);
- if (ccdCtrl->Register())
- m_triggerControllers.insert(ccdCtrl);
+ if (!ccdCtrl->Register())
+ return false;
+ m_triggerControllers.insert(ccdCtrl);
+ return true;
}
void CcdPhysicsEnvironment::CallbackTriggers()
{
-
- CcdPhysicsController* ctrl0=0,*ctrl1=0;
-
if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)))
{
//walk over all overlapping pairs, and if one of the involved bodies is registered for trigger callback, perform callback
@@ -2099,12 +2127,13 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi
// declare this object as Dyamic rather then static!!
// The reason as it is designed to detect all type of object, including static object
// It would cause static-static message to be printed on the console otherwise
- cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE/* | btCollisionObject::CF_KINEMATIC_OBJECT*/;
+ cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_STATIC_OBJECT;
DefaultMotionState* motionState = new DefaultMotionState();
cinfo.m_MotionState = motionState;
// we will add later the possibility to select the filter from option
cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter;
+ cinfo.m_bSensor = true;
motionState->m_worldTransform.setIdentity();
motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2]));
@@ -2373,7 +2402,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
frameInB = inv * globalFrameA;
bool useReferenceFrameA = true;
- genericConstraint = new btGeneric6DofConstraint(
+ genericConstraint = new btGeneric6DofSpringConstraint(
*rb0,*rb1,
frameInA,frameInB,useReferenceFrameA);
@@ -2397,7 +2426,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
frameInB = rb0->getCenterOfMassTransform() * frameInA;
bool useReferenceFrameA = true;
- genericConstraint = new btGeneric6DofConstraint(
+ genericConstraint = new btGeneric6DofSpringConstraint(
*rb0,s_fixedObject2,
frameInA,frameInB,useReferenceFrameA);
}
@@ -2558,13 +2587,14 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float conera
cinfo.m_collisionShape = new btConeShape(coneradius,coneheight);
cinfo.m_MotionState = 0;
cinfo.m_physicsEnv = this;
- cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
+ cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_STATIC_OBJECT;
DefaultMotionState* motionState = new DefaultMotionState();
cinfo.m_MotionState = motionState;
// we will add later the possibility to select the filter from option
cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter;
+ cinfo.m_bSensor = true;
motionState->m_worldTransform.setIdentity();
// motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2]));
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index f861621ae37..bc5491e00cc 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -114,7 +114,7 @@ protected:
virtual void beginFrame();
virtual void endFrame() {};
/// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep);
+ virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
virtual void debugDrawWorld();
// virtual bool proceedDeltaTimeOneStep(float timeStep);
@@ -149,7 +149,10 @@ protected:
const btVector3& angularMaxLimits,int flags
);
+
virtual void setConstraintParam(int constraintId,int param,float value,float value1);
+
+ virtual float getConstraintParam(int constraintId,int param);
virtual void removeConstraint(int constraintid);
@@ -179,8 +182,8 @@ protected:
virtual void addSensor(PHY_IPhysicsController* ctrl);
virtual void removeSensor(PHY_IPhysicsController* ctrl);
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl);
//These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position);
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
diff --git a/source/gameengine/Physics/Bullet/Makefile b/source/gameengine/Physics/Bullet/Makefile
index 48e537bb6a3..19b17de275a 100644
--- a/source/gameengine/Physics/Bullet/Makefile
+++ b/source/gameengine/Physics/Bullet/Makefile
@@ -51,4 +51,6 @@ CPPFLAGS += -I../../Expressions
CPPFLAGS += -I../../GameLogic
CPPFLAGS += -I../../SceneGraph
CPPFLAGS += -I../../../../source/blender/makesdna
+CPPFLAGS += -I../../../../source/blender/blenkernel
+CPPFLAGS += -I../../../../source/blender/blenlib
diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript
index ab2c68ddfd5..ed53e8112cd 100644
--- a/source/gameengine/Physics/Bullet/SConscript
+++ b/source/gameengine/Physics/Bullet/SConscript
@@ -14,7 +14,10 @@ incs += ' #source/gameengine/Expressions'
incs += ' #source/gameengine/GameLogic'
incs += ' #source/gameengine/SceneGraph'
incs += ' #source/blender/makesdna'
+incs += ' #source/blender/blenkernel'
+incs += ' #source/blender/blenlib'
incs += ' #intern/SoundSystem'
+incs += ' #intern/guardedalloc'
incs += ' ' + env['BF_BULLET_INC']
incs += ' ' + env['BF_PYTHON_INC']
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
index ba196b5cf55..e41574ff181 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
@@ -57,7 +57,7 @@ void DummyPhysicsEnvironment::endFrame()
-bool DummyPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
+bool DummyPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval)
{
//step physics simulation, typically perform
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
index 4e15e6ec130..8dbd137f9de 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
@@ -48,7 +48,7 @@ public:
virtual void beginFrame();
virtual void endFrame();
// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep);
+ virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
virtual float getFixedTimeStep();
@@ -79,8 +79,8 @@ public:
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
{
}
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl) {}
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl) {}
+ 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;}
@@ -88,6 +88,11 @@ public:
{
}
+ virtual float getConstraintParam(int constraintId,int param)
+ {
+ return 0.f;
+ }
+
};
#endif //_DUMMYPHYSICSENVIRONMENT
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
index 3451e6c3ec8..56caa9236bf 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
@@ -390,6 +390,11 @@ void SumoPhysicsController::PostProcessReplica(class PHY_IMotionState* motionst
m_sumoScene->add(* (m_sumoObj));
}
+PHY_IMotionState* SumoPhysicsController::GetMotionState()
+{
+ return m_MotionState;
+}
+
void SumoPhysicsController::SetSimulatedTime(float)
{
}
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.h b/source/gameengine/Physics/Sumo/SumoPhysicsController.h
index 415bc1e3982..adf29649f18 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.h
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.h
@@ -110,6 +110,7 @@ public:
virtual void WriteDynamicsToMotionState() {};
virtual void WriteMotionStateToDynamics(bool nondynaonly);
+ virtual class PHY_IMotionState* GetMotionState();
/**
* call from Scene Graph Node to 'update'.
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
index 3be5e027345..b4daf0a3f80 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
@@ -81,7 +81,7 @@ float SumoPhysicsEnvironment::getFixedTimeStep()
}
-bool SumoPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
+bool SumoPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval)
{
bool result = false;
@@ -213,7 +213,7 @@ void SumoPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCa
m_sumoScene->addTouchCallback(sumoRespClass,SumoPHYCallbackBridge::StaticSolidToPHYCallback,bridge);
}
-void SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
+bool SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
{
SumoPhysicsController* smctrl = dynamic_cast<SumoPhysicsController*>(ctrl);
MT_assert(smctrl);
@@ -225,12 +225,15 @@ void SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ct
smObject->setPhysicsClientObject(ctrl);
m_sumoScene->requestCollisionCallback(*smObject);
+ return true;
}
+ return false;
}
-void SumoPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
+bool SumoPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
{
// intentionally empty
+ return false;
}
PHY_IPhysicsController* SumoPhysicsEnvironment::CreateSphereController(float radius,const PHY__Vector3& position)
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
index 418a361a065..5ae33eb4b0e 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
@@ -54,7 +54,7 @@ public:
virtual void beginFrame();
virtual void endFrame();
// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep);
+ virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
virtual float getFixedTimeStep();
@@ -83,11 +83,15 @@ public:
virtual void addSensor(PHY_IPhysicsController* ctrl);
virtual void removeSensor(PHY_IPhysicsController* ctrl);
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl);
+ 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)
{
}
diff --git a/source/gameengine/Physics/common/PHY_IGraphicController.h b/source/gameengine/Physics/common/PHY_IGraphicController.h
index 36b8a978e87..470d42cb84a 100644
--- a/source/gameengine/Physics/common/PHY_IGraphicController.h
+++ b/source/gameengine/Physics/common/PHY_IGraphicController.h
@@ -47,6 +47,9 @@ class PHY_IGraphicController : public PHY_IController
SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
*/
virtual bool SetGraphicTransform()=0;
+ virtual void Activate(bool active=true)=0;
+ virtual void setLocalAabb(const PHY__Vector3& aabbMin,const PHY__Vector3& aabbMax)=0;
+ virtual void setLocalAabb(const float* aabbMin,const float* aabbMax)=0;
virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate) {return 0;}
diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h
index 64bb810ee7c..f7bcbd4f2d0 100644
--- a/source/gameengine/Physics/common/PHY_IMotionState.h
+++ b/source/gameengine/Physics/common/PHY_IMotionState.h
@@ -45,10 +45,12 @@ class PHY_IMotionState
virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)=0;
// ori = array 12 floats, [0..3] = first column + 0, [4..7] = second colum, [8..11] = third column
virtual void getWorldOrientation(float* ori)=0;
+ virtual void setWorldOrientation(const float* ori)=0;
virtual void setWorldPosition(float posX,float posY,float posZ)=0;
virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0;
+
virtual void calculateWorldTransformations()=0;
};
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
index 770426b48db..d7b8cb0b54f 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h
@@ -31,7 +31,7 @@
#include "PHY_IController.h"
-
+class PHY_IMotionState;
/**
PHY_IPhysicsController is the abstract simplified Interface to a physical object.
@@ -53,6 +53,7 @@ class PHY_IPhysicsController : public PHY_IController
virtual void WriteMotionStateToDynamics(bool nondynaonly)=0;
virtual void WriteDynamicsToMotionState()=0;
+ virtual class PHY_IMotionState* GetMotionState() = 0;
// controller replication
virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)=0;
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index 9a4500c3214..c76e9d175ce 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -89,7 +89,7 @@ class PHY_IPhysicsEnvironment
virtual void beginFrame() = 0;
virtual void endFrame() = 0;
/// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep)=0;
+ virtual bool proceedDeltaTime(double curTime,float timeStep,float interval)=0;
///draw debug lines (make sure to call this during the render phase, otherwise lines are not drawn properly)
virtual void debugDrawWorld(){}
virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)=0;
@@ -152,13 +152,14 @@ class PHY_IPhysicsEnvironment
virtual void addSensor(PHY_IPhysicsController* ctrl)=0;
virtual void removeSensor(PHY_IPhysicsController* ctrl)=0;
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0;
- virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
- virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+ virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+ virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl)=0;
//These two methods are *solely* used to create controllers for sensor! Don't use for anything else
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) =0;
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0;
virtual void setConstraintParam(int constraintId,int param,float value,float value1) = 0;
+ virtual float getConstraintParam(int constraintId,int param) = 0;
};
#endif //_IPHYSICSENVIRONMENT
diff --git a/source/gameengine/PyDoc/API_intro.py b/source/gameengine/PyDoc/API_intro.py
new file mode 100644
index 00000000000..ad37e34fbac
--- /dev/null
+++ b/source/gameengine/PyDoc/API_intro.py
@@ -0,0 +1,103 @@
+# This is not a real module, it's simply an introductory text.
+
+"""
+The Blender Game Engine Python API Reference
+============================================
+
+ See U{release notes<http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.49/Game_Engine>} for updates, changes and new functionality in the Game Engine Python API.
+
+ Top Module:
+ -----------
+
+ - L{GameLogic}
+ - L{GameKeys}
+ - L{GameTypes}
+ - L{Mathutils}
+ - L{Geometry}
+ - L{BGL}
+
+ Undocumented modules:
+ ---------------------
+ - VideoTexture
+ - CValue
+ - Expression
+ - PhysicsConstraints
+
+
+Introduction:
+=============
+
+ This reference documents the Blender Python API, a growing collection of
+ Python modules (libraries) that give access to part of the program's internal
+ data and functions.
+
+ Through scripting Blender can be extended in real-time via
+ U{Python <www.python.org>}, an impressive high level, multi-paradigm, open
+ source language. Newcomers are recommended to start with the tutorial that
+ comes with it.
+
+ This opens many interesting possibilities not available with logic bricks.
+
+ Game Engine API Stability:
+ --------------------------
+
+ When writing python scripts there are a number of situations you should avoid to prevent crashes or unstable behavior.
+ While the API tries to prevent problems there are some situations where error checking would be too time consuming.
+
+ Known cases:
+ - Memory Limits.
+
+ There is nothing stopping you from filling a list or making a string so big that that causes blender to run out of memory, in this case python should rasie a MemoryError, but its likely blender will crash before this point.
+
+ - Accessing any data that has been freed.
+
+ For instance accessing a KX_GameObject after its End Object actuator runs.
+ This will cause a SystemError, however for L{KX_MeshProxy}, L{KX_VertexProxy} and L{KX_VertexProxy} it will crash the blender game engine.
+
+ See: L{GameTypes.PyObjectPlus.invalid} which many types inherit.
+
+ - Mixing L{KX_GameObject} between scenes.
+
+ For instance tracking/parenting an L{KX_GameObject} object to an object from other scene.
+
+ External Modules:
+ -----------------
+
+ Since 2.49 support for importing modules has been added.
+
+ This allows you to import any blender textblock with a .py extension.
+
+ External python scripts may be imported as modules when the script is in the same directory as the blend file.
+
+ The current blend files path is included in the sys.path for loading modules.
+ All linked libraries will also be included so you can be sure when linking in assets from another blend file the scripts will load too.
+
+ A note to newbie script writers:
+ --------------------------------
+
+ Interpreted languages are known to be much slower than compiled code, but for
+ many applications the difference is negligible or acceptable. Also, with
+ profiling (or even simple direct timing with L{Blender.sys.time<Sys.time>}) to
+ identify slow areas and well thought optimizations, the speed can be
+ I{considerably} improved in many cases. Try some of the best BPython scripts
+ to get an idea of what can be done, you may be surprised.
+
+@author: The Blender Python Team
+@requires: Blender 2.49 or newer.
+@version: 2.49
+@see: U{www.blender.org<http://www.blender.org>}: documentation and forum
+@see: U{blenderartists.org<http://blenderartists.org>}: user forum
+@see: U{projects.blender.org<http://projects.blender.org>}
+@see: U{www.python.org<http://www.python.org>}
+@see: U{www.python.org/doc<http://www.python.org/doc>}
+@see: U{Blending into Python<en.wikibooks.org/wiki/Blender_3D:_Blending_Into_Python>}: User contributed documentation, featuring a blender/python cookbook with many examples.
+
+@note: the official version of this reference guide is only updated for each
+ new Blender release. But you can build the current SVN
+ version yourself: install epydoc, grab all files in the
+ source/gameengine/PyDoc/ folder of Blender's SVN and use the
+ epy_docgen.sh script also found there to generate the html docs.
+ Naturally you will also need a recent Blender binary to try the new
+ features. If you prefer not to compile it yourself, there is a testing
+ builds forum at U{blender.org<http://www.blender.org>}.
+"""
diff --git a/source/gameengine/PyDoc/BL_ActionActuator.py b/source/gameengine/PyDoc/BL_ActionActuator.py
deleted file mode 100644
index 480681dc14a..00000000000
--- a/source/gameengine/PyDoc/BL_ActionActuator.py
+++ /dev/null
@@ -1,230 +0,0 @@
-# $Id$
-# Documentation for BL_ActionActuator
-import SCA_ILogicBrick
-from SCA_IActuator import *
-
-
-class BL_ActionActuator(SCA_IActuator):
- """
- Action Actuators apply an action to an actor.
-
- @ivar action: The name of the action to set as the current action.
- @type action: string
- @ivar start: Specifies the starting frame of the animation.
- @type start: float
- @ivar end: Specifies the ending frame of the animation.
- @type end: float
- @ivar blendin: Specifies the number of frames of animation to generate when making transitions between actions.
- @type blendin: float
- @ivar priority: Sets the priority of this actuator. Actuators will lower
- priority numbers will override actuators with higher
- numbers.
- @type priority: integer
- @ivar frame: Sets the current frame for the animation.
- @type frame: float
- @ivar property: Sets the property to be used in FromProp playback mode.
- @type property: string
- @ivar blendTime: Sets the internal frame timer. This property must be in
- the range from 0.0 to blendin.
- @type blendTime: float
- @ivar type: The operation mode of the actuator. KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
- @type type: integer
- @ivar continue: The actions continue option, True or False.
- When True, the action will always play from where last left off,
- otherwise negative events to this actuator will reset it to its start frame.
- @type: boolean
- @ivar frameProperty: The name of the property that is set to the current frame number.
- @type frameProperty: string
- """
- def setChannel(channel, matrix, mode = False):
- """
- @param channel: A string specifying the name of the bone channel.
- @type channel: string
- @param matrix: A 4x4 matrix specifying the overriding transformation
- as an offset from the bone's rest position.
- @type matrix: list [[float]]
- @param mode: True for armature/world space, False for bone space
- @type mode: boolean
- """
-
- #--The following methods are deprecated--
- def setAction(action, reset = True):
- """
- DEPRECATED: use the 'action' property
- Sets the current action.
-
- @param action: The name of the action to set as the current action.
- @type action: string
- @param reset: Optional parameter indicating whether to reset the
- blend timer or not. A value of 1 indicates that the
- timer should be reset. A value of 0 will leave it
- unchanged. If reset is not specified, the timer will
- be reset.
- """
-
- def setStart(start):
- """
- DEPRECATED: use the 'start' property
- Specifies the starting frame of the animation.
-
- @param start: the starting frame of the animation
- @type start: float
- """
-
- def setEnd(end):
- """
- DEPRECATED: use the 'end' property
- Specifies the ending frame of the animation.
-
- @param end: the ending frame of the animation
- @type end: float
- """
- def setBlendin(blendin):
- """
- DEPRECATED: use the 'blendin' property
- Specifies the number of frames of animation to generate
- when making transitions between actions.
-
- @param blendin: the number of frames in transition.
- @type blendin: float
- """
-
- def setPriority(priority):
- """
- DEPRECATED: use the 'priority' property
- Sets the priority of this actuator.
-
- @param priority: Specifies the new priority. Actuators will lower
- priority numbers will override actuators with higher
- numbers.
- @type priority: integer
- """
- def setFrame(frame):
- """
- DEPRECATED: use the 'frame' property
- Sets the current frame for the animation.
-
- @param frame: Specifies the new current frame for the animation
- @type frame: float
- """
-
- def setProperty(prop):
- """
- DEPRECATED: use the 'property' property
- Sets the property to be used in FromProp playback mode.
-
- @param prop: the name of the property to use.
- @type prop: string.
- """
-
- def setBlendtime(blendtime):
- """
- DEPRECATED: use the 'blendTime' property
- Sets the internal frame timer.
-
- Allows the script to directly modify the internal timer
- used when generating transitions between actions.
-
- @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0.
- @type blendtime: float
- """
-
- def setType(mode):
- """
- DEPRECATED: use the 'type' property
- Sets the operation mode of the actuator
-
- @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
- @type mode: integer
- """
-
- def setContinue(cont):
- """
- DEPRECATED: use the 'continue' property
- Set the actions continue option True or False. see getContinue.
-
- @param cont: The continue option.
- @type cont: bool
- """
-
- def getType():
- """
- DEPRECATED: use the 'type' property
- Returns the operation mode of the actuator
-
- @rtype: integer
- @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
- """
-
- def getContinue():
- """
- DEPRECATED: use the 'continue' property
- When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
-
- @rtype: bool
- """
-
- def getAction():
- """
- DEPRECATED: use the 'action' property
- getAction() returns the name of the action associated with this actuator.
-
- @rtype: string
- """
-
- def getStart():
- """
- DEPRECATED: use the 'start' property
- Returns the starting frame of the action.
-
- @rtype: float
- """
- def getEnd():
- """
- DEPRECATED: use the 'end' property
- Returns the last frame of the action.
-
- @rtype: float
- """
- def getBlendin():
- """
- DEPRECATED: use the 'blendin' property
- Returns the number of interpolation animation frames to be generated when this actuator is triggered.
-
- @rtype: float
- """
- def getPriority():
- """
- DEPRECATED: use the 'priority' property
- Returns the priority for this actuator. Actuators with lower Priority numbers will
- override actuators with higher numbers.
-
- @rtype: integer
- """
- def getFrame():
- """
- DEPRECATED: use the 'frame' property
- Returns the current frame number.
-
- @rtype: float
- """
- def getProperty():
- """
- DEPRECATED: use the 'property' property
- Returns the name of the property to be used in FromProp mode.
-
- @rtype: string
- """
- def setFrameProperty(prop):
- """
- DEPRECATED: use the 'frameProperty' property
- @param prop: A string specifying the property of the object that will be updated with the action frame number.
- @type prop: string
- """
- def getFrameProperty():
- """
- DEPRECATED: use the 'frameProperty' property
- Returns the name of the property that is set to the current frame number.
-
- @rtype: string
- """
diff --git a/source/gameengine/PyDoc/BL_Shader.py b/source/gameengine/PyDoc/BL_Shader.py
deleted file mode 100644
index 182b73d437b..00000000000
--- a/source/gameengine/PyDoc/BL_Shader.py
+++ /dev/null
@@ -1,228 +0,0 @@
-class BL_Shader: # (PyObjectPlus)
- """
- BL_Shader GLSL shaders.
-
- All placeholders have a __ prefix
- """
-
- def __setUniformfv(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
-
- def __delSource(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getFragmentProg(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getVertexProg(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __isValid(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setAttrib(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setNumberOfPasses(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setSampler(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setSource(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniform1f(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniform1i(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniform2f(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniform2i(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniform3f(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniform3i(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniform4f(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniform4i(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniformDef(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniformMatrix3(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniformMatrix4(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setUniformiv(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __validate(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
diff --git a/source/gameengine/PyDoc/BL_ShapeActionActuator.py b/source/gameengine/PyDoc/BL_ShapeActionActuator.py
deleted file mode 100644
index e1e8b039749..00000000000
--- a/source/gameengine/PyDoc/BL_ShapeActionActuator.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# $Id$
-# Documentation for BL_ShapeActionActuator
-from SCA_IActuator import *
-from SCA_ILogicBrick import *
-
-class BL_ShapeActionActuator(SCA_IActuator):
- """
- ShapeAction Actuators apply an shape action to an mesh object.\
-
- @ivar action: The name of the action to set as the current shape action.
- @type action: string
- @ivar start: Specifies the starting frame of the shape animation.
- @type start: float
- @ivar end: Specifies the ending frame of the shape animation.
- @type end: float
- @ivar blendin: Specifies the number of frames of animation to generate when making transitions between actions.
- @type blendin: float
- @ivar priority: Sets the priority of this actuator. Actuators will lower
- priority numbers will override actuators with higher
- numbers.
- @type priority: integer
- @ivar frame: Sets the current frame for the animation.
- @type frame: float
- @ivar property: Sets the property to be used in FromProp playback mode.
- @type property: string
- @ivar blendTime: Sets the internal frame timer. This property must be in
- the range from 0.0 to blendin.
- @type blendTime: float
- @ivar type: The operation mode of the actuator.
- KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER,
- KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
- @type type: integer
- @ivar frameProperty: The name of the property that is set to the current frame number.
- @type frameProperty: string
-
- """
- def setAction(action, reset = True):
- """
- DEPRECATED: use the 'action' property
- Sets the current action.
-
- @param action: The name of the action to set as the current action.
- @type action: string
- @param reset: Optional parameter indicating whether to reset the
- blend timer or not. A value of 1 indicates that the
- timer should be reset. A value of 0 will leave it
- unchanged. If reset is not specified, the timer will
- be reset.
- """
-
- def setStart(start):
- """
- DEPRECATED: use the 'start' property
- Specifies the starting frame of the animation.
-
- @param start: the starting frame of the animation
- @type start: float
- """
-
- def setEnd(end):
- """
- DEPRECATED: use the 'end' property
- Specifies the ending frame of the animation.
-
- @param end: the ending frame of the animation
- @type end: float
- """
- def setBlendin(blendin):
- """
- DEPRECATED: use the 'blendin' property
- Specifies the number of frames of animation to generate
- when making transitions between actions.
-
- @param blendin: the number of frames in transition.
- @type blendin: float
- """
-
- def setPriority(priority):
- """
- DEPRECATED: use the 'priority' property
- Sets the priority of this actuator.
-
- @param priority: Specifies the new priority. Actuators will lower
- priority numbers will override actuators with higher
- numbers.
- @type priority: integer
- """
- def setFrame(frame):
- """
- DEPRECATED: use the 'frame' property
- Sets the current frame for the animation.
-
- @param frame: Specifies the new current frame for the animation
- @type frame: float
- """
-
- def setProperty(prop):
- """
- DEPRECATED: use the 'property' property
- Sets the property to be used in FromProp playback mode.
-
- @param prop: the name of the property to use.
- @type prop: string.
- """
-
- def setBlendtime(blendtime):
- """
- DEPRECATED: use the 'blendTime' property
- Sets the internal frame timer.
-
- Allows the script to directly modify the internal timer
- used when generating transitions between actions.
-
- @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0.
- @type blendtime: float
- """
-
- def setType(mode):
- """
- DEPRECATED: use the 'type' property
- Sets the operation mode of the actuator
-
- @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
- @type mode: integer
- """
-
- def getType():
- """
- DEPRECATED: use the 'type' property
- Returns the operation mode of the actuator
-
- @rtype: integer
- @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
- """
-
- def getAction():
- """
- DEPRECATED: use the 'action' property
- getAction() returns the name of the action associated with this actuator.
-
- @rtype: string
- """
-
- def getStart():
- """
- DEPRECATED: use the 'start' property
- Returns the starting frame of the action.
-
- @rtype: float
- """
- def getEnd():
- """
- DEPRECATED: use the 'end' property
- Returns the last frame of the action.
-
- @rtype: float
- """
- def getBlendin():
- """
- DEPRECATED: use the 'blendin' property
- Returns the number of interpolation animation frames to be generated when this actuator is triggered.
-
- @rtype: float
- """
- def getPriority():
- """
- DEPRECATED: use the 'priority' property
- Returns the priority for this actuator. Actuators with lower Priority numbers will
- override actuators with higher numbers.
-
- @rtype: integer
- """
- def getFrame():
- """
- DEPRECATED: use the 'frame' property
- Returns the current frame number.
-
- @rtype: float
- """
- def getProperty():
- """
- DEPRECATED: use the 'property' property
- Returns the name of the property to be used in FromProp mode.
-
- @rtype: string
- """
- def setFrameProperty(prop):
- """
- DEPRECATED: use the 'frameProperty' property
- @param prop: A string specifying the property of the object that will be updated with the action frame number.
- @type prop: string
- """
- def getFrameProperty():
- """
- DEPRECATED: use the 'frameProperty' property
- Returns the name of the property that is set to the current frame number.
-
- @rtype: string
- """
diff --git a/source/gameengine/PyDoc/CListValue.py b/source/gameengine/PyDoc/CListValue.py
deleted file mode 100644
index e9fc4215bb6..00000000000
--- a/source/gameengine/PyDoc/CListValue.py
+++ /dev/null
@@ -1,59 +0,0 @@
-class CListValue: # (PyObjectPlus)
- """
- CListValue
-
- This is a list like object used in the game engine internally that behaves similar to a python list in most ways.
-
- As well as the normal index lookup.
- C{val= clist[i]}
-
- CListValue supports string lookups.
- C{val= scene.objects["OBCube"]}
-
- Other operations such as C{len(clist), list(clist), clist[0:10]} are also supported.
- """
- def append(val):
- """
- Add an item to the list (like pythons append)
-
- Warning: Appending values to the list can cause crashes when the list is used internally by the game engine.
- """
-
- def count(val):
- """
- Count the number of instances of a value in the list.
-
- @rtype: integer
- @return: number of instances
- """
- def index(val):
- """
- Return the index of a value in the list.
-
- @rtype: integer
- @return: The index of the value in the list.
- """
- def reverse():
- """
- Reverse the order of the list.
- """
- def from_id(id):
- """
- This is a funtion especially for the game engine to return a value with a spesific id.
-
- Since object names are not always unique, the id of an object can be used to get an object from the CValueList.
-
- Example.
-
- C{myObID = id(gameObject)}
-
- C{...}
-
- C{ob= scene.objects.from_id(myObID)}
-
- Where myObID is an int or long from the id function.
-
- This has the advantage that you can store the id in places you could not store a gameObject.
-
- Warning: the id is derived from a memory location and will be different each time the game engine starts.
- """ \ No newline at end of file
diff --git a/source/gameengine/PyDoc/GameKeys.py b/source/gameengine/PyDoc/GameKeys.py
index 310f2b0d506..e798f6c901b 100644
--- a/source/gameengine/PyDoc/GameKeys.py
+++ b/source/gameengine/PyDoc/GameKeys.py
@@ -5,126 +5,6 @@ Documentation for the GameKeys module.
This module holds key constants for the SCA_KeyboardSensor.
-Alphabet keys
--------------
- - AKEY
- - BKEY
- - CKEY
- - DKEY
- - EKEY
- - FKEY
- - GKEY
- - HKEY
- - IKEY
- - JKEY
- - KKEY
- - LKEY
- - MKEY
- - NKEY
- - OKEY
- - PKEY
- - QKEY
- - RKEY
- - SKEY
- - TKEY
- - UKEY
- - VKEY
- - WKEY
- - XKEY
- - YKEY
- - ZKEY
-
-Number keys
------------
- - ZEROKEY
- - ONEKEY
- - TWOKEY
- - THREEKEY
- - FOURKEY
- - FIVEKEY
- - SIXKEY
- - SEVENKEY
- - EIGHTKEY
- - NINEKEY
-
-Shift Modifiers
----------------
- - CAPSLOCKKEY
-
- - LEFTCTRLKEY
- - LEFTALTKEY
- - RIGHTALTKEY
- - RIGHTCTRLKEY
- - RIGHTSHIFTKEY
- - LEFTSHIFTKEY
-
-Arrow Keys
-----------
- - LEFTARROWKEY
- - DOWNARROWKEY
- - RIGHTARROWKEY
- - UPARROWKEY
-
-Numberpad Keys
---------------
- - PAD0
- - PAD1
- - PAD2
- - PAD3
- - PAD4
- - PAD5
- - PAD6
- - PAD7
- - PAD8
- - PAD9
- - PADPERIOD
- - PADSLASHKEY
- - PADASTERKEY
- - PADMINUS
- - PADENTER
- - PADPLUSKEY
-
-Function Keys
--------------
- - F1KEY
- - F2KEY
- - F3KEY
- - F4KEY
- - F5KEY
- - F6KEY
- - F7KEY
- - F8KEY
- - F9KEY
- - F10KEY
- - F11KEY
- - F12KEY
-
-Other Keys
-----------
- - ACCENTGRAVEKEY
- - BACKSLASHKEY
- - BACKSPACEKEY
- - COMMAKEY
- - DELKEY
- - ENDKEY
- - EQUALKEY
- - ESCKEY
- - HOMEKEY
- - INSERTKEY
- - LEFTBRACKETKEY
- - LINEFEEDKEY
- - MINUSKEY
- - PAGEDOWNKEY
- - PAGEUPKEY
- - PAUSEKEY
- - PERIODKEY
- - QUOTEKEY
- - RIGHTBRACKETKEY
- - RETKEY
- - SEMICOLONKEY
- - SLASHKEY
- - SPACEKEY
- - TABKEY
Example::
# Set a connected keyboard sensor to accept F1
@@ -156,7 +36,120 @@ Example::
# Activate Left!
if key[0] == GameKeys.DKEY:
# Activate Right!
-
+
+@group Alphabet keys: AKEY, BKEY, CKEY, DKEY, EKEY, FKEY, GKEY, HKEY, IKEY, JKEY, KKEY, LKEY, MKEY, NKEY, OKEY, PKEY, QKEY, RKEY, SKEY, TKEY, UKEY, VKEY, WKEY, XKEY, YKEY, ZKEY
+@var AKEY:
+@var BKEY:
+@var CKEY:
+@var DKEY:
+@var EKEY:
+@var FKEY:
+@var GKEY:
+@var HKEY:
+@var IKEY:
+@var JKEY:
+@var KKEY:
+@var LKEY:
+@var MKEY:
+@var NKEY:
+@var OKEY:
+@var PKEY:
+@var QKEY:
+@var RKEY:
+@var SKEY:
+@var TKEY:
+@var UKEY:
+@var VKEY:
+@var WKEY:
+@var XKEY:
+@var YKEY:
+@var ZKEY:
+
+@group Number keys: ZEROKEY, ONEKEY, TWOKEY, THREEKEY, FOURKEY, FIVEKEY, SIXKEY, SEVENKEY, EIGHTKEY, NINEKEY
+@var ZEROKEY:
+@var ONEKEY:
+@var TWOKEY:
+@var THREEKEY:
+@var FOURKEY:
+@var FIVEKEY:
+@var SIXKEY:
+@var SEVENKEY:
+@var EIGHTKEY:
+@var NINEKEY:
+
+@group Modifiers: CAPSLOCKKEY, LEFTCTRLKEY, LEFTALTKEY, RIGHTALTKEY, RIGHTCTRLKEY, RIGHTSHIFTKEY, LEFTSHIFTKEY
+@var CAPSLOCKKEY:
+@var LEFTCTRLKEY:
+@var LEFTALTKEY:
+@var RIGHTALTKEY:
+@var RIGHTCTRLKEY:
+@var RIGHTSHIFTKEY:
+@var LEFTSHIFTKEY:
+
+@group Arrow Keys: LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY
+@var LEFTARROWKEY:
+@var DOWNARROWKEY:
+@var RIGHTARROWKEY:
+@var UPARROWKEY:
+
+@group Numberpad Keys: PAD0, PAD1, PAD2, PAD3, PAD4, PAD5, PAD6, PAD7, PAD8, PAD9, PADPERIOD, PADSLASHKEY, PADASTERKEY, PADMINUS, PADENTER, PADPLUSKEY
+@var PAD0:
+@var PAD1:
+@var PAD2:
+@var PAD3:
+@var PAD4:
+@var PAD5:
+@var PAD6:
+@var PAD7:
+@var PAD8:
+@var PAD9:
+@var PADPERIOD:
+@var PADSLASHKEY:
+@var PADASTERKEY:
+@var PADMINUS:
+@var PADENTER:
+@var PADPLUSKEY:
+
+@group Function Keys: F1KEY, F2KEY, F3KEY, F4KEY, F5KEY, F6KEY, F7KEY, F8KEY, F9KEY, F10KEY, F11KEY, F12KEY
+@var F1KEY:
+@var F2KEY:
+@var F3KEY:
+@var F4KEY:
+@var F5KEY:
+@var F6KEY:
+@var F7KEY:
+@var F8KEY:
+@var F9KEY:
+@var F10KEY:
+@var F11KEY:
+@var F12KEY:
+
+@group Other Keys: ACCENTGRAVEKEY, BACKSLASHKEY, BACKSPACEKEY, COMMAKEY, DELKEY, ENDKEY, EQUALKEY, ESCKEY, HOMEKEY, INSERTKEY, LEFTBRACKETKEY, LINEFEEDKEY, MINUSKEY, PAGEDOWNKEY, PAGEUPKEY, PAUSEKEY, PERIODKEY, QUOTEKEY, RIGHTBRACKETKEY, RETKEY, SEMICOLONKEY, SLASHKEY, SPACEKEY, TABKEY
+@var ACCENTGRAVEKEY:
+@var BACKSLASHKEY:
+@var BACKSPACEKEY:
+@var COMMAKEY:
+@var DELKEY:
+@var ENDKEY:
+@var EQUALKEY:
+@var ESCKEY:
+@var HOMEKEY:
+@var INSERTKEY:
+@var LEFTBRACKETKEY:
+@var LINEFEEDKEY:
+@var MINUSKEY:
+@var PAGEDOWNKEY:
+@var PAGEUPKEY:
+@var PAUSEKEY:
+@var PERIODKEY:
+@var QUOTEKEY:
+@var RIGHTBRACKETKEY:
+@var RETKEY:
+@var SEMICOLONKEY:
+@var SLASHKEY:
+@var SPACEKEY:
+@var TABKEY:
+
"""
def EventToString(event):
@@ -174,8 +167,8 @@ def EventToCharacter(event, shift):
@type event: int
@param event: key event from GameKeys or the keyboard sensor.
- @type event: bool
- @param event: set to true if shift is held.
+ @type shift: bool
+ @param shift: set to true if shift is held.
@rtype: string
"""
diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py
index 1996aa3f8a9..3ec30a63c58 100644
--- a/source/gameengine/PyDoc/GameLogic.py
+++ b/source/gameengine/PyDoc/GameLogic.py
@@ -2,29 +2,15 @@
"""
Documentation for the GameLogic Module.
=======================================
-
- Modules available in the game engine:
- - GameLogic
- - L{GameKeys}
- - L{Rasterizer}
- - L{GameTypes}
-
- Undocumented modules:
- - VideoTexture
- - CValue
- - Expression
- - PhysicsConstraints
-
- All the other modules are accessible through the methods in GameLogic.
- See L{WhatsNew} for updates, changes and new functionality in the Game Engine Python API.
+ Module to access logic functions, imported automatically into the python controllers namespace.
Examples::
# To get the controller thats running this python script:
- co = GameLogic.getCurrentController() # GameLogic is automatically imported
+ cont = GameLogic.getCurrentController() # GameLogic is automatically imported
# To get the game object this controller is on:
- obj = co.getOwner()
+ obj = cont.owner
L{KX_GameObject} and L{KX_Camera} or L{KX_LightObject} methods are
available depending on the type of object::
# To get a sensor linked to this controller.
@@ -32,55 +18,59 @@ Documentation for the GameLogic Module.
# +---------------------+ +--------+
# | Sensor "sensorname" +--+ Python +
# +---------------------+ +--------+
- sens = co.getSensor("sensorname")
+ sens = cont.sensors["sensorname"]
- # To get a list of all sensors:
- sensors = co.getSensors()
+ # To get a sequence of all sensors:
+ sensors = co.sensors
See the sensor's reference for available methods:
- - L{DelaySensor<SCA_DelaySensor.SCA_DelaySensor>}
- - L{JoystickSensor<SCA_JoystickSensor.SCA_JoystickSensor>}
- - L{KeyboardSensor<SCA_KeyboardSensor.SCA_KeyboardSensor>}
- - L{MouseFocusSensor<KX_MouseFocusSensor.KX_MouseFocusSensor>}
- - L{MouseSensor<SCA_MouseSensor.SCA_MouseSensor>}
- - L{NearSensor<KX_NearSensor.KX_NearSensor>}
- - L{NetworkMessageSensor<KX_NetworkMessageSensor.KX_NetworkMessageSensor>}
- - L{PropertySensor<SCA_PropertySensor.SCA_PropertySensor>}
- - L{RadarSensor<KX_RadarSensor.KX_RadarSensor>}
- - L{RandomSensor<SCA_RandomSensor.SCA_RandomSensor>}
- - L{RaySensor<KX_RaySensor.KX_RaySensor>}
- - L{TouchSensor<KX_TouchSensor.KX_TouchSensor>}
+ - L{DelaySensor<GameTypes.SCA_DelaySensor>}
+ - L{JoystickSensor<GameTypes.SCA_JoystickSensor>}
+ - L{KeyboardSensor<GameTypes.SCA_KeyboardSensor>}
+ - L{MouseFocusSensor<GameTypes.KX_MouseFocusSensor>}
+ - L{MouseSensor<GameTypes.SCA_MouseSensor>}
+ - L{NearSensor<GameTypes.KX_NearSensor>}
+ - L{NetworkMessageSensor<GameTypes.KX_NetworkMessageSensor>}
+ - L{PropertySensor<GameTypes.SCA_PropertySensor>}
+ - L{RadarSensor<GameTypes.KX_RadarSensor>}
+ - L{RandomSensor<GameTypes.SCA_RandomSensor>}
+ - L{RaySensor<GameTypes.KX_RaySensor>}
+ - L{TouchSensor<GameTypes.KX_TouchSensor>}
You can also access actuators linked to the controller::
# To get an actuator attached to the controller:
# +--------+ +-------------------------+
# + Python +--+ Actuator "actuatorname" |
# +--------+ +-------------------------+
- actuator = co.getActuator("actuatorname")
+ actuator = co.actuators["actuatorname"]
# Activate an actuator
- GameLogic.addActiveActuator(actuator, True)
+ controller.activate(actuator)
See the actuator's reference for available methods:
- - L{ActionActuator<BL_ActionActuator.BL_ActionActuator>}
- - L{AddObjectActuator<KX_SCA_AddObjectActuator.KX_SCA_AddObjectActuator>}
- - L{CameraActuator<KX_CameraActuator.KX_CameraActuator>}
- - L{CDActuator<KX_CDActuator.KX_CDActuator>}
- - L{ConstraintActuator<KX_ConstraintActuator.KX_ConstraintActuator>}
- - L{EndObjectActuator<KX_SCA_EndObjectActuator.KX_SCA_EndObjectActuator>}
- - L{GameActuator<KX_GameActuator.KX_GameActuator>}
- - L{IpoActuator<KX_IpoActuator.KX_IpoActuator>}
- - L{NetworkMessageActuator<KX_NetworkMessageActuator.KX_NetworkMessageActuator>}
- - L{ObjectActuator<KX_ObjectActuator.KX_ObjectActuator>}
- - L{PropertyActuator<SCA_PropertyActuator.SCA_PropertyActuator>}
- - L{RandomActuator<SCA_RandomActuator.SCA_RandomActuator>}
- - L{ReplaceMeshActuator<KX_SCA_ReplaceMeshActuator.KX_SCA_ReplaceMeshActuator>}
- - L{SceneActuator<KX_SceneActuator.KX_SceneActuator>}
- - L{SoundActuator<KX_SoundActuator.KX_SoundActuator>}
- - L{TrackToActuator<KX_TrackToActuator.KX_TrackToActuator>}
- - L{VisibilityActuator<KX_VisibilityActuator.KX_VisibilityActuator>}
- - L{DynamicActuator<KX_SCA_DynamicActuator.KX_SCA_DynamicActuator>}
-
+ - L{2DFilterActuator<GameTypes.SCA_2DFilterActuator>}
+ - L{ActionActuator<GameTypes.BL_ActionActuator>}
+ - L{AddObjectActuator<GameTypes.KX_SCA_AddObjectActuator>}
+ - L{CameraActuator<GameTypes.KX_CameraActuator>}
+ - L{CDActuator<GameTypes.KX_CDActuator>}
+ - L{ConstraintActuator<GameTypes.KX_ConstraintActuator>}
+ - L{DynamicActuator<GameTypes.KX_SCA_DynamicActuator>}
+ - L{EndObjectActuator<GameTypes.KX_SCA_EndObjectActuator>}
+ - L{GameActuator<GameTypes.KX_GameActuator>}
+ - L{IpoActuator<GameTypes.KX_IpoActuator>}
+ - L{NetworkMessageActuator<GameTypes.KX_NetworkMessageActuator>}
+ - L{ObjectActuator<GameTypes.KX_ObjectActuator>}
+ - L{ParentActuator<GameTypes.KX_ParentActuator>}
+ - L{PropertyActuator<GameTypes.SCA_PropertyActuator>}
+ - L{RandomActuator<GameTypes.SCA_RandomActuator>}
+ - L{ReplaceMeshActuator<GameTypes.KX_SCA_ReplaceMeshActuator>}
+ - L{SceneActuator<GameTypes.KX_SceneActuator>}
+ - L{ShapeActionActuator<GameTypes.BL_ShapeActionActuator>}
+ - L{SoundActuator<GameTypes.KX_SoundActuator>}
+ - L{StateActuator<GameTypes.KX_StateActuator>}
+ - L{TrackToActuator<GameTypes.KX_TrackToActuator>}
+ - L{VisibilityActuator<GameTypes.KX_VisibilityActuator>}
+
Most logic brick's methods are accessors for the properties available in the logic buttons.
Consult the logic bricks documentation for more information on how each logic brick works.
@@ -92,7 +82,7 @@ Documentation for the GameLogic Module.
cam = scene.active_camera
Matricies as used by the game engine are B{row major}::
- matrix[row][col] = blah
+ matrix[row][col] = float
L{KX_Camera} has some examples using matricies.
@@ -100,29 +90,37 @@ Documentation for the GameLogic Module.
@var KX_TRUE: True value used by some modules.
@var KX_FALSE: False value used by some modules.
-@group Property Sensor: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL, KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED, KX_PROPSENSOR_EXPRESSION
+@group Property Sensor: KX_PROPSENSOR_*
@var KX_PROPSENSOR_EQUAL: Activate when the property is equal to the sensor value.
@var KX_PROPSENSOR_NOTEQUAL: Activate when the property is not equal to the sensor value.
@var KX_PROPSENSOR_INTERVAL: Activate when the property is between the specified limits.
@var KX_PROPSENSOR_CHANGED: Activate when the property changes
@var KX_PROPSENSOR_EXPRESSION: Activate when the expression matches
-@group Constraint Actuator: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ, KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ
+@group Constraint Actuator: KX_CONSTRAINTACT_*
@var KX_CONSTRAINTACT_LOCX: See L{KX_ConstraintActuator}
@var KX_CONSTRAINTACT_LOCY: See L{KX_ConstraintActuator}
@var KX_CONSTRAINTACT_LOCZ: See L{KX_ConstraintActuator}
@var KX_CONSTRAINTACT_ROTX: See L{KX_ConstraintActuator}
@var KX_CONSTRAINTACT_ROTY: See L{KX_ConstraintActuator}
@var KX_CONSTRAINTACT_ROTZ: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_DIRNX: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_DIRNY: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_DIRPX: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_DIRPY: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_ORIX: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_ORIY: See L{KX_ConstraintActuator}
+@var KX_CONSTRAINTACT_ORIZ: See L{KX_ConstraintActuator}
-@group IPO Actuator: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
+@group IPO Actuator: KX_IPOACT_*
@var KX_IPOACT_PLAY: See L{KX_IpoActuator}
@var KX_IPOACT_PINGPONG: See L{KX_IpoActuator}
@var KX_IPOACT_FLIPPER: See L{KX_IpoActuator}
@var KX_IPOACT_LOOPSTOP: See L{KX_IpoActuator}
@var KX_IPOACT_LOOPEND: See L{KX_IpoActuator}
+@var KX_IPOACT_FROM_PROP: See L{KX_IpoActuator}
-@group Random Distributions: KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI, KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON, KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL, KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
+@group Random Distributions: KX_RANDOMACT_*
@var KX_RANDOMACT_BOOL_CONST: See L{SCA_RandomActuator}
@var KX_RANDOMACT_BOOL_UNIFORM: See L{SCA_RandomActuator}
@var KX_RANDOMACT_BOOL_BERNOUILLI: See L{SCA_RandomActuator}
@@ -134,14 +132,14 @@ Documentation for the GameLogic Module.
@var KX_RANDOMACT_FLOAT_NORMAL: See L{SCA_RandomActuator}
@var KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL: See L{SCA_RandomActuator}
-@group Action Actuator: KX_ACTIONACT_PLAY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND, KX_ACTIONACT_PROPERTY
+@group Action Actuator: KX_ACTIONACT_*
@var KX_ACTIONACT_PLAY: See L{BL_ActionActuator}
@var KX_ACTIONACT_FLIPPER: See L{BL_ActionActuator}
@var KX_ACTIONACT_LOOPSTOP: See L{BL_ActionActuator}
@var KX_ACTIONACT_LOOPEND: See L{BL_ActionActuator}
@var KX_ACTIONACT_PROPERTY: See L{BL_ActionActuator}
-@group Sound Actuator: KX_SOUNDACT_PLAYSTOP, KX_SOUNDACT_PLAYEND, KX_SOUNDACT_LOOPSTOP, KX_SOUNDACT_LOOPEND, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
+@group Sound Actuator: KX_SOUNDACT_*
@var KX_SOUNDACT_PLAYSTOP: See L{KX_SoundActuator}
@var KX_SOUNDACT_PLAYEND: See L{KX_SoundActuator}
@var KX_SOUNDACT_LOOPSTOP: See L{KX_SoundActuator}
@@ -149,7 +147,7 @@ Documentation for the GameLogic Module.
@var KX_SOUNDACT_LOOPBIDIRECTIONAL: See L{KX_SoundActuator}
@var KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: See L{KX_SoundActuator}
-@group Radar Sensor: KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y, KX_RADAR_AXIS_POS_Z, KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y, KX_RADAR_AXIS_NEG_Z
+@group Radar Sensor: KX_RADAR_*
@var KX_RADAR_AXIS_POS_X: See L{KX_RadarSensor}
@var KX_RADAR_AXIS_POS_Y: See L{KX_RadarSensor}
@var KX_RADAR_AXIS_POS_Z: See L{KX_RadarSensor}
@@ -157,7 +155,7 @@ Documentation for the GameLogic Module.
@var KX_RADAR_AXIS_NEG_Y: See L{KX_RadarSensor}
@var KX_RADAR_AXIS_NEG_Z: See L{KX_RadarSensor}
-@group Ray Sensor: KX_RAY_AXIS_POS_X, KX_RAY_AXIS_POS_Y, KX_RAY_AXIS_POS_Z, KX_RAY_AXIS_NEG_X, KX_RAY_AXIS_NEG_Y, KX_RAY_AXIS_NEG_Z
+@group Ray Sensor: KX_RAY_*
@var KX_RAY_AXIS_POS_X: See L{KX_RaySensor}
@var KX_RAY_AXIS_POS_Y: See L{KX_RaySensor}
@var KX_RAY_AXIS_POS_Z: See L{KX_RaySensor}
@@ -165,26 +163,153 @@ Documentation for the GameLogic Module.
@var KX_RAY_AXIS_NEG_Y: See L{KX_RaySensor}
@var KX_RAY_AXIS_NEG_Z: See L{KX_RaySensor}
-@group Dynamic Actuator: KX_DYN_RESTORE_DYNAMICS, KX_DYN_DISABLE_DYNAMICS, KX_DYN_ENABLE_RIGID_BODY, KX_DYN_DISABLE_RIGID_BODY, KX_DYN_SET_MASS
+@group Dynamic Actuator: KX_DYN_*
@var KX_DYN_RESTORE_DYNAMICS: See L{KX_SCA_DynamicActuator}
@var KX_DYN_DISABLE_DYNAMICS: See L{KX_SCA_DynamicActuator}
@var KX_DYN_ENABLE_RIGID_BODY: See L{KX_SCA_DynamicActuator}
@var KX_DYN_DISABLE_RIGID_BODY: See L{KX_SCA_DynamicActuator}
@var KX_DYN_SET_MASS: See L{KX_SCA_DynamicActuator}
-@group Input Status: KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED
+@group Game Actuator: KX_GAME_*
+@var KX_GAME_LOAD: See L{KX_GameActuator}
+@var KX_GAME_START: See L{KX_GameActuator}
+@var KX_GAME_RESTART: See L{KX_GameActuator}
+@var KX_GAME_QUIT: See L{KX_GameActuator}
+@var KX_GAME_SAVECFG: See L{KX_GameActuator}
+@var KX_GAME_LOADCFG: See L{KX_GameActuator}
+
+@group Scene Actuator: KX_SCENE_*
+@var KX_SCENE_RESTART: See L{KX_SceneActuator}
+@var KX_SCENE_SET_SCENE: See L{KX_SceneActuator}
+@var KX_SCENE_SET_CAMERA: See L{KX_SceneActuator}
+@var KX_SCENE_ADD_FRONT_SCENE: See L{KX_SceneActuator}
+@var KX_SCENE_ADD_BACK_SCENE: See L{KX_SceneActuator}
+@var KX_SCENE_REMOVE_SCENE: See L{KX_SceneActuator}
+@var KX_SCENE_SUSPEND: See L{KX_SceneActuator}
+@var KX_SCENE_RESUME: See L{KX_SceneActuator}
+
+@group Input Status: KX_INPUT_*
@var KX_INPUT_NONE: See L{SCA_MouseSensor}
@var KX_INPUT_JUST_ACTIVATED: See L{SCA_MouseSensor}
@var KX_INPUT_ACTIVE: See L{SCA_MouseSensor}
@var KX_INPUT_JUST_RELEASED: See L{SCA_MouseSensor}
-@group Mouse Buttons: KX_MOUSE_BUT_LEFT, KX_MOUSE_BUT_MIDDLE, KX_MOUSE_BUT_RIGHT
+@group Mouse Buttons: KX_MOUSE_BUT_*
@var KX_MOUSE_BUT_LEFT: See L{SCA_MouseSensor}
@var KX_MOUSE_BUT_MIDDLE: See L{SCA_MouseSensor}
@var KX_MOUSE_BUT_RIGHT: See L{SCA_MouseSensor}
+
+@group States: KX_STATE*
+@var KX_STATE1:
+@var KX_STATE10:
+@var KX_STATE11:
+@var KX_STATE12:
+@var KX_STATE13:
+@var KX_STATE14:
+@var KX_STATE15:
+@var KX_STATE16:
+@var KX_STATE17:
+@var KX_STATE18:
+@var KX_STATE19:
+@var KX_STATE2:
+@var KX_STATE20:
+@var KX_STATE21:
+@var KX_STATE22:
+@var KX_STATE23:
+@var KX_STATE24:
+@var KX_STATE25:
+@var KX_STATE26:
+@var KX_STATE27:
+@var KX_STATE28:
+@var KX_STATE29:
+@var KX_STATE3:
+@var KX_STATE30:
+@var KX_STATE4:
+@var KX_STATE5:
+@var KX_STATE6:
+@var KX_STATE7:
+@var KX_STATE8:
+@var KX_STATE9:
+@var KX_STATE_OP_CLR:
+@var KX_STATE_OP_CPY:
+@var KX_STATE_OP_NEG:
+@var KX_STATE_OP_SET:
+
+@group 2D Filter: RAS_2DFILTER_*
+@var RAS_2DFILTER_BLUR:
+@var RAS_2DFILTER_CUSTOMFILTER:
+@var RAS_2DFILTER_DILATION:
+@var RAS_2DFILTER_DISABLED:
+@var RAS_2DFILTER_ENABLED:
+@var RAS_2DFILTER_EROSION:
+@var RAS_2DFILTER_GRAYSCALE:
+@var RAS_2DFILTER_INVERT:
+@var RAS_2DFILTER_LAPLACIAN:
+@var RAS_2DFILTER_MOTIONBLUR:
+@var RAS_2DFILTER_NOFILTER:
+@var RAS_2DFILTER_PREWITT:
+@var RAS_2DFILTER_SEPIA:
+@var RAS_2DFILTER_SHARPEN:
+@var RAS_2DFILTER_SOBEL:
+
+@group Constraint Actuator: KX_ACT_CONSTRAINT_*
+@var KX_ACT_CONSTRAINT_DISTANCE:
+@var KX_ACT_CONSTRAINT_DOROTFH:
+@var KX_ACT_CONSTRAINT_FHNX:
+@var KX_ACT_CONSTRAINT_FHNY:
+@var KX_ACT_CONSTRAINT_FHNZ:
+@var KX_ACT_CONSTRAINT_FHPX:
+@var KX_ACT_CONSTRAINT_FHPY:
+@var KX_ACT_CONSTRAINT_FHPZ:
+@var KX_ACT_CONSTRAINT_LOCAL:
+@var KX_ACT_CONSTRAINT_MATERIAL:
+@var KX_ACT_CONSTRAINT_NORMAL:
+@var KX_ACT_CONSTRAINT_PERMANENT:
+
+@group Parent Actuator: KX_PARENT_*
+@var KX_PARENT_REMOVE:
+@var KX_PARENT_SET:
+
+@group Shader: MODELMATRIX*, MODELVIEWMATRIX*, VIEWMATRIX*, CAM_POS, CONSTANT_TIMER
+@var VIEWMATRIX:
+@var VIEWMATRIX_INVERSE:
+@var VIEWMATRIX_INVERSETRANSPOSE:
+@var VIEWMATRIX_TRANSPOSE:
+@var MODELMATRIX:
+@var MODELMATRIX_INVERSE:
+@var MODELMATRIX_INVERSETRANSPOSE:
+@var MODELMATRIX_TRANSPOSE:
+@var MODELVIEWMATRIX:
+@var MODELVIEWMATRIX_INVERSE:
+@var MODELVIEWMATRIX_INVERSETRANSPOSE:
+@var MODELVIEWMATRIX_TRANSPOSE:
+@var CAM_POS: Current camera position
+@var CONSTANT_TIMER: Current camera position
+@var SHD_TANGENT: Current camera position
+
+@group Blender Material: BL_*
+@var BL_DST_ALPHA:
+@var BL_DST_COLOR:
+@var BL_ONE:
+@var BL_ONE_MINUS_DST_ALPHA:
+@var BL_ONE_MINUS_DST_COLOR:
+@var BL_ONE_MINUS_SRC_ALPHA:
+@var BL_ONE_MINUS_SRC_COLOR:
+@var BL_SRC_ALPHA:
+@var BL_SRC_ALPHA_SATURATE:
+@var BL_SRC_COLOR:
+@var BL_ZERO:
+
+@group Deprecated: addActiveActuator
"""
+import GameTypes
+
+# TODO
+# globalDict
+# error
+
def getCurrentController():
"""
Gets the Python controller associated with this Python script.
@@ -197,10 +322,19 @@ def getCurrentScene():
@rtype: L{KX_Scene}
"""
+def getSceneList():
+ """
+ Gets a list of the current scenes loaded in the game engine.
+
+ @note: Scenes in your blend file that have not been converted wont be in this list. This list will only contain scenes such as overlays scenes.
+
+ @rtype: list of L{KX_Scene}
+ """
def addActiveActuator(actuator, activate):
"""
Activates the given actuator.
+ @deprecated: Use L{GameTypes.SCA_PythonController.activate} and L{GameTypes.SCA_PythonController.deactivate} instead.
@type actuator: L{SCA_IActuator} or the actuator name as a string.
@type activate: boolean
@param activate: whether to activate or deactivate the given actuator.
@@ -218,10 +352,6 @@ def sendMessage(subject, body="", to="", message_from=""):
@param message_from: The name of the object that the message is coming from (optional)
@type message_from: string
"""
-def getRandomFloat():
- """
- Returns a random floating point value in the range [0...1)
- """
def setGravity(gravity):
"""
Sets the world gravity.
@@ -242,6 +372,38 @@ def stopDSP():
Only the fmod sound driver supports this.
DSP can be computationally expensive.
"""
+def getMaxLogicFrame():
+ """
+ Gets the maximum number of logic frame per render frame.
+
+ @return: The maximum number of logic frame per render frame
+ @rtype: interger
+ """
+def setMaxLogicFrame(maxlogic):
+ """
+ Sets the maximum number of logic frame that are executed per render frame.
+ This does not affect the physic system that still runs at full frame rate.
+
+ @param maxlogic: The new maximum number of logic frame per render frame. Valid values: 1..5
+ @type maxlogic: integer
+ """
+def getMaxPhysicsFrame():
+ """
+ Gets the maximum number of physics frame per render frame.
+
+ @return: The maximum number of physics frame per render frame
+ @rtype: interger
+ """
+def setMaxPhysicsFrame(maxphysics):
+ """
+ Sets the maximum number of physics timestep that are executed per render frame.
+ Higher value allows physics to keep up with realtime even if graphics slows down the game.
+ Physics timestep is fixed and equal to 1/tickrate (see setLogicTicRate)
+ maxphysics/ticrate is the maximum delay of the renderer that physics can compensate.
+
+ @param maxphysics: The new maximum number of physics timestep per render frame. Valid values: 1..5.
+ @type maxphysics: integer
+ """
def getLogicTicRate():
"""
Gets the logic update frequency.
@@ -254,13 +416,14 @@ def setLogicTicRate(ticrate):
Sets the logic update frequency.
The logic update frequency is the number of times logic bricks are executed every second.
- The default is 30 Hz.
+ The default is 60 Hz.
@param ticrate: The new logic update frequency (in Hz).
@type ticrate: float
"""
def getPhysicsTicRate():
"""
+ NOT IMPLEMENTED
Gets the physics update frequency
@return: The physics update frequency in Hz
@@ -268,6 +431,7 @@ def getPhysicsTicRate():
"""
def setPhysicsTicRate(ticrate):
"""
+ NOT IMPLEMENTED
Sets the physics update frequency
The physics update frequency is the number of times the physics system is executed every second.
@@ -276,6 +440,8 @@ def setPhysicsTicRate(ticrate):
@param ticrate: The new update frequency (in Hz).
@type ticrate: float
"""
+
+#{ Utility functions
def getAverageFrameRate():
"""
Gets the estimated average framerate
@@ -283,7 +449,6 @@ def getAverageFrameRate():
@return: The estimed average framerate in frames per second
@rtype: float
"""
-
def expandPath(path):
"""
Converts a blender internal path into a proper file system path.
@@ -309,3 +474,12 @@ def getBlendFileList(path = "//"):
@return: A list of filenames, with no directory prefix
@rtype: list
"""
+def PrintGLInfo():
+ """
+ Prints GL Extension Info into the console
+ """
+def getRandomFloat():
+ """
+ Returns a random floating point value in the range [0...1)
+ """
+#}
diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py
index 2b07a18247c..4ab175a8f6c 100644
--- a/source/gameengine/PyDoc/GameTypes.py
+++ b/source/gameengine/PyDoc/GameTypes.py
@@ -1,75 +1,5796 @@
-# $Id$
"""
-GameEngine Types
-================
-@var BL_ActionActuator: L{BL_ActionActuator<BL_ActionActuator.BL_ActionActuator>}
-@var BL_Shader: L{BL_Shader<BL_Shader.BL_Shader>}
-@var BL_ShapeActionActuator: L{BL_ShapeActionActuator<BL_ShapeActionActuator.BL_ShapeActionActuator>}
-@var CListValue: L{CListValue<CListValue.CListValue>}
-@var CValue: L{CValue<CValue.CValue>}
-@var KX_BlenderMaterial: L{KX_BlenderMaterial<KX_BlenderMaterial.KX_BlenderMaterial>}
-@var KX_CDActuator: L{KX_CDActuator<KX_CDActuator.KX_CDActuator>}
-@var KX_Camera: L{KX_Camera<KX_Camera.KX_Camera>}
-@var KX_CameraActuator: L{KX_CameraActuator<KX_CameraActuator.KX_CameraActuator>}
-@var KX_ConstraintActuator: L{KX_ConstraintActuator<KX_ConstraintActuator.KX_ConstraintActuator>}
-@var KX_ConstraintWrapper: L{KX_ConstraintWrapper<KX_ConstraintWrapper.KX_ConstraintWrapper>}
-@var KX_GameActuator: L{KX_GameActuator<KX_GameActuator.KX_GameActuator>}
-@var KX_GameObject: L{KX_GameObject<KX_GameObject.KX_GameObject>}
-@var KX_IpoActuator: L{KX_IpoActuator<KX_IpoActuator.KX_IpoActuator>}
-@var KX_LightObject: L{KX_LightObject<KX_LightObject.KX_LightObject>}
-@var KX_MeshProxy: L{KX_MeshProxy<KX_MeshProxy.KX_MeshProxy>}
-@var KX_MouseFocusSensor: L{KX_MouseFocusSensor<KX_MouseFocusSensor.KX_MouseFocusSensor>}
-@var KX_NearSensor: L{KX_NearSensor<KX_NearSensor.KX_NearSensor>}
-@var KX_NetworkMessageActuator: L{KX_NetworkMessageActuator<KX_NetworkMessageActuator.KX_NetworkMessageActuator>}
-@var KX_NetworkMessageSensor: L{KX_NetworkMessageSensor<KX_NetworkMessageSensor.KX_NetworkMessageSensor>}
-@var KX_ObjectActuator: L{KX_ObjectActuator<KX_ObjectActuator.KX_ObjectActuator>}
-@var KX_ParentActuator: L{KX_ParentActuator<KX_ParentActuator.KX_ParentActuator>}
-@var KX_PhysicsObjectWrapper: L{KX_PhysicsObjectWrapper<KX_PhysicsObjectWrapper.KX_PhysicsObjectWrapper>}
-@var KX_PolyProxy: L{KX_PolyProxy<KX_PolyProxy.KX_PolyProxy>}
-@var KX_PolygonMaterial: L{KX_PolygonMaterial<KX_PolygonMaterial.KX_PolygonMaterial>}
-@var KX_RadarSensor: L{KX_RadarSensor<KX_RadarSensor.KX_RadarSensor>}
-@var KX_RaySensor: L{KX_RaySensor<KX_RaySensor.KX_RaySensor>}
-@var KX_SCA_AddObjectActuator: L{KX_SCA_AddObjectActuator<KX_SCA_AddObjectActuator.KX_SCA_AddObjectActuator>}
-@var KX_SCA_DynamicActuator: L{KX_SCA_DynamicActuator<KX_SCA_DynamicActuator.KX_SCA_DynamicActuator>}
-@var KX_SCA_EndObjectActuator: L{KX_SCA_EndObjectActuator<KX_SCA_EndObjectActuator.KX_SCA_EndObjectActuator>}
-@var KX_SCA_ReplaceMeshActuator: L{KX_SCA_ReplaceMeshActuator<KX_SCA_ReplaceMeshActuator.KX_SCA_ReplaceMeshActuator>}
-@var KX_Scene: L{KX_Scene<KX_Scene.KX_Scene>}
-@var KX_SceneActuator: L{KX_SceneActuator<KX_SceneActuator.KX_SceneActuator>}
-@var KX_SoundActuator: L{KX_SoundActuator<KX_SoundActuator.KX_SoundActuator>}
-@var KX_StateActuator: L{KX_StateActuator<KX_StateActuator.KX_StateActuator>}
-@var KX_TouchSensor: L{KX_TouchSensor<KX_TouchSensor.KX_TouchSensor>}
-@var KX_TrackToActuator: L{KX_TrackToActuator<KX_TrackToActuator.KX_TrackToActuator>}
-@var KX_VehicleWrapper: L{KX_VehicleWrapper<KX_VehicleWrapper.KX_VehicleWrapper>}
-@var KX_VertexProxy: L{KX_VertexProxy<KX_VertexProxy.KX_VertexProxy>}
-@var KX_VisibilityActuator: L{KX_VisibilityActuator<KX_VisibilityActuator.KX_VisibilityActuator>}
-@var PyObjectPlus: L{PyObjectPlus<PyObjectPlus.PyObjectPlus>}
-@var SCA_2DFilterActuator: L{SCA_2DFilterActuator<SCA_2DFilterActuator.SCA_2DFilterActuator>}
-@var SCA_ANDController: L{SCA_ANDController<SCA_ANDController.SCA_ANDController>}
-@var SCA_ActuatorSensor: L{SCA_ActuatorSensor<SCA_ActuatorSensor.SCA_ActuatorSensor>}
-@var SCA_AlwaysSensor: L{SCA_AlwaysSensor<SCA_AlwaysSensor.SCA_AlwaysSensor>}
-@var SCA_DelaySensor: L{SCA_DelaySensor<SCA_DelaySensor.SCA_DelaySensor>}
-@var SCA_ILogicBrick: L{SCA_ILogicBrick<SCA_ILogicBrick.SCA_ILogicBrick>}
-@var SCA_IObject: L{SCA_IObject<SCA_IObject.SCA_IObject>}
-@var SCA_ISensor: L{SCA_ISensor<SCA_ISensor.SCA_ISensor>}
-@var SCA_JoystickSensor: L{SCA_JoystickSensor<SCA_JoystickSensor.SCA_JoystickSensor>}
-@var SCA_KeyboardSensor: L{SCA_KeyboardSensor<SCA_KeyboardSensor.SCA_KeyboardSensor>}
-@var SCA_MouseSensor: L{SCA_MouseSensor<SCA_MouseSensor.SCA_MouseSensor>}
-@var SCA_NANDController: L{SCA_NANDController<SCA_NANDController.SCA_NANDController>}
-@var SCA_NORController: L{SCA_NORController<SCA_NORController.SCA_NORController>}
-@var SCA_ORController: L{SCA_ORController<SCA_ORController.SCA_ORController>}
-@var SCA_PropertyActuator: L{SCA_PropertyActuator<SCA_PropertyActuator.SCA_PropertyActuator>}
-@var SCA_PropertySensor: L{SCA_PropertySensor<SCA_PropertySensor.SCA_PropertySensor>}
-@var SCA_PythonController: L{SCA_PythonController<SCA_PythonController.SCA_PythonController>}
-@var SCA_RandomActuator: L{SCA_RandomActuator<SCA_RandomActuator.SCA_RandomActuator>}
-@var SCA_RandomSensor: L{SCA_RandomSensor<SCA_RandomSensor.SCA_RandomSensor>}
-@var SCA_XNORController: L{SCA_XNORController<SCA_XNORController.SCA_XNORController>}
-@var SCA_XORController: L{SCA_XORController<SCA_XORController.SCA_XORController>}
+Documentation for the GameTypes Module.
+=======================================
+
+@group Base: PyObjectPlus, CValue, CPropValue, SCA_ILogicBrick, SCA_IObject, SCA_ISensor, SCA_IController, SCA_IActuator
+
+@group Object: KX_GameObject, KX_LightObject, KX_Camera
+
+@group Mesh: KX_MeshProxy, KX_PolyProxy, KX_VertexProxy
+
+@group Shading: KX_PolygonMaterial, KX_BlenderMaterial, BL_Shader
+
+@group Sensors: SCA_ActuatorSensor, SCA_AlwaysSensor, SCA_DelaySensor, SCA_JoystickSensor, SCA_KeyboardSensor, KX_MouseFocusSensor, SCA_MouseSensor, KX_NearSensor, KX_NetworkMessageSensor, SCA_PropertySensor, KX_RadarSensor, SCA_RandomSensor, KX_RaySensor, KX_TouchSensor
+
+@group Actuators: SCA_2DFilterActuator, BL_ActionActuator, KX_SCA_AddObjectActuator, KX_CameraActuator, KX_CDActuator, KX_ConstraintActuator, KX_SCA_DynamicActuator, KX_SCA_EndObjectActuator, KX_GameActuator, KX_IpoActuator, KX_NetworkMessageActuator, KX_ObjectActuator, KX_ParentActuator, SCA_PropertyActuator, SCA_RandomActuator, KX_SCA_ReplaceMeshActuator, KX_SceneActuator, BL_ShapeActionActuator, KX_SoundActuator, KX_StateActuator, KX_TrackToActuator, KX_VisibilityActuator
+
+@group Controllers: SCA_ANDController, SCA_NANDController, SCA_NORController, SCA_ORController, SCA_PythonController, SCA_XNORController, SCA_XORController
+"""
+import GameLogic
+
+class PyObjectPlus:
+ """
+ PyObjectPlus base class of most other types in the Game Engine.
+
+ @ivar invalid: Test if the object has been freed by the game engine and is no longer valid.
+
+ Normally this is not a problem but when storing game engine data in the GameLogic module,
+ KX_Scenes or other KX_GameObjects its possible to hold a reference to invalid data.
+ Calling an attribute or method on an invalid object will raise a SystemError.
+
+ The invalid attribute allows testing for this case without exception handling.
+ @type invalid: bool
+ """
+
+ def isA(game_type):
+ """
+ Check if this is a type or a subtype game_type.
+
+ @param game_type: the name of the type or the type its self from the L{GameTypes} module.
+ @type game_type: string or type
+ @return: True if this object is a type or a subtype of game_type.
+ @rtype: bool
+ """
+
+class CValue(PyObjectPlus):
+ """
+ This class is a basis for other classes.
+ @ivar name: The name of this CValue derived object (read-only).
+ @type name: string
+ @group Deprecated: getName
+ """
+ def getName():
+ """
+ Returns the name of the CValue.
+
+ @deprecated: Use the L{name} attribute instead.
+ @note: in most cases the CValue's subclasses will override this function.
+ @rtype: string
+ """
+
+class CPropValue(CValue):
+ """
+ This class has no python functions
+ """
+ pass
+
+class SCA_ILogicBrick(CValue):
+ """
+ Base class for all logic bricks.
+
+ @ivar executePriority: This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
+ @type executePriority: int
+ @ivar owner: The game object this logic brick is attached to (read-only).
+ @type owner: L{KX_GameObject} or None in exceptional cases.
+ @ivar name: The name of this logic brick (read-only).
+ @type name: string
+ """
+
+#{ Deprecated
+ def getOwner():
+ """
+ Gets the game object associated with this logic brick.
+
+ @deprecated: Use the L{owner} attribute instead.
+ @rtype: L{KX_GameObject}
+ """
+
+ def setExecutePriority(priority):
+ """
+ Sets the priority of this logic brick.
+
+ This determines the order controllers are evaluated, and actuators are activated.
+ Bricks with lower priority will be executed first.
+
+ @deprecated: Use the L{executePriority} attribute instead.
+ @type priority: integer
+ @param priority: the priority of this logic brick.
+ """
+ def getExecutePriority():
+ """
+ Gets the execution priority of this logic brick.
+
+ @deprecated: Use the L{executePriority} attribute instead.
+ @rtype: integer
+ @return: this logic bricks current priority.
+ """
+#}
+
+class SCA_IObject(CValue):
+ """
+ This class has no python functions
+ """
+ pass
+
+class SCA_ISensor(SCA_ILogicBrick):
+ """
+ Base class for all sensor logic bricks.
+
+ @ivar usePosPulseMode: Flag to turn positive pulse mode on and off.
+ @type usePosPulseMode: boolean
+ @ivar useNegPulseMode: Flag to turn negative pulse mode on and off.
+ @type useNegPulseMode: boolean
+ @ivar frequency: The frequency for pulse mode sensors.
+ @type frequency: int
+ @ivar level: Option whether to detect level or edge transition when entering a state.
+ It makes a difference only in case of logic state transition (state actuator).
+ A level detector will immediately generate a pulse, negative or positive
+ depending on the sensor condition, as soon as the state is activated.
+ A edge detector will wait for a state change before generating a pulse.
+ note: mutually exclusive with L{tap}, enabling will disable L{tap}.
+ @type level: boolean
+ @ivar tap: When enabled only sensors that are just activated will send a positive event,
+ after this they will be detected as negative by the controllers.
+ This will make a key thats held act as if its only tapped for an instant.
+ note: mutually exclusive with L{level}, enabling will disable L{level}.
+ @type tap: boolean
+ @ivar invert: Flag to set if this sensor activates on positive or negative events.
+ @type invert: boolean
+ @ivar triggered: True if this sensor brick is in a positive state. (read-only)
+ @type triggered: boolean
+ @ivar positive: True if this sensor brick is in a positive state. (read-only)
+ @type positive: boolean
+ """
+
+ def reset():
+ """
+ Reset sensor internal state, effect depends on the type of sensor and settings.
+
+ The sensor is put in its initial state as if it was just activated.
+ """
+#{ Deprecated
+ def isPositive():
+ """
+ True if this sensor brick is in a positive state.
+
+ @deprecated: use L{positive}
+ """
+
+ def isTriggered():
+ """
+ True if this sensor brick has triggered the current controller.
+
+ @deprecated: use L{triggered}
+ """
+
+ def getUsePosPulseMode():
+ """
+ True if the sensor is in positive pulse mode.
+
+ @deprecated: use L{usePosPulseMode}
+ """
+ def setUsePosPulseMode(pulse):
+ """
+ Sets positive pulse mode.
+
+ @type pulse: boolean
+ @param pulse: If True, will activate positive pulse mode for this sensor.
+ @deprecated: use L{usePosPulseMode}
+ """
+ def getFrequency():
+ """
+ The frequency for pulse mode sensors.
+
+ @rtype: integer
+ @return: the pulse frequency in 1/50 sec.
+ @deprecated: use L{frequency}
+ """
+ def setFrequency(freq):
+ """
+ Sets the frequency for pulse mode sensors.
+
+ @type freq: integer
+ @return: the pulse frequency in 1/50 sec.
+ @deprecated: use L{frequency}
+ """
+ def getUseNegPulseMode():
+ """
+ True if the sensor is in negative pulse mode.
+
+ @deprecated: use L{useNegPulseMode}
+ """
+ def setUseNegPulseMode(pulse):
+ """
+ Sets negative pulse mode.
+
+ @type pulse: boolean
+ @param pulse: If True, will activate negative pulse mode for this sensor.
+ @deprecated: use L{useNegPulseMode}
+ """
+ def getInvert():
+ """
+ True if this sensor activates on negative events.
+
+ @deprecated: use L{invert}
+ """
+ def setInvert(invert):
+ """
+ Sets if this sensor activates on positive or negative events.
+
+ @type invert: boolean
+ @param invert: true if activates on negative events; false if activates on positive events.
+ @deprecated: use L{invert}
+ """
+ def getLevel():
+ """
+ Returns whether this sensor is a level detector or a edge detector.
+ It makes a difference only in case of logic state transition (state actuator).
+ A level detector will immediately generate a pulse, negative or positive
+ depending on the sensor condition, as soon as the state is activated.
+ A edge detector will wait for a state change before generating a pulse.
+
+ @rtype: boolean
+ @return: true if sensor is level sensitive, false if it is edge sensitive
+ @deprecated: use L{level}
+ """
+ def setLevel(level):
+ """
+ Set whether to detect level or edge transition when entering a state.
+
+ @param level: Detect level instead of edge? (KX_TRUE, KX_FALSE)
+ @type level: boolean
+ @deprecated: use L{level}
+ """
+#}
+
+class SCA_IController(SCA_ILogicBrick):
+ """
+ Base class for all controller logic bricks.
+
+ @ivar state: the controllers state bitmask.
+ This can be used with the GameObject's state to test if the controller is active.
+ @type state: int bitmask
+ @ivar sensors: a list of sensors linked to this controller
+ - note: the sensors are not necessarily owned by the same object.
+ - note: when objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
+ @type sensors: sequence supporting index/string lookups and iteration.
+ @ivar actuators: a list of actuators linked to this controller.
+ - note: the sensors are not necessarily owned by the same object.
+ - note: when objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
+ @type actuators: sequence supporting index/string lookups and iteration.
+ @ivar useHighPriority: When set the controller executes always before all other controllers that dont have this set.
+ note: Order of execution between high priority controllers is not guaranteed.
+ @type useHighPriority: bool
+ """
+#{ Deprecated
+ def getState():
+ """
+ Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active.
+ This for instance will always be true however you could compare with a previous state to see when the state was activated.
+ GameLogic.getCurrentController().state & GameLogic.getCurrentController().owner.state
+ @deprecated: Use the L{state} property
+ @rtype: int
+ """
+ def getSensors():
+ """
+ Gets a list of all sensors attached to this controller.
+ @deprecated: use the L{sensors} property
+ @rtype: list [L{SCA_ISensor}]
+ """
+ def getSensor(name):
+ """
+ Gets the named linked sensor.
+ @deprecated: use the L{sensors}[name] property
+ @type name: string
+ @rtype: L{SCA_ISensor}
+ """
+ def getActuators():
+ """
+ Gets a list of all actuators linked to this controller.
+ @deprecated: Use the L{actuators} property
+ @rtype: list [L{SCA_IActuator}]
+ """
+ def getActuator(name):
+ """
+ Gets the named linked actuator.
+ @deprecated: use the L{actuators}[name] property
+ @type name: string
+ @rtype: L{SCA_IActuator}
+ """
+#}
+
+class SCA_IActuator(SCA_ILogicBrick):
+ """
+ Base class for all actuator logic bricks.
+ """
+
+class BL_ActionActuator(SCA_IActuator):
+ """
+ Action Actuators apply an action to an actor.
+
+ @ivar action: The name of the action to set as the current action.
+ @type action: string
+ @ivar frameStart: Specifies the starting frame of the animation.
+ @type frameStart: float
+ @ivar frameEnd: Specifies the ending frame of the animation.
+ @type frameEnd: float
+ @ivar blendIn: Specifies the number of frames of animation to generate when making transitions between actions.
+ @type blendIn: float
+ @ivar priority: Sets the priority of this actuator. Actuators will lower
+ priority numbers will override actuators with higher
+ numbers.
+ @type priority: integer
+ @ivar frame: Sets the current frame for the animation.
+ @type frame: float
+ @ivar propName: Sets the property to be used in FromProp playback mode.
+ @type propName: string
+ @ivar blendTime: Sets the internal frame timer. This property must be in
+ the range from 0.0 to blendIn.
+ @type blendTime: float
+ @ivar mode: The operation mode of the actuator. KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ @type mode: integer
+ @ivar useContinue: The actions continue option, True or False.
+ When True, the action will always play from where last left off,
+ otherwise negative events to this actuator will reset it to its start frame.
+ @type useContinue: boolean
+ @ivar framePropName: The name of the property that is set to the current frame number.
+ @type framePropName: string
+ """
+ def setChannel(channel, matrix, mode = False):
+ """
+ @param channel: A string specifying the name of the bone channel.
+ @type channel: string
+ @param matrix: A 4x4 matrix specifying the overriding transformation
+ as an offset from the bone's rest position.
+ @type matrix: list [[float]]
+ @param mode: True for armature/world space, False for bone space
+ @type mode: boolean
+ """
+
+#{ Deprecated
+ def setAction(action, reset = True):
+ """
+ Sets the current action.
+ @deprecated: use the L{action} property
+ @param action: The name of the action to set as the current action.
+ @type action: string
+ @param reset: Optional parameter indicating whether to reset the
+ blend timer or not. A value of 1 indicates that the
+ timer should be reset. A value of 0 will leave it
+ unchanged. If reset is not specified, the timer will
+ be reset.
+ """
+
+ def setStart(start):
+ """
+ Specifies the starting frame of the animation.
+ @deprecated: Use the L{frameStart} property
+ @param start: the starting frame of the animation
+ @type start: float
+ """
+
+ def setEnd(end):
+ """
+ Specifies the ending frame of the animation.
+ @deprecated: use the L{frameEnd} property
+ @param end: the ending frame of the animation
+ @type end: float
+ """
+ def setBlendin(blendin):
+ """
+ Specifies the number of frames of animation to generate
+ when making transitions between actions.
+ @deprecated: use the L{blendIn} property
+ @param blendin: the number of frames in transition.
+ @type blendin: float
+ """
+
+ def setPriority(priority):
+ """
+ Sets the priority of this actuator.
+
+ @deprecated: Use use the L{priority} property
+ @param priority: Specifies the new priority. Actuators will lower
+ priority numbers will override actuators with higher
+ numbers.
+ @type priority: integer
+ """
+ def setFrame(frame):
+ """
+ Sets the current frame for the animation.
+
+ @deprecated: use the L{frame} property
+ @param frame: Specifies the new current frame for the animation
+ @type frame: float
+ """
+
+ def setProperty(prop):
+ """
+ Sets the property to be used in FromProp playback mode.
+
+ @deprecated: use the L{property} property
+ @param prop: the name of the property to use.
+ @type prop: string.
+ """
+
+ def setBlendtime(blendtime):
+ """
+ Sets the internal frame timer.
+
+ Allows the script to directly modify the internal timer
+ used when generating transitions between actions.
+
+ @deprecated: use the L{blendTime} property
+ @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0.
+ @type blendtime: float
+ """
+
+ def setType(mode):
+ """
+ Sets the operation mode of the actuator
+
+ @deprecated: use the L{type} property
+ @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ @type mode: integer
+ """
+
+ def setContinue(cont):
+ """
+ Set the actions continue option True or False. see getContinue.
+
+ @deprecated: use the L{useContinue} property
+ @param cont: The continue option.
+ @type cont: bool
+ """
+
+ def getType():
+ """
+ Returns the operation mode of the actuator
+
+ @deprecated: use the L{type} property
+ @rtype: integer
+ @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ """
+
+ def getContinue():
+ """
+ When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
+
+ @deprecated: use the L{useContinue} property
+ @rtype: bool
+ """
+
+ def getAction():
+ """
+ getAction() returns the name of the action associated with this actuator.
+
+ @deprecated: use the L{action} property
+ @rtype: string
+ """
+
+ def getStart():
+ """
+ Returns the starting frame of the action.
+
+ @deprecated: use the L{frameStart} property
+ @rtype: float
+ """
+ def getEnd():
+ """
+ Returns the last frame of the action.
+
+ @deprecated: use the L{frameEnd} property
+ @rtype: float
+ """
+ def getBlendin():
+ """
+ Returns the number of interpolation animation frames to be generated when this actuator is triggered.
+
+ @deprecated: use the L{blendIn} property
+ @rtype: float
+ """
+ def getPriority():
+ """
+ Returns the priority for this actuator. Actuators with lower Priority numbers will
+ override actuators with higher numbers.
+
+ @deprecated: use the L{priority} property
+ @rtype: integer
+ """
+ def getFrame():
+ """
+ Returns the current frame number.
+
+ @deprecated: use the L{frame} property
+ @rtype: float
+ """
+ def getProperty():
+ """
+ Returns the name of the property to be used in FromProp mode.
+
+ @deprecated: use the L{property} property
+ @rtype: string
+ """
+ def setFrameProperty(prop):
+ """
+ @deprecated: use the L{framePropName} property
+ @param prop: A string specifying the property of the object that will be updated with the action frame number.
+ @type prop: string
+ """
+ def getFrameProperty():
+ """
+ Returns the name of the property that is set to the current frame number.
+
+ @deprecated: use the L{framePropName} property
+ @rtype: string
+ """
+#}
+
+class BL_Shader(PyObjectPlus):
+ """
+ BL_Shader GLSL shaders.
+
+ TODO - Description
+ """
+
+ def setUniformfv(name, fList):
+ """
+ Set a uniform with a list of float values
+
+ @param name: the uniform name
+ @type name: string
+
+ @param fList: a list (2, 3 or 4 elements) of float values
+ @type fList: list[float]
+ """
+
+ def delSource():
+ """
+ Clear the shader. Use this method before the source is changed with L{setSource}.
+ """
+ def getFragmentProg():
+ """
+ Returns the fragment program.
+
+ @rtype: string
+ @return: The fragment program.
+ """
+ def getVertexProg():
+ """
+ Get the vertex program.
+
+ @rtype: string
+ @return: The vertex program.
+ """
+ def isValid():
+ """
+ Check if the shader is valid.
+
+ @rtype: bool
+ @return: True if the shader is valid
+ """
+ def setAttrib(enum):
+ """
+ Set attribute location. (The parameter is ignored a.t.m. and the value of "tangent" is always used.)
+
+ @param enum: attribute location value
+ @type enum: integer
+ """
+ def setNumberOfPasses( max_pass ):
+ """
+ Set the maximum number of passes. Not used a.t.m.
+
+ @param max_pass: the maximum number of passes
+ @type max_pass: integer
+ """
+ def setSampler(name, index):
+ """
+ Set uniform texture sample index.
+
+ @param name: Uniform name
+ @type name: string
+
+ @param index: Texture sample index.
+ @type index: integer
+ """
+ def setSource(vertexProgram, fragmentProgram):
+ """
+ Set the vertex and fragment programs
+
+ @param vertexProgram: Vertex program
+ @type vertexProgram: string
+
+ @param fragmentProgram: Fragment program
+ @type fragmentProgram: string
+ """
+ def setUniform1f(name, fx):
+ """
+ Set a uniform with 1 float value.
+
+ @param name: the uniform name
+ @type name: string
+
+ @param fx: Uniform value
+ @type fx: float
+ """
+ def setUniform1i(name, ix):
+ """
+ Set a uniform with an integer value.
+
+ @param name: the uniform name
+ @type name: string
+
+ @param ix: the uniform value
+ @type ix: integer
+ """
+ def setUniform2f(name, fx, fy):
+ """
+ Set a uniform with 2 float values
+
+ @param name: the uniform name
+ @type name: string
+
+ @param fx: first float value
+ @type fx: float
+
+ @param fy: second float value
+ @type fy: float
+ """
+ def setUniform2i(name, ix, iy):
+ """
+ Set a uniform with 2 integer values
+
+ @param name: the uniform name
+ @type name: string
+
+ @param ix: first integer value
+ @type ix: integer
+
+ @param iy: second integer value
+ @type iy: integer
+ """
+ def setUniform3f(name, fx,fy,fz):
+ """
+ Set a uniform with 3 float values.
+
+ @param name: the uniform name
+ @type name: string
+
+ @param fx: first float value
+ @type fx: float
+
+ @param fy: second float value
+ @type fy: float
+
+ @param fz: third float value
+ @type fz: float
+ """
+ def setUniform3i(name, ix,iy,iz):
+ """
+ Set a uniform with 3 integer values
+
+ @param name: the uniform name
+ @type name: string
+
+ @param ix: first integer value
+ @type ix: integer
+
+ @param iy: second integer value
+ @type iy: integer
+
+ @param iz: third integer value
+ @type iz: integer
+ """
+ def setUniform4f(name, fx,fy,fz,fw):
+ """
+ Set a uniform with 4 float values.
+
+ @param name: the uniform name
+ @type name: string
+
+ @param fx: first float value
+ @type fx: float
+
+ @param fy: second float value
+ @type fy: float
+
+ @param fz: third float value
+ @type fz: float
+
+ @param fw: fourth float value
+ @type fw: float
+ """
+ def setUniform4i(name, ix,iy,iz, iw):
+ """
+ Set a uniform with 4 integer values
+
+ @param name: the uniform name
+ @type name: string
+
+ @param ix: first integer value
+ @type ix: integer
+
+ @param iy: second integer value
+ @type iy: integer
+
+ @param iz: third integer value
+ @type iz: integer
+
+ @param iw: fourth integer value
+ @type iw: integer
+ """
+ def setUniformDef(name, type):
+ """
+ Define a new uniform
+
+ @param name: the uniform name
+ @type name: string
+
+ @param type: uniform type
+ @type type: UNI_NONE, UNI_INT, UNI_FLOAT, UNI_INT2, UNI_FLOAT2, UNI_INT3, UNI_FLOAT3, UNI_INT4, UNI_FLOAT4, UNI_MAT3, UNI_MAT4, UNI_MAX
+ """
+ def setUniformMatrix3(name, mat, transpose):
+ """
+ Set a uniform with a 3x3 matrix value
+
+ @param name: the uniform name
+ @type name: string
+
+ @param mat: A 3x3 matrix [[f,f,f], [f,f,f], [f,f,f]]
+ @type mat: 3x3 matrix
+
+ @param transpose: set to True to transpose the matrix
+ @type transpose: bool
+ """
+ def setUniformMatrix4(name, mat, transpose):
+ """
+ Set a uniform with a 4x4 matrix value
+
+ @param name: the uniform name
+ @type name: string
+
+ @param mat: A 4x4 matrix [[f,f,f,f], [f,f,f,f], [f,f,f,f], [f,f,f,f]]
+ @type mat: 4x4 matrix
+
+ @param transpose: set to True to transpose the matrix
+ @type transpose: bool
+ """
+ def setUniformiv(name, iList):
+ """
+ Set a uniform with a list of integer values
+
+ @param name: the uniform name
+ @type name: string
+
+ @param iList: a list (2, 3 or 4 elements) of integer values
+ @type iList: list[integer]
+ """
+ def validate():
+ """
+ Validate the shader object.
+
+ """
+
+class BL_ShapeActionActuator(SCA_IActuator):
+ """
+ ShapeAction Actuators apply an shape action to an mesh object.\
+
+ @ivar action: The name of the action to set as the current shape action.
+ @type action: string
+ @ivar frameStart: Specifies the starting frame of the shape animation.
+ @type frameStart: float
+ @ivar frameEnd: Specifies the ending frame of the shape animation.
+ @type frameEnd: float
+ @ivar blendIn: Specifies the number of frames of animation to generate when making transitions between actions.
+ @type blendIn: float
+ @ivar priority: Sets the priority of this actuator. Actuators will lower
+ priority numbers will override actuators with higher
+ numbers.
+ @type priority: integer
+ @ivar frame: Sets the current frame for the animation.
+ @type frame: float
+ @ivar propName: Sets the property to be used in FromProp playback mode.
+ @type propName: string
+ @ivar blendTime: Sets the internal frame timer. This property must be in
+ the range from 0.0 to blendin.
+ @type blendTime: float
+ @ivar mode: The operation mode of the actuator.
+ KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER,
+ KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ @type mode: integer
+ @ivar framePropName: The name of the property that is set to the current frame number.
+ @type framePropName: string
+
+ """
+#{ Deprecated
+ def setAction(action, reset = True):
+ """
+ Sets the current action.
+
+ @deprecated: use the L{action} property
+ @param action: The name of the action to set as the current action.
+ @type action: string
+ @param reset: Optional parameter indicating whether to reset the
+ blend timer or not. A value of 1 indicates that the
+ timer should be reset. A value of 0 will leave it
+ unchanged. If reset is not specified, the timer will
+ be reset.
+ """
+
+ def setStart(start):
+ """
+ Specifies the starting frame of the animation.
+
+ @deprecated: use the L{frameStart} property
+ @param start: the starting frame of the animation
+ @type start: float
+ """
+
+ def setEnd(end):
+ """
+ Specifies the ending frame of the animation.
+
+ @deprecated: use the L{frameEnd} property
+ @param end: the ending frame of the animation
+ @type end: float
+ """
+ def setBlendin(blendin):
+ """
+ Specifies the number of frames of animation to generate
+ when making transitions between actions.
+
+ @deprecated: use the L{blendIn} property
+ @param blendin: the number of frames in transition.
+ @type blendin: float
+ """
+
+ def setPriority(priority):
+ """
+ Sets the priority of this actuator.
+
+ @deprecated: use the L{priority} property
+ @param priority: Specifies the new priority. Actuators will lower
+ priority numbers will override actuators with higher
+ numbers.
+ @type priority: integer
+ """
+ def setFrame(frame):
+ """
+ Sets the current frame for the animation.
+
+ @deprecated: use the L{frame} property
+ @param frame: Specifies the new current frame for the animation
+ @type frame: float
+ """
+
+ def setProperty(prop):
+ """
+ Sets the property to be used in FromProp playback mode.
+
+ @deprecated: use the L{property} property
+ @param prop: the name of the property to use.
+ @type prop: string.
+ """
+
+ def setBlendtime(blendtime):
+ """
+ Sets the internal frame timer.
+
+ Allows the script to directly modify the internal timer
+ used when generating transitions between actions.
+
+ @deprecated: use the L{blendTime} property
+ @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0.
+ @type blendtime: float
+ """
+
+ def setType(mode):
+ """
+ Sets the operation mode of the actuator
+
+ @deprecated: use the L{type} property
+ @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ @type mode: integer
+ """
+
+ def getType():
+ """
+ Returns the operation mode of the actuator
+
+ @deprecated: use the L{type} property
+ @rtype: integer
+ @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ """
+
+ def getAction():
+ """
+ getAction() returns the name of the action associated with this actuator.
+
+ @deprecated: use the L{action} property
+ @rtype: string
+ """
+
+ def getStart():
+ """
+ Returns the starting frame of the action.
+
+ @deprecated: use the L{frameStart} property
+ @rtype: float
+ """
+ def getEnd():
+ """
+ Returns the last frame of the action.
+
+ @deprecated: use the L{frameEnd} property
+ @rtype: float
+ """
+ def getBlendin():
+ """
+ Returns the number of interpolation animation frames to be generated when this actuator is triggered.
+
+ @deprecated: use the L{blendIn} property
+ @rtype: float
+ """
+ def getPriority():
+ """
+ Returns the priority for this actuator. Actuators with lower Priority numbers will
+ override actuators with higher numbers.
+
+ @deprecated: use the L{priority} property
+ @rtype: integer
+ """
+ def getFrame():
+ """
+ Returns the current frame number.
+
+ @deprecated: use the L{frame} property
+ @rtype: float
+ """
+ def getProperty():
+ """
+ Returns the name of the property to be used in FromProp mode.
+
+ @deprecated: use the L{property} property
+ @rtype: string
+ """
+ def setFrameProperty(prop):
+ """
+ @deprecated: use the L{framePropName} property
+ @param prop: A string specifying the property of the object that will be updated with the action frame number.
+ @type prop: string
+ """
+ def getFrameProperty():
+ """
+ Returns the name of the property that is set to the current frame number.
+
+ @deprecated: use the L{framePropName} property
+ @rtype: string
+ """
+#}
+
+class CListValue(CPropValue):
+ """
+ CListValue
+
+ This is a list like object used in the game engine internally that behaves similar to a python list in most ways.
+
+ As well as the normal index lookup.
+ C{val= clist[i]}
+
+ CListValue supports string lookups.
+ C{val= scene.objects["OBCube"]}
+
+ Other operations such as C{len(clist), list(clist), clist[0:10]} are also supported.
+ """
+ def append(val):
+ """
+ Add an item to the list (like pythons append)
+
+ Warning: Appending values to the list can cause crashes when the list is used internally by the game engine.
+ """
+
+ def count(val):
+ """
+ Count the number of instances of a value in the list.
+
+ @rtype: integer
+ @return: number of instances
+ """
+ def index(val):
+ """
+ Return the index of a value in the list.
+
+ @rtype: integer
+ @return: The index of the value in the list.
+ """
+ def reverse():
+ """
+ Reverse the order of the list.
+ """
+ def get(key, default=None):
+ """
+ Return the value matching key, or the default value if its not found.
+ @return: The key value or a default.
+ """
+ def has_key(key):
+ """
+ Return True if the key is found.
+ @rtype: boolean
+ @return: The key value or a default.
+ """
+ def from_id(id):
+ """
+ This is a funtion especially for the game engine to return a value with a spesific id.
+
+ Since object names are not always unique, the id of an object can be used to get an object from the CValueList.
+
+ Example.
+
+ C{myObID = id(gameObject)}
+
+ C{...}
+
+ C{ob= scene.objects.from_id(myObID)}
+
+ Where myObID is an int or long from the id function.
+
+ This has the advantage that you can store the id in places you could not store a gameObject.
+
+ Warning: the id is derived from a memory location and will be different each time the game engine starts.
+ """
+
+class KX_BlenderMaterial(PyObjectPlus): # , RAS_IPolyMaterial)
+ """
+ KX_BlenderMaterial
+
+ """
+
+ def getShader():
+ """
+ Returns the material's shader.
+
+ @rtype: L{BL_Shader}
+ @return: the material's shader
+ """
+
+ def setBlending(src, dest):
+ """
+ Set the pixel color arithmetic functions.
+
+ @param src: Specifies how the red, green, blue,
+ and alpha source blending factors are computed.
+ @type src: GL_ZERO,
+ GL_ONE,
+ GL_SRC_COLOR,
+ GL_ONE_MINUS_SRC_COLOR,
+ GL_DST_COLOR,
+ GL_ONE_MINUS_DST_COLOR,
+ GL_SRC_ALPHA,
+ GL_ONE_MINUS_SRC_ALPHA,
+ GL_DST_ALPHA,
+ GL_ONE_MINUS_DST_ALPHA,
+ GL_SRC_ALPHA_SATURATE
+
+
+ @param dest: Specifies how the red, green, blue,
+ and alpha destination blending factors are computed.
+ @type dest: GL_ZERO,
+ GL_ONE,
+ GL_SRC_COLOR,
+ GL_ONE_MINUS_SRC_COLOR,
+ GL_DST_COLOR,
+ GL_ONE_MINUS_DST_COLOR,
+ GL_SRC_ALPHA,
+ GL_ONE_MINUS_SRC_ALPHA,
+ GL_DST_ALPHA,
+ GL_ONE_MINUS_DST_ALPHA,
+ GL_SRC_ALPHA_SATURATE
+
+ """
+ def getMaterialIndex():
+ """
+ Returns the material's index.
+
+ @rtype: integer
+ @return: the material's index
+ """
+
+class KX_CDActuator(SCA_IActuator):
+ """
+ CD Controller actuator.
+ @ivar volume: controls the volume to set the CD to. 0.0 = silent, 1.0 = max volume.
+ @type volume: float
+ @ivar track: the track selected to be played
+ @type track: integer
+ @ivar gain: the gain (volume) of the CD between 0.0 and 1.0.
+ @type gain: float
+ """
+ def startCD():
+ """
+ Starts the CD playing.
+ """
+ def stopCD():
+ """
+ Stops the CD playing.
+ """
+ def pauseCD():
+ """
+ Pauses the CD.
+ """
+ def resumeCD():
+ """
+ Resumes the CD after a pause.
+ """
+ def playAll():
+ """
+ Plays the CD from the beginning.
+ """
+ def playTrack(trackNumber):
+ """
+ Plays the track selected.
+ """
+#{ Deprecated
+ def setGain(gain):
+ """
+ Sets the gain (volume) of the CD.
+
+ @deprecated: Use the L{volume} property.
+ @type gain: float
+ @param gain: the gain to set the CD to. 0.0 = silent, 1.0 = max volume.
+ """
+ def getGain():
+ """
+ Gets the current gain (volume) of the CD.
+
+ @deprecated: Use the L{volume} property.
+ @rtype: float
+ @return: Between 0.0 (silent) and 1.0 (max volume)
+ """
+#}
+
+class KX_CameraActuator(SCA_IActuator):
+ """
+ Applies changes to a camera.
+
+ @ivar min: minimum distance to the target object maintained by the actuator
+ @type min: float
+ @ivar max: maximum distance to stay from the target object
+ @type max: float
+ @ivar height: height to stay above the target object
+ @type height: float
+ @ivar useXY: axis this actuator is tracking, true=X, false=Y
+ @type useXY: boolean
+ @ivar object: the object this actuator tracks.
+ @type object: KX_GameObject or None
+ @author: snail
+ """
+#{ Deprecated
+ def getObject(name_only = 1):
+ """
+ Returns the name of the object this actuator tracks.
+
+ @deprecated: Use the L{object} attribute instead.
+ @type name_only: bool
+ @param name_only: optional argument, when 0 return a KX_GameObject
+ @rtype: string, KX_GameObject or None if no object is set
+ """
+
+ def setObject(target):
+ """
+ Sets the object this actuator tracks.
+
+ @deprecated: Use the L{object} attribute instead.
+ @param target: the object to track.
+ @type target: L{KX_GameObject}, string or None
+ """
+
+ def getMin():
+ """
+ Returns the minimum distance to target maintained by the actuator.
+
+ @deprecated: Use the L{min} attribute instead.
+ @rtype: float
+ """
+
+ def setMin(distance):
+ """
+ Sets the minimum distance to the target object maintained by the
+ actuator.
+
+ @deprecated: Use the L{min} attribute instead.
+ @param distance: The minimum distance to maintain.
+ @type distance: float
+ """
+
+ def getMax():
+ """
+ Gets the maximum distance to stay from the target object.
+
+ @deprecated: Use the L{max} attribute instead.
+ @rtype: float
+ """
+
+ def setMax(distance):
+ """
+ Sets the maximum distance to stay from the target object.
+
+ @deprecated: Use the L{max} attribute instead.
+ @param distance: The maximum distance to maintain.
+ @type distance: float
+ """
+
+ def getHeight():
+ """
+ Returns the height to stay above the target object.
+
+ @deprecated: Use the L{height} attribute instead.
+ @rtype: float
+ """
+
+ def setHeight(height):
+ """
+ Sets the height to stay above the target object.
+
+ @deprecated: Use the L{height} attribute instead.
+ @type height: float
+ @param height: The height to stay above the target object.
+ """
+
+ def setXY(xaxis):
+ """
+ Sets the axis to get behind.
+
+ @deprecated: Use the L{useXY} attribute instead.
+ @param xaxis: False to track Y axis, True to track X axis.
+ @type xaxis: boolean
+ """
+
+ def getXY():
+ """
+ Returns the axis this actuator is tracking.
+
+ @deprecated: Use the L{useXY} attribute instead.
+ @return: True if tracking X axis, False if tracking Y axis.
+ @rtype: boolean
+ """
+#}
+
+class KX_ConstraintActuator(SCA_IActuator):
+ """
+ A constraint actuator limits the position, rotation, distance or orientation of an object.
+
+ Properties:
+
+ @ivar damp: time constant of the constraint expressed in frame (not use by Force field constraint)
+ @type damp: integer
+
+ @ivar rotDamp: time constant for the rotation expressed in frame (only for the distance constraint)
+ 0 = use damp for rotation as well
+ @type rotDamp: integer
+
+ @ivar direction: the reference direction in world coordinate for the orientation constraint
+ @type direction: 3-tuple of float: [x,y,z]
+
+ @ivar option: Binary combination of the following values:
+ Applicable to Distance constraint:
+ - KX_ACT_CONSTRAINT_NORMAL ( 64) : Activate alignment to surface
+ - KX_ACT_CONSTRAINT_DISTANCE ( 512) : Activate distance control
+ - KX_ACT_CONSTRAINT_LOCAL (1024) : direction of the ray is along the local axis
+ Applicable to Force field constraint:
+ - KX_ACT_CONSTRAINT_DOROTFH (2048) : Force field act on rotation as well
+ Applicable to both:
+ - KX_ACT_CONSTRAINT_MATERIAL ( 128) : Detect material rather than property
+ - KX_ACT_CONSTRAINT_PERMANENT ( 256) : No deactivation if ray does not hit target
+ @type option: integer
+
+ @ivar time: activation time of the actuator. The actuator disables itself after this many frame.
+ If set to 0, the actuator is not limited in time.
+ @type time: integer
+
+ @ivar propName: the name of the property or material for the ray detection of the distance constraint.
+ @type propName: string
+
+ @ivar min: The lower bound of the constraint
+ For the rotation and orientation constraint, it represents radiant
+ @type min: float
+
+ @ivar distance: the target distance of the distance constraint
+ @type distance: float
+
+ @ivar max: the upper bound of the constraint.
+ For rotation and orientation constraints, it represents radiant.
+ @type max: float
+
+ @ivar rayLength: the length of the ray of the distance constraint.
+ @type rayLength: float
+
+ @ivar limit: type of constraint, use one of the following constant:
+ KX_ACT_CONSTRAINT_LOCX ( 1) : limit X coord
+ KX_ACT_CONSTRAINT_LOCY ( 2) : limit Y coord
+ KX_ACT_CONSTRAINT_LOCZ ( 3) : limit Z coord
+ KX_ACT_CONSTRAINT_ROTX ( 4) : limit X rotation
+ KX_ACT_CONSTRAINT_ROTY ( 5) : limit Y rotation
+ KX_ACT_CONSTRAINT_ROTZ ( 6) : limit Z rotation
+ KX_ACT_CONSTRAINT_DIRPX ( 7) : set distance along positive X axis
+ KX_ACT_CONSTRAINT_DIRPY ( 8) : set distance along positive Y axis
+ KX_ACT_CONSTRAINT_DIRPZ ( 9) : set distance along positive Z axis
+ KX_ACT_CONSTRAINT_DIRNX (10) : set distance along negative X axis
+ KX_ACT_CONSTRAINT_DIRNY (11) : set distance along negative Y axis
+ KX_ACT_CONSTRAINT_DIRNZ (12) : set distance along negative Z axis
+ KX_ACT_CONSTRAINT_ORIX (13) : set orientation of X axis
+ KX_ACT_CONSTRAINT_ORIY (14) : set orientation of Y axis
+ KX_ACT_CONSTRAINT_ORIZ (15) : set orientation of Z axis
+ KX_ACT_CONSTRAINT_FHPX (16) : set force field along positive X axis
+ KX_ACT_CONSTRAINT_FHPY (17) : set force field along positive Y axis
+ KX_ACT_CONSTRAINT_FHPZ (18) : set force field along positive Z axis
+ KX_ACT_CONSTRAINT_FHNX (19) : set force field along negative X axis
+ KX_ACT_CONSTRAINT_FHNY (20) : set force field along negative Y axis
+ KX_ACT_CONSTRAINT_FHNZ (21) : set force field along negative Z axis
+ @type limit: integer
+ """
+#{ Deprecated
+ def setDamp(time):
+ """
+ Sets the time this constraint is delayed.
+
+ @param time: The number of frames to delay.
+ Negative values are ignored.
+ @type time: integer
+ """
+ def getDamp():
+ """
+ Returns the damping time of the constraint.
+
+ @rtype: integer
+ """
+ def setMin(lower):
+ """
+ Sets the lower bound of the constraint.
+
+ For rotational and orientation constraints, lower is specified in degrees.
+
+ @type lower: float
+ """
+ def getMin():
+ """
+ Gets the lower bound of the constraint.
+
+ For rotational and orientation constraints, the lower bound is returned in radians.
+
+ @rtype: float
+ """
+ def setMax(upper):
+ """
+ Sets the upper bound of the constraint.
+
+ For rotational and orientation constraints, upper is specified in degrees.
+
+ @type upper: float
+ """
+ def getMax():
+ """
+ Gets the upper bound of the constraint.
+
+ For rotational and orientation constraints, the upper bound is returned in radians.
+
+ @rtype: float
+ """
+ def setLimit(limit):
+ """
+ Sets the type of constraint.
+
+ See module L{GameLogic} for valid constraint types.
+
+ @param limit:
+ Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ
+ Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ
+ Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ
+ Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ
+ """
+ def getLimit():
+ """
+ Gets the type of constraint.
+
+ See module L{GameLogic} for valid constraints.
+
+ @return:
+ Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ,
+ Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ,
+ Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ,
+ Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ
+ """
+ def setRotDamp(duration):
+ """
+ Sets the time constant of the orientation constraint.
+
+ @param duration: If the duration is negative, it is set to 0.
+ @type duration: integer
+ """
+ def getRotDamp():
+ """
+ Returns the damping time for application of the constraint.
+
+ @rtype: integer
+ """
+ def setDirection(vector):
+ """
+ Sets the reference direction in world coordinate for the orientation constraint
+
+ @type vector: 3-tuple
+ """
+ def getDirection():
+ """
+ Returns the reference direction of the orientation constraint in world coordinate.
+
+ @rtype: 3-tuple
+ """
+ def setOption(option):
+ """
+ Sets several options of the distance constraint.
+
+ @type option: integer
+ @param option: Binary combination of the following values:
+ 64 : Activate alignment to surface
+ 128 : Detect material rather than property
+ 256 : No deactivation if ray does not hit target
+ 512 : Activate distance control
+ """
+ def getOption():
+ """
+ Returns the option parameter.
+
+ @rtype: integer
+ """
+ def setTime(duration):
+ """
+ Sets the activation time of the actuator.
+
+ @type duration: integer
+ @param duration: The actuator disables itself after this many frame.
+ If set to 0 or negative, the actuator is not limited in time.
+ """
+ def getTime():
+ """
+ Returns the time parameter.
+
+ @rtype: integer
+ """
+ def setProperty(property):
+ """
+ Sets the name of the property or material for the ray detection of the distance constraint.
+
+ @type property: string
+ @param property: If empty, the ray will detect any collisioning object.
+ """
+ def getProperty():
+ """
+ Returns the property parameter.
+
+ @rtype: string
+ """
+ def setDistance(distance):
+ """
+ Sets the target distance in distance constraint.
+
+ @type distance: float
+ """
+ def getDistance():
+ """
+ Returns the distance parameter.
+
+ @rtype: float
+ """
+ def setRayLength(length):
+ """
+ Sets the maximum ray length of the distance constraint.
+
+ @type length: float
+ """
+ def getRayLength():
+ """
+ Returns the length of the ray
+
+ @rtype: float
+ """
+#}
+
+class KX_ConstraintWrapper(PyObjectPlus):
+ """
+ KX_ConstraintWrapper
+
+ """
+ def getConstraintId(val):
+ """
+ Returns the contraint's ID
+
+ @rtype: integer
+ @return: the constraint's ID
+ """
+
+class KX_GameActuator(SCA_IActuator):
+ """
+ The game actuator loads a new .blend file, restarts the current .blend file or quits the game.
+
+ Properties:
+
+ @ivar fileName: the new .blend file to load
+ @type fileName: string.
+ @ivar mode: The mode of this actuator
+ @type mode: Constant in...
+ - L{GameLogic.KX_GAME_LOAD}
+ - L{GameLogic.KX_GAME_START}
+ - L{GameLogic.KX_GAME_RESTART}
+ - L{GameLogic.KX_GAME_QUIT}
+ - L{GameLogic.KX_GAME_SAVECFG}
+ - L{GameLogic.KX_GAME_LOADCFG}
+ """
+#{ Deprecated
+ def getFile():
+ """
+ Returns the filename of the new .blend file to load.
+
+ @deprecated: use the L{fileName} property
+ @rtype: string
+ """
+ def setFile(filename):
+ """
+ Sets the new .blend file to load.
+
+ @deprecated: use the L{fileName} property
+ @param filename: The file name this actuator will load.
+ @type filename: string
+ """
+#}
+
+class KX_GameObject(SCA_IObject):
+ """
+ All game objects are derived from this class.
+
+ Properties assigned to game objects are accessible as attributes of this class.
+ - note: Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError, if an object may have been removed since last accessing it use the L{invalid} attribute to check.
+
+ @ivar name: The object's name. (read-only)
+ - note: Currently (Blender 2.49) the prefix "OB" is added to all objects name. This may change in blender 2.5.
+ @type name: string.
+ @ivar mass: The object's mass
+ - note: The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0
+ @type mass: float
+ @ivar linVelocityMin: Enforces the object keeps moving at a minimum velocity.
+ - note: Applies to dynamic and rigid body objects only.
+ - note: A value of 0.0 disables this option.
+ - note: While objects are stationary the minimum velocity will not be applied.
+ @type linVelocityMin: float
+ @ivar linVelocityMax: Clamp the maximum linear velocity to prevent objects moving beyond a set speed.
+ - note: Applies to dynamic and rigid body objects only.
+ - note: A value of 0.0 disables this option (rather then setting it stationary).
+ @type linVelocityMax: float
+ @ivar localInertia: the object's inertia vector in local coordinates. Read only.
+ @type localInertia: list [ix, iy, iz]
+ @ivar parent: The object's parent object. (read-only)
+ @type parent: L{KX_GameObject} or None
+ @ivar visible: visibility flag.
+ - note: Game logic will still run for invisible objects.
+ @type visible: boolean
+ @ivar occlusion: occlusion capability flag.
+ @type occlusion: boolean
+ @ivar position: The object's position.
+
+ deprecated: use L{localPosition} and L{worldPosition}
+ @type position: list [x, y, z] On write: local position, on read: world position
+ @ivar orientation: The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
+
+ deprecated: use L{localOrientation} and L{worldOrientation}
+ @type orientation: 3x3 Matrix [[float]] On write: local orientation, on read: world orientation
+ @ivar scaling: The object's scaling factor. list [sx, sy, sz]
+
+ deprecated: use L{localScale} and L{worldScale}
+ @type scaling: list [sx, sy, sz] On write: local scaling, on read: world scaling
+ @ivar localOrientation: The object's local orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
+ @type localOrientation: 3x3 Matrix [[float]]
+ @ivar worldOrientation: The object's world orientation.
+ @type worldOrientation: 3x3 Matrix [[float]]
+ @ivar localScale: The object's local scaling factor.
+ @type localScale: list [sx, sy, sz]
+ @ivar worldScale: The object's world scaling factor. Read-only
+ @type worldScale: list [sx, sy, sz]
+ @ivar localPosition: The object's local position.
+ @type localPosition: list [x, y, z]
+ @ivar worldPosition: The object's world position.
+ @type worldPosition: list [x, y, z]
+ @ivar timeOffset: adjust the slowparent delay at runtime.
+ @type timeOffset: float
+ @ivar state: the game object's state bitmask, using the first 30 bits, one bit must always be set.
+ @type state: int
+ @ivar meshes: a list meshes for this object.
+ - note: Most objects use only 1 mesh.
+ - note: Changes to this list will not update the KX_GameObject.
+ @type meshes: list of L{KX_MeshProxy}
+ @ivar sensors: a sequence of L{SCA_ISensor} objects with string/index lookups and iterator support.
+ - note: This attribute is experemental and may be removed (but probably wont be).
+ - note: Changes to this list will not update the KX_GameObject.
+ @type sensors: list
+ @ivar controllers: a sequence of L{SCA_IController} objects with string/index lookups and iterator support.
+ - note: This attribute is experemental and may be removed (but probably wont be).
+ - note: Changes to this list will not update the KX_GameObject.
+ @type controllers: list of L{SCA_ISensor}.
+ @ivar actuators: a list of L{SCA_IActuator} with string/index lookups and iterator support.
+ - note: This attribute is experemental and may be removed (but probably wont be).
+ - note: Changes to this list will not update the KX_GameObject.
+ @type actuators: list
+ @ivar attrDict: get the objects internal python attribute dictionary for direct (faster) access.
+ @type attrDict: dict
+ @ivar children: direct children of this object, (read-only).
+ @type children: L{CListValue} of L{KX_GameObject}'s
+ @ivar childrenRecursive: all children of this object including childrens children, (read-only).
+ @type childrenRecursive: L{CListValue} of L{KX_GameObject}'s
+ @group Deprecated: getPosition, setPosition, setWorldPosition, getOrientation, setOrientation, getState, setState, getParent, getVisible, getMass, getMesh, getChildren, getChildrenRecursive
+ @group Property Access: get, has_key, attrDict, getPropertyNames
+ """
+ def endObject():
+ """
+ Delete this object, can be used inpace of the EndObject Actuator.
+ The actual removal of the object from the scene is delayed.
+ """
+ def replaceMesh(mesh):
+ """
+ Replace the mesh of this object with a new mesh. This works the same was as the actuator.
+ @type mesh: L{KX_MeshProxy} or mesh name
+ """
+ def getVisible():
+ """
+ Gets the game object's visible flag.
+
+ @deprecated: use L{visible}
+ @rtype: boolean
+ """
+ def setVisible(visible, recursive):
+ """
+ Sets the game object's visible flag.
+
+ @type visible: boolean
+ @type recursive: boolean
+ @param recursive: optional argument to set all childrens visibility flag too.
+ """
+ def setOcclusion(occlusion, recursive):
+ """
+ Sets the game object's occlusion capability.
+
+ @type occlusion: boolean
+ @type recursive: boolean
+ @param recursive: optional argument to set all childrens occlusion flag too.
+ """
+ def getState():
+ """
+ Gets the game object's state bitmask.
+
+ @deprecated: use L{state}
+ @rtype: int
+ @return: the objects state.
+ """
+ def setState(state):
+ """
+ Sets the game object's state flag.
+ The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
+ @deprecated: use L{state}
+ @type state: integer
+ """
+ def setPosition(pos):
+ """
+ Sets the game object's position.
+ Global coordinates for root object, local for child objects.
+
+ @deprecated: use L{localPosition}
+ @type pos: [x, y, z]
+ @param pos: the new position, in local coordinates.
+ """
+ def setWorldPosition(pos):
+ """
+ Sets the game object's position in world coordinates regardless if the object is root or child.
+
+ @deprecated: use L{worldPosition}
+ @type pos: [x, y, z]
+ @param pos: the new position, in world coordinates.
+ """
+ def getPosition():
+ """
+ Gets the game object's position.
+
+ @deprecated: use L{worldPosition}
+ @rtype: list [x, y, z]
+ @return: the object's position in world coordinates.
+ """
+ def setOrientation(orn):
+ """
+ Sets the game object's orientation.
+
+ @deprecated: use L{localOrientation}
+ @type orn: 3x3 rotation matrix, or Quaternion.
+ @param orn: a rotation matrix specifying the new rotation.
+ @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
+ """
+ def alignAxisToVect(vect, axis, factor):
+ """
+ Aligns any of the game object's axis along the given vector.
+
+ @type vect: 3d vector.
+ @param vect: a vector to align the axis.
+ @type axis: integer.
+ @param axis:The axis you want to align
+ - 0: X axis
+ - 1: Y axis
+ - 2: Z axis (default)
+ @type factor: float
+ @param factor: Only rotate a feaction of the distance to the target vector (0.0 - 1.0)
+ """
+ def getAxisVect(vect):
+ """
+ Returns the axis vector rotates by the objects worldspace orientation.
+ This is the equivalent if multiplying the vector by the orientation matrix.
+
+ @type vect: 3d vector.
+ @param vect: a vector to align the axis.
+ @rtype: 3d vector.
+ @return: The vector in relation to the objects rotation.
+
+ """
+ def getOrientation():
+ """
+ Gets the game object's orientation.
+
+ @deprecated: use L{worldOrientation}
+ @rtype: 3x3 rotation matrix
+ @return: The game object's rotation matrix
+ @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
+ """
+ def applyMovement(movement, local = 0):
+ """
+ Sets the game object's movement.
+
+ @type movement: 3d vector.
+ @param movement: movement vector.
+ @type local: boolean
+ @param local: - False: you get the "global" movement ie: relative to world orientation (default).
+ - True: you get the "local" movement ie: relative to object orientation.
+ """
+ def applyRotation(rotation, local = 0):
+ """
+ Sets the game object's rotation.
+
+ @type rotation: 3d vector.
+ @param rotation: rotation vector.
+ @type local: boolean
+ @param local: - False: you get the "global" rotation ie: relative to world orientation (default).
+ - True: you get the "local" rotation ie: relative to object orientation.
+ """
+ def applyForce(force, local = 0):
+ """
+ Sets the game object's force.
+
+ This requires a dynamic object.
+
+ @type force: 3d vector.
+ @param force: force vector.
+ @type local: boolean
+ @param local: - False: you get the "global" force ie: relative to world orientation (default).
+ - True: you get the "local" force ie: relative to object orientation.
+ """
+ def applyTorque(torque, local = 0):
+ """
+ Sets the game object's torque.
+
+ This requires a dynamic object.
+
+ @type torque: 3d vector.
+ @param torque: torque vector.
+ @type local: boolean
+ @param local: - False: you get the "global" torque ie: relative to world orientation (default).
+ - True: you get the "local" torque ie: relative to object orientation.
+ """
+ def getLinearVelocity(local = 0):
+ """
+ Gets the game object's linear velocity.
+
+ This method returns the game object's velocity through it's centre of mass,
+ ie no angular velocity component.
+
+ @type local: boolean
+ @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
+ - True: you get the "local" velocity ie: relative to object orientation.
+ @rtype: list [vx, vy, vz]
+ @return: the object's linear velocity.
+ """
+ def setLinearVelocity(velocity, local = 0):
+ """
+ Sets the game object's linear velocity.
+
+ This method sets game object's velocity through it's centre of mass,
+ ie no angular velocity component.
+
+ This requires a dynamic object.
+
+ @type velocity: 3d vector.
+ @param velocity: linear velocity vector.
+ @type local: boolean
+ @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
+ - True: you get the "local" velocity ie: relative to object orientation.
+ """
+ def getAngularVelocity(local = 0):
+ """
+ Gets the game object's angular velocity.
+
+ @type local: boolean
+ @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
+ - True: you get the "local" velocity ie: relative to object orientation.
+ @rtype: list [vx, vy, vz]
+ @return: the object's angular velocity.
+ """
+ def setAngularVelocity(velocity, local = 0):
+ """
+ Sets the game object's angular velocity.
+
+ This requires a dynamic object.
+
+ @type velocity: 3d vector.
+ @param velocity: angular velocity vector.
+ @type local: boolean
+ @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
+ - True: you get the "local" velocity ie: relative to object orientation.
+ """
+ def getVelocity(point):
+ """
+ Gets the game object's velocity at the specified point.
+
+ Gets the game object's velocity at the specified point, including angular
+ components.
+
+ @type point: list [x, y, z]
+ @param point: the point to return the velocity for, in local coordinates. (optional: default = [0, 0, 0])
+ @rtype: list [vx, vy, vz]
+ @return: the velocity at the specified point.
+ """
+ def getMass():
+ """
+ Gets the game object's mass.
+
+ @deprecated: use L{mass}
+ @rtype: float
+ @return: the object's mass.
+ """
+ def getReactionForce():
+ """
+ Gets the game object's reaction force.
+
+ The reaction force is the force applied to this object over the last simulation timestep.
+ This also includes impulses, eg from collisions.
+
+ (B{This is not implimented for bullet physics at the moment})
+
+ @rtype: list [fx, fy, fz]
+ @return: the reaction force of this object.
+ """
+ def applyImpulse(point, impulse):
+ """
+ Applies an impulse to the game object.
+
+ This will apply the specified impulse to the game object at the specified point.
+ If point != getPosition(), applyImpulse will also change the object's angular momentum.
+ Otherwise, only linear momentum will change.
+
+ @type point: list [x, y, z]
+ @param point: the point to apply the impulse to (in world coordinates)
+ """
+ def suspendDynamics():
+ """
+ Suspends physics for this object.
+ """
+ def restoreDynamics():
+ """
+ Resumes physics for this object.
+ @Note: The objects linear velocity will be applied from when the dynamics were suspended.
+ """
+ def enableRigidBody():
+ """
+ Enables rigid body physics for this object.
+
+ Rigid body physics allows the object to roll on collisions.
+ @Note: This is not working with bullet physics yet.
+ """
+ def disableRigidBody():
+ """
+ Disables rigid body physics for this object.
+ @Note: This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later.
+ """
+ def getParent():
+ """
+ Gets this object's parent.
+
+ @deprecated: use L{parent}
+ @rtype: L{KX_GameObject}
+ @return: this object's parent object, or None if this object has no parent.
+ """
+ def setParent(parent,compound,ghost):
+ """
+ Sets this object's parent.
+ Control the shape status with the optional compound and ghost parameters:
+ compound=1: the object shape should be added to the parent compound shape (default)
+ compound=0: the object should keep its individual shape.
+ In that case you can control if it should be ghost or not:
+ ghost=1 if the object should be made ghost while parented (default)
+ ghost=0 if the object should be solid while parented
+ Note: if the object type is sensor, it stays ghost regardless of ghost parameter
+
+ @type parent: L{KX_GameObject}
+ @param parent: new parent object.
+ @type compound: int
+ @param compound: whether the shape should be added to the parent compound shape
+ @type ghost: int
+ @param ghost: whether the object should be ghost while parented
+ """
+ def removeParent():
+ """
+ Removes this objects parent.
+ """
+ def getChildren():
+ """
+ Return a list of immediate children of this object.
+ @rtype: L{CListValue} of L{KX_GameObject}
+ @return: a list of all this objects children.
+ """
+ def getChildrenRecursive():
+ """
+ Return a list of children of this object, including all their childrens children.
+ @rtype: L{CListValue} of L{KX_GameObject}
+ @return: a list of all this objects children recursivly.
+ """
+ def getMesh(mesh):
+ """
+ Gets the mesh object for this object.
+
+ @type mesh: integer
+ @param mesh: the mesh object to return (optional: default mesh = 0)
+ @rtype: L{KX_MeshProxy}
+ @return: the first mesh object associated with this game object, or None if this object has no meshs.
+ """
+ def getPhysicsId():
+ """
+ Returns the user data object associated with this game object's physics controller.
+ """
+ def getPropertyNames():
+ """
+ Gets a list of all property names.
+ @rtype: list
+ @return: All property names for this object.
+ """
+ def getDistanceTo(other):
+ """
+ Returns the distance to another object or point.
+
+ @param other: a point or another L{KX_GameObject} to measure the distance to.
+ @type other: L{KX_GameObject} or list [x, y, z]
+ @rtype: float
+ """
+ def getVectTo(other):
+ """
+ Returns the vector and the distance to another object or point.
+ The vector is normalized unless the distance is 0, in which a NULL vector is returned.
+
+ @param other: a point or another L{KX_GameObject} to get the vector and distance to.
+ @type other: L{KX_GameObject} or list [x, y, z]
+ @rtype: 3-tuple (float, 3-tuple (x,y,z), 3-tuple (x,y,z))
+ @return: (distance, globalVector(3), localVector(3))
+ """
+ def rayCastTo(other,dist,prop):
+ """
+ Look towards another point/object and find first object hit within dist that matches prop.
+
+ The ray is always casted from the center of the object, ignoring the object itself.
+ The ray is casted towards the center of another object or an explicit [x,y,z] point.
+ Use rayCast() if you need to retrieve the hit point
+
+ @param other: [x,y,z] or object towards which the ray is casted
+ @type other: L{KX_GameObject} or 3-tuple
+ @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
+ @type dist: float
+ @param prop: property name that object must have; can be omitted => detect any object
+ @type prop: string
+ @rtype: L{KX_GameObject}
+ @return: the first object hit or None if no object or object does not match prop
+ """
+ def rayCast(objto,objfrom,dist,prop,face,xray,poly):
+ """
+ Look from a point/object to another point/object and find first object hit within dist that matches prop.
+ if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
+ if poly is 1, returns a 4-tuple with in addition a L{KX_PolyProxy} as 4th element.
+
+ Ex::
+ # shoot along the axis gun-gunAim (gunAim should be collision-free)
+ ob,point,normal = gun.rayCast(gunAim,None,50)
+ if ob:
+ # hit something
+
+ Notes:
+ The ray ignores the object on which the method is called.
+ It is casted from/to object center or explicit [x,y,z] points.
+
+ The face paremeter determines the orientation of the normal::
+ 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
+ 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
+
+ The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
+ The prop and xray parameters interact as follow::
+ prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
+ prop off, xray on : idem.
+ prop on, xray off: return closest hit if it matches prop, no hit otherwise.
+ prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
+ The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
+ If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
+
+ The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
+
+ @param objto: [x,y,z] or object to which the ray is casted
+ @type objto: L{KX_GameObject} or 3-tuple
+ @param objfrom: [x,y,z] or object from which the ray is casted; None or omitted => use self object center
+ @type objfrom: L{KX_GameObject} or 3-tuple or None
+ @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
+ @type dist: float
+ @param prop: property name that object must have; can be omitted or "" => detect any object
+ @type prop: string
+ @param face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
+ @type face: int
+ @param xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
+ @type xray: int
+ @param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy}
+ @type poly: int
+ @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz))
+ or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy})
+ @return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon)
+ If no hit, returns (None,None,None) or (None,None,None,None)
+ If the object hit is not a static mesh, polygon is None
+ """
+ def setCollisionMargin(margin):
+ """
+ Set the objects collision margin.
+
+ note: If this object has no physics controller (a physics ID of zero), this function will raise RuntimeError.
+
+ @type margin: float
+ @param margin: the collision margin distance in blender units.
+ """
+ def sendMessage(subject, body="", to=""):
+ """
+ Sends a message.
+
+ @param subject: The subject of the message
+ @type subject: string
+ @param body: The body of the message (optional)
+ @type body: string
+ @param to: The name of the object to send the message to (optional)
+ @type to: string
+ """
+ def get(key, default=None):
+ """
+ Return the value matching key, or the default value if its not found.
+ @return: The key value or a default.
+ """
+ def has_key(key):
+ """
+ Return True if the key is found.
+ @rtype: boolean
+ @return: The key value or a default.
+ """
+
+
+class KX_IpoActuator(SCA_IActuator):
+ """
+ IPO actuator activates an animation.
+
+ @ivar frameStart: Start frame.
+ @type frameStart: float
+ @ivar frameEnd: End frame.
+ @type frameEnd: float
+ @ivar propName: Use this property to define the Ipo position
+ @type propName: string
+ @ivar framePropName: Assign this property this action current frame number
+ @type framePropName: string
+ @ivar mode: Play mode for the ipo. (In GameLogic.KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND, KX_IPOACT_FROM_PROP)
+ @type mode: int
+ @ivar useIpoAsForce: Apply Ipo as a global or local force depending on the local option (dynamic objects only)
+ @type useIpoAsForce: bool
+ @ivar useIpoAdd: Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag
+ @type useIpoAdd: bool
+ @ivar useIpoLocal: Let the ipo acts in local coordinates, used in Force and Add mode.
+ @type useIpoLocal: bool
+ @ivar useChildren: Update IPO on all children Objects as well
+ @type useChildren: bool
+ """
+#{ Deprecated
+ def set(mode, startframe, endframe, force):
+ """
+ Sets the properties of the actuator.
+
+ @deprecated: use other attributes.
+ @param mode: "Play", "PingPong", "Flipper", "LoopStop", "LoopEnd" or "FromProp"
+ @type mode: string
+ @param startframe: first frame to use
+ @type startframe: integer
+ @param endframe: last frame to use
+ @type endframe: integer
+ @param force: special mode
+ @type force: integer (0=normal, 1=interpret location as force, 2=additive)
+ """
+ def setProperty(property):
+ """
+ Sets the name of the property to be used in FromProp mode.
+
+ @deprecated: use L{propName}
+ @type property: string
+ """
+ def setStart(startframe):
+ """
+ Sets the frame from which the IPO starts playing.
+
+ @deprecated: use L{frameStart}
+ @type startframe: integer
+ """
+ def getStart():
+ """
+ Returns the frame from which the IPO starts playing.
+
+ @deprecated: use L{frameStart}
+ @rtype: integer
+ """
+ def setEnd(endframe):
+ """
+ Sets the frame at which the IPO stops playing.
+
+ @deprecated: use L{frameEnd}
+ @type endframe: integer
+ """
+ def getEnd():
+ """
+ Returns the frame at which the IPO stops playing.
+
+ @deprecated: use L{frameEnd}
+ @rtype: integer
+ """
+ def setIpoAsForce(force):
+ """
+ Set whether to interpret the ipo as a force rather than a displacement.
+
+ @deprecated: use L{useIpoAsForce}
+ @type force: boolean
+ @param force: KX_TRUE or KX_FALSE
+ """
+ def getIpoAsForce():
+ """
+ Returns whether to interpret the ipo as a force rather than a displacement.
+
+ @deprecated: use L{useIpoAsForce}
+ @rtype: boolean
+ """
+ def setIpoAdd(add):
+ """
+ Set whether to interpret the ipo as additive rather than absolute.
+
+ @deprecated: use L{useIpoAdd}
+ @type add: boolean
+ @param add: KX_TRUE or KX_FALSE
+ """
+ def getIpoAdd():
+ """
+ Returns whether to interpret the ipo as additive rather than absolute.
+
+ @deprecated: use L{useIpoAdd}
+ @rtype: boolean
+ """
+ def setType(mode):
+ """
+ Sets the operation mode of the actuator.
+
+ @deprecated: use L{type}
+ @param mode: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
+ @type mode: string
+ """
+ def getType():
+ """
+ Returns the operation mode of the actuator.
+
+ @deprecated: use L{type}
+ @rtype: integer
+ @return: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
+ """
+ def setForceIpoActsLocal(local):
+ """
+ Set whether to apply the force in the object's local
+ coordinates rather than the world global coordinates.
+
+ @deprecated: use L{useIpoLocal}
+ @param local: Apply the ipo-as-force in the object's local
+ coordinates? (KX_TRUE, KX_FALSE)
+ @type local: boolean
+ """
+ def getForceIpoActsLocal():
+ """
+ Return whether to apply the force in the object's local
+ coordinates rather than the world global coordinates.
+
+ @deprecated: use L{useIpoLocal}
+ """
+#}
+
+class KX_LightObject(KX_GameObject):
+ """
+ A Light object.
+
+ Example:
+
+ # Turn on a red alert light.
+ import GameLogic
+
+ co = GameLogic.getCurrentController()
+ light = co.owner
+
+ light.energy = 1.0
+ light.colour = [1.0, 0.0, 0.0]
+
+ @group Constants: NORMAL, SPOT, SUN
+ @ivar SPOT: A spot light source. See attribute 'type'
+ @ivar SUN: A point light source with no attenuation. See attribute 'type'
+ @ivar NORMAL: A point light source. See attribute 'type'
+
+ @ivar type: The type of light - must be SPOT, SUN or NORMAL
+ @ivar layer: The layer mask that this light affects object on.
+ @type layer: bitfield
+ @ivar energy: The brightness of this light.
+ @type energy: float
+ @ivar distance: The maximum distance this light can illuminate. (SPOT and NORMAL lights only)
+ @type distance: float
+ @ivar colour: The colour of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0]
+ @type colour: list [r, g, b]
+ @ivar color: Synonym for colour.
+ @ivar lin_attenuation: The linear component of this light's attenuation. (SPOT and NORMAL lights only)
+ @type lin_attenuation: float
+ @ivar quad_attenuation: The quadratic component of this light's attenuation (SPOT and NORMAL lights only)
+ @type quad_attenuation: float
+ @ivar spotsize: The cone angle of the spot light, in degrees. (float) (SPOT lights only)
+ 0.0 <= spotsize <= 180.0. Spotsize = 360.0 is also accepted.
+ @ivar spotblend: Specifies the intensity distribution of the spot light. (float) (SPOT lights only)
+ Higher values result in a more focused light source.
+ 0.0 <= spotblend <= 1.0.
+
+ """
+
+class KX_MeshProxy(SCA_IObject):
+ """
+ A mesh object.
+
+ You can only change the vertex properties of a mesh object, not the mesh topology.
+
+ To use mesh objects effectively, you should know a bit about how the game engine handles them.
+ 1. Mesh Objects are converted from Blender at scene load.
+ 2. The Converter groups polygons by Material. This means they can be sent to the
+ renderer efficiently. A material holds:
+ 1. The texture.
+ 2. The Blender material.
+ 3. The Tile properties
+ 4. The face properties - (From the "Texture Face" panel)
+ 5. Transparency & z sorting
+ 6. Light layer
+ 7. Polygon shape (triangle/quad)
+ 8. Game Object
+ 3. Verticies will be split by face if necessary. Verticies can only be shared between
+ faces if:
+ 1. They are at the same position
+ 2. UV coordinates are the same
+ 3. Their normals are the same (both polygons are "Set Smooth")
+ 4. They are the same colour
+ For example: a cube has 24 verticies: 6 faces with 4 verticies per face.
+
+ The correct method of iterating over every L{KX_VertexProxy} in a game object::
+ import GameLogic
+
+ co = GameLogic.getCurrentController()
+ obj = co.owner
+
+ m_i = 0
+ mesh = obj.getMesh(m_i) # There can be more than one mesh...
+ while mesh != None:
+ for mat in range(mesh.getNumMaterials()):
+ for v_index in range(mesh.getVertexArrayLength(mat)):
+ vertex = mesh.getVertex(mat, v_index)
+ # Do something with vertex here...
+ # ... eg: colour the vertex red.
+ vertex.colour = [1.0, 0.0, 0.0, 1.0]
+ m_i += 1
+ mesh = obj.getMesh(m_i)
+
+ @ivar materials:
+ @type materials: list of L{KX_BlenderMaterial} or L{KX_PolygonMaterial} types
+
+ @ivar numPolygons:
+ @type numPolygons: integer
+
+ @ivar numMaterials:
+ @type numMaterials: integer
+ """
+
+ def getNumMaterials():
+ """
+ Gets the number of materials associated with this object.
+
+ @rtype: integer
+ """
+
+ def getMaterialName(matid):
+ """
+ Gets the name of the specified material.
+
+ @type matid: integer
+ @param matid: the specified material.
+ @rtype: string
+ @return: the attached material name.
+ """
+ def getTextureName(matid):
+ """
+ Gets the name of the specified material's texture.
+
+ @type matid: integer
+ @param matid: the specified material
+ @rtype: string
+ @return: the attached material's texture name.
+ """
+ def getVertexArrayLength(matid):
+ """
+ Gets the length of the vertex array associated with the specified material.
+
+ There is one vertex array for each material.
+
+ @type matid: integer
+ @param matid: the specified material
+ @rtype: integer
+ @return: the number of verticies in the vertex array.
+ """
+ def getVertex(matid, index):
+ """
+ Gets the specified vertex from the mesh object.
+
+ @type matid: integer
+ @param matid: the specified material
+ @type index: integer
+ @param index: the index into the vertex array.
+ @rtype: L{KX_VertexProxy}
+ @return: a vertex object.
+ """
+ def getNumPolygons():
+ """
+ Returns the number of polygon in the mesh.
+
+ @rtype: integer
+ """
+ def getPolygon(index):
+ """
+ Gets the specified polygon from the mesh.
+
+ @type index: integer
+ @param index: polygon number
+ @rtype: L{KX_PolyProxy}
+ @return: a polygon object.
+ """
+ def reinstancePhysicsMesh():
+ """
+ Updates the physics system with the changed mesh.
+
+ A mesh must have only one material with collision flags,
+ and have all collision primitives in one vertex array (ie. < 65535 verts) and
+ be either a polytope or polyheder mesh. If you don't get a warning in the
+ console when the collision type is polytope, the mesh is suitable for reinstance.
+ @bug: This currently does not work.
+ @rtype: boolean
+ @return: True if reinstance succeeded, False if it failed.
+ """
+
+class SCA_MouseSensor(SCA_ISensor):
+ """
+ Mouse Sensor logic brick.
+
+ Properties:
+
+ @ivar position: current [x,y] coordinates of the mouse, in frame coordinates (pixels)
+ @type position: [integer,interger]
+ @ivar mode: sensor mode: 1=KX_MOUSESENSORMODE_LEFTBUTTON 2=KX_MOUSESENSORMODE_MIDDLEBUTTON
+ 3=KX_MOUSESENSORMODE_RIGHTBUTTON 4=KX_MOUSESENSORMODE_WHEELUP
+ 5=KX_MOUSESENSORMODE_WHEELDOWN 9=KX_MOUSESENSORMODE_MOVEMENT
+ @type mode: integer
+ """
+
+ def getXPosition():
+ """
+ Gets the x coordinate of the mouse.
+
+ @deprecated: use the L{position} property
+ @rtype: integer
+ @return: the current x coordinate of the mouse, in frame coordinates (pixels)
+ """
+ def getYPosition():
+ """
+ Gets the y coordinate of the mouse.
+
+ @deprecated: use the L{position} property
+ @rtype: integer
+ @return: the current y coordinate of the mouse, in frame coordinates (pixels).
+ """
+ def getButtonStatus(button):
+ """
+ Get the mouse button status.
+
+ @type button: int
+ @param button: value in GameLogic members KX_MOUSE_BUT_LEFT, KX_MOUSE_BUT_MIDDLE, KX_MOUSE_BUT_RIGHT
+
+ @rtype: integer
+ @return: value in GameLogic members KX_INPUT_NONE, KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED
+ """
+
+class KX_MouseFocusSensor(SCA_MouseSensor):
+ """
+ The mouse focus sensor detects when the mouse is over the current game object.
+
+ The mouse focus sensor works by transforming the mouse coordinates from 2d device
+ space to 3d space then raycasting away from the camera.
+
+ @ivar raySource: The worldspace source of the ray (the view position)
+ @type raySource: list (vector of 3 floats)
+ @ivar rayTarget: The worldspace target of the ray.
+ @type rayTarget: list (vector of 3 floats)
+ @ivar rayDirection: The L{rayTarget} - L{raySource} normalized.
+ @type rayDirection: list (normalized vector of 3 floats)
+ @ivar hitObject: the last object the mouse was over.
+ @type hitObject: L{KX_GameObject} or None
+ @ivar hitPosition: The worldspace position of the ray intersecton.
+ @type hitPosition: list (vector of 3 floats)
+ @ivar hitNormal: the worldspace normal from the face at point of intersection.
+ @type hitNormal: list (normalized vector of 3 floats)
+ """
+#{ Deprecated
+ def getHitNormal():
+ """
+ Returns the normal (in worldcoordinates) at the point of collision where the object was hit by this ray.
+
+ @deprecated: use the L{hitNormal} property
+ @rtype: list [x, y, z]
+ @return: the ray collision normal.
+ """
+ def getHitObject():
+ """
+ Returns the object that was hit by this ray or None.
+
+ @deprecated: use the L{hitObject} property
+ @rtype: L{KX_GameObject} or None
+ @return: the collision object.
+ """
+ def getHitPosition():
+ """
+ Returns the position (in worldcoordinates) at the point of collision where the object was hit by this ray.
+
+ @deprecated: use the L{hitPosition} property
+ @rtype: list [x, y, z]
+ @return: the ray collision position.
+ """
+ def getRayDirection():
+ """
+ Returns the normalized direction (in worldcoordinates) of the ray cast by the mouse.
+
+ @deprecated: use the L{rayDirection} property
+ @rtype: list [x, y, z]
+ @return: the ray direction.
+ """
+ def getRaySource():
+ """
+ Returns the position (in worldcoordinates) the ray was cast from by the mouse.
+
+ @deprecated: use the L{raySource} property
+ @rtype: list [x, y, z]
+ @return: the ray source.
+ """
+ def getRayTarget():
+ """
+ Returns the target of the ray (in worldcoordinates) that seeks the focus object.
+
+ @deprecated: use the L{rayTarget} property
+ @rtype: list [x, y, z]
+ @return: the ray target.
+ """
+#}
+
+class KX_TouchSensor(SCA_ISensor):
+ """
+ Touch sensor detects collisions between objects.
+
+ @ivar propName: The property or material to collide with.
+ @type propName: string
+ @ivar useMaterial: Determines if the sensor is looking for a property or material.
+ KX_True = Find material; KX_False = Find property
+ @type useMaterial: boolean
+ @ivar usePulseCollision: The last collided object.
+ @type usePulseCollision: bool
+ @ivar hitObject: The last collided object. (read-only)
+ @type hitObject: L{KX_GameObject} or None
+ @ivar hitObjectList: A list of colliding objects. (read-only)
+ @type hitObjectList: L{CListValue} of L{KX_GameObject}
+ """
+#{ Deprecated
+ def setProperty(name):
+ """
+ Set the property or material to collide with. Use
+ setTouchMaterial() to switch between properties and
+ materials.
+
+ @deprecated: use the L{property} property
+ @type name: string
+ """
+
+ def getProperty():
+ """
+ Returns the property or material to collide with. Use
+ getTouchMaterial() to find out whether this sensor
+ looks for properties or materials.
+
+ @deprecated: use the L{property} property
+ @rtype: string
+ """
+ def getHitObject():
+ """
+ Returns the last object hit by this touch sensor.
+
+ @deprecated: use the L{hitObject} property
+ @rtype: L{KX_GameObject}
+ """
+ def getHitObjectList():
+ """
+ Returns a list of all objects hit in the last frame. (B{deprecated})
+
+ Only objects that have the requisite material/property are listed.
+
+ @deprecated: use the L{hitObjectList} property
+ @rtype: L{CListValue} of L{hitObjectList}
+ """
+ def getTouchMaterial():
+ """
+ Returns KX_TRUE if this sensor looks for a specific material,
+ KX_FALSE if it looks for a specific property. (B{deprecated})
+
+ @deprecated: use the L{useMaterial} property
+ """
+#}
+
+class KX_NearSensor(KX_TouchSensor):
+ """
+ A near sensor is a specialised form of touch sensor.
+
+ @ivar distance: The near sensor activates when an object is within this distance.
+ @type distance: float
+ @ivar resetDistance: The near sensor deactivates when the object exceeds this distance.
+ @type resetDistance: float
+ """
+
+class KX_NetworkMessageActuator(SCA_IActuator):
+ """
+ Message Actuator
+
+ @ivar propName: Messages will only be sent to objects with the given property name.
+ @type propName: string
+ @ivar subject: The subject field of the message.
+ @type subject: string
+ @ivar body: The body of the message.
+ @type body: string
+ @ivar usePropBody: Send a property instead of a regular body message.
+ @type usePropBody: boolean
+ """
+#{Deprecated
+ def setToPropName(name):
+ """
+ Messages will only be sent to objects with the given property name.
+
+ @deprecated: Use the L{propName} attribute instead.
+ @type name: string
+ """
+ def setSubject(subject):
+ """
+ Sets the subject field of the message.
+
+ @deprecated: Use the L{subject} attribute instead.
+ @type subject: string
+ """
+ def setBodyType(bodytype):
+ """
+ Sets the type of body to send.
+
+ @deprecated: Use the L{usePropBody} attribute instead.
+ @type bodytype: boolean
+ @param bodytype: True to send the value of a property, False to send the body text.
+ """
+ def setBody(body):
+ """
+ Sets the message body.
+
+ @deprecated: Use the L{body} attribute instead.
+ @type body: string
+ @param body: if the body type is True, this is the name of the property to send.
+ if the body type is False, this is the text to send.
+ """
+#}
+
+class KX_NetworkMessageSensor(SCA_ISensor):
+ """
+ The Message Sensor logic brick.
+
+ Currently only loopback (local) networks are supported.
+
+ @ivar subject: The subject the sensor is looking for.
+ @type subject: string
+ @ivar frameMessageCount: The number of messages received since the last frame.
+ (Read-only)
+ @type frameMessageCount: int
+ @ivar subjects: The list of message subjects received. (Read-only)
+ @type subjects: list of strings
+ @ivar bodies: The list of message bodies received. (Read-only)
+ @type bodies: list of strings
+ """
+#{ Deprecated
+ def setSubjectFilterText(subject):
+ """
+ Change the message subject text that this sensor is listening to.
+
+ @deprecated: Use the L{subject} attribute instead.
+ @type subject: string
+ @param subject: the new message subject to listen for.
+ """
+
+ def getFrameMessageCount():
+ """
+ Get the number of messages received since the last frame.
+
+ @deprecated: Use the L{frameMessageCount} attribute instead.
+ @rtype: integer
+ """
+ def getBodies():
+ """
+ Gets the list of message bodies.
+
+ @deprecated: Use the L{bodies} attribute instead.
+ @rtype: list
+ """
+ def getSubject():
+ """
+ Gets the message subject this sensor is listening for from the Subject: field.
+
+ @deprecated: Use the L{subject} attribute instead.
+ @rtype: string
+ """
+ def getSubjects():
+ """
+ Gets the list of message subjects received.
+
+ @deprecated: Use the L{subjects} attribute instead.
+ @rtype: list
+ """
+#}
+
+class KX_ObjectActuator(SCA_IActuator):
+ """
+ The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement,
+ velocity, or angular velocity to an object.
+ Servo control allows to regulate force to achieve a certain speed target.
+
+ @ivar force: The force applied by the actuator
+ @type force: list [x, y, z]
+ @ivar useLocalForce: A flag specifying if the force is local
+ @type useLocalForce: bool
+ @ivar torque: The torque applied by the actuator
+ @type torque: list [x, y, z]
+ @ivar useLocalTorque: A flag specifying if the torque is local
+ @type useLocalTorque: bool
+ @ivar dLoc: The displacement vector applied by the actuator
+ @type dLoc: list [x, y, z]
+ @ivar useLocalDLoc: A flag specifying if the dLoc is local
+ @type useLocalDLoc: bool
+ @ivar dRot: The angular displacement vector applied by the actuator
+ - note: Since the displacement is applied every frame, you must adjust the displacement
+ based on the frame rate, or you game experience will depend on the player's computer
+ speed.
+ @type dRot: list [x, y, z]
+ @ivar useLocalDRot: A flag specifying if the dRot is local
+ @type useLocalDRot: bool
+ @ivar linV: The linear velocity applied by the actuator
+ @type linV: list [x, y, z]
+ @ivar useLocalLinV: A flag specifying if the linear velocity is local
+ - note: This is the target speed for servo controllers
+ @type useLocalLinV: bool
+ @ivar angV: The angular velocity applied by the actuator
+ @type angV: list [x, y, z]
+ @ivar useLocalAngV: A flag specifying if the angular velocity is local
+ @type useLocalAngV: bool
+
+ @ivar damping: The damping parameter of the servo controller
+ @type damping: short
+
+ @ivar forceLimitX: The min/max force limit along the X axis and activates or deactivates the limits in the servo controller
+ @type forceLimitX: list [min(float), max(float), bool]
+ @ivar forceLimitY: The min/max force limit along the Y axis and activates or deactivates the limits in the servo controller
+ @type forceLimitY: list [min(float), max(float), bool]
+ @ivar forceLimitZ: The min/max force limit along the Z axis and activates or deactivates the limits in the servo controller
+ @type forceLimitZ: list [min(float), max(float), bool]
+
+ @ivar pid: The PID coefficients of the servo controller
+ @type pid: list of floats [proportional, integral, derivate]
+ @ivar reference: The object that is used as reference to compute the velocity for the servo controller.
+ @type reference: KX_GameObject or None
+
+ @group Deprecated: getForce, setForce, getTorque, setTorque, getDLoc, setDLoc, getDRot, setDRot, getLinearVelocity, setLinearVelocity, getAngularVelocity,
+ setAngularVelocity, getDamping, setDamping, getForceLimitX, setForceLimitX, getForceLimitY, setForceLimitY, getForceLimitZ, setForceLimitZ,
+ getPID, setPID
+ """
+ def getForce():
+ """
+ Returns the force applied by the actuator.
+
+ @deprecated: Use L{force} and L{useLocalForce} instead.
+ @rtype: list [fx, fy, fz, local]
+ @return: A four item list, containing the vector force, and a flag specifying whether the force is local.
+ """
+ def setForce(fx, fy, fz, local):
+ """
+ Sets the force applied by the actuator.
+
+ @deprecated: Use L{force} and L{useLocalForce} instead.
+ @type fx: float
+ @param fx: the x component of the force.
+ @type fy: float
+ @param fy: the z component of the force.
+ @type fz: float
+ @param fz: the z component of the force.
+ @type local: boolean
+ @param local: - False: the force is applied in world coordinates.
+ - True: the force is applied in local coordinates.
+ """
+ def getTorque():
+ """
+ Returns the torque applied by the actuator.
+
+ @deprecated: Use L{torque} and L{useLocalTorque} instead.
+ @rtype: list [S{Tau}x, S{Tau}y, S{Tau}z, local]
+ @return: A four item list, containing the vector torque, and a flag specifying whether
+ the torque is applied in local coordinates (True) or world coordinates (False)
+ """
+ def setTorque(tx, ty, tz, local):
+ """
+ Sets the torque applied by the actuator.
+
+ @deprecated: Use L{torque} and L{useLocalTorque} instead.
+ @type tx: float
+ @param tx: the x component of the torque.
+ @type ty: float
+ @param ty: the z component of the torque.
+ @type tz: float
+ @param tz: the z component of the torque.
+ @type local: boolean
+ @param local: - False: the torque is applied in world coordinates.
+ - True: the torque is applied in local coordinates.
+ """
+ def getDLoc():
+ """
+ Returns the displacement vector applied by the actuator.
+
+ @deprecated: Use L{dLoc} and L{useLocalDLoc} instead.
+ @rtype: list [dx, dy, dz, local]
+ @return: A four item list, containing the vector displacement, and whether
+ the displacement is applied in local coordinates (True) or world
+ coordinates (False)
+ """
+ def setDLoc(dx, dy, dz, local):
+ """
+ Sets the displacement vector applied by the actuator.
+
+ Since the displacement is applied every frame, you must adjust the displacement
+ based on the frame rate, or you game experience will depend on the player's computer
+ speed.
+
+ @deprecated: Use L{dLoc} and L{useLocalDLoc} instead.
+ @type dx: float
+ @param dx: the x component of the displacement vector.
+ @type dy: float
+ @param dy: the z component of the displacement vector.
+ @type dz: float
+ @param dz: the z component of the displacement vector.
+ @type local: boolean
+ @param local: - False: the displacement vector is applied in world coordinates.
+ - True: the displacement vector is applied in local coordinates.
+ """
+ def getDRot():
+ """
+ Returns the angular displacement vector applied by the actuator.
+
+ @deprecated: Use L{dRot} and L{useLocalDRot} instead.
+ @rtype: list [dx, dy, dz, local]
+ @return: A four item list, containing the angular displacement vector, and whether
+ the displacement is applied in local coordinates (True) or world coordinates (False)
+ """
+ def setDRot(dx, dy, dz, local):
+ """
+ Sets the angular displacement vector applied by the actuator.
+
+ Since the displacement is applied every frame, you must adjust the displacement
+ based on the frame rate, or you game experience will depend on the player's computer
+ speed.
+
+ @deprecated: Use L{dRot} and L{useLocalDRot} instead.
+ @type dx: float
+ @param dx: the x component of the angular displacement vector.
+ @type dy: float
+ @param dy: the z component of the angular displacement vector.
+ @type dz: float
+ @param dz: the z component of the angular displacement vector.
+ @type local: boolean
+ @param local: - False: the angular displacement vector is applied in world coordinates.
+ - True: the angular displacement vector is applied in local coordinates.
+ """
+ def getLinearVelocity():
+ """
+ Returns the linear velocity applied by the actuator.
+ For the servo control actuator, this is the target speed.
+
+ @deprecated: Use L{linV} and L{useLocalLinV} instead.
+ @rtype: list [vx, vy, vz, local]
+ @return: A four item list, containing the vector velocity, and whether the velocity is applied in local coordinates (True) or world coordinates (False)
+ """
+ def setLinearVelocity(vx, vy, vz, local):
+ """
+ Sets the linear velocity applied by the actuator.
+ For the servo control actuator, sets the target speed.
+
+ @deprecated: Use L{linV} and L{useLocalLinV} instead.
+ @type vx: float
+ @param vx: the x component of the velocity vector.
+ @type vy: float
+ @param vy: the z component of the velocity vector.
+ @type vz: float
+ @param vz: the z component of the velocity vector.
+ @type local: boolean
+ @param local: - False: the velocity vector is in world coordinates.
+ - True: the velocity vector is in local coordinates.
+ """
+ def getAngularVelocity():
+ """
+ Returns the angular velocity applied by the actuator.
+
+ @deprecated: Use L{angV} and L{useLocalAngV} instead.
+ @rtype: list [S{omega}x, S{omega}y, S{omega}z, local]
+ @return: A four item list, containing the vector velocity, and whether
+ the velocity is applied in local coordinates (True) or world
+ coordinates (False)
+ """
+ def setAngularVelocity(wx, wy, wz, local):
+ """
+ Sets the angular velocity applied by the actuator.
+
+ @deprecated: Use L{angV} and L{useLocalAngV} instead.
+ @type wx: float
+ @param wx: the x component of the velocity vector.
+ @type wy: float
+ @param wy: the z component of the velocity vector.
+ @type wz: float
+ @param wz: the z component of the velocity vector.
+ @type local: boolean
+ @param local: - False: the velocity vector is applied in world coordinates.
+ - True: the velocity vector is applied in local coordinates.
+ """
+ def getDamping():
+ """
+ Returns the damping parameter of the servo controller.
+
+ @deprecated: Use L{damping} instead.
+ @rtype: integer
+ @return: the time constant of the servo controller in frame unit.
+ """
+ def setDamping(damp):
+ """
+ Sets the damping parameter of the servo controller.
+
+ @deprecated: Use L{damping} instead.
+ @type damp: integer
+ @param damp: the damping parameter in frame unit.
+ """
+ def getForceLimitX():
+ """
+ Returns the min/max force limit along the X axis used by the servo controller.
+
+ @deprecated: Use L{forceLimitX} instead.
+ @rtype: list [min, max, enabled]
+ @return: A three item list, containing the min and max limits of the force as float
+ and whether the limits are active(true) or inactive(true)
+ """
+ def setForceLimitX(min, max, enable):
+ """
+ Sets the min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
+
+ @deprecated: Use L{forceLimitX} instead.
+ @type min: float
+ @param min: the minimum value of the force along the X axis.
+ @type max: float
+ @param max: the maximum value of the force along the X axis.
+ @type enable: boolean
+ @param enable: - True: the force will be limited to the min/max
+ - False: the force will not be limited
+ """
+ def getForceLimitY():
+ """
+ Returns the min/max force limit along the Y axis used by the servo controller.
+
+ @deprecated: Use L{forceLimitY} instead.
+ @rtype: list [min, max, enabled]
+ @return: A three item list, containing the min and max limits of the force as float
+ and whether the limits are active(true) or inactive(true)
+ """
+ def setForceLimitY(min, max, enable):
+ """
+ Sets the min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
+
+ @deprecated: Use L{forceLimitY} instead.
+ @type min: float
+ @param min: the minimum value of the force along the Y axis.
+ @type max: float
+ @param max: the maximum value of the force along the Y axis.
+ @type enable: boolean
+ @param enable: - True: the force will be limited to the min/max
+ - False: the force will not be limited
+ """
+ def getForceLimitZ():
+ """
+ Returns the min/max force limit along the Z axis used by the servo controller.
+
+ @deprecated: Use L{forceLimitZ} instead.
+ @rtype: list [min, max, enabled]
+ @return: A three item list, containing the min and max limits of the force as float
+ and whether the limits are active(true) or inactive(true)
+ """
+ def setForceLimitZ(min, max, enable):
+ """
+ Sets the min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
+
+ @deprecated: Use L{forceLimitZ} instead.
+ @type min: float
+ @param min: the minimum value of the force along the Z axis.
+ @type max: float
+ @param max: the maximum value of the force along the Z axis.
+ @type enable: boolean
+ @param enable: - True: the force will be limited to the min/max
+ - False: the force will not be limited
+ """
+ def getPID():
+ """
+ Returns the PID coefficient of the servo controller.
+
+ @deprecated: Use L{pid} instead.
+ @rtype: list [P, I, D]
+ @return: A three item list, containing the PID coefficient as floats:
+ P : proportional coefficient
+ I : Integral coefficient
+ D : Derivate coefficient
+ """
+ def setPID(P, I, D):
+ """
+ Sets the PID coefficients of the servo controller.
+
+ @deprecated: Use L{pid} instead.
+ @type P: flat
+ @param P: proportional coefficient
+ @type I: float
+ @param I: Integral coefficient
+ @type D: float
+ @param D: Derivate coefficient
+ """
+
+class KX_ParentActuator(SCA_IActuator):
+ """
+ The parent actuator can set or remove an objects parent object.
+ @ivar object: the object this actuator sets the parent too.
+ @type object: KX_GameObject or None
+ @ivar mode: The mode of this actuator
+ @type mode: int from 0 to 1 L{GameLogic.Parent Actuator}
+ @ivar compound: Whether the object shape should be added to the parent compound shape when parenting
+ Effective only if the parent is already a compound shape
+ @type compound: bool
+ @ivar ghost: whether the object should be made ghost when parenting
+ Effective only if the shape is not added to the parent compound shape
+ @type ghost: bool
+
+ """
+ def setObject(object):
+ """
+ Sets the object to set as parent.
+
+ Object can be either a L{KX_GameObject} or the name of the object.
+
+ @deprecated: Use the L{object} property.
+ @type object: L{KX_GameObject}, string or None
+ """
+ def getObject(name_only = 1):
+ """
+ Returns the name of the object to change to.
+
+ @deprecated: Use the L{object} property.
+ @type name_only: bool
+ @param name_only: optional argument, when 0 return a KX_GameObject
+ @rtype: string, KX_GameObject or None if no object is set
+ """
+
+class KX_PhysicsObjectWrapper(PyObjectPlus):
+ """
+ KX_PhysicsObjectWrapper
+
+ """
+ def setActive(active):
+ """
+ Set the object to be active.
+
+ @param active: set to True to be active
+ @type active: bool
+ """
+
+ def setAngularVelocity(x, y, z, local):
+ """
+ Set the angular velocity of the object.
+
+ @param x: angular velocity for the x-axis
+ @type x: float
+
+ @param y: angular velocity for the y-axis
+ @type y: float
+
+ @param z: angular velocity for the z-axis
+ @type z: float
+
+ @param local: set to True for local axis
+ @type local: bool
+ """
+ def setLinearVelocity(x, y, z, local):
+ """
+ Set the linear velocity of the object.
+
+ @param x: linear velocity for the x-axis
+ @type x: float
+
+ @param y: linear velocity for the y-axis
+ @type y: float
+
+ @param z: linear velocity for the z-axis
+ @type z: float
+
+ @param local: set to True for local axis
+ @type local: bool
+ """
+ def setPosition(x, y, z):
+ """
+ Set the position of the object
+
+ @param x: x coordinate
+ @type x: float
+
+ @param y: y coordinate
+ @type y: float
+
+ @param z: z coordinate
+ @type z: float
+ """
+
+class KX_PolyProxy(SCA_IObject):
+ """
+ A polygon holds the index of the vertex forming the poylgon.
+
+ Note:
+ The polygon attributes are read-only, you need to retrieve the vertex proxy if you want
+ to change the vertex settings.
+
+ @ivar matname: The name of polygon material, empty if no material.
+ @type matname: string
+ @ivar material: The material of the polygon
+ @type material: L{KX_PolygonMaterial} or L{KX_BlenderMaterial}
+ @ivar texture: The texture name of the polygon.
+ @type texture: string
+ @ivar matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
+ @type matid: integer
+ @ivar v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
+ @type v1: integer
+ @ivar v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
+ @type v2: integer
+ @ivar v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
+ @type v3: integer
+ @ivar v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
+ use this to retrieve vertex proxy from mesh proxy
+ @type v4: integer
+ @ivar visible: visible state of the polygon: 1=visible, 0=invisible
+ @type visible: integer
+ @ivar collide: collide state of the polygon: 1=receives collision, 0=collision free.
+ @type collide: integer
+ """
+
+ def getMaterialName():
+ """
+ Returns the polygon material name with MA prefix
+
+ @rtype: string
+ @return: material name
+ """
+ def getMaterial():
+ """
+ Returns the polygon material
+
+ @rtype: L{KX_PolygonMaterial} or L{KX_BlenderMaterial}
+ """
+ def getTextureName():
+ """
+ Returns the polygon texture name
+
+ @rtype: string
+ @return: texture name
+ """
+ def getMaterialIndex():
+ """
+ Returns the material bucket index of the polygon.
+ This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}.
+
+ @rtype: integer
+ @return: the material index in the mesh
+ """
+ def getNumVertex():
+ """
+ Returns the number of vertex of the polygon.
+
+ @rtype: integer
+ @return: number of vertex, 3 or 4.
+ """
+ def isVisible():
+ """
+ Returns whether the polygon is visible or not
+
+ @rtype: integer
+ @return: 0=invisible, 1=visible
+ """
+ def isCollider():
+ """
+ Returns whether the polygon is receives collision or not
+
+ @rtype: integer
+ @return: 0=collision free, 1=receives collision
+ """
+ def getVertexIndex(vertex):
+ """
+ Returns the mesh vertex index of a polygon vertex
+ This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}.
+
+ @type vertex: integer
+ @param vertex: index of the vertex in the polygon: 0->3
+ @rtype: integer
+ @return: mesh vertex index
+ """
+ def getMesh():
+ """
+ Returns a mesh proxy
+
+ @rtype: L{KX_MeshProxy}
+ @return: mesh proxy
+ """
+
+class KX_PolygonMaterial:
+ """
+ This is the interface to materials in the game engine.
+
+ Materials define the render state to be applied to mesh objects.
+
+ Warning: Some of the methods/variables are CObjects. If you mix these up,
+ you will crash blender.
+
+ This example requires:
+ - PyOpenGL http://pyopengl.sourceforge.net/
+ - GLEWPy http://glewpy.sourceforge.net/
+ Example::
+
+ import GameLogic
+ import OpenGL
+ from OpenGL.GL import *
+ from OpenGL.GLU import *
+ import glew
+ from glew import *
+
+ glewInit()
+
+ vertex_shader = \"\"\"
+
+ void main(void)
+ {
+ gl_Position = ftransform();
+ }
+ \"\"\"
+
+ fragment_shader =\"\"\"
+
+ void main(void)
+ {
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+ }
+ \"\"\"
+
+ class MyMaterial:
+ def __init__(self):
+ self.pass_no = 0
+ # Create a shader
+ self.m_program = glCreateProgramObjectARB()
+ # Compile the vertex shader
+ self.shader(GL_VERTEX_SHADER_ARB, (vertex_shader))
+ # Compile the fragment shader
+ self.shader(GL_FRAGMENT_SHADER_ARB, (fragment_shader))
+ # Link the shaders together
+ self.link()
+
+ def PrintInfoLog(self, tag, object):
+ \"\"\"
+ PrintInfoLog prints the GLSL compiler log
+ \"\"\"
+ print "Tag: def PrintGLError(self, tag = ""):
+
+ def PrintGLError(self, tag = ""):
+ \"\"\"
+ Prints the current GL error status
+ \"\"\"
+ if len(tag):
+ print tag
+ err = glGetError()
+ if err != GL_NO_ERROR:
+ print "GL Error: %s\\n"%(gluErrorString(err))
+
+ def shader(self, type, shaders):
+ \"\"\"
+ shader compiles a GLSL shader and attaches it to the current
+ program.
+
+ type should be either GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB
+ shaders should be a sequence of shader source to compile.
+ \"\"\"
+ # Create a shader object
+ shader_object = glCreateShaderObjectARB(type)
+
+ # Add the source code
+ glShaderSourceARB(shader_object, len(shaders), shaders)
+
+ # Compile the shader
+ glCompileShaderARB(shader_object)
+
+ # Print the compiler log
+ self.PrintInfoLog("vertex shader", shader_object)
+
+ # Check if compiled, and attach if it did
+ compiled = glGetObjectParameterivARB(shader_object, GL_OBJECT_COMPILE_STATUS_ARB)
+ if compiled:
+ glAttachObjectARB(self.m_program, shader_object)
+
+ # Delete the object (glAttachObjectARB makes a copy)
+ glDeleteObjectARB(shader_object)
+
+ # print the gl error log
+ self.PrintGLError()
+
+ def link(self):
+ \"\"\"
+ Links the shaders together.
+ \"\"\"
+ # clear error indicator
+ glGetError()
+
+ glLinkProgramARB(self.m_program)
+
+ self.PrintInfoLog("link", self.m_program)
+
+ linked = glGetObjectParameterivARB(self.m_program, GL_OBJECT_LINK_STATUS_ARB)
+ if not linked:
+ print "Shader failed to link"
+ return
+
+ glValidateProgramARB(self.m_program)
+ valid = glGetObjectParameterivARB(self.m_program, GL_OBJECT_VALIDATE_STATUS_ARB)
+ if not valid:
+ print "Shader failed to validate"
+ return
+
+ def activate(self, rasty, cachingInfo, mat):
+ self.pass_no+=1
+ if (self.pass_no == 1):
+ glDisable(GL_COLOR_MATERIAL)
+ glUseProgramObjectARB(self.m_program)
+ return True
+
+ glEnable(GL_COLOR_MATERIAL)
+ glUseProgramObjectARB(0)
+ self.pass_no = 0
+ return False
+
+ obj = GameLogic.getCurrentController().owner
+
+ mesh = obj.meshes[0]
+
+ for mat in mesh.materials:
+ mat.setCustomMaterial(MyMaterial())
+ print mat.texture
+
+ @ivar texture: Texture name
+ @type texture: string (read-only)
+
+ @ivar gl_texture: OpenGL texture handle (eg for glBindTexture(GL_TEXTURE_2D, gl_texture)
+ @type gl_texture: integer (read-only)
+
+ @ivar material: Material name
+ @type material: string (read-only)
+
+ @ivar tface: Texture face properties
+ @type tface: CObject (read-only)
+
+ @ivar tile: Texture is tiling
+ @type tile: boolean
+ @ivar tilexrep: Number of tile repetitions in x direction.
+ @type tilexrep: integer
+ @ivar tileyrep: Number of tile repetitions in y direction.
+ @type tileyrep: integer
+
+ @ivar drawingmode: Drawing mode for the material.
+ - 2 (drawingmode & 4) Textured
+ - 4 (drawingmode & 16) Light
+ - 14 (drawingmode & 16384) 3d Polygon Text
+ @type drawingmode: bitfield
+
+ @ivar transparent: This material is transparent. All meshes with this
+ material will be rendered after non transparent meshes from back
+ to front.
+ @type transparent: boolean
+
+ @ivar zsort: Transparent polygons in meshes with this material will be sorted back to
+ front before rendering.
+ Non-Transparent polygons will be sorted front to back before rendering.
+ @type zsort: boolean
+
+ @ivar lightlayer: Light layers this material affects.
+ @type lightlayer: bitfield.
+
+ @ivar triangle: Mesh data with this material is triangles. It's probably not safe to change this.
+ @type triangle: boolean
+
+ @ivar diffuse: The diffuse colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]
+ @type diffuse: list [r, g, b]
+ @ivar specular: The specular colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]
+ @type specular: list [r, g, b]
+ @ivar shininess: The shininess (specular exponent) of the material. 0.0 <= shininess <= 128.0
+ @type shininess: float
+ @ivar specularity: The amount of specular of the material. 0.0 <= specularity <= 1.0
+ @type specularity: float
+ """
+ def updateTexture(tface, rasty):
+ """
+ Updates a realtime animation.
+
+ @param tface: Texture face (eg mat.tface)
+ @type tface: CObject
+ @param rasty: Rasterizer
+ @type rasty: CObject
+ """
+ def setTexture(tface):
+ """
+ Sets texture render state.
+
+ Example::
+ mat.setTexture(mat.tface)
+
+ @param tface: Texture face
+ @type tface: CObject
+ """
+ def activate(rasty, cachingInfo):
+ """
+ Sets material parameters for this object for rendering.
+
+ Material Parameters set:
+ 1. Texture
+ 2. Backface culling
+ 3. Line drawing
+ 4. Specular Colour
+ 5. Shininess
+ 6. Diffuse Colour
+ 7. Polygon Offset.
+
+ @param rasty: Rasterizer instance.
+ @type rasty: CObject
+ @param cachingInfo: Material cache instance.
+ @type cachingInfo: CObject
+ """
+ def setCustomMaterial(material):
+ """
+ Sets the material state setup object.
+
+ Using this method, you can extend or completely replace the gameengine material
+ to do your own advanced multipass effects.
+
+ Use this method to register your material class. Instead of the normal material,
+ your class's activate method will be called just before rendering the mesh.
+ This should setup the texture, material, and any other state you would like.
+ It should return True to render the mesh, or False if you are finished. You should
+ clean up any state Blender does not set before returning False.
+
+ Activate Method Definition::
+ def activate(self, rasty, cachingInfo, material):
+
+ Example::
+ class PyMaterial:
+ def __init__(self):
+ self.pass_no = -1
+
+ def activate(self, rasty, cachingInfo, material):
+ # Activate the material here.
+ #
+ # The activate method will be called until it returns False.
+ # Every time the activate method returns True the mesh will
+ # be rendered.
+ #
+ # rasty is a CObject for passing to material.updateTexture()
+ # and material.activate()
+ # cachingInfo is a CObject for passing to material.activate()
+ # material is the KX_PolygonMaterial instance this material
+ # was added to
+
+ # default material properties:
+ self.pass_no += 1
+ if self.pass_no == 0:
+ material.activate(rasty, cachingInfo)
+ # Return True to do this pass
+ return True
+
+ # clean up and return False to finish.
+ self.pass_no = -1
+ return False
+
+ # Create a new Python Material and pass it to the renderer.
+ mat.setCustomMaterial(PyMaterial())
+
+ @param material: The material object.
+ @type material: instance
+ """
+
+class KX_RadarSensor(KX_NearSensor):
+ """
+ Radar sensor is a near sensor with a conical sensor object.
+
+ @ivar coneOrigin: The origin of the cone with which to test. The origin
+ is in the middle of the cone.
+ (read-only)
+ @type coneOrigin: list of floats [x, y, z]
+ @ivar coneTarget: The center of the bottom face of the cone with which to test.
+ (read-only)
+ @type coneTarget: list of floats [x, y, z]
+ @ivar distance: The height of the cone with which to test.
+ @type distance: float
+ @ivar angle: The angle of the cone (in degrees) with which to test.
+ @type angle: float from 0 to 360
+ @ivar axis: The axis on which the radar cone is cast
+ @type axis: int from 0 to 5
+ KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y, KX_RADAR_AXIS_POS_Z,
+ KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y, KX_RADAR_AXIS_NEG_Z
+ """
+#{Deprecated
+ #--The following methods are deprecated, please use properties instead.
+ def getConeOrigin():
+ """
+ Returns the origin of the cone with which to test. The origin
+ is in the middle of the cone.
+
+ @deprecated: Use the L{coneOrigin} property.
+ @rtype: list [x, y, z]
+ """
+
+ def getConeTarget():
+ """
+ Returns the center of the bottom face of the cone with which to test.
+
+ @deprecated: Use the L{coneTarget} property.
+ @rtype: list [x, y, z]
+ """
+#}
+
+ def getConeHeight():
+ """
+ Returns the height of the cone with which to test.
+
+ @rtype: float
+ """
+
+class KX_RaySensor(SCA_ISensor):
+ """
+ A ray sensor detects the first object in a given direction.
+
+ @ivar propName: The property the ray is looking for.
+ @type propName: string
+ @ivar range: The distance of the ray.
+ @type range: float
+ @ivar useMaterial: Whether or not to look for a material (false = property)
+ @type useMaterial: boolean
+ @ivar useXRay: Whether or not to use XRay.
+ @type useXRay: boolean
+ @ivar hitObject: The game object that was hit by the ray. (Read-only)
+ @type hitObject: KX_GameObject
+ @ivar hitPosition: The position (in worldcoordinates) where the object was hit by the ray. (Read-only)
+ @type hitPosition: list [x, y, z]
+ @ivar hitNormal: The normal (in worldcoordinates) of the object at the location where the object was hit by the ray. (Read-only)
+ @type hitNormal: list [x, y, z]
+ @ivar rayDirection: The direction from the ray (in worldcoordinates). (Read-only)
+ @type rayDirection: list [x, y, z]
+ @ivar axis: The axis the ray is pointing on.
+ @type axis: int from 0 to 5
+ KX_RAY_AXIS_POS_X, KX_RAY_AXIS_POS_Y, KX_RAY_AXIS_POS_Z,
+ KX_RAY_AXIS_NEG_X, KX_RAY_AXIS_NEG_Y, KX_RAY_AXIS_NEG_Z
+ """
+#{ Deprecated
+ def getHitObject():
+ """
+ Returns the game object that was hit by this ray.
+
+ @deprecated: Use the L{hitObject} attribute instead.
+ @rtype: KX_GameObject
+ """
+ def getHitPosition():
+ """
+ Returns the position (in worldcoordinates) where the object was hit by this ray.
+
+ @deprecated: Use the L{hitPosition} attribute instead.
+ @rtype: list [x, y, z]
+ """
+ def getHitNormal():
+ """
+ Returns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.
+
+ @deprecated: Use the L{hitNormal} attribute instead.
+ @rtype: list [nx, ny, nz]
+ """
+ def getRayDirection():
+ """
+ Returns the direction from the ray (in worldcoordinates)
+
+ @deprecated: Use the L{rayDirection} attribute instead.
+ @rtype: list [dx, dy, dz]
+ """
+#}
+
+class KX_SCA_AddObjectActuator(SCA_IActuator):
+ """
+ Edit Object Actuator (in Add Object Mode)
+ @ivar object: the object this actuator adds.
+ @type object: KX_GameObject or None
+ @ivar objectLastCreated: the last added object from this actuator (read-only).
+ @type objectLastCreated: KX_GameObject or None
+ @ivar time: the lifetime of added objects, in frames. Set to 0 to disable automatic deletion.
+ @type time: integer
+ @ivar linearVelocity: the initial linear velocity of added objects.
+ @type linearVelocity: list [vx, vy, vz]
+ @ivar angularVelocity: the initial angular velocity of added objects.
+ @type angularVelocity: list [vx, vy, vz]
+
+ @warning: An Add Object actuator will be ignored if at game start, the linked object doesn't exist
+ (or is empty) or the linked object is in an active layer.
+
+ This will genereate a warning in the console:
+
+ C{ERROR: GameObject I{OBName} has a AddObjectActuator I{ActuatorName} without object (in 'nonactive' layer)}
+ """
+#{Deprecated
+ def setObject(object):
+ """
+ Sets the game object to add.
+
+ A copy of the object will be added to the scene when the actuator is activated.
+
+ If the object does not exist, this function is ignored.
+
+ object can either be a L{KX_GameObject} or the name of an object or None.
+
+ @deprecated: use the L{object} property
+ @type object: L{KX_GameObject}, string or None
+ """
+ def getObject(name_only = 0):
+ """
+ Returns the name of the game object to be added.
+
+ Returns None if no game object has been assigned to be added.
+
+ @deprecated: use the L{object} property
+ @type name_only: bool
+ @param name_only: optional argument, when 0 return a KX_GameObject
+ @rtype: string, KX_GameObject or None if no object is set
+ """
+ def setTime(time):
+ """
+ Sets the lifetime of added objects, in frames.
+
+ If time == 0, the object will last forever.
+
+ @deprecated: use the L{time} property
+ @type time: integer
+ @param time: The minimum value for time is 0.
+ """
+ def getTime():
+ """
+ Returns the lifetime of the added object, in frames.
+
+ @deprecated: use the L{time} property
+ @rtype: integer
+ """
+ def setLinearVelocity(vx, vy, vz):
+ """
+ Sets the initial linear velocity of added objects.
+
+ @deprecated: use the L{linearVelocity} property
+ @type vx: float
+ @param vx: the x component of the initial linear velocity.
+ @type vy: float
+ @param vy: the y component of the initial linear velocity.
+ @type vz: float
+ @param vz: the z component of the initial linear velocity.
+ """
+ def getLinearVelocity():
+ """
+ Returns the initial linear velocity of added objects.
+
+ @deprecated: use the L{linearVelocity} property
+ @rtype: list [vx, vy, vz]
+ """
+ def setAngularVelocity(vx, vy, vz):
+ """
+ Sets the initial angular velocity of added objects.
+
+ @deprecated: use the L{angularVelocity} property
+ @type vx: float
+ @param vx: the x component of the initial angular velocity.
+ @type vy: float
+ @param vy: the y component of the initial angular velocity.
+ @type vz: float
+ @param vz: the z component of the initial angular velocity.
+ """
+ def getAngularVelocity():
+ """
+ Returns the initial angular velocity of added objects.
+
+ @deprecated: use the L{angularVelocity} property
+ @rtype: list [vx, vy, vz]
+ """
+ def getLastCreatedObject():
+ """
+ Returns the last object created by this actuator.
+
+ @deprecated: use the L{objectLastCreated} property
+ @rtype: L{KX_GameObject}
+ @return: A L{KX_GameObject} or None if no object has been created.
+ """
+#}
+ def instantAddObject():
+ """
+ Returns the last object created by this actuator. The object can then be accessed from L{objectLastCreated}.
+
+ @rtype: None
+ """
+
+class KX_SCA_DynamicActuator(SCA_IActuator):
+ """
+ Dynamic Actuator.
+ @ivar mode: the type of operation of the actuator, 0-4
+ KX_DYN_RESTORE_DYNAMICS, KX_DYN_DISABLE_DYNAMICS,
+ KX_DYN_ENABLE_RIGID_BODY, KX_DYN_DISABLE_RIGID_BODY, KX_DYN_SET_MASS
+ @type mode: integer
+ @ivar mass: the mass value for the KX_DYN_SET_MASS operation
+ @type mass: float
+ """
+#{ Deprecated
+ def setOperation(operation):
+ """
+ Set the type of operation when the actuator is activated:
+ - 0 = restore dynamics
+ - 1 = disable dynamics
+ - 2 = enable rigid body
+ - 3 = disable rigid body
+ - 4 = set mass
+
+ @deprecated: Use the L{mode} attribute instead.
+ """
+ def getOperation():
+ """
+ return the type of operation
+ @deprecated: Use the L{mode} attribute instead.
+ """
+#}
+
+class KX_SCA_EndObjectActuator(SCA_IActuator):
+ """
+ Edit Object Actuator (in End Object mode)
+
+ This actuator has no python methods.
+ """
+
+class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
+ """
+ Edit Object actuator, in Replace Mesh mode.
+
+ Example::
+ # Level-of-detail
+ # Switch a game object's mesh based on its depth in the camera view.
+ # +----------+ +-----------+ +-------------------------------------+
+ # | Always +-----+ Python +-----+ Edit Object (Replace Mesh) LOD.Mesh |
+ # +----------+ +-----------+ +-------------------------------------+
+ import GameLogic
+
+ # List detail meshes here
+ # Mesh (name, near, far)
+ # Meshes overlap so that they don't 'pop' when on the edge of the distance.
+ meshes = ((".Hi", 0.0, -20.0),
+ (".Med", -15.0, -50.0),
+ (".Lo", -40.0, -100.0)
+ )
+
+ co = GameLogic.getCurrentController()
+ obj = co.owner
+ act = co.actuators["LOD." + obj.name]
+ cam = GameLogic.getCurrentScene().active_camera
+
+ def Depth(pos, plane):
+ return pos[0]*plane[0] + pos[1]*plane[1] + pos[2]*plane[2] + plane[3]
+
+ # Depth is negative and decreasing further from the camera
+ depth = Depth(obj.position, cam.world_to_camera[2])
+
+ newmesh = None
+ curmesh = None
+ # Find the lowest detail mesh for depth
+ for mesh in meshes:
+ if depth < mesh[1] and depth > mesh[2]:
+ newmesh = mesh
+ if "ME" + obj.name + mesh[0] == act.getMesh():
+ curmesh = mesh
+
+ if newmesh != None and "ME" + obj.name + newmesh[0] != act.getMesh():
+ # The mesh is a different mesh - switch it.
+ # Check the current mesh is not a better fit.
+ if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
+ act.mesh = obj.getName() + newmesh[0]
+ GameLogic.addActiveActuator(act, True)
+
+ @warning: Replace mesh actuators will be ignored if at game start, the
+ named mesh doesn't exist.
+
+ This will generate a warning in the console:
+
+ C{ERROR: GameObject I{OBName} ReplaceMeshActuator I{ActuatorName} without object}
+
+ @ivar mesh: L{KX_MeshProxy} or the name of the mesh that will replace the current one
+ Set to None to disable actuator
+ @type mesh: L{KX_MeshProxy} or None if no mesh is set
+ """
+ def setMesh(name):
+ """
+ Sets the name of the mesh that will replace the current one.
+ When the name is None it will unset the mesh value so no action is taken.
+
+ @deprecated: Use the L{mesh} attribute instead.
+ @type name: string or None
+ """
+ def getMesh():
+ """
+ Returns the name of the mesh that will replace the current one.
+
+ Returns None if no mesh has been scheduled to be added.
+
+ @deprecated: Use the L{mesh} attribute instead.
+ @rtype: string or None
+ """
+ def instantReplaceMesh():
+ """
+ Immediately replace mesh without delay.
+ @rtype: None
+ """
+
+class KX_Scene(PyObjectPlus):
+ """
+ An active scene that gives access to objects, cameras, lights and scene attributes.
+
+ The activity culling stuff is supposed to disable logic bricks when their owner gets too far
+ from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows
+ what it does!
+
+ Example::
+ import GameLogic
+
+ # get the scene
+ scene = GameLogic.getCurrentScene()
+
+ # print all the objects in the scene
+ for obj in scene.objects:
+ print obj.name
+
+ # get an object named 'Cube'
+ obj = scene.objects["OBCube"]
+
+ # get the first object in the scene.
+ obj = scene.objects[0]
+
+ Example::
+ # Get the depth of an object in the camera view.
+ import GameLogic
+
+ obj = GameLogic.getCurrentController().owner
+ cam = GameLogic.getCurrentScene().active_camera
+
+ # Depth is negative and decreasing further from the camera
+ depth = obj.position[0]*cam.world_to_camera[2][0] + obj.position[1]*cam.world_to_camera[2][1] + obj.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
+
+ @bug: All attributes are read only at the moment.
+
+ @ivar name: The scene's name, (read-only).
+ @type name: string
+ @ivar objects: A list of objects in the scene, (read-only).
+ @type objects: L{CListValue} of L{KX_GameObject}
+ @ivar objectsInactive: A list of objects on background layers (used for the addObject actuator), (read-only).
+ @type objectsInactive: L{CListValue} of L{KX_GameObject}
+ @ivar lights: A list of lights in the scene, (read-only).
+ @type lights: L{CListValue} of L{KX_LightObject}
+ @ivar cameras: A list of cameras in the scene, (read-only).
+ @type cameras: L{CListValue} of L{KX_Camera}
+ @ivar active_camera: The current active camera.
+ note: this can be set directly from python to avoid using the L{KX_SceneActuator}.
+ @type active_camera: L{KX_Camera}
+ @ivar suspended: True if the scene is suspended, (read-only).
+ @type suspended: boolean
+ @ivar activity_culling: True if the scene is activity culling
+ @type activity_culling: boolean
+ @ivar activity_culling_radius: The distance outside which to do activity culling. Measured in manhattan distance.
+ @type activity_culling_radius: float
+ @ivar dbvt_culling: True when Dynamic Bounding box Volume Tree is set (read-only).
+ @type dbvt_culling: bool
+ @group Deprecated: getLightList, getObjectList, getName
+ """
+
+ def getLightList():
+ """
+ Returns the list of lights in the scene.
+
+ @deprecated: Use the L{lights} attribute instead.
+ @rtype: list [L{KX_LightObject}]
+ """
+ def getObjectList():
+ """
+ Returns the list of objects in the scene.
+
+ @deprecated: Use the L{objects} attribute instead.
+ @rtype: list [L{KX_GameObject}]
+ """
+ def getName():
+ """
+ Returns the name of the scene.
+
+ @deprecated: Use the L{name} attribute instead.
+ @rtype: string
+ """
+
+ def addObject(object, other, time=0):
+ """
+ Adds an object to the scene like the Add Object Actuator would, and returns the created object.
+
+ @param object: The object to add
+ @type object: L{KX_GameObject} or string
+ @param other: The object's center to use when adding the object
+ @type other: L{KX_GameObject} or string
+ @param time: The lifetime of the added object, in frames. A time of 0 means the object will last forever.
+ @type time: int
+
+ @rtype: L{KX_GameObject}
+ """
+
+class KX_SceneActuator(SCA_IActuator):
+ """
+ Scene Actuator logic brick.
+
+ @warning: Scene actuators that use a scene name will be ignored if at game start, the
+ named scene doesn't exist or is empty
+
+ This will generate a warning in the console:
+
+ C{ERROR: GameObject I{OBName} has a SceneActuator I{ActuatorName} (SetScene) without scene}
+
+ @ivar scene: the name of the scene to change to/overlay/underlay/remove/suspend/resume
+ @type scene: string.
+ @ivar camera: the camera to change to.
+ When setting the attribute, you can use either a L{KX_Camera} or the name of the camera.
+ @type camera: L{KX_Camera} on read, string or L{KX_Camera} on write
+ @ivar useRestart: Set flag to True to restart the sene
+ @type useRestart: bool
+ @ivar mode: The mode of the actuator
+ @type mode: int from 0 to 5 L{GameLogic.Scene Actuator}
+ """
+#{ Deprecated
+ def setUseRestart(flag):
+ """
+ Set flag to True to restart the scene.
+
+ @deprecated: Use the L{useRestart} attribute instead.
+ @type flag: boolean
+ """
+ def setScene(scene):
+ """
+ Sets the name of the scene to change to/overlay/underlay/remove/suspend/resume.
+
+ @deprecated: use the L{scene} attribute instead.
+ @type scene: string
+ """
+ def setCamera(camera):
+ """
+ Sets the camera to change to.
+
+ Camera can be either a L{KX_Camera} or the name of the camera.
+
+ @deprecated: use the L{camera} attribute instead.
+ @type camera: L{KX_Camera} or string
+ """
+ def getUseRestart():
+ """
+ Returns True if the scene will be restarted.
+
+ @deprecated: use the L{useRestart} attribute instead.
+ @rtype: boolean
+ """
+ def getScene():
+ """
+ Returns the name of the scene to change to/overlay/underlay/remove/suspend/resume.
+
+ Returns an empty string ("") if no scene has been set.
+
+ @deprecated: use the L{scene} attribute instead.
+ @rtype: string
+ """
+ def getCamera():
+ """
+ Returns the name of the camera to change to.
+
+ @deprecated: use the L{camera} attribute instead.
+ @rtype: string
+ """
+#}
+
+class KX_SoundActuator(SCA_IActuator):
+ """
+ Sound Actuator.
+
+ The L{startSound()}, L{pauseSound()} and L{stopSound()} do not require
+ the actuator to be activated - they act instantly provided that the actuator has
+ been activated once at least.
+
+ @ivar fileName: The filename of the sound this actuator plays.
+ @type fileName: string
+
+ @ivar volume: The volume (gain) of the sound.
+ @type volume: float
+
+ @ivar pitch: The pitch of the sound.
+ @type pitch: float
+
+ @ivar rollOffFactor: The roll off factor. Rolloff defines the rate of attenuation as the sound gets further away.
+ @type rollOffFactor: float
+
+ @ivar looping: The loop mode of the actuator.
+ @type looping: integer
+
+ @ivar position: The position of the sound as a list: [x, y, z].
+ @type position: float array
+
+ @ivar velocity: The velocity of the emitter as a list: [x, y, z]. The relative velocity to the observer determines the pitch. List of 3 floats: [x, y, z].
+ @type velocity: float array
+
+ @ivar orientation: The orientation of the sound. When setting the orientation you can also use quaternion [float,float,float,float] or euler angles [float,float,float]
+ @type orientation: 3x3 matrix [[float]]
+
+ @ivar mode: The operation mode of the actuator. You can use one of the following constants:
+ - KX_SOUNDACT_PLAYSTOP (1)
+ - KX_SOUNDACT_PLAYEND (2)
+ - KX_SOUNDACT_LOOPSTOP (3)
+ - KX_SOUNDACT_LOOPEND (4)
+ - KX_SOUNDACT_LOOPBIDIRECTIONAL (5)
+ - KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP (6)
+ @type mode: integer
+ """
+
+#{ Play Methods
+ def startSound():
+ """
+ Starts the sound.
+ """
+ def pauseSound():
+ """
+ Pauses the sound.
+ """
+ def stopSound():
+ """
+ Stops the sound.
+ """
+#}
+
+#{ Deprecated
+ def setFilename(filename):
+ """
+ Sets the filename of the sound this actuator plays.
+
+ @deprecated: Use the L{fileName} attribute instead.
+ @type filename: string
+ """
+ def getFilename():
+ """
+ Returns the filename of the sound this actuator plays.
+
+ @deprecated: Use the L{fileName} attribute instead.
+ @rtype: string
+ """
+ def setGain(gain):
+ """
+ Sets the gain (volume) of the sound
+
+ @deprecated: Use the L{volume} attribute instead.
+ @type gain: float
+ @param gain: 0.0 (quiet) <= gain <= 1.0 (loud)
+ """
+ def getGain():
+ """
+ Gets the gain (volume) of the sound.
+
+ @deprecated: Use the L{volume} attribute instead.
+ @rtype: float
+ """
+ def setPitch(pitch):
+ """
+ Sets the pitch of the sound.
+
+ @deprecated: Use the L{pitch} attribute instead.
+ @type pitch: float
+ """
+ def getPitch():
+ """
+ Returns the pitch of the sound.
+
+ @deprecated: Use the L{pitch} attribute instead.
+ @rtype: float
+ """
+ def setRollOffFactor(rolloff):
+ """
+ Sets the rolloff factor for the sounds.
+
+ Rolloff defines the rate of attenuation as the sound gets further away.
+ Higher rolloff factors shorten the distance at which the sound can be heard.
+
+ @deprecated: Use the L{rollOffFactor} attribute instead.
+ @type rolloff: float
+ """
+ def getRollOffFactor():
+ """
+ Returns the rolloff factor for the sound.
+
+ @deprecated: Use the L{rollOffFactor} attribute instead.
+ @rtype: float
+ """
+ def setLooping(loop):
+ """
+ Sets the loop mode of the actuator.
+
+ @bug: There are no constants defined for this method!
+ @param loop: - Play Stop 1
+ - Play End 2
+ - Loop Stop 3
+ - Loop End 4
+ - Bidirection Stop 5
+ - Bidirection End 6
+
+ @deprecated: Use the L{looping} attribute instead.
+ @type loop: integer
+ """
+ def getLooping():
+ """
+ Returns the current loop mode of the actuator.
+
+ @deprecated: Use the L{looping} attribute instead.
+ @rtype: integer
+ """
+ def setPosition(x, y, z):
+ """
+ Sets the position this sound will come from.
+
+ @deprecated: Use the L{position} attribute instead.
+ @type x: float
+ @param x: The x coordinate of the sound.
+ @type y: float
+ @param y: The y coordinate of the sound.
+ @type z: float
+ @param z: The z coordinate of the sound.
+ """
+ def setVelocity(vx, vy, vz):
+ """
+ Sets the velocity this sound is moving at.
+
+ The sound's pitch is determined from the velocity.
+
+ @deprecated: Use the L{velocity} attribute instead.
+ @type vx: float
+ @param vx: The vx coordinate of the sound.
+ @type vy: float
+ @param vy: The vy coordinate of the sound.
+ @type vz: float
+ @param vz: The vz coordinate of the sound.
+ """
+ def setOrientation(o11, o12, o13, o21, o22, o23, o31, o32, o33):
+ """
+ Sets the orientation of the sound.
+
+ The nine parameters specify a rotation matrix::
+ | o11, o12, o13 |
+ | o21, o22, o23 |
+ | o31, o32, o33 |
+ @deprecated: Use the L{orientation} attribute instead.
+ """
+
+ def setType(mode):
+ """
+ Sets the operation mode of the actuator.
+
+ @deprecated: Use the L{type} attribute instead.
+ @param mode: KX_SOUNDACT_PLAYSTOP, KX_SOUNDACT_PLAYEND, KX_SOUNDACT_LOOPSTOP, KX_SOUNDACT_LOOPEND, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
+ @type mode: integer
+ """
+
+ def getType():
+ """
+ Returns the operation mode of the actuator.
+
+ @deprecated: Use the L{type} attribute instead.
+ @rtype: integer
+ @return: KX_SOUNDACT_PLAYSTOP, KX_SOUNDACT_PLAYEND, KX_SOUNDACT_LOOPSTOP, KX_SOUNDACT_LOOPEND, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
+ """
+#}
+
+class KX_StateActuator(SCA_IActuator):
+ """
+ State actuator changes the state mask of parent object.
+
+ Property:
+
+ @ivar operation: type of bit operation to be applied on object state mask.
+ You can use one of the following constant:
+ - KX_STATE_OP_CPY (0) : Copy state mask
+ - KX_STATE_OP_SET (1) : Add bits to state mask
+ - KX_STATE_OP_CLR (2) : Substract bits to state mask
+ - KX_STATE_OP_NEG (3) : Invert bits to state mask
+ @type operation: integer
+
+ @ivar mask: value that defines the bits that will be modified by the operation.
+ The bits that are 1 in the mask will be updated in the object state,
+ the bits that are 0 are will be left unmodified expect for the Copy operation
+ which copies the mask to the object state
+ @type mask: integer
+ """
+ def setOperation(op):
+ """
+ Set the type of bit operation to be applied on object state mask.
+ Use setMask() to specify the bits that will be modified.
+
+ @deprecated: Use the L{operation} attribute instead.
+ @param op: bit operation (0=Copy, 1=Add, 2=Substract, 3=Invert)
+ @type op: integer
+ """
+ def setMask(mask):
+ """
+ Set the value that defines the bits that will be modified by the operation.
+ The bits that are 1 in the value will be updated in the object state,
+ the bits that are 0 are will be left unmodified expect for the Copy operation
+ which copies the value to the object state.
+
+ @deprecated: Use the L{mask} attribute instead.
+ @param mask: bits that will be modified
+ @type mask: integer
+ """
+
+class KX_TrackToActuator(SCA_IActuator):
+ """
+ Edit Object actuator in Track To mode.
+
+ @warning: Track To Actuators will be ignored if at game start, the
+ object to track to is invalid.
+
+ This will generate a warning in the console:
+
+ C{ERROR: GameObject I{OBName} no object in EditObjectActuator I{ActuatorName}}
+
+ @ivar object: the object this actuator tracks.
+ @type object: KX_GameObject or None
+ @ivar time: the time in frames with which to delay the tracking motion
+ @type time: integer
+ @ivar use3D: the tracking motion to use 3D
+ @type use3D: boolean
+
+ """
+#{ Deprecated
+ def setObject(object):
+ """
+ Sets the object to track.
+
+ @deprecated: Use the L{object} attribute instead.
+ @type object: L{KX_GameObject}, string or None
+ @param object: Either a reference to a game object or the name of the object to track.
+ """
+ def getObject(name_only):
+ """
+ Returns the name of the object to track.
+
+ @deprecated: Use the L{object} attribute instead.
+ @type name_only: bool
+ @param name_only: optional argument, when 0 return a KX_GameObject
+ @rtype: string, KX_GameObject or None if no object is set
+ """
+ def setTime(time):
+ """
+ Sets the time in frames with which to delay the tracking motion.
+
+ @deprecated: Use the L{time} attribute instead.
+ @type time: integer
+ """
+ def getTime():
+ """
+ Returns the time in frames with which the tracking motion is delayed.
+
+ @deprecated: Use the L{time} attribute instead.
+ @rtype: integer
+ """
+ def setUse3D(use3d):
+ """
+ DEPRECATED: Use the property.
+ Sets the tracking motion to use 3D.
+
+ @deprecated: Use the L{use3D} attribute instead.
+ @type use3d: boolean
+ @param use3d: - True: allow the tracking motion to extend in the z-direction.
+ - False: lock the tracking motion to the x-y plane.
+ """
+ def getUse3D():
+ """
+ Returns True if the tracking motion will track in the z direction.
+
+ @deprecated: Use the L{use3D} attribute instead.
+ @rtype: boolean
+ """
+#}
+
+class KX_VehicleWrapper(PyObjectPlus):
+ """
+ KX_VehicleWrapper
+
+ TODO - description
+ """
+
+ def addWheel(wheel, attachPos, attachDir, axleDir, suspensionRestLength, wheelRadius, hasSteering):
+
+ """
+ Add a wheel to the vehicle
+
+ @param wheel: The object to use as a wheel.
+ @type wheel: L{KX_GameObject} or a KX_GameObject name
+ @param attachPos: The position that this wheel will attach to.
+ @type attachPos: vector of 3 floats
+ @param attachDir: The direction this wheel points.
+ @type attachDir: vector of 3 floats
+ @param axleDir: The direction of this wheels axle.
+ @type axleDir: vector of 3 floats
+ @param suspensionRestLength: TODO - Description
+ @type suspensionRestLength: float
+ @param wheelRadius: The size of the wheel.
+ @type wheelRadius: float
+ """
+
+ def applyBraking(force, wheelIndex):
+ """
+ Apply a braking force to the specified wheel
+
+ @param force: the brake force
+ @type force: float
+
+ @param wheelIndex: index of the wheel where the force needs to be applied
+ @type wheelIndex: integer
+ """
+ def applyEngineForce(force, wheelIndex):
+ """
+ Apply an engine force to the specified wheel
+
+ @param force: the engine force
+ @type force: float
+
+ @param wheelIndex: index of the wheel where the force needs to be applied
+ @type wheelIndex: integer
+ """
+ def getConstraintId():
+ """
+ Get the constraint ID
+
+ @rtype: integer
+ @return: the constraint id
+ """
+ def getConstraintType():
+ """
+ Returns the constraint type.
+
+ @rtype: integer
+ @return: constraint type
+ """
+ def getNumWheels():
+ """
+ Returns the number of wheels.
+
+ @rtype: integer
+ @return: the number of wheels for this vehicle
+ """
+ def getWheelOrientationQuaternion(wheelIndex):
+ """
+ Returns the wheel orientation as a quaternion.
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+
+ @rtype: TODO - type should be quat as per method name but from the code it looks like a matrix
+ @return: TODO Description
+ """
+ def getWheelPosition(wheelIndex):
+ """
+ Returns the position of the specified wheel
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+
+ @rtype: list[x, y, z]
+ @return: position vector
+ """
+ def getWheelRotation(wheelIndex):
+ """
+ Returns the rotation of the specified wheel
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+
+ @rtype: float
+ @return: the wheel rotation
+ """
+ def setRollInfluence(rollInfluece, wheelIndex):
+ """
+ Set the specified wheel's roll influence.
+ The higher the roll influence the more the vehicle will tend to roll over in corners.
+
+ @param rollInfluece: the wheel roll influence
+ @type rollInfluece: float
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+ """
+ def setSteeringValue(steering, wheelIndex):
+ """
+ Set the specified wheel's steering
+
+ @param steering: the wheel steering
+ @type steering: float
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+ """
+ def setSuspensionCompression(compression, wheelIndex):
+ """
+ Set the specified wheel's compression
+
+ @param compression: the wheel compression
+ @type compression: float
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+ """
+ def setSuspensionDamping(damping, wheelIndex):
+ """
+ Set the specified wheel's damping
+
+ @param damping: the wheel damping
+ @type damping: float
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+ """
+ def setSuspensionStiffness(stiffness, wheelIndex):
+ """
+ Set the specified wheel's stiffness
+
+ @param stiffness: the wheel stiffness
+ @type stiffness: float
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+ """
+ def setTyreFriction(friction, wheelIndex):
+ """
+ Set the specified wheel's tyre friction
+
+ @param friction: the tyre friction
+ @type friction: float
+
+ @param wheelIndex: the wheel index
+ @type wheelIndex: integer
+ """
+
+class KX_VertexProxy(SCA_IObject):
+ """
+ A vertex holds position, UV, colour and normal information.
+
+ Note:
+ The physics simulation is NOT currently updated - physics will not respond
+ to changes in the vertex position.
+
+ @ivar XYZ: The position of the vertex.
+ @type XYZ: list [x, y, z]
+ @ivar UV: The texture coordinates of the vertex.
+ @type UV: list [u, v]
+ @ivar normal: The normal of the vertex
+ @type normal: list [nx, ny, nz]
+ @ivar colour: The colour of the vertex.
+ Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0]
+ @type colour: list [r, g, b, a]
+ @ivar color: Synonym for colour.
+
+ @group Position: x, y, z
+ @ivar x: The x coordinate of the vertex.
+ @type x: float
+ @ivar y: The y coordinate of the vertex.
+ @type y: float
+ @ivar z: The z coordinate of the vertex.
+ @type z: float
+
+ @group Texture Coordinates: u, v
+ @ivar u: The u texture coordinate of the vertex.
+ @type u: float
+ @ivar v: The v texture coordinate of the vertex.
+ @type v: float
+
+ @ivar u2: The second u texture coordinate of the vertex.
+ @type u2: float
+ @ivar v2: The second v texture coordinate of the vertex.
+ @type v2: float
+
+ @group Colour: r, g, b, a
+ @ivar r: The red component of the vertex colour. 0.0 <= r <= 1.0
+ @type r: float
+ @ivar g: The green component of the vertex colour. 0.0 <= g <= 1.0
+ @type g: float
+ @ivar b: The blue component of the vertex colour. 0.0 <= b <= 1.0
+ @type b: float
+ @ivar a: The alpha component of the vertex colour. 0.0 <= a <= 1.0
+ @type a: float
+ """
+
+ def getXYZ():
+ """
+ Gets the position of this vertex.
+
+ @rtype: list [x, y, z]
+ @return: this vertexes position in local coordinates.
+ """
+ def setXYZ(pos):
+ """
+ Sets the position of this vertex.
+
+ @type pos: list [x, y, z]
+ @param pos: the new position for this vertex in local coordinates.
+ """
+ def getUV():
+ """
+ Gets the UV (texture) coordinates of this vertex.
+
+ @rtype: list [u, v]
+ @return: this vertexes UV (texture) coordinates.
+ """
+ def setUV(uv):
+ """
+ Sets the UV (texture) coordinates of this vertex.
+
+ @type uv: list [u, v]
+ """
+ def getUV2():
+ """
+ Gets the 2nd UV (texture) coordinates of this vertex.
+
+ @rtype: list [u, v]
+ @return: this vertexes UV (texture) coordinates.
+ """
+ def setUV2(uv, unit):
+ """
+ Sets the 2nd UV (texture) coordinates of this vertex.
+
+ @type uv: list [u, v]
+ @param unit: optional argument, FLAT==1, SECOND_UV==2, defaults to SECOND_UV
+ @param unit: int
+ """
+ def getRGBA():
+ """
+ Gets the colour of this vertex.
+
+ The colour is represented as four bytes packed into an integer value. The colour is
+ packed as RGBA.
+
+ Since Python offers no way to get each byte without shifting, you must use the struct module to
+ access colour in an machine independent way.
+
+ Because of this, it is suggested you use the r, g, b and a attributes or the colour attribute instead.
+
+ Example::
+ import struct;
+ col = struct.unpack('4B', struct.pack('I', v.getRGBA()))
+ # col = (r, g, b, a)
+ # black = ( 0, 0, 0, 255)
+ # white = (255, 255, 255, 255)
+
+ @rtype: integer
+ @return: packed colour. 4 byte integer with one byte per colour channel in RGBA format.
+ """
+ def setRGBA(col):
+ """
+ Sets the colour of this vertex.
+
+ See getRGBA() for the format of col, and its relevant problems. Use the r, g, b and a attributes
+ or the colour attribute instead.
+
+ setRGBA() also accepts a four component list as argument col. The list represents the colour as [r, g, b, a]
+ with black = [0.0, 0.0, 0.0, 1.0] and white = [1.0, 1.0, 1.0, 1.0]
+
+ Example::
+ v.setRGBA(0xff0000ff) # Red
+ v.setRGBA(0xff00ff00) # Green on little endian, transparent purple on big endian
+ v.setRGBA([1.0, 0.0, 0.0, 1.0]) # Red
+ v.setRGBA([0.0, 1.0, 0.0, 1.0]) # Green on all platforms.
+
+ @type col: integer or list [r, g, b, a]
+ @param col: the new colour of this vertex in packed RGBA format.
+ """
+ def getNormal():
+ """
+ Gets the normal vector of this vertex.
+
+ @rtype: list [nx, ny, nz]
+ @return: normalised normal vector.
+ """
+ def setNormal(normal):
+ """
+ Sets the normal vector of this vertex.
+
+ @type normal: sequence of floats [r, g, b]
+ @param normal: the new normal of this vertex.
+ """
+
+class KX_VisibilityActuator(SCA_IActuator):
+ """
+ Visibility Actuator.
+ @ivar visibility: whether the actuator makes its parent object visible or invisible
+ @type visibility: boolean
+ @ivar useOcclusion: whether the actuator makes its parent object an occluder or not
+ @type useOcclusion: boolean
+ @ivar useRecursion: whether the visibility/occlusion should be propagated to all children of the object
+ @type useRecursion: boolean
+ """
+#{ Deprecated
+ def set(visible):
+ """
+ Sets whether the actuator makes its parent object visible or invisible.
+
+ @deprecated: Use the L{visibility} attribute instead.
+ @param visible: - True: Makes its parent visible.
+ - False: Makes its parent invisible.
+ """
+#}
+
+class SCA_2DFilterActuator(SCA_IActuator):
+ """
+ Create, enable and disable 2D filters
+
+ Properties:
+
+ The following properties don't have an immediate effect.
+ You must active the actuator to get the result.
+ The actuator is not persistent: it automatically stops itself after setting up the filter
+ but the filter remains active. To stop a filter you must activate the actuator with 'type'
+ set to RAS_2DFILTER_DISABLED or RAS_2DFILTER_NOFILTER.
+
+ @ivar shaderText: shader source code for custom shader
+ @type shaderText: string
+ @ivar disableMotionBlur: action on motion blur: 0=enable, 1=disable
+ @type disableMotionBlur: integer
+ @ivar mode: type of 2D filter, use one of the following constants:
+ RAS_2DFILTER_ENABLED (-2) : enable the filter that was previously disabled
+ RAS_2DFILTER_DISABLED (-1) : disable the filter that is currently active
+ RAS_2DFILTER_NOFILTER (0) : disable and destroy the filter that is currently active
+ RAS_2DFILTER_MOTIONBLUR (1) : create and enable preset filters
+ RAS_2DFILTER_BLUR (2)
+ RAS_2DFILTER_SHARPEN (3)
+ RAS_2DFILTER_DILATION (4)
+ RAS_2DFILTER_EROSION (5)
+ RAS_2DFILTER_LAPLACIAN (6)
+ RAS_2DFILTER_SOBEL (7)
+ RAS_2DFILTER_PREWITT (8)
+ RAS_2DFILTER_GRAYSCALE (9)
+ RAS_2DFILTER_SEPIA (10)
+ RAS_2DFILTER_INVERT (11)
+ RAS_2DFILTER_CUSTOMFILTER (12) : customer filter, the code code is set via shaderText property
+ @type mode: integer
+ @ivar passNumber: order number of filter in the stack of 2D filters. Filters are executed in increasing order of passNb.
+ Only be one filter can be defined per passNb.
+ @type passNumber: integer (0-100)
+ @ivar value: argument for motion blur filter
+ @type value: float (0.0-100.0)
+ """
+
+class SCA_ANDController(SCA_IController):
+ """
+ An AND controller activates only when all linked sensors are activated.
+
+ There are no special python methods for this controller.
+ """
+
+class SCA_ActuatorSensor(SCA_ISensor):
+ """
+ Actuator sensor detect change in actuator state of the parent object.
+ It generates a positive pulse if the corresponding actuator is activated
+ and a negative pulse if the actuator is deactivated.
+
+ Properties:
+
+ @ivar actuator: the name of the actuator that the sensor is monitoring.
+ @type actuator: string
+ """
+#{Deprecated
+ def getActuator():
+ """
+ Return the Actuator with which the sensor operates.
+
+ @deprecated: Use the L{actuator} attribute instead.
+ @rtype: string
+ """
+ def setActuator(name):
+ """
+ Sets the Actuator with which to operate. If there is no Actuator
+ of this name, the function has no effect.
+
+ @deprecated: Use the L{actuator} attribute instead.
+ @param name: actuator name
+ @type name: string
+ """
+#}
+
+class SCA_AlwaysSensor(SCA_ISensor):
+ """
+ This sensor is always activated.
+ """
+
+class SCA_DelaySensor(SCA_ISensor):
+ """
+ The Delay sensor generates positive and negative triggers at precise time,
+ expressed in number of frames. The delay parameter defines the length
+ of the initial OFF period. A positive trigger is generated at the end of this period.
+ The duration parameter defines the length of the ON period following the OFF period.
+ There is a negative trigger at the end of the ON period. If duration is 0, the sensor
+ stays ON and there is no negative trigger.
+ The sensor runs the OFF-ON cycle once unless the repeat option is set: the
+ OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
+ Use SCA_ISensor::reset() at any time to restart sensor.
+
+ Properties:
+
+ @ivar delay: length of the initial OFF period as number of frame, 0 for immediate trigger.
+ @type delay: integer.
+ @ivar duration: length of the ON period in number of frame after the initial OFF period.
+ If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
+ @type duration: integer
+ @ivar repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
+ @type repeat: integer
+ """
+#{Deprecated
+ def setDelay(delay):
+ """
+ Set the initial delay before the positive trigger.
+
+ @deprecated: Use the L{delay} attribute instead.
+ @param delay: length of the initial OFF period as number of frame, 0 for immediate trigger
+ @type delay: integer
+ """
+ def setDuration(duration):
+ """
+ Set the duration of the ON pulse after initial delay and the generation of the positive trigger.
+ If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
+
+ @deprecated: Use the L{duration} attribute instead.
+ @param duration: length of the ON period in number of frame after the initial OFF period
+ @type duration: integer
+ """
+ def setRepeat(repeat):
+ """
+ Set if the sensor repeat mode.
+
+ @deprecated: Use the L{repeat} attribute instead.
+ @param repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
+ @type repeat: integer
+ """
+ def getDelay():
+ """
+ Return the delay parameter value.
+
+ @deprecated: Use the L{delay} attribute instead.
+ @rtype: integer
+ """
+ def getDuration():
+ """
+ Return the duration parameter value
+
+ @deprecated: Use the L{duration} attribute instead.
+ @rtype: integer
+ """
+ def getRepeat():
+ """
+ Return the repeat parameter value
+
+ @deprecated: Use the L{repeat} attribute instead.
+ @rtype: KX_TRUE or KX_FALSE
+ """
+#}
+
+class SCA_JoystickSensor(SCA_ISensor):
+ """
+ This sensor detects player joystick events.
+
+ Properties:
+
+ @ivar axisValues: (read-only) The state of the joysticks axis as a list of values L{numAxis} long.
+ each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
+ The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
+ left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
+ @type axisValues: list of ints
+
+ @ivar axisSingle: (read-only) like L{axisValues} but returns a single axis value that is set by the sensor.
+ Only use this for "Single Axis" type sensors otherwise it will raise an error.
+ @type axisSingle: int
+
+ @ivar hatValues: (read-only) The state of the joysticks hats as a list of values L{numHats} long.
+ each spesifying the direction of the hat from 1 to 12, 0 when inactive.
+ Hat directions are as follows...
+ - 0:None
+ - 1:Up
+ - 2:Right
+ - 4:Down
+ - 8:Left
+ - 3:Up - Right
+ - 6:Down - Right
+ - 12:Down - Left
+ - 9:Up - Left
+
+ @type hatValues: list of ints
+
+ @ivar hatSingle: (read-only) like L{hatValues} but returns a single hat direction value that is set by the sensor.
+ @type hatSingle: int
+
+ @ivar numAxis: (read-only) The number of axes for the joystick at this index.
+ @type numAxis: integer
+ @ivar numButtons: (read-only) The number of buttons for the joystick at this index.
+ @type numButtons: integer
+ @ivar numHats: (read-only) The number of hats for the joystick at this index.
+ @type numHats: integer
+ @ivar connected: (read-only) True if a joystick is connected at this joysticks index.
+ @type connected: boolean
+ @ivar index: The joystick index to use (from 0 to 7). The first joystick is always 0.
+ @type index: integer
+ @ivar threshold: Axis threshold. Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
+ @type threshold: integer
+ @ivar button: The button index the sensor reacts to (first button = 0). When the "All Events" toggle is set, this option has no effect.
+ @type button: integer
+ @ivar axis: The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection]
+ axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control.
+ axisDirection: 0=right, 1=up, 2=left, 3=down
+ @type axis: [integer, integer]
+ @ivar hat: The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection]
+ hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat (4 max).
+ hatDirection: 1-12
+ @type hat: [integer, integer]
+ """
+
+ def getButtonActiveList():
+ """
+ Returns a list containing the indicies of the currently pressed buttons.
+ @rtype: list
+ """
+ def getButtonStatus(buttonIndex):
+ """
+ Returns a bool of the current pressed state of the specified button.
+ @param buttonIndex: the button index, 0=first button
+ @type buttonIndex: integer
+ @rtype: bool
+ """
+#{Deprecated
+ def getIndex():
+ """
+ Returns the joystick index to use (from 1 to 8).
+
+ @deprecated: Use the L{index} attribute instead.
+ @rtype: integer
+ """
+ def setIndex(index):
+ """
+ Sets the joystick index to use.
+
+ @deprecated: Use the L{index} attribute instead.
+ @param index: The index of this joystick sensor, Clamped between 1 and 8.
+ @type index: integer
+ @note: This is only useful when you have more then 1 joystick connected to your computer - multiplayer games.
+ """
+ def getAxis():
+ """
+ Returns the current axis this sensor reacts to. See L{getAxisValue()<SCA_JoystickSensor.getAxisValue>} for the current axis state.
+
+ @deprecated: Use the L{axis} attribute instead.
+ @rtype: list
+ @return: 2 values returned are [axisIndex, axisDirection] - see L{setAxis()<SCA_JoystickSensor.setAxis>} for their purpose.
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def setAxis(axisIndex, axisDirection):
+ """
+ @deprecated: Use the L{axis} attribute instead.
+ @param axisIndex: Set the axis index to use when detecting axis movement.
+ @type axisIndex: integer from 1 to 2
+ @param axisDirection: Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down.
+ @type axisDirection: integer from 0 to 3
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def getAxisValue():
+ """
+ Returns the state of the joysticks axis. See differs to L{getAxis()<SCA_JoystickSensor.getAxis>} returning the current state of the joystick.
+
+ @deprecated: Use the L{axisValues} attribute instead.
+ @rtype: list
+ @return: 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
+
+ The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
+
+ left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
+ @note: Some gamepads only set the axis on and off like a button.
+ """
+ def getThreshold():
+ """
+ Get the axis threshold. See L{setThreshold()<SCA_JoystickSensor.setThreshold>} for details.
+
+ @deprecated: Use the L{threshold} attribute instead.
+ @rtype: integer
+ """
+ def setThreshold(threshold):
+ """
+ Set the axis threshold.
+
+ @deprecated: Use the L{threshold} attribute instead.
+ @param threshold: Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
+ @type threshold: integer
+ """
+ def getButton():
+ """
+ Returns the button index the sensor reacts to. See L{getButtonValue()<SCA_JoystickSensor.getButtonValue>} for a list of pressed buttons.
+
+ @deprecated: Use the L{button} attribute instead.
+ @rtype: integer
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def setButton(index):
+ """
+ Sets the button index the sensor reacts to when the "All Events" option is not set.
+
+ @deprecated: Use the L{button} attribute instead.
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def getButtonValue():
+ """
+ Returns a list containing the indicies of the currently pressed buttons.
+
+ @deprecated: Use the L{getButtonActiveList} method instead.
+ @rtype: list
+ """
+ def getHat():
+ """
+ Returns the current hat direction this sensor is set to.
+ [hatNumber, hatDirection].
+
+ @deprecated: Use the L{hat} attribute instead.
+ @rtype: list
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def setHat(index,direction):
+ """
+ Sets the hat index the sensor reacts to when the "All Events" option is not set.
+
+ @deprecated: Use the L{hat} attribute instead.
+ @type index: integer
+ """
+ def getNumAxes():
+ """
+ Returns the number of axes for the joystick at this index.
+
+ @deprecated: Use the L{numAxis} attribute instead.
+ @rtype: integer
+ """
+ def getNumButtons():
+ """
+ Returns the number of buttons for the joystick at this index.
+
+ @deprecated: Use the L{numButtons} attribute instead.
+ @rtype: integer
+ """
+ def getNumHats():
+ """
+ Returns the number of hats for the joystick at this index.
+
+ @deprecated: Use the L{numHats} attribute instead.
+ @rtype: integer
+ """
+ def isConnected():
+ """
+ Returns True if a joystick is detected at this joysticks index.
+
+ @deprecated: Use the L{connected} attribute instead.
+ @rtype: bool
+ """
+#}
+
+class SCA_KeyboardSensor(SCA_ISensor):
+ """
+ A keyboard sensor detects player key presses.
+
+ See module L{GameKeys} for keycode values.
+
+ @ivar key: The key code this sensor is looking for.
+ @type key: keycode from L{GameKeys} module
+ @ivar hold1: The key code for the first modifier this sensor is looking for.
+ @type hold1: keycode from L{GameKeys} module
+ @ivar hold2: The key code for the second modifier this sensor is looking for.
+ @type hold2: keycode from L{GameKeys} module
+ @ivar toggleProperty: The name of the property that indicates whether or not to log keystrokes as a string.
+ @type toggleProperty: string
+ @ivar targetProperty: The name of the property that receives keystrokes in case in case a string is logged.
+ @type targetProperty: string
+ @ivar useAllKeys: Flag to determine whether or not to accept all keys.
+ @type useAllKeys: boolean
+ @ivar events: a list of pressed keys that have either been pressed, or just released, or are active this frame. (read-only).
+
+ - 'keycode' matches the values in L{GameKeys}.
+ - 'status' uses...
+ - L{GameLogic.KX_INPUT_NONE}
+ - L{GameLogic.KX_INPUT_JUST_ACTIVATED}
+ - L{GameLogic.KX_INPUT_ACTIVE}
+ - L{GameLogic.KX_INPUT_JUST_RELEASED}
+
+ @type events: list [[keycode, status], ...]
+ """
+
+ def getKeyStatus(keycode):
+ """
+ Get the status of a key.
+
+ @rtype: key state L{GameLogic} members (KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED)
+ @return: The state of the given key
+ @type keycode: integer
+ @param keycode: The code that represents the key you want to get the state of
+ """
+
+#{Deprecated
+ def getKey():
+ """
+ Returns the key code this sensor is looking for.
+
+ @deprecated: Use the L{key} attribute instead.
+ @rtype: keycode from L{GameKeys} module
+ """
+
+ def setKey(keycode):
+ """
+ Set the key this sensor should listen for.
+
+ @deprecated: Use the L{key} attribute instead.
+ @type keycode: keycode from L{GameKeys} module
+ """
+
+ def getHold1():
+ """
+ Returns the key code for the first modifier this sensor is looking for.
+
+ @deprecated: Use the L{hold1} attribute instead.
+ @rtype: keycode from L{GameKeys} module
+ """
+
+ def setHold1(keycode):
+ """
+ Sets the key code for the first modifier this sensor should look for.
+
+ @deprecated: Use the L{hold1} attribute instead.
+ @type keycode: keycode from L{GameKeys} module
+ """
+
+ def getHold2():
+ """
+ Returns the key code for the second modifier this sensor is looking for.
+
+ @deprecated: Use the L{hold2} attribute instead.
+ @rtype: keycode from L{GameKeys} module
+ """
+
+ def setHold2(keycode):
+ """
+ Sets the key code for the second modifier this sensor should look for.
+
+ @deprecated: Use the L{hold2} attribute instead.
+ @type keycode: keycode from L{GameKeys} module
+ """
+
+ def getPressedKeys():
+ """
+ Get a list of keys that have either been pressed, or just released this frame.
+
+ @deprecated: Use the L{events} attribute instead.
+ @rtype: list of key status. [[keycode, status]]
+ """
+
+ def getCurrentlyPressedKeys():
+ """
+ Get a list of currently pressed keys that have either been pressed, or just released
+
+ @deprecated: Use the L{events} attribute instead.
+ @rtype: list of key status. [[keycode, status]]
+ """
+#}
+
+class SCA_NANDController(SCA_IController):
+ """
+ An NAND controller activates when all linked sensors are not active.
+
+ There are no special python methods for this controller.
+ """
+
+class SCA_NORController(SCA_IController):
+ """
+ An NOR controller activates only when all linked sensors are de-activated.
+
+ There are no special python methods for this controller.
+ """
+
+class SCA_ORController(SCA_IController):
+ """
+ An OR controller activates when any connected sensor activates.
+
+ There are no special python methods for this controller.
+ """
+
+class SCA_PropertyActuator(SCA_IActuator):
+ """
+ Property Actuator
+
+ Properties:
+
+ @ivar propName: the property on which to operate.
+ @type propName: string
+ @ivar value: the value with which the actuator operates.
+ @type value: string
+ @ivar mode: TODO - add constants to game logic dict!.
+ @type mode: int
+ """
+#{ Deprecated
+ def setProperty(prop):
+ """
+ Set the property on which to operate.
+
+ If there is no property of this name, the call is ignored.
+
+ @deprecated: Use the L{propName} attribute instead.
+ @type prop: string
+ @param prop: The name of the property to set.
+ """
+ def getProperty():
+ """
+ Returns the name of the property on which to operate.
+
+ @deprecated: Use the L{propName} attribute instead.
+ @rtype: string
+ """
+ def setValue(value):
+ """
+ Set the value with which the actuator operates.
+
+ If the value is not compatible with the type of the
+ property, the subsequent action is ignored.
+
+ @deprecated: Use the L{value} attribute instead.
+ @type value: string
+ """
+ def getValue():
+ """
+ Gets the value with which this actuator operates.
+
+ @deprecated: Use the L{value} attribute instead.
+ @rtype: string
+ """
+#}
+
+class SCA_PropertySensor(SCA_ISensor):
+ """
+ Activates when the game object property matches.
+
+ Properties:
+
+ @ivar mode: type of check on the property:
+ KX_PROPSENSOR_EQUAL(1), KX_PROPSENSOR_NOTEQUAL(2), KX_PROPSENSOR_INTERVAL(3),
+ KX_PROPSENSOR_CHANGED(4), KX_PROPSENSOR_EXPRESSION(5)
+ @type mode: integer
+ @ivar propName: the property the sensor operates.
+ @type propName: string
+ @ivar value: the value with which the sensor compares to the value of the property.
+ @type value: string
+ """
+#{ Deprecated
+ def getType():
+ """
+ Gets when to activate this sensor.
+
+ @deprecated: Use the L{mode} attribute instead.
+ @return: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
+ KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,
+ or KX_PROPSENSOR_EXPRESSION.
+ """
+
+ def setType(checktype):
+ """
+ Set the type of check to perform.
+
+ @deprecated: Use the L{mode} attribute instead.
+ @type checktype: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
+ KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,
+ or KX_PROPSENSOR_EXPRESSION.
+ """
+
+ def getProperty():
+ """
+ Return the property with which the sensor operates.
+
+ @deprecated: Use the L{propName} attribute instead.
+ @rtype: string
+ @return: the name of the property this sensor is watching.
+ """
+ def setProperty(name):
+ """
+ Sets the property with which to operate. If there is no property
+ of that name, this call is ignored.
+
+ @deprecated: Use the L{propName} attribute instead.
+ @type name: string.
+ """
+ def getValue():
+ """
+ Return the value with which the sensor compares to the value of the property.
+
+ @deprecated: Use the L{value} attribute instead.
+ @rtype: string
+ @return: the value of the property this sensor is watching.
+ """
+ def setValue(value):
+ """
+ Set the value with which the sensor operates. If the value
+ is not compatible with the type of the property, the subsequent
+ action is ignored.
+
+ @deprecated: Use the L{value} attribute instead.
+ @type value: string
+ """
+#}
+
+class SCA_PythonController(SCA_IController):
+ """
+ A Python controller uses a Python script to activate it's actuators,
+ based on it's sensors.
+
+ Properties:
+
+ @ivar script: The value of this variable depends on the execution methid.
+ - When 'Script' execution mode is set this value contains the entire python script as a single string (not the script name as you might expect) which can be modified to run different scripts.
+ - When 'Module' execution mode is set this value will contain a single line string - module name and function "module.func" or "package.modile.func" where the module names are python textblocks or external scripts.
+ note: once this is set the script name given for warnings will remain unchanged.
+ @type script: string
+ @ivar mode: the execution mode for this controller (read-only).
+ - Script: 0, Execite the L{script} as a python code.
+ - Module: 1, Execite the L{script} as a module and function.
+ @type mode: int
+
+ @group Deprecated: getScript, setScript
+ """
+ def activate(actuator):
+ """
+ Activates an actuator attached to this controller.
+ @type actuator: actuator or the actuator name as a string
+ """
+ def deactivate(actuator):
+ """
+ Deactivates an actuator attached to this controller.
+ @type actuator: actuator or the actuator name as a string
+ """
+ def getScript():
+ """
+ Gets the Python script body this controller executes.
+
+ @deprecated: Use the L{script} attribute instead.
+ @rtype: string
+ """
+ def setScript(script_body):
+ """
+ Sets the Python script string this controller executes.
+
+ @deprecated: Use the L{script} attribute instead.
+ @type script_body: string.
+ """
+
+class SCA_RandomActuator(SCA_IActuator):
+ """
+ Random Actuator
+
+ Properties:
+
+ @ivar seed: Seed of the random number generator.
+ Equal seeds produce equal series. If the seed is 0,
+ the generator will produce the same value on every call.
+ @type seed: integer
+ @ivar para1: the first parameter of the active distribution.
+ Refer to the documentation of the generator types for the meaning
+ of this value.
+ @type para1: float, read-only
+ @ivar para2: the second parameter of the active distribution.
+ Refer to the documentation of the generator types for the meaning
+ of this value.
+ @type para2: float, read-only
+ @ivar distribution: distribution type:
+ KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
+ KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON,
+ KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
+ KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
+ @type distribution: integer, read-only
+ @ivar propName: the name of the property to set with the random value.
+ If the generator and property types do not match, the assignment is ignored.
+ @type propName: string
+
+ """
+ def setBoolConst(value):
+ """
+ Sets this generator to produce a constant boolean value.
+
+ @param value: The value to return.
+ @type value: boolean
+ """
+ def setBoolUniform():
+ """
+ Sets this generator to produce a uniform boolean distribution.
+
+ The generator will generate True or False with 50% chance.
+ """
+ def setBoolBernouilli(value):
+ """
+ Sets this generator to produce a Bernouilli distribution.
+
+ @param value: Specifies the proportion of False values to produce.
+ - 0.0: Always generate True
+ - 1.0: Always generate False
+ @type value: float
+ """
+ def setIntConst(value):
+ """
+ Sets this generator to always produce the given value.
+
+ @param value: the value this generator produces.
+ @type value: integer
+ """
+ def setIntUniform(lower_bound, upper_bound):
+ """
+ Sets this generator to produce a random value between the given lower and
+ upper bounds (inclusive).
+
+ @type lower_bound: integer
+ @type upper_bound: integer
+ """
+ def setIntPoisson(value):
+ """
+ Generate a Poisson-distributed number.
+
+ This performs a series of Bernouilli tests with parameter value.
+ It returns the number of tries needed to achieve succes.
+
+ @type value: float
+ """
+ def setFloatConst(value):
+ """
+ Always generate the given value.
+
+ @type value: float
+ """
+ def setFloatUniform(lower_bound, upper_bound):
+ """
+ Generates a random float between lower_bound and upper_bound with a
+ uniform distribution.
+
+ @type lower_bound: float
+ @type upper_bound: float
+ """
+ def setFloatNormal(mean, standard_deviation):
+ """
+ Generates a random float from the given normal distribution.
+
+ @type mean: float
+ @param mean: The mean (average) value of the generated numbers
+ @type standard_deviation: float
+ @param standard_deviation: The standard deviation of the generated numbers.
+ """
+ def setFloatNegativeExponential(half_life):
+ """
+ Generate negative-exponentially distributed numbers.
+
+ The half-life 'time' is characterized by half_life.
+
+ @type half_life: float
+ """
+#{ Deprecated
+ def setSeed(seed):
+ """
+ Sets the seed of the random number generator.
+
+ Equal seeds produce equal series. If the seed is 0,
+ the generator will produce the same value on every call.
+
+ @deprecated: Use the L{seed} attribute instead.
+ @type seed: integer
+ """
+ def getSeed():
+ """
+ Returns the initial seed of the generator.
+
+ @deprecated: Use the L{seed} attribute instead.
+ @rtype: integer
+ """
+ def getPara1():
+ """
+ Returns the first parameter of the active distribution.
+
+ Refer to the documentation of the generator types for the meaning
+ of this value.
+
+ @deprecated: Use the L{para1} attribute instead.
+ @rtype: float
+ """
+ def getPara2():
+ """
+ Returns the second parameter of the active distribution.
+
+ Refer to the documentation of the generator types for the meaning
+ of this value.
+
+ @deprecated: Use the L{para2} attribute instead.
+ @rtype: float
+ """
+ def getDistribution():
+ """
+ Returns the type of random distribution.
+
+ @deprecated: Use the L{distribution} attribute instead.
+ @rtype: distribution type
+ @return: KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
+ KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON,
+ KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
+ KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
+ """
+ def setProperty(property):
+ """
+ Set the property to which the random value is assigned.
+
+ If the generator and property types do not match, the assignment is ignored.
+
+ @deprecated: Use the L{propName} attribute instead.
+ @type property: string
+ @param property: The name of the property to set.
+ """
+ def getProperty():
+ """
+ Returns the name of the property to set.
+
+ @deprecated: Use the L{propName} attribute instead.
+ @rtype: string
+ """
+#}
+
+
+class SCA_RandomSensor(SCA_ISensor):
+ """
+ This sensor activates randomly.
+
+ @ivar lastDraw: The seed of the random number generator.
+ @type lastDraw: int
+ @ivar seed: The seed of the random number generator.
+ @type seed: int
+ """
+
+ def setSeed(seed):
+ """
+ Sets the seed of the random number generator.
+
+ If the seed is 0, the generator will produce the same value on every call.
+
+ @type seed: integer.
+ """
+ def getSeed():
+ """
+ Returns the initial seed of the generator. Equal seeds produce equal random
+ series.
+
+ @rtype: integer
+ """
+ def getLastDraw():
+ """
+ Returns the last random number generated.
+
+ @rtype: integer
+ """
+
+class SCA_XNORController(SCA_IController):
+ """
+ An XNOR controller activates when all linked sensors are the same (activated or inative).
+
+ There are no special python methods for this controller.
+ """
+
+class SCA_XORController(SCA_IController):
+ """
+ An XOR controller activates when there is the input is mixed, but not when all are on or off.
+
+ There are no special python methods for this controller.
+ """
+
+class KX_Camera(KX_GameObject):
+ """
+ A Camera object.
+
+ @group Constants: INSIDE, INTERSECT, OUTSIDE
+ @ivar INSIDE: see sphereInsideFrustum() and boxInsideFrustum()
+ @ivar INTERSECT: see sphereInsideFrustum() and boxInsideFrustum()
+ @ivar OUTSIDE: see sphereInsideFrustum() and boxInsideFrustum()
+
+ @ivar lens: The camera's lens value.
+ @type lens: float
+ @ivar near: The camera's near clip distance.
+ @type near: float
+ @ivar far: The camera's far clip distance.
+ @type far: float
+ @ivar perspective: True if this camera has a perspective transform, False for an orthographic projection.
+ @type perspective: boolean
+ @ivar frustum_culling: True if this camera is frustum culling.
+ @type frustum_culling: boolean
+ @ivar projection_matrix: This camera's 4x4 projection matrix.
+ @type projection_matrix: 4x4 Matrix [[float]]
+ @ivar modelview_matrix: This camera's 4x4 model view matrix. (read-only)
+ Regenerated every frame from the camera's position and orientation.
+ @type modelview_matrix: 4x4 Matrix [[float]]
+ @ivar camera_to_world: This camera's camera to world transform. (read-only)
+ Regenerated every frame from the camera's position and orientation.
+ @type camera_to_world: 4x4 Matrix [[float]]
+ @ivar world_to_camera: This camera's world to camera transform. (read-only)
+ Regenerated every frame from the camera's position and orientation.
+ This is camera_to_world inverted.
+ @type world_to_camera: 4x4 Matrix [[float]]
+ @ivar useViewport: True when the camera is used as a viewport, set True to enable a viewport for this camera.
+ @type useViewport: bool
+
+ @group Deprecated: enableViewport, getProjectionMatrix, setProjectionMatrix
+ """
+
+ def sphereInsideFrustum(centre, radius):
+ """
+ Tests the given sphere against the view frustum.
+
+ @note: when the camera is first initialized the result will be invalid because the projection matrix has not been set.
+ @param centre: The centre of the sphere (in world coordinates.)
+ @type centre: list [x, y, z]
+ @param radius: the radius of the sphere
+ @type radius: float
+ @return: INSIDE, OUTSIDE or INTERSECT
+
+ Example::
+ import GameLogic
+ co = GameLogic.getCurrentController()
+ cam = co.owner
+
+ # A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
+ if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
+ # Sphere is inside frustum !
+ # Do something useful !
+ else:
+ # Sphere is outside frustum
+ """
+ def boxInsideFrustum(box):
+ """
+ Tests the given box against the view frustum.
+
+ Example::
+ import GameLogic
+ co = GameLogic.getCurrentController()
+ cam = co.owner
+
+ # Box to test...
+ box = []
+ box.append([-1.0, -1.0, -1.0])
+ box.append([-1.0, -1.0, 1.0])
+ box.append([-1.0, 1.0, -1.0])
+ box.append([-1.0, 1.0, 1.0])
+ box.append([ 1.0, -1.0, -1.0])
+ box.append([ 1.0, -1.0, 1.0])
+ box.append([ 1.0, 1.0, -1.0])
+ box.append([ 1.0, 1.0, 1.0])
+
+ if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
+ # Box is inside/intersects frustum !
+ # Do something useful !
+ else:
+ # Box is outside the frustum !
+
+ @note: when the camera is first initialized the result will be invalid because the projection matrix has not been set.
+ @return: INSIDE, OUTSIDE or INTERSECT
+ @type box: list
+ @param box: Eight (8) corner points of the box (in world coordinates.)
+ """
+ def pointInsideFrustum(point):
+ """
+ Tests the given point against the view frustum.
+
+ Example::
+ import GameLogic
+ co = GameLogic.getCurrentController()
+ cam = co.owner
+
+ # Test point [0.0, 0.0, 0.0]
+ if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
+ # Point is inside frustum !
+ # Do something useful !
+ else:
+ # Box is outside the frustum !
+
+ @note: when the camera is first initialized the result will be invalid because the projection matrix has not been set.
+ @rtype: boolean
+ @return: True if the given point is inside this camera's viewing frustum.
+ @type point: [x, y, z]
+ @param point: The point to test (in world coordinates.)
+ """
+ def getCameraToWorld():
+ """
+ Returns the camera-to-world transform.
+
+ @rtype: matrix (4x4 list)
+ @return: the camera-to-world transform matrix.
+ """
+ def getWorldToCamera():
+ """
+ Returns the world-to-camera transform.
+
+ This returns the inverse matrix of getCameraToWorld().
+
+ @rtype: matrix (4x4 list)
+ @return: the world-to-camera transform matrix.
+ """
+ def getProjectionMatrix():
+ """
+ Returns the camera's projection matrix.
+
+ @deprecated: Use the L{projection_matrix} attribute instead.
+ @rtype: matrix (4x4 list)
+ @return: the camera's projection matrix.
+ """
+ def setProjectionMatrix(matrix):
+ """
+ Sets the camera's projection matrix.
+
+ You should use normalised device coordinates for the clipping planes:
+ left = -1.0, right = 1.0, top = 1.0, bottom = -1.0, near = cam.near, far = cam.far
+
+ Example::
+ import GameLogic
+
+ def Scale(matrix, size):
+ for y in range(4):
+ for x in range(4):
+ matrix[y][x] = matrix[y][x] * size[y]
+ return matrix
+
+ # Generate a perspective projection matrix
+ def Perspective(cam):
+ return [[cam.near, 0.0 , 0.0 , 0.0 ],
+ [0.0 , cam.near, 0.0 , 0.0 ],
+ [0.0 , 0.0 , -(cam.far+cam.near)/(cam.far-cam.near), -2.0*cam.far*cam.near/(cam.far - cam.near)],
+ [0.0 , 0.0 , -1.0 , 0.0 ]]
+
+ # Generate an orthographic projection matrix
+ # You will need to scale the camera
+ def Orthographic(cam):
+ return [[1.0/cam.scaling[0], 0.0 , 0.0 , 0.0 ],
+ [0.0 , 1.0/cam.scaling[1], 0.0 , 0.0 ],
+ [0.0 , 0.0 , -2.0/(cam.far-cam.near), -(cam.far+cam.near)/(cam.far-cam.near)],
+ [0.0 , 0.0 , 0.0 , 1.0 ]]
+
+ # Generate an isometric projection matrix
+ def Isometric(cam):
+ return Scale([[0.707, 0.0 , 0.707, 0.0],
+ [0.408, 0.816,-0.408, 0.0],
+ [0.0 , 0.0 , 0.0 , 0.0],
+ [0.0 , 0.0 , 0.0 , 1.0]],
+ [1.0/cam.scaling[0], 1.0/cam.scaling[1], 1.0/cam.scaling[2], 1.0])
+
+ co = GameLogic.getCurrentController()
+ cam = co.owner
+ cam.setProjectionMatrix(Perspective(cam)))
+
+ @deprecated: Use the L{projection_matrix} attribute instead.
+ @type matrix: 4x4 matrix.
+ @param matrix: The new projection matrix for this camera.
+ """
+
+ def enableViewport(viewport):
+ """
+ Use this camera to draw a viewport on the screen (for split screen games or overlay scenes). The viewport region is defined with L{setViewport}.
+
+ @deprecated: Use the L{useViewport} attribute instead.
+ @type viewport: bool
+ @param viewport: the new viewport status
+ """
+ def setOnTop():
+ """
+ Set this cameras viewport ontop of all other viewport.
+ """
+ def setViewport(left, bottom, right, top):
+ """
+ Sets the region of this viewport on the screen in pixels.
+
+ Use L{Rasterizer.getWindowHeight} L{Rasterizer.getWindowWidth} to calculate values relative to the entire display.
+
+ @type left: int
+ @type bottom: int
+ @type right: int
+ @type top: int
+ """
+ def getScreenPosition(arg):
+ """
+ Gets the position of an object projected on screen space.
+
+ Example:
+ # For an object in the middle of the screen, coord = [0.5,0.5]
+ coord = camera.getScreenPosition(object)
+
+ @param arg: L{KX_GameObject}, object name or list [x, y, z]
+ @rtype: list [x, y]
+ @return: the object's position in screen coordinates.
+ """
+ def getScreenVect(x, y):
+ """
+ Gets the vector from the camera position in the screen coordinate direction.
+
+ Example:
+ # Gets the vector of the camera front direction:
+ m_vect = camera.getScreenVect(0.5,0.5)
+
+ @type x: float
+ @type y: float
+ @rtype: 3d vector
+ @return: the vector from a screen coordinate.
+ """
+ def getScreenRay(x, y, dist, property):
+ """
+ Look towards a screen coordinate (x,y) and find first object hit within dist that matches prop.
+ The ray is similar to KX_GameObject->rayCastTo.
+
+ Example:
+ # Gets an object with a property "wall" in front of the camera within a distance of 100:
+ target = camera.getScreenRay(0.5,0.5,100,"wall")
+
+ @type x: float
+ @type y: float
+ @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
+ @type dist: float
+ @param property: property name that object must have; can be omitted => detect any object
+ @type property: string
+ @rtype: L{KX_GameObject}
+ @return: the first object hit or None if no object or object does not match prop
+ """
+
+# Util func to extract all attrs
+"""
+import types
+attrs = []
+for name, val in locals().items():
+ if name.startswith('__'):
+ continue
+ if type(val) == types.ClassType:
+ for line in val.__doc__.split('\n'):
+ if '@ivar' in line:
+ attrs.append(name + '::' + line.split()[1].replace(':', ''))
+
+for a in attrs:
+ print a
"""
-if 0:
- # Use to print out all the links
- for i in a.split('\n'):
- if i.startswith('@var'):
- var = i.split(' ')[1].split(':')[0]
- print '@var %s: L{%s<%s.%s>}' % (var, var, var, var)
+# Util func to construct a mapping from deprecated attrs to new ones.
+"""
+import types
+import re
+import pprint
+depAttrs = {}
+for name, val in locals().items():
+ if name.startswith('__'):
+ continue
+ if type(val) == types.ClassType:
+ print "\t# %s" % name
+
+ # Inspect each attribute.
+ for attrName in dir(val):
+ if attrName.startswith('__'):
+ continue
+ attr = getattr(val, attrName)
+
+ # Check whether this attribute is deprecated by searching each line.
+ newAttrName = None
+ for line in attr.__doc__.split('\n'):
+ match = re.search(r'@deprecated.*L{(\w+)}', line)
+ if match:
+ newAttrName = match.group(1)
+ break
+ if not newAttrName:
+ continue
+
+ # Store the mappings to new attributes in a list (because there
+ # could be collisions).
+ if not depAttrs.has_key(attrName):
+ depAttrs[attrName] = {}
+ mapping = depAttrs[attrName]
+
+ for line in val.__doc__.split('\n'):
+ if ("@type %s:" % newAttrName) in line:
+ # The attribute is being replaced in this class (i.e. the
+ # deprecated attribute wasn't inherited from a parent). We
+ # have a winner!
+ funcType = None
+ if 'sequence' in line:
+ funcType = 'Keyed'
+ else:
+ funcType = 'Simple'
+
+ if attrName.startswith('get') or attrName.startswith('is'):
+ func = "replace%sGetter" % funcType
+ elif attrName.startswith('set') or attrName.startswith('enable'):
+ func = "replace%sSetter" % funcType
+ else:
+ func = 'UNKNOWN'
+
+ # Another mapping, from a conversion tuple to lists of class
+ # names.
+ conversion = (func, newAttrName)
+ if not mapping.has_key(conversion):
+ mapping[conversion] = []
+ mapping[conversion].append(name)
+ break
+
+pprint.pprint(depAttrs, width = 100)
+"""
diff --git a/source/gameengine/PyDoc/KX_BlenderMaterial.py b/source/gameengine/PyDoc/KX_BlenderMaterial.py
deleted file mode 100644
index 21417db1802..00000000000
--- a/source/gameengine/PyDoc/KX_BlenderMaterial.py
+++ /dev/null
@@ -1,38 +0,0 @@
-class KX_BlenderMaterial: # (PyObjectPlus)
- """
- KX_BlenderMaterial
-
- All placeholders have a __ prefix
- """
-
- def __getShader(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
-
- def __setBlending(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getMaterialIndex(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
diff --git a/source/gameengine/PyDoc/KX_CDActuator.py b/source/gameengine/PyDoc/KX_CDActuator.py
deleted file mode 100644
index e1067674e7e..00000000000
--- a/source/gameengine/PyDoc/KX_CDActuator.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# $Id$
-# Documentation for CD Actuator
-from SCA_IActuator import *
-
-class KX_CDActuator(SCA_IActuator):
- """
- CD Controller actuator.
- @ivar volume: controls the volume to set the CD to. 0.0 = silent, 1.0 = max volume.
- @type volume: float
- @ivar track: the track selected to be played
- @type track: integer
- @ivar gain: the gain (volume) of the CD between 0.0 and 1.0.
- @type gain: float
- """
- def startCD():
- """
- Starts the CD playing.
- """
- def stopCD():
- """
- Stops the CD playing.
- """
- def pauseCD():
- """
- Pauses the CD.
- """
- def resumeCD():
- """
- Resumes the CD after a pause.
- """
- def playAll():
- """
- Plays the CD from the beginning.
- """
- def playTrack(trackNumber):
- """
- Plays the track selected.
- """
- def setGain(gain):
- """
- DEPRECATED: Use the volume property.
- Sets the gain (volume) of the CD.
-
- @type gain: float
- @param gain: the gain to set the CD to. 0.0 = silent, 1.0 = max volume.
- """
- def getGain():
- """
- DEPRECATED: Use the volume property.
- Gets the current gain (volume) of the CD.
-
- @rtype: float
- @return: Between 0.0 (silent) and 1.0 (max volume)
- """
-
diff --git a/source/gameengine/PyDoc/KX_Camera.py b/source/gameengine/PyDoc/KX_Camera.py
deleted file mode 100644
index f5d0d45f968..00000000000
--- a/source/gameengine/PyDoc/KX_Camera.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# $Id$
-# Documentation for Camera game objects.
-from KX_GameObject import *
-
-class KX_Camera(KX_GameObject):
- """
- A Camera object.
-
- @group Constants: INSIDE, INTERSECT, OUTSIDE
- @ivar INSIDE: see sphereInsideFrustum() and boxInsideFrustum()
- @ivar INTERSECT: see sphereInsideFrustum() and boxInsideFrustum()
- @ivar OUTSIDE: see sphereInsideFrustum() and boxInsideFrustum()
-
- @ivar lens: The camera's lens value.
- @type lens: float
- @ivar near: The camera's near clip distance.
- @type near: float
- @ivar far: The camera's far clip distance.
- @type far: float
- @ivar perspective: True if this camera has a perspective transform.
-
- If perspective is False, this camera has an orthographic transform.
-
- Note that the orthographic transform is faked by multiplying the lens attribute
- by 100.0 and translating the camera 100.0 along the z axis.
-
- This is the same as Blender. If you want a true orthographic transform, see L{setProjectionMatrix}.
- @type perspective: boolean
- @ivar frustum_culling: True if this camera is frustum culling.
- @type frustum_culling: boolean
- @ivar projection_matrix: This camera's 4x4 projection matrix.
- @type projection_matrix: 4x4 Matrix [[float]]
- @ivar modelview_matrix: This camera's 4x4 model view matrix. (read only)
- Regenerated every frame from the camera's position and orientation.
- @type modelview_matrix: 4x4 Matrix [[float]]
- @ivar camera_to_world: This camera's camera to world transform. (read only)
- Regenerated every frame from the camera's position and orientation.
- @type camera_to_world: 4x4 Matrix [[float]]
- @ivar world_to_camera: This camera's world to camera transform. (read only)
- Regenerated every frame from the camera's position and orientation.
- This is camera_to_world inverted.
- @type world_to_camera: 4x4 Matrix [[float]]
- """
-
- def sphereInsideFrustum(centre, radius):
- """
- Tests the given sphere against the view frustum.
-
- @param centre: The centre of the sphere (in world coordinates.)
- @type centre: list [x, y, z]
- @param radius: the radius of the sphere
- @type radius: float
- @return: INSIDE, OUTSIDE or INTERSECT
-
- Example::
- import GameLogic
- co = GameLogic.getCurrentController()
- cam = co.GetOwner()
-
- # A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
- if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
- # Sphere is inside frustum !
- # Do something useful !
- else:
- # Sphere is outside frustum
- """
- def boxInsideFrustum(box):
- """
- Tests the given box against the view frustum.
-
- Example::
- import GameLogic
- co = GameLogic.getCurrentController()
- cam = co.GetOwner()
-
- # Box to test...
- box = []
- box.append([-1.0, -1.0, -1.0])
- box.append([-1.0, -1.0, 1.0])
- box.append([-1.0, 1.0, -1.0])
- box.append([-1.0, 1.0, 1.0])
- box.append([ 1.0, -1.0, -1.0])
- box.append([ 1.0, -1.0, 1.0])
- box.append([ 1.0, 1.0, -1.0])
- box.append([ 1.0, 1.0, 1.0])
-
- if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
- # Box is inside/intersects frustum !
- # Do something useful !
- else:
- # Box is outside the frustum !
-
- @return: INSIDE, OUTSIDE or INTERSECT
- @type box: list
- @param box: Eight (8) corner points of the box (in world coordinates.)
- """
- def pointInsideFrustum(point):
- """
- Tests the given point against the view frustum.
-
- Example::
- import GameLogic
- co = GameLogic.getCurrentController()
- cam = co.GetOwner()
-
- # Test point [0.0, 0.0, 0.0]
- if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
- # Point is inside frustum !
- # Do something useful !
- else:
- # Box is outside the frustum !
-
- @rtype: boolean
- @return: True if the given point is inside this camera's viewing frustum.
- @type point: [x, y, z]
- @param point: The point to test (in world coordinates.)
- """
- def getCameraToWorld():
- """
- Returns the camera-to-world transform.
-
- @rtype: matrix (4x4 list)
- @return: the camera-to-world transform matrix.
- """
- def getWorldToCamera():
- """
- Returns the world-to-camera transform.
-
- This returns the inverse matrix of getCameraToWorld().
-
- @rtype: matrix (4x4 list)
- @return: the world-to-camera transform matrix.
- """
- def getProjectionMatrix():
- """
- Returns the camera's projection matrix.
-
- @rtype: matrix (4x4 list)
- @return: the camera's projection matrix.
- """
- def setProjectionMatrix(matrix):
- """
- Sets the camera's projection matrix.
-
- You should use normalised device coordinates for the clipping planes:
- left = -1.0, right = 1.0, top = 1.0, bottom = -1.0, near = cam.near, far = cam.far
-
- Example::
- import GameLogic
-
- def Scale(matrix, size):
- for y in range(4):
- for x in range(4):
- matrix[y][x] = matrix[y][x] * size[y]
- return matrix
-
- # Generate a perspective projection matrix
- def Perspective(cam):
- return [[cam.near, 0.0 , 0.0 , 0.0 ],
- [0.0 , cam.near, 0.0 , 0.0 ],
- [0.0 , 0.0 , -(cam.far+cam.near)/(cam.far-cam.near), -2.0*cam.far*cam.near/(cam.far - cam.near)],
- [0.0 , 0.0 , -1.0 , 0.0 ]]
-
- # Generate an orthographic projection matrix
- # You will need to scale the camera
- def Orthographic(cam):
- return [[1.0/cam.scaling[0], 0.0 , 0.0 , 0.0 ],
- [0.0 , 1.0/cam.scaling[1], 0.0 , 0.0 ],
- [0.0 , 0.0 , -2.0/(cam.far-cam.near), -(cam.far+cam.near)/(cam.far-cam.near)],
- [0.0 , 0.0 , 0.0 , 1.0 ]]
-
- # Generate an isometric projection matrix
- def Isometric(cam):
- return Scale([[0.707, 0.0 , 0.707, 0.0],
- [0.408, 0.816,-0.408, 0.0],
- [0.0 , 0.0 , 0.0 , 0.0],
- [0.0 , 0.0 , 0.0 , 1.0]],
- [1.0/cam.scaling[0], 1.0/cam.scaling[1], 1.0/cam.scaling[2], 1.0])
-
- co = GameLogic.getCurrentController()
- cam = co.getOwner()
- cam.setProjectionMatrix(Perspective(cam)))
-
- @type matrix: 4x4 matrix.
- @param matrix: The new projection matrix for this camera.
- """
-
- def enableViewport(viewport):
- """
- Use this camera to draw a viewport on the screen (for split screen games or overlay scenes). The viewport region is defined with L{setViewport}.
-
- @type viewport: bool
- @param viewport: the new viewport status
- """
- def setOnTop():
- """
- Set this cameras viewport ontop of all other viewport.
- """
- def setViewport(left, bottom, right, top):
- """
- Sets the region of this viewport on the screen in pixels.
-
- Use L{Rasterizer.getWindowHeight} L{Rasterizer.getWindowWidth} to calculate values relative to the entire display.
-
- @type left: int
- @type bottom: int
- @type right: int
- @type top: int
- """
diff --git a/source/gameengine/PyDoc/KX_CameraActuator.py b/source/gameengine/PyDoc/KX_CameraActuator.py
deleted file mode 100644
index 6ffc55a5854..00000000000
--- a/source/gameengine/PyDoc/KX_CameraActuator.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# $Id$
-# Documentation for KX_CameraActuator
-from SCA_IActuator import *
-
-class KX_CameraActuator(SCA_IActuator):
- """
- Applies changes to a camera.
-
- @ivar min: minimum distance to the target object maintained by the actuator
- @type min: float
- @ivar max: maximum distance to stay from the target object
- @type max: float
- @ivar height: height to stay above the target object
- @type height: float
- @ivar xy: axis this actuator is tracking, true=X, false=Y
- @type xy: boolean
- @ivar object: the object this actuator tracks.
- @type object: KX_GameObject or None
- @author: snail
- """
- def getObject(name_only = 1):
- """
- Returns the name of the object this actuator tracks.
-
- @type name_only: bool
- @param name_only: optional argument, when 0 return a KX_GameObject
- @rtype: string, KX_GameObject or None if no object is set
- """
-
- def setObject(target):
- """
- Sets the object this actuator tracks.
-
- @param target: the object to track.
- @type target: L{KX_GameObject}, string or None
- """
-
- def getMin():
- """
- Returns the minimum distance to target maintained by the actuator.
-
- @rtype: float
- """
-
- def setMin(distance):
- """
- Sets the minimum distance to the target object maintained by the
- actuator.
-
- @param distance: The minimum distance to maintain.
- @type distance: float
- """
-
- def getMax():
- """
- Gets the maximum distance to stay from the target object.
-
- @rtype: float
- """
-
- def setMax(distance):
- """
- Sets the maximum distance to stay from the target object.
-
- @param distance: The maximum distance to maintain.
- @type distance: float
- """
-
- def getHeight():
- """
- Returns the height to stay above the target object.
-
- @rtype: float
- """
-
- def setHeight(height):
- """
- Sets the height to stay above the target object.
-
- @type height: float
- @param height: The height to stay above the target object.
- """
-
- def setXY(xaxis):
- """
- Sets the axis to get behind.
-
- @param xaxis: False to track Y axis, True to track X axis.
- @type xaxis: boolean
- """
-
- def getXY():
- """
- Returns the axis this actuator is tracking.
-
- @return: True if tracking X axis, False if tracking Y axis.
- @rtype: boolean
- """
diff --git a/source/gameengine/PyDoc/KX_ConstraintActuator.py b/source/gameengine/PyDoc/KX_ConstraintActuator.py
deleted file mode 100644
index a30b859548b..00000000000
--- a/source/gameengine/PyDoc/KX_ConstraintActuator.py
+++ /dev/null
@@ -1,249 +0,0 @@
-# $Id$
-# Documentation for KX_ConstraintActuator
-from SCA_IActuator import *
-
-class KX_ConstraintActuator(SCA_IActuator):
- """
- A constraint actuator limits the position, rotation, distance or orientation of an object.
-
- Properties:
-
- @ivar damp: time constant of the constraint expressed in frame (not use by Force field constraint)
- @type damp: integer
-
- @ivar rotDamp: time constant for the rotation expressed in frame (only for the distance constraint)
- 0 = use damp for rotation as well
- @type rotDamp: integer
-
- @ivar direction: the reference direction in world coordinate for the orientation constraint
- @type direction: 3-tuple of float: [x,y,z]
-
- @ivar option: Binary combination of the following values:
- Applicable to Distance constraint:
- KX_ACT_CONSTRAINT_NORMAL ( 64) : Activate alignment to surface
- KX_ACT_CONSTRAINT_DISTANCE ( 512) : Activate distance control
- KX_ACT_CONSTRAINT_LOCAL (1024) : direction of the ray is along the local axis
- Applicable to Force field constraint:
- KX_ACT_CONSTRAINT_DOROTFH (2048) : Force field act on rotation as well
- Applicable to both:
- KX_ACT_CONSTRAINT_MATERIAL ( 128) : Detect material rather than property
- KX_ACT_CONSTRAINT_PERMANENT ( 256) : No deactivation if ray does not hit target
- @type option: integer
-
- @ivar time: activation time of the actuator. The actuator disables itself after this many frame.
- If set to 0, the actuator is not limited in time.
- @type time: integer
-
- @ivar property: the name of the property or material for the ray detection of the distance constraint.
- @type property: string
-
- @ivar min: The lower bound of the constraint
- For the rotation and orientation constraint, it represents radiant
- @type min: float
-
- @ivar distance: the target distance of the distance constraint
- @type distance: float
-
- @ivar max: the upper bound of the constraint.
- For rotation and orientation constraints, it represents radiant.
- @type max: float
-
- @ivar rayLength: the length of the ray of the distance constraint.
- @type rayLength: float
-
- @ivar limit: type of constraint, use one of the following constant:
- KX_ACT_CONSTRAINT_LOCX ( 1) : limit X coord
- KX_ACT_CONSTRAINT_LOCY ( 2) : limit Y coord
- KX_ACT_CONSTRAINT_LOCZ ( 3) : limit Z coord
- KX_ACT_CONSTRAINT_ROTX ( 4) : limit X rotation
- KX_ACT_CONSTRAINT_ROTY ( 5) : limit Y rotation
- KX_ACT_CONSTRAINT_ROTZ ( 6) : limit Z rotation
- KX_ACT_CONSTRAINT_DIRPX ( 7) : set distance along positive X axis
- KX_ACT_CONSTRAINT_DIRPY ( 8) : set distance along positive Y axis
- KX_ACT_CONSTRAINT_DIRPZ ( 9) : set distance along positive Z axis
- KX_ACT_CONSTRAINT_DIRNX (10) : set distance along negative X axis
- KX_ACT_CONSTRAINT_DIRNY (11) : set distance along negative Y axis
- KX_ACT_CONSTRAINT_DIRNZ (12) : set distance along negative Z axis
- KX_ACT_CONSTRAINT_ORIX (13) : set orientation of X axis
- KX_ACT_CONSTRAINT_ORIY (14) : set orientation of Y axis
- KX_ACT_CONSTRAINT_ORIZ (15) : set orientation of Z axis
- KX_ACT_CONSTRAINT_FHPX (16) : set force field along positive X axis
- KX_ACT_CONSTRAINT_FHPY (17) : set force field along positive Y axis
- KX_ACT_CONSTRAINT_FHPZ (18) : set force field along positive Z axis
- KX_ACT_CONSTRAINT_FHNX (19) : set force field along negative X axis
- KX_ACT_CONSTRAINT_FHNY (20) : set force field along negative Y axis
- KX_ACT_CONSTRAINT_FHNZ (21) : set force field along negative Z axis
- @type limit: integer
- """
- def setDamp(time):
- """
- Sets the time this constraint is delayed.
-
- @param time: The number of frames to delay.
- Negative values are ignored.
- @type time: integer
- """
- def getDamp():
- """
- Returns the damping time of the constraint.
-
- @rtype: integer
- """
- def setMin(lower):
- """
- Sets the lower bound of the constraint.
-
- For rotational and orientation constraints, lower is specified in degrees.
-
- @type lower: float
- """
- def getMin():
- """
- Gets the lower bound of the constraint.
-
- For rotational and orientation constraints, the lower bound is returned in radians.
-
- @rtype: float
- """
- def setMax(upper):
- """
- Sets the upper bound of the constraint.
-
- For rotational and orientation constraints, upper is specified in degrees.
-
- @type upper: float
- """
- def getMax():
- """
- Gets the upper bound of the constraint.
-
- For rotational and orientation constraints, the upper bound is returned in radians.
-
- @rtype: float
- """
- def setLimit(limit):
- """
- Sets the type of constraint.
-
- See module L{GameLogic} for valid constraint types.
-
- @param limit:
- Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ
- Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ
- Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ
- Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ
- """
- def getLimit():
- """
- Gets the type of constraint.
-
- See module L{GameLogic} for valid constraints.
-
- @return:
- Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ,
- Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ,
- Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ,
- Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ
- """
- def setRotDamp(duration):
- """
- Sets the time constant of the orientation constraint.
-
- @param duration: If the duration is negative, it is set to 0.
- @type duration: integer
- """
- def getRotDamp():
- """
- Returns the damping time for application of the constraint.
-
- @rtype: integer
- """
- def setDirection(vector):
- """
- Sets the reference direction in world coordinate for the orientation constraint
-
- @type vector: 3-tuple
- """
- def getDirection():
- """
- Returns the reference direction of the orientation constraint in world coordinate.
-
- @rtype: 3-tuple
- """
- def setOption(option):
- """
- Sets several options of the distance constraint.
-
- @type option: integer
- @param option: Binary combination of the following values:
- 64 : Activate alignment to surface
- 128 : Detect material rather than property
- 256 : No deactivation if ray does not hit target
- 512 : Activate distance control
- """
- def getOption():
- """
- Returns the option parameter.
-
- @rtype: integer
- """
- def setTime(duration):
- """
- Sets the activation time of the actuator.
-
- @type duration: integer
- @param duration: The actuator disables itself after this many frame.
- If set to 0 or negative, the actuator is not limited in time.
- """
- def getTime():
- """
- Returns the time parameter.
-
- @rtype: integer
- """
- def setProperty(property):
- """
- Sets the name of the property or material for the ray detection of the distance constraint.
-
- @type property: string
- @param property: If empty, the ray will detect any collisioning object.
- """
- def getProperty():
- """
- Returns the property parameter.
-
- @rtype: string
- """
- def setDistance(distance):
- """
- Sets the target distance in distance constraint.
-
- @type distance: float
- """
- def getDistance():
- """
- Returns the distance parameter.
-
- @rtype: float
- """
- def setRayLength(length):
- """
- Sets the maximum ray length of the distance constraint.
-
- @type length: float
- """
- def getRayLength():
- """
- Returns the length of the ray
-
- @rtype: float
- """
-
-
-
-
-
-
-
-
-
diff --git a/source/gameengine/PyDoc/KX_ConstraintWrapper.py b/source/gameengine/PyDoc/KX_ConstraintWrapper.py
deleted file mode 100644
index 5b34e1609e8..00000000000
--- a/source/gameengine/PyDoc/KX_ConstraintWrapper.py
+++ /dev/null
@@ -1,28 +0,0 @@
-class KX_ConstraintWrapper: # (PyObjectPlus)
- """
- KX_ConstraintWrapper
-
- All placeholders have a __ prefix
- """
- def __getConstraintId(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
-
- def __testMethod(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
-
diff --git a/source/gameengine/PyDoc/KX_GameActuator.py b/source/gameengine/PyDoc/KX_GameActuator.py
deleted file mode 100644
index fc5bd6005fc..00000000000
--- a/source/gameengine/PyDoc/KX_GameActuator.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# $Id$
-# Documentation for KX_GameActuator
-from SCA_IActuator import *
-
-class KX_GameActuator(SCA_IActuator):
- """
- The game actuator loads a new .blend file, restarts the current .blend file or quits the game.
-
- Properties:
-
- @ivar file: the new .blend file to load
- @type file: string.
- """
- def getFile():
- """
- DEPRECATED: use the file property
- Returns the filename of the new .blend file to load.
-
- @rtype: string
- """
- def setFile(filename):
- """
- DEPRECATED: use the file property
- Sets the new .blend file to load.
-
- @param filename: The file name this actuator will load.
- @type filename: string
- """
-
diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py
deleted file mode 100644
index 21ddf439924..00000000000
--- a/source/gameengine/PyDoc/KX_GameObject.py
+++ /dev/null
@@ -1,504 +0,0 @@
-# $Id$
-# Documentation for game objects
-
-# from SCA_IObject import *
-# from SCA_ISensor import *
-# from SCA_IController import *
-# from SCA_IActuator import *
-
-
-class KX_GameObject: # (SCA_IObject)
- """
- All game objects are derived from this class.
-
- Properties assigned to game objects are accessible as attributes of this class.
- - note: Calling ANY method or attribute on an object that has been removed from a scene will raise a RuntimeError, if an object may have been removed since last accessing it use the L{isValid} attribute to check.
-
- @ivar name: The object's name. (Read only)
- - note: Currently (Blender 2.49) the prefix "OB" is added to all objects name. This may change in blender 2.5.
- @type name: string.
- @ivar mass: The object's mass
- - note: The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0
- @type mass: float
- @ivar linVelocityMin: Enforces the object keeps moving at a minimum velocity.
- - note: Applies to dynamic and rigid body objects only.
- - note: A value of 0.0 disables this option.
- - note: While objects are stationary the minimum velocity will not be applied.
- @type linVelocityMin: float
- @ivar linVelocityMax: Clamp the maximum linear velocity to prevent objects moving beyond a set speed.
- - note: Applies to dynamic and rigid body objects only.
- - note: A value of 0.0 disables this option (rather then setting it stationary).
- @type linVelocityMax: float
- @ivar localInertia: the object's inertia vector in local coordinates. Read only.
- @type localInertia: list [ix, iy, iz]
- @ivar parent: The object's parent object. (Read only)
- @type parent: L{KX_GameObject} or None
- @ivar visible: visibility flag.
- - note: Game logic will still run for invisible objects.
- @type visible: boolean
- @ivar occlusion: occlusion capability flag.
- @type occlusion: boolean
- @ivar position: The object's position.
- DEPRECATED: use localPosition and worldPosition
- @type position: list [x, y, z] On write: local position, on read: world position
- @ivar orientation: The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
- DEPRECATED: use localOrientation and worldOrientation
- @type orientation: 3x3 Matrix [[float]] On write: local orientation, on read: world orientation
- @ivar scaling: The object's scaling factor. list [sx, sy, sz]
- DEPRECATED: use localScaling and worldScaling
- @type scaling: list [sx, sy, sz] On write: local scaling, on read: world scaling
- @ivar localOrientation: The object's local orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
- @type localOrientation: 3x3 Matrix [[float]]
- @ivar worldOrientation: The object's world orientation. Read-only.
- @type worldOrientation: 3x3 Matrix [[float]]
- @ivar localScaling: The object's local scaling factor.
- @type localScaling: list [sx, sy, sz]
- @ivar worldScaling: The object's world scaling factor. Read-only
- @type worldScaling: list [sx, sy, sz]
- @ivar localPosition: The object's local position.
- @type localPosition: list [x, y, z]
- @ivar worldPosition: The object's world position.
- @type worldPosition: list [x, y, z]
- @ivar timeOffset: adjust the slowparent delay at runtime.
- @type timeOffset: float
- @ivar state: the game object's state bitmask, using the first 30 bits, one bit must always be set.
- @type state: int
- @ivar meshes: a list meshes for this object.
- - note: Most objects use only 1 mesh.
- - note: Changes to this list will not update the KX_GameObject.
- @type meshes: list of L{KX_MeshProxy}
- @ivar sensors: a list of L{SCA_ISensor} objects.
- - note: This attribute is experemental and may be removed (but probably wont be).
- - note: Changes to this list will not update the KX_GameObject.
- @type sensors: list
- @ivar controllers: a list of L{SCA_IController} objects.
- - note: This attribute is experemental and may be removed (but probably wont be).
- - note: Changes to this list will not update the KX_GameObject.
- @type controllers: list of L{SCA_ISensor}.
- @ivar actuators: a list of L{SCA_IActuator} objects.
- - note: This attribute is experemental and may be removed (but probably wont be).
- - note: Changes to this list will not update the KX_GameObject.
- @type actuators: list
- @ivar isValid: Retuerns fails when the object has been removed from the scene and can no longer be used.
- @type isValid: bool
- """
- def endObject(visible):
- """
- Delete this object, can be used inpace of the EndObject Actuator.
- The actual removal of the object from the scene is delayed.
- """
- def replaceMesh(mesh_name):
- """
- Replace the mesh of this object with a new mesh. This works the same was as the actuator.
- @type mesh_name: string
- """
- def getVisible():
- """
- Gets the game object's visible flag. (B{deprecated})
-
- @rtype: boolean
- """
- def setVisible(visible, recursive):
- """
- Sets the game object's visible flag.
-
- @type visible: boolean
- @type recursive: boolean
- @param recursive: optional argument to set all childrens visibility flag too.
- """
- def setOcclusion(occlusion, recursive):
- """
- Sets the game object's occlusion capability.
-
- @type visible: boolean
- @type recursive: boolean
- @param recursive: optional argument to set all childrens occlusion flag too.
- """
- def getState():
- """
- Gets the game object's state bitmask. (B{deprecated})
-
- @rtype: int
- @return: the objects state.
- """
- def setState(state):
- """
- Sets the game object's state flag. (B{deprecated}).
- The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
-
- @type state: integer
- """
- def setPosition(pos):
- """
- Sets the game object's position. (B{deprecated})
- Global coordinates for root object, local for child objects.
-
-
- @type pos: [x, y, z]
- @param pos: the new position, in local coordinates.
- """
- def setWorldPosition(pos):
- """
- Sets the game object's position in world coordinates regardless if the object is root or child.
-
- @type pos: [x, y, z]
- @param pos: the new position, in world coordinates.
- """
- def getPosition():
- """
- Gets the game object's position. (B{deprecated})
-
- @rtype: list [x, y, z]
- @return: the object's position in world coordinates.
- """
- def setOrientation(orn):
- """
- Sets the game object's orientation. (B{deprecated})
-
- @type orn: 3x3 rotation matrix, or Quaternion.
- @param orn: a rotation matrix specifying the new rotation.
- @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
- """
- def alignAxisToVect(vect, axis):
- """
- Aligns any of the game object's axis along the given vector.
-
- @type vect: 3d vector.
- @param vect: a vector to align the axis.
- @type axis: integer.
- @param axis:The axis you want to align
- - 0: X axis
- - 1: Y axis
- - 2: Z axis (default)
- """
- def getAxisVect(vect):
- """
- Returns the axis vector rotates by the objects worldspace orientation.
- This is the equivalent if multiplying the vector by the orientation matrix.
-
- @type vect: 3d vector.
- @param vect: a vector to align the axis.
- @rtype: 3d vector.
- @return: The vector in relation to the objects rotation.
-
- """
- def getOrientation():
- """
- Gets the game object's orientation. (B{deprecated})
-
- @rtype: 3x3 rotation matrix
- @return: The game object's rotation matrix
- @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
- """
- def applyMovement(movement, local = 0):
- """
- Sets the game object's movement.
-
- @type movement: 3d vector.
- @param movement: movement vector.
- @type local: boolean
- @param local: - False: you get the "global" movement ie: relative to world orientation (default).
- - True: you get the "local" movement ie: relative to object orientation.
- """
- def applyRotation(rotation, local = 0):
- """
- Sets the game object's rotation.
-
- @type rotation: 3d vector.
- @param rotation: rotation vector.
- @type local: boolean
- @param local: - False: you get the "global" rotation ie: relative to world orientation (default).
- - True: you get the "local" rotation ie: relative to object orientation.
- """
- def applyForce(force, local = 0):
- """
- Sets the game object's force.
-
- This requires a dynamic object.
-
- @type force: 3d vector.
- @param force: force vector.
- @type local: boolean
- @param local: - False: you get the "global" force ie: relative to world orientation (default).
- - True: you get the "local" force ie: relative to object orientation.
- """
- def applyTorque(torque, local = 0):
- """
- Sets the game object's torque.
-
- This requires a dynamic object.
-
- @type torque: 3d vector.
- @param torque: torque vector.
- @type local: boolean
- @param local: - False: you get the "global" torque ie: relative to world orientation (default).
- - True: you get the "local" torque ie: relative to object orientation.
- """
- def getLinearVelocity(local = 0):
- """
- Gets the game object's linear velocity.
-
- This method returns the game object's velocity through it's centre of mass,
- ie no angular velocity component.
-
- @type local: boolean
- @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
- - True: you get the "local" velocity ie: relative to object orientation.
- @rtype: list [vx, vy, vz]
- @return: the object's linear velocity.
- """
- def setLinearVelocity(velocity, local = 0):
- """
- Sets the game object's linear velocity.
-
- This method sets game object's velocity through it's centre of mass,
- ie no angular velocity component.
-
- This requires a dynamic object.
-
- @type velocity: 3d vector.
- @param velocity: linear velocity vector.
- @type local: boolean
- @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
- - True: you get the "local" velocity ie: relative to object orientation.
- """
- def getAngularVelocity(local = 0):
- """
- Gets the game object's angular velocity.
-
- @type local: boolean
- @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
- - True: you get the "local" velocity ie: relative to object orientation.
- @rtype: list [vx, vy, vz]
- @return: the object's angular velocity.
- """
- def setAngularVelocity(velocity, local = 0):
- """
- Sets the game object's angular velocity.
-
- This requires a dynamic object.
-
- @type velocity: 3d vector.
- @param velocity: angular velocity vector.
- @type local: boolean
- @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
- - True: you get the "local" velocity ie: relative to object orientation.
- """
- def getVelocity(point):
- """
- Gets the game object's velocity at the specified point.
-
- Gets the game object's velocity at the specified point, including angular
- components.
-
- @type point: list [x, y, z]
- @param point: the point to return the velocity for, in local coordinates. (optional: default = [0, 0, 0])
- @rtype: list [vx, vy, vz]
- @return: the velocity at the specified point.
- """
- def getMass():
- """
- Gets the game object's mass. (B{deprecated})
-
- @rtype: float
- @return: the object's mass.
- """
- def getReactionForce():
- """
- Gets the game object's reaction force.
-
- The reaction force is the force applied to this object over the last simulation timestep.
- This also includes impulses, eg from collisions.
-
- (B{This is not implimented for bullet physics at the moment})
-
- @rtype: list [fx, fy, fz]
- @return: the reaction force of this object.
- """
- def applyImpulse(point, impulse):
- """
- Applies an impulse to the game object.
-
- This will apply the specified impulse to the game object at the specified point.
- If point != getPosition(), applyImpulse will also change the object's angular momentum.
- Otherwise, only linear momentum will change.
-
- @type point: list [x, y, z]
- @param point: the point to apply the impulse to (in world coordinates)
- """
- def suspendDynamics():
- """
- Suspends physics for this object.
- """
- def restoreDynamics():
- """
- Resumes physics for this object.
- @Note: The objects linear velocity will be applied from when the dynamics were suspended.
- """
- def enableRigidBody():
- """
- Enables rigid body physics for this object.
-
- Rigid body physics allows the object to roll on collisions.
- @Note: This is not working with bullet physics yet.
- """
- def disableRigidBody():
- """
- Disables rigid body physics for this object.
- @Note: This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later.
- """
- def getParent():
- """
- Gets this object's parent. (B{deprecated})
-
- @rtype: L{KX_GameObject}
- @return: this object's parent object, or None if this object has no parent.
- """
- def setParent(parent):
- """
- Sets this object's parent.
-
- @type parent: L{KX_GameObject}
- @param parent: new parent object.
- """
- def removeParent():
- """
- Removes this objects parent.
- """
- def getChildren():
- """
- Return a list of immediate children of this object.
- @rtype: L{CListValue<CListValue.CListValue>} of L{KX_GameObject<KX_GameObject.KX_GameObject>}
- @return: a list of all this objects children.
- """
- def getChildrenRecursive():
- """
- Return a list of children of this object, including all their childrens children.
- @rtype: L{CListValue<CListValue.CListValue>} of L{KX_GameObject<KX_GameObject.KX_GameObject>}
- @return: a list of all this objects children recursivly.
- """
- def getMesh(mesh):
- """
- Gets the mesh object for this object.
-
- @type mesh: integer
- @param mesh: the mesh object to return (optional: default mesh = 0)
- @rtype: L{KX_MeshProxy}
- @return: the first mesh object associated with this game object, or None if this object has no meshs.
- """
- def getPhysicsId():
- """
- Returns the user data object associated with this game object's physics controller.
- """
- def getPropertyNames():
- """
- Gets a list of all property names.
- @rtype: list
- @return: All property names for this object.
- """
- def getDistanceTo(other):
- """
- Returns the distance to another object or point.
-
- @param other: a point or another L{KX_GameObject} to measure the distance to.
- @type other: L{KX_GameObject} or list [x, y, z]
- @rtype: float
- """
- def getVectTo(other):
- """
- Returns the vector and the distance to another object or point.
- The vector is normalized unless the distance is 0, in which a NULL vector is returned.
-
- @param other: a point or another L{KX_GameObject} to get the vector and distance to.
- @type other: L{KX_GameObject} or list [x, y, z]
- @rtype: 3-tuple (float, 3-tuple (x,y,z), 3-tuple (x,y,z))
- @return: (distance, globalVector(3), localVector(3))
- """
- def rayCastTo(other,dist,prop):
- """
- Look towards another point/object and find first object hit within dist that matches prop.
-
- The ray is always casted from the center of the object, ignoring the object itself.
- The ray is casted towards the center of another object or an explicit [x,y,z] point.
- Use rayCast() if you need to retrieve the hit point
-
- @param other: [x,y,z] or object towards which the ray is casted
- @type other: L{KX_GameObject} or 3-tuple
- @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
- @type dist: float
- @param prop: property name that object must have; can be omitted => detect any object
- @type prop: string
- @rtype: L{KX_GameObject}
- @return: the first object hit or None if no object or object does not match prop
- """
- def rayCast(objto,objfrom,dist,prop,face,xray,poly):
- """
- Look from a point/object to another point/object and find first object hit within dist that matches prop.
- if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
- if poly is 1, returns a 4-tuple with in addition a L{KX_PolyProxy} as 4th element.
-
- Ex::
- # shoot along the axis gun-gunAim (gunAim should be collision-free)
- ob,point,normal = gun.rayCast(gunAim,None,50)
- if ob:
- # hit something
-
- Notes:
- The ray ignores the object on which the method is called.
- It is casted from/to object center or explicit [x,y,z] points.
-
- The face paremeter determines the orientation of the normal::
- 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
- 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
-
- The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
- The prop and xray parameters interact as follow::
- prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
- prop off, xray on : idem.
- prop on, xray off: return closest hit if it matches prop, no hit otherwise.
- prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
- The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
- If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
-
- The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
-
- @param objto: [x,y,z] or object to which the ray is casted
- @type objto: L{KX_GameObject} or 3-tuple
- @param objfrom: [x,y,z] or object from which the ray is casted; None or omitted => use self object center
- @type objfrom: L{KX_GameObject} or 3-tuple or None
- @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
- @type dist: float
- @param prop: property name that object must have; can be omitted => detect any object
- @type prop: string
- @param face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
- @type face: int
- @param xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
- @type xray: int
- @param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy}
- @type poly: int
- @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz))
- or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy})
- @return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon)
- If no hit, returns (None,None,None) or (None,None,None,None)
- If the object hit is not a static mesh, polygon is None
- """
- def setCollisionMargin(margin):
- """
- Set the objects collision margin.
-
- note: If this object has no physics controller (a physics ID of zero), this function will raise RuntimeError.
-
- @type margin: float
- @param margin: the collision margin distance in blender units.
- """
- def sendMessage(subject, body="", to=""):
- """
- Sends a message.
-
- @param subject: The subject of the message
- @type subject: string
- @param body: The body of the message (optional)
- @type body: string
- @param to: The name of the object to send the message to (optional)
- @type to: string
- """
diff --git a/source/gameengine/PyDoc/KX_IpoActuator.py b/source/gameengine/PyDoc/KX_IpoActuator.py
deleted file mode 100644
index ebc0b855f0a..00000000000
--- a/source/gameengine/PyDoc/KX_IpoActuator.py
+++ /dev/null
@@ -1,124 +0,0 @@
-# $Id$
-# Documentation for KX_IpoActuator
-from SCA_IActuator import *
-
-class KX_IpoActuator(SCA_IActuator):
- """
- IPO actuator activates an animation.
-
- @ivar startFrame: Start frame.
- @type startFrame: float
- @ivar endFrame: End frame.
- @type endFrame: float
- @ivar propName: Use this property to define the Ipo position
- @type propName: string
- @ivar framePropName: Assign this property this action current frame number
- @type framePropName: string
- @ivar type: Play mode for the ipo. (In GameLogic.KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND, KX_IPOACT_FROM_PROP)
- @type type: int
- @ivar useIpoAsForce: Apply Ipo as a global or local force depending on the local option (dynamic objects only)
- @type useIpoAsForce: bool
- @ivar useIpoAdd: Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag
- @type useIpoAdd: bool
- @ivar useIpoLocal: Let the ipo acts in local coordinates, used in Force and Add mode.
- @type useIpoLocal: bool
- @ivar useChildren: Update IPO on all children Objects as well
- @type useChildren: bool
- """
- def set(mode, startframe, endframe, force):
- """
- Sets the properties of the actuator. (B{deprecated})
-
- @param mode: "Play", "PingPong", "Flipper", "LoopStop", "LoopEnd" or "FromProp"
- @type mode: string
- @param startframe: first frame to use
- @type startframe: integer
- @param endframe: last frame to use
- @type endframe: integer
- @param force: special mode
- @type force: integer (0=normal, 1=interpret location as force, 2=additive)
- """
- def setProperty(property):
- """
- Sets the name of the property to be used in FromProp mode. (B{deprecated})
-
- @type property: string
- """
- def setStart(startframe):
- """
- Sets the frame from which the IPO starts playing. (B{deprecated})
-
- @type startframe: integer
- """
- def getStart():
- """
- Returns the frame from which the IPO starts playing. (B{deprecated})
-
- @rtype: integer
- """
- def setEnd(endframe):
- """
- Sets the frame at which the IPO stops playing. (B{deprecated})
-
- @type endframe: integer
- """
- def getEnd():
- """
- Returns the frame at which the IPO stops playing. (B{deprecated})
-
- @rtype: integer
- """
- def setIpoAsForce(force):
- """
- Set whether to interpret the ipo as a force rather than a displacement. (B{deprecated})
-
- @type force: boolean
- @param force: KX_TRUE or KX_FALSE
- """
- def getIpoAsForce():
- """
- Returns whether to interpret the ipo as a force rather than a displacement. (B{deprecated})
-
- @rtype: boolean
- """
- def setIpoAdd(add):
- """
- Set whether to interpret the ipo as additive rather than absolute. (B{deprecated})
-
- @type add: boolean
- @param add: KX_TRUE or KX_FALSE
- """
- def getIpoAdd():
- """
- Returns whether to interpret the ipo as additive rather than absolute. (B{deprecated})
-
- @rtype: boolean
- """
- def setType(mode):
- """
- Sets the operation mode of the actuator. (B{deprecated})
-
- @param mode: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
- @type mode: string
- """
- def getType():
- """
- Returns the operation mode of the actuator. (B{deprecated})
-
- @rtype: integer
- @return: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
- """
- def setForceIpoActsLocal(local):
- """
- Set whether to apply the force in the object's local
- coordinates rather than the world global coordinates. (B{deprecated})
-
- @param local: Apply the ipo-as-force in the object's local
- coordinates? (KX_TRUE, KX_FALSE)
- @type local: boolean
- """
- def getForceIpoActsLocal():
- """
- Return whether to apply the force in the object's local
- coordinates rather than the world global coordinates. (B{deprecated})
- """
diff --git a/source/gameengine/PyDoc/KX_LightObject.py b/source/gameengine/PyDoc/KX_LightObject.py
deleted file mode 100644
index 8cc1787887b..00000000000
--- a/source/gameengine/PyDoc/KX_LightObject.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# $Id$
-# Documentation for Light game objects.
-from KX_GameObject import *
-
-class KX_LightObject(KX_GameObject):
- """
- A Light object.
-
- Example:
-
- # Turn on a red alert light.
- import GameLogic
-
- co = GameLogic.getCurrentController()
- light = co.getOwner()
-
- light.energy = 1.0
- light.colour = [1.0, 0.0, 0.0]
-
- @group Constants: NORMAL, SPOT, SUN
- @ivar SPOT: A spot light source. See attribute 'type'
- @ivar SUN: A point light source with no attenuation. See attribute 'type'
- @ivar NORMAL: A point light source. See attribute 'type'
-
- @ivar type: The type of light - must be SPOT, SUN or NORMAL
- @ivar layer: The layer mask that this light affects object on.
- @type layer: bitfield
- @ivar energy: The brightness of this light.
- @type energy: float
- @ivar distance: The maximum distance this light can illuminate. (SPOT and NORMAL lights only)
- @type distance: float
- @ivar colour: The colour of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0]
- @type colour: list [r, g, b]
- @ivar color: Synonym for colour.
- @ivar lin_attenuation: The linear component of this light's attenuation. (SPOT and NORMAL lights only)
- @type lin_attenuation: float
- @ivar quad_attenuation: The quadratic component of this light's attenuation (SPOT and NORMAL lights only)
- @type quad_attenuation: float
- @ivar spotsize: The cone angle of the spot light, in degrees. (float) (SPOT lights only)
- 0.0 <= spotsize <= 180.0. Spotsize = 360.0 is also accepted.
- @ivar spotblend: Specifies the intensity distribution of the spot light. (float) (SPOT lights only)
- Higher values result in a more focused light source.
- 0.0 <= spotblend <= 1.0.
-
- """
diff --git a/source/gameengine/PyDoc/KX_MeshProxy.py b/source/gameengine/PyDoc/KX_MeshProxy.py
deleted file mode 100644
index e8839ac484c..00000000000
--- a/source/gameengine/PyDoc/KX_MeshProxy.py
+++ /dev/null
@@ -1,132 +0,0 @@
-# $Id$
-# Documentation for KX_MeshProxy
-
-class KX_MeshProxy:
- """
- A mesh object.
-
- You can only change the vertex properties of a mesh object, not the mesh topology.
-
- To use mesh objects effectively, you should know a bit about how the game engine handles them.
- 1. Mesh Objects are converted from Blender at scene load.
- 2. The Converter groups polygons by Material. This means they can be sent to the
- renderer efficiently. A material holds:
- 1. The texture.
- 2. The Blender material.
- 3. The Tile properties
- 4. The face properties - (From the "Texture Face" panel)
- 5. Transparency & z sorting
- 6. Light layer
- 7. Polygon shape (triangle/quad)
- 8. Game Object
- 3. Verticies will be split by face if necessary. Verticies can only be shared between
- faces if:
- 1. They are at the same position
- 2. UV coordinates are the same
- 3. Their normals are the same (both polygons are "Set Smooth")
- 4. They are the same colour
- For example: a cube has 24 verticies: 6 faces with 4 verticies per face.
-
- The correct method of iterating over every L{KX_VertexProxy} in a game object::
- import GameLogic
-
- co = GameLogic.getcurrentController()
- obj = co.getOwner()
-
- m_i = 0
- mesh = obj.getMesh(m_i) # There can be more than one mesh...
- while mesh != None:
- for mat in range(mesh.getNumMaterials()):
- for v_index in range(mesh.getVertexArrayLength(mat)):
- vertex = mesh.getVertex(mat, v_index)
- # Do something with vertex here...
- # ... eg: colour the vertex red.
- vertex.colour = [1.0, 0.0, 0.0, 1.0]
- m_i += 1
- mesh = obj.getMesh(m_i)
-
- @ivar materials:
- @type materials: list of L{KX_BlenderMaterial} or L{KX_PolygonMaterial} types
-
- @ivar numPolygons:
- @type numPolygons: integer
-
- @ivar numMaterials:
- @type numMaterials: integer
- """
-
- def getNumMaterials():
- """
- Gets the number of materials associated with this object.
-
- @rtype: integer
- """
-
- def getMaterialName(matid):
- """
- Gets the name of the specified material.
-
- @type matid: integer
- @param matid: the specified material.
- @rtype: string
- @return: the attached material name.
- """
- def getTextureName(matid):
- """
- Gets the name of the specified material's texture.
-
- @type matid: integer
- @param matid: the specified material
- @rtype: string
- @return: the attached material's texture name.
- """
- def getVertexArrayLength(matid):
- """
- Gets the length of the vertex array associated with the specified material.
-
- There is one vertex array for each material.
-
- @type matid: integer
- @param matid: the specified material
- @rtype: integer
- @return: the number of verticies in the vertex array.
- """
- def getVertex(matid, index):
- """
- Gets the specified vertex from the mesh object.
-
- @type matid: integer
- @param matid: the specified material
- @type index: integer
- @param index: the index into the vertex array.
- @rtype: L{KX_VertexProxy}
- @return: a vertex object.
- """
- def getNumPolygons():
- """
- Returns the number of polygon in the mesh.
-
- @rtype: integer
- """
- def getPolygon(index):
- """
- Gets the specified polygon from the mesh.
-
- @type index: integer
- @param index: polygon number
- @rtype: L{KX_PolyProxy}
- @return: a polygon object.
- """
- def reinstancePhysicsMesh():
- """
- Updates the physics system with the changed mesh.
-
- A mesh must have only one material with collision flags,
- and have all collision primitives in one vertex array (ie. < 65535 verts) and
- be either a polytope or polyheder mesh. If you don't get a warning in the
- console when the collision type is polytope, the mesh is suitable for reinstance.
-
- @rtype: boolean
- @return: True if reinstance succeeded, False if it failed.
- """
-
diff --git a/source/gameengine/PyDoc/KX_MouseFocusSensor.py b/source/gameengine/PyDoc/KX_MouseFocusSensor.py
deleted file mode 100644
index 24f7716218b..00000000000
--- a/source/gameengine/PyDoc/KX_MouseFocusSensor.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# $Id$
-# Documentation for KX_MouseFocusSensor
-from SCA_MouseSensor import *
-
-class KX_MouseFocusSensor(SCA_MouseSensor):
- """
- The mouse focus sensor detects when the mouse is over the current game object.
-
- The mouse focus sensor works by transforming the mouse coordinates from 2d device
- space to 3d space then raycasting away from the camera.
-
- @ivar raySource: The worldspace source of the ray (the view position)
- @type raySource: list (vector of 3 floats)
- @ivar rayTarget: The worldspace target of the ray.
- @type rayTarget: list (vector of 3 floats)
- @ivar rayDirection: The L{rayTarget} - L{raySource} normalized.
- @type rayDirection: list (normalized vector of 3 floats)
- @ivar hitObject: the last object the mouse was over.
- @type hitObject: L{KX_GameObject<KX_GameObject.KX_GameObject>} or None
- @ivar hitPosition: The worldspace position of the ray intersecton.
- @type hitPosition: list (vector of 3 floats)
- @ivar hitNormal: the worldspace normal from the face at point of intersection.
- @type hitNormal: list (normalized vector of 3 floats)
- """
-
- def getHitNormal():
- """
- Returns the normal (in worldcoordinates) at the point of collision where the object was hit by this ray. (B{deprecated})
-
- @rtype: list [x, y, z]
- @return: the ray collision normal.
- """
- def getHitObject():
- """
- Returns the object that was hit by this ray or None. (B{deprecated})
-
- @rtype: L{KX_GameObject} or None
- @return: the collision object.
- """
- def getHitPosition():
- """
- Returns the position (in worldcoordinates) at the point of collision where the object was hit by this ray. (B{deprecated})
-
- @rtype: list [x, y, z]
- @return: the ray collision position.
- """
- def getRayDirection():
- """
- Returns the normalized direction (in worldcoordinates) of the ray cast by the mouse. (B{deprecated})
-
- @rtype: list [x, y, z]
- @return: the ray direction.
- """
- def getRaySource():
- """
- Returns the position (in worldcoordinates) the ray was cast from by the mouse. (B{deprecated})
-
- @rtype: list [x, y, z]
- @return: the ray source.
- """
- def getRayTarget():
- """
- Returns the target of the ray (in worldcoordinates) that seeks the focus object. (B{deprecated})
-
- @rtype: list [x, y, z]
- @return: the ray target.
- """ \ No newline at end of file
diff --git a/source/gameengine/PyDoc/KX_NearSensor.py b/source/gameengine/PyDoc/KX_NearSensor.py
deleted file mode 100644
index a8c408827fe..00000000000
--- a/source/gameengine/PyDoc/KX_NearSensor.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# $Id$
-# Documentation for KX_NearSensor
-from KX_TouchSensor import *
-
-class KX_NearSensor(KX_TouchSensor):
- """
- A near sensor is a specialised form of touch sensor.
-
- @ivar distance: The near sensor activates when an object is within this distance.
- @type distance: float
- @ivar resetDistance: The near sensor deactivates when the object exceeds this distance.
- @type resetDistance: float
- """
-
diff --git a/source/gameengine/PyDoc/KX_NetworkMessageActuator.py b/source/gameengine/PyDoc/KX_NetworkMessageActuator.py
deleted file mode 100644
index c9f48d47eb8..00000000000
--- a/source/gameengine/PyDoc/KX_NetworkMessageActuator.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# $Id$
-# Documentation for KX_NetworkMessageActuator
-from SCA_IActuator import *
-
-class KX_NetworkMessageActuator(SCA_IActuator):
- """
- Message Actuator
-
- @ivar propName: Messages will only be sent to objects with the given property name.
- @type propName: string
- @ivar subject: The subject field of the message.
- @type subject: string
- @ivar body: The body of the message.
- @type body: string
- @ivar usePropBody: Send a property instead of a regular body message.
- @type usePropBody: boolean
- """
- def setToPropName(name):
- """
- DEPRECATED: Use the propName property instead.
- Messages will only be sent to objects with the given property name.
-
- @type name: string
- """
- def setSubject(subject):
- """
- DEPRECATED: Use the subject property instead.
- Sets the subject field of the message.
-
- @type subject: string
- """
- def setBodyType(bodytype):
- """
- DEPRECATED: Use the usePropBody property instead.
- Sets the type of body to send.
-
- @type bodytype: boolean
- @param bodytype: True to send the value of a property, False to send the body text.
- """
- def setBody(body):
- """
- DEPRECATED: Use the body property instead.
- Sets the message body.
-
- @type body: string
- @param body: if the body type is True, this is the name of the property to send.
- if the body type is False, this is the text to send.
- """
-
diff --git a/source/gameengine/PyDoc/KX_NetworkMessageSensor.py b/source/gameengine/PyDoc/KX_NetworkMessageSensor.py
deleted file mode 100644
index 0fecad58437..00000000000
--- a/source/gameengine/PyDoc/KX_NetworkMessageSensor.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# $Id$
-# Documentation for KX_NetworkMessageSensor
-from SCA_ISensor import *
-
-class KX_NetworkMessageSensor(SCA_ISensor):
- """
- The Message Sensor logic brick.
-
- Currently only loopback (local) networks are supported.
-
- @ivar subject: The subject the sensor is looking for.
- @type subject: string
- @ivar frameMessageCount: The number of messages received since the last frame.
- (Read-only)
- @type framemessageCount: int
- @ivar subjects: The list of message subjects received. (Read-only)
- @type subjects: list of strings
- @ivar bodies: The list of message bodies received. (Read-only)
- @type bodies: list of strings
- """
-
-
- def setSubjectFilterText(subject):
- """
- DEPRECATED: Use the subject property instead.
- Change the message subject text that this sensor is listening to.
-
- @type subject: string
- @param subject: the new message subject to listen for.
- """
-
- def getFrameMessageCount():
- """
- DEPRECATED: Use the frameMessageCount property instead.
- Get the number of messages received since the last frame.
-
- @rtype: integer
- """
- def getBodies():
- """
- DEPRECATED: Use the bodies property instead.
- Gets the list of message bodies.
-
- @rtype: list
- """
- def getSubject():
- """
- DEPRECATED: Use the subject property instead.
- Gets the message subject this sensor is listening for from the Subject: field.
-
- @rtype: string
- """
- def getSubjects():
- """
- DEPRECATED: Use the subjects property instead.
- Gets the list of message subjects received.
-
- @rtype: list
- """
- \ No newline at end of file
diff --git a/source/gameengine/PyDoc/KX_ObjectActuator.py b/source/gameengine/PyDoc/KX_ObjectActuator.py
deleted file mode 100644
index b7b76473292..00000000000
--- a/source/gameengine/PyDoc/KX_ObjectActuator.py
+++ /dev/null
@@ -1,250 +0,0 @@
-# $Id$
-# Documentation for KX_ObjectActuator
-from SCA_IActuator import *
-
-class KX_ObjectActuator(SCA_IActuator):
- """
- The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement,
- velocity, or angular velocity to an object.
- Servo control allows to regulate force to achieve a certain speed target.
- """
- def getForce():
- """
- Returns the force applied by the actuator.
-
- @rtype: list [fx, fy, fz, local]
- @return: A four item list, containing the vector force, and a flag specifying whether the force is local.
- """
- def setForce(fx, fy, fz, local):
- """
- Sets the force applied by the actuator.
-
- @type fx: float
- @param fx: the x component of the force.
- @type fy: float
- @param fy: the z component of the force.
- @type fz: float
- @param fz: the z component of the force.
- @type local: boolean
- @param local: - False: the force is applied in world coordinates.
- - True: the force is applied in local coordinates.
- """
- def getTorque():
- """
- Returns the torque applied by the actuator.
-
- @rtype: list [S{Tau}x, S{Tau}y, S{Tau}z, local]
- @return: A four item list, containing the vector torque, and a flag specifying whether
- the torque is applied in local coordinates (True) or world coordinates (False)
- """
- def setTorque(tx, ty, tz, local):
- """
- Sets the torque applied by the actuator.
-
- @type tx: float
- @param tx: the x component of the torque.
- @type ty: float
- @param ty: the z component of the torque.
- @type tz: float
- @param tz: the z component of the torque.
- @type local: boolean
- @param local: - False: the torque is applied in world coordinates.
- - True: the torque is applied in local coordinates.
- """
- def getDLoc():
- """
- Returns the displacement vector applied by the actuator.
-
- @rtype: list [dx, dy, dz, local]
- @return: A four item list, containing the vector displacement, and whether
- the displacement is applied in local coordinates (True) or world
- coordinates (False)
- """
- def setDLoc(dx, dy, dz, local):
- """
- Sets the displacement vector applied by the actuator.
-
- Since the displacement is applied every frame, you must adjust the displacement
- based on the frame rate, or you game experience will depend on the player's computer
- speed.
-
- @type dx: float
- @param dx: the x component of the displacement vector.
- @type dy: float
- @param dy: the z component of the displacement vector.
- @type dz: float
- @param dz: the z component of the displacement vector.
- @type local: boolean
- @param local: - False: the displacement vector is applied in world coordinates.
- - True: the displacement vector is applied in local coordinates.
- """
- def getDRot():
- """
- Returns the angular displacement vector applied by the actuator.
-
- @rtype: list [dx, dy, dz, local]
- @return: A four item list, containing the angular displacement vector, and whether
- the displacement is applied in local coordinates (True) or world
- coordinates (False)
- """
- def setDRot(dx, dy, dz, local):
- """
- Sets the angular displacement vector applied by the actuator.
-
- Since the displacement is applied every frame, you must adjust the displacement
- based on the frame rate, or you game experience will depend on the player's computer
- speed.
-
- @type dx: float
- @param dx: the x component of the angular displacement vector.
- @type dy: float
- @param dy: the z component of the angular displacement vector.
- @type dz: float
- @param dz: the z component of the angular displacement vector.
- @type local: boolean
- @param local: - False: the angular displacement vector is applied in world coordinates.
- - True: the angular displacement vector is applied in local coordinates.
- """
- def getLinearVelocity():
- """
- Returns the linear velocity applied by the actuator.
- For the servo control actuator, this is the target speed.
-
- @rtype: list [vx, vy, vz, local]
- @return: A four item list, containing the vector velocity, and whether the velocity is applied in local coordinates (True) or world coordinates (False)
- """
- def setLinearVelocity(vx, vy, vz, local):
- """
- Sets the linear velocity applied by the actuator.
- For the servo control actuator, sets the target speed.
-
- @type vx: float
- @param vx: the x component of the velocity vector.
- @type vy: float
- @param vy: the z component of the velocity vector.
- @type vz: float
- @param vz: the z component of the velocity vector.
- @type local: boolean
- @param local: - False: the velocity vector is in world coordinates.
- - True: the velocity vector is in local coordinates.
- """
- def getAngularVelocity():
- """
- Returns the angular velocity applied by the actuator.
-
- @rtype: list [S{omega}x, S{omega}y, S{omega}z, local]
- @return: A four item list, containing the vector velocity, and whether
- the velocity is applied in local coordinates (True) or world
- coordinates (False)
- """
- def setAngularVelocity(wx, wy, wz, local):
- """
- Sets the angular velocity applied by the actuator.
-
- @type wx: float
- @param wx: the x component of the velocity vector.
- @type wy: float
- @param wy: the z component of the velocity vector.
- @type wz: float
- @param wz: the z component of the velocity vector.
- @type local: boolean
- @param local: - False: the velocity vector is applied in world coordinates.
- - True: the velocity vector is applied in local coordinates.
- """
- def getDamping():
- """
- Returns the damping parameter of the servo controller.
-
- @rtype: integer
- @return: the time constant of the servo controller in frame unit.
- """
- def setDamping(damp):
- """
- Sets the damping parameter of the servo controller.
-
- @type damp: integer
- @param damp: the damping parameter in frame unit.
- """
- def getForceLimitX():
- """
- Returns the min/max force limit along the X axis used by the servo controller.
-
- @rtype: list [min, max, enabled]
- @return: A three item list, containing the min and max limits of the force as float
- and whether the limits are active(true) or inactive(true)
- """
- def setForceLimitX(min, max, enable):
- """
- Sets the min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
-
- @type min: float
- @param min: the minimum value of the force along the X axis.
- @type max: float
- @param max: the maximum value of the force along the X axis.
- @type enable: boolean
- @param enable: - True: the force will be limited to the min/max
- - False: the force will not be limited
- """
- def getForceLimitY():
- """
- Returns the min/max force limit along the Y axis used by the servo controller.
-
- @rtype: list [min, max, enabled]
- @return: A three item list, containing the min and max limits of the force as float
- and whether the limits are active(true) or inactive(true)
- """
- def setForceLimitY(min, max, enable):
- """
- Sets the min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
-
- @type min: float
- @param min: the minimum value of the force along the Y axis.
- @type max: float
- @param max: the maximum value of the force along the Y axis.
- @type enable: boolean
- @param enable: - True: the force will be limited to the min/max
- - False: the force will not be limited
- """
- def getForceLimitZ():
- """
- Returns the min/max force limit along the Z axis used by the servo controller.
-
- @rtype: list [min, max, enabled]
- @return: A three item list, containing the min and max limits of the force as float
- and whether the limits are active(true) or inactive(true)
- """
- def setForceLimitZ(min, max, enable):
- """
- Sets the min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
-
- @type min: float
- @param min: the minimum value of the force along the Z axis.
- @type max: float
- @param max: the maximum value of the force along the Z axis.
- @type enable: boolean
- @param enable: - True: the force will be limited to the min/max
- - False: the force will not be limited
- """
- def getPID():
- """
- Returns the PID coefficient of the servo controller.
-
- @rtype: list [P, I, D]
- @return: A three item list, containing the PID coefficient as floats:
- P : proportional coefficient
- I : Integral coefficient
- D : Derivate coefficient
- """
- def setPID(P, I, D):
- """
- Sets the PID coefficients of the servo controller.
-
- @type P: flat
- @param P: proportional coefficient
- @type I: float
- @param I: Integral coefficient
- @type D: float
- @param D: Derivate coefficient
- """
-
-
diff --git a/source/gameengine/PyDoc/KX_ParentActuator.py b/source/gameengine/PyDoc/KX_ParentActuator.py
deleted file mode 100644
index 2f5d9515d0b..00000000000
--- a/source/gameengine/PyDoc/KX_ParentActuator.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# $Id$
-# Documentation for KX_ParentActuator
-from SCA_IActuator import *
-
-class KX_ParentActuator(SCA_IActuator):
- """
- The parent actuator can set or remove an objects parent object.
- @ivar object: the object this actuator sets the parent too.
- @type object: KX_GameObject or None
- """
- def setObject(object):
- """
- DEPRECATED: Use the object property.
- Sets the object to set as parent.
-
- Object can be either a L{KX_GameObject} or the name of the object.
-
- @type object: L{KX_GameObject}, string or None
- """
- def getObject(name_only = 1):
- """
- DEPRECATED: Use the object property.
- Returns the name of the object to change to.
- @type name_only: bool
- @param name_only: optional argument, when 0 return a KX_GameObject
- @rtype: string, KX_GameObject or None if no object is set
- """
diff --git a/source/gameengine/PyDoc/KX_PhysicsObjectWrapper.py b/source/gameengine/PyDoc/KX_PhysicsObjectWrapper.py
deleted file mode 100644
index 2171cf4c7b6..00000000000
--- a/source/gameengine/PyDoc/KX_PhysicsObjectWrapper.py
+++ /dev/null
@@ -1,47 +0,0 @@
-class KX_PhysicsObjectWrapper: # (PyObjectPlus)
- """
- KX_PhysicsObjectWrapper
-
- All placeholders have a __ prefix
- """
- def __setActive(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
-
- def __setAngularVelocity(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setLinearVelocity(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setPosition(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
diff --git a/source/gameengine/PyDoc/KX_PolyProxy.py b/source/gameengine/PyDoc/KX_PolyProxy.py
deleted file mode 100644
index bcd42c2ac2e..00000000000
--- a/source/gameengine/PyDoc/KX_PolyProxy.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# $Id$
-# Documentation for the polygon proxy class
-
-class KX_PolyProxy:
- """
- A polygon holds the index of the vertex forming the poylgon.
-
- Note:
- The polygon attributes are read-only, you need to retrieve the vertex proxy if you want
- to change the vertex settings.
-
- @ivar matname: The name of polygon material, empty if no material.
- @type matname: string
- @ivar material: The material of the polygon
- @type material: L{KX_PolygonMaterial} or KX_BlenderMaterial
- @ivar texture: The texture name of the polygon.
- @type texture: string
- @ivar matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
- @type matid: integer
- @ivar v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
- @type v1: integer
- @ivar v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
- @type v2: integer
- @ivar v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
- @type v3: integer
- @ivar v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
- use this to retrieve vertex proxy from mesh proxy
- @type v4: integer
- @ivar visible: visible state of the polygon: 1=visible, 0=invisible
- @type visible: integer
- @ivar collide: collide state of the polygon: 1=receives collision, 0=collision free.
- @type collide: integer
- """
-
- def getMaterialName():
- """
- Returns the polygon material name with MA prefix
-
- @rtype: string
- @return: material name
- """
- def getMaterial():
- """
- Returns the polygon material
-
- @rtype: L{KX_PolygonMaterial} or KX_BlenderMaterial
- """
- def getTextureName():
- """
- Returns the polygon texture name
-
- @rtype: string
- @return: texture name
- """
- def getMaterialIndex():
- """
- Returns the material bucket index of the polygon.
- This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}.
-
- @rtype: integer
- @return: the material index in the mesh
- """
- def getNumVertex():
- """
- Returns the number of vertex of the polygon.
-
- @rtype: integer
- @return: number of vertex, 3 or 4.
- """
- def isVisible():
- """
- Returns whether the polygon is visible or not
-
- @rtype: integer
- @return: 0=invisible, 1=visible
- """
- def isCollider():
- """
- Returns whether the polygon is receives collision or not
-
- @rtype: integer
- @return: 0=collision free, 1=receives collision
- """
- def getVertexIndex(vertex):
- """
- Returns the mesh vertex index of a polygon vertex
- This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}.
-
- @type vertex: integer
- @param vertex: index of the vertex in the polygon: 0->3
- @rtype: integer
- @return: mesh vertex index
- """
- def getMesh():
- """
- Returns a mesh proxy
-
- @rtype: L{KX_MeshProxy}
- @return: mesh proxy
- """
diff --git a/source/gameengine/PyDoc/KX_PolygonMaterial.py b/source/gameengine/PyDoc/KX_PolygonMaterial.py
deleted file mode 100644
index cfc4257f95d..00000000000
--- a/source/gameengine/PyDoc/KX_PolygonMaterial.py
+++ /dev/null
@@ -1,281 +0,0 @@
-# $Id$
-
-class KX_PolygonMaterial:
- """
- This is the interface to materials in the game engine.
-
- Materials define the render state to be applied to mesh objects.
-
- Warning: Some of the methods/variables are CObjects. If you mix these up,
- you will crash blender.
-
- This example requires:
- - PyOpenGL http://pyopengl.sourceforge.net/
- - GLEWPy http://glewpy.sourceforge.net/
- Example::
-
- import GameLogic
- import OpenGL
- from OpenGL.GL import *
- from OpenGL.GLU import *
- import glew
- from glew import *
-
- glewInit()
-
- vertex_shader = \"\"\"
-
- void main(void)
- {
- gl_Position = ftransform();
- }
- \"\"\"
-
- fragment_shader =\"\"\"
-
- void main(void)
- {
- gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
- }
- \"\"\"
-
- class MyMaterial:
- def __init__(self):
- self.pass_no = 0
- # Create a shader
- self.m_program = glCreateProgramObjectARB()
- # Compile the vertex shader
- self.shader(GL_VERTEX_SHADER_ARB, (vertex_shader))
- # Compile the fragment shader
- self.shader(GL_FRAGMENT_SHADER_ARB, (fragment_shader))
- # Link the shaders together
- self.link()
-
- def PrintInfoLog(self, tag, object):
- \"\"\"
- PrintInfoLog prints the GLSL compiler log
- \"\"\"
- print "Tag: def PrintGLError(self, tag = ""):
-
- def PrintGLError(self, tag = ""):
- \"\"\"
- Prints the current GL error status
- \"\"\"
- if len(tag):
- print tag
- err = glGetError()
- if err != GL_NO_ERROR:
- print "GL Error: %s\\n"%(gluErrorString(err))
-
- def shader(self, type, shaders):
- \"\"\"
- shader compiles a GLSL shader and attaches it to the current
- program.
-
- type should be either GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB
- shaders should be a sequence of shader source to compile.
- \"\"\"
- # Create a shader object
- shader_object = glCreateShaderObjectARB(type)
-
- # Add the source code
- glShaderSourceARB(shader_object, len(shaders), shaders)
-
- # Compile the shader
- glCompileShaderARB(shader_object)
-
- # Print the compiler log
- self.PrintInfoLog("vertex shader", shader_object)
-
- # Check if compiled, and attach if it did
- compiled = glGetObjectParameterivARB(shader_object, GL_OBJECT_COMPILE_STATUS_ARB)
- if compiled:
- glAttachObjectARB(self.m_program, shader_object)
-
- # Delete the object (glAttachObjectARB makes a copy)
- glDeleteObjectARB(shader_object)
-
- # print the gl error log
- self.PrintGLError()
-
- def link(self):
- \"\"\"
- Links the shaders together.
- \"\"\"
- # clear error indicator
- glGetError()
-
- glLinkProgramARB(self.m_program)
-
- self.PrintInfoLog("link", self.m_program)
-
- linked = glGetObjectParameterivARB(self.m_program, GL_OBJECT_LINK_STATUS_ARB)
- if not linked:
- print "Shader failed to link"
- return
-
- glValidateProgramARB(self.m_program)
- valid = glGetObjectParameterivARB(self.m_program, GL_OBJECT_VALIDATE_STATUS_ARB)
- if not valid:
- print "Shader failed to validate"
- return
-
- def activate(self, rasty, cachingInfo, mat):
- self.pass_no+=1
- if (self.pass_no == 1):
- glDisable(GL_COLOR_MATERIAL)
- glUseProgramObjectARB(self.m_program)
- return True
-
- glEnable(GL_COLOR_MATERIAL)
- glUseProgramObjectARB(0)
- self.pass_no = 0
- return False
-
- obj = GameLogic.getCurrentController().getOwner()
-
- mesh = obj.getMesh(0)
-
- for mat in mesh.materials:
- mat.setCustomMaterial(MyMaterial())
- print mat.texture
-
- @ivar texture: Texture name
- @type texture: string (read only)
-
- @ivar gl_texture: OpenGL texture handle (eg for glBindTexture(GL_TEXTURE_2D, gl_texture)
- @type gl_texture: integer (read only)
-
- @ivar material: Material name
- @type material: string (read only)
-
- @ivar tface: Texture face properties
- @type tface: CObject (read only)
-
- @ivar tile: Texture is tiling
- @type tile: boolean
- @ivar tilexrep: Number of tile repetitions in x direction.
- @type tilexrep: integer
- @ivar tileyrep: Number of tile repetitions in y direction.
- @type tileyrep: integer
-
- @ivar drawingmode: Drawing mode for the material.
- - 2 (drawingmode & 4) Textured
- - 4 (drawingmode & 16) Light
- - 14 (drawingmode & 16384) 3d Polygon Text
- @type drawingmode: bitfield
-
- @ivar transparent: This material is transparent. All meshes with this
- material will be rendered after non transparent meshes from back
- to front.
- @type transparent: boolean
-
- @ivar zsort: Transparent polygons in meshes with this material will be sorted back to
- front before rendering.
- Non-Transparent polygons will be sorted front to back before rendering.
- @type zsort: boolean
-
- @ivar lightlayer: Light layers this material affects.
- @type lightlayer: bitfield.
-
- @ivar triangle: Mesh data with this material is triangles. It's probably not safe to change this.
- @type triangle: boolean
-
- @ivar diffuse: The diffuse colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]
- @type diffuse: list [r, g, b]
- @ivar specular: The specular colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]
- @type specular: list [r, g, b]
- @ivar shininess: The shininess (specular exponent) of the material. 0.0 <= shininess <= 128.0
- @type shininess: float
- @ivar specularity: The amount of specular of the material. 0.0 <= specularity <= 1.0
- @type specularity: float
- """
- def updateTexture(tface, rasty):
- """
- Updates a realtime animation.
-
- @param tface: Texture face (eg mat.tface)
- @type tface: CObject
- @param rasty: Rasterizer
- @type rasty: CObject
- """
- def setTexture(tface):
- """
- Sets texture render state.
-
- Example::
- mat.setTexture(mat.tface)
-
- @param tface: Texture face
- @type tface: CObject
- """
- def activate(rasty, cachingInfo):
- """
- Sets material parameters for this object for rendering.
-
- Material Parameters set:
- 1. Texture
- 2. Backface culling
- 3. Line drawing
- 4. Specular Colour
- 5. Shininess
- 6. Diffuse Colour
- 7. Polygon Offset.
-
- @param rasty: Rasterizer instance.
- @type rasty: CObject
- @param cachingInfo: Material cache instance.
- @type cachingInfo: CObject
- """
- def setCustomMaterial(material):
- """
- Sets the material state setup object.
-
- Using this method, you can extend or completely replace the gameengine material
- to do your own advanced multipass effects.
-
- Use this method to register your material class. Instead of the normal material,
- your class's activate method will be called just before rendering the mesh.
- This should setup the texture, material, and any other state you would like.
- It should return True to render the mesh, or False if you are finished. You should
- clean up any state Blender does not set before returning False.
-
- Activate Method Definition::
- def activate(self, rasty, cachingInfo, material):
-
- Example::
- class PyMaterial:
- def __init__(self):
- self.pass_no = -1
-
- def activate(self, rasty, cachingInfo, material):
- # Activate the material here.
- #
- # The activate method will be called until it returns False.
- # Every time the activate method returns True the mesh will
- # be rendered.
- #
- # rasty is a CObject for passing to material.updateTexture()
- # and material.activate()
- # cachingInfo is a CObject for passing to material.activate()
- # material is the KX_PolygonMaterial instance this material
- # was added to
-
- # default material properties:
- self.pass_no += 1
- if self.pass_no == 0:
- material.activate(rasty, cachingInfo)
- # Return True to do this pass
- return True
-
- # clean up and return False to finish.
- self.pass_no = -1
- return False
-
- # Create a new Python Material and pass it to the renderer.
- mat.setCustomMaterial(PyMaterial())
-
- @param material: The material object.
- @type material: instance
- """
-
diff --git a/source/gameengine/PyDoc/KX_RadarSensor.py b/source/gameengine/PyDoc/KX_RadarSensor.py
deleted file mode 100644
index b68bf4ea0f3..00000000000
--- a/source/gameengine/PyDoc/KX_RadarSensor.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# $Id$
-# Documentation for KX_RadarSensor
-from KX_NearSensor import *
-
-class KX_RadarSensor(KX_NearSensor):
- """
- Radar sensor is a near sensor with a conical sensor object.
-
- @ivar coneOrigin: The origin of the cone with which to test. The origin
- is in the middle of the cone.
- (Read only)
- @type coneOrigin: list of floats [x, y, z]
- @ivar coneTarget: The center of the bottom face of the cone with which to test.
- (Read only)
- @type coneTarget: list of floats [x, y, z]
- @ivar distance: The height of the cone with which to test.
- @type distance: float
- @ivar angle: The angle of the cone (in degrees) with which to test.
- @type angle: float from 0 to 360
- @ivar axis: The axis on which the radar cone is cast
- @type axis: int from 0 to 5
- KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y, KX_RADAR_AXIS_POS_Z,
- KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y, KX_RADAR_AXIS_NEG_Z
- """
-
-
- #--The following methods are deprecated, please use properties instead.
- def getConeOrigin():
- """
- Returns the origin of the cone with which to test. The origin
- is in the middle of the cone.
-
- @rtype: list [x, y, z]
- """
-
- def getConeTarget():
- """
- Returns the center of the bottom face of the cone with which to test.
-
- @rtype: list [x, y, z]
- """
-
- def getConeHeight():
- """
- Returns the height of the cone with which to test.
-
- @rtype: float
- """
-
diff --git a/source/gameengine/PyDoc/KX_RaySensor.py b/source/gameengine/PyDoc/KX_RaySensor.py
deleted file mode 100644
index b9de54e92a5..00000000000
--- a/source/gameengine/PyDoc/KX_RaySensor.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# $Id$
-# Documentation for KX_RaySensor
-from SCA_ISensor import *
-
-class KX_RaySensor(SCA_ISensor):
- """
- A ray sensor detects the first object in a given direction.
-
- @ivar property: The property the ray is looking for.
- @type property: string
- @ivar range: The distance of the ray.
- @type range: float
- @ivar useMaterial: Whether or not to look for a material (false = property)
- @type useMaterial: boolean
- @ivar useXRay: Whether or not to use XRay.
- @type useXRay: boolean
- @ivar hitObject: The game object that was hit by the ray. (Read-only)
- @type hitObject: KX_GameObject
- @ivar hitPosition: The position (in worldcoordinates) where the object was hit by the ray. (Read-only)
- @type hitPosition: list [x, y, z]
- @ivar hitNormal: The normal (in worldcoordinates) of the object at the location where the object was hit by the ray. (Read-only)
- @type hitNormal: list [x, y, z]
- @ivar rayDirection: The direction from the ray (in worldcoordinates). (Read-only)
- @type rayDirection: list [x, y, z]
- @ivar axis: The axis the ray is pointing on.
- @type axis: int from 0 to 5
- KX_RAY_AXIS_POS_X, KX_RAY_AXIS_POS_Y, KX_RAY_AXIS_POS_Z,
- KX_RAY_AXIS_NEG_X, KX_RAY_AXIS_NEG_Y, KX_RAY_AXIS_NEG_Z
- """
-
- def getHitObject():
- """
- DEPRECATED: Use the hitObject property instead.
- Returns the game object that was hit by this ray.
-
- @rtype: KX_GameObject
- """
- def getHitPosition():
- """
- DEPRECATED: Use the hitPosition property instead.
- Returns the position (in worldcoordinates) where the object was hit by this ray.
-
- @rtype: list [x, y, z]
- """
- def getHitNormal():
- """
- DEPRECATED: Use the hitNormal property instead.
- Returns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.
-
- @rtype: list [nx, ny, nz]
- """
- def getRayDirection():
- """
- DEPRECATED: Use the rayDirection property instead.
- Returns the direction from the ray (in worldcoordinates)
-
- @rtype: list [dx, dy, dz]
- """
diff --git a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
deleted file mode 100644
index 572b864ff0a..00000000000
--- a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
+++ /dev/null
@@ -1,118 +0,0 @@
-# $Id$
-# Documentation for KX_SCA_AddObjectActuator
-from SCA_IActuator import *
-
-class KX_SCA_AddObjectActuator(SCA_IActuator):
- """
- Edit Object Actuator (in Add Object Mode)
- @ivar object: the object this actuator adds.
- @type object: KX_GameObject or None
- @ivar objectLastCreated: the last added object from this actuator (read only).
- @type objectLastCreated: KX_GameObject or None
- @ivar time: the lifetime of added objects, in frames.
- @type time: integer
- @ivar linearVelocity: the initial linear velocity of added objects.
- @type linearVelocity: list [vx, vy, vz]
- @ivar angularVelocity: the initial angular velocity of added objects.
- @type angularVelocity: list [vx, vy, vz]
-
- @warning: An Add Object actuator will be ignored if at game start, the linked object doesn't exist
- (or is empty) or the linked object is in an active layer.
-
- This will genereate a warning in the console:
-
- C{ERROR: GameObject I{OBName} has a AddObjectActuator I{ActuatorName} without object (in 'nonactive' layer)}
- """
- def setObject(object):
- """
- DEPRECATED: use the object property
- Sets the game object to add.
-
- A copy of the object will be added to the scene when the actuator is activated.
-
- If the object does not exist, this function is ignored.
-
- object can either be a L{KX_GameObject} or the name of an object or None.
-
- @type object: L{KX_GameObject}, string or None
- """
- def getObject(name_only = 0):
- """
- DEPRECATED: use the object property
- Returns the name of the game object to be added.
-
- Returns None if no game object has been assigned to be added.
- @type name_only: bool
- @param name_only: optional argument, when 0 return a KX_GameObject
- @rtype: string, KX_GameObject or None if no object is set
- """
- def setTime(time):
- """
- DEPRECATED: use the time property
- Sets the lifetime of added objects, in frames.
-
- If time == 0, the object will last forever.
-
- @type time: integer
- @param time: The minimum value for time is 0.
- """
- def getTime():
- """
- DEPRECATED: use the time property
- Returns the lifetime of the added object, in frames.
-
- @rtype: integer
- """
- def setLinearVelocity(vx, vy, vz):
- """
- DEPRECATED: use the linearVelocity property
- Sets the initial linear velocity of added objects.
-
- @type vx: float
- @param vx: the x component of the initial linear velocity.
- @type vy: float
- @param vy: the y component of the initial linear velocity.
- @type vz: float
- @param vz: the z component of the initial linear velocity.
- """
- def getLinearVelocity():
- """
- DEPRECATED: use the linearVelocity property
- Returns the initial linear velocity of added objects.
-
- @rtype: list [vx, vy, vz]
- """
- def setAngularVelocity(vx, vy, vz):
- """
- DEPRECATED: use the angularVelocity property
- Sets the initial angular velocity of added objects.
-
- @type vx: float
- @param vx: the x component of the initial angular velocity.
- @type vy: float
- @param vy: the y component of the initial angular velocity.
- @type vz: float
- @param vz: the z component of the initial angular velocity.
- """
- def getAngularVelocity():
- """
- DEPRECATED: use the angularVelocity property
- Returns the initial angular velocity of added objects.
-
- @rtype: list [vx, vy, vz]
- """
- def getLastCreatedObject():
- """
- DEPRECATED: use the objectLastCreated property
- Returns the last object created by this actuator.
-
- @rtype: L{KX_GameObject}
- @return: A L{KX_GameObject} or None if no object has been created.
- """
- def instantAddObject():
- """
- Returns the last object created by this actuator. The object can then be accessed from L{objectLastCreated}.
-
- @rtype: None
- """
-
diff --git a/source/gameengine/PyDoc/KX_SCA_DynamicActuator.py b/source/gameengine/PyDoc/KX_SCA_DynamicActuator.py
deleted file mode 100644
index 22da159ce71..00000000000
--- a/source/gameengine/PyDoc/KX_SCA_DynamicActuator.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# $Id$
-# Documentation for KX_SCA_DynamicActuator
-from SCA_IActuator import *
-
-class KX_SCA_DynamicActuator(SCA_IActuator):
- """
- Dynamic Actuator.
- @ivar operation: the type of operation of the actuator, 0-4
- KX_DYN_RESTORE_DYNAMICS, KX_DYN_DISABLE_DYNAMICS,
- KX_DYN_ENABLE_RIGID_BODY, KX_DYN_DISABLE_RIGID_BODY, KX_DYN_SET_MASS
- @type operation: integer
- @ivar mass: the mass value for the KX_DYN_SET_MASS operation
- @type mass: float
- """
- def setOperation(operation):
- """
- DEPRECATED: Use the operation property instead.
- Set the type of operation when the actuator is activated:
- - 0 = restore dynamics
- - 1 = disable dynamics
- - 2 = enable rigid body
- - 3 = disable rigid body
- - 4 = set mass
- """
- def getOperation():
- """
- DEPRECATED: Use the operation property instead.
- return the type of operation
- """
-
diff --git a/source/gameengine/PyDoc/KX_SCA_EndObjectActuator.py b/source/gameengine/PyDoc/KX_SCA_EndObjectActuator.py
deleted file mode 100644
index 8a7c79bb52b..00000000000
--- a/source/gameengine/PyDoc/KX_SCA_EndObjectActuator.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-# Documentation for KX_SCA_EndObjectActuator
-from SCA_IActuator import *
-
-class KX_SCA_EndObjectActuator(SCA_IActuator):
- """
- Edit Object Actuator (in End Object mode)
-
- This actuator has no python methods.
- """
-
diff --git a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
deleted file mode 100644
index 951c118a99a..00000000000
--- a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# $Id$
-# Documentation for KX_SCA_ReplaceMeshActuator
-from SCA_IActuator import *
-
-class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
- """
- Edit Object actuator, in Replace Mesh mode.
-
- Example::
- # Level-of-detail
- # Switch a game object's mesh based on its depth in the camera view.
- # +----------+ +-----------+ +-------------------------------------+
- # | Always +-----+ Python +-----+ Edit Object (Replace Mesh) LOD.Mesh |
- # +----------+ +-----------+ +-------------------------------------+
- import GameLogic
-
- # List detail meshes here
- # Mesh (name, near, far)
- # Meshes overlap so that they don't 'pop' when on the edge of the distance.
- meshes = ((".Hi", 0.0, -20.0),
- (".Med", -15.0, -50.0),
- (".Lo", -40.0, -100.0)
- )
-
- co = GameLogic.getCurrentController()
- obj = co.getOwner()
- act = co.getActuator("LOD." + obj.name)
- cam = GameLogic.getCurrentScene().active_camera
-
- def Depth(pos, plane):
- return pos[0]*plane[0] + pos[1]*plane[1] + pos[2]*plane[2] + plane[3]
-
- # Depth is negative and decreasing further from the camera
- depth = Depth(obj.position, cam.world_to_camera[2])
-
- newmesh = None
- curmesh = None
- # Find the lowest detail mesh for depth
- for mesh in meshes:
- if depth < mesh[1] and depth > mesh[2]:
- newmesh = mesh
- if "ME" + obj.name + mesh[0] == act.getMesh():
- curmesh = mesh
-
- if newmesh != None and "ME" + obj.name + newmesh[0] != act.getMesh():
- # The mesh is a different mesh - switch it.
- # Check the current mesh is not a better fit.
- if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
- act.setMesh(obj.getName() + newmesh[0])
- GameLogic.addActiveActuator(act, True)
-
- @warning: Replace mesh actuators will be ignored if at game start, the
- named mesh doesn't exist.
-
- This will generate a warning in the console:
-
- C{ERROR: GameObject I{OBName} ReplaceMeshActuator I{ActuatorName} without object}
-
- @ivar mesh: L{KX_MeshProxy} or the name of the mesh that will replace the current one
- Set to None to disable actuator
- @type mesh: L{KX_MeshProxy} or None if no mesh is set
- """
- def setMesh(name):
- """
- DEPRECATED: Use the mesh property instead.
- Sets the name of the mesh that will replace the current one.
- When the name is None it will unset the mesh value so no action is taken.
-
- @type name: string or None
- """
- def getMesh():
- """
- DEPRECATED: Use the mesh property instead.
- Returns the name of the mesh that will replace the current one.
-
- Returns None if no mesh has been scheduled to be added.
-
- @rtype: string or None
- """
- def instantReplaceMesh():
- """
- Immediately replace mesh without delay.
- @rtype: None
- """ \ No newline at end of file
diff --git a/source/gameengine/PyDoc/KX_Scene.py b/source/gameengine/PyDoc/KX_Scene.py
deleted file mode 100644
index 5dcd560ee96..00000000000
--- a/source/gameengine/PyDoc/KX_Scene.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# $Id$
-# Documentation for KX_Scene.py
-
-class KX_Scene:
- """
- Scene.
-
- The activity culling stuff is supposed to disable logic bricks when their owner gets too far
- from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows
- what it does!
-
- Example::
- import GameLogic
-
- # get the scene
- scene = GameLogic.getCurrentScene()
-
- # print all the objects in the scene
- for obj in scene.objects:
- print obj.name
-
- # get an object named 'Cube'
- obj = scene.objects["OBCube"]
-
- # get the first object in the scene.
- obj = scene.objects[0]
-
- Example::
- # Get the depth of an object in the camera view.
- import GameLogic
-
- obj = GameLogic.getCurrentController().getOwner()
- cam = GameLogic.getCurrentScene().active_camera
-
- # Depth is negative and decreasing further from the camera
- depth = obj.position[0]*cam.world_to_camera[2][0] + obj.position[1]*cam.world_to_camera[2][1] + obj.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
-
- @bug: All attributes are read only at the moment.
-
- @ivar name: The scene's name
- @type name: string
- @ivar objects: A list of objects in the scene.
- @type objects: L{CListValue<CListValue.CListValue>} of L{KX_GameObject<KX_GameObject.KX_GameObject>}
- @ivar active_camera: The current active camera
- @type active_camera: L{KX_Camera}
- @ivar suspended: True if the scene is suspended.
- @type suspended: boolean
- @ivar activity_culling: True if the scene is activity culling
- @type activity_culling: boolean
- @ivar activity_culling_radius: The distance outside which to do activity culling. Measured in manhattan distance.
- @type activity_culling_radius: float
- """
-
- def getLightList():
- """
- Returns the list of lights in the scene.
-
- @rtype: list [L{KX_LightObject}]
- """
- def getObjectList():
- """
- Returns the list of objects in the scene.
-
- @rtype: list [L{KX_GameObject}]
- """
- def getName():
- """
- Returns the name of the scene.
-
- @rtype: string
- """
-
- def addObject(object, other, time=0):
- """
- Adds an object to the scene like the Add Object Actuator would, and returns the created object.
-
- @param object: The object to add
- @type object: L{KX_GameObject} or string
- @param other: The object's center to use when adding the object
- @type other: L{KX_GameObject} or string
- @param time: The lifetime of the added object, in frames. A time of 0 means the object will last forever.
- @type time: int
-
- @rtype: L{KX_GameObject}
- """
diff --git a/source/gameengine/PyDoc/KX_SceneActuator.py b/source/gameengine/PyDoc/KX_SceneActuator.py
deleted file mode 100644
index 6e27257533e..00000000000
--- a/source/gameengine/PyDoc/KX_SceneActuator.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# $Id$
-# Documentation for KX_SceneActuator
-from SCA_IActuator import *
-
-class KX_SceneActuator(SCA_IActuator):
- """
- Scene Actuator logic brick.
-
- @warning: Scene actuators that use a scene name will be ignored if at game start, the
- named scene doesn't exist or is empty
-
- This will generate a warning in the console:
-
- C{ERROR: GameObject I{OBName} has a SceneActuator I{ActuatorName} (SetScene) without scene}
-
- @ivar scene: the name of the scene to change to/overlay/underlay/remove/suspend/resume
- @type scene: string.
- @ivar camera: the camera to change to.
- When setting the attribute, you can use either a L{KX_Camera} or the name of the camera.
- @type camera: L{KX_Camera} on read, string or L{KX_Camera} on write
- """
- def setUseRestart(flag):
- """
- DEPRECATED
- Set flag to True to restart the scene.
-
- @type flag: boolean
- """
- def setScene(scene):
- """
- DEPRECATED: use the scene property instead
- Sets the name of the scene to change to/overlay/underlay/remove/suspend/resume.
-
- @type scene: string
- """
- def setCamera(camera):
- """
- DEPRECATED: use the camera property instead
- Sets the camera to change to.
-
- Camera can be either a L{KX_Camera} or the name of the camera.
-
- @type camera: L{KX_Camera} or string
- """
- def getUseRestart():
- """
- DEPRECATED
- Returns True if the scene will be restarted.
-
- @rtype: boolean
- """
- def getScene():
- """
- DEPRECATED: use the scene property instead
- Returns the name of the scene to change to/overlay/underlay/remove/suspend/resume.
-
- Returns an empty string ("") if no scene has been set.
-
- @rtype: string
- """
- def getCamera():
- """
- DEPRECATED: use the camera property instead
- Returns the name of the camera to change to.
-
- @rtype: string
- """
diff --git a/source/gameengine/PyDoc/KX_SoundActuator.py b/source/gameengine/PyDoc/KX_SoundActuator.py
deleted file mode 100644
index 37ae3c6640d..00000000000
--- a/source/gameengine/PyDoc/KX_SoundActuator.py
+++ /dev/null
@@ -1,195 +0,0 @@
-# $Id$
-# Documentation for KX_SoundActuator
-from SCA_IActuator import *
-
-class KX_SoundActuator(SCA_IActuator):
- """
- Sound Actuator.
-
- The L{startSound()}, L{pauseSound()} and L{stopSound()} do not require
- the actuator to be activated - they act instantly provided that the actuator has
- been activated once at least.
-
- @ivar filename: Sets the filename of the sound this actuator plays.
- @type filename: string
-
- @ivar volume: Sets the volume (gain) of the sound.
- @type volume: float
-
- @ivar pitch: Sets the pitch of the sound.
- @type pitch: float
-
- @ivar rollOffFactor: Sets the roll off factor. Rolloff defines the rate of attenuation as the sound gets further away.
- @type rollOffFactor: float
-
- @ivar looping: Sets the loop mode of the actuator.
- @type looping: integer
-
- @ivar position: Sets the position of the sound.
- @type position: float array
-
- @ivar velocity: Sets the speed of the sound; The speed of the sound alter the pitch.
- @type velocity: float array
-
- @ivar orientation: Sets the orientation of the sound. When setting the orientation you can
- also use quaternion [float,float,float,float] or euler angles [float,float,float]
- @type orientation: 3x3 matrix [[float]]
-
- @ivar type: Sets the operation mode of the actuator. You can use one of the following constant:
- KX_SOUNDACT_PLAYSTOP (1)
- KX_SOUNDACT_PLAYEND (2)
- KX_SOUNDACT_LOOPSTOP (3)
- KX_SOUNDACT_LOOPEND (4)
- KX_SOUNDACT_LOOPBIDIRECTIONAL (5)
- KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP (6)
- @type type: integer
-
- @group Play Methods: startSound, pauseSound, stopSound.
- """
- def setFilename(filename):
- """
- DEPRECATED: Use the filename property instead.
- Sets the filename of the sound this actuator plays.
-
- @type filename: string
- """
- def getFilename():
- """
- DEPRECATED: Use the filename property instead.
- Returns the filename of the sound this actuator plays.
-
- @rtype: string
- """
- def startSound():
- """
- Starts the sound.
- """
- def pauseSound():
- """
- Pauses the sound.
- """
- def stopSound():
- """
- Stops the sound.
- """
- def setGain(gain):
- """
- DEPRECATED: Use the volume property instead
- Sets the gain (volume) of the sound
-
- @type gain: float
- @param gain: 0.0 (quiet) <= gain <= 1.0 (loud)
- """
- def getGain():
- """
- DEPRECATED: Use the volume property instead.
- Gets the gain (volume) of the sound.
-
- @rtype: float
- """
- def setPitch(pitch):
- """
- DEPRECATED: Use the pitch property instead.
- Sets the pitch of the sound.
-
- @type pitch: float
- """
- def getPitch():
- """
- DEPRECATED: Use the pitch property instead.
- Returns the pitch of the sound.
-
- @rtype: float
- """
- def setRollOffFactor(rolloff):
- """
- DEPRECATED: Use the rollOffFactor property instead.
- Sets the rolloff factor for the sounds.
-
- Rolloff defines the rate of attenuation as the sound gets further away.
- Higher rolloff factors shorten the distance at which the sound can be heard.
-
- @type rolloff: float
- """
- def getRollOffFactor():
- """
- DEPRECATED: Use the rollOffFactor property instead.
- Returns the rolloff factor for the sound.
-
- @rtype: float
- """
- def setLooping(loop):
- """
- DEPRECATED: Use the looping property instead.
- Sets the loop mode of the actuator.
-
- @bug: There are no constants defined for this method!
- @param loop: - Play Stop 1
- - Play End 2
- - Loop Stop 3
- - Loop End 4
- - Bidirection Stop 5
- - Bidirection End 6
- @type loop: integer
- """
- def getLooping():
- """
- DEPRECATED: Use the looping property instead.
- Returns the current loop mode of the actuator.
-
- @rtype: integer
- """
- def setPosition(x, y, z):
- """
- DEPRECATED: Use the position property instead.
- Sets the position this sound will come from.
-
- @type x: float
- @param x: The x coordinate of the sound.
- @type y: float
- @param y: The y coordinate of the sound.
- @type z: float
- @param z: The z coordinate of the sound.
- """
- def setVelocity(vx, vy, vz):
- """
- DEPRECATED: Use the velocity property instead.
- Sets the velocity this sound is moving at.
-
- The sound's pitch is determined from the velocity.
-
- @type vx: float
- @param vx: The vx coordinate of the sound.
- @type vy: float
- @param vy: The vy coordinate of the sound.
- @type vz: float
- @param vz: The vz coordinate of the sound.
- """
- def setOrientation(o11, o12, o13, o21, o22, o23, o31, o32, o33):
- """
- DEPRECATED: Use the orientation property instead.
- Sets the orientation of the sound.
-
- The nine parameters specify a rotation matrix::
- | o11, o12, o13 |
- | o21, o22, o23 |
- | o31, o32, o33 |
- """
-
- def setType(mode):
- """
- DEPRECATED: Use the type property instead.
- Sets the operation mode of the actuator.
-
- @param mode: KX_SOUNDACT_PLAYSTOP, KX_SOUNDACT_PLAYEND, KX_SOUNDACT_LOOPSTOP, KX_SOUNDACT_LOOPEND, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
- @type mode: integer
- """
-
- def getType():
- """
- DEPRECATED: Use the type property instead.
- Returns the operation mode of the actuator.
-
- @rtype: integer
- @return: KX_SOUNDACT_PLAYSTOP, KX_SOUNDACT_PLAYEND, KX_SOUNDACT_LOOPSTOP, KX_SOUNDACT_LOOPEND, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
- """
diff --git a/source/gameengine/PyDoc/KX_StateActuator.py b/source/gameengine/PyDoc/KX_StateActuator.py
deleted file mode 100644
index fe3669d3809..00000000000
--- a/source/gameengine/PyDoc/KX_StateActuator.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# $Id$
-# Documentation for KX_StateActuator
-from SCA_IActuator import *
-
-class KX_StateActuator(SCA_IActuator):
- """
- State actuator changes the state mask of parent object.
-
- Property:
-
- @ivar operation: type of bit operation to be applied on object state mask.
- You can use one of the following constant:
- KX_STATE_OP_CPY (0) : Copy state mask
- KX_STATE_OP_SET (1) : Add bits to state mask
- KX_STATE_OP_CLR (2) : Substract bits to state mask
- KX_STATE_OP_NEG (3) : Invert bits to state mask
- @type operation: integer
-
- @ivar mask: value that defines the bits that will be modified by the operation.
- The bits that are 1 in the mask will be updated in the object state,
- the bits that are 0 are will be left unmodified expect for the Copy operation
- which copies the mask to the object state
- @type mask: integer
- """
- def setOperation(op):
- """
- DEPRECATED: Use the operation property instead.
- Set the type of bit operation to be applied on object state mask.
- Use setMask() to specify the bits that will be modified.
-
- @param op: bit operation (0=Copy, 1=Add, 2=Substract, 3=Invert)
- @type op: integer
- """
- def setMask(mask):
- """
- DEPRECATED: Use the mask property instead.
- Set the value that defines the bits that will be modified by the operation.
- The bits that are 1 in the value will be updated in the object state,
- the bits that are 0 are will be left unmodified expect for the Copy operation
- which copies the value to the object state.
-
- @param mask: bits that will be modified
- @type mask: integer
- """
diff --git a/source/gameengine/PyDoc/KX_TouchSensor.py b/source/gameengine/PyDoc/KX_TouchSensor.py
deleted file mode 100644
index f4fcbeefc62..00000000000
--- a/source/gameengine/PyDoc/KX_TouchSensor.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# $Id$
-# Documentation for KX_TouchSensor
-from SCA_ISensor import *
-from KX_GameObject import *
-
-class KX_TouchSensor(SCA_ISensor):
- """
- Touch sensor detects collisions between objects.
-
- @ivar property: The property or material to collide with.
- @type property: string
- @ivar useMaterial: Determines if the sensor is looking for a property or material.
- KX_True = Find material; KX_False = Find property
- @type useMaterial: boolean
- @ivar pulseCollisions: The last collided object.
- @type pulseCollisions: bool
- @ivar objectHit: The last collided object. (Read Only)
- @type objectHit: L{KX_GameObject} or None
- @ivar objectHitList: A list of colliding objects. (Read Only)
- @type objectHitList: L{CListValue<CListValue.CListValue>} of L{KX_GameObject<KX_GameObject.KX_GameObject>}
- """
-
- #--The following methods are deprecated, please use properties instead.
- def setProperty(name):
- """
- DEPRECATED: use the property property
- Set the property or material to collide with. Use
- setTouchMaterial() to switch between properties and
- materials.
- @type name: string
- """
-
- def getProperty():
- """
- DEPRECATED: use the property property
- Returns the property or material to collide with. Use
- getTouchMaterial() to find out whether this sensor
- looks for properties or materials. (B{deprecated})
-
- @rtype: string
- """
- def getHitObject():
- """
- DEPRECATED: use the objectHit property
- Returns the last object hit by this touch sensor. (B{deprecated})
-
- @rtype: L{KX_GameObject}
- """
- def getHitObjectList():
- """
- DEPRECATED: use the objectHitList property
- Returns a list of all objects hit in the last frame. (B{deprecated})
-
- Only objects that have the requisite material/property are listed.
-
- @rtype: L{CListValue<CListValue.CListValue>} of L{KX_GameObject<KX_GameObject.KX_GameObject>}
- """
- def getTouchMaterial():
- """
- DEPRECATED: use the useMaterial property
- Returns KX_TRUE if this sensor looks for a specific material,
- KX_FALSE if it looks for a specific property. (B{deprecated})
- """
diff --git a/source/gameengine/PyDoc/KX_TrackToActuator.py b/source/gameengine/PyDoc/KX_TrackToActuator.py
deleted file mode 100644
index ee2dc5d6144..00000000000
--- a/source/gameengine/PyDoc/KX_TrackToActuator.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# $Id$
-# Documentation for KX_TrackToActuator
-from SCA_IActuator import *
-
-class KX_TrackToActuator(SCA_IActuator):
- """
- Edit Object actuator in Track To mode.
-
- @warning: Track To Actuators will be ignored if at game start, the
- object to track to is invalid.
-
- This will generate a warning in the console:
-
- C{ERROR: GameObject I{OBName} no object in EditObjectActuator I{ActuatorName}}
-
- @ivar object: the object this actuator tracks.
- @type object: KX_GameObject or None
- @ivar time: the time in frames with which to delay the tracking motion
- @type time: integer
- @ivar use3D: the tracking motion to use 3D
- @type use3D: boolean
-
- """
- def setObject(object):
- """
- DEPRECATED: Use the object property.
- Sets the object to track.
-
- @type object: L{KX_GameObject}, string or None
- @param object: Either a reference to a game object or the name of the object to track.
- """
- def getObject(name_only):
- """
- DEPRECATED: Use the object property.
- Returns the name of the object to track.
-
- @type name_only: bool
- @param name_only: optional argument, when 0 return a KX_GameObject
- @rtype: string, KX_GameObject or None if no object is set
- """
- def setTime(time):
- """
- DEPRECATED: Use the time property.
- Sets the time in frames with which to delay the tracking motion.
-
- @type time: integer
- """
- def getTime():
- """
- DEPRECATED: Use the time property.
- Returns the time in frames with which the tracking motion is delayed.
-
- @rtype: integer
- """
- def setUse3D(use3d):
- """
- DEPRECATED: Use the use3D property.
- Sets the tracking motion to use 3D.
-
- @type use3d: boolean
- @param use3d: - True: allow the tracking motion to extend in the z-direction.
- - False: lock the tracking motion to the x-y plane.
- """
- def getUse3D():
- """
- DEPRECATED: Use the use3D property.
- Returns True if the tracking motion will track in the z direction.
-
- @rtype: boolean
- """
diff --git a/source/gameengine/PyDoc/KX_VehicleWrapper.py b/source/gameengine/PyDoc/KX_VehicleWrapper.py
deleted file mode 100644
index 087aa167475..00000000000
--- a/source/gameengine/PyDoc/KX_VehicleWrapper.py
+++ /dev/null
@@ -1,166 +0,0 @@
-class KX_VehicleWrapper: # (PyObjectPlus)
- """
- KX_VehicleWrapper
-
- All placeholders have a __ prefix
- """
-
- def addWheel(wheel, attachPos, attachDir, axleDir, suspensionRestLength, wheelRadius, hasSteering):
-
- """
- TODO - Description
-
- @param wheel: The object to use as a wheel.
- @type wheel: L{KX_GameObject<KX_GameObject.KX_GameObject>} or a KX_GameObject name
- @param attachPos: The position that this wheel will attach to.
- @type attachPos: vector of 3 floats
- @param attachDir: The direction this wheel points.
- @type attachDir: vector of 3 floats
- @param axleDir: The direction of this wheels axle.
- @type axleDir: vector of 3 floats
- @param suspensionRestLength: TODO - Description
- @type suspensionRestLength: float
- @param wheelRadius: The size of the wheel.
- @type wheelRadius: float
- """
-
- def __applyBraking(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __applyEngineForce(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getConstraintId(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getConstraintType(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getNumWheels(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getWheelOrientationQuaternion(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getWheelPosition(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __getWheelRotation(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setRollInfluence(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setSteeringValue(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setSuspensionCompression(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setSuspensionDamping(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setSuspensionStiffness(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
- def __setTyreFriction(val):
- """
- TODO - Description
-
- @param val: the starting frame of the animation
- @type val: float
-
- @rtype: integer
- @return: TODO Description
- """
diff --git a/source/gameengine/PyDoc/KX_VertexProxy.py b/source/gameengine/PyDoc/KX_VertexProxy.py
deleted file mode 100644
index 7ee5087b316..00000000000
--- a/source/gameengine/PyDoc/KX_VertexProxy.py
+++ /dev/null
@@ -1,148 +0,0 @@
-# $Id$
-# Documentation for the vertex proxy class
-
-class KX_VertexProxy:
- """
- A vertex holds position, UV, colour and normal information.
-
- Note:
- The physics simulation is NOT currently updated - physics will not respond
- to changes in the vertex position.
-
- @ivar XYZ: The position of the vertex.
- @type XYZ: list [x, y, z]
- @ivar UV: The texture coordinates of the vertex.
- @type UV: list [u, v]
- @ivar normal: The normal of the vertex
- @type normal: list [nx, ny, nz]
- @ivar colour: The colour of the vertex.
- Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0]
- @type colour: list [r, g, b, a]
- @ivar color: Synonym for colour.
-
- @group Position: x, y, z
- @ivar x: The x coordinate of the vertex.
- @type x: float
- @ivar y: The y coordinate of the vertex.
- @type y: float
- @ivar z: The z coordinate of the vertex.
- @type z: float
-
- @group Texture Coordinates: u, v
- @ivar u: The u texture coordinate of the vertex.
- @type u: float
- @ivar v: The v texture coordinate of the vertex.
- @type v: float
-
- @ivar u2: The second u texture coordinate of the vertex.
- @type u2: float
- @ivar v2: The second v texture coordinate of the vertex.
- @type v2: float
-
- @group Colour: r, g, b, a
- @ivar r: The red component of the vertex colour. 0.0 <= r <= 1.0
- @type r: float
- @ivar g: The green component of the vertex colour. 0.0 <= g <= 1.0
- @type g: float
- @ivar b: The blue component of the vertex colour. 0.0 <= b <= 1.0
- @type b: float
- @ivar a: The alpha component of the vertex colour. 0.0 <= a <= 1.0
- @type a: float
- """
-
- def getXYZ():
- """
- Gets the position of this vertex.
-
- @rtype: list [x, y, z]
- @return: this vertexes position in local coordinates.
- """
- def setXYZ(pos):
- """
- Sets the position of this vertex.
-
- @type pos: list [x, y, z]
- @param pos: the new position for this vertex in local coordinates.
- """
- def getUV():
- """
- Gets the UV (texture) coordinates of this vertex.
-
- @rtype: list [u, v]
- @return: this vertexes UV (texture) coordinates.
- """
- def setUV(uv):
- """
- Sets the UV (texture) coordinates of this vertex.
-
- @type uv: list [u, v]
- """
- def getUV2():
- """
- Gets the 2nd UV (texture) coordinates of this vertex.
-
- @rtype: list [u, v]
- @return: this vertexes UV (texture) coordinates.
- """
- def setUV2(uv):
- """
- Sets the 2nd UV (texture) coordinates of this vertex.
-
- @type uv: list [u, v]
- """
- def getRGBA():
- """
- Gets the colour of this vertex.
-
- The colour is represented as four bytes packed into an integer value. The colour is
- packed as RGBA.
-
- Since Python offers no way to get each byte without shifting, you must use the struct module to
- access colour in an machine independent way.
-
- Because of this, it is suggested you use the r, g, b and a attributes or the colour attribute instead.
-
- Example::
- import struct;
- col = struct.unpack('4B', struct.pack('I', v.getRGBA()))
- # col = (r, g, b, a)
- # black = ( 0, 0, 0, 255)
- # white = (255, 255, 255, 255)
-
- @rtype: integer
- @return: packed colour. 4 byte integer with one byte per colour channel in RGBA format.
- """
- def setRGBA(col):
- """
- Sets the colour of this vertex.
-
- See getRGBA() for the format of col, and its relevant problems. Use the r, g, b and a attributes
- or the colour attribute instead.
-
- setRGBA() also accepts a four component list as argument col. The list represents the colour as [r, g, b, a]
- with black = [0.0, 0.0, 0.0, 1.0] and white = [1.0, 1.0, 1.0, 1.0]
-
- Example::
- v.setRGBA(0xff0000ff) # Red
- v.setRGBA(0xff00ff00) # Green on little endian, transparent purple on big endian
- v.setRGBA([1.0, 0.0, 0.0, 1.0]) # Red
- v.setRGBA([0.0, 1.0, 0.0, 1.0]) # Green on all platforms.
-
- @type col: integer or list [r, g, b, a]
- @param col: the new colour of this vertex in packed RGBA format.
- """
- def getNormal():
- """
- Gets the normal vector of this vertex.
-
- @rtype: list [nx, ny, nz]
- @return: normalised normal vector.
- """
- def setNormal(normal):
- """
- Sets the normal vector of this vertex.
-
- @type normal: sequence of floats [r, g, b]
- @param normal: the new normal of this vertex.
- """
-
diff --git a/source/gameengine/PyDoc/KX_VisibilityActuator.py b/source/gameengine/PyDoc/KX_VisibilityActuator.py
deleted file mode 100644
index 36f25b2423c..00000000000
--- a/source/gameengine/PyDoc/KX_VisibilityActuator.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# $Id$
-# Documentation for KX_VisibilityActuator
-from SCA_IActuator import *
-
-class KX_VisibilityActuator(SCA_IActuator):
- """
- Visibility Actuator.
- @ivar visibility: whether the actuator makes its parent object visible or invisible
- @type visibility: boolean
- @ivar occlusion: whether the actuator makes its parent object an occluder or not
- @type occlusion: boolean
- @ivar recursion: whether the visibility/occlusion should be propagated to all children of the object
- @type recursion: boolean
- """
- def set(visible):
- """
- DEPRECATED: Use the visibility property instead.
- Sets whether the actuator makes its parent object visible or invisible.
-
- @param visible: - True: Makes its parent visible.
- - False: Makes its parent invisible.
- """
diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py
index 6a67cdcc71b..bafcfece473 100644
--- a/source/gameengine/PyDoc/Rasterizer.py
+++ b/source/gameengine/PyDoc/Rasterizer.py
@@ -43,7 +43,6 @@ Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement M
@var KX_BLENDER_GLSL_MATERIAL: Materials approximating blender materials with GLSL.
"""
-
def getWindowWidth():
"""
Gets the width of the window (in pixels)
@@ -105,6 +104,13 @@ def setMistColor(rgb):
@type rgb: list [r, g, b]
"""
+
+def setAmbientColor(rgb):
+ """
+ Sets the color of ambient light.
+
+ @type rgb: list [r, g, b]
+ """
def setMistStart(start):
"""
@@ -121,6 +127,13 @@ def setMistEnd(end):
@type end: float
"""
+def disableMist():
+ """
+ Disables mist.
+
+ @note: Set any of the mist properties to enable mist.
+ """
+
def setEyeSeparation(eyesep):
"""
Sets the eye separation for stereo mode.
@@ -194,3 +207,15 @@ def drawLine(fromVec,toVec,color):
@type color: list [r, g, b]
"""
+def enableMotionBlur(factor):
+ """
+ Enable the motion blue effect.
+
+ @param factor: the ammount of motion blur to display.
+ @type factor: float [0.0 - 1.0]
+ """
+
+def disableMotionBlur():
+ """
+ Disable the motion blue effect.
+ """
diff --git a/source/gameengine/PyDoc/SCA_2DFilterActuator.py b/source/gameengine/PyDoc/SCA_2DFilterActuator.py
deleted file mode 100644
index 9a010e8f221..00000000000
--- a/source/gameengine/PyDoc/SCA_2DFilterActuator.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# $Id$
-# Documentation for SCA_2DFilterActuator
-from SCA_IActuator import *
-from SCA_ILogicBrick import *
-
-class SCA_2DFilterActuator(SCA_IActuator):
- """
- Create, enable and disable 2D filters
-
- Properties:
-
- The following properties don't have an immediate effect.
- You must active the actuator to get the result.
- The actuator is not persistent: it automatically stops itself after setting up the filter
- but the filter remains active. To stop a filter you must activate the actuator with 'type'
- set to RAS_2DFILTER_DISABLED or RAS_2DFILTER_NOFILTER.
-
- @ivar shaderText: shader source code for custom shader
- @type shaderText: string
- @ivar disableMotionBlur: action on motion blur: 0=enable, 1=disable
- @type disableMotionBlur: integer
- @ivar type: type of 2D filter, use one of the following constants:
- RAS_2DFILTER_ENABLED (-2) : enable the filter that was previously disabled
- RAS_2DFILTER_DISABLED (-1) : disable the filter that is currently active
- RAS_2DFILTER_NOFILTER (0) : disable and destroy the filter that is currently active
- RAS_2DFILTER_MOTIONBLUR (1) : create and enable preset filters
- RAS_2DFILTER_BLUR (2)
- RAS_2DFILTER_SHARPEN (3)
- RAS_2DFILTER_DILATION (4)
- RAS_2DFILTER_EROSION (5)
- RAS_2DFILTER_LAPLACIAN (6)
- RAS_2DFILTER_SOBEL (7)
- RAS_2DFILTER_PREWITT (8)
- RAS_2DFILTER_GRAYSCALE (9)
- RAS_2DFILTER_SEPIA (10)
- RAS_2DFILTER_INVERT (11)
- RAS_2DFILTER_CUSTOMFILTER (12) : customer filter, the code code is set via shaderText property
- @type type: integer
- @ivar passNb: order number of filter in the stack of 2D filters. Filters are executed in increasing order of passNb.
- Only be one filter can be defined per passNb.
- @type passNb: integer (0-100)
- @ivar value: argument for motion blur filter
- @type value: float (0.0-100.0)
- """
diff --git a/source/gameengine/PyDoc/SCA_ANDController.py b/source/gameengine/PyDoc/SCA_ANDController.py
deleted file mode 100644
index 1717e613595..00000000000
--- a/source/gameengine/PyDoc/SCA_ANDController.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-# Documentation for SCA_ANDController
-from SCA_IController import *
-
-class SCA_ANDController(SCA_IController):
- """
- An AND controller activates only when all linked sensors are activated.
-
- There are no special python methods for this controller.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_ActuatorSensor.py b/source/gameengine/PyDoc/SCA_ActuatorSensor.py
deleted file mode 100644
index 515354e8716..00000000000
--- a/source/gameengine/PyDoc/SCA_ActuatorSensor.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# $Id$
-# Documentation for SCA_ActuatorSensor
-from SCA_IActuator import *
-from SCA_ISensor import *
-from SCA_ILogicBrick import *
-
-class SCA_ActuatorSensor(SCA_ISensor):
- """
- Actuator sensor detect change in actuator state of the parent object.
- It generates a positive pulse if the corresponding actuator is activated
- and a negative pulse if the actuator is deactivated.
-
- Properties:
-
- @ivar actuator: the name of the actuator that the sensor is monitoring.
- @type actuator: string
- """
- def getActuator():
- """
- DEPRECATED: use the actuator property
- Return the Actuator with which the sensor operates.
-
- @rtype: string
- """
- def setActuator(name):
- """
- DEPRECATED: use the actuator property
- Sets the Actuator with which to operate. If there is no Actuator
- of this name, the function has no effect.
-
- @param name: actuator name
- @type name: string
- """
diff --git a/source/gameengine/PyDoc/SCA_AlwaysSensor.py b/source/gameengine/PyDoc/SCA_AlwaysSensor.py
deleted file mode 100644
index 54ab07a8a99..00000000000
--- a/source/gameengine/PyDoc/SCA_AlwaysSensor.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-# Documentation for SCA_AlwaysSensor
-from SCA_ISensor import *
-
-class SCA_AlwaysSensor(SCA_ISensor):
- """
- This sensor is always activated.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_DelaySensor.py b/source/gameengine/PyDoc/SCA_DelaySensor.py
deleted file mode 100644
index 6560df6573e..00000000000
--- a/source/gameengine/PyDoc/SCA_DelaySensor.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# $Id$
-# Documentation for SCA_DelaySensor
-from SCA_ISensor import *
-
-class SCA_DelaySensor(SCA_ISensor):
- """
- The Delay sensor generates positive and negative triggers at precise time,
- expressed in number of frames. The delay parameter defines the length
- of the initial OFF period. A positive trigger is generated at the end of this period.
- The duration parameter defines the length of the ON period following the OFF period.
- There is a negative trigger at the end of the ON period. If duration is 0, the sensor
- stays ON and there is no negative trigger.
- The sensor runs the OFF-ON cycle once unless the repeat option is set: the
- OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
- Use SCA_ISensor::reset() at any time to restart sensor.
-
- Properties:
-
- @ivar delay: length of the initial OFF period as number of frame, 0 for immediate trigger.
- @type delay: integer.
- @ivar duration: length of the ON period in number of frame after the initial OFF period.
- If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
- @type duration: integer
- @ivar repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
- @type repeat: integer
- """
- def setDelay(delay):
- """
- DEPRECATED: use the delay property
- Set the initial delay before the positive trigger.
-
- @param delay: length of the initial OFF period as number of frame, 0 for immediate trigger
- @type delay: integer
- """
- def setDuration(duration):
- """
- DEPRECATED: use the duration property
- Set the duration of the ON pulse after initial delay and the generation of the positive trigger.
- If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
-
- @param duration: length of the ON period in number of frame after the initial OFF period
- @type duration: integer
- """
- def setRepeat(repeat):
- """
- DEPRECATED: use the repeat property
- Set if the sensor repeat mode.
-
- @param repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
- @type repeat: integer
- """
- def getDelay():
- """
- DEPRECATED: use the delay property
- Return the delay parameter value.
-
- @rtype: integer
- """
- def getDuration():
- """
- DEPRECATED: use the duration property
- Return the duration parameter value
-
- @rtype: integer
- """
- def getRepeat():
- """
- DEPRECATED: use the repeat property
- Return the repeat parameter value
-
- @rtype: KX_TRUE or KX_FALSE
- """
diff --git a/source/gameengine/PyDoc/SCA_IActuator.py b/source/gameengine/PyDoc/SCA_IActuator.py
deleted file mode 100644
index ac47c15dc78..00000000000
--- a/source/gameengine/PyDoc/SCA_IActuator.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-# Documentation for SCA_IActuator
-from SCA_ILogicBrick import *
-
-class SCA_IActuator(SCA_ILogicBrick):
- """
- Base class for all actuator logic bricks.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_IController.py b/source/gameengine/PyDoc/SCA_IController.py
deleted file mode 100644
index f83e7c97dce..00000000000
--- a/source/gameengine/PyDoc/SCA_IController.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-# Documentation for KX_CameraActuator
-from SCA_ILogicBrick import *
-
-class SCA_IController(SCA_ILogicBrick):
- """
- Base class for all controller logic bricks.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_ILogicBrick.py b/source/gameengine/PyDoc/SCA_ILogicBrick.py
deleted file mode 100644
index 4688ba12bb6..00000000000
--- a/source/gameengine/PyDoc/SCA_ILogicBrick.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# $Id$
-# Documentation for the logic brick base class SCA_ILogicBrick
-from KX_GameObject import *
-
-class SCA_ILogicBrick:
- """
- Base class for all logic bricks.
-
- @ivar executePriority: This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
- @type executePriority: int
- @ivar owner: The game object this logic brick is attached to (read only).
- @type owner: L{KX_GameObject<KX_GameObject.KX_GameObject>} or None in exceptional cases.
- """
-
- def getOwner():
- """
- Gets the game object associated with this logic brick.
-
- Deprecated: Use the "owner" property instead.
-
- @rtype: L{KX_GameObject<KX_GameObject.KX_GameObject>}
- """
-
- #--The following methods are deprecated--
- def setExecutePriority(priority):
- """
- Sets the priority of this logic brick.
-
- This determines the order controllers are evaluated, and actuators are activated.
- Bricks with lower priority will be executed first.
-
- Deprecated: Use the "executePriority" property instead.
-
- @type priority: integer
- @param priority: the priority of this logic brick.
- """
- def getExecutePriority():
- """
- Gets the execution priority of this logic brick.
-
- Deprecated: Use the "executePriority" property instead.
-
- @rtype: integer
- @return: this logic bricks current priority.
- """
diff --git a/source/gameengine/PyDoc/SCA_ISensor.py b/source/gameengine/PyDoc/SCA_ISensor.py
deleted file mode 100644
index ab35996aa50..00000000000
--- a/source/gameengine/PyDoc/SCA_ISensor.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# $Id$
-# Documentation for SCA_ISensor
-from SCA_ILogicBrick import *
-
-class SCA_ISensor(SCA_ILogicBrick):
- """
- Base class for all sensor logic bricks.
-
- @ivar usePosPulseMode: Flag to turn positive pulse mode on and off.
- @type usePosPulseMode: boolean
- @ivar useNegPulseMode: Flag to turn negative pulse mode on and off.
- @type useNegPulseMode: boolean
- @ivar frequency: The frequency for pulse mode sensors.
- @type frequency: int
- @ivar level: Flag to set whether to detect level or edge transition when entering a state.
- It makes a difference only in case of logic state transition (state actuator).
- A level detector will immediately generate a pulse, negative or positive
- depending on the sensor condition, as soon as the state is activated.
- A edge detector will wait for a state change before generating a pulse.
- @type level: boolean
- @ivar invert: Flag to set if this sensor activates on positive or negative events.
- @type invert: boolean
- @ivar triggered: True if this sensor brick is in a positive state. (Read only)
- @type triggered: boolean
- @ivar positive: True if this sensor brick is in a positive state. (Read only)
- @type positive: boolean
- """
-
- def reset():
- """
- Reset sensor internal state, effect depends on the type of sensor and settings.
-
- The sensor is put in its initial state as if it was just activated.
- """
-
- #--The following methods are deprecated--
- def isPositive():
- """
- True if this sensor brick is in a positive state.
- """
-
- def isTriggered():
- """
- True if this sensor brick has triggered the current controller.
- """
-
- def getUsePosPulseMode():
- """
- True if the sensor is in positive pulse mode.
- """
- def setUsePosPulseMode(pulse):
- """
- Sets positive pulse mode.
-
- @type pulse: boolean
- @param pulse: If True, will activate positive pulse mode for this sensor.
- """
- def getFrequency():
- """
- The frequency for pulse mode sensors.
-
- @rtype: integer
- @return: the pulse frequency in 1/50 sec.
- """
- def setFrequency(freq):
- """
- Sets the frequency for pulse mode sensors.
-
- @type freq: integer
- @return: the pulse frequency in 1/50 sec.
- """
- def getUseNegPulseMode():
- """
- True if the sensor is in negative pulse mode.
- """
- def setUseNegPulseMode(pulse):
- """
- Sets negative pulse mode.
-
- @type pulse: boolean
- @param pulse: If True, will activate negative pulse mode for this sensor.
- """
- def getInvert():
- """
- True if this sensor activates on negative events.
- """
- def setInvert(invert):
- """
- Sets if this sensor activates on positive or negative events.
-
- @type invert: boolean
- @param invert: true if activates on negative events; false if activates on positive events.
- """
- def getLevel():
- """
- Returns whether this sensor is a level detector or a edge detector.
- It makes a difference only in case of logic state transition (state actuator).
- A level detector will immediately generate a pulse, negative or positive
- depending on the sensor condition, as soon as the state is activated.
- A edge detector will wait for a state change before generating a pulse.
-
- @rtype: boolean
- @return: true if sensor is level sensitive, false if it is edge sensitive
- """
- def setLevel(level):
- """
- Set whether to detect level or edge transition when entering a state.
-
- @param level: Detect level instead of edge? (KX_TRUE, KX_FALSE)
- @type level: boolean
- """
diff --git a/source/gameengine/PyDoc/SCA_JoystickSensor.py b/source/gameengine/PyDoc/SCA_JoystickSensor.py
deleted file mode 100644
index 13b006e8dd6..00000000000
--- a/source/gameengine/PyDoc/SCA_JoystickSensor.py
+++ /dev/null
@@ -1,169 +0,0 @@
-# $Id$
-# Documentation for SCA_RandomSensor
-from SCA_ISensor import *
-
-class SCA_JoystickSensor(SCA_ISensor):
- """
- This sensor detects player joystick events.
-
- Properties:
-
- @ivar axisValues: (read-only) The state of the joysticks axis as a list of values L{numAxis} long.
- each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
- The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
- left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
- @type axisValues: list of ints
-
- @ivar axisSingle: (read-only) like L{axisValues} but returns a single axis value that is set by the sensor.
- Only use this for "Single Axis" type sensors otherwise it will raise an error.
- @type axisSingle: int
-
- @ivar numAxis: (read-only) The number of axes for the joystick at this index.
- @type numAxis: integer
- @ivar numButtons: (read-only) The number of buttons for the joystick at this index.
- @type numButtons: integer
- @ivar numHats: (read-only) The number of hats for the joystick at this index.
- @type numHats: integer
- @ivar connected: (read-only) True if a joystick is connected at this joysticks index.
- @type connected: boolean
- @ivar index: The joystick index to use (from 0 to 7). The first joystick is always 0.
- @type index: integer
- @ivar threshold: Axis threshold. Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
- @type threshold: integer
- @ivar button: The button index the sensor reacts to (first button = 0). When the "All Events" toggle is set, this option has no effect.
- @type button: integer
- @ivar axis: The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection]
- axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control.
- axisDirection: 0=right, 1=up, 2=left, 3=down
- @type axis: [integer, integer]
- @ivar hat: The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection]
- hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat.
- hatDirection: 0-11
- @type hat: [integer, integer]
- """
-
- def getButtonActiveList():
- """
- Returns a list containing the indicies of the currently pressed buttons.
- @rtype: list
- """
- def getButtonStatus(buttonIndex):
- """
- Returns a bool of the current pressed state of the specified button.
- @param buttonIndex: the button index, 0=first button
- @type buttonIndex: integer
- @rtype: bool
- """
- def getIndex():
- """
- DEPRECATED: use the 'index' property.
- Returns the joystick index to use (from 1 to 8).
- @rtype: integer
- """
- def setIndex(index):
- """
- DEPRECATED: use the 'index' property.
- Sets the joystick index to use.
- @param index: The index of this joystick sensor, Clamped between 1 and 8.
- @type index: integer
- @note: This is only useful when you have more then 1 joystick connected to your computer - multiplayer games.
- """
- def getAxis():
- """
- DEPRECATED: use the 'axis' property.
- Returns the current axis this sensor reacts to. See L{getAxisValue()<SCA_JoystickSensor.getAxisValue>} for the current axis state.
- @rtype: list
- @return: 2 values returned are [axisIndex, axisDirection] - see L{setAxis()<SCA_JoystickSensor.setAxis>} for their purpose.
- @note: When the "All Events" toggle is set, this option has no effect.
- """
- def setAxis(axisIndex, axisDirection):
- """
- DEPRECATED: use the 'axis' property.
- @param axisIndex: Set the axis index to use when detecting axis movement.
- @type axisIndex: integer from 1 to 2
- @param axisDirection: Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down.
- @type axisDirection: integer from 0 to 3
- @note: When the "All Events" toggle is set, this option has no effect.
- """
- def getAxisValue():
- """
- DEPRECATED: use the 'axisPosition' property.
- Returns the state of the joysticks axis. See differs to L{getAxis()<SCA_JoystickSensor.getAxis>} returning the current state of the joystick.
- @rtype: list
- @return: 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
-
- The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
-
- left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
- @note: Some gamepads only set the axis on and off like a button.
- """
- def getThreshold():
- """
- DEPRECATED: use the 'threshold' property.
- Get the axis threshold. See L{setThreshold()<SCA_JoystickSensor.setThreshold>} for details.
- @rtype: integer
- """
- def setThreshold(threshold):
- """
- DEPRECATED: use the 'threshold' property.
- Set the axis threshold.
- @param threshold: Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
- @type threshold: integer
- """
- def getButton():
- """
- DEPRECATED: use the 'button' property.
- Returns the button index the sensor reacts to. See L{getButtonValue()<SCA_JoystickSensor.getButtonValue>} for a list of pressed buttons.
- @rtype: integer
- @note: When the "All Events" toggle is set, this option has no effect.
- """
- def setButton(index):
- """
- DEPRECATED: use the 'button' property.
- Sets the button index the sensor reacts to when the "All Events" option is not set.
- @note: When the "All Events" toggle is set, this option has no effect.
- """
- def getButtonValue():
- """
- DEPRECATED: use the 'getButtonActiveList' method.
- Returns a list containing the indicies of the currently pressed buttons.
- @rtype: list
- """
- def getHat():
- """
- DEPRECATED: use the 'hat' property.
- Returns the current hat direction this sensor is set to.
- [hatNumber, hatDirection].
- @rtype: list
- @note: When the "All Events" toggle is set, this option has no effect.
- """
- def setHat(index,direction):
- """
- DEPRECATED: use the 'hat' property.
- Sets the hat index the sensor reacts to when the "All Events" option is not set.
- @type index: integer
- """
- def getNumAxes():
- """
- DEPRECATED: use the 'numAxis' property.
- Returns the number of axes for the joystick at this index.
- @rtype: integer
- """
- def getNumButtons():
- """
- DEPRECATED: use the 'numButtons' property.
- Returns the number of buttons for the joystick at this index.
- @rtype: integer
- """
- def getNumHats():
- """
- DEPRECATED: use the 'numHats' property.
- Returns the number of hats for the joystick at this index.
- @rtype: integer
- """
- def isConnected():
- """
- DEPRECATED: use the 'connected' property.
- Returns True if a joystick is detected at this joysticks index.
- @rtype: bool
- """
diff --git a/source/gameengine/PyDoc/SCA_KeyboardSensor.py b/source/gameengine/PyDoc/SCA_KeyboardSensor.py
deleted file mode 100644
index 8abb1fda762..00000000000
--- a/source/gameengine/PyDoc/SCA_KeyboardSensor.py
+++ /dev/null
@@ -1,116 +0,0 @@
-# $Id$
-# Documentation for SCA_KeyboardSensor
-from SCA_ISensor import *
-
-class SCA_KeyboardSensor(SCA_ISensor):
- """
- A keyboard sensor detects player key presses.
-
- See module L{GameKeys} for keycode values.
-
- @ivar key: The key code this sensor is looking for.
- @type key: keycode from L{GameKeys} module
- @ivar hold1: The key code for the first modifier this sensor is looking for.
- @type hold1: keycode from L{GameKeys} module
- @ivar hold2: The key code for the second modifier this sensor is looking for.
- @type hold2: keycode from L{GameKeys} module
- @ivar toggleProperty: The name of the property that indicates whether or not to log keystrokes as a string.
- @type toggleProperty: string
- @ivar targetProperty: The name of the property that receives keystrokes in case in case a string is logged.
- @type targetProperty: string
- @ivar useAllKeys: Flag to determine whether or not to accept all keys.
- @type useAllKeys: boolean
- @ivar events: a list of pressed keys that have either been pressed, or just released, or are active this frame. (read only).
-
- - 'keycode' matches the values in L{GameKeys}.
- - 'status' uses...
- - L{GameLogic.KX_INPUT_NONE}
- - L{GameLogic.KX_INPUT_JUST_ACTIVATED}
- - L{GameLogic.KX_INPUT_ACTIVE}
- - L{GameLogic.KX_INPUT_JUST_RELEASED}
-
- @type events: list [[keycode, status], ...]
- """
-
- def getKeyStatus(keycode):
- """
- Get the status of a key.
-
- @rtype: key state L{GameLogic} members (KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED)
- @return: The state of the given key
- @type keycode: integer
- @param keycode: The code that represents the key you want to get the state of
- """
-
- #--The following methods are DEPRECATED--
- def getKey():
- """
- Returns the key code this sensor is looking for.
-
- B{DEPRECATED: Use the "key" property instead}.
-
- @rtype: keycode from L{GameKeys} module
- """
-
- def setKey(keycode):
- """
- Set the key this sensor should listen for.
-
- B{DEPRECATED: Use the "key" property instead}.
-
- @type keycode: keycode from L{GameKeys} module
- """
-
- def getHold1():
- """
- Returns the key code for the first modifier this sensor is looking for.
-
- B{DEPRECATED: Use the "hold1" property instead}.
-
- @rtype: keycode from L{GameKeys} module
- """
-
- def setHold1(keycode):
- """
- Sets the key code for the first modifier this sensor should look for.
-
- B{DEPRECATED: Use the "hold1" property instead}.
-
- @type keycode: keycode from L{GameKeys} module
- """
-
- def getHold2():
- """
- Returns the key code for the second modifier this sensor is looking for.
-
- B{DEPRECATED: Use the "hold2" property instead}.
-
- @rtype: keycode from L{GameKeys} module
- """
-
- def setHold2(keycode):
- """
- Sets the key code for the second modifier this sensor should look for.
-
- B{DEPRECATED: Use the "hold2" property instead.}
-
- @type keycode: keycode from L{GameKeys} module
- """
-
- def getPressedKeys():
- """
- Get a list of keys that have either been pressed, or just released this frame.
-
- B{DEPRECATED: Use "events" instead.}
-
- @rtype: list of key status. [[keycode, status]]
- """
-
- def getCurrentlyPressedKeys():
- """
- Get a list of currently pressed keys that have either been pressed, or just released
-
- B{DEPRECATED: Use "events" instead.}
-
- @rtype: list of key status. [[keycode, status]]
- """ \ No newline at end of file
diff --git a/source/gameengine/PyDoc/SCA_MouseSensor.py b/source/gameengine/PyDoc/SCA_MouseSensor.py
deleted file mode 100644
index 278ebe63b8a..00000000000
--- a/source/gameengine/PyDoc/SCA_MouseSensor.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# $Id$
-# Documentation for SCA_MouseSensor
-from SCA_ISensor import *
-
-class SCA_MouseSensor(SCA_ISensor):
- """
- Mouse Sensor logic brick.
-
- Properties:
-
- @ivar position: current [x,y] coordinates of the mouse, in frame coordinates (pixels)
- @type position: [integer,interger]
- @ivar mode: sensor mode: 1=KX_MOUSESENSORMODE_LEFTBUTTON 2=KX_MOUSESENSORMODE_MIDDLEBUTTON
- 3=KX_MOUSESENSORMODE_RIGHTBUTTON 4=KX_MOUSESENSORMODE_WHEELUP
- 5=KX_MOUSESENSORMODE_WHEELDOWN 9=KX_MOUSESENSORMODE_MOVEMENT
- @type mode: integer
- """
-
- def getXPosition():
- """
- DEPRECATED: use the position property
- Gets the x coordinate of the mouse.
-
- @rtype: integer
- @return: the current x coordinate of the mouse, in frame coordinates (pixels)
- """
- def getYPosition():
- """
- DEPRECATED: use the position property
- Gets the y coordinate of the mouse.
-
- @rtype: integer
- @return: the current y coordinate of the mouse, in frame coordinates (pixels).
- """
- def getButtonStatus(button):
- """
- Get the mouse button status.
-
- @type button: int
- @param button: value in GameLogic members KX_MOUSE_BUT_LEFT, KX_MOUSE_BUT_MIDDLE, KX_MOUSE_BUT_RIGHT
-
- @rtype: integer
- @return: value in GameLogic members KX_INPUT_NONE, KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED
- """
diff --git a/source/gameengine/PyDoc/SCA_NANDController.py b/source/gameengine/PyDoc/SCA_NANDController.py
deleted file mode 100644
index a864ff2981c..00000000000
--- a/source/gameengine/PyDoc/SCA_NANDController.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-# Documentation for SCA_NANDController
-from SCA_IController import *
-
-class SCA_NANDController(SCA_IController):
- """
- An NAND controller activates when all linked sensors are not active.
-
- There are no special python methods for this controller.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_NORController.py b/source/gameengine/PyDoc/SCA_NORController.py
deleted file mode 100644
index 0bc0a71d7b1..00000000000
--- a/source/gameengine/PyDoc/SCA_NORController.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-# Documentation for SCA_NORController
-from SCA_IController import *
-
-class SCA_NORController(SCA_IController):
- """
- An NOR controller activates only when all linked sensors are de-activated.
-
- There are no special python methods for this controller.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_ORController.py b/source/gameengine/PyDoc/SCA_ORController.py
deleted file mode 100644
index eeeb9de3afe..00000000000
--- a/source/gameengine/PyDoc/SCA_ORController.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-# Documentation for SCA_ORController
-from SCA_IController import *
-
-class SCA_ORController(SCA_IController):
- """
- An OR controller activates when any connected sensor activates.
-
- There are no special python methods for this controller.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_PropertyActuator.py b/source/gameengine/PyDoc/SCA_PropertyActuator.py
deleted file mode 100644
index 52aefcae651..00000000000
--- a/source/gameengine/PyDoc/SCA_PropertyActuator.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# $Id$
-# Documentation for SCA_PropertyActuator
-from SCA_IActuator import *
-
-class SCA_PropertyActuator(SCA_IActuator):
- """
- Property Actuator
-
- Properties:
-
- @ivar property: the property on which to operate.
- @type property: string
- @ivar value: the value with which the actuator operates.
- @type value: string
- """
- def setProperty(prop):
- """
- DEPRECATED: use the 'property' property
- Set the property on which to operate.
-
- If there is no property of this name, the call is ignored.
-
- @type prop: string
- @param prop: The name of the property to set.
- """
- def getProperty():
- """
- DEPRECATED: use the 'property' property
- Returns the name of the property on which to operate.
-
- @rtype: string
- """
- def setValue(value):
- """
- DEPRECATED: use the 'value' property
- Set the value with which the actuator operates.
-
- If the value is not compatible with the type of the
- property, the subsequent action is ignored.
-
- @type value: string
- """
- def getValue():
- """
- DEPRECATED: use the 'value' property
- Gets the value with which this actuator operates.
-
- @rtype: string
- """
diff --git a/source/gameengine/PyDoc/SCA_PropertySensor.py b/source/gameengine/PyDoc/SCA_PropertySensor.py
deleted file mode 100644
index 949ffd3b703..00000000000
--- a/source/gameengine/PyDoc/SCA_PropertySensor.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# $Id$
-# Documentation for SCA_PropertySensor
-from SCA_ISensor import *
-
-class SCA_PropertySensor(SCA_ISensor):
- """
- Activates when the game object property matches.
-
- Properties:
-
- @ivar type: type of check on the property:
- KX_PROPSENSOR_EQUAL(1), KX_PROPSENSOR_NOTEQUAL(2), KX_PROPSENSOR_INTERVAL(3),
- KX_PROPSENSOR_CHANGED(4), KX_PROPSENSOR_EXPRESSION(5)
- @type type: integer
- @ivar property: the property with which the sensor operates.
- @type property: string
- @ivar value: the value with which the sensor compares to the value of the property.
- @type value: string
- """
-
- def getType():
- """
- DEPRECATED: use the type property
- Gets when to activate this sensor.
-
- @return: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
- KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,
- or KX_PROPSENSOR_EXPRESSION.
- """
-
- def setType(checktype):
- """
- DEPRECATED: use the type property
- Set the type of check to perform.
-
- @type checktype: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
- KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,
- or KX_PROPSENSOR_EXPRESSION.
- """
-
- def getProperty():
- """
- DEPRECATED: use the property property
- Return the property with which the sensor operates.
-
- @rtype: string
- @return: the name of the property this sensor is watching.
- """
- def setProperty(name):
- """
- DEPRECATED: use the property property
- Sets the property with which to operate. If there is no property
- of that name, this call is ignored.
-
- @type name: string.
- """
- def getValue():
- """
- DEPRECATED: use the value property
- Return the value with which the sensor compares to the value of the property.
-
- @rtype: string
- @return: the value of the property this sensor is watching.
- """
- def setValue(value):
- """
- DEPRECATED: use the value property
- Set the value with which the sensor operates. If the value
- is not compatible with the type of the property, the subsequent
- action is ignored.
-
- @type value: string
- """
-
diff --git a/source/gameengine/PyDoc/SCA_PythonController.py b/source/gameengine/PyDoc/SCA_PythonController.py
deleted file mode 100644
index 9684b41d481..00000000000
--- a/source/gameengine/PyDoc/SCA_PythonController.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# $Id$
-# Documentation for SCA_PythonController
-from SCA_IController import *
-
-class SCA_PythonController(SCA_IController):
- """
- A Python controller uses a Python script to activate it's actuators,
- based on it's sensors.
-
- Properties:
-
- @ivar script: the Python script this controller executes
- @type script: string, read-only
- @ivar state: the controllers state bitmask.
- This can be used with the GameObject's state to test if the controller is active.
- @type state: integer
- """
- def activate(actuator):
- """
- Activates an actuator attached to this controller.
- @type actuator: actuator or the actuator name as a string
- """
- def deactivate(actuator):
- """
- Deactivates an actuator attached to this controller.
- @type actuator: actuator or the actuator name as a string
- """
-
- def getSensors():
- """
- Gets a list of all sensors attached to this controller.
-
- @rtype: list [L{SCA_ISensor}]
- """
- def getSensor(name):
- """
- Gets the named linked sensor.
-
- @type name: string
- @rtype: L{SCA_ISensor}
- """
- def getActuators():
- """
- Gets a list of all actuators linked to this controller.
-
- @rtype: list [L{SCA_IActuator}]
- """
- def getActuator(name):
- """
- Gets the named linked actuator.
-
- @type name: string
- @rtype: L{SCA_IActuator}
- """
- def getScript():
- """
- DEPRECATED: use the script property
- Gets the Python script this controller executes.
-
- @rtype: string
- """
- def setScript(script):
- """
- Sets the Python script this controller executes.
-
- @type script: string.
- """
- def getState():
- """
- DEPRECATED: use the state property
- Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active.
- This for instance will always be true however you could compare with a previous state to see when the state was activated.
- GameLogic.getCurrentController().getState() & GameLogic.getCurrentController().getOwner().getState()
-
- @rtype: int
- """
-
diff --git a/source/gameengine/PyDoc/SCA_RandomActuator.py b/source/gameengine/PyDoc/SCA_RandomActuator.py
deleted file mode 100644
index 000a1af7846..00000000000
--- a/source/gameengine/PyDoc/SCA_RandomActuator.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# $Id$
-# Documentation for SCA_RandomActuator
-from SCA_IActuator import *
-
-class SCA_RandomActuator(SCA_IActuator):
- """
- Random Actuator
-
- Properties:
-
- @ivar seed: Seed of the random number generator.
- Equal seeds produce equal series. If the seed is 0,
- the generator will produce the same value on every call.
- @type seed: integer
- @ivar para1: the first parameter of the active distribution.
- Refer to the documentation of the generator types for the meaning
- of this value.
- @type para1: float, read-only
- @ivar para2: the second parameter of the active distribution.
- Refer to the documentation of the generator types for the meaning
- of this value.
- @type para2: float, read-only
- @ivar distribution: distribution type:
- KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
- KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON,
- KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
- KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
- @type distribution: integer, read-only
- @ivar property: the name of the property to set with the random value.
- If the generator and property types do not match, the assignment is ignored.
- @type property: string
-
- """
- def setSeed(seed):
- """
- DEPRECATED: use the seed property
- Sets the seed of the random number generator.
-
- Equal seeds produce equal series. If the seed is 0,
- the generator will produce the same value on every call.
-
- @type seed: integer
- """
- def getSeed():
- """
- DEPRECATED: use the seed property
- Returns the initial seed of the generator.
-
- @rtype: integer
- """
- def getPara1():
- """
- DEPRECATED: use the para1 property
- Returns the first parameter of the active distribution.
-
- Refer to the documentation of the generator types for the meaning
- of this value.
-
- @rtype: float
- """
- def getPara2():
- """
- DEPRECATED: use the para2 property
- Returns the second parameter of the active distribution.
-
- Refer to the documentation of the generator types for the meaning
- of this value.
-
- @rtype: float
- """
- def getDistribution():
- """
- DEPRECATED: use the distribution property
- Returns the type of random distribution.
-
- @rtype: distribution type
- @return: KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
- KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON,
- KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
- KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
- """
- def setProperty(property):
- """
- DEPRECATED: use the property property
- Set the property to which the random value is assigned.
-
- If the generator and property types do not match, the assignment is ignored.
-
- @type property: string
- @param property: The name of the property to set.
- """
- def getProperty():
- """
- DEPRECATED: use the property property
- Returns the name of the property to set.
-
- @rtype: string
- """
- def setBoolConst(value):
- """
- Sets this generator to produce a constant boolean value.
-
- @param value: The value to return.
- @type value: boolean
- """
- def setBoolUniform():
- """
- Sets this generator to produce a uniform boolean distribution.
-
- The generator will generate True or False with 50% chance.
- """
- def setBoolBernouilli(value):
- """
- Sets this generator to produce a Bernouilli distribution.
-
- @param value: Specifies the proportion of False values to produce.
- - 0.0: Always generate True
- - 1.0: Always generate False
- @type value: float
- """
- def setIntConst(value):
- """
- Sets this generator to always produce the given value.
-
- @param value: the value this generator produces.
- @type value: integer
- """
- def setIntUniform(lower_bound, upper_bound):
- """
- Sets this generator to produce a random value between the given lower and
- upper bounds (inclusive).
-
- @type lower_bound: integer
- @type upper_bound: integer
- """
- def setIntPoisson(value):
- """
- Generate a Poisson-distributed number.
-
- This performs a series of Bernouilli tests with parameter value.
- It returns the number of tries needed to achieve succes.
-
- @type value: float
- """
- def setFloatConst(value):
- """
- Always generate the given value.
-
- @type value: float
- """
- def setFloatUniform(lower_bound, upper_bound):
- """
- Generates a random float between lower_bound and upper_bound with a
- uniform distribution.
-
- @type lower_bound: float
- @type upper_bound: float
- """
- def setFloatNormal(mean, standard_deviation):
- """
- Generates a random float from the given normal distribution.
-
- @type mean: float
- @param mean: The mean (average) value of the generated numbers
- @type standard_deviation: float
- @param standard_deviation: The standard deviation of the generated numbers.
- """
- def setFloatNegativeExponential(half_life):
- """
- Generate negative-exponentially distributed numbers.
-
- The half-life 'time' is characterized by half_life.
-
- @type half_life: float
- """
diff --git a/source/gameengine/PyDoc/SCA_RandomSensor.py b/source/gameengine/PyDoc/SCA_RandomSensor.py
deleted file mode 100644
index 6dc0a3c23c0..00000000000
--- a/source/gameengine/PyDoc/SCA_RandomSensor.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# $Id$
-# Documentation for SCA_RandomSensor
-from SCA_ISensor import *
-
-class SCA_RandomSensor(SCA_ISensor):
- """
- This sensor activates randomly.
-
- @ivar lastDraw: The seed of the random number generator.
- @type lastDraw: int
- @ivar seed: The seed of the random number generator.
- @type seed: int
- """
-
- def setSeed(seed):
- """
- Sets the seed of the random number generator.
-
- If the seed is 0, the generator will produce the same value on every call.
-
- @type seed: integer.
- """
- def getSeed():
- """
- Returns the initial seed of the generator. Equal seeds produce equal random
- series.
-
- @rtype: integer
- """
- def getLastDraw():
- """
- Returns the last random number generated.
-
- @rtype: integer
- """
diff --git a/source/gameengine/PyDoc/SCA_XNORController.py b/source/gameengine/PyDoc/SCA_XNORController.py
deleted file mode 100644
index 5fb2561f35a..00000000000
--- a/source/gameengine/PyDoc/SCA_XNORController.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-# Documentation for SCA_XNORController
-from SCA_IController import *
-
-class SCA_XNORController(SCA_IController):
- """
- An XNOR controller activates when all linked sensors are the same (activated or inative).
-
- There are no special python methods for this controller.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_XORController.py b/source/gameengine/PyDoc/SCA_XORController.py
deleted file mode 100644
index 10e20fb0945..00000000000
--- a/source/gameengine/PyDoc/SCA_XORController.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-# Documentation for SCA_XORController
-from SCA_IController import *
-
-class SCA_XORController(SCA_IController):
- """
- An XOR controller activates when there is the input is mixed, but not when all are on or off.
-
- There are no special python methods for this controller.
- """
-
diff --git a/source/gameengine/PyDoc/WhatsNew.py b/source/gameengine/PyDoc/WhatsNew.py
deleted file mode 100644
index 4d86e6ef3c4..00000000000
--- a/source/gameengine/PyDoc/WhatsNew.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# $Id$
-"""
-New Python Functionality in this Version of Blender
-===================================================
-
-This document lists what has been changed in the Game Engine Python API.
-
-Blender CVS
- - Added L{KX_GameObject}.getDistanceTo() method. (thanks Charlie C)
- - Added L{KX_PolygonMaterial} module
-
-Blender 2.36
-------------
- - Added L{KX_CameraActuator} methods (thanks snail)
-
-Blender 2.35
-------------
- - Added tic rate methods to L{GameLogic}
- - Added stereo eye separation and focal length methods to L{Rasterizer}.
- - Fixed L{Rasterizer}.makeScreenshot() method.
- - Added setLogicTicRate() and setPhysicsTicRate() to L{GameLogic}
-
-Blender 2.34
-------------
-
- - Added getType() and setType() to L{BL_ActionActuator} and L{KX_SoundActuator} (sgefant)
- - New Scene module: L{KX_Scene}
- - New Camera module: L{KX_Camera}
- - New Light module: L{KX_LightObject}
- - Added attributes to L{KX_GameObject}, L{KX_VertexProxy}
- - L{KX_SCA_AddObjectActuator}.setObject(), L{KX_TrackToActuator}.setObject() and
- L{KX_SceneActuator}.setCamera() now accept L{KX_GameObject}s as parameters
-
-"""
diff --git a/source/gameengine/PyDoc/bge_api_validate_py.txt b/source/gameengine/PyDoc/bge_api_validate_py.txt
index 0920e5d3c7d..ebd74c06bb3 100644
--- a/source/gameengine/PyDoc/bge_api_validate_py.txt
+++ b/source/gameengine/PyDoc/bge_api_validate_py.txt
@@ -12,9 +12,17 @@
#
# Currently it only prints missing modules and methods (not attributes)
+import sys, os
BGE_API_DOC_PATH = 'source/gameengine/PyDoc'
+
+mods = ['GameLogic', 'Rasterizer', 'GameKeys']
+mods_dict = {}
+for m in mods:
+ mods_dict[m] = sys.modules[m]
+
+
import GameTypes
type_members = {}
@@ -34,7 +42,7 @@ for type_name in dir(GameTypes):
# print type_object.__name__ + '.' + k
members.append(member)
-import sys, os
+
doc_dir= os.path.join(os.getcwd(), BGE_API_DOC_PATH)
@@ -42,13 +50,12 @@ if doc_dir not in sys.path:
sys.path.append(doc_dir)
-def check_attribute(type_mame, member):
- filename = os.path.join(doc_dir, type_mame + '.py')
- # print filename
+def check_attribute(class_ob, member):
+ doc = class_ob.__doc__
+ if not doc:
+ return False
- file = open(filename, 'rU')
-
- for l in file:
+ for l in doc.split('\n'):
l = l.strip()
'''
@@ -58,14 +65,12 @@ def check_attribute(type_mame, member):
'''
- if l.startswith('@ivar'):
+ if l.startswith('@ivar') or l.startswith('@var'):
var = l.split()[1].split(':')[0]
if var == member:
- file.close()
return True
- file.close()
return False
@@ -77,20 +82,16 @@ print '\n\n\nChecking Docs'
PRINT_OK = False
+pymod = sys.modules['GameTypes']
+del sys.modules['GameTypes'] # temp remove
+mod = __import__('GameTypes') # get the python module
+reload(mod) # incase were editing it
+sys.modules['GameTypes'] = pymod
+
for type_name in sorted(type_members.keys()):
members = type_members[type_name]
try:
- mod = __import__(type_name)
- if PRINT_OK:
- print "type: %s" % type_name
- except:
- print "missing: %s - %s" % (type_name, str(sorted(members)))
- continue
-
- reload(mod) # incase were editing it
-
- try:
type_class = getattr(mod, type_name)
except:
print "missing class: %s.%s - %s" % (type_name, type_name, str(sorted(members)))
@@ -102,9 +103,34 @@ for type_name in sorted(type_members.keys()):
if PRINT_OK:
print "\tfound: %s.%s" % (type_name, member)
except:
- if check_attribute(type_name, member):
+ if check_attribute(type_class, member):
if PRINT_OK:
print "\tfound attr: %s.%s" % (type_name, member)
else:
print "\tmissing: %s.%s" % (type_name, member)
+
+# Now check the modules
+for mod_name, pymod in mods_dict.iteritems():
+ print pymod
+ del sys.modules[mod_name]
+
+ # Now well get the python version
+ pydoc = __import__(mod_name)
+ pydoc = reload(pydoc) # avoid using the out dated pyc file only
+ print pydoc.__file__
+
+ for member in sorted(dir(pymod)):
+ if hasattr(pydoc, member) or check_attribute(pydoc, member):
+ if PRINT_OK:
+ print "\tfound module attr: %s.%s" % (mod_name, member)
+ else:
+ print "\tmissing module attr: %s.%s" % (mod_name, member)
+
+ # Restore real module
+ sys.modules[mod_name] = pymod
+
+
+sys.path.pop() # remove the pydoc dir from our import paths
+
+
diff --git a/source/gameengine/PyDoc/epy_docgen.sh b/source/gameengine/PyDoc/epy_docgen.sh
index ddf39dcc081..dd30256f42f 100755
--- a/source/gameengine/PyDoc/epy_docgen.sh
+++ b/source/gameengine/PyDoc/epy_docgen.sh
@@ -7,5 +7,10 @@
# set posix locale so regex works properly for [A-Z]*.py
LC_ALL=POSIX
-epydoc --debug -v -o BPY_GE --url "http://www.blender.org" --top GameLogic \
- --name "Blender GameEngine" --no-private --no-frames --no-sourcecode --inheritance=included *.py
+epydoc --debug -v -o BPY_GE --url "http://www.blender.org" --top API_intro \
+ --name "Blender GameEngine" --no-private --no-sourcecode --inheritance=included \
+ *.py \
+ ../../../source/blender/python/api2_2x/doc/BGL.py \
+ ../../../source/blender/python/api2_2x/doc/Mathutils.py \
+ ../../../source/blender/python/api2_2x/doc/Geometry.py
+
diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt
index 6d53ee53471..143209f5a54 100644
--- a/source/gameengine/Rasterizer/CMakeLists.txt
+++ b/source/gameengine/Rasterizer/CMakeLists.txt
@@ -29,6 +29,8 @@ FILE(GLOB SRC *.cpp)
SET(INC
.
../../../source/kernel/gen_system
+ ../../../source/blender/makesdna
+ ../../../source/gameengine/SceneGraph
../../../intern/string
../../../intern/moto/include
../../../extern/glew/include
diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile
index 917f70c7108..eafa2ded2f2 100644
--- a/source/gameengine/Rasterizer/Makefile
+++ b/source/gameengine/Rasterizer/Makefile
@@ -40,6 +40,8 @@ CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../kernel/gen_system
+CPPFLAGS += -I../../blender/makesdna
+CPPFLAGS += -I../SceneGraph
CPPFLAGS += -I../BlenderRoutines
CPPFLAGS += -I../Expressions
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
index 176da51b183..239031866ca 100644
--- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
@@ -63,11 +63,9 @@ numberoffilters(0), need_tex_update(true)
isshadersupported = GLEW_ARB_shader_objects &&
GLEW_ARB_fragment_shader && GLEW_ARB_multitexture;
+ /* used to return before 2.49 but need to initialize values so dont */
if(!isshadersupported)
- {
std::cout<<"shaders not supported!" << std::endl;
- return;
- }
int passindex;
for(passindex =0; passindex<MAX_RENDER_PASS; passindex++)
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp
index ec290f89d9e..200b1c6c89f 100644
--- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp
@@ -113,16 +113,26 @@ void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList
const MT_Vector3 pnorm(cameratrans.getBasis()[2]);
for (bit = buckets.begin(); bit != buckets.end(); ++bit)
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit)
- if (!mit->IsCulled())
- size++;
+ {
+ SG_DList::iterator<RAS_MeshSlot> mit((*bit)->GetActiveMeshSlots());
+ for(mit.begin(); !mit.end(); ++mit)
+ size++;
+ }
slots.resize(size);
for (bit = buckets.begin(); bit != buckets.end(); ++bit)
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit)
- if (!mit->IsCulled())
- slots[i++].set(&*mit, *bit, pnorm);
+ {
+ RAS_MaterialBucket* bucket = *bit;
+ RAS_MeshSlot* ms;
+ // remove the mesh slot form the list, it culls them automatically for next frame
+ for(ms = bucket->GetNextActiveMeshSlot();
+ ms!= NULL;
+ ms = bucket->GetNextActiveMeshSlot())
+ {
+ slots[i++].set(ms, bucket, pnorm);
+ }
+ }
if(alpha)
sort(slots.begin(), slots.end(), backtofront());
@@ -161,11 +171,28 @@ void RAS_BucketManager::RenderSolidBuckets(
const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools)
{
BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
+#if 1
+ RAS_MaterialBucket* bucket = *bit;
+ RAS_MeshSlot* ms;
+ // remove the mesh slot form the list, it culls them automatically for next frame
+ for(ms = bucket->GetNextActiveMeshSlot();
+ ms!= NULL;
+ ms = bucket->GetNextActiveMeshSlot())
+ {
+ rendertools->SetClientObject(rasty, ms->m_clientObj);
+ while (bucket->ActivateMaterial(cameratrans, rasty, rendertools))
+ bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *ms);
+
+ // make this mesh slot culled automatically for next frame
+ // it will be culled out by frustrum culling
+ ms->SetCulled(true);
+ }
+#else
+ list<RAS_MeshSlot>::iterator mit;
for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
if (mit->IsCulled())
continue;
@@ -179,6 +206,7 @@ void RAS_BucketManager::RenderSolidBuckets(
// it will be culled out by frustrum culling
mit->SetCulled(true);
}
+#endif
}
/* this code draws meshes order front-to-back instead to reduce overdraw.
@@ -276,3 +304,21 @@ void RAS_BucketManager::ReleaseDisplayLists(RAS_IPolyMaterial *mat)
}
}
+void RAS_BucketManager::ReleaseMaterials(RAS_IPolyMaterial * mat)
+{
+ BucketList::iterator bit;
+ list<RAS_MeshSlot>::iterator mit;
+
+ for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
+ if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
+ (*bit)->GetPolyMaterial()->ReleaseMaterial();
+ }
+ }
+
+ for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) {
+ if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
+ (*bit)->GetPolyMaterial()->ReleaseMaterial();
+ }
+ }
+}
+
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h
index 74526f365a0..2b81ddd3c82 100644
--- a/source/gameengine/Rasterizer/RAS_BucketManager.h
+++ b/source/gameengine/Rasterizer/RAS_BucketManager.h
@@ -58,6 +58,7 @@ public:
void OptimizeBuckets(MT_Scalar distance);
void ReleaseDisplayLists(RAS_IPolyMaterial * material = NULL);
+ void ReleaseMaterials(RAS_IPolyMaterial * material = NULL);
private:
void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha);
diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h
index e3af43fb839..c8f4d9a0a17 100644
--- a/source/gameengine/Rasterizer/RAS_CameraData.h
+++ b/source/gameengine/Rasterizer/RAS_CameraData.h
@@ -32,6 +32,7 @@
struct RAS_CameraData
{
float m_lens;
+ float m_scale;
float m_clipstart;
float m_clipend;
bool m_perspective;
@@ -42,10 +43,11 @@ struct RAS_CameraData
int m_viewporttop;
float m_focallength;
- RAS_CameraData(float lens = 35.0, float clipstart = 0.1, float clipend = 5000.0, bool perspective = true,
+ RAS_CameraData(float lens = 35.0, float scale = 6.0, float clipstart = 0.1, float clipend = 5000.0, bool perspective = true,
float focallength = 0.0f, bool viewport = false, int viewportleft = 0, int viewportbottom = 0,
int viewportright = 0, int viewporttop = 0) :
m_lens(lens),
+ m_scale(scale),
m_clipstart(clipstart),
m_clipend(clipend),
m_perspective(perspective),
diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h
index 3332ac4c0a7..fe9b1540af8 100644
--- a/source/gameengine/Rasterizer/RAS_Deformer.h
+++ b/source/gameengine/Rasterizer/RAS_Deformer.h
@@ -34,23 +34,47 @@
#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
#endif //WIN32
+#include <stdlib.h>
#include "GEN_Map.h"
+struct DerivedMesh;
+
class RAS_Deformer
{
public:
- RAS_Deformer(){};
+ RAS_Deformer() : m_pMesh(NULL), m_bDynamic(false) {};
virtual ~RAS_Deformer(){};
virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)=0;
virtual bool Apply(class RAS_IPolyMaterial *polymat)=0;
virtual bool Update(void)=0;
- virtual RAS_Deformer *GetReplica(class KX_GameObject* replica)=0;
+ virtual bool UpdateBuckets(void)=0;
+ virtual RAS_Deformer *GetReplica()=0;
+ virtual void ProcessReplica()=0;
virtual bool SkipVertexTransform()
{
return false;
}
+ virtual bool ShareVertexArray()
+ {
+ return true;
+ }
+ virtual bool UseVertexArray()
+ {
+ return true;
+ }
+ // true when deformer produces varying vertex (shape or armature)
+ bool IsDynamic()
+ {
+ return m_bDynamic;
+ }
+ virtual struct DerivedMesh* GetFinalMesh()
+ {
+ return NULL;
+ }
+
protected:
class RAS_MeshObject *m_pMesh;
+ bool m_bDynamic;
};
#endif
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp
index e2bbca48bb5..ea18ffb2298 100644
--- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp
@@ -72,6 +72,39 @@ ComputeDefaultFrustum(
void
RAS_FramingManager::
+ComputeDefaultOrtho(
+ const float camnear,
+ const float camfar,
+ const float scale,
+ const float design_aspect_ratio,
+ RAS_FrameFrustum & frustum
+)
+{
+ float halfSize = scale*0.5f;
+ float sizeX;
+ float sizeY;
+
+ if (design_aspect_ratio > 1.f) {
+ // halfsize defines the width
+ sizeX = halfSize;
+ sizeY = halfSize/design_aspect_ratio;
+ } else {
+ // halfsize defines the height
+ sizeX = halfSize * design_aspect_ratio;
+ sizeY = halfSize;
+ }
+
+ frustum.x2 = sizeX;
+ frustum.x1 = -frustum.x2;
+ frustum.y2 = sizeY;
+ frustum.y1 = -frustum.y2;
+ frustum.camnear = -camfar;
+ frustum.camfar = camfar;
+}
+
+
+ void
+RAS_FramingManager::
ComputeBestFitViewRect(
const RAS_Rect &availableViewport,
const float design_aspect_ratio,
@@ -227,5 +260,73 @@ ComputeFrustum(
}
}
+ void
+RAS_FramingManager::
+ ComputeOrtho(
+ const RAS_FrameSettings &settings,
+ const RAS_Rect &availableViewport,
+ const RAS_Rect &viewport,
+ const float scale,
+ const float camnear,
+ const float camfar,
+ RAS_FrameFrustum &frustum
+ )
+{
+ RAS_FrameSettings::RAS_FrameType type = settings.FrameType();
+
+ const float design_width = float(settings.DesignAspectWidth());
+ const float design_height = float(settings.DesignAspectHeight());
+
+ float design_aspect_ratio = float(1);
+
+ if (design_height == float(0)) {
+ // well this is ill defined
+ // lets just scale the thing
+ type = RAS_FrameSettings::e_frame_scale;
+ } else {
+ design_aspect_ratio = design_width/design_height;
+ }
+
+
+ ComputeDefaultOrtho(
+ camnear,
+ camfar,
+ scale,
+ design_aspect_ratio,
+ frustum
+ );
+
+ switch (type) {
+
+ case RAS_FrameSettings::e_frame_extend:
+ {
+ RAS_Rect vt;
+ ComputeBestFitViewRect(
+ availableViewport,
+ design_aspect_ratio,
+ vt
+ );
+
+ // now scale the calculated frustum by the difference
+ // between vt and the viewport in each axis.
+ // These are always > 1
+
+ float x_scale = float(viewport.GetWidth())/float(vt.GetWidth());
+ float y_scale = float(viewport.GetHeight())/float(vt.GetHeight());
+
+ frustum.x1 *= x_scale;
+ frustum.x2 *= x_scale;
+ frustum.y1 *= y_scale;
+ frustum.y2 *= y_scale;
+
+ break;
+ }
+ case RAS_FrameSettings::e_frame_scale :
+ case RAS_FrameSettings::e_frame_bars:
+ default :
+ break;
+ }
+
+}
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h
index 0a226ac30f9..4398e2d00c3 100644
--- a/source/gameengine/Rasterizer/RAS_FramingManager.h
+++ b/source/gameengine/Rasterizer/RAS_FramingManager.h
@@ -209,6 +209,18 @@ public :
static
void
+ ComputeOrtho(
+ const RAS_FrameSettings &settings,
+ const RAS_Rect &availableViewport,
+ const RAS_Rect &viewport,
+ const float scale,
+ const float camnear,
+ const float camfar,
+ RAS_FrameFrustum &frustum
+ );
+
+ static
+ void
ComputeFrustum(
const RAS_FrameSettings &settings,
const RAS_Rect &availableViewport,
@@ -229,6 +241,16 @@ public :
RAS_FrameFrustum & frustum
);
+ static
+ void
+ ComputeDefaultOrtho(
+ const float camnear,
+ const float camfar,
+ const float scale,
+ const float design_aspect_ratio,
+ RAS_FrameFrustum & frustum
+ );
+
private :
static
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
index cd88112007b..6af00d63c2d 100644
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
+++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
@@ -29,12 +29,71 @@
#include "RAS_IPolygonMaterial.h"
#include "RAS_IRasterizer.h"
+#include "DNA_image_types.h"
+#include "DNA_meshdata_types.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+void RAS_IPolyMaterial::Initialize(
+ const STR_String& texname,
+ const STR_String& matname,
+ int materialindex,
+ int tile,
+ int tilexrep,
+ int tileyrep,
+ int mode,
+ int transp,
+ bool alpha,
+ bool zsort,
+ int lightlayer)
+{
+ m_texturename = texname;
+ m_materialname = matname;
+ m_materialindex = materialindex;
+ m_tile = tile;
+ m_tilexrep = tilexrep;
+ m_tileyrep = tileyrep;
+ m_drawingmode = mode;
+ m_transp = transp;
+ m_alpha = alpha;
+ m_zsort = zsort;
+ //m_lightlayer = lightlayer;
+ m_polymatid = m_newpolymatid++;
+ m_flag = 0;
+ m_multimode = 0;
+ m_shininess = 35.0;
+ m_specular.setValue(0.5,0.5,0.5);
+ m_specularity = 1.0;
+ m_diffuse.setValue(0.5,0.5,0.5);
+}
+
+RAS_IPolyMaterial::RAS_IPolyMaterial()
+ : m_texturename("__Dummy_Texture_Name__"),
+ m_materialname("__Dummy_Material_Name__"),
+ m_materialindex(0),
+ m_tile(0),
+ m_tilexrep(0),
+ m_tileyrep(0),
+ m_drawingmode (0),
+ m_transp(0),
+ m_alpha(false),
+ m_zsort(false),
+ //m_lightlayer(0),
+ m_polymatid(0),
+ m_flag(0),
+ m_multimode(0)
+{
+ m_shininess = 35.0;
+ m_specular = MT_Vector3(0.5,0.5,0.5);
+ m_specularity = 1.0;
+ m_diffuse = MT_Vector3(0.5,0.5,0.5);
+}
+
RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname,
const STR_String& matname,
+ int materialindex,
int tile,
int tilexrep,
int tileyrep,
@@ -45,6 +104,7 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname,
int lightlayer)
: m_texturename(texname),
m_materialname(matname),
+ m_materialindex(materialindex),
m_tile(tile),
m_tilexrep(tilexrep),
m_tileyrep(tileyrep),
@@ -52,7 +112,7 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname,
m_transp(transp),
m_alpha(alpha),
m_zsort(zsort),
- m_lightlayer(lightlayer),
+ //m_lightlayer(lightlayer),
m_polymatid(m_newpolymatid++),
m_flag(0),
m_multimode(0)
@@ -95,6 +155,15 @@ bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const
}
}
+
+void RAS_IPolyMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
+{
+ *rgba++ = 0xFF;
+ *rgba++ = 0xFF;
+ *rgba++ = 0xFF;
+ *rgba++ = 0xFF;
+}
+
bool RAS_IPolyMaterial::Less(const RAS_IPolyMaterial& rhs) const
{
if (Equals(rhs))
@@ -103,10 +172,10 @@ bool RAS_IPolyMaterial::Less(const RAS_IPolyMaterial& rhs) const
return m_polymatid < rhs.m_polymatid;
}
-int RAS_IPolyMaterial::GetLightLayer() const
-{
- return m_lightlayer;
-}
+//int RAS_IPolyMaterial::GetLightLayer() const
+//{
+// return m_lightlayer;
+//}
bool RAS_IPolyMaterial::IsAlpha() const
{
@@ -143,6 +212,25 @@ const STR_String& RAS_IPolyMaterial::GetTextureName() const
return m_texturename;
}
+int RAS_IPolyMaterial::GetMaterialIndex() const
+{
+ return m_materialindex;
+}
+
+Material *RAS_IPolyMaterial::GetBlenderMaterial() const
+{
+ return NULL;
+}
+
+Scene* RAS_IPolyMaterial::GetBlenderScene() const
+{
+ return NULL;
+}
+
+void RAS_IPolyMaterial::ReleaseMaterial()
+{
+}
+
unsigned int RAS_IPolyMaterial::GetFlag() const
{
return m_flag;
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
index e5b24070c4b..e19db35ccb5 100644
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
+++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
@@ -39,6 +39,9 @@
#include "STR_HashedString.h"
class RAS_IRasterizer;
+struct MTFace;
+struct Material;
+struct Scene;
enum MaterialProps
{
@@ -70,7 +73,8 @@ protected:
int m_transp;
bool m_alpha;
bool m_zsort;
- int m_lightlayer;
+ //int m_lightlayer;
+ int m_materialindex;
unsigned int m_polymatid;
static unsigned int m_newpolymatid;
@@ -96,8 +100,10 @@ public:
SHADOW =8192
};
+ RAS_IPolyMaterial();
RAS_IPolyMaterial(const STR_String& texname,
const STR_String& matname,
+ int materialindex,
int tile,
int tilexrep,
int tileyrep,
@@ -106,6 +112,17 @@ public:
bool alpha,
bool zsort,
int lightlayer);
+ void Initialize(const STR_String& texname,
+ const STR_String& matname,
+ int materialindex,
+ int tile,
+ int tilexrep,
+ int tileyrep,
+ int mode,
+ int transp,
+ bool alpha,
+ bool zsort,
+ int lightlayer);
virtual ~RAS_IPolyMaterial() {};
/**
@@ -130,7 +147,7 @@ public:
virtual bool Equals(const RAS_IPolyMaterial& lhs) const;
bool Less(const RAS_IPolyMaterial& rhs) const;
- int GetLightLayer() const;
+ //int GetLightLayer() const;
bool IsAlpha() const;
bool IsZSort() const;
unsigned int hash() const;
@@ -139,14 +156,18 @@ public:
dword GetMaterialNameHash() const;
const STR_String& GetTextureName() const;
unsigned int GetFlag() const;
+ int GetMaterialIndex() const;
+ virtual Material* GetBlenderMaterial() const;
+ virtual Scene* GetBlenderScene() const;
+ virtual void ReleaseMaterial();
+ virtual void GetMaterialRGBAColor(unsigned char *rgba) const;
virtual bool UsesLighting(RAS_IRasterizer *rasty) const;
virtual bool UsesObjectColor() const;
-
/*
* PreCalculate texture gen
*/
- virtual void OnConstruction(){}
+ virtual void OnConstruction(int layer){}
};
inline bool operator ==( const RAS_IPolyMaterial & rhs,const RAS_IPolyMaterial & lhs)
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index cfeda06e670..dc8c3c1ebf8 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -250,9 +250,9 @@ public:
* Sets the modelview matrix.
*/
virtual void SetViewMatrix(const MT_Matrix4x4 & mat,
- const MT_Vector3& campos,
- const MT_Point3 &camLoc,
- const MT_Quaternion &camOrientQuat)=0;
+ const MT_Matrix3x3 & ori,
+ const MT_Point3 & pos,
+ bool perspective)=0;
/**
*/
virtual const MT_Point3& GetCameraPosition()=0;
@@ -280,6 +280,7 @@ public:
/**
*/
virtual void DisableFog()=0;
+ virtual bool IsFogEnabled()=0;
virtual void SetBackColor(float red,
float green,
@@ -325,6 +326,26 @@ public:
float focallength = 0.0f,
bool perspective = true
)=0;
+
+ /**
+ * Generates a orthographic projection matrix from the specified frustum.
+ * @param left the left clipping plane
+ * @param right the right clipping plane
+ * @param bottom the bottom clipping plane
+ * @param top the top clipping plane
+ * @param frustnear the near clipping plane
+ * @param frustfar the far clipping plane
+ * @return a 4x4 matrix representing the projection transform.
+ */
+ virtual MT_Matrix4x4 GetOrthoMatrix(
+ float left,
+ float right,
+ float bottom,
+ float top,
+ float frustnear,
+ float frustfar
+ )=0;
+
/**
* Sets the specular color component of the lighting equation.
*/
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
index 6beab28d61f..8e90c9a1c08 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
@@ -42,7 +42,7 @@
/* mesh slot */
-RAS_MeshSlot::RAS_MeshSlot()
+RAS_MeshSlot::RAS_MeshSlot() : SG_QList()
{
m_clientObj = NULL;
m_pDeformer = NULL;
@@ -56,6 +56,7 @@ RAS_MeshSlot::RAS_MeshSlot()
m_DisplayList = NULL;
m_bDisplayList = true;
m_joinSlot = NULL;
+ m_pDerivedMesh = NULL;
}
RAS_MeshSlot::~RAS_MeshSlot()
@@ -81,12 +82,13 @@ RAS_MeshSlot::~RAS_MeshSlot()
}
}
-RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot)
+RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot) : SG_QList()
{
RAS_DisplayArrayList::iterator it;
m_clientObj = NULL;
m_pDeformer = NULL;
+ m_pDerivedMesh = NULL;
m_OpenGLMatrix = NULL;
m_mesh = slot.m_mesh;
m_bucket = slot.m_bucket;
@@ -279,6 +281,63 @@ void RAS_MeshSlot::AddPolygonVertex(int offset)
m_endindex++;
}
+void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer)
+{
+ if (deformer && m_pDeformer != deformer) {
+ RAS_DisplayArrayList::iterator it;
+ if (deformer->ShareVertexArray()) {
+ // this deformer uses the base vertex array, first release the current ones
+ for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+ (*it)->m_users--;
+ if((*it)->m_users == 0)
+ delete *it;
+ }
+ m_displayArrays.clear();
+ // then hook to the base ones
+ RAS_MeshMaterial *mmat = m_mesh->GetMeshMaterial(m_bucket->GetPolyMaterial());
+ if (mmat && mmat->m_baseslot) {
+ m_displayArrays = mmat->m_baseslot->m_displayArrays;
+ for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+ (*it)->m_users++;
+ }
+ }
+ }
+ else {
+ // no sharing
+ // we create local copy of RAS_DisplayArray when we have a deformer:
+ // this way we can avoid conflict between the vertex cache of duplicates
+ for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+ if (deformer->UseVertexArray()) {
+ // the deformer makes use of vertex array, make sure we have our local copy
+ if ((*it)->m_users > 1) {
+ // only need to copy if there are other users
+ // note that this is the usual case as vertex arrays are held by the material base slot
+ RAS_DisplayArray *newarray = new RAS_DisplayArray(*(*it));
+ newarray->m_users = 1;
+ (*it)->m_users--;
+ *it = newarray;
+ }
+ } else {
+ // the deformer is not using vertex array (Modifier), release them
+ (*it)->m_users--;
+ if((*it)->m_users == 0)
+ delete *it;
+ }
+ }
+ if (!deformer->UseVertexArray()) {
+ m_displayArrays.clear();
+ m_startarray = 0;
+ m_startvertex = 0;
+ m_startindex = 0;
+ m_endarray = 0;
+ m_endvertex = 0;
+ m_endindex = 0;
+ }
+ }
+ }
+ m_pDeformer = deformer;
+}
+
bool RAS_MeshSlot::Equals(RAS_MeshSlot *target)
{
if(!m_OpenGLMatrix || !target->m_OpenGLMatrix)
@@ -422,21 +481,21 @@ bool RAS_MeshSlot::Split(bool force)
return false;
}
+
+#ifdef USE_SPLIT
bool RAS_MeshSlot::IsCulled()
{
- list<RAS_MeshSlot*>::iterator it;
-
if(m_joinSlot)
return true;
if(!m_bCulled)
return false;
-#ifdef USE_SPLIT
+ list<RAS_MeshSlot*>::iterator it;
for(it=m_joinedSlots.begin(); it!=m_joinedSlots.end(); it++)
if(!(*it)->m_bCulled)
return false;
-#endif
return true;
}
+#endif
/* material bucket sorting */
@@ -558,7 +617,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa
// then it won't have texture coordinates for actual drawing. also
// for zsort we can't make a display list, since the polygon order
// changes all the time.
- if(ms.m_pDeformer)
+ if(ms.m_pDeformer && ms.m_pDeformer->IsDynamic())
ms.m_bDisplayList = false;
else if(!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW)
ms.m_bDisplayList = false;
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
index f5c8cd3e107..8db75b8b735 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
@@ -32,6 +32,7 @@
#include "RAS_TexVert.h"
#include "GEN_Map.h"
#include "STR_HashedString.h"
+#include "SG_QList.h"
#include "MT_Transform.h"
#include "RAS_IPolygonMaterial.h"
@@ -69,6 +70,7 @@ class RAS_DisplayArray;
class RAS_MeshSlot;
class RAS_MeshMaterial;
class RAS_MaterialBucket;
+struct DerivedMesh;
/* An array with data used for OpenGL drawing */
@@ -88,7 +90,9 @@ public:
/* Entry of a RAS_MeshObject into RAS_MaterialBucket */
typedef std::vector<RAS_DisplayArray*> RAS_DisplayArrayList;
-class RAS_MeshSlot
+// The QList is used to link the mesh slots to the object
+// The DList is used to link the visible mesh slots to the material bucket
+class RAS_MeshSlot : public SG_QList
{
friend class RAS_ListRasterizer;
private:
@@ -110,6 +114,7 @@ public:
RAS_MeshObject* m_mesh;
void* m_clientObj;
RAS_Deformer* m_pDeformer;
+ DerivedMesh* m_pDerivedMesh;
double* m_OpenGLMatrix;
// visibility
bool m_bVisible;
@@ -148,6 +153,7 @@ public:
/* used during construction */
void SetDisplayArray(int numverts);
RAS_DisplayArray *CurrentDisplayArray();
+ void SetDeformer(RAS_Deformer* deformer);
void AddPolygon(int numverts);
int AddVertex(const RAS_TexVert& tv);
@@ -157,7 +163,11 @@ public:
bool Split(bool force=false);
bool Join(RAS_MeshSlot *target, MT_Scalar distance);
bool Equals(RAS_MeshSlot *target);
+#ifdef USE_SPLIT
bool IsCulled();
+#else
+ bool IsCulled() { return m_bCulled; }
+#endif
void SetCulled(bool culled) { m_bCulled = culled; }
};
@@ -168,7 +178,6 @@ class RAS_MeshMaterial
public:
RAS_MeshSlot *m_baseslot;
class RAS_MaterialBucket *m_bucket;
-
GEN_Map<GEN_HashedPtr,RAS_MeshSlot*> m_slots;
};
@@ -205,10 +214,23 @@ public:
class RAS_MeshSlot* CopyMesh(class RAS_MeshSlot *ms);
void RemoveMesh(class RAS_MeshSlot* ms);
void Optimize(MT_Scalar distance);
+ void ActivateMesh(RAS_MeshSlot* slot)
+ {
+ m_activeMeshSlotsHead.AddBack(slot);
+ }
+ SG_DList& GetActiveMeshSlots()
+ {
+ return m_activeMeshSlotsHead;
+ }
+ RAS_MeshSlot* GetNextActiveMeshSlot()
+ {
+ return (RAS_MeshSlot*)m_activeMeshSlotsHead.Remove();
+ }
private:
- list<RAS_MeshSlot> m_meshSlots;
+ list<RAS_MeshSlot> m_meshSlots; // all the mesh slots
RAS_IPolyMaterial* m_material;
+ SG_DList m_activeMeshSlotsHead; // only those which must be rendered
};
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
index 162f9a81335..1dfcb0c512d 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
@@ -91,7 +91,7 @@ struct RAS_MeshObject::fronttoback
STR_String RAS_MeshObject::s_emptyname = "";
RAS_MeshObject::RAS_MeshObject(Mesh* mesh, int lightlayer)
- : m_lightlayer(lightlayer),
+ : //m_lightlayer(lightlayer),
m_bModified(true),
m_bMeshModified(true),
m_mesh(mesh),
@@ -112,10 +112,10 @@ bool RAS_MeshObject::MeshModified()
return m_bMeshModified;
}
-unsigned int RAS_MeshObject::GetLightLayer()
-{
- return m_lightlayer;
-}
+//unsigned int RAS_MeshObject::GetLightLayer()
+//{
+// return m_lightlayer;
+//}
@@ -179,14 +179,14 @@ list<RAS_MeshMaterial>::iterator RAS_MeshObject::GetLastMaterial()
-void RAS_MeshObject::SetName(STR_String name)
+void RAS_MeshObject::SetName(const char *name)
{
m_name = name;
}
-const STR_String& RAS_MeshObject::GetName()
+STR_String& RAS_MeshObject::GetName()
{
return m_name;
}
@@ -215,6 +215,19 @@ RAS_MeshMaterial *RAS_MeshObject::GetMeshMaterial(RAS_IPolyMaterial *mat)
return NULL;
}
+int RAS_MeshObject::GetMaterialId(RAS_IPolyMaterial *mat)
+{
+ list<RAS_MeshMaterial>::iterator mit;
+ int imat;
+
+ /* find a mesh material */
+ for(imat=0, mit = m_materials.begin(); mit != m_materials.end(); mit++, imat++)
+ if(mit->m_bucket->GetPolyMaterial() == mat)
+ return imat;
+
+ return -1;
+}
+
RAS_Polygon* RAS_MeshObject::AddPolygon(RAS_MaterialBucket *bucket, int numverts)
{
RAS_MeshMaterial *mmat;
@@ -229,6 +242,7 @@ RAS_Polygon* RAS_MeshObject::AddPolygon(RAS_MaterialBucket *bucket, int numverts
RAS_MeshMaterial meshmat;
meshmat.m_bucket = bucket;
meshmat.m_baseslot = meshmat.m_bucket->AddMesh(numverts);
+ meshmat.m_baseslot->m_mesh = this;
m_materials.push_back(meshmat);
mmat = &m_materials.back();
}
@@ -291,7 +305,7 @@ void RAS_MeshObject::AddVertex(RAS_Polygon *poly, int i,
slot = mmat->m_baseslot;
darray = slot->CurrentDisplayArray();
- if(!flat) {
+ { /* Shared Vertex! */
/* find vertices shared between faces, with the restriction
* that they exist in the same display array, and have the
* same uv coordinate etc */
@@ -319,7 +333,7 @@ void RAS_MeshObject::AddVertex(RAS_Polygon *poly, int i,
slot->AddPolygonVertex(offset);
poly->SetVertexOffset(i, offset);
- if(!flat) {
+ { /* Shared Vertex! */
SharedVertex shared;
shared.m_darray = darray;
shared.m_offset = offset;
@@ -368,16 +382,41 @@ RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid,
return NULL;
}
-void RAS_MeshObject::AddMeshUser(void *clientobj)
+void RAS_MeshObject::AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer)
{
list<RAS_MeshMaterial>::iterator it;
+ list<RAS_MeshMaterial>::iterator mit;
for(it = m_materials.begin();it!=m_materials.end();++it) {
/* always copy from the base slot, which is never removed
* since new objects can be created with the same mesh data */
+ if (deformer && !deformer->UseVertexArray())
+ {
+ // HACK!
+ // this deformer doesn't use vertex array => derive mesh
+ // we must keep only the mesh slots that have unique material id
+ // this is to match the derived mesh drawing function
+ // Need a better solution in the future: scan the derive mesh and create vertex array
+ RAS_IPolyMaterial* curmat = it->m_bucket->GetPolyMaterial();
+ if (curmat->GetFlag() & RAS_BLENDERGLSL)
+ {
+ for(mit = m_materials.begin(); mit != it; ++mit)
+ {
+ RAS_IPolyMaterial* mat = mit->m_bucket->GetPolyMaterial();
+ if ((mat->GetFlag() & RAS_BLENDERGLSL) &&
+ mat->GetMaterialIndex() == curmat->GetMaterialIndex())
+ // no need to convert current mesh slot
+ break;
+ }
+ if (mit != it)
+ continue;
+ }
+ }
RAS_MeshSlot *ms = it->m_bucket->CopyMesh(it->m_baseslot);
ms->m_clientObj = clientobj;
+ ms->SetDeformer(deformer);
it->m_slots.insert(clientobj, ms);
+ head->QAddBack(ms);
}
}
@@ -389,7 +428,7 @@ void RAS_MeshObject::UpdateBuckets(void* clientobj,
bool culled)
{
list<RAS_MeshMaterial>::iterator it;
-
+
for(it = m_materials.begin();it!=m_materials.end();++it) {
RAS_MeshSlot **msp = it->m_slots[clientobj];
@@ -404,6 +443,8 @@ void RAS_MeshObject::UpdateBuckets(void* clientobj,
ms->m_RGBAcolor = rgbavec;
ms->m_bVisible = visible;
ms->m_bCulled = culled || !visible;
+ if (!ms->m_bCulled)
+ ms->m_bucket->ActivateMesh(ms);
/* split if necessary */
#ifdef USE_SPLIT
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h
index 404b7f16a59..e763d6e7c7f 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.h
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.h
@@ -45,6 +45,7 @@
#include "GEN_HashedPtr.h"
struct Mesh;
+class RAS_Deformer;
/* RAS_MeshObject is a mesh used for rendering. It stores polygons,
* but the actual vertices and index arrays are stored in material
@@ -54,7 +55,7 @@ class RAS_MeshObject
{
private:
unsigned int m_debugcolor;
- int m_lightlayer;
+ //int m_lightlayer;
bool m_bModified;
bool m_bMeshModified;
@@ -89,15 +90,16 @@ public:
RAS_MeshMaterial* GetMeshMaterial(unsigned int matid);
RAS_MeshMaterial* GetMeshMaterial(RAS_IPolyMaterial *mat);
+ int GetMaterialId(RAS_IPolyMaterial *mat);
list<RAS_MeshMaterial>::iterator GetFirstMaterial();
list<RAS_MeshMaterial>::iterator GetLastMaterial();
- unsigned int GetLightLayer();
+ //unsigned int GetLightLayer();
/* name */
- void SetName(STR_String name);
- const STR_String& GetName();
+ void SetName(const char *name);
+ STR_String& GetName();
/* modification state */
bool MeshModified();
@@ -129,7 +131,7 @@ public:
RAS_Polygon* GetPolygon(int num) const;
/* buckets */
- virtual void AddMeshUser(void *clientobj);
+ virtual void AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer);
virtual void UpdateBuckets(
void* clientobj,
double* oglmatrix,
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
index e4403ace69f..fe3d0f6aeea 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
@@ -31,8 +31,14 @@ SET(INC
../../../../intern/string
../../../../intern/moto/include
../../../../source/gameengine/Rasterizer
+ ../../../../source/gameengine/Ketsji
+ ../../../../source/gameengine/SceneGraph
../../../../extern/glew/include
../../../../source/blender/gpu
+ ../../../../source/blender/makesdna
+ ../../../../source/blender/blenkernel
+ ../../../../source/blender/blenlib
+ ../../../../source/blender/blenloader
)
BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}")
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile
index aee485a22be..0327714dc5f 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile
@@ -42,8 +42,14 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../../kernel/gen_system
CPPFLAGS += -I../../../blender/gpu
+CPPFLAGS += -I../../../blender/makesdna
+CPPFLAGS += -I../../../blender/blenlib
+CPPFLAGS += -I../../../blender/blenkernel
CPPFLAGS += -I../../BlenderRoutines
+CPPFLAGS += -I../../Ketsji
+CPPFLAGS += -I../../SceneGraph
CPPFLAGS += -I..
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
ifeq ($(OS),darwin)
CPPFLAGS += -fpascal-strings
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
index 65aadd63a40..014169f8838 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
@@ -104,9 +104,11 @@ bool RAS_ListSlot::End()
RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays, bool lock)
: RAS_VAOpenGLRasterizer(canvas, lock),
- mUseVertexArrays(useVertexArrays)
+ mUseVertexArrays(useVertexArrays),
+ mATI(false)
{
- // --
+ if (!strcmp((const char*)glGetString(GL_VENDOR), "ATI Technologies Inc."))
+ mATI = true;
}
RAS_ListRasterizer::~RAS_ListRasterizer()
@@ -116,13 +118,24 @@ RAS_ListRasterizer::~RAS_ListRasterizer()
void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list)
{
- RAS_Lists::iterator it = mLists.begin();
- while(it != mLists.end()) {
- if (it->second == list) {
- mLists.erase(it);
- break;
+ if (list->m_flag & LIST_DERIVEDMESH) {
+ RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();
+ while(it != mDerivedMeshLists.end()) {
+ if (it->second == list) {
+ mDerivedMeshLists.erase(it);
+ break;
+ }
+ it++;
+ }
+ } else {
+ RAS_ArrayLists::iterator it = mArrayLists.begin();
+ while(it != mArrayLists.end()) {
+ if (it->second == list) {
+ mArrayLists.erase(it);
+ break;
+ }
+ it++;
}
- it++;
}
}
@@ -136,12 +149,25 @@ RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
*/
RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList;
if(!localSlot) {
- RAS_Lists::iterator it = mLists.find(ms.m_displayArrays);
- if(it == mLists.end()) {
- localSlot = new RAS_ListSlot(this);
- mLists.insert(std::pair<RAS_DisplayArrayList, RAS_ListSlot*>(ms.m_displayArrays, localSlot));
+ if (ms.m_pDerivedMesh) {
+ // that means that we draw based on derived mesh, a display list is possible
+ // Note that we come here only for static derived mesh
+ RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.find(ms.m_pDerivedMesh);
+ if(it == mDerivedMeshLists.end()) {
+ localSlot = new RAS_ListSlot(this);
+ localSlot->m_flag |= LIST_DERIVEDMESH;
+ mDerivedMeshLists.insert(std::pair<DerivedMesh*, RAS_ListSlot*>(ms.m_pDerivedMesh, localSlot));
+ } else {
+ localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
+ }
} else {
- localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
+ RAS_ArrayLists::iterator it = mArrayLists.find(ms.m_displayArrays);
+ if(it == mArrayLists.end()) {
+ localSlot = new RAS_ListSlot(this);
+ mArrayLists.insert(std::pair<RAS_DisplayArrayList, RAS_ListSlot*>(ms.m_displayArrays, localSlot));
+ } else {
+ localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
+ }
}
}
MT_assert(localSlot);
@@ -150,12 +176,12 @@ RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
void RAS_ListRasterizer::ReleaseAlloc()
{
- RAS_Lists::iterator it = mLists.begin();
- while(it != mLists.end()) {
+ for(RAS_ArrayLists::iterator it = mArrayLists.begin();it != mArrayLists.end();++it)
delete it->second;
- it++;
- }
- mLists.clear();
+ mArrayLists.clear();
+ for (RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();it != mDerivedMeshLists.end();++it)
+ delete it->second;
+ mDerivedMeshLists.clear();
}
void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
@@ -172,8 +198,8 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
return;
}
}
-
- if (mUseVertexArrays)
+ // derived mesh cannot use vertex array
+ if (mUseVertexArrays && !ms.m_pDerivedMesh)
RAS_VAOpenGLRasterizer::IndexPrimitives(ms);
else
RAS_OpenGLRasterizer::IndexPrimitives(ms);
@@ -204,7 +230,7 @@ void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
// workaround: note how we do not use vertex arrays for making display
// lists, since glVertexAttribPointerARB doesn't seem to work correct
// in display lists on ATI? either a bug in the driver or in Blender ..
- if (mUseVertexArrays && !localSlot)
+ if (mUseVertexArrays && !mATI && !ms.m_pDerivedMesh)
RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(ms);
else
RAS_OpenGLRasterizer::IndexPrimitivesMulti(ms);
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
index 653bb43e534..fe358808e4a 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
@@ -9,6 +9,7 @@
class RAS_ListRasterizer;
class RAS_ListSlot : public KX_ListSlot
{
+ friend class RAS_ListRasterizer;
unsigned int m_list;
unsigned int m_flag;
RAS_ListRasterizer* m_rasty;
@@ -32,15 +33,21 @@ enum RAS_ListSlotFlags {
LIST_NOCREATE =8,
LIST_BEGIN =16,
LIST_END =32,
- LIST_REGEN =64
+ LIST_REGEN =64,
+ LIST_DERIVEDMESH=128,
};
-typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_Lists;
+struct DerivedMesh;
+
+typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_ArrayLists;
+typedef std::map<DerivedMesh*, RAS_ListSlot*> RAS_DerivedMeshLists;
class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer
{
bool mUseVertexArrays;
- RAS_Lists mLists;
+ bool mATI;
+ RAS_ArrayLists mArrayLists;
+ RAS_DerivedMeshLists mDerivedMeshLists;
RAS_ListSlot* FindOrAdd(class RAS_MeshSlot& ms);
void ReleaseAlloc();
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 1a9a28916de..83ba2778ad6 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -35,11 +35,20 @@
#include "RAS_Rect.h"
#include "RAS_TexVert.h"
+#include "RAS_MeshObject.h"
#include "MT_CmMatrix4x4.h"
#include "RAS_IRenderTools.h" // rendering text
#include "GPU_draw.h"
#include "GPU_material.h"
+#include "GPU_extensions.h"
+
+#include "DNA_image_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_material_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_DerivedMesh.h"
/**
* 32x32 bit masks for vinterlace stereo mode
@@ -72,7 +81,7 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas)
m_motionblurvalue(-1.0),
m_texco_num(0),
m_attrib_num(0),
- m_last_blendmode(GPU_BLEND_SOLID),
+ //m_last_blendmode(GPU_BLEND_SOLID),
m_last_frontface(true),
m_materialCachingInfo(0)
{
@@ -109,7 +118,8 @@ bool RAS_OpenGLRasterizer::Init()
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
- m_last_blendmode = GPU_BLEND_SOLID;
+ //m_last_blendmode = GPU_BLEND_SOLID;
+ GPU_set_material_blend_mode(GPU_BLEND_SOLID);
glFrontFace(GL_CCW);
m_last_frontface = true;
@@ -201,6 +211,10 @@ void RAS_OpenGLRasterizer::DisableFog()
m_fogenabled = false;
}
+bool RAS_OpenGLRasterizer::IsFogEnabled()
+{
+ return m_fogenabled;
+}
void RAS_OpenGLRasterizer::DisplayFog()
@@ -275,7 +289,8 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time)
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
- m_last_blendmode = GPU_BLEND_SOLID;
+ //m_last_blendmode = GPU_BLEND_SOLID;
+ GPU_set_material_blend_mode(GPU_BLEND_SOLID);
glFrontFace(GL_CCW);
m_last_frontface = true;
@@ -703,6 +718,51 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
IndexPrimitivesInternal(ms, true);
}
+static bool current_wireframe;
+static RAS_MaterialBucket *current_bucket;
+static RAS_IPolyMaterial *current_polymat;
+static RAS_MeshSlot *current_ms;
+static RAS_MeshObject *current_mesh;
+static int current_blmat_nr;
+static GPUVertexAttribs current_gpu_attribs;
+static int CheckMaterialDM(int matnr, void *attribs)
+{
+ // only draw the current material
+ if (matnr != current_blmat_nr)
+ return 0;
+ GPUVertexAttribs *gattribs = (GPUVertexAttribs *)attribs;
+ if (gattribs)
+ memcpy(gattribs, &current_gpu_attribs, sizeof(GPUVertexAttribs));
+ return 1;
+}
+static int CheckTexfaceDM(void *mcol, int index)
+{
+
+ // index is the original face index, retrieve the polygon
+ RAS_Polygon* polygon = (index >= 0 && index < current_mesh->NumPolygons()) ?
+ current_mesh->GetPolygon(index) : NULL;
+ if (polygon && polygon->GetMaterial() == current_bucket) {
+ // must handle color.
+ if (current_wireframe)
+ return 2;
+ if (current_ms->m_bObjectColor) {
+ MT_Vector4& rgba = current_ms->m_RGBAcolor;
+ glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
+ // don't use mcol
+ return 2;
+ }
+ if (!mcol) {
+ // we have to set the color from the material
+ unsigned char rgba[4];
+ current_polymat->GetMaterialRGBAColor(rgba);
+ glColor4ubv((const GLubyte *)rgba);
+ return 2;
+ }
+ return 1;
+ }
+ return 0;
+}
+
void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{
bool obcolor = ms.m_bObjectColor;
@@ -710,6 +770,34 @@ void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
MT_Vector4& rgba = ms.m_RGBAcolor;
RAS_MeshSlot::iterator it;
+ if (ms.m_pDerivedMesh) {
+ // mesh data is in derived mesh,
+ current_bucket = ms.m_bucket;
+ current_polymat = current_bucket->GetPolyMaterial();
+ current_ms = &ms;
+ current_mesh = ms.m_mesh;
+ current_wireframe = wireframe;
+ MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL);
+ if (current_polymat->GetFlag() & RAS_BLENDERGLSL) {
+ // GetMaterialIndex return the original mface material index,
+ // increment by 1 to match what derived mesh is doing
+ current_blmat_nr = current_polymat->GetMaterialIndex()+1;
+ // For GLSL we need to retrieve the GPU material attribute
+ Material* blmat = current_polymat->GetBlenderMaterial();
+ Scene* blscene = current_polymat->GetBlenderScene();
+ if (!wireframe && blscene && blmat)
+ GPU_material_vertex_attributes(GPU_material_from_blender(blscene, blmat), &current_gpu_attribs);
+ else
+ memset(&current_gpu_attribs, 0, sizeof(current_gpu_attribs));
+ // DM draw can mess up blending mode, restore at the end
+ int current_blend_mode = GPU_get_material_blend_mode();
+ ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM);
+ GPU_set_material_blend_mode(current_blend_mode);
+ } else {
+ ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol);
+ }
+ return;
+ }
// iterate over display arrays, each containing an index + vertex array
for(ms.begin(it); !ms.end(it); ms.next(it)) {
RAS_TexVert *vertex;
@@ -838,17 +926,40 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
return result;
}
+MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
+ float left,
+ float right,
+ float bottom,
+ float top,
+ float frustnear,
+ float frustfar
+){
+ MT_Matrix4x4 result;
+ double mat[16];
+
+ // stereo is meaning less for orthographic, disable it
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(left, right, bottom, top, frustnear, frustfar);
+
+ glGetDoublev(GL_PROJECTION_MATRIX, mat);
+ result.setValue(mat);
+
+ return result;
+}
+
// next arguments probably contain redundant info, for later...
-void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vector3& campos,
- const MT_Point3 &, const MT_Quaternion &camOrientQuat)
+void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
+ const MT_Matrix3x3 & camOrientMat3x3,
+ const MT_Point3 & pos,
+ bool perspective)
{
m_viewmatrix = mat;
// correction for stereo
- if(Stereo())
+ if(Stereo() && perspective)
{
- MT_Matrix3x3 camOrientMat3x3(camOrientQuat);
MT_Vector3 unitViewDir(0.0, -1.0, 0.0); // minus y direction, Blender convention
MT_Vector3 unitViewupVec(0.0, 0.0, 1.0);
MT_Vector3 viewDir, viewupVec;
@@ -894,7 +1005,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vecto
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(glviewmat);
- m_campos = campos;
+ m_campos = pos;
}
@@ -990,6 +1101,8 @@ void RAS_OpenGLRasterizer::DisableMotionBlur()
void RAS_OpenGLRasterizer::SetBlendingMode(int blendmode)
{
+ GPU_set_material_blend_mode(blendmode);
+/*
if(blendmode == m_last_blendmode)
return;
@@ -1016,6 +1129,7 @@ void RAS_OpenGLRasterizer::SetBlendingMode(int blendmode)
}
m_last_blendmode = blendmode;
+*/
}
void RAS_OpenGLRasterizer::SetFrontFace(bool ccw)
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
index 83a9f759a8b..e3422394e9e 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
@@ -100,7 +100,7 @@ protected:
TexCoGen m_attrib[RAS_MAX_ATTRIB];
int m_texco_num;
int m_attrib_num;
- int m_last_blendmode;
+ //int m_last_blendmode;
bool m_last_frontface;
/** Stores the caching information for the last material activated. */
@@ -163,9 +163,9 @@ public:
virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat);
virtual void SetViewMatrix(
const MT_Matrix4x4 & mat,
- const MT_Vector3& campos,
- const MT_Point3 &camLoc,
- const MT_Quaternion &camOrientQuat
+ const MT_Matrix3x3 & ori,
+ const MT_Point3 & pos,
+ bool perspective
);
virtual const MT_Point3& GetCameraPosition();
@@ -190,6 +190,7 @@ public:
void DisableFog();
virtual void DisplayFog();
+ virtual bool IsFogEnabled();
virtual void SetBackColor(
float red,
@@ -215,6 +216,15 @@ public:
bool perspective
);
+ virtual MT_Matrix4x4 GetOrthoMatrix(
+ float left,
+ float right,
+ float bottom,
+ float top,
+ float frustnear,
+ float frustfar
+ );
+
virtual void SetSpecularity(
float specX,
float specY,
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
index 2cb3b52adfb..00f0f27b6c1 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
@@ -110,6 +110,12 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
RAS_MeshSlot::iterator it;
GLenum drawmode;
+ if (ms.m_pDerivedMesh) {
+ // cannot be handled here, pass to RAS_OpenGLRasterizer
+ RAS_OpenGLRasterizer::IndexPrimitivesInternal(ms, false);
+ return;
+ }
+
if(!wireframe)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -167,6 +173,12 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
RAS_MeshSlot::iterator it;
GLenum drawmode;
+ if (ms.m_pDerivedMesh) {
+ // cannot be handled here, pass to RAS_OpenGLRasterizer
+ RAS_OpenGLRasterizer::IndexPrimitivesInternal(ms, true);
+ return;
+ }
+
if(!wireframe)
EnableTextures(true);
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
index c0b73e7644f..3d605ce12b8 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
@@ -5,6 +5,8 @@ sources = env.Glob('*.cpp')
incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines '
incs += ' #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC']
+incs += ' #source/blender/gameengine/Ketsji #source/gameengine/SceneGraph #source/blender/makesdna #source/blender/blenkernel'
+incs += ' #intern/guardedalloc #source/blender/blenlib'
cxxflags = []
if env['OURPLATFORM']=='win32-vc':
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp
index 210addfb927..8eee24ac7f0 100644
--- a/source/gameengine/Rasterizer/RAS_TexVert.cpp
+++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp
@@ -113,19 +113,20 @@ void RAS_TexVert::SetTangent(const MT_Vector3& tangent)
tangent.getValue(m_tangent);
}
+
// compare two vertices, and return TRUE if both are almost identical (they can be shared)
-#define _VEC_EQUAL3(_v1, _v2) (_v1[0]==_v2[0] && _v1[1]==_v2[1] && _v1[2]==_v2[2])
-#define _VEC_EQUAL2(_v1, _v2) (_v1[0]==_v2[0] && _v1[1]==_v2[1])
bool RAS_TexVert::closeTo(const RAS_TexVert* other)
{
- return (m_flag == other->m_flag &&
+ return (
+ /* m_flag == other->m_flag && */
+ /* at the moment the face only stores the smooth/flat setting so dont bother comparing it */
m_rgba == other->m_rgba &&
- _VEC_EQUAL3(m_normal, other->m_normal) &&
- _VEC_EQUAL3(m_tangent, other->m_tangent) &&
- _VEC_EQUAL2(m_uv1, other->m_uv1) &&
- _VEC_EQUAL2(m_uv2, other->m_uv2) // p --
- /* we know the verts must be shared so dont need to check this */
- /*&& FAST_MT_fuzzyEqual3(m_localxyz, other->m_localxyz)*/) ;
+ MT_fuzzyEqual(MT_Vector3(m_normal), MT_Vector3(other->m_normal)) &&
+ MT_fuzzyEqual(MT_Vector3(m_tangent), MT_Vector3(other->m_tangent)) &&
+ MT_fuzzyEqual(MT_Vector2(m_uv1), MT_Vector2(other->m_uv1)) &&
+ MT_fuzzyEqual(MT_Vector2(m_uv2), MT_Vector2(other->m_uv2)) /* &&
+ MT_fuzzyEqual(MT_Vector3(m_localxyz), MT_Vector3(other->m_localxyz))*/) ;
+ /* dont bother comparing m_localxyz since we know there from the same vert */
}
short RAS_TexVert::getFlag() const
diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript
index 9f4cd61e7bb..018f2ab4d20 100644
--- a/source/gameengine/Rasterizer/SConscript
+++ b/source/gameengine/Rasterizer/SConscript
@@ -4,7 +4,7 @@ Import ('env')
sources = env.Glob('*.cpp')
-incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/blender/blenkernel #source/blender/makesdna'
+incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/gameengine/SceneGraph #source/blender/blenkernel #source/blender/makesdna'
incs += ' ' + env['BF_PYTHON_INC']
cxxflags = []
diff --git a/source/gameengine/SceneGraph/SG_DList.h b/source/gameengine/SceneGraph/SG_DList.h
new file mode 100644
index 00000000000..7bef13cc9e3
--- /dev/null
+++ b/source/gameengine/SceneGraph/SG_DList.h
@@ -0,0 +1,161 @@
+/**
+ * $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 __SG_DLIST
+#define __SG_DLIST
+
+#include <stdlib.h>
+
+/**
+ * Double circular linked list
+ */
+class SG_DList
+{
+protected :
+ SG_DList* m_flink;
+ SG_DList* m_blink;
+
+public:
+ template<typename T> class iterator
+ {
+ private:
+ SG_DList& m_head;
+ T* m_current;
+ public:
+ typedef iterator<T> _myT;
+ iterator(SG_DList& head) : m_head(head), m_current(NULL) {}
+ ~iterator() {}
+
+ void begin()
+ {
+ m_current = (T*)m_head.Peek();
+ }
+ void back()
+ {
+ m_current = (T*)m_head.Back();
+ }
+ bool end()
+ {
+ return (m_current == (T*)m_head.Self());
+ }
+ bool add_back(T* item)
+ {
+ return m_current->AddBack(item);
+ }
+ T* operator*()
+ {
+ return m_current;
+ }
+ _myT& operator++()
+ {
+ // no check of NULL! make sure you don't try to increment beyond end
+ m_current = (T*)m_current->Peek();
+ return *this;
+ }
+ _myT& operator--()
+ {
+ // no check of NULL! make sure you don't try to increment beyond end
+ m_current = (T*)m_current->Back();
+ return *this;
+ }
+ };
+
+ SG_DList()
+ {
+ m_flink = m_blink = this;
+ }
+ SG_DList(const SG_DList& other)
+ {
+ m_flink = m_blink = this;
+ }
+ virtual ~SG_DList()
+ {
+ Delink();
+ }
+
+ inline bool Empty() // Check for empty queue
+ {
+ return ( m_flink == this );
+ }
+ bool AddBack( SG_DList *item ) // Add to the back
+ {
+ if (!item->Empty())
+ return false;
+ item->m_blink = m_blink;
+ item->m_flink = this;
+ m_blink->m_flink = item;
+ m_blink = item;
+ return true;
+ }
+ bool AddFront( SG_DList *item ) // Add to the back
+ {
+ if (!item->Empty())
+ return false;
+ item->m_flink = m_flink;
+ item->m_blink = this;
+ m_flink->m_blink = item;
+ m_flink = item;
+ return true;
+ }
+ SG_DList *Remove() // Remove from the front
+ {
+ if (Empty())
+ {
+ return NULL;
+ }
+ SG_DList* item = m_flink;
+ m_flink = item->m_flink;
+ m_flink->m_blink = this;
+ item->m_flink = item->m_blink = item;
+ return item;
+ }
+ bool Delink() // Remove from the middle
+ {
+ if (Empty())
+ return false;
+ m_blink->m_flink = m_flink;
+ m_flink->m_blink = m_blink;
+ m_flink = m_blink = this;
+ return true;
+ }
+ inline SG_DList *Peek() // Look at front without removing
+ {
+ return m_flink;
+ }
+ inline SG_DList *Back() // Look at front without removing
+ {
+ return m_blink;
+ }
+ inline SG_DList *Self()
+ {
+ return this;
+ }
+};
+
+#endif //__SG_DLIST
+
diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp
index fbab4032a10..5795ca57113 100644
--- a/source/gameengine/SceneGraph/SG_IObject.cpp
+++ b/source/gameengine/SceneGraph/SG_IObject.cpp
@@ -39,19 +39,20 @@ SG_IObject::
SG_IObject(
void* clientobj,
void* clientinfo,
- SG_Callbacks callbacks
+ SG_Callbacks& callbacks
):
+ SG_QList(),
m_SGclientObject(clientobj),
- m_SGclientInfo(clientinfo),
- m_callbacks(callbacks)
+ m_SGclientInfo(clientinfo)
{
- //nothing to do
+ m_callbacks = callbacks;
}
SG_IObject::
SG_IObject(
const SG_IObject &other
) :
+ SG_QList(),
m_SGclientObject(other.m_SGclientObject),
m_SGclientInfo(other.m_SGclientInfo),
m_callbacks(other.m_callbacks)
@@ -74,92 +75,17 @@ RemoveAllControllers(
m_SGcontrollers.clear();
}
-/// Needed for replication
- SGControllerList&
-SG_IObject::
-GetSGControllerList(
-){
- return m_SGcontrollers;
-}
-
- void*
-SG_IObject::
-GetSGClientObject(
-){
- return m_SGclientObject;
-}
-
-const
- void*
-SG_IObject::
-GetSGClientObject(
-) const {
- return m_SGclientObject;
-}
-
- void
-SG_IObject::
-SetSGClientObject(
- void* clientObject
-){
- m_SGclientObject = clientObject;
-}
-
-
- bool
-SG_IObject::
-ActivateReplicationCallback(
- SG_IObject *replica
-){
- if (m_callbacks.m_replicafunc)
- {
- // Call client provided replication func
- if (m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo) == NULL)
- return false;
- }
- return true;
-};
-
- void
-SG_IObject::
-ActivateDestructionCallback(
-){
- if (m_callbacks.m_destructionfunc)
- {
- // Call client provided destruction function on this!
- m_callbacks.m_destructionfunc(this,m_SGclientObject,m_SGclientInfo);
- }
- else
- {
- // no callback but must still destroy the node to avoid memory leak
- delete this;
- }
-}
-
- void
-SG_IObject::
-ActivateUpdateTransformCallback(
-){
- if (m_callbacks.m_updatefunc)
- {
- // Call client provided update func.
- m_callbacks.m_updatefunc(this, m_SGclientObject, m_SGclientInfo);
- }
-}
-
- void
-SG_IObject::
-SetControllerTime(
- double time
-){
+void SG_IObject::SetControllerTime(double time)
+{
SGControllerList::iterator contit;
-
for (contit = m_SGcontrollers.begin();contit!=m_SGcontrollers.end();++contit)
{
(*contit)->SetSimulatedTime(time);
}
}
+/// Needed for replication
+
SG_IObject::
~SG_IObject()
diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h
index 9012b532059..8f448a0e890 100644
--- a/source/gameengine/SceneGraph/SG_IObject.h
+++ b/source/gameengine/SceneGraph/SG_IObject.h
@@ -29,6 +29,7 @@
#ifndef __SG_IOBJECT
#define __SG_IOBJECT
+#include "SG_QList.h"
#include <vector>
// used for debugging: stage of the game engine main loop at which a Scenegraph modification is done
@@ -84,6 +85,18 @@ typedef void (*SG_UpdateTransformCallback)(
void* clientinfo
);
+typedef bool (*SG_ScheduleUpdateCallback)(
+ SG_IObject* sgobject,
+ void* clientobj,
+ void* clientinfo
+);
+
+typedef bool (*SG_RescheduleUpdateCallback)(
+ SG_IObject* sgobject,
+ void* clientobj,
+ void* clientinfo
+);
+
/**
* SG_Callbacks hold 2 call backs to the outside world.
@@ -106,30 +119,38 @@ struct SG_Callbacks
):
m_replicafunc(NULL),
m_destructionfunc(NULL),
- m_updatefunc(NULL)
+ m_updatefunc(NULL),
+ m_schedulefunc(NULL),
+ m_reschedulefunc(NULL)
{
};
SG_Callbacks(
SG_ReplicationNewCallback repfunc,
SG_DestructionNewCallback destructfunc,
- SG_UpdateTransformCallback updatefunc
+ SG_UpdateTransformCallback updatefunc,
+ SG_ScheduleUpdateCallback schedulefunc,
+ SG_RescheduleUpdateCallback reschedulefunc
):
m_replicafunc(repfunc),
m_destructionfunc(destructfunc),
- m_updatefunc(updatefunc)
+ m_updatefunc(updatefunc),
+ m_schedulefunc(schedulefunc),
+ m_reschedulefunc(reschedulefunc)
{
};
SG_ReplicationNewCallback m_replicafunc;
SG_DestructionNewCallback m_destructionfunc;
SG_UpdateTransformCallback m_updatefunc;
+ SG_ScheduleUpdateCallback m_schedulefunc;
+ SG_RescheduleUpdateCallback m_reschedulefunc;
};
/**
base object that can be part of the scenegraph.
*/
-class SG_IObject
+class SG_IObject : public SG_QList
{
private :
@@ -177,10 +198,18 @@ public:
* using STL?
*/
- SGControllerList&
- GetSGControllerList(
- );
+ SGControllerList& GetSGControllerList()
+ {
+ return m_SGcontrollers;
+ }
+ /**
+ *
+ */
+ SG_Callbacks& GetCallBackFunctions()
+ {
+ return m_callbacks;
+ }
/**
* Get the client object associated with this
@@ -192,16 +221,16 @@ public:
* This may be NULL.
*/
- void*
- GetSGClientObject(
- );
+ inline const void* GetSGClientObject() const
+ {
+ return m_SGclientObject;
+ }
- const
- void*
- GetSGClientObject(
- ) const ;
+ inline void* GetSGClientObject()
+ {
+ return m_SGclientObject;
+ }
-
/**
* Set the client object for this node. This is just a
* pointer to an object allocated that should exist for
@@ -209,10 +238,10 @@ public:
* this function is called again.
*/
- void
- SetSGClientObject(
- void* clientObject
- );
+ void SetSGClientObject(void* clientObject)
+ {
+ m_SGclientObject = clientObject;
+ }
/**
* Set the current simulation time for this node.
@@ -220,10 +249,7 @@ public:
* the nodes list of controllers and calls their SetSimulatedTime methods
*/
- void
- SetControllerTime(
- double time
- );
+ void SetControllerTime(double time);
virtual
void
@@ -235,20 +261,76 @@ protected :
bool
ActivateReplicationCallback(
SG_IObject *replica
- );
+ )
+ {
+ if (m_callbacks.m_replicafunc)
+ {
+ // Call client provided replication func
+ if (m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo) == NULL)
+ return false;
+ }
+ return true;
+ }
+
void
ActivateDestructionCallback(
- );
+ )
+ {
+ if (m_callbacks.m_destructionfunc)
+ {
+ // Call client provided destruction function on this!
+ m_callbacks.m_destructionfunc(this,m_SGclientObject,m_SGclientInfo);
+ }
+ else
+ {
+ // no callback but must still destroy the node to avoid memory leak
+ delete this;
+ }
+ }
void
ActivateUpdateTransformCallback(
- );
+ )
+ {
+ if (m_callbacks.m_updatefunc)
+ {
+ // Call client provided update func.
+ m_callbacks.m_updatefunc(this, m_SGclientObject, m_SGclientInfo);
+ }
+ }
+
+ bool
+ ActivateScheduleUpdateCallback(
+ )
+ {
+ // HACK, this check assumes that the scheduled nodes are put on a DList (see SG_Node.h)
+ // The early check on Empty() allows up to avoid calling the callback function
+ // when the node is already scheduled for update.
+ if (Empty() && m_callbacks.m_schedulefunc)
+ {
+ // Call client provided update func.
+ return m_callbacks.m_schedulefunc(this, m_SGclientObject, m_SGclientInfo);
+ }
+ return false;
+ }
+
+ void
+ ActivateRecheduleUpdateCallback(
+ )
+ {
+ if (m_callbacks.m_reschedulefunc)
+ {
+ // Call client provided update func.
+ m_callbacks.m_reschedulefunc(this, m_SGclientObject, m_SGclientInfo);
+ }
+ }
+
SG_IObject(
void* clientobj,
void* clientinfo,
- SG_Callbacks callbacks
+ SG_Callbacks& callbacks
);
SG_IObject(
diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp
index 64d9019c86a..4cd43e852b8 100644
--- a/source/gameengine/SceneGraph/SG_Node.cpp
+++ b/source/gameengine/SceneGraph/SG_Node.cpp
@@ -40,12 +40,13 @@ using namespace std;
SG_Node::SG_Node(
void* clientobj,
void* clientinfo,
- SG_Callbacks callbacks
+ SG_Callbacks& callbacks
)
: SG_Spatial(clientobj,clientinfo,callbacks),
m_SGparent(NULL)
{
+ m_modified = true;
}
SG_Node::SG_Node(
@@ -55,7 +56,7 @@ SG_Node::SG_Node(
m_children(other.m_children),
m_SGparent(other.m_SGparent)
{
- // nothing to do
+ m_modified = true;
}
SG_Node::~SG_Node()
@@ -141,22 +142,6 @@ Destruct()
ActivateDestructionCallback();
}
-
- SG_Node*
-SG_Node::
-GetSGParent(
-) const {
- return m_SGparent;
-}
-
- void
-SG_Node::
-SetSGParent(
- SG_Node* parent
-){
- m_SGparent = parent;
-}
-
const
SG_Node*
SG_Node::
@@ -165,28 +150,6 @@ GetRootSGParent(
return (m_SGparent ? (const SG_Node*) m_SGparent->GetRootSGParent() : (const SG_Node*) this);
}
- bool
-SG_Node::
-IsVertexParent()
-{
- if (m_parent_relation)
- {
- return m_parent_relation->IsVertexRelation();
- }
- return false;
-}
-
- bool
-SG_Node::
-IsSlowParent()
-{
- if (m_parent_relation)
- {
- return m_parent_relation->IsSlowRelation();
- }
- return false;
-}
-
void
SG_Node::
DisconnectFromParent(
@@ -199,8 +162,6 @@ DisconnectFromParent(
}
-
-
void SG_Node::AddChild(SG_Node* child)
{
m_children.push_back(child);
@@ -228,6 +189,9 @@ void SG_Node::UpdateWorldData(double time, bool parentUpdated)
// to update the
ActivateUpdateTransformCallback();
+ // The node is updated, remove it from the update list
+ Delink();
+
// update children's worlddata
for (NodeList::iterator it = m_children.begin();it!=m_children.end();++it)
{
@@ -236,24 +200,6 @@ void SG_Node::UpdateWorldData(double time, bool parentUpdated)
}
-NodeList& SG_Node::GetSGChildren()
-{
- return this->m_children;
-}
-
-
-const NodeList& SG_Node::GetSGChildren() const
-{
- return this->m_children;
-}
-
-
-void SG_Node::ClearSGChildren()
-{
- m_children.clear();
-}
-
-
void SG_Node::SetSimulatedTime(double time,bool recurse)
{
diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h
index 29943653a81..7c6ef92f670 100644
--- a/source/gameengine/SceneGraph/SG_Node.h
+++ b/source/gameengine/SceneGraph/SG_Node.h
@@ -44,7 +44,7 @@ public:
SG_Node(
void* clientobj,
void* clientinfo,
- SG_Callbacks callbacks
+ SG_Callbacks& callbacks
);
SG_Node(
@@ -85,45 +85,47 @@ public:
* @return a reference to the list of children of this node.
*/
- NodeList&
- GetSGChildren(
- );
+ NodeList& GetSGChildren()
+ {
+ return this->m_children;
+ }
/**
* Get the current list of children.
* @return a const reference to the current list of children of this node.
*/
- const
- NodeList&
- GetSGChildren(
- ) const;
+ const NodeList& GetSGChildren() const
+ {
+ return this->m_children;
+ }
/**
* Clear the list of children associated with this node
*/
- void
- ClearSGChildren(
- );
+ void ClearSGChildren()
+ {
+ m_children.clear();
+ }
/**
* return the parent of this node if it exists.
*/
- SG_Node*
- GetSGParent(
- ) const ;
-
+ SG_Node* GetSGParent() const
+ {
+ return m_SGparent;
+ }
/**
* Set the parent of this node.
*/
- void
- SetSGParent(
- SG_Node* parent
- );
+ void SetSGParent(SG_Node* parent)
+ {
+ m_SGparent = parent;
+ }
/**
* Return the top node in this node's Scene graph hierarchy
@@ -143,30 +145,33 @@ public:
);
/**
- * Tell this node to treat it's parent as a vertex parent.
- */
-
- void
- SetVertexParent(
- bool isvertexparent
- ) ;
-
-
- /**
* Return vertex parent status.
*/
+ bool IsVertexParent()
+ {
+ if (m_parent_relation)
+ {
+ return m_parent_relation->IsVertexRelation();
+ }
+ return false;
+ }
+
- bool
- IsVertexParent(
- ) ;
-
/**
* Return slow parent status.
*/
- bool
- IsSlowParent(
- ) ;
+ bool IsSlowParent()
+ {
+ if (m_parent_relation)
+ {
+ return m_parent_relation->IsSlowRelation();
+ }
+ return false;
+ }
+
+
+
/**
* Update the spatial data of this node. Iterate through
@@ -191,6 +196,42 @@ public:
);
/**
+ * Schedule this node for update by placing it in head queue
+ */
+ bool Schedule(SG_QList& head)
+ {
+ // Put top parent in front of list to make sure they are updated before their
+ // children => the children will be udpated and removed from the list before
+ // we get to them, should they be in the list too.
+ return (m_SGparent)?head.AddBack(this):head.AddFront(this);
+ }
+
+ /**
+ * Used during Scenegraph update
+ */
+ static SG_Node* GetNextScheduled(SG_QList& head)
+ {
+ return static_cast<SG_Node*>(head.Remove());
+ }
+
+ /**
+ * Make this node ready for schedule on next update. This is needed for nodes
+ * that must always be updated (slow parent, bone parent)
+ */
+ bool Reschedule(SG_QList& head)
+ {
+ return head.QAddBack(this);
+ }
+
+ /**
+ * Used during Scenegraph update
+ */
+ static SG_Node* GetNextRescheduled(SG_QList& head)
+ {
+ return static_cast<SG_Node*>(head.QRemove());
+ }
+
+ /**
* Node replication functions.
*/
diff --git a/source/gameengine/SceneGraph/SG_QList.h b/source/gameengine/SceneGraph/SG_QList.h
new file mode 100644
index 00000000000..d8afc33ea4f
--- /dev/null
+++ b/source/gameengine/SceneGraph/SG_QList.h
@@ -0,0 +1,157 @@
+/**
+ * $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 __SG_QLIST
+#define __SG_QLIST
+
+#include "SG_DList.h"
+
+/**
+ * Double-Double circular linked list
+ * For storing an object is two lists simultaneously
+ */
+class SG_QList : public SG_DList
+{
+protected :
+ SG_QList* m_fqlink;
+ SG_QList* m_bqlink;
+
+public:
+ template<typename T> class iterator
+ {
+ private:
+ SG_QList& m_head;
+ T* m_current;
+ public:
+ typedef iterator<T> _myT;
+ iterator(SG_QList& head, SG_QList* current=NULL) : m_head(head) { m_current = (T*)current; }
+ ~iterator() {}
+
+ void begin()
+ {
+ m_current = (T*)m_head.QPeek();
+ }
+ void back()
+ {
+ m_current = (T*)m_head.QBack();
+ }
+ bool end()
+ {
+ return (m_current == (T*)m_head.Self());
+ }
+ bool add_back(T* item)
+ {
+ return m_current->QAddBack(item);
+ }
+ T* operator*()
+ {
+ return m_current;
+ }
+ _myT& operator++()
+ {
+ m_current = (T*)m_current->QPeek();
+ return *this;
+ }
+ _myT& operator--()
+ {
+ // no check on NULL! make sure you don't try to increment beyond end
+ m_current = (T*)m_current->QBack();
+ return *this;
+ }
+ };
+
+ SG_QList() : SG_DList()
+ {
+ m_fqlink = m_bqlink = this;
+ }
+ SG_QList(const SG_QList& other) : SG_DList()
+ {
+ m_fqlink = m_bqlink = this;
+ }
+ virtual ~SG_QList()
+ {
+ QDelink();
+ }
+
+ inline bool QEmpty() // Check for empty queue
+ {
+ return ( m_fqlink == this );
+ }
+ bool QAddBack( SG_QList *item ) // Add to the back
+ {
+ if (!item->QEmpty())
+ return false;
+ item->m_bqlink = m_bqlink;
+ item->m_fqlink = this;
+ m_bqlink->m_fqlink = item;
+ m_bqlink = item;
+ return true;
+ }
+ bool QAddFront( SG_QList *item ) // Add to the back
+ {
+ if (!item->Empty())
+ return false;
+ item->m_fqlink = m_fqlink;
+ item->m_bqlink = this;
+ m_fqlink->m_bqlink = item;
+ m_fqlink = item;
+ return true;
+ }
+ SG_QList *QRemove() // Remove from the front
+ {
+ if (QEmpty())
+ {
+ return NULL;
+ }
+ SG_QList* item = m_fqlink;
+ m_fqlink = item->m_fqlink;
+ m_fqlink->m_bqlink = this;
+ item->m_fqlink = item->m_bqlink = item;
+ return item;
+ }
+ bool QDelink() // Remove from the middle
+ {
+ if (QEmpty())
+ return false;
+ m_bqlink->m_fqlink = m_fqlink;
+ m_fqlink->m_bqlink = m_bqlink;
+ m_fqlink = m_bqlink = this;
+ return true;
+ }
+ inline SG_QList *QPeek() // Look at front without removing
+ {
+ return m_fqlink;
+ }
+ inline SG_QList *QBack() // Look at front without removing
+ {
+ return m_bqlink;
+ }
+};
+
+#endif //__SG_QLIST
+
diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp
index 2f3176816c6..5a47f07f573 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.cpp
+++ b/source/gameengine/SceneGraph/SG_Spatial.cpp
@@ -40,7 +40,7 @@ SG_Spatial::
SG_Spatial(
void* clientobj,
void* clientinfo,
- SG_Callbacks callbacks
+ SG_Callbacks& callbacks
):
SG_IObject(clientobj,clientinfo,callbacks),
@@ -56,7 +56,8 @@ SG_Spatial(
m_bbox(MT_Point3(-1.0, -1.0, -1.0), MT_Point3(1.0, 1.0, 1.0)),
m_radius(1.0),
- m_modified(true)
+ m_modified(false),
+ m_ogldirty(false)
{
}
@@ -76,7 +77,9 @@ SG_Spatial(
m_parent_relation(NULL),
m_bbox(other.m_bbox),
- m_radius(other.m_radius)
+ m_radius(other.m_radius),
+ m_modified(false),
+ m_ogldirty(false)
{
// duplicate the parent relation for this object
m_parent_relation = other.m_parent_relation->NewCopy();
@@ -88,13 +91,6 @@ SG_Spatial::
delete (m_parent_relation);
}
- SG_ParentRelation *
-SG_Spatial::
-GetParentRelation(
-){
- return m_parent_relation;
-}
-
void
SG_Spatial::
SetParentRelation(
@@ -102,7 +98,7 @@ SetParentRelation(
){
delete (m_parent_relation);
m_parent_relation = relation;
- m_modified = true;
+ SetModified();
}
@@ -143,11 +139,6 @@ UpdateSpatialData(
return bComputesWorldTransform;
}
-bool SG_Spatial::ComputeWorldTransforms(const SG_Spatial *parent, bool& parentUpdated)
-{
- return m_parent_relation->UpdateChildCoordinates(this,parent,parentUpdated);
-}
-
/**
* Position and translation methods
*/
@@ -169,56 +160,14 @@ RelativeTranslate(
m_localPosition += trans;
}
}
- m_modified = true;
+ SetModified();
}
- void
-SG_Spatial::
-SetLocalPosition(
- const MT_Point3& trans
-){
- m_localPosition = trans;
- m_modified = true;
-}
-
- void
-SG_Spatial::
-SetWorldPosition(
- const MT_Point3& trans
-) {
- m_worldPosition = trans;
-}
/**
* Scaling methods.
*/
- void
-SG_Spatial::
-RelativeScale(
- const MT_Vector3& scale
-){
- m_localScaling = m_localScaling * scale;
- m_modified = true;
-}
-
- void
-SG_Spatial::
-SetLocalScale(
- const MT_Vector3& scale
-){
- m_localScaling = scale;
- m_modified = true;
-}
-
-
- void
-SG_Spatial::
-SetWorldScale(
- const MT_Vector3& scale
-){
- m_worldScaling = scale;
-}
/**
* Orientation and rotation methods.
@@ -236,93 +185,11 @@ RelativeRotate(
rot
:
(GetWorldOrientation().inverse() * rot * GetWorldOrientation()));
- m_modified = true;
-}
-
- void
-SG_Spatial::
-SetLocalOrientation(const MT_Matrix3x3& rot)
-{
- m_localRotation = rot;
- m_modified = true;
+ SetModified();
}
- void
-SG_Spatial::
-SetWorldOrientation(
- const MT_Matrix3x3& rot
-) {
- m_worldRotation = rot;
-}
-
-const
- MT_Point3&
-SG_Spatial::
-GetLocalPosition(
-) const {
- return m_localPosition;
-}
-
-const
- MT_Matrix3x3&
-SG_Spatial::
-GetLocalOrientation(
-) const {
- return m_localRotation;
-}
-
-const
- MT_Vector3&
-SG_Spatial::
-GetLocalScale(
-) const{
- return m_localScaling;
-}
-
-
-const
- MT_Point3&
-SG_Spatial::
-GetWorldPosition(
-) const {
- return m_worldPosition;
-}
-
-const
- MT_Matrix3x3&
-SG_Spatial::
-GetWorldOrientation(
-) const {
- return m_worldRotation;
-}
-
-const
- MT_Vector3&
-SG_Spatial::
-GetWorldScaling(
-) const {
- return m_worldScaling;
-}
-
-void SG_Spatial::SetWorldFromLocalTransform()
-{
- m_worldPosition= m_localPosition;
- m_worldScaling= m_localScaling;
- m_worldRotation= m_localRotation;
-}
-
-SG_BBox& SG_Spatial::BBox()
-{
- return m_bbox;
-}
-
-void SG_Spatial::SetBBox(SG_BBox& bbox)
-{
- m_bbox = bbox;
-}
-
MT_Transform SG_Spatial::GetWorldTransform() const
{
return MT_Transform(m_worldPosition,
diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h
index c2ed80d21b2..6e274487c9d 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.h
+++ b/source/gameengine/SceneGraph/SG_Spatial.h
@@ -35,6 +35,7 @@
#include <MT_Matrix3x3.h> // or Quaternion later ?
#include "SG_IObject.h"
#include "SG_BBox.h"
+#include "SG_ParentRelation.h"
class SG_Node;
@@ -62,9 +63,24 @@ protected:
SG_BBox m_bbox;
MT_Scalar m_radius;
bool m_modified;
+ bool m_ogldirty; // true if the openGL matrix for this object must be recomputed
public:
+ inline void ClearModified()
+ {
+ m_modified = false;
+ m_ogldirty = true;
+ }
+ inline void SetModified()
+ {
+ m_modified = true;
+ ActivateScheduleUpdateCallback();
+ }
+ inline void ClearDirty()
+ {
+ m_ogldirty = false;
+ }
/**
* Define the realtionship this node has with it's parent
* node. You should pass an unshared instance of an SG_ParentRelation
@@ -84,9 +100,12 @@ public:
SG_ParentRelation *relation
);
- SG_ParentRelation *
- GetParentRelation(
- );
+ SG_ParentRelation * GetParentRelation()
+ {
+ return m_parent_relation;
+ }
+
+
/**
@@ -105,15 +124,17 @@ public:
bool local
);
- void
- SetLocalPosition(
- const MT_Point3& trans
- );
+ void SetLocalPosition(const MT_Point3& trans)
+ {
+ m_localPosition = trans;
+ SetModified();
+ }
+
+ void SetWorldPosition(const MT_Point3& trans)
+ {
+ m_worldPosition = trans;
+ }
- void
- SetWorldPosition(
- const MT_Point3& trans
- );
void
RelativeRotate(
@@ -121,72 +142,102 @@ public:
bool local
);
- void
- SetLocalOrientation(
- const MT_Matrix3x3& rot
- );
+ void SetLocalOrientation(const MT_Matrix3x3& rot)
+ {
+ m_localRotation = rot;
+ SetModified();
+ }
+
+ // rot is arrange like openGL matrix
+ void SetLocalOrientation(const float* rot)
+ {
+ m_localRotation.setValue(rot);
+ SetModified();
+ }
+
+ void SetWorldOrientation(const MT_Matrix3x3& rot)
+ {
+ m_worldRotation = rot;
+ }
+
+ void RelativeScale(const MT_Vector3& scale)
+ {
+ m_localScaling = m_localScaling * scale;
+ SetModified();
+ }
+
+ void SetLocalScale(const MT_Vector3& scale)
+ {
+ m_localScaling = scale;
+ SetModified();
+ }
+
+ void SetWorldScale(const MT_Vector3& scale)
+ {
+ m_worldScaling = scale;
+ }
+
+ const MT_Point3& GetLocalPosition() const
+ {
+ return m_localPosition;
+ }
+
+ const MT_Matrix3x3& GetLocalOrientation() const
+ {
+ return m_localRotation;
+ }
+
+ const MT_Vector3& GetLocalScale() const
+ {
+ return m_localScaling;
+ }
+
+ const MT_Point3& GetWorldPosition() const
+ {
+ return m_worldPosition;
+ }
+
+ const MT_Matrix3x3& GetWorldOrientation() const
+ {
+ return m_worldRotation;
+ }
+
+ const MT_Vector3& GetWorldScaling() const
+ {
+ return m_worldScaling;
+ }
+
+ void SetWorldFromLocalTransform()
+ {
+ m_worldPosition= m_localPosition;
+ m_worldScaling= m_localScaling;
+ m_worldRotation= m_localRotation;
+ }
- void
- SetWorldOrientation(
- const MT_Matrix3x3& rot
- );
- void
- RelativeScale(
- const MT_Vector3& scale
- );
-
- void
- SetLocalScale(
- const MT_Vector3& scale
- );
-
- void
- SetWorldScale(
- const MT_Vector3& scale
- );
-
- const
- MT_Point3&
- GetLocalPosition(
- ) const ;
-
- const
- MT_Matrix3x3&
- GetLocalOrientation(
- ) const ;
-
- const
- MT_Vector3&
- GetLocalScale(
- ) const;
-
- const
- MT_Point3&
- GetWorldPosition(
- ) const ;
-
- const
- MT_Matrix3x3&
- GetWorldOrientation(
- ) const ;
-
- const
- MT_Vector3&
- GetWorldScaling(
- ) const ;
-
- void SetWorldFromLocalTransform();
MT_Transform GetWorldTransform() const;
- bool ComputeWorldTransforms(const SG_Spatial *parent, bool& parentUpdated);
+ bool ComputeWorldTransforms(const SG_Spatial *parent, bool& parentUpdated)
+ {
+ return m_parent_relation->UpdateChildCoordinates(this,parent,parentUpdated);
+ }
+
/**
* Bounding box functions.
*/
- SG_BBox& BBox();
- void SetBBox(SG_BBox & bbox);
+ SG_BBox& BBox()
+ {
+ return m_bbox;
+ }
+
+ void SetBBox(SG_BBox& bbox)
+ {
+ m_bbox = bbox;
+ }
+
+
bool inside(const MT_Point3 &point) const;
void getBBox(MT_Point3 *box) const;
void getAABBox(MT_Point3 *box) const;
@@ -194,6 +245,7 @@ public:
MT_Scalar Radius() const { return m_radius; }
void SetRadius(MT_Scalar radius) { m_radius = radius; }
bool IsModified() { return m_modified; }
+ bool IsDirty() { return m_ogldirty; }
protected:
friend class SG_Controller;
@@ -210,7 +262,7 @@ protected:
SG_Spatial(
void* clientobj,
void* clientinfo,
- SG_Callbacks callbacks
+ SG_Callbacks& callbacks
);
SG_Spatial(
@@ -231,7 +283,6 @@ protected:
double time,
bool& parentUpdated
);
- void SetModified(bool modified) { m_modified = modified; }
};
diff --git a/source/gameengine/VideoTexture/BlendType.h b/source/gameengine/VideoTexture/BlendType.h
index ac3ed8812a6..8b243c43912 100644
--- a/source/gameengine/VideoTexture/BlendType.h
+++ b/source/gameengine/VideoTexture/BlendType.h
@@ -25,6 +25,7 @@ http://www.gnu.org/copyleft/lesser.txt.
/// class allows check type of blender python object and access its contained object
+/// MUST ONLY BE USED FOR KX classes that are descendent of PyObjectPlus
template <class PyObj> class BlendType
{
public:
@@ -48,8 +49,9 @@ public:
// if pointer to type is set and don't match to type of provided object, return NULL
else if (obj->ob_type != m_objType)
return NULL;
- // return pointer to object
- return (PyObj*)obj;
+ // return pointer to object, this class can only be used for KX object =>
+ // the Py object is actually a proxy
+ return (PyObj*)BGE_PROXY_REF(obj);
}
/// parse arguments to get object
diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp
index 43d7566102a..6b23105a278 100644
--- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp
+++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp
@@ -135,8 +135,13 @@ static PyGetSetDef filterBSGetSets[] =
// define python type
PyTypeObject FilterBlueScreenType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.FilterBlueScreen", /*tp_name*/
sizeof(PyFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp
index 22ee729b200..5ff1f7f11ce 100644
--- a/source/gameengine/VideoTexture/FilterColor.cpp
+++ b/source/gameengine/VideoTexture/FilterColor.cpp
@@ -41,8 +41,13 @@ static PyGetSetDef filterGrayGetSets[] =
// define python type
PyTypeObject FilterGrayType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.FilterGray", /*tp_name*/
sizeof(PyFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -173,8 +178,13 @@ static PyGetSetDef filterColorGetSets[] =
// define python type
PyTypeObject FilterColorType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.FilterColor", /*tp_name*/
sizeof(PyFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -307,8 +317,13 @@ static PyGetSetDef filterLevelGetSets[] =
// define python type
PyTypeObject FilterLevelType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.FilterLevel", /*tp_name*/
sizeof(PyFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp
index a7266967efb..9a2b1e90d5a 100644
--- a/source/gameengine/VideoTexture/FilterNormal.cpp
+++ b/source/gameengine/VideoTexture/FilterNormal.cpp
@@ -124,8 +124,13 @@ static PyGetSetDef filterNormalGetSets[] =
// define python type
PyTypeObject FilterNormalType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.FilterNormal", /*tp_name*/
sizeof(PyFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp
index f3676e93a6d..4c75e14bbac 100644
--- a/source/gameengine/VideoTexture/FilterSource.cpp
+++ b/source/gameengine/VideoTexture/FilterSource.cpp
@@ -36,8 +36,13 @@ http://www.gnu.org/copyleft/lesser.txt.
// define python type
PyTypeObject FilterRGB24Type =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.FilterRGB24", /*tp_name*/
sizeof(PyFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -82,8 +87,13 @@ PyTypeObject FilterRGB24Type =
// define python type
PyTypeObject FilterRGBA32Type =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.FilterRGBA32", /*tp_name*/
sizeof(PyFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -128,8 +138,13 @@ PyTypeObject FilterRGBA32Type =
// define python type
PyTypeObject FilterBGR24Type =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.FilterBGR24", /*tp_name*/
sizeof(PyFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp
index dcca20de24a..5e2841271a6 100644
--- a/source/gameengine/VideoTexture/ImageBase.cpp
+++ b/source/gameengine/VideoTexture/ImageBase.cpp
@@ -437,7 +437,9 @@ PyObject * Image_getSource (PyImage * self, PyObject * args)
{
// get arguments
char * id;
- if (self->m_image != NULL && PyArg_ParseTuple(args, "s", &id))
+ if (!PyArg_ParseTuple(args, "s:getSource", &id))
+ return NULL;
+ if (self->m_image != NULL)
{
// get source object
PyObject * src = reinterpret_cast<PyObject*>(self->m_image->getSource(id));
@@ -460,7 +462,9 @@ PyObject * Image_setSource (PyImage * self, PyObject * args)
// get arguments
char * id;
PyObject * obj;
- if (self->m_image != NULL && PyArg_ParseTuple(args, "sO", &id, &obj))
+ if (!PyArg_ParseTuple(args, "sO:setSource", &id, &obj))
+ return NULL;
+ if (self->m_image != NULL)
{
// check type of object
if (pyImageTypes.in(obj->ob_type))
diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp
index 19ad17ac643..c7185660e83 100644
--- a/source/gameengine/VideoTexture/ImageBuff.cpp
+++ b/source/gameengine/VideoTexture/ImageBuff.cpp
@@ -71,10 +71,9 @@ static PyObject * load (PyImage * self, PyObject * args)
short width;
short height;
// parse parameters
- if (!PyArg_ParseTuple(args, "s#hh", &buff, &buffSize, &width, &height))
+ if (!PyArg_ParseTuple(args, "s#hh:load", &buff, &buffSize, &width, &height))
{
// report error
- PyErr_SetString(PyExc_TypeError, "Parameters are not correct");
return NULL;
}
// else check buffer size
@@ -123,8 +122,13 @@ static PyGetSetDef imageBuffGetSets[] =
// define python type
PyTypeObject ImageBuffType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.ImageBuff", /*tp_name*/
sizeof(PyImage), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp
index b07b362818c..067143e57bb 100644
--- a/source/gameengine/VideoTexture/ImageMix.cpp
+++ b/source/gameengine/VideoTexture/ImageMix.cpp
@@ -109,7 +109,9 @@ PyObject * getWeight (PyImage * self, PyObject * args)
short weight = 0;
// get arguments
char * id;
- if (self->m_image != NULL && PyArg_ParseTuple(args, "s", &id))
+ if (!PyArg_ParseTuple(args, "s:getWeight", &id))
+ return NULL;
+ if (self->m_image != NULL)
// get weight
weight = getImageMix(self)->getWeight(id);
// return weight
@@ -123,7 +125,9 @@ PyObject * setWeight (PyImage * self, PyObject * args)
// get arguments
char * id;
short weight = 0;
- if (self->m_image != NULL && PyArg_ParseTuple(args, "sh", &id, &weight))
+ if (!PyArg_ParseTuple(args, "sh:setWeight", &id, &weight))
+ return NULL;
+ if (self->m_image != NULL)
// set weight
if (!getImageMix(self)->setWeight(id, weight))
{
@@ -162,8 +166,13 @@ static PyGetSetDef imageMixGetSets[] =
// define python type
PyTypeObject ImageMixType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.ImageMix", /*tp_name*/
sizeof(PyImage), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp
index 09c3c22f258..c4fb1fefd9c 100644
--- a/source/gameengine/VideoTexture/ImageRender.cpp
+++ b/source/gameengine/VideoTexture/ImageRender.cpp
@@ -181,7 +181,6 @@ void ImageRender::Render()
frustrum.camnear = -mirrorOffset[2];
frustrum.camfar = -mirrorOffset[2]+m_clip;
}
- const float ortho = 100.0;
const RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode();
// The screen area that ImageViewport will copy is also the rendering zone
@@ -214,44 +213,48 @@ void ImageRender::Render()
float farfrust = m_camera->GetCameraFar();
float aspect_ratio = 1.0f;
Scene *blenderScene = m_scene->GetBlenderScene();
+ MT_Matrix4x4 projmat;
- if (orthographic) {
- lens *= ortho;
- nearfrust = (nearfrust + 1.0)*ortho;
- farfrust *= ortho;
- }
// compute the aspect ratio from frame blender scene settings so that render to texture
// works the same in Blender and in Blender player
if (blenderScene->r.ysch != 0)
- aspect_ratio = float(blenderScene->r.xsch) / float(blenderScene->r.ysch);
-
- RAS_FramingManager::ComputeDefaultFrustum(
- nearfrust,
- farfrust,
- lens,
- aspect_ratio,
- frustrum);
-
- MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix(
- frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar);
-
+ aspect_ratio = float(blenderScene->r.xsch*blenderScene->r.xasp) / float(blenderScene->r.ysch*blenderScene->r.yasp);
+
+ if (orthographic) {
+
+ RAS_FramingManager::ComputeDefaultOrtho(
+ nearfrust,
+ farfrust,
+ m_camera->GetScale(),
+ aspect_ratio,
+ frustrum
+ );
+
+ projmat = m_rasterizer->GetOrthoMatrix(
+ frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar);
+ } else
+ {
+ RAS_FramingManager::ComputeDefaultFrustum(
+ nearfrust,
+ farfrust,
+ lens,
+ aspect_ratio,
+ frustrum);
+
+ projmat = m_rasterizer->GetFrustumMatrix(
+ frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar);
+ }
m_camera->SetProjectionMatrix(projmat);
}
MT_Transform camtrans(m_camera->GetWorldToCamera());
- if (!m_camera->GetCameraData()->m_perspective)
- camtrans.getOrigin()[2] *= ortho;
MT_Matrix4x4 viewmat(camtrans);
- m_rasterizer->SetViewMatrix(viewmat, m_camera->NodeGetWorldPosition(),
- m_camera->GetCameraLocation(), m_camera->GetCameraOrientation());
+ m_rasterizer->SetViewMatrix(viewmat, m_camera->NodeGetWorldOrientation(), m_camera->NodeGetWorldPosition(), m_camera->GetCameraData()->m_perspective);
m_camera->SetModelviewMatrix(viewmat);
// restore the stereo mode now that the matrix is computed
m_rasterizer->SetStereoMode(stereomode);
- // do not update the mesh transform, we don't want to do it more than once per frame
- //m_scene->UpdateMeshTransformations();
-
m_scene->CalculateVisibleMeshes(m_rasterizer,m_camera);
m_scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
@@ -373,8 +376,13 @@ static PyGetSetDef imageRenderGetSets[] =
// define python type
PyTypeObject ImageRenderType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.ImageRender", /*tp_name*/
sizeof(PyImage), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -553,8 +561,8 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj
float yaxis[3] = {0.f, 1.f, 0.f};
float mirrorMat[3][3];
float left, right, top, bottom, back;
-
- m_camera= new KX_Camera(scene, KX_Scene::m_callbacks, camdata);
+ // make sure this camera will delete its node
+ m_camera= new KX_Camera(scene, KX_Scene::m_callbacks, camdata, true, true);
m_camera->SetName("__mirror__cam__");
// don't add the camera to the scene object list, it doesn't need to be accessible
m_owncamera = true;
@@ -707,8 +715,13 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj
// define python type
PyTypeObject ImageMirrorType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.ImageMirror", /*tp_name*/
sizeof(PyImage), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp
index a4e36b5948c..d2c23e758f6 100644
--- a/source/gameengine/VideoTexture/ImageViewport.cpp
+++ b/source/gameengine/VideoTexture/ImageViewport.cpp
@@ -289,8 +289,13 @@ static PyGetSetDef imageViewportGetSets[] =
// define python type
PyTypeObject ImageViewportType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.ImageViewport", /*tp_name*/
sizeof(PyImage), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp
index 6d2676dce09..2d571675dbd 100644
--- a/source/gameengine/VideoTexture/PyTypeList.cpp
+++ b/source/gameengine/VideoTexture/PyTypeList.cpp
@@ -45,7 +45,6 @@ bool PyTypeList::in (PyTypeObject * type)
/// add type to list
void PyTypeList::add (PyTypeObject * type, const char * name)
{
- PyTypeListItem * typeItem;
// if list doesn't exist, create it
if (m_list.get() == NULL)
m_list.reset(new PyTypeListType());
diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp
index 3533cee0f7f..f4105652f80 100644
--- a/source/gameengine/VideoTexture/Texture.cpp
+++ b/source/gameengine/VideoTexture/Texture.cpp
@@ -50,7 +50,7 @@ http://www.gnu.org/copyleft/lesser.txt.
// macro for exception handling and logging
#define CATCH_EXCP catch (Exception & exp) \
-{ exp.report(); }
+{ exp.report(); return NULL; }
// Blender GameObject type
@@ -162,11 +162,12 @@ void Texture_dealloc (Texture * self)
// release renderer
Py_XDECREF(self->m_source);
// close texture
- Texture_close(self);
+ PyObject* ret = Texture_close(self);
+ Py_DECREF(ret);
// release scaled image buffer
delete [] self->m_scaledImg;
// release object
- self->ob_type->tp_free((PyObject*)self);
+ ((PyObject *)self)->ob_type->tp_free((PyObject*)self);
}
@@ -278,7 +279,7 @@ PyObject * Texture_refresh (Texture * self, PyObject * args)
{
// get parameter - refresh source
PyObject * param;
- if (!PyArg_ParseTuple(args, "O", &param) || !PyBool_Check(param))
+ if (!PyArg_ParseTuple(args, "O:refresh", &param) || !PyBool_Check(param))
{
// report error
PyErr_SetString(PyExc_TypeError, "The value must be a bool");
@@ -433,8 +434,13 @@ static PyGetSetDef textureGetSets[] =
// class Texture declaration
PyTypeObject TextureType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.Texture", /*tp_name*/
sizeof(Texture), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/VideoBase.cpp b/source/gameengine/VideoTexture/VideoBase.cpp
index 3c703d75cda..5d449a158d8 100644
--- a/source/gameengine/VideoTexture/VideoBase.cpp
+++ b/source/gameengine/VideoTexture/VideoBase.cpp
@@ -113,7 +113,10 @@ void Video_open (VideoBase * self, char * file, short captureID)
PyObject * Video_play (PyImage * self)
{ if (getVideo(self)->play()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
-// stop video
+// pause video
+PyObject * Video_pause (PyImage * self)
+{ if (getVideo(self)->pause()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
+
PyObject * Video_stop (PyImage * self)
{ if (getVideo(self)->stop()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
@@ -146,7 +149,7 @@ int Video_setRange (PyImage * self, PyObject * value, void * closure)
|| !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0))
|| !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1)))
{
- PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 longs");
+ PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 float");
return -1;
}
// set range
diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h
index 15ecb7a78f4..0c8668ee0bc 100644
--- a/source/gameengine/VideoTexture/VideoBase.h
+++ b/source/gameengine/VideoTexture/VideoBase.h
@@ -80,7 +80,17 @@ public:
}
return false;
}
- /// stop/pause video
+ /// pause video
+ virtual bool pause (void)
+ {
+ if (m_status == SourcePlaying)
+ {
+ m_status = SourceStopped;
+ return true;
+ }
+ return false;
+ }
+ /// stop video
virtual bool stop (void)
{
if (m_status == SourcePlaying)
@@ -170,6 +180,7 @@ template <class T> void Video_init (PyImage * self)
// video functions
void Video_open (VideoBase * self, char * file, short captureID);
PyObject * Video_play (PyImage * self);
+PyObject * Video_pause (PyImage * self);
PyObject * Video_stop (PyImage * self);
PyObject * Video_refresh (PyImage * self);
PyObject * Video_getStatus (PyImage * self, void * closure);
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
index 5265b0ecb93..1a5481488c0 100644
--- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp
+++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
@@ -117,6 +117,7 @@ bool VideoFFmpeg::release()
}
m_codec = NULL;
m_status = SourceStopped;
+ m_lastFrame = -1;
return true;
}
@@ -669,12 +670,12 @@ bool VideoFFmpeg::play (void)
}
-// stop video
-bool VideoFFmpeg::stop (void)
+// pause video
+bool VideoFFmpeg::pause (void)
{
try
{
- if (VideoBase::stop())
+ if (VideoBase::pause())
{
return true;
}
@@ -683,6 +684,20 @@ bool VideoFFmpeg::stop (void)
return false;
}
+// stop video
+bool VideoFFmpeg::stop (void)
+{
+ try
+ {
+ VideoBase::stop();
+ // force restart when play
+ m_lastFrame = -1;
+ return true;
+ }
+ CATCH_EXCP;
+ return false;
+}
+
// set video range
void VideoFFmpeg::setRange (double start, double stop)
@@ -721,6 +736,8 @@ void VideoFFmpeg::loadFrame (void)
{
// get actual time
double startTime = PIL_check_seconds_timer();
+ if (m_lastFrame == -1 && !m_isFile)
+ m_startTime = startTime;
double actTime = startTime - m_startTime;
// if video has ended
if (m_isFile && actTime * m_frameRate >= m_range[1])
@@ -886,28 +903,47 @@ AVFrame *VideoFFmpeg::grabFrame(long position)
if (position != m_curPosition + 1)
{
double timeBase = av_q2d(m_formatCtx->streams[m_videoStream]->time_base);
- long long pos = (long long)
- ((long long) (position - m_preseek) * AV_TIME_BASE / m_baseFrameRate);
- long long startTs = m_formatCtx->streams[m_videoStream]->start_time;
+ int64_t pos = (int64_t)((position - m_preseek) / (m_baseFrameRate*timeBase));
+ int64_t startTs = m_formatCtx->streams[m_videoStream]->start_time;
+ int seekres;
if (pos < 0)
pos = 0;
if (startTs != AV_NOPTS_VALUE)
- pos += (long long)(startTs * AV_TIME_BASE * timeBase);
+ pos += startTs;
if (position <= m_curPosition || !m_eof)
{
- // no need to seek past the end of the file
- if (av_seek_frame(m_formatCtx, -1, pos, AVSEEK_FLAG_BACKWARD) >= 0)
+#if 0
+ // Tried to make this work but couldn't: seeking on byte is ignored by the
+ // format plugin and it will generally continue to read from last timestamp.
+ // Too bad because frame seek is not always able to get the first frame
+ // of the file.
+ if (position <= m_preseek)
+ {
+ // we can safely go the begining of the file
+ if (av_seek_frame(m_formatCtx, m_videoStream, 0, AVSEEK_FLAG_BYTE) >= 0)
+ {
+ // binary seek does not reset the timestamp, must do it now
+ av_update_cur_dts(m_formatCtx, m_formatCtx->streams[m_videoStream], startTs);
+ m_curPosition = 0;
+ }
+ }
+ else
+#endif
{
// current position is now lost, guess a value.
- // It's not important because it will be set at this end of this function
- m_curPosition = position - m_preseek - 1;
+ if (av_seek_frame(m_formatCtx, m_videoStream, pos, AVSEEK_FLAG_BACKWARD) >= 0)
+ {
+ // current position is now lost, guess a value.
+ // It's not important because it will be set at this end of this function
+ m_curPosition = position - m_preseek - 1;
+ }
}
}
// this is the timestamp of the frame we're looking for
- targetTs = (long long)(((double) position) / m_baseFrameRate / timeBase);
+ targetTs = (int64_t)(position / (m_baseFrameRate * timeBase));
if (startTs != AV_NOPTS_VALUE)
targetTs += startTs;
@@ -1097,8 +1133,9 @@ int VideoFFmpeg_setDeinterlace (PyImage * self, PyObject * value, void * closure
// methods structure
static PyMethodDef videoMethods[] =
{ // methods from VideoBase class
- {"play", (PyCFunction)Video_play, METH_NOARGS, "Play video"},
- {"stop", (PyCFunction)Video_stop, METH_NOARGS, "Stop (pause) video"},
+ {"play", (PyCFunction)Video_play, METH_NOARGS, "Play (restart) video"},
+ {"pause", (PyCFunction)Video_pause, METH_NOARGS, "pause video"},
+ {"stop", (PyCFunction)Video_stop, METH_NOARGS, "stop video (play will replay it from start)"},
{"refresh", (PyCFunction)Video_refresh, METH_NOARGS, "Refresh video - get its status"},
{NULL}
};
@@ -1123,8 +1160,13 @@ static PyGetSetDef videoGetSets[] =
// python type declaration
PyTypeObject VideoFFmpegType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.VideoFFmpeg", /*tp_name*/
sizeof(PyImage), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1173,7 +1215,7 @@ static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds
char * file = NULL;
// get parameters
- if (!PyArg_ParseTuple(args, "s", &file))
+ if (!PyArg_ParseTuple(args, "s:ImageFFmpeg", &file))
return -1;
try
@@ -1198,8 +1240,9 @@ static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds
PyObject * Image_reload (PyImage * self, PyObject *args)
{
char * newname = NULL;
-
- if (self->m_image != NULL && PyArg_ParseTuple(args, "|s", &newname))
+ if (!PyArg_ParseTuple(args, "|s:reload", &newname))
+ return NULL;
+ if (self->m_image != NULL)
{
VideoFFmpeg* video = getFFmpeg(self);
// check type of object
@@ -1241,8 +1284,13 @@ static PyGetSetDef imageGetSets[] =
// python type declaration
PyTypeObject ImageFFmpegType =
{
- PyObject_HEAD_INIT(NULL)
+#if (PY_VERSION_HEX >= 0x02060000)
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ /* python 2.5 and below */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /*ob_size*/
+#endif
"VideoTexture.ImageFFmpeg", /*tp_name*/
sizeof(PyImage), /*tp_basicsize*/
0, /*tp_itemsize*/
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h
index 51f1067c466..fbd04e7e1fc 100644
--- a/source/gameengine/VideoTexture/VideoFFmpeg.h
+++ b/source/gameengine/VideoTexture/VideoFFmpeg.h
@@ -83,9 +83,10 @@ public:
/// play video
virtual bool play (void);
- /// stop/pause video
+ /// pause video
+ virtual bool pause (void);
+ /// stop video
virtual bool stop (void);
-
/// set play range
virtual void setRange (double start, double stop);
/// set frame rate
diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp
index c11e7fffecd..1dcc72c8f7d 100644
--- a/source/gameengine/VideoTexture/blendVideoTex.cpp
+++ b/source/gameengine/VideoTexture/blendVideoTex.cpp
@@ -74,7 +74,7 @@ static PyObject * getLastError (PyObject *self, PyObject *args)
static PyObject * setLogFile (PyObject *self, PyObject *args)
{
// get parameters
- if (!PyArg_ParseTuple(args, "s", &Exception::m_logFile))
+ if (!PyArg_ParseTuple(args, "s:setLogFile", &Exception::m_logFile))
return Py_BuildValue("i", -1);
// log file was loaded
return Py_BuildValue("i", 0);
@@ -86,7 +86,7 @@ static PyObject * imageToArray (PyObject * self, PyObject *args)
{
// parameter is Image object
PyObject * pyImg;
- if (!PyArg_ParseTuple(args, "O", &pyImg) || !pyImageTypes.in(pyImg->ob_type))
+ if (!PyArg_ParseTuple(args, "O:imageToArray", &pyImg) || !pyImageTypes.in(pyImg->ob_type))
{
// if object is incorect, report error
PyErr_SetString(PyExc_TypeError, "VideoTexture.imageToArray(image): The value must be a image source object");
@@ -159,8 +159,25 @@ static void registerAllTypes(void)
pyFilterTypes.add(&FilterBGR24Type, "FilterBGR24");
}
+
+#if (PY_VERSION_HEX >= 0x03000000)
+static struct PyModuleDef VideoTexture_module_def = {
+ {}, /* m_base */
+ "VideoTexture", /* m_name */
+ "Module that allows to play video files on textures in GameBlender.", /* m_doc */
+ 0, /* m_size */
+ moduleMethods, /* m_methods */
+ 0, /* m_reload */
+ 0, /* m_traverse */
+ 0, /* m_clear */
+ 0, /* m_free */
+};
+#endif
+
PyObject* initVideoTexture(void)
{
+ PyObject * m;
+
// initialize GL extensions
//bgl::InitExtensions(0);
@@ -175,9 +192,25 @@ PyObject* initVideoTexture(void)
if (PyType_Ready(&TextureType) < 0)
return NULL;
- PyObject * m = Py_InitModule4("VideoTexture", moduleMethods,
- "Module that allows to play video files on textures in GameBlender.",
- (PyObject*)NULL,PYTHON_API_VERSION);
+ /* Use existing module where possible
+ * be careful not to init any runtime vars after this */
+ m = PyImport_ImportModule( "VideoTexture" );
+ if(m) {
+ Py_DECREF(m);
+ return m;
+ }
+ else {
+ PyErr_Clear();
+
+#if (PY_VERSION_HEX >= 0x03000000)
+ m = PyModule_Create(&VideoTexture_module_def);
+#else
+ m = Py_InitModule4("VideoTexture", moduleMethods,
+ "Module that allows to play video files on textures in GameBlender.",
+ (PyObject*)NULL,PYTHON_API_VERSION);
+#endif
+ }
+
if (m == NULL)
return NULL;
@@ -187,9 +220,10 @@ PyObject* initVideoTexture(void)
Py_INCREF(&TextureType);
PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType);
-
+
// init last error description
Exception::m_lastError[0] = '\0';
+
return m;
}
diff --git a/source/kernel/gen_system/GEN_HashedPtr.cpp b/source/kernel/gen_system/GEN_HashedPtr.cpp
index 6dbed1fb7a8..ff9de465a34 100644
--- a/source/kernel/gen_system/GEN_HashedPtr.cpp
+++ b/source/kernel/gen_system/GEN_HashedPtr.cpp
@@ -40,11 +40,12 @@
// is a 32-bit integer, use all the bits of the pointer as long
// as possible.
//
-
+#if 1
unsigned int GEN_Hash(void * inDWord)
{
uintptr_t key = (uintptr_t)inDWord;
-
+#if 0
+ // this is way too complicated
key += ~(key << 16);
key ^= (key >> 5);
key += (key << 3);
@@ -53,4 +54,8 @@ unsigned int GEN_Hash(void * inDWord)
key ^= (key >> 17);
return (unsigned int)(key & 0xffffffff);
+#else
+ return (unsigned int)(key ^ (key>>4));
+#endif
}
+#endif \ No newline at end of file
diff --git a/source/nan_definitions.mk b/source/nan_definitions.mk
index ba2f8f04233..b9e623ed4e4 100644
--- a/source/nan_definitions.mk
+++ b/source/nan_definitions.mk
@@ -288,8 +288,12 @@ endif
export HOST = $(shell /usr/bsd/hostname -s)
#export NAN_NO_KETSJI=true
export NAN_JUST_BLENDERDYNAMIC=true
- export NAN_PYTHON ?= $(LCGDIR)/python
- export NAN_PYTHON_VERSION ?= 2.3
+ export NAN_PYTHON_VERSION ?= 2.5
+ ifeq ($(IRIX_USE_GCC), true)
+ export NAN_PYTHON ?= $(LCGDIR)/python_gcc
+ else
+ export NAN_PYTHON ?= $(LCGDIR)/python
+ endif
export NAN_PYTHON_BINARY ?= $(NAN_PYTHON)/bin/python$(NAN_PYTHON_VERSION)
export NAN_PYTHON_LIB ?= $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/config/libpython$(NAN_PYTHON_VERSION).a -lpthread
export NAN_OPENAL ?= $(LCGDIR)/openal
diff --git a/tools/Blender.py b/tools/Blender.py
index ce5570ebd45..bb82f9caa1d 100644
--- a/tools/Blender.py
+++ b/tools/Blender.py
@@ -126,8 +126,6 @@ def setup_staticlibs(lenv):
libincs += Split(lenv['BF_SDL_LIBPATH'])
if lenv['WITH_BF_FFMPEG']:
libincs += Split(lenv['BF_FFMPEG_LIBPATH'])
- if lenv['WITH_BF_STATICCXX']:
- statlibs += Split(lenv['BF_CXX_LIB_STATIC'])
if lenv['WITH_BF_OPENEXR']:
libincs += Split(lenv['BF_OPENEXR_LIBPATH'])
if lenv['WITH_BF_STATICOPENEXR']:
@@ -140,6 +138,8 @@ def setup_staticlibs(lenv):
statlibs += Split(lenv['BF_OPENAL_LIB_STATIC'])
if lenv['WITH_BF_STATICOPENGL']:
statlibs += Split(lenv['BF_OPENGL_LIB_STATIC'])
+ if lenv['WITH_BF_STATICCXX']:
+ statlibs += Split(lenv['BF_CXX_LIB_STATIC'])
if lenv['WITH_BF_PYTHON'] and lenv['WITH_BF_STATICPYTHON']:
statlibs += Split(lenv['BF_PYTHON_LIB_STATIC'])
diff --git a/tools/btools.py b/tools/btools.py
index b32ef83349c..bbf8d0a232e 100755
--- a/tools/btools.py
+++ b/tools/btools.py
@@ -36,6 +36,8 @@ def validate_arguments(args, bc):
'WITH_BF_FFMPEG', 'BF_FFMPEG_LIB','BF_FFMPEG_EXTRA', 'BF_FFMPEG', 'BF_FFMPEG_INC',
'WITH_BF_OGG', 'BF_OGG', 'BF_OGG_LIB',
'WITH_BF_JPEG', 'BF_JPEG', 'BF_JPEG_INC', 'BF_JPEG_LIB', 'BF_JPEG_LIBPATH',
+ 'WITH_BF_OPENJPEG', 'BF_OPENJPEG', 'BF_OPENJPEG_INC', 'BF_OPENJPEG_LIB', 'BF_OPENJPEG_LIBPATH',
+ 'WITH_BF_REDCODE', 'BF_REDCODE', 'BF_REDCODE_INC', 'BF_REDCODE_LIB', 'BF_REDCODE_LIBPATH',
'WITH_BF_PNG', 'BF_PNG', 'BF_PNG_INC', 'BF_PNG_LIB', 'BF_PNG_LIBPATH',
'BF_TIFF', 'BF_TIFF_INC', 'BF_TIFF_LIB', 'BF_TIFF_LIBPATH',
'WITH_BF_ZLIB', 'BF_ZLIB', 'BF_ZLIB_INC', 'BF_ZLIB_LIB', 'BF_ZLIB_LIBPATH',
@@ -92,7 +94,7 @@ def validate_arguments(args, bc):
if (k in opts_list) or (k in arg_list):
okdict[k] = v
elif k in opts_list_split:
- okdict[k] = v.split() # "" have alredy been stripped
+ okdict[k] = v.split() # "" have already been stripped
else:
print '\t'+bc.WARNING+'Invalid argument: '+bc.ENDC+k+'='+v