mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 23:09:52 +02:00
Merge pull request #3933 from ZappoMan/entityCollisions
move emit of collisions to after done moving entities, so that callbacks can delete entities
This commit is contained in:
commit
1697636db5
2 changed files with 8 additions and 8 deletions
|
@ -22,7 +22,7 @@ var velocity = {
|
||||||
y: 0,
|
y: 0,
|
||||||
z: 1 };
|
z: 1 };
|
||||||
|
|
||||||
var damping = 0.1;
|
var damping = 0;
|
||||||
|
|
||||||
var color = {
|
var color = {
|
||||||
red: 255,
|
red: 255,
|
||||||
|
|
|
@ -170,12 +170,6 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
||||||
|
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
|
||||||
Collision collision;
|
|
||||||
collision.penetration = penetration;
|
|
||||||
// for now the contactPoint is the average between the the two paricle centers
|
|
||||||
collision.contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition());
|
|
||||||
emitGlobalEntityCollisionWithEntity(entityA, entityB, collision);
|
|
||||||
|
|
||||||
glm::vec3 axis = glm::normalize(penetration);
|
glm::vec3 axis = glm::normalize(penetration);
|
||||||
glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
|
glm::vec3 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
|
||||||
|
|
||||||
|
@ -232,7 +226,13 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
||||||
// thereby waking up static non-moving entities.
|
// thereby waking up static non-moving entities.
|
||||||
_entityTree->updateEntity(entityB, propertiesB);
|
_entityTree->updateEntity(entityB, propertiesB);
|
||||||
_packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB);
|
_packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Do this after updating the entities so that the callback can delete the entities if they want to
|
||||||
|
Collision collision;
|
||||||
|
collision.penetration = penetration;
|
||||||
|
collision.contactPoint = (0.5f * (float)TREE_SCALE) * (entityA->getPosition() + entityB->getPosition());
|
||||||
|
emitGlobalEntityCollisionWithEntity(entityA, entityB, collision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue