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:
authorSergej Reich <sergej.reich@googlemail.com>2013-01-23 09:56:22 +0400
committerSergej Reich <sergej.reich@googlemail.com>2013-01-23 09:56:22 +0400
commit27601aaf017263bf356dce37a4b90a764a819ee7 (patch)
tree8fb82ff4a5681a93a77883603786d730da13b4c4 /source/blender/blenkernel/BKE_rigidbody.h
parent5c85deb28570a911e825af5923a7939ca5781ee7 (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/BKE_rigidbody.h')
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
new file mode 100644
index 00000000000..26a003841c4
--- /dev/null
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -0,0 +1,94 @@
+/*
+ * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2013 Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Joshua Leung, Sergej Reich
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file BKE_rigidbody.h
+ * \ingroup blenkernel
+ * \brief API for Blender-side Rigid Body stuff
+ */
+
+
+#ifndef __BKE_RIGIDBODY_H__
+#define __BKE_RIGIDBODY_H__
+
+struct RigidBodyWorld;
+struct RigidBodyOb;
+
+struct Scene;
+struct Object;
+struct Group;
+
+/* -------------- */
+/* Memory Management */
+
+void BKE_rigidbody_free_world(struct RigidBodyWorld *rbw);
+void BKE_rigidbody_free_object(struct Object *ob);
+void BKE_rigidbody_free_constraint(struct Object *ob);
+
+/* ...... */
+
+struct RigidBodyOb *BKE_rigidbody_copy_object(struct Object *ob);
+struct RigidBodyCon *BKE_rigidbody_copy_constraint(struct Object *ob);
+
+/* -------------- */
+/* Setup */
+
+/* create Blender-side settings data - physics objects not initialised yet */
+struct RigidBodyWorld *BKE_rigidbody_create_world(struct Scene *scene);
+struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Object *ob, short type);
+struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type);
+
+/* 'validate' (i.e. make new or replace old) Physics-Engine objects */
+void BKE_rigidbody_validate_sim_world(struct Scene *scene, struct RigidBodyWorld *rbw, short rebuild);
+void BKE_rigidbody_validate_sim_object(struct RigidBodyWorld *rbw, struct Object *ob, short rebuild);
+void BKE_rigidbody_validate_sim_shape(struct Object *ob, short rebuild);
+void BKE_rigidbody_validate_sim_constraint(struct RigidBodyWorld *rbw, struct Object *ob, short rebuild);
+
+/* -------------- */
+/* Utilities */
+
+struct RigidBodyWorld *BKE_rigidbody_get_world(struct Scene *scene);
+void BKE_rigidbody_remove_object(struct Scene *scene, struct Object *ob);
+void BKE_rigidbody_remove_constraint(struct Scene *scene, struct Object *ob);
+
+/* -------------- */
+/* Utility Macros */
+
+/* get mass of Rigid Body Object to supply to RigidBody simulators */
+#define RBO_GET_MASS(rbo) \
+ ((rbo && ((rbo->type == RBO_TYPE_PASSIVE) || (rbo->flag & RBO_FLAG_KINEMATIC) || (rbo->flag & RBO_FLAG_DISABLED))) ? (0.0f) : (rbo->mass))
+/* get collision margin for Rigid Body Object, triangle mesh and cone shapes cannot embed margin, convex hull always uses custom margin */
+#define RBO_GET_MARGIN(rbo) \
+ ((rbo->flag & RBO_FLAG_USE_MARGIN || rbo->shape == RB_SHAPE_CONVEXH || rbo->shape == RB_SHAPE_TRIMESH || rbo->shape == RB_SHAPE_CONE) ? (rbo->margin) : (0.04f))
+
+/* -------------- */
+/* Simulation */
+
+void BKE_rigidbody_sync_transforms(struct Scene *scene, struct Object *ob, float ctime);
+void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw);
+void BKE_rigidbody_do_simulation(struct Scene *scene, float ctime);
+
+#endif /* __BKE_RIGIDBODY_H__ */