[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47195] trunk/blender: BGE #30734: add support for physics linear and angular thresholds and deactivation time from python and GUI .
Jorge Bernal
jbernalmartinez at gmail.com
Wed May 30 07:25:57 CEST 2012
Hi Benoit,
in readfile.c, shouldn't it be sce->gm.deactivationtime = 0.0f?
Best Regards,
Jorge
2012/5/29 Benoit Bolsee <benoit.bolsee at online.be>
> Revision: 47195
>
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47195
> Author: ben2610
> Date: 2012-05-29 20:30:33 +0000 (Tue, 29 May 2012)
> Log Message:
> -----------
> BGE #30734: add support for physics linear and angular thresholds and
> deactivation time from python and GUI.
> ========================
> The linear and angular thresholds set the speed limit (in m/s) and
> rotation limit (in rad/s)
> under which a rigid body will go to sleep (stop moving) if it stays below
> the limits for a
> time equal or longer than the deactivation time (sleeping is disabled is
> deactivation time is
> set to 0).
> These settings help reducing the processing spent on Physics during the
> game.
>
> Previously they were only accessible from python but not working because
> of a bug.
> Now the python functions are working and the settings are available in the
> Physics panel
> of the World settings when using the Blender Game render engine.
>
> Python API:
> import PhysicsConstraints
> PhysicsConstraints.setDeactivationLinearTreshold(float)
> PhysicsConstraints.setDeactivationAngularTreshold(float)
>
> Modified Paths:
> --------------
> trunk/blender/release/scripts/startup/bl_ui/properties_game.py
> trunk/blender/source/blender/blenkernel/BKE_blender.h
> trunk/blender/source/blender/blenkernel/intern/scene.c
> trunk/blender/source/blender/blenloader/intern/readfile.c
> trunk/blender/source/blender/makesdna/DNA_object_types.h
> trunk/blender/source/blender/makesdna/DNA_scene_types.h
> trunk/blender/source/blender/makesrna/intern/rna_scene.c
> trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
> trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
>
> Modified: trunk/blender/release/scripts/startup/bl_ui/properties_game.py
> ===================================================================
> --- trunk/blender/release/scripts/startup/bl_ui/properties_game.py
> 2012-05-29 20:06:31 UTC (rev 47194)
> +++ trunk/blender/release/scripts/startup/bl_ui/properties_game.py
> 2012-05-29 20:30:33 UTC (rev 47195)
> @@ -622,6 +622,14 @@
> col.prop(gs, "logic_step_max", text="Max")
>
> col = layout.column()
> + col.label(text="Physics Deactivation:")
> + sub = col.row(align=True)
> + sub.prop(gs, "deactivation_linear_threshold", text="Linear
> Threshold")
> + sub.prop(gs, "deactivation_angular_threshold", text="Angular
> Threshold")
> + sub = col.row()
> + sub.prop(gs, "deactivation_time", text="Time")
> +
> + col = layout.column()
> col.prop(gs, "use_occlusion_culling", text="Occlusion Culling")
> sub = col.column()
> sub.active = gs.use_occlusion_culling
>
> Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/BKE_blender.h 2012-05-29
> 20:06:31 UTC (rev 47194)
> +++ trunk/blender/source/blender/blenkernel/BKE_blender.h 2012-05-29
> 20:30:33 UTC (rev 47195)
> @@ -42,7 +42,7 @@
> * and keep comment above the defines.
> * Use STRINGIFY() rather than defining with quotes */
> #define BLENDER_VERSION 263
> -#define BLENDER_SUBVERSION 7
> +#define BLENDER_SUBVERSION 8
>
> #define BLENDER_MINVERSION 250
> #define BLENDER_MINSUBVERSION 0
>
> Modified: trunk/blender/source/blender/blenkernel/intern/scene.c
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/intern/scene.c 2012-05-29
> 20:06:31 UTC (rev 47194)
> +++ trunk/blender/source/blender/blenkernel/intern/scene.c 2012-05-29
> 20:30:33 UTC (rev 47195)
> @@ -516,6 +516,9 @@
> sce->gm.maxlogicstep = 5;
> sce->gm.physubstep = 1;
> sce->gm.maxphystep = 5;
> + sce->gm.lineardeactthreshold = 0.8f;
> + sce->gm.angulardeactthreshold = 1.0f;
> + sce->gm.deactivationtime = 0.0f;
>
> sce->gm.flag = GAME_DISPLAY_LISTS;
> sce->gm.matmode = GAME_MAT_MULTITEX;
>
> Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
> ===================================================================
> --- trunk/blender/source/blender/blenloader/intern/readfile.c 2012-05-29
> 20:06:31 UTC (rev 47194)
> +++ trunk/blender/source/blender/blenloader/intern/readfile.c 2012-05-29
> 20:30:33 UTC (rev 47195)
> @@ -7230,9 +7230,9 @@
>
> if (main->versionfile < 263) {
> /* set fluidsim rate. the version patch for this in 2.62
> was wrong, so
> - * try to correct it, if rate is 0.0 that's likely not
> intentional */
> + try to correct it, if rate is 0.0 that's likely not
> intentional */
> Object *ob;
> -
> +
> for (ob = main->object.first; ob; ob = ob->id.next) {
> ModifierData *md;
> for (md = ob->modifiers.first; md; md = md->next) {
> @@ -7502,6 +7502,19 @@
> }
> }
>
> + if (main->versionfile < 263 || (main->versionfile == 263 &&
> main->subversionfile < 8))
> + {
> + /* set new deactivation values for game settings */
> + Scene *sce;
> +
> + for (sce = main->scene.first; sce; sce = sce->id.next) {
> + /* Game Settings */
> + sce->gm.lineardeactthreshold = 0.8f;
> + sce->gm.angulardeactthreshold = 1.0f;
> + sce->gm.deactivationtime = 2.0f;
> + }
> + }
> +
> /* WATCH IT!!!: pointers from libdata have not been converted yet
> here! */
> /* WATCH IT 2!: Userdef struct init has to be in
> editors/interface/resources.c! */
> {
>
> Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_object_types.h 2012-05-29
> 20:06:31 UTC (rev 47194)
> +++ trunk/blender/source/blender/makesdna/DNA_object_types.h 2012-05-29
> 20:30:33 UTC (rev 47195)
> @@ -201,7 +201,7 @@
> float rdamping, sizefac;
> 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 min_vel; /* clamp the minimum velocity 0.0 is disabled */
> float m_contactProcessingThreshold;
> float obstacleRad;
>
>
> Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_scene_types.h 2012-05-29
> 20:06:31 UTC (rev 47194)
> +++ trunk/blender/source/blender/makesdna/DNA_scene_types.h 2012-05-29
> 20:30:33 UTC (rev 47195)
> @@ -625,6 +625,7 @@
> short ticrate, maxlogicstep, physubstep, maxphystep;
> short obstacleSimulation, pad1;
> float levelHeight;
> + float deactivationtime, lineardeactthreshold,
> angulardeactthreshold,pad2;
> } GameData;
>
> #define STEREO_NOSTEREO 1
>
> Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
> ===================================================================
> --- trunk/blender/source/blender/makesrna/intern/rna_scene.c 2012-05-29
> 20:06:31 UTC (rev 47194)
> +++ trunk/blender/source/blender/makesrna/intern/rna_scene.c 2012-05-29
> 20:30:33 UTC (rev 47195)
> @@ -2577,6 +2577,31 @@
> "higher value give better physics
> precision");
> RNA_def_property_update(prop, NC_SCENE, NULL);
>
> + prop = RNA_def_property(srna, "deactivation_linear_threshold",
> PROP_FLOAT, PROP_NONE);
> + RNA_def_property_float_sdna(prop, NULL, "lineardeactthreshold");
> + RNA_def_property_ui_range(prop, 0.001, 10000.0, 2, 3);
> + RNA_def_property_range(prop, 0.001, 10000.0);
> + RNA_def_property_ui_text(prop, "Deactivation Linear Threshold",
> + "Linear velocity that an object must be
> below before the deactivation timer can start");
> + RNA_def_property_update(prop, NC_SCENE, NULL);
> +
> + prop = RNA_def_property(srna, "deactivation_angular_threshold",
> PROP_FLOAT, PROP_NONE);
> + RNA_def_property_float_sdna(prop, NULL, "angulardeactthreshold");
> + RNA_def_property_ui_range(prop, 0.001, 10000.0, 2, 3);
> + RNA_def_property_range(prop, 0.001, 10000.0);
> + RNA_def_property_ui_text(prop, "Deactivation Angular Threshold",
> + "Angular velocity that an object must be
> below before the deactivation timer can start");
> + RNA_def_property_update(prop, NC_SCENE, NULL);
> +
> + prop = RNA_def_property(srna, "deactivation_time", PROP_FLOAT,
> PROP_NONE);
> + RNA_def_property_float_sdna(prop, NULL, "deactivationtime");
> + RNA_def_property_ui_range(prop, 0.0, 60.0, 1, 1);
> + RNA_def_property_range(prop, 0.0, 60.0);
> + RNA_def_property_ui_text(prop, "Deactivation Time",
> + "Amount of time (in seconds) after
> objects with a velocity less than than a certain "
> + "threshold will deactivate. Time 0.0
> means deactivation inactive");
> + RNA_def_property_update(prop, NC_SCENE, NULL);
> +
> /* mode */
> prop = RNA_def_property(srna, "use_occlusion_culling",
> PROP_BOOLEAN, PROP_NONE);
> RNA_def_property_boolean_sdna(prop, NULL, "mode", (1 << 5)); /*XXX
> mode hardcoded *//* WO_DBVT_CULLING */
>
> Modified:
> trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
> ===================================================================
> --- trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
> 2012-05-29 20:06:31 UTC (rev 47194)
> +++ trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
> 2012-05-29 20:30:33 UTC (rev 47195)
> @@ -324,8 +324,9 @@
> {
> CcdPhysicsEnvironment* ccdPhysEnv = new
> CcdPhysicsEnvironment(useDbvtCulling);
> ccdPhysEnv->setDebugDrawer(new
> BlenderDebugDraw());
> -
> ccdPhysEnv->setDeactivationLinearTreshold(0.8f); // default, can be
> overridden by Python
> -
> ccdPhysEnv->setDeactivationAngularTreshold(1.0f); // default, can be
> overridden by Python
> +
> ccdPhysEnv->setDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
> +
> ccdPhysEnv->setDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
> +
> ccdPhysEnv->setDeactivationTime(blenderscene->gm.deactivationtime);
>
> SYS_SystemHandle syshandle =
> SYS_GetSystem(); /*unused*/
> int visualizePhysics =
> SYS_GetCommandLineInt(syshandle,"show_physics",0);
>
> Modified:
> trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
> ===================================================================
> ---
> trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
> 2012-05-29 20:06:31 UTC (rev 47194)
> +++
> trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
> 2012-05-29 20:30:33 UTC (rev 47195)
> @@ -60,8 +60,8 @@
> extern bool gDisableDeactivation;
>
>
> -float gLinearSleepingTreshold = 0.8f;
> -float gAngularSleepingTreshold = 1.0f;
> +float gLinearSleepingTreshold;
> +float gAngularSleepingTreshold;
>
>
> btVector3 startVel(0,0,0);//-10000);
> @@ -519,6 +519,7 @@
> body->setAngularFactor(0.f);
> }
>
> body->setContactProcessingThreshold(m_cci.m_contactProcessingThreshold);
> + body->setSleepingThresholds(gLinearSleepingTreshold,
> gAngularSleepingTreshold);
>
> }
> if (m_object && m_cci.m_do_anisotropic)
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
More information about the Bf-committers
mailing list