mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:47:41 +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,
|
y: 0,
|
||||||
z: 1 };
|
z: 1 };
|
||||||
|
|
||||||
var damping = 0.1;
|
var damping = 0;
|
||||||
|
|
||||||
var color = {
|
var color = {
|
||||||
red: 255,
|
red: 255,
|
||||||
|
@ -43,6 +43,7 @@ function draw(deltaTime) {
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
|
script: "file:///Users/zappoman/Development/HiFi/hifi/examples/entityScripts/changeColorOnCollision.js",
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
position: startPosition,
|
position: startPosition,
|
||||||
dimensions: {x: largeRadius, y: largeRadius, z: largeRadius},
|
dimensions: {x: largeRadius, y: largeRadius, z: largeRadius},
|
||||||
|
@ -84,6 +85,7 @@ function draw(deltaTime) {
|
||||||
if (numberEntitiesAdded <= MAX_ENTITIES) {
|
if (numberEntitiesAdded <= MAX_ENTITIES) {
|
||||||
var properties = {
|
var properties = {
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
|
script: "file:///Users/zappoman/Development/HiFi/hifi/examples/entityScripts/changeColorOnCollision.js",
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
position: center,
|
position: center,
|
||||||
dimensions: {x: entitySize, y: entitySize, z: entitySize},
|
dimensions: {x: entitySize, y: entitySize, z: entitySize},
|
||||||
|
|
|
@ -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