mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 13:03:55 +02:00
Merge pull request #6891 from sethalves/avatar-updates-query-cube
Avatar updates query cube
This commit is contained in:
commit
86b2a67f72
3 changed files with 40 additions and 0 deletions
|
@ -50,6 +50,8 @@
|
|||
#include "Util.h"
|
||||
#include "InterfaceLogging.h"
|
||||
#include "DebugDraw.h"
|
||||
#include "EntityEditPacketSender.h"
|
||||
#include "MovingEntitiesOperator.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -363,6 +365,37 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
|
||||
// consider updating our billboard
|
||||
maybeUpdateBillboard();
|
||||
|
||||
locationChanged();
|
||||
// if a entity-child of this avatar has moved outside of its queryAACube, update the cube and tell the entity server.
|
||||
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
||||
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
||||
if (entityTree) {
|
||||
EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender();
|
||||
MovingEntitiesOperator moveOperator(entityTree);
|
||||
forEachDescendant([&](SpatiallyNestablePointer object) {
|
||||
// if the queryBox has changed, tell the entity-server
|
||||
if (object->computePuffedQueryAACube() && object->getNestableType() == NestableType::Entity) {
|
||||
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
|
||||
bool success;
|
||||
AACube newCube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
moveOperator.addEntityToMoveList(entity, newCube);
|
||||
}
|
||||
if (packetSender) {
|
||||
EntityItemProperties properties = entity->getProperties();
|
||||
properties.setQueryAACubeDirty();
|
||||
packetSender->queueEditEntityMessage(PacketType::EntityEdit, entity->getID(), properties);
|
||||
entity->setLastBroadcast(usecTimestampNow());
|
||||
}
|
||||
}
|
||||
});
|
||||
// also update the position of children in our local octree
|
||||
if (moveOperator.hasMovingEntities()) {
|
||||
PerformanceTimer perfTimer("recurseTreeWithOperator");
|
||||
entityTree->recurseTreeWithOperator(&moveOperator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glm::mat4 MyAvatar::getSensorToWorldMatrix() const {
|
||||
|
|
|
@ -252,6 +252,8 @@ public:
|
|||
|
||||
void setLinePointsDirty() {_linePointsChanged = true; }
|
||||
|
||||
void setQueryAACubeDirty() { _queryAACubeChanged = true; }
|
||||
|
||||
void setCreated(QDateTime& v);
|
||||
|
||||
bool hasTerseUpdateChanges() const;
|
||||
|
|
|
@ -144,7 +144,12 @@ PhysicsMotionType EntityMotionState::computePhysicsMotionType() const {
|
|||
return MOTION_TYPE_STATIC;
|
||||
}
|
||||
assert(entityTreeIsLocked());
|
||||
|
||||
if (_entity->getDynamic()) {
|
||||
if (!_entity->getParentID().isNull()) {
|
||||
// if something would have been dynamic but is a child of something else, force it to be kinematic, instead.
|
||||
return MOTION_TYPE_KINEMATIC;
|
||||
}
|
||||
return MOTION_TYPE_DYNAMIC;
|
||||
}
|
||||
return (_entity->isMoving() || _entity->hasActions()) ? MOTION_TYPE_KINEMATIC : MOTION_TYPE_STATIC;
|
||||
|
|
Loading…
Reference in a new issue