From ef7e908675e7fdaebc6e73d8aec2f1468e217f6e Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 30 Sep 2015 18:03:15 -0700 Subject: [PATCH 1/3] allow dynamic objects to be set collisionless --- libraries/entities/src/BoxEntityItem.h | 1 + libraries/entities/src/EntityItem.h | 2 +- libraries/entities/src/SphereEntityItem.h | 1 + libraries/physics/src/EntityMotionState.cpp | 6 ++++++ libraries/physics/src/ObjectMotionState.h | 8 ++++---- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/entities/src/BoxEntityItem.h b/libraries/entities/src/BoxEntityItem.h index fdc66dd3e5..cc3bba4823 100644 --- a/libraries/entities/src/BoxEntityItem.h +++ b/libraries/entities/src/BoxEntityItem.h @@ -52,6 +52,7 @@ public: } virtual ShapeType getShapeType() const { return SHAPE_TYPE_BOX; } + virtual bool shouldBePhysical() const { return true; } virtual void debugDump() const; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 62b436b498..f070e2c1e4 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -334,7 +334,7 @@ public: bool getCollisionsWillMove() const { return _collisionsWillMove; } void setCollisionsWillMove(bool value) { _collisionsWillMove = value; } - virtual bool shouldBePhysical() const { return !_ignoreForCollisions; } + virtual bool shouldBePhysical() const { return false; } bool getLocked() const { return _locked; } void setLocked(bool value) { _locked = value; } diff --git a/libraries/entities/src/SphereEntityItem.h b/libraries/entities/src/SphereEntityItem.h index 19ea5d06f9..81a6cf704c 100644 --- a/libraries/entities/src/SphereEntityItem.h +++ b/libraries/entities/src/SphereEntityItem.h @@ -51,6 +51,7 @@ public: } virtual ShapeType getShapeType() const { return SHAPE_TYPE_SPHERE; } + virtual bool shouldBePhysical() const { return true; } virtual bool supportsDetailedRayIntersection() const { return true; } virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index ff546dbb0b..9cbe89dda6 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -596,6 +596,12 @@ QString EntityMotionState::getName() { // virtual int16_t EntityMotionState::computeCollisionGroup() { + if (!_entity) { + return COLLISION_GROUP_STATIC; + } + if (_entity->getIgnoreForCollisions()) { + return COLLISION_GROUP_COLLISIONLESS; + } switch (computeObjectMotionType()){ case MOTION_TYPE_STATIC: return COLLISION_GROUP_STATIC; diff --git a/libraries/physics/src/ObjectMotionState.h b/libraries/physics/src/ObjectMotionState.h index 1bdf8b6372..61254e49bd 100644 --- a/libraries/physics/src/ObjectMotionState.h +++ b/libraries/physics/src/ObjectMotionState.h @@ -37,11 +37,11 @@ enum MotionStateType { // The update flags trigger two varieties of updates: "hard" which require the body to be pulled // and re-added to the physics engine and "easy" which just updates the body properties. -const uint32_t HARD_DIRTY_PHYSICS_FLAGS = (uint32_t)(EntityItem::DIRTY_MOTION_TYPE | EntityItem::DIRTY_SHAPE); +const uint32_t HARD_DIRTY_PHYSICS_FLAGS = (uint32_t)(EntityItem::DIRTY_MOTION_TYPE | EntityItem::DIRTY_SHAPE | + EntityItem::DIRTY_COLLISION_GROUP); const uint32_t EASY_DIRTY_PHYSICS_FLAGS = (uint32_t)(EntityItem::DIRTY_TRANSFORM | EntityItem::DIRTY_VELOCITIES | - EntityItem::DIRTY_MASS | EntityItem::DIRTY_COLLISION_GROUP | - EntityItem::DIRTY_MATERIAL | EntityItem::DIRTY_SIMULATOR_ID | - EntityItem::DIRTY_SIMULATOR_OWNERSHIP); + EntityItem::DIRTY_MASS | EntityItem::DIRTY_MATERIAL | + EntityItem::DIRTY_SIMULATOR_ID | EntityItem::DIRTY_SIMULATOR_OWNERSHIP); // These are the set of incoming flags that the PhysicsEngine needs to hear about: const uint32_t DIRTY_PHYSICS_FLAGS = (uint32_t)(HARD_DIRTY_PHYSICS_FLAGS | EASY_DIRTY_PHYSICS_FLAGS | From 22b66077604e699d1725cc4c44e1a9594993b080 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 30 Sep 2015 18:15:34 -0700 Subject: [PATCH 2/3] add polyvox entities to physics engine --- libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h index e1e042f3d0..ef44ba5ab0 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h @@ -79,6 +79,7 @@ public: glm::mat4 localToVoxelMatrix() const; virtual ShapeType getShapeType() const; + virtual bool shouldBePhysical() const { return true; } virtual bool isReadyToComputeShape(); virtual void computeShapeInfo(ShapeInfo& info); From 381c98c4fa268b09ec81c85d38ad4a8676a58db0 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 30 Sep 2015 18:32:08 -0700 Subject: [PATCH 3/3] fix for ModelEntityItem::shouldBePhysical() --- libraries/entities/src/ModelEntityItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 70747937d8..cd9e3cd3e1 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -457,5 +457,5 @@ QString ModelEntityItem::getAnimationSettings() const { // virtual bool ModelEntityItem::shouldBePhysical() const { - return EntityItem::shouldBePhysical() && getShapeType() != SHAPE_TYPE_NONE; + return getShapeType() != SHAPE_TYPE_NONE; }