Changeset View
Standalone View
source/blender/makesrna/intern/rna_rigidbody.c
| Context not available. | |||||
| #include <string.h> | #include <string.h> | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_enum_types.h" | |||||
aligorith: Why? | |||||
Not Done Inline ActionsThis file (as some others too) contain remainders of a unlucky merge.... need to clean this up scorpion81: This file (as some others too) contain remainders of a unlucky merge.... need to clean this up | |||||
| #include "rna_internal.h" | #include "rna_internal.h" | ||||
| Context not available. | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_modifier_types.h" | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "bmesh.h" | |||||
| /* roles of objects in RigidBody Sims */ | /* roles of objects in RigidBody Sims */ | ||||
| EnumPropertyItem rigidbody_object_type_items[] = { | EnumPropertyItem rigidbody_object_type_items[] = { | ||||
| Context not available. | |||||
| /* ******************************** */ | /* ******************************** */ | ||||
| static void rna_RigidBodyWorld_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) | static void rna_RigidBodyWorld_reset(Main *bmain, Scene *scene, PointerRNA *ptr) | ||||
Not Done Inline ActionsLeftover changes? aligorith: Leftover changes? | |||||
| { | { | ||||
| RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data; | RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data; | ||||
| BKE_rigidbody_cache_reset(rbw); | BKE_rigidbody_cache_reset(rbw); | ||||
| } | } | ||||
| static char *rna_RigidBodyWorld_path(PointerRNA *UNUSED(ptr)) | static char *rna_RigidBodyWorld_path(PointerRNA *ptr) | ||||
Not Done Inline ActionsLeftover changes? aligorith: Leftover changes? | |||||
| { | { | ||||
| return BLI_sprintfN("rigidbody_world"); | return BLI_sprintfN("rigidbody_world"); | ||||
| } | } | ||||
| Context not available. | |||||
| /* ******************************** */ | /* ******************************** */ | ||||
| static void rna_RigidBodyOb_reset(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) | |||||
| /* ------------------------------------------ */ | |||||
| void foreach_shard_float(Object* ob, float value, void (*func)(RigidBodyOb *rbo, float value)) | |||||
| { | |||||
| ModifierData *md; | |||||
| FractureModifierData* rmd; | |||||
| MeshIsland* mi; | |||||
| for (md = ob->modifiers.first; md; md = md->next) { | |||||
| if (md->type == eModifierType_Fracture) { | |||||
| rmd = (FractureModifierData*)md; | |||||
| for (mi = rmd->meshIslands.first; mi; mi = mi->next) { | |||||
| if (mi->rigidbody != NULL) { | |||||
| func(mi->rigidbody, value); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void foreach_shard_mass(Object *ob) | |||||
| { | |||||
| ModifierData *md; | |||||
| FractureModifierData* rmd; | |||||
| MeshIsland* mi; | |||||
| for (md = ob->modifiers.first; md; md = md->next) { | |||||
| if (md->type == eModifierType_Fracture) { | |||||
| rmd = (FractureModifierData*)md; | |||||
| for (mi = rmd->meshIslands.first; mi; mi = mi->next) { | |||||
| if (mi->rigidbody != NULL) { | |||||
| BKE_rigidbody_calc_shard_mass(ob, mi, NULL); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void foreach_shard_int(Object *ob, int value, void (*func)(RigidBodyOb *rbo, int value)) | |||||
| { | |||||
| ModifierData *md; | |||||
| FractureModifierData* rmd; | |||||
| MeshIsland* mi; | |||||
| for (md = ob->modifiers.first; md; md = md->next) { | |||||
| if (md->type == eModifierType_Fracture) { | |||||
| rmd = (FractureModifierData*)md; | |||||
| for (mi = rmd->meshIslands.first; mi; mi = mi->next) { | |||||
| if (mi->rigidbody != NULL) { | |||||
| func(mi->rigidbody, value); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void foreach_shard_ints(Object *ob, const int *value, void (*func)(RigidBodyOb *rbo, const int *value)) | |||||
| { | |||||
| ModifierData *md; | |||||
| FractureModifierData* rmd; | |||||
| MeshIsland *mi; | |||||
| for (md = ob->modifiers.first; md; md = md->next) { | |||||
| if (md->type == eModifierType_Fracture) { | |||||
| rmd = (FractureModifierData*)md; | |||||
| for (mi = rmd->meshIslands.first; mi; mi = mi->next) { | |||||
| if (mi->rigidbody != NULL) { | |||||
| func(mi->rigidbody, value); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void foreach_shard_flag_shape(Object *ob, int flag, short shape, bool reset) | |||||
Not Done Inline Actions
aligorith: 1) Codestyle (asterix goes on side of variable, not type)
2) Give your variables meaningful… | |||||
| { | |||||
| ModifierData *md; | |||||
| FractureModifierData *rmd; | |||||
| MeshIsland *mi; | |||||
| for (md = ob->modifiers.first; md; md = md->next) { | |||||
| if (md->type == eModifierType_Fracture) { | |||||
| rmd = (FractureModifierData*)md; | |||||
| for (mi = rmd->meshIslands.first; mi; mi = mi->next) { | |||||
| if (mi->rigidbody != NULL) { | |||||
| mi->rigidbody->flag = flag; | |||||
| mi->rigidbody->shape = shape; | |||||
| if (reset) { | |||||
| if (mi->rigidbody->physics_shape) | |||||
| mi->rigidbody->flag |= RBO_FLAG_NEEDS_RESHAPE; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
Not Done Inline Actionshaving to look inside all modifiers mesh islands on RNA update seems very heavy for an update function. It seems like you're working around each shard not being a real object or apart of the depsgraph. But this isnt so simple to solve, perhaps these shards could be moved into the depsgraph (not trivial), campbellbarton: having to look inside all modifiers mesh islands on RNA update seems very heavy for an update… | |||||
| static void rna_RigidBodyOb_reset(Main *bmain, Scene *scene, PointerRNA *ptr) | |||||
| { | { | ||||
| RigidBodyWorld *rbw = scene->rigidbody_world; | RigidBodyWorld *rbw = scene->rigidbody_world; | ||||
| Object *ob = ptr->id.data; | |||||
| RigidBodyOb* rbo = ptr->data; | |||||
| foreach_shard_flag_shape(ob, rbo->flag, rbo->shape, false); | |||||
| BKE_rigidbody_cache_reset(rbw); | BKE_rigidbody_cache_reset(rbw); | ||||
| } | } | ||||
| static void rna_RigidBodyOb_shape_reset(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) | static void rna_RigidBodyOb_shape_reset(Main *bmain, Scene *scene, PointerRNA *ptr) | ||||
| { | { | ||||
| RigidBodyWorld *rbw = scene->rigidbody_world; | RigidBodyWorld *rbw = scene->rigidbody_world; | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object *ob = ptr->id.data; | |||||
| foreach_shard_flag_shape(ob, rbo->flag, rbo->shape, true); | |||||
| BKE_rigidbody_cache_reset(rbw); | BKE_rigidbody_cache_reset(rbw); | ||||
| if (rbo->physics_shape) | if (rbo->physics_shape) | ||||
| rbo->flag |= RBO_FLAG_NEEDS_RESHAPE; | rbo->flag |= RBO_FLAG_NEEDS_RESHAPE; | ||||
| } | } | ||||
| static char *rna_RigidBodyOb_path(PointerRNA *UNUSED(ptr)) | static char *rna_RigidBodyOb_path(PointerRNA *ptr) | ||||
| { | { | ||||
| /* NOTE: this hardcoded path should work as long as only Objects have this */ | /* NOTE: this hardcoded path should work as long as only Objects have this */ | ||||
| return BLI_sprintfN("rigid_body"); | return BLI_sprintfN("rigid_body"); | ||||
| } | } | ||||
| static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value) | void set_type(RigidBodyOb* rbo, int value) { | ||||
| { | |||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | |||||
| rbo->type = value; | rbo->type = value; | ||||
| rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | ||||
| } | } | ||||
| static void rna_RigidBodyOb_shape_set(PointerRNA *ptr, int value) | static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object* ob = ptr->id.data; | |||||
| rbo->shape = value; | set_type(rbo, value); | ||||
| rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | foreach_shard_int(ob, value, set_type); | ||||
| } | } | ||||
| static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value) | |||||
| { | |||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | void set_disabled(RigidBodyOb* rbo, int value) { | ||||
| RB_FLAG_SET(rbo->flag, !value, RBO_FLAG_DISABLED); | int flag = value; | ||||
| flag = !flag; | |||||
| RB_FLAG_SET(rbo->flag, flag, RBO_FLAG_DISABLED); | |||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| /* update kinematic state if necessary - only needed for active bodies */ | /* update kinematic state if necessary - only needed for active bodies */ | ||||
| if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { | if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { | ||||
| RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo)); | RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo)); | ||||
| RB_body_set_kinematic_state(rbo->physics_object, !value); | RB_body_set_kinematic_state(rbo->physics_object, flag); | ||||
| rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value) | static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object *ob = ptr->id.data; | |||||
| set_disabled(rbo, value); | |||||
| foreach_shard_int(ob, value, set_disabled); | |||||
| } | |||||
| void set_mass(RigidBodyOb* rbo, float value) | |||||
| { | |||||
| rbo->mass = value; | rbo->mass = value; | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_friction_set(PointerRNA *ptr, float value) | static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object* ob = ptr->id.data; | |||||
| set_mass(rbo, value); | |||||
| //foreach_shard_float(ob, value, set_mass); | |||||
| foreach_shard_mass(ob); | |||||
| } | |||||
| void set_friction(RigidBodyOb* rbo, float value) | |||||
| { | |||||
| rbo->friction = value; | rbo->friction = value; | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_restitution_set(PointerRNA *ptr, float value) | static void rna_RigidBodyOb_friction_set(PointerRNA *ptr, float value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object* ob = ptr->id.data; | |||||
| set_friction(rbo, value); | |||||
| foreach_shard_float(ob, value, set_friction); | |||||
| } | |||||
| void set_restitution(RigidBodyOb *rbo, float value) | |||||
| { | |||||
| rbo->restitution = value; | rbo->restitution = value; | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| if (rbo->physics_object) { | if (rbo->physics_object) { | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_collision_margin_set(PointerRNA *ptr, float value) | static void rna_RigidBodyOb_restitution_set(PointerRNA *ptr, float value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object* ob = ptr->id.data; | |||||
| set_restitution(rbo, value); | |||||
| foreach_shard_float(ob, value, set_restitution); | |||||
| } | |||||
| void set_collision_margin(RigidBodyOb* rbo, float value) | |||||
| { | |||||
| rbo->margin = value; | rbo->margin = value; | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| Context not available. | |||||
| RB_shape_set_margin(rbo->physics_shape, RBO_GET_MARGIN(rbo)); | RB_shape_set_margin(rbo->physics_shape, RBO_GET_MARGIN(rbo)); | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | |||||
| static void rna_RigidBodyOb_collision_groups_set(PointerRNA *ptr, const int *values) | } | ||||
| static void rna_RigidBodyOb_collision_margin_set(PointerRNA *ptr, float value) | |||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object *ob = ptr->id.data; | |||||
| set_collision_margin(rbo, value); | |||||
| foreach_shard_float(ob, value, set_collision_margin); | |||||
| } | |||||
| void set_collision_groups(RigidBodyOb* rbo, const int *values) | |||||
| { | |||||
| int i; | int i; | ||||
| for (i = 0; i < 20; i++) { | for (i = 0; i < 20; i++) { | ||||
| Context not available. | |||||
| rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | ||||
| } | } | ||||
| static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value) | static void rna_RigidBodyOb_collision_groups_set(PointerRNA *ptr, const int *values) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object *ob = ptr->id.data; | |||||
| RB_FLAG_SET(rbo->flag, value, RBO_FLAG_KINEMATIC); | |||||
| set_collision_groups(rbo, values); | |||||
| foreach_shard_ints(ob, values, set_collision_groups); | |||||
| } | |||||
| void set_kinematic(RigidBodyOb *rbo, int value) | |||||
| { | |||||
| int flag = value; | |||||
| RB_FLAG_SET(rbo->flag, flag, RBO_FLAG_KINEMATIC); | |||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| /* update kinematic state if necessary */ | /* update kinematic state if necessary */ | ||||
| if (rbo->physics_object) { | if (rbo->physics_object) { | ||||
| RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo)); | RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo)); | ||||
| RB_body_set_kinematic_state(rbo->physics_object, value); | RB_body_set_kinematic_state(rbo->physics_object, flag); | ||||
| rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, int value) | static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object* ob = ptr->id.data; | |||||
| set_kinematic(rbo, value); //stupid casting but need only 1 function... | |||||
| foreach_shard_int(ob, value, set_kinematic); | |||||
| } | |||||
| void set_activation(RigidBodyOb* rbo, int value) | |||||
| { | |||||
| RB_FLAG_SET(rbo->flag, value, RBO_FLAG_USE_DEACTIVATION); | RB_FLAG_SET(rbo->flag, value, RBO_FLAG_USE_DEACTIVATION); | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_linear_sleepThresh_set(PointerRNA *ptr, float value) | static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, int value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object *ob = ptr->id.data; | |||||
| set_activation(rbo, value); | |||||
| foreach_shard_int(ob, value, set_activation); | |||||
| } | |||||
| void set_linear_sleepThresh(RigidBodyOb *rbo, float value) | |||||
| { | |||||
| rbo->lin_sleep_thresh = value; | rbo->lin_sleep_thresh = value; | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_angular_sleepThresh_set(PointerRNA *ptr, float value) | static void rna_RigidBodyOb_linear_sleepThresh_set(PointerRNA *ptr, float value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object *ob = ptr->id.data; | |||||
| set_linear_sleepThresh(rbo, value); | |||||
| foreach_shard_float(ob, value, set_linear_sleepThresh); | |||||
| } | |||||
| void set_angular_sleepThresh(RigidBodyOb *rbo, float value) | |||||
| { | |||||
| rbo->ang_sleep_thresh = value; | rbo->ang_sleep_thresh = value; | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_linear_damping_set(PointerRNA *ptr, float value) | static void rna_RigidBodyOb_angular_sleepThresh_set(PointerRNA *ptr, float value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object *ob = ptr->id.data; | |||||
| set_angular_sleepThresh(rbo, value); | |||||
| foreach_shard_float(ob, value, set_angular_sleepThresh); | |||||
| } | |||||
| void set_linear_damping(RigidBodyOb *rbo, float value) | |||||
| { | |||||
| rbo->lin_damping = value; | rbo->lin_damping = value; | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| static void rna_RigidBodyOb_angular_damping_set(PointerRNA *ptr, float value) | static void rna_RigidBodyOb_linear_damping_set(PointerRNA *ptr, float value) | ||||
| { | { | ||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | ||||
| Object *ob = ptr->id.data; | |||||
| set_linear_damping(rbo, value); | |||||
| foreach_shard_float(ob, value, set_linear_damping); | |||||
| } | |||||
| void set_angular_damping(RigidBodyOb *rbo, float value) | |||||
| { | |||||
| rbo->ang_damping = value; | rbo->ang_damping = value; | ||||
| #ifdef WITH_BULLET | #ifdef WITH_BULLET | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| static char *rna_RigidBodyCon_path(PointerRNA *UNUSED(ptr)) | static void rna_RigidBodyOb_angular_damping_set(PointerRNA *ptr, float value) | ||||
| { | |||||
| RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; | |||||
| Object *ob = ptr->id.data; | |||||
| set_angular_damping(rbo, value); | |||||
| foreach_shard_float(ob, value, set_angular_damping); | |||||
| } | |||||
| static char *rna_RigidBodyCon_path(PointerRNA *ptr) | |||||
| { | { | ||||
| /* NOTE: this hardcoded path should work as long as only Objects have this */ | /* NOTE: this hardcoded path should work as long as only Objects have this */ | ||||
| return BLI_sprintfN("rigid_body_constraint"); | return BLI_sprintfN("rigid_body_constraint"); | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| /* Sweep test */ | |||||
| static void rna_RigidBodyWorld_convex_sweep_test( | |||||
| RigidBodyWorld *rbw, ReportList *reports, | |||||
| Object *object, float ray_start[3], float ray_end[3], | |||||
| float r_location[3], float r_hitpoint[3], float r_normal[3], int *r_hit) | |||||
| { | |||||
| #ifdef WITH_BULLET | |||||
| RigidBodyOb *rob = object->rigidbody_object; | |||||
| if (rbw->physics_world != NULL && rob->physics_object != NULL) { | |||||
| RB_world_convex_sweep_test(rbw->physics_world, rob->physics_object, ray_start, ray_end, | |||||
| r_location, r_hitpoint, r_normal, r_hit); | |||||
| if (*r_hit == -2) { | |||||
| BKE_report(reports, RPT_ERROR, | |||||
| "A non convex collision shape was passed to the function, use only convex collision shapes"); | |||||
| } | |||||
| } | |||||
| else { | |||||
| *r_hit = -1; | |||||
| BKE_report(reports, RPT_ERROR, "Rigidbody world was not properly initialized, need to step the simulation first"); | |||||
| } | |||||
| #else | |||||
| (void)rbw, (void)reports, (void)object, (void)ray_start, (void)ray_end; | |||||
| (void)r_location, (void)r_hitpoint, (void)r_normal, (void)r_hit; | |||||
| #endif | |||||
| } | |||||
| #else | #else | ||||
| Context not available. | |||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| FunctionRNA *func; | |||||
| srna = RNA_def_struct(brna, "RigidBodyWorld", NULL); | srna = RNA_def_struct(brna, "RigidBodyWorld", NULL); | ||||
| RNA_def_struct_sdna(srna, "RigidBodyWorld"); | RNA_def_struct_sdna(srna, "RigidBodyWorld"); | ||||
| RNA_def_struct_ui_text(srna, "Rigid Body World", "Self-contained rigid body simulation environment and settings"); | RNA_def_struct_ui_text(srna, "Rigid Body World", "Self-contained rigid body simulation environment and settings"); | ||||
| Context not available. | |||||
| prop = RNA_def_property(srna, "steps_per_second", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "steps_per_second", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "steps_per_second"); | RNA_def_property_int_sdna(prop, NULL, "steps_per_second"); | ||||
| RNA_def_property_range(prop, 1, SHRT_MAX); | RNA_def_property_range(prop, 1, SHRT_MAX); | ||||
| RNA_def_property_ui_range(prop, 60, 1000, 1, -1); | RNA_def_property_ui_range(prop, 60, 1000, 1, 0); | ||||
Not Done Inline ActionsWhy is this changed? campbellbarton: Why is this changed? | |||||
| RNA_def_property_int_default(prop, 60); | RNA_def_property_int_default(prop, 60); | ||||
| RNA_def_property_ui_text(prop, "Steps Per Second", | RNA_def_property_ui_text(prop, "Steps Per Second", | ||||
| "Number of simulation steps taken per second (higher values are more accurate " | "Number of simulation steps taken per second (higher values are more accurate " | ||||
| Context not available. | |||||
| prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations"); | RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations"); | ||||
| RNA_def_property_range(prop, 1, 1000); | RNA_def_property_range(prop, 1, 1000); | ||||
| RNA_def_property_ui_range(prop, 10, 100, 1, -1); | RNA_def_property_ui_range(prop, 10, 100, 1, 0); | ||||
| RNA_def_property_int_default(prop, 10); | RNA_def_property_int_default(prop, 10); | ||||
| RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyWorld_num_solver_iterations_set", NULL); | RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyWorld_num_solver_iterations_set", NULL); | ||||
| RNA_def_property_ui_text(prop, "Solver Iterations", | RNA_def_property_ui_text(prop, "Solver Iterations", | ||||
| Context not available. | |||||
| RNA_def_property_struct_type(prop, "EffectorWeights"); | RNA_def_property_struct_type(prop, "EffectorWeights"); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_ui_text(prop, "Effector Weights", ""); | RNA_def_property_ui_text(prop, "Effector Weights", ""); | ||||
| /* Sweep test */ | |||||
| func = RNA_def_function(srna, "convex_sweep_test", "rna_RigidBodyWorld_convex_sweep_test"); | |||||
| RNA_def_function_ui_description(func, "Sweep test convex rigidbody against the current rigidbody world"); | |||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | |||||
| prop = RNA_def_pointer(func, "object", "Object", "", "Rigidbody object with a convex collision shape"); | |||||
| RNA_def_property_flag(prop, PROP_REQUIRED | PROP_NEVER_NULL); | |||||
| RNA_def_property_clear_flag(prop, PROP_THICK_WRAP); | |||||
| /* ray start and end */ | |||||
| prop = RNA_def_float_vector(func, "start", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); | |||||
| RNA_def_property_flag(prop, PROP_REQUIRED); | |||||
| prop = RNA_def_float_vector(func, "end", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); | |||||
| RNA_def_property_flag(prop, PROP_REQUIRED); | |||||
| prop = RNA_def_float_vector(func, "object_location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", | |||||
| "The hit location of this sweep test", -1e4, 1e4); | |||||
| RNA_def_property_flag(prop, PROP_THICK_WRAP); | |||||
| RNA_def_function_output(func, prop); | |||||
| prop = RNA_def_float_vector(func, "hitpoint", 3, NULL, -FLT_MAX, FLT_MAX, "Hitpoint", | |||||
| "The hit location of this sweep test", -1e4, 1e4); | |||||
| RNA_def_property_flag(prop, PROP_THICK_WRAP); | |||||
| RNA_def_function_output(func, prop); | |||||
| prop = RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", | |||||
| "The face normal at the sweep test hit location", -1e4, 1e4); | |||||
| RNA_def_property_flag(prop, PROP_THICK_WRAP); | |||||
| RNA_def_function_output(func, prop); | |||||
| prop = RNA_def_int(func, "has_hit", 0, 0, 0, "", "If the function has found collision point, value is 1, otherwise 0", 0, 0); | |||||
| RNA_def_function_output(func, prop); | |||||
| } | } | ||||
| static void rna_def_rigidbody_object(BlenderRNA *brna) | static void rna_def_rigidbody_object(BlenderRNA *brna) | ||||
| Context not available. | |||||
| prop = RNA_def_property(srna, "collision_shape", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "collision_shape", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_sdna(prop, NULL, "shape"); | RNA_def_property_enum_sdna(prop, NULL, "shape"); | ||||
| RNA_def_property_enum_items(prop, rigidbody_object_shape_items); | RNA_def_property_enum_items(prop, rigidbody_object_shape_items); | ||||
| RNA_def_property_enum_funcs(prop, NULL, "rna_RigidBodyOb_shape_set", NULL); | |||||
Not Done Inline ActionsWhy is this removed? campbellbarton: Why is this removed? | |||||
| RNA_def_property_ui_text(prop, "Collision Shape", "Collision Shape of object in Rigid Body Simulations"); | RNA_def_property_ui_text(prop, "Collision Shape", "Collision Shape of object in Rigid Body Simulations"); | ||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset"); | RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset"); | ||||
| Context not available. | |||||
| prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations"); | RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations"); | ||||
| RNA_def_property_range(prop, 1, 1000); | RNA_def_property_range(prop, 1, 1000); | ||||
| RNA_def_property_ui_range(prop, 1, 100, 1, -1); | RNA_def_property_ui_range(prop, 1, 100, 1, 0); | ||||
| RNA_def_property_int_default(prop, 10); | RNA_def_property_int_default(prop, 10); | ||||
| RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyCon_num_solver_iterations_set", NULL); | RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyCon_num_solver_iterations_set", NULL); | ||||
| RNA_def_property_ui_text(prop, "Solver Iterations", | RNA_def_property_ui_text(prop, "Solver Iterations", | ||||
| Context not available. | |||||
Why?