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:
authorBenoit Bolsee <benoit.bolsee@online.be>2012-05-30 00:30:33 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2012-05-30 00:30:33 +0400
commit58bc424b3c46ee3ee6644ff578671670c2a1c8ec (patch)
tree147b691cecd0286e750fd73f0c6a2edad8ab9b90 /source/blender
parent1d4ab9daf0ef38066469fb86bed0fc24b2e1bbda (diff)
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)
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/intern/scene.c3
-rw-r--r--source/blender/blenloader/intern/readfile.c17
-rw-r--r--source/blender/makesdna/DNA_object_types.h2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_scene.c25
6 files changed, 46 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index e2bca1bb93e..24386730ddb 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* 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
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 63efd194932..62d5459336b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -516,6 +516,9 @@ Scene *BKE_scene_add(const char *name)
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;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a0513cf55b1..081264d62df 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7230,9 +7230,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
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 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ 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! */
{
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 11ca1f1fa8e..44d7ec660f2 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -201,7 +201,7 @@ typedef struct Object {
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;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 673156e3d7d..198b6a9bf80 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -625,6 +625,7 @@ typedef struct GameData {
short ticrate, maxlogicstep, physubstep, maxphystep;
short obstacleSimulation, pad1;
float levelHeight;
+ float deactivationtime, lineardeactthreshold, angulardeactthreshold,pad2;
} GameData;
#define STEREO_NOSTEREO 1
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 5b355e56911..17efc25c132 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2577,6 +2577,31 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
"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 */