mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 16:26:17 +02:00
move emit of collisions to after done moving entities, so that callbacks can delete entities
This commit is contained in:
parent
651e550063
commit
3c09ca71cb
2 changed files with 10 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,
|
||||
|
@ -43,6 +43,7 @@ function draw(deltaTime) {
|
|||
|
||||
var properties = {
|
||||
type: "Sphere",
|
||||
script: "file:///Users/zappoman/Development/HiFi/hifi/examples/entityScripts/changeColorOnCollision.js",
|
||||
collisionsWillMove: true,
|
||||
position: startPosition,
|
||||
dimensions: {x: largeRadius, y: largeRadius, z: largeRadius},
|
||||
|
@ -84,6 +85,7 @@ function draw(deltaTime) {
|
|||
if (numberEntitiesAdded <= MAX_ENTITIES) {
|
||||
var properties = {
|
||||
type: "Sphere",
|
||||
script: "file:///Users/zappoman/Development/HiFi/hifi/examples/entityScripts/changeColorOnCollision.js",
|
||||
collisionsWillMove: true,
|
||||
position: center,
|
||||
dimensions: {x: entitySize, y: entitySize, z: entitySize},
|
||||
|
|
|
@ -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