pull andrew's branch, add back in visual indicator of an entity being active in bullet

This commit is contained in:
Seth Alves 2015-05-05 13:14:22 -07:00
parent 8aafce6382
commit 1cd93b9ec8
8 changed files with 71 additions and 15 deletions

View file

@ -7,4 +7,9 @@ add_dependency_external_projects(glm)
find_package(GLM REQUIRED) find_package(GLM REQUIRED)
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
link_hifi_libraries(shared gpu script-engine render-utils) add_dependency_external_projects(bullet)
find_package(Bullet REQUIRED)
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})
link_hifi_libraries(shared gpu script-engine render-utils)

View file

@ -14,6 +14,7 @@
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <gpu/GPUConfig.h> #include <gpu/GPUConfig.h>
#include <DeferredLightingEffect.h> #include <DeferredLightingEffect.h>
#include <PhysicsEngine.h>
#include "RenderableDebugableEntityItem.h" #include "RenderableDebugableEntityItem.h"
@ -23,7 +24,6 @@ void RenderableDebugableEntityItem::renderBoundingBox(EntityItem* entity, Render
glm::vec3 center = entity->getCenter(); glm::vec3 center = entity->getCenter();
glm::vec3 dimensions = entity->getDimensions(); glm::vec3 dimensions = entity->getDimensions();
glm::quat rotation = entity->getRotation(); glm::quat rotation = entity->getRotation();
glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
glPushMatrix(); glPushMatrix();
glTranslatef(position.x, position.y, position.z); glTranslatef(position.x, position.y, position.z);
@ -34,14 +34,41 @@ void RenderableDebugableEntityItem::renderBoundingBox(EntityItem* entity, Render
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);
if (puffedOut) { if (puffedOut) {
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.2f, greenColor); glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.2f, redColor);
} else { } else {
glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, greenColor); DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, greenColor);
} }
glPopMatrix(); glPopMatrix();
glPopMatrix(); glPopMatrix();
} }
void RenderableDebugableEntityItem::renderHoverDot(EntityItem* entity, RenderArgs* args) {
glm::vec3 position = entity->getPosition();
glm::vec3 center = entity->getCenter();
glm::vec3 dimensions = entity->getDimensions();
glm::quat rotation = entity->getRotation();
glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f);
float radius = 0.05f;
glPushMatrix();
glTranslatef(position.x, position.y + dimensions.y + radius, position.z);
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glPushMatrix();
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(radius, radius, radius);
const int SLICES = 8;
const int STACKS = 8;
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, SLICES, STACKS, blueColor);
glPopMatrix();
glPopMatrix();
}
void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) { void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) {
bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP; bool debugSimulationOwnership = args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP;
@ -52,4 +79,8 @@ void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args)
renderBoundingBox(entity, args, true); renderBoundingBox(entity, args, true);
} }
} }
if (PhysicsEngine::physicsInfoIsActive(entity->getPhysicsInfo())) {
renderHoverDot(entity, args);
}
} }

View file

@ -17,6 +17,7 @@
class RenderableDebugableEntityItem { class RenderableDebugableEntityItem {
public: public:
static void renderBoundingBox(EntityItem* entity, RenderArgs* args, bool puffedOut); static void renderBoundingBox(EntityItem* entity, RenderArgs* args, bool puffedOut);
static void renderHoverDot(EntityItem* entity, RenderArgs* args);
static void render(EntityItem* entity, RenderArgs* args); static void render(EntityItem* entity, RenderArgs* args);
}; };

View file

@ -313,10 +313,10 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
// if this bitstream indicates that this node is the simulation owner, ignore any physics-related updates. // if this bitstream indicates that this node is the simulation owner, ignore any physics-related updates.
glm::vec3 savePosition = _position; glm::vec3 savePosition = _position;
glm::quat saveRotation = _rotation; glm::quat saveRotation = _rotation;
glm::vec3 saveVelocity = _velocity; // glm::vec3 saveVelocity = _velocity;
glm::vec3 saveAngularVelocity = _angularVelocity; // glm::vec3 saveAngularVelocity = _angularVelocity;
glm::vec3 saveGravity = _gravity; // glm::vec3 saveGravity = _gravity;
glm::vec3 saveAcceleration = _acceleration; // glm::vec3 saveAcceleration = _acceleration;
// Header bytes // Header bytes
@ -401,8 +401,10 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
if (lastEditedFromBufferAdjusted > now) { if (lastEditedFromBufferAdjusted > now) {
lastEditedFromBufferAdjusted = now; lastEditedFromBufferAdjusted = now;
} }
#if 0 // XXX
bool fromSameServerEdit = (lastEditedFromBuffer == _lastEditedFromRemoteInRemoteTime); bool fromSameServerEdit = (lastEditedFromBuffer == _lastEditedFromRemoteInRemoteTime);
#endif
#ifdef WANT_DEBUG #ifdef WANT_DEBUG
qCDebug(entities) << "data from server **************** "; qCDebug(entities) << "data from server **************** ";
@ -419,6 +421,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
bool ignoreServerPacket = false; // assume we'll use this server packet bool ignoreServerPacket = false; // assume we'll use this server packet
#if 0 // XXX Trying to eliminate this code as a possible source of deviation between interfaces
// If this packet is from the same server edit as the last packet we accepted from the server // If this packet is from the same server edit as the last packet we accepted from the server
// we probably want to use it. // we probably want to use it.
if (fromSameServerEdit) { if (fromSameServerEdit) {
@ -435,6 +438,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
ignoreServerPacket = true; ignoreServerPacket = true;
} }
} }
#endif
if (ignoreServerPacket) { if (ignoreServerPacket) {
overwriteLocalData = false; overwriteLocalData = false;
@ -618,10 +622,10 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
// this node, so our version has to be newer than what the packet contained. // this node, so our version has to be newer than what the packet contained.
_position = savePosition; _position = savePosition;
_rotation = saveRotation; _rotation = saveRotation;
_velocity = saveVelocity; // _velocity = saveVelocity;
_angularVelocity = saveAngularVelocity; // _angularVelocity = saveAngularVelocity;
_gravity = saveGravity; // _gravity = saveGravity;
_acceleration = saveAcceleration; // _acceleration = saveAcceleration;
} }
return bytesRead; return bytesRead;

View file

@ -145,8 +145,7 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro
// squash the physics-related changes. // squash the physics-related changes.
properties.setSimulatorIDChanged(false); properties.setSimulatorIDChanged(false);
properties.setPositionChanged(false); properties.setPositionChanged(false);
properties.setVelocityChanged(false); properties.setRotationChanged(false);
properties.setAccelerationChanged(false);
} else { } else {
qCDebug(entities) << "allowing simulatorID change"; qCDebug(entities) << "allowing simulatorID change";
} }

View file

@ -111,7 +111,8 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
_movingStepsWithoutSimulationOwner = 0; _movingStepsWithoutSimulationOwner = 0;
} }
if (_movingStepsWithoutSimulationOwner > 4) { // XXX maybe meters from our characterController ? if (_movingStepsWithoutSimulationOwner > 100) { // XXX maybe meters from our characterController ?
qDebug() << "XXX XXX XXX -- claiming something I saw moving";
setShouldClaimSimulationOwnership(true); setShouldClaimSimulationOwnership(true);
} }

View file

@ -405,3 +405,16 @@ void PhysicsEngine::setCharacterController(DynamicCharacterController* character
} }
} }
bool PhysicsEngine::physicsInfoIsActive(void* physicsInfo) {
if (!physicsInfo) {
return false;
}
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(physicsInfo);
btRigidBody* body = motionState->getRigidBody();
if (!body) {
return false;
}
return body->isActive();
}

View file

@ -92,6 +92,8 @@ public:
void dumpNextStats() { _dumpNextStats = true; } void dumpNextStats() { _dumpNextStats = true; }
static bool physicsInfoIsActive(void* physicsInfo);
private: private:
void removeContacts(ObjectMotionState* motionState); void removeContacts(ObjectMotionState* motionState);