Add support back for reinstancePhysics mesh, a frequently requested feature in the BGE forums.
from what I can tell Sumo supported this but bullet never did.
Currently only accessible via python at the moment.
- rigid body, dynamic, static types work.
- instanced physics meshes are modified too.
- compound shapes are not supported.
Physics mesh can be re-instanced from...
* shape keys & armature deformations
* subsurf (any other modifiers too)
* RAS_TexVert's (can be modified from python)
Moved the reinstancePhysicsMesh functions from RAS_MeshObject into KX_GameObject since the physics data is stored here.
video and blend file demo.
http://www.graphicall.org/ftp/ideasman42/reinstance.ogvhttp://www.graphicall.org/ftp/ideasman42/reinstance_demo.blend
Example is a cube that lands on a plane, sleeps after some time, a script changes the scale.
It would still use the scale when the object first went to sleep.
reported on blenderartist.
http://blenderartists.org/forum/showthread.php?t=158617
- Typo in occlusion variable init "m_buffer == NULL;" -> "m_buffer = NULL;"
CcdPhysicsEnvironment.cpp and CcdPhysicsController.cpp had too many warnings, fixed most of them.
http://blenderartists.org/forum/showpost.php?p=1382653&postcount=102
(todo: expose this setting in World setting GUI)
Expose contact processing threshold in Advanced GUI, next to rigid body margin, called CPT.
Default to 1, makes rigid body stacking a bit more stable, smaller values makes sliding easier (at the cost of easier jittering).
Disabled for 'dynamic' objects that don't rotate, because characters etc. always need smooth sliding.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
* Actor option: the collisioning object must have the Actor flag set to be detected
* property/material: as specified in the collision sensors attached to it
Broadphase filtering is important for performance reason: the collision points
will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
to the suface by increasing the margin in the Advanced Settings panel.
The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
because of the Scenegraph optimizations and they can have multiple collision sensors
on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
"warning btCollisionDispatcher::needsCollision: static-static collision!"
In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects
This commit completes the support for modifiers in the BGE.
- The physic shape is generated according to the derived mesh.
This is true for all types of shapes and all types of
objects except soft body.
- Optimization for static derived mesh (mesh with modifiers
but no armature and no shape keys). Replicas will share
the derived mesh and the display list: less memory and
faster rendering. With this optimization, the static
derived mesh will render as fast as if the modifiers were
applied.
Known Limits:
- Sharing of mesh and display list is only possible between
in-game replicas or dupligroup. If you want to instantiate
multiple objects with modifiers, use dupligroup to ensure
best memory and GPU utilization.
- rayCast() will interact with the derived mesh as follow:
Hit position and hit normal are the real values according
to the derived mesh but the KX_PolyProxy object refers to
the original mesh. You should use it only to retrieve the
material.
- Dynamic derived mesh have very poor performance:
They use direct openGL calls for rendering (no support
for display list and vertex array) and they dont't share
the derived mesh memory. Always apply modifiers on dynamic
mesh for best performance.
- Time dependent modifiers are not supported.
- Modifiers are not supported for Bullet soft body.
Clamp objects min/max velocity.
Accessed with bullet physics from the advanced button with dynamic and rigid body objects.
- useful for preventing unstable physics in cases where objects move too fast.
- can add linear velocity with the motion actuator to give smooth motion transitions, without moving too fast.
- minimum velocity means objects don't stop moving.
- python scripts can adjust these values speedup or throttle velocity in the existing direction.
Also made copy properties from an object with no properties work (in case you want to clear all props)
This commit contains a number of performance improvements for the
BGE in the Scenegraph (parent relation between objects in the
scene) and view frustrum culling.
The scenegraph improvement consists in avoiding position update
if the object has not moved since last update and the removal
of redundant updates and synchronization with the physics engine.
The view frustrum culling improvement consists in using the DBVT
broadphase facility of Bullet to build a tree of graphical objects
in the scene. The elements of the tree are Aabb boxes (Aligned
Axis Bounding Boxes) enclosing the objects. This provides good
precision in closed and opened scenes. This new culling system
is enabled by default but just in case, it can be disabled with
a button in the World settings. There is no do_version in this
commit but it will be added before the 2.49 release. For now you
must manually enable the DBVT culling option in World settings
when you open an old file.
The above improvements speed up scenegraph and culling up to 5x.
However, this performance improvement is only visible when
you have hundreds or thousands of objects.
The main interest of the DBVT tree is to allow easy occlusion
culling and automatic LOD system. This will be the object of further
improvements.
Was adding each face with a remove doubles option that made conversion increasingly slower for larger meshes, this would often hang blender when starting with the BGE with larger meshes.
Replace btTriangleMesh()->addTriangle() with btTriangleIndexVertexArray()
YoFrankie level_1_home.blend starts a third faster, level_nut about twice as fast.
- previous commit was also incorrect using the original meshes vert locations rather then the vert locations that came from the derived mesh.
- Softbody is relying on removing doubles at 0.01 to give stable results, this no longer works but seems a bit dodgy anyway. Maybe some post-processing filter could fix up a mesh for bullet softbody.
In a simple test with ~12000 verts, overall BGE startup time went from ~4.5 sec to a bit under a second.
- before adding each vert it did a check for a duplicates.
- Using RAS_Polygon verts can give a lot of duplicates because the verts also store UV's and normals.
- Was increasing the array one item at a time, now resize the array once.
- Use the blender mesh mvert array rather then RAS_TexVert's, so needed to include some DNA headers.
In particular, the Bullet vehicle seems broken, and some soft-body demos don't work.
No new features or benefits are added yet, but a few improvements are planned before Blender 2.49 release.
Please update the build systems, and add those 3 files:
extern/bullet2/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp
extern/bullet2/src/BulletCollision/CollisionDispatch/btGhostObject.cpp
extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp
I'll watch the Blender mailing list, in case this commit causes some issues.
btPoint3 has been deprecated, it was already a typedef to btVector3
replace std::vector by btAlignedObjectArray when storing Bullet objects, because MSVC STL implementation has some bugs, preventing to contain aligned objects
(btVector3 is 16-byte aligned, to allow SIMD)
This patch modifies the way the setParent actuator and KX_GameObject::setParent() function
works when parenting to a compound object: the collision shape of the object being parented
is dynamically added to the coumpound shape.
Similarly, unparenting an object from a compound object will cause the child collision shape
to be dynamically removed from the parent shape provided that is was previously added with
setParent.
Note: * This also works if the object is parented to a child of a compound object: the
collision shape is added to the compound shape of the top parent.
* The collision shape is added with the transformation (position, scale and orientation)
it had at the time of the parenting.
* The child shape is rigidly attached to the compound shape, the transformation is not
affected by any further change in position/scale/orientation of the child object.
* While the child shape is added to the compound shape, the child object is removed from
the dynamic world to avoid superposition of shapes (one for the object itself and
one for the compound child shape). This means that collision sensors on the child
object are disabled while the child object is parent to a compound object.
* There is no difference when setParent is used on a non-compound object: the child
object is automatically changed to a static ghost object to avoid bad interaction
with the parent shape; collision sensors on the child object continue to be active
while the object is parented.
* The child shape dynamically added to a compound shape modifies the inertia of the
compound object but not the mass. It participates to collision detection as any other
"static" child shape.
Implementation of the PHY_IPhysicsController::SetMargin(),
GetMargin(), SetRadius() and GetRadius() for Bullet and Sumo
to allow resetting the Near sensor radius. For bullet use
the new setUnscaledRadius() function to change sphere radius.
In pPreparation of a Fh constraint actuator:
- Add KX_IPhysicsController::GetRadius()
- Fix implementation of KX_BulletPhysicsController::GetVelocity()
(velocity at a point in geometric coordinate)
- Don't try to set velocity on static object (Bullet will assert)
- Add KX_GameObject::GetVelocity() for C access to local velocity
add -nojoystick commandline option: it takes 5 seconds everytime to start the game engine, while there IS no joystick.
In other words: blender -noaudio -nojoystick improves workflow turnaround times for P - ESC from 7 seconds to 1 second!
Improved Bullet soft body advanced options, still work-in-progress. Make sure to create game Bullet soft bodies from scratch, it is not compatible with last weeks builds.
Previously the distance constraint actuator was always working
in local axis. The local flag allows to cast the ray along a
world axis (when the flag is not selected).
The N flag works differently in this case: only the object
orientation is changed to be parallel to the normal at the hit
point.
The linear velocity is now changed so that the speed along the
ray axis is null. This eliminates the need to compensate the
gravity when casting along the Z axis.
Added Bullet/Gimpact concave collision detection to Blender. If your build system isn't updated yet, please add extern/bullet2/src/BulletCollision/Gimpact/*
This allows moving/dynamic concave triangle meshes (decomposing meshes into compound convex shapes, and using 'compound' shapes is still preferred)
set a fake world transform for game soft bodies, based on center of the AABB, so visiblity and some game logic works. note: this world transform is not smooth.
The Physics button controls the creation of a physics representation
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.
The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through
Python. By default, the collision margin is set to 0.0 on static
objects and 0.06 on dynamic objects.
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.
Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is
now kept "inside" the object for box, sphere and cylinder bound
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding.
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects.
The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions.
This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects:
center, shape, size, position of children, etc.
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
HELP BUILD SYSTEM MAINTAINERS: Please help with updating all build systems: the newly added files need to be added. Note that the src/SoftBody has been added for future extension of real-time soft bodies.