mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-08 07:02:25 +02:00
Make the changes - big thanks to Andrew!
This commit is contained in:
parent
aa4059eb05
commit
4d791211ee
4 changed files with 19 additions and 8 deletions
|
@ -1091,15 +1091,18 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons
|
|||
|
||||
// trigger scripted collision sounds and events for locally owned objects
|
||||
EntityItemPointer entityA = entityTree->findEntityByEntityItemID(idA);
|
||||
if ((bool)entityA && myNodeID == entityA->getSimulatorID()) {
|
||||
EntityItemPointer entityB = entityTree->findEntityByEntityItemID(idB);
|
||||
QUuid entityASimulatorID = entityA->getSimulatorID();
|
||||
QUuid entityBSimulatorID = entityB->getSimulatorID();
|
||||
if ((bool)entityA && (myNodeID == entityASimulatorID || ((bool)entityB && myNodeID == entityBSimulatorID && entityASimulatorID.isNull()))) {
|
||||
playEntityCollisionSound(entityA, collision);
|
||||
emit collisionWithEntity(idA, idB, collision);
|
||||
if (_entitiesScriptEngine) {
|
||||
_entitiesScriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision);
|
||||
}
|
||||
}
|
||||
EntityItemPointer entityB = entityTree->findEntityByEntityItemID(idB);
|
||||
if ((bool)entityB && myNodeID == entityB->getSimulatorID()) {
|
||||
|
||||
if ((bool)entityB && (myNodeID == entityBSimulatorID || ((bool)entityA && myNodeID == entityASimulatorID && entityBSimulatorID.isNull()))) {
|
||||
playEntityCollisionSound(entityB, collision);
|
||||
// since we're swapping A and B we need to send the inverted collision
|
||||
Collision invertedCollision(collision);
|
||||
|
|
|
@ -1824,10 +1824,15 @@ bool EntityItemProperties::hasTerseUpdateChanges() const {
|
|||
return _positionChanged || _velocityChanged || _rotationChanged || _angularVelocityChanged || _accelerationChanged;
|
||||
}
|
||||
|
||||
bool EntityItemProperties::hasDynamicPhysicsChanges() const {
|
||||
return _dynamicChanged || _velocityChanged || _angularVelocityChanged || _accelerationChanged;
|
||||
}
|
||||
|
||||
bool EntityItemProperties::hasMiscPhysicsChanges() const {
|
||||
return _gravityChanged || _dimensionsChanged || _densityChanged || _frictionChanged
|
||||
|| _restitutionChanged || _dampingChanged || _angularDampingChanged || _registrationPointChanged ||
|
||||
_compoundShapeURLChanged || _dynamicChanged || _collisionlessChanged || _collisionMaskChanged;
|
||||
_compoundShapeURLChanged || _collisionlessChanged || _collisionMaskChanged ||
|
||||
_rotationChanged || _positionChanged;
|
||||
}
|
||||
|
||||
void EntityItemProperties::clearSimulationOwner() {
|
||||
|
|
|
@ -274,6 +274,7 @@ public:
|
|||
void setCreated(QDateTime& v);
|
||||
|
||||
bool hasTerseUpdateChanges() const;
|
||||
bool hasDynamicPhysicsChanges() const;
|
||||
bool hasMiscPhysicsChanges() const;
|
||||
|
||||
void clearSimulationOwner();
|
||||
|
|
|
@ -414,15 +414,17 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
|||
entityFound = true;
|
||||
// make sure the properties has a type, so that the encode can know which properties to include
|
||||
properties.setType(entity->getType());
|
||||
bool hasTerseUpdateChanges = properties.hasTerseUpdateChanges();
|
||||
bool hasPhysicsChanges = properties.hasMiscPhysicsChanges() || hasTerseUpdateChanges;
|
||||
if (_bidOnSimulationOwnership && hasPhysicsChanges) {
|
||||
bool hasMiscPhysicsChanges = properties.hasMiscPhysicsChanges();
|
||||
bool hasDynamicsChanges = properties.hasDynamicPhysicsChanges();
|
||||
// _bidOnSimulationOwnership is set per-instance of the scripting interface.
|
||||
// It essentially corresponds to "Am I an AC or an Interface client?" - ACs will never bid.
|
||||
if ((_bidOnSimulationOwnership && ((hasMiscPhysicsChanges && entity->isMoving()) || hasDynamicsChanges))) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||
|
||||
if (entity->getSimulatorID() == myNodeID) {
|
||||
// we think we already own the simulation, so make sure to send ALL TerseUpdate properties
|
||||
if (hasTerseUpdateChanges) {
|
||||
if (properties.hasTerseUpdateChanges()) {
|
||||
entity->getAllTerseUpdateProperties(properties);
|
||||
}
|
||||
// TODO: if we knew that ONLY TerseUpdate properties have changed in properties AND the object
|
||||
|
|
Loading…
Reference in a new issue