diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2013-01-23 09:56:22 +0400 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2013-01-23 09:56:22 +0400 |
commit | 27601aaf017263bf356dce37a4b90a764a819ee7 (patch) | |
tree | 8fb82ff4a5681a93a77883603786d730da13b4c4 /source/blender/blenkernel/intern/scene.c | |
parent | 5c85deb28570a911e825af5923a7939ca5781ee7 (diff) |
rigidbody: Add DNA/RNA/BKE infrastructure for the rigid body sim
This is just the basic structure, the simulation isn't hooked up yet.
Scenes get a pointer to a rigid body world that holds rigid body objects.
Objects get a pointer to a rigdid body object.
Both rigid body world and objects aren't used directly in the simulation
and only hold information to create the actual physics objects.
Physics objects are created when rigid body objects are validated.
In order to keep blender and bullet objects in sync care has to be taken
to either call appropriate set functions or flag objects for validation.
Part of GSoC 2010 and 2012.
Authors: Joshua Leung (aligorith), Sergej Reich (sergof)
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9cf0724f82a..e48cf369d4f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -46,6 +46,7 @@ #include "DNA_group_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" +#include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_sequence_types.h" @@ -72,6 +73,7 @@ #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_pointcache.h" +#include "BKE_rigidbody.h" #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_world.h" @@ -310,6 +312,9 @@ void BKE_scene_free(Scene *sce) BKE_free_animdata((ID *)sce); BKE_keyingsets_free(&sce->keyingsets); + if (sce->rigidbody_world) + BKE_rigidbody_free_world(sce->rigidbody_world); + if (sce->r.avicodecdata) { free_avicodecdata(sce->r.avicodecdata); MEM_freeN(sce->r.avicodecdata); @@ -936,6 +941,16 @@ Base *BKE_scene_base_add(Scene *sce, Object *ob) return b; } +void BKE_scene_base_remove(Scene *sce, Base *base) +{ + /* remove rigid body object from world before removing object */ + if (base->object->rigidbody_object) + BKE_rigidbody_remove_object(sce, base->object); + + BLI_remlink(&sce->base, base); + MEM_freeN(base); +} + void BKE_scene_base_deselect_all(Scene *sce) { Base *b; @@ -1376,3 +1391,8 @@ int BKE_scene_check_color_management_enabled(const Scene *scene) { return strcmp(scene->display_settings.display_device, "None") != 0; } + +int BKE_scene_check_rigidbody_active(const Scene *scene) +{ + return scene && scene->rigidbody_world && scene->rigidbody_world->group && !(scene->rigidbody_world->flag & RBW_FLAG_MUTED); +} |