diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-09-08 20:15:42 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-09-08 20:15:42 +0400 |
commit | d9ffc99e66d659ac887d801b9cc071b4c3f9b8ab (patch) | |
tree | d88e83b5a9edab115081641d26c811b6aa22296a /source/blender/editors/physics/rigidbody_object.c | |
parent | 551ebaa3dd758bc1975548c28766bfa3159d3846 (diff) | |
parent | b1490e39dd1017e51984d8a34d226e869bbb25df (diff) |
Merge branch 'master' into soc-2014-viewport_fxsoc-2014-viewport_fx
I have resolved some differences, for instance selection code which was more or less a stub, to be
the same as master. This will have to be fixed later.
Conflicts:
CMakeLists.txt
intern/ghost/CMakeLists.txt
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_Window.cpp
intern/ghost/intern/GHOST_WindowWin32.cpp
intern/ghost/intern/GHOST_WindowX11.cpp
source/blender/blenlib/BLI_math_matrix.h
source/blender/blenlib/intern/math_matrix.c
source/blender/gpu/CMakeLists.txt
source/blender/gpu/GPU_select.h
source/blender/gpu/intern/gpu_buffers.c
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/gpu/intern/gpu_select.c
source/blender/gpu/shaders/gpu_shader_simple_vert.glsl
source/blender/nodes/CMakeLists.txt
Diffstat (limited to 'source/blender/editors/physics/rigidbody_object.c')
-rw-r--r-- | source/blender/editors/physics/rigidbody_object.c | 74 |
1 files changed, 1 insertions, 73 deletions
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index b46d79fc82e..13a3d7a523f 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -485,78 +485,6 @@ static EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C), PointerR /* ------------------------------------------ */ -/* helper function to calculate volume of rigidbody object */ -// TODO: allow a parameter to specify method used to calculate this? -static float rigidbody_object_calc_volume(Object *ob) -{ - RigidBodyOb *rbo = ob->rigidbody_object; - - float size[3] = {1.0f, 1.0f, 1.0f}; - float radius = 1.0f; - float height = 1.0f; - - float volume = 0.0f; - - /* if automatically determining dimensions, use the Object's boundbox - * - assume that all quadrics are standing upright on local z-axis - * - assume even distribution of mass around the Object's pivot - * (i.e. Object pivot is centralised in boundbox) - * - boundbox gives full width - */ - // XXX: all dimensions are auto-determined now... later can add stored settings for this - BKE_object_dimensions_get(ob, size); - - if (ELEM3(rbo->shape, RB_SHAPE_CAPSULE, RB_SHAPE_CYLINDER, RB_SHAPE_CONE)) { - /* take radius as largest x/y dimension, and height as z-dimension */ - radius = MAX2(size[0], size[1]) * 0.5f; - height = size[2]; - } - else if (rbo->shape == RB_SHAPE_SPHERE) { - /* take radius to the the largest dimension to try and encompass everything */ - radius = max_fff(size[0], size[1], size[2]) * 0.5f; - } - - /* calculate volume as appropriate */ - switch (rbo->shape) { - case RB_SHAPE_BOX: - volume = size[0] * size[1] * size[2]; - break; - - case RB_SHAPE_SPHERE: - volume = 4.0f / 3.0f * (float)M_PI * radius * radius * radius; - break; - - /* for now, assume that capsule is close enough to a cylinder... */ - case RB_SHAPE_CAPSULE: - case RB_SHAPE_CYLINDER: - volume = (float)M_PI * radius * radius * height; - break; - - case RB_SHAPE_CONE: - volume = (float)M_PI / 3.0f * radius * radius * height; - break; - - /* for now, all mesh shapes are just treated as boxes... - * NOTE: this may overestimate the volume, but other methods are overkill - */ - case RB_SHAPE_CONVEXH: - case RB_SHAPE_TRIMESH: - volume = size[0] * size[1] * size[2]; - break; - -#if 0 // XXX: not defined yet - case RB_SHAPE_COMPOUND: - volume = 0.0f; - break; -#endif - } - - /* return the volume calculated */ - return volume; -} - -/* ------------------------------------------ */ - static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op) { int material = RNA_enum_get(op->ptr, "material"); @@ -589,7 +517,7 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op) /* mass is calculated from the approximate volume of the object, * and the density of the material we're simulating */ - volume = rigidbody_object_calc_volume(ob); + BKE_rigidbody_calc_volume(ob, &volume); mass = volume * density; /* use RNA-system to change the property and perform all necessary changes */ |