mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 01:23:57 +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,
|
||||
z: 1 };
|
||||
|
||||
var damping = 0.1;
|
||||
var damping = 0;
|
||||
|
||||
var color = {
|
||||
red: 255,
|
||||
|
|
|
@ -170,12 +170,6 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
|||
|
||||
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 axialVelocity = glm::dot(relativeVelocity, axis) * axis;
|
||||
|
||||
|
@ -232,7 +226,13 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
|||
// thereby waking up static non-moving entities.
|
||||
_entityTree->updateEntity(entityB, 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