Hooked up Bullet's internal debug draw functionality to our client.
Under the Developer > Physics Menu there are five new items:
* Show Bullet Collision - will draw all collision shapes in wireframe. WARNING: can be slow on large scenes.
* Show Bullet Bounding Boxes - will draw axis aligned bounding boxes around all physics shapes.
* Show Bullet Contact Points - will draw all contact points where two or more objects are colliding.
* Show Bullet Constraints - will render wire frame axes for each constraint connecting bodies together.
* Show Bullet Constraint Limits - will render the joint limits for each constraint.
This commit adds support for the polyhedrons and polygons sans
Torus and Quad which aren't currently supported within GeometryCache.
* Moves GeometryCache::_shapes from public to private scope
* Nothing aside from the class should be directly altering this, only querying
* Updated instances of direct referencing which looks to have been limited to prior
testing of instancing and shapes.
* Adds an accessor function for ShapeData to GeometryCache
* Consolidates point list generation to helper function
* GeometryCache::computeSimpleHullPointListForShape
* Moves GeometryCache::Shape to entity::Shape mapping to GeometryCache from
RenderableShapeEntityItem
* Adds conversion accessor to GeometryCache, GeometryCache::Shape getShapeForEntityShape
* Sets ShapeEntityItem::ShapeInfoCalculator callback committed earlier.
* This helps circumvent the issue with library inclusion. entity-render knows about
entity; however, entity doesn't know about entity-renderer; however, GeometryCache
data is needed within entity::ShapeEntityItem to compose the ShapeInfo point list data.
* This callback is set up within Application::init of the Interface as it knows about
both halves of the equation, and the callback needs to be setup prior to any entities
collision data getting generated.
* Removes _type reset within ShapeInfo::setPointCollection
* This should avoid any issues due to subversively setting the type or
incorrectly setting the type as a tangential operation.
* Audited instances of ShapeInfo::setPointCollection and all seemed to be
calling the function immediately after having set the type via
ShapeInfo::setParams
* Adds new ShapeType: SHAPE_TYPE_CIRCLE
* This type is reserved for the circle which is now treated as a special
type of Cylinder_Y with regard to collision as opposed to a simple hull.
* Fixes the issue where jumping on a circle, at times, would
result in the avatar sliding off towards an edge as if atop a
squished cone.
* Also updates ShapeInfo::getType() to return ShapeType as opposed to int
* Auditing calls showed that majority of places were comparing against ShapeType
* ShapeType::_type is a ShapeType so returning the type explicitly
is more consistent.
* ShapeInfo file houses ShapeType enum so any file aware of ShapeInfo is aware of
ShapeType enumeration.
* entity::Quad defaults to SHAPE_TYPE_ELLIPSOID
* Like entity::Shape::Torus, entity::Shape::Quad is currently unsupported within
GeometryCache::buildShapes.
* Also it appears that a Quad shape can't be created within world via the creation menu.
* There's no explicit option at present to create one.
* Trying subvert the Cube/Box creation option to generate one results in an enforced
stubby box as opposed to a quad.
* Given the aforementioned points, entity::Shape::Quad will default to
SHAPE_TYPE_ELLIPSOID as opposed to SHAPE_TYPE_BOX.
* Added Todo regarding the shape being unsupported along with a notation to create
a special ShapeType, SHAPE_TYPE_QUAD, for it should it be added in the future.
* Adds some comments and has some minor clean up.
Reviewed-by: Leander Hasty <leander@1stplayable.com>
Changes Committed:
modified: interface/src/Application.cpp
modified: interface/src/Util.cpp
modified: interface/src/Util.h
modified: libraries/entities-renderer/src/RenderableShapeEntityItem.cpp
modified: libraries/entities/src/ShapeEntityItem.cpp
modified: libraries/entities/src/ShapeEntityItem.h
modified: libraries/physics/src/ShapeFactory.cpp
modified: libraries/render-utils/src/GeometryCache.cpp
modified: libraries/render-utils/src/GeometryCache.h
modified: libraries/shared/src/ShapeInfo.cpp
modified: libraries/shared/src/ShapeInfo.h
modified: tests/gpu-test/src/TestInstancedShapes.cpp
This is a classic deadlock between the main thread and the OctreeProcessor network thread.
On the main thread, the EntitySimulation lock is taken before the EntityItem read lock is taken.
On the network thread, the EntityItem write lock is taken before the EntitySimulation lock is taken.
To work around this issue the network thread no longer takes the EntitySimulation lock when calling
PhysicalEntitySimulation::addDynamic(). Instead, a fine grained lock around the EntitySimulation's dynamic lists
is used instead.
https://github.com/highfidelity/hifi/pull/11024#pullrequestreview-51611518
Cleans up tabs, moves new functionality out of ShapeFactory directly to
RenderableShapeEntityItem's computeShapeInfo override, begins to break down
where we will need pointlists.
Still need to determine how rotation is handled for pointlists, and check
for axis alignment on cylinders before deciding on a shape.
Changes to be committed:
modified: libraries/entities-renderer/src/RenderableShapeEntityItem.cpp
modified: libraries/entities-renderer/src/RenderableShapeEntityItem.h
modified: libraries/entities/CMakeLists.txt
modified: libraries/entities/src/ShapeEntityItem.cpp
modified: libraries/entities/src/ShapeEntityItem.h
modified: libraries/physics/src/ShapeFactory.cpp
modified: libraries/physics/src/ShapeFactory.h
modified: libraries/shared/src/ShapeInfo.cpp
modified: scripts/developer/tests/basicEntityTest/entitySpawner.js
* Addresses physics library dependency by moving computeShapeInfo override from
ShapeEntityItem (which is within Entities Library) to RenderableShapeEntityItem
(which is in Entities-Renderer Library).
** Entities-Renderer library already links against the physic library.
** Per discussion with Andrew Meadows: In order to ShapeEntityItem to be
utilized the library dependency between the Entity and Physics library
would need to be resolved to avoid the cyclical reliance which isn't in
the scope of this ticket.
* Updates shapeSpawner test script from the default clone of basicEntityTest\entitySpawner.js
** Objects now have a finite lifetime
** Script now cleans up the objects created when the script ends
** Also moved some adjustable properties out into var aliases at the top of the
file for easier/less error prone tweaking. Should probably add one for the shapeType.
* Fixes some issues with validateShapeType helper function
* Removed naive attempt at including physics library within entities library.
* Transferred some todos from notes
* Fixed some formatting
NOTE(s):
This compiles and runs. Cylinder is spawned and treated as CYLINDER_Y.
TODO(s):
* Add tweakable var for shapeType within shapeSpawner.js
* Vet and verify other shapes.
* Add in edge case handling.
* Add in support for other shapes to ShapeInfo infrastructure.
Changes to be committed:
modified: libraries/entities-renderer/src/RenderableShapeEntityItem.cpp
modified: libraries/entities-renderer/src/RenderableShapeEntityItem.h
modified: libraries/entities/CMakeLists.txt
modified: libraries/entities/src/ShapeEntityItem.cpp
modified: libraries/entities/src/ShapeEntityItem.h
modified: libraries/physics/src/ShapeFactory.cpp
modified: libraries/shared/src/ShapeInfo.cpp
modified: scripts/developer/tests/basicEntityTest/shapeSpawner.js
Revised approach involves creating a helper function within ShapeFactory to aid
in devising the ShapeType to be used by an ShapeEntityItem for collision. The
ShapeFactory is currently doing this for creating the actual Bullet Library
collision shapes.
ShapeEntityItem overrides its virtually inherited computeShapeInfo which
in turn calls the new ShapeFactory helper function.
ShapeEntityItem has a new memvar _collisionShapeType to cache its actual
ShapeType used by the physics system. This memvar is returned via the getShapeType
accessor which is expected to return an object's ShapeType.
Note(s):
This is similar to the original approach save translation between entity::Shape and ShapeType
isn't tied to the EntityItemProperties shapeTypeNames or shapeType. This approach more
directly solves the issue of getting the actual ShapeType used by the time it's needed
to determine the bullet collision object type created when initializing the physic information.
Translation of the ShapeEntityItem's entity::Shape to its ShapeType is handled by
ShapeFactory which handles creating the bullet collision objects when setting up
physics on the ShapeEntityItems.
Known Issue(s):
This doesn't compile. It appears that the Entity Library needs to know about
the Physics Library. The naive attempt at providing that link failed to resolve
all compilation issues.
Current Error:
C1083: Cannot open include file: btBulletDynamicsCommon.h:
No such file or directory (C:\projects\cusack\libraries\entities\src\ShapeEntityItem.cpp)
C:\projects\cusack\libraries\physics\src\ShapeFactory.h 15 1 entities
modified: libraries/entities-renderer/src/RenderableShapeEntityItem.cpp
modified: libraries/entities/CMakeLists.txt
modified: libraries/entities/src/ShapeEntityItem.cpp
modified: libraries/entities/src/ShapeEntityItem.h
modified: libraries/physics/src/ShapeFactory.cpp
modified: libraries/physics/src/ShapeFactory.h
modified: libraries/physics/src/ShapeInfo.cpp
modified: scripts/developer/tests/basicEntityTest/entitySpawner.js
new file: scripts/developer/tests/basicEntityTest/shapeSpawner.js