mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-14 13:07:55 +02:00
DIRTY_PHYSICS_ACTIVATION not DIRTY_PHYSICS_NO_WAKE
also add separate flag for rotation and separate flags for linear vs angular velocity and some combined flag masks for convenience
This commit is contained in:
parent
c3901939e6
commit
195dd1420c
3 changed files with 27 additions and 18 deletions
|
@ -579,7 +579,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
READ_ENTITY_PROPERTY_STRING(PROP_MARKETPLACE_ID, setMarketplaceID);
|
||||
}
|
||||
|
||||
if (overwriteLocalData && (getDirtyFlags() & (EntityItem::DIRTY_POSITION | EntityItem::DIRTY_VELOCITY))) {
|
||||
if (overwriteLocalData && (getDirtyFlags() & (EntityItem::DIRTY_TRANSFORM | EntityItem::DIRTY_VELOCITIES))) {
|
||||
// NOTE: This code is attempting to "repair" the old data we just got from the server to make it more
|
||||
// closely match where the entities should be if they'd stepped forward in time to "now". The server
|
||||
// is sending us data with a known "last simulated" time. That time is likely in the past, and therefore
|
||||
|
@ -940,7 +940,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
|
|||
if (_created != UNKNOWN_CREATED_TIME) {
|
||||
setLastEdited(now);
|
||||
}
|
||||
if (getDirtyFlags() & (EntityItem::DIRTY_POSITION | EntityItem::DIRTY_VELOCITY)) {
|
||||
if (getDirtyFlags() & (EntityItem::DIRTY_TRANSFORM | EntityItem::DIRTY_VELOCITIES)) {
|
||||
// TODO: Andrew & Brad to discuss. Is this correct? Maybe it is. Need to think through all cases.
|
||||
_lastSimulated = now;
|
||||
}
|
||||
|
@ -1107,7 +1107,10 @@ void EntityItem::updatePositionInDomainUnits(const glm::vec3& value) {
|
|||
void EntityItem::updatePosition(const glm::vec3& value) {
|
||||
if (value != _position) {
|
||||
auto distance = glm::distance(_position, value);
|
||||
_dirtyFlags |= (distance > MIN_POSITION_DELTA) ? EntityItem::DIRTY_POSITION : EntityItem::DIRTY_PHYSICS_NO_WAKE;
|
||||
_dirtyFlags |= EntityItem::DIRTY_POSITION;
|
||||
if (distance > MIN_POSITION_DELTA) {
|
||||
dirtyFlags |= EntityItem::DIRTY_PHYSICS_ACTIVATION;
|
||||
}
|
||||
_position = value;
|
||||
}
|
||||
}
|
||||
|
@ -1127,7 +1130,10 @@ void EntityItem::updateDimensions(const glm::vec3& value) {
|
|||
void EntityItem::updateRotation(const glm::quat& rotation) {
|
||||
if (rotation != _rotation) {
|
||||
auto alignmentDot = glm::abs(glm::dot(_rotation, rotation));
|
||||
_dirtyFlags |= (alignmentDot < MIN_ALIGNMENT_DOT) ? EntityItem::DIRTY_POSITION : EntityItem::DIRTY_PHYSICS_NO_WAKE;
|
||||
_dirtyFlags |= EntityItem::DIRTY_ROTATION;
|
||||
if (alignmentDot < MIN_ALIGNMENT_DOT) {
|
||||
dirtyFlags |= EntityItem::DIRTY_PHYSICS_ACTIVATION;
|
||||
}
|
||||
_rotation = rotation;
|
||||
}
|
||||
}
|
||||
|
@ -1168,7 +1174,7 @@ void EntityItem::updateVelocity(const glm::vec3& value) {
|
|||
} else {
|
||||
_velocity = value;
|
||||
}
|
||||
_dirtyFlags |= EntityItem::DIRTY_VELOCITY;
|
||||
_dirtyFlags |= EntityItem::DIRTY_LINEAR_VELOCITY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,21 +1193,20 @@ void EntityItem::updateGravityInDomainUnits(const glm::vec3& value) {
|
|||
void EntityItem::updateGravity(const glm::vec3& value) {
|
||||
if (glm::distance(_gravity, value) > MIN_GRAVITY_DELTA) {
|
||||
_gravity = value;
|
||||
_dirtyFlags |= EntityItem::DIRTY_VELOCITY;
|
||||
_dirtyFlags |= EntityItem::DIRTY_LINEAR_VELOCITY;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityItem::updateAcceleration(const glm::vec3& value) {
|
||||
if (glm::distance(_acceleration, value) > MIN_ACCELERATION_DELTA) {
|
||||
_acceleration = value;
|
||||
_dirtyFlags |= EntityItem::DIRTY_VELOCITY;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityItem::updateAngularVelocity(const glm::vec3& value) {
|
||||
auto distance = glm::distance(_angularVelocity, value);
|
||||
if (distance > MIN_SPIN_DELTA) {
|
||||
_dirtyFlags |= EntityItem::DIRTY_VELOCITY;
|
||||
_dirtyFlags |= EntityItem::DIRTY_ANGULAR_VELOCITY;
|
||||
if (glm::length(value) < MIN_SPIN_DELTA) {
|
||||
_angularVelocity = ENTITY_ITEM_ZERO_VEC3;
|
||||
} else {
|
||||
|
|
|
@ -53,15 +53,19 @@ class EntityItem {
|
|||
public:
|
||||
enum EntityDirtyFlags {
|
||||
DIRTY_POSITION = 0x0001,
|
||||
DIRTY_VELOCITY = 0x0002,
|
||||
DIRTY_MASS = 0x0004,
|
||||
DIRTY_COLLISION_GROUP = 0x0008,
|
||||
DIRTY_MOTION_TYPE = 0x0010,
|
||||
DIRTY_SHAPE = 0x0020,
|
||||
DIRTY_LIFETIME = 0x0040,
|
||||
DIRTY_UPDATEABLE = 0x0080,
|
||||
DIRTY_MATERIAL = 0x00100,
|
||||
DIRTY_PHYSICS_NO_WAKE = 0x0200 // we want to update values in physics engine without "waking" the object up
|
||||
DIRTY_ROTATOION = 0x0002;
|
||||
DIRTY_LINEAR_VELOCITY = 0x0004,
|
||||
DIRTY_ANGULAR_VELOCITY = 0x0008,
|
||||
DIRTY_MASS = 0x0010,
|
||||
DIRTY_COLLISION_GROUP = 0x0020,
|
||||
DIRTY_MOTION_TYPE = 0x0040,
|
||||
DIRTY_SHAPE = 0x0080,
|
||||
DIRTY_LIFETIME = 0x0100,
|
||||
DIRTY_UPDATEABLE = 0x0200,
|
||||
DIRTY_MATERIAL = 0x00400,
|
||||
DIRTY_PHYSICS_ACTIVATION = 0x0800, // we want to activate the object
|
||||
DIRTY_TRANSFORM = DIRTY_POSITION | DIRTY_ROTATION,
|
||||
DIRTY_VELOCITIES = DIRTY_LINEAR_VELOCITY | DIRTY_ANGULAR_VELOCITY
|
||||
};
|
||||
|
||||
DONT_ALLOW_INSTANTIATION // This class can not be instantiated directly
|
||||
|
|
|
@ -146,7 +146,7 @@ void ObjectMotionState::handleEasyChanges(uint32_t flags) {
|
|||
_body->updateInertiaTensor();
|
||||
}
|
||||
|
||||
if (flags & EntityItem::DIRTY_ACTIVATION) {
|
||||
if (flags & EntityItem::DIRTY_PHYSICS_ACTIVATION) {
|
||||
_body->activate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue