mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 12:09:52 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into metavoxels
This commit is contained in:
commit
cad8313e56
19 changed files with 136 additions and 160 deletions
|
@ -404,6 +404,13 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
|
||||||
|
|
||||||
bool lastNodeDidntFit = false; // assume each node fits
|
bool lastNodeDidntFit = false; // assume each node fits
|
||||||
if (!nodeData->elementBag.isEmpty()) {
|
if (!nodeData->elementBag.isEmpty()) {
|
||||||
|
|
||||||
|
quint64 lockWaitStart = usecTimestampNow();
|
||||||
|
_myServer->getOctree()->lockForRead();
|
||||||
|
quint64 lockWaitEnd = usecTimestampNow();
|
||||||
|
lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart);
|
||||||
|
quint64 encodeStart = usecTimestampNow();
|
||||||
|
|
||||||
OctreeElement* subTree = nodeData->elementBag.extract();
|
OctreeElement* subTree = nodeData->elementBag.extract();
|
||||||
|
|
||||||
/* TODO: Looking for a way to prevent locking and encoding a tree that is not
|
/* TODO: Looking for a way to prevent locking and encoding a tree that is not
|
||||||
|
@ -447,12 +454,6 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
|
||||||
// it seems like it may be a good idea to include the lock time as part of the encode time
|
// it seems like it may be a good idea to include the lock time as part of the encode time
|
||||||
// are reported to client. Since you can encode without the lock
|
// are reported to client. Since you can encode without the lock
|
||||||
nodeData->stats.encodeStarted();
|
nodeData->stats.encodeStarted();
|
||||||
|
|
||||||
quint64 lockWaitStart = usecTimestampNow();
|
|
||||||
_myServer->getOctree()->lockForRead();
|
|
||||||
quint64 lockWaitEnd = usecTimestampNow();
|
|
||||||
lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart);
|
|
||||||
quint64 encodeStart = usecTimestampNow();
|
|
||||||
|
|
||||||
bytesWritten = _myServer->getOctree()->encodeTreeBitstream(subTree, &_packetData, nodeData->elementBag, params);
|
bytesWritten = _myServer->getOctree()->encodeTreeBitstream(subTree, &_packetData, nodeData->elementBag, params);
|
||||||
|
|
||||||
|
|
|
@ -139,10 +139,10 @@ function drawLobby() {
|
||||||
MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15);
|
MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15);
|
||||||
|
|
||||||
// start the drone sound
|
// start the drone sound
|
||||||
currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
// currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
||||||
|
|
||||||
// start one of our muzak sounds
|
// start one of our muzak sounds
|
||||||
playRandomMuzak();
|
// playRandomMuzak();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,9 +353,9 @@ function update(deltaTime) {
|
||||||
Overlays.editOverlay(descriptionText, { position: textOverlayPosition() });
|
Overlays.editOverlay(descriptionText, { position: textOverlayPosition() });
|
||||||
|
|
||||||
// if the reticle is up then we may need to play the next muzak
|
// if the reticle is up then we may need to play the next muzak
|
||||||
if (!Audio.isInjectorPlaying(currentMuzakInjector)) {
|
// if (!Audio.isInjectorPlaying(currentMuzakInjector)) {
|
||||||
playNextMuzak();
|
// playNextMuzak();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ Head::Head(Avatar* owningAvatar) :
|
||||||
_deltaRoll(0.0f),
|
_deltaRoll(0.0f),
|
||||||
_deltaLeanSideways(0.0f),
|
_deltaLeanSideways(0.0f),
|
||||||
_deltaLeanForward(0.0f),
|
_deltaLeanForward(0.0f),
|
||||||
_torsoTwist(0.0f),
|
|
||||||
_isCameraMoving(false),
|
_isCameraMoving(false),
|
||||||
_isLookingAtMe(false),
|
_isLookingAtMe(false),
|
||||||
_faceModel(this),
|
_faceModel(this),
|
||||||
|
|
|
@ -76,9 +76,6 @@ public:
|
||||||
float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; }
|
float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; }
|
||||||
float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; }
|
float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; }
|
||||||
|
|
||||||
float getTorsoTwist() const { return _torsoTwist; }
|
|
||||||
void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; }
|
|
||||||
|
|
||||||
glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
|
glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
|
||||||
|
|
||||||
const glm::vec3& getRightEyePosition() const { return _rightEyePosition; }
|
const glm::vec3& getRightEyePosition() const { return _rightEyePosition; }
|
||||||
|
@ -151,8 +148,6 @@ private:
|
||||||
// delta lean angles for lean perturbations (driven by collisions)
|
// delta lean angles for lean perturbations (driven by collisions)
|
||||||
float _deltaLeanSideways;
|
float _deltaLeanSideways;
|
||||||
float _deltaLeanForward;
|
float _deltaLeanForward;
|
||||||
|
|
||||||
float _torsoTwist;
|
|
||||||
|
|
||||||
bool _isCameraMoving;
|
bool _isCameraMoving;
|
||||||
bool _isLookingAtMe;
|
bool _isLookingAtMe;
|
||||||
|
|
|
@ -158,15 +158,18 @@ QByteArray AvatarData::toByteArray() {
|
||||||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
|
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
|
||||||
|
|
||||||
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
||||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalYaw());
|
glm::vec3 pitchYawRoll = glm::vec3(_headData->getFinalPitch(),
|
||||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalPitch());
|
_headData->getFinalYaw(),
|
||||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalRoll());
|
_headData->getFinalRoll());
|
||||||
|
if (this->isMyAvatar()) {
|
||||||
// Head lean X,Z (head lateral and fwd/back motion relative to torso)
|
glm::vec3 lean = glm::vec3(_headData->getFinalLeanForward(),
|
||||||
memcpy(destinationBuffer, &_headData->_leanSideways, sizeof(_headData->_leanSideways));
|
_headData->getTorsoTwist(),
|
||||||
destinationBuffer += sizeof(_headData->_leanSideways);
|
_headData->getFinalLeanSideways());
|
||||||
memcpy(destinationBuffer, &_headData->_leanForward, sizeof(_headData->_leanForward));
|
pitchYawRoll -= lean;
|
||||||
destinationBuffer += sizeof(_headData->_leanForward);
|
}
|
||||||
|
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.x);
|
||||||
|
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.y);
|
||||||
|
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.z);
|
||||||
|
|
||||||
// Lookat Position
|
// Lookat Position
|
||||||
memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition));
|
memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition));
|
||||||
|
@ -287,18 +290,16 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
// bodyPitch = 2 (compressed float)
|
// bodyPitch = 2 (compressed float)
|
||||||
// bodyRoll = 2 (compressed float)
|
// bodyRoll = 2 (compressed float)
|
||||||
// targetScale = 2 (compressed float)
|
// targetScale = 2 (compressed float)
|
||||||
// headYaw = 2 (compressed float)
|
|
||||||
// headPitch = 2 (compressed float)
|
// headPitch = 2 (compressed float)
|
||||||
|
// headYaw = 2 (compressed float)
|
||||||
// headRoll = 2 (compressed float)
|
// headRoll = 2 (compressed float)
|
||||||
// leanSideways = 4
|
|
||||||
// leanForward = 4
|
|
||||||
// lookAt = 12
|
// lookAt = 12
|
||||||
// audioLoudness = 4
|
// audioLoudness = 4
|
||||||
// }
|
// }
|
||||||
// + 1 byte for pupilSize
|
// + 1 byte for pupilSize
|
||||||
// + 1 byte for numJoints (0)
|
// + 1 byte for numJoints (0)
|
||||||
// = 53 bytes
|
// = 45 bytes
|
||||||
int minPossibleSize = 52;
|
int minPossibleSize = 45;
|
||||||
|
|
||||||
int maxAvailableSize = packet.size() - offset;
|
int maxAvailableSize = packet.size() - offset;
|
||||||
if (minPossibleSize > maxAvailableSize) {
|
if (minPossibleSize > maxAvailableSize) {
|
||||||
|
@ -356,8 +357,8 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
{ // Head rotation
|
{ // Head rotation
|
||||||
//(NOTE: This needs to become a quaternion to save two bytes)
|
//(NOTE: This needs to become a quaternion to save two bytes)
|
||||||
float headYaw, headPitch, headRoll;
|
float headYaw, headPitch, headRoll;
|
||||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
|
|
||||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headPitch);
|
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headPitch);
|
||||||
|
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
|
||||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headRoll);
|
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headRoll);
|
||||||
if (glm::isnan(headYaw) || glm::isnan(headPitch) || glm::isnan(headRoll)) {
|
if (glm::isnan(headYaw) || glm::isnan(headPitch) || glm::isnan(headRoll)) {
|
||||||
if (shouldLogError(now)) {
|
if (shouldLogError(now)) {
|
||||||
|
@ -365,27 +366,10 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
}
|
}
|
||||||
return maxAvailableSize;
|
return maxAvailableSize;
|
||||||
}
|
}
|
||||||
_headData->setBaseYaw(headYaw);
|
|
||||||
_headData->setBasePitch(headPitch);
|
_headData->setBasePitch(headPitch);
|
||||||
|
_headData->setBaseYaw(headYaw);
|
||||||
_headData->setBaseRoll(headRoll);
|
_headData->setBaseRoll(headRoll);
|
||||||
} // 6 bytes
|
} // 6 bytes
|
||||||
|
|
||||||
// Head lean (relative to pelvis)
|
|
||||||
{
|
|
||||||
float leanSideways, leanForward;
|
|
||||||
memcpy(&leanSideways, sourceBuffer, sizeof(float));
|
|
||||||
sourceBuffer += sizeof(float);
|
|
||||||
memcpy(&leanForward, sourceBuffer, sizeof(float));
|
|
||||||
sourceBuffer += sizeof(float);
|
|
||||||
if (glm::isnan(leanSideways) || glm::isnan(leanForward)) {
|
|
||||||
if (shouldLogError(now)) {
|
|
||||||
qDebug() << "Discard nan AvatarData::leanSideways,leanForward; displayName = '" << _displayName << "'";
|
|
||||||
}
|
|
||||||
return maxAvailableSize;
|
|
||||||
}
|
|
||||||
_headData->_leanSideways = leanSideways;
|
|
||||||
_headData->_leanForward = leanForward;
|
|
||||||
} // 8 bytes
|
|
||||||
|
|
||||||
{ // Lookat Position
|
{ // Lookat Position
|
||||||
glm::vec3 lookAt;
|
glm::vec3 lookAt;
|
||||||
|
|
|
@ -152,6 +152,8 @@ class AvatarData : public QObject {
|
||||||
public:
|
public:
|
||||||
AvatarData();
|
AvatarData();
|
||||||
virtual ~AvatarData();
|
virtual ~AvatarData();
|
||||||
|
|
||||||
|
virtual bool isMyAvatar() { return false; }
|
||||||
|
|
||||||
const QUuid& getSessionUUID() const { return _sessionUUID; }
|
const QUuid& getSessionUUID() const { return _sessionUUID; }
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
||||||
_baseRoll(0.0f),
|
_baseRoll(0.0f),
|
||||||
_leanSideways(0.0f),
|
_leanSideways(0.0f),
|
||||||
_leanForward(0.0f),
|
_leanForward(0.0f),
|
||||||
|
_torsoTwist(0.0f),
|
||||||
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
||||||
_audioLoudness(0.0f),
|
_audioLoudness(0.0f),
|
||||||
_isFaceshiftConnected(false),
|
_isFaceshiftConnected(false),
|
||||||
|
|
|
@ -71,11 +71,13 @@ public:
|
||||||
|
|
||||||
float getLeanSideways() const { return _leanSideways; }
|
float getLeanSideways() const { return _leanSideways; }
|
||||||
float getLeanForward() const { return _leanForward; }
|
float getLeanForward() const { return _leanForward; }
|
||||||
|
float getTorsoTwist() const { return _torsoTwist; }
|
||||||
virtual float getFinalLeanSideways() const { return _leanSideways; }
|
virtual float getFinalLeanSideways() const { return _leanSideways; }
|
||||||
virtual float getFinalLeanForward() const { return _leanForward; }
|
virtual float getFinalLeanForward() const { return _leanForward; }
|
||||||
|
|
||||||
void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; }
|
void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; }
|
||||||
void setLeanForward(float leanForward) { _leanForward = leanForward; }
|
void setLeanForward(float leanForward) { _leanForward = leanForward; }
|
||||||
|
void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; }
|
||||||
|
|
||||||
friend class AvatarData;
|
friend class AvatarData;
|
||||||
|
|
||||||
|
@ -86,6 +88,7 @@ protected:
|
||||||
float _baseRoll;
|
float _baseRoll;
|
||||||
float _leanSideways;
|
float _leanSideways;
|
||||||
float _leanForward;
|
float _leanForward;
|
||||||
|
float _torsoTwist;
|
||||||
|
|
||||||
glm::vec3 _lookAtPosition;
|
glm::vec3 _lookAtPosition;
|
||||||
float _audioLoudness;
|
float _audioLoudness;
|
||||||
|
|
|
@ -92,7 +92,8 @@ bool DeleteEntityOperator::preRecursion(OctreeElement* element) {
|
||||||
// and we can stop searching.
|
// and we can stop searching.
|
||||||
if (entityTreeElement == details.containingElement) {
|
if (entityTreeElement == details.containingElement) {
|
||||||
EntityItem* theEntity = details.entity;
|
EntityItem* theEntity = details.entity;
|
||||||
assert(entityTreeElement->removeEntityItem(theEntity)); // remove it from the element
|
bool entityDeleted = entityTreeElement->removeEntityItem(theEntity); // remove it from the element
|
||||||
|
assert(entityDeleted);
|
||||||
_tree->setContainingElement(details.entity->getEntityItemID(), NULL); // update or id to element lookup
|
_tree->setContainingElement(details.entity->getEntityItemID(), NULL); // update or id to element lookup
|
||||||
_foundCount++;
|
_foundCount++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,31 +21,6 @@
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
#include "EntityTree.h"
|
#include "EntityTree.h"
|
||||||
|
|
||||||
const float EntityItem::IMMORTAL = -1.0f; /// special lifetime which means the entity lives for ever. default lifetime
|
|
||||||
const float EntityItem::DEFAULT_GLOW_LEVEL = 0.0f;
|
|
||||||
const float EntityItem::DEFAULT_LOCAL_RENDER_ALPHA = 1.0f;
|
|
||||||
const float EntityItem::DEFAULT_MASS = 1.0f;
|
|
||||||
const float EntityItem::DEFAULT_LIFETIME = EntityItem::IMMORTAL;
|
|
||||||
const QString EntityItem::DEFAULT_USER_DATA = QString("");
|
|
||||||
const float EntityItem::DEFAULT_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header)
|
|
||||||
const glm::vec3 EntityItem::NO_VELOCITY = glm::vec3(0, 0, 0);
|
|
||||||
const float EntityItem::EPSILON_VELOCITY_LENGTH = (1.0f / 1000.0f) / (float)TREE_SCALE; // really small: 1mm/second
|
|
||||||
const glm::vec3 EntityItem::DEFAULT_VELOCITY = EntityItem::NO_VELOCITY;
|
|
||||||
const glm::vec3 EntityItem::NO_GRAVITY = glm::vec3(0, 0, 0);
|
|
||||||
const glm::vec3 EntityItem::REGULAR_GRAVITY = glm::vec3(0, (-9.8f / TREE_SCALE), 0);
|
|
||||||
const glm::vec3 EntityItem::DEFAULT_GRAVITY = EntityItem::NO_GRAVITY;
|
|
||||||
const QString EntityItem::DEFAULT_SCRIPT = QString("");
|
|
||||||
const glm::quat EntityItem::DEFAULT_ROTATION;
|
|
||||||
const glm::vec3 EntityItem::DEFAULT_DIMENSIONS = glm::vec3(0.1f, 0.1f, 0.1f);
|
|
||||||
const glm::vec3 EntityItem::DEFAULT_REGISTRATION_POINT = glm::vec3(0.5f, 0.5f, 0.5f); // center
|
|
||||||
const glm::vec3 EntityItem::NO_ANGULAR_VELOCITY = glm::vec3(0.0f, 0.0f, 0.0f);
|
|
||||||
const glm::vec3 EntityItem::DEFAULT_ANGULAR_VELOCITY = NO_ANGULAR_VELOCITY;
|
|
||||||
const float EntityItem::DEFAULT_ANGULAR_DAMPING = 2.0f;
|
|
||||||
const bool EntityItem::DEFAULT_VISIBLE = true;
|
|
||||||
const bool EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS = false;
|
|
||||||
const bool EntityItem::DEFAULT_COLLISIONS_WILL_MOVE = false;
|
|
||||||
const bool EntityItem::DEFAULT_LOCKED = false;
|
|
||||||
|
|
||||||
void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
||||||
_id = entityItemID.id;
|
_id = entityItemID.id;
|
||||||
_creatorTokenID = entityItemID.creatorTokenID;
|
_creatorTokenID = entityItemID.creatorTokenID;
|
||||||
|
@ -95,6 +70,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) {
|
||||||
_physicsInfo = NULL;
|
_physicsInfo = NULL;
|
||||||
_dirtyFlags = 0;
|
_dirtyFlags = 0;
|
||||||
_changedOnServer = 0;
|
_changedOnServer = 0;
|
||||||
|
_element = NULL;
|
||||||
initFromEntityItemID(entityItemID);
|
initFromEntityItemID(entityItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +86,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert
|
||||||
_physicsInfo = NULL;
|
_physicsInfo = NULL;
|
||||||
_dirtyFlags = 0;
|
_dirtyFlags = 0;
|
||||||
_changedOnServer = 0;
|
_changedOnServer = 0;
|
||||||
|
_element = NULL;
|
||||||
initFromEntityItemID(entityItemID);
|
initFromEntityItemID(entityItemID);
|
||||||
setProperties(properties);
|
setProperties(properties);
|
||||||
}
|
}
|
||||||
|
@ -117,6 +94,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert
|
||||||
EntityItem::~EntityItem() {
|
EntityItem::~EntityItem() {
|
||||||
// be sure to clean up _physicsInfo before calling this dtor
|
// be sure to clean up _physicsInfo before calling this dtor
|
||||||
assert(_physicsInfo == NULL);
|
assert(_physicsInfo == NULL);
|
||||||
|
assert(_element == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||||
|
@ -1015,7 +993,6 @@ void EntityItem::recalculateCollisionShape() {
|
||||||
entityAACube.scale(TREE_SCALE); // scale to meters
|
entityAACube.scale(TREE_SCALE); // scale to meters
|
||||||
_collisionShape.setTranslation(entityAACube.calcCenter());
|
_collisionShape.setTranslation(entityAACube.calcCenter());
|
||||||
_collisionShape.setScale(entityAACube.getScale());
|
_collisionShape.setScale(entityAACube.getScale());
|
||||||
// TODO: use motionState to update physics object
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const float MIN_POSITION_DELTA = 0.0001f;
|
const float MIN_POSITION_DELTA = 0.0001f;
|
||||||
|
|
|
@ -35,10 +35,36 @@ class EntityTreeElementExtraEncodeData;
|
||||||
#define DONT_ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() = 0;
|
#define DONT_ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() = 0;
|
||||||
#define ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() { };
|
#define ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() { };
|
||||||
|
|
||||||
|
const glm::vec3 DEFAULT_DIMENSIONS = glm::vec3(0.1f) / (float)TREE_SCALE;
|
||||||
|
const glm::quat DEFAULT_ROTATION;
|
||||||
|
const float DEFAULT_GLOW_LEVEL = 0.0f;
|
||||||
|
const float DEFAULT_LOCAL_RENDER_ALPHA = 1.0f;
|
||||||
|
const float DEFAULT_MASS = 1.0f;
|
||||||
|
const glm::vec3 NO_VELOCITY= glm::vec3(0.0f);
|
||||||
|
const glm::vec3 DEFAULT_VELOCITY = NO_VELOCITY;
|
||||||
|
const float EPSILON_VELOCITY_LENGTH = 0.001f / (float)TREE_SCALE;
|
||||||
|
const glm::vec3 NO_GRAVITY = glm::vec3(0.0f);
|
||||||
|
const glm::vec3 DEFAULT_GRAVITY = NO_GRAVITY;
|
||||||
|
const glm::vec3 REGULAR_GRAVITY = glm::vec3(0, -9.8f / (float)TREE_SCALE, 0);
|
||||||
|
const float DEFAULT_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header)
|
||||||
|
const float IMMORTAL = -1.0f; /// special lifetime which means the entity lives for ever. default lifetime
|
||||||
|
const float DEFAULT_LIFETIME = IMMORTAL;
|
||||||
|
const QString DEFAULT_SCRIPT = QString("");
|
||||||
|
const glm::vec3 DEFAULT_REGISTRATION_POINT = glm::vec3(0.5f, 0.5f, 0.5f); // center
|
||||||
|
const glm::vec3 NO_ANGULAR_VELOCITY = glm::vec3(0.0f);
|
||||||
|
const glm::vec3 DEFAULT_ANGULAR_VELOCITY = NO_ANGULAR_VELOCITY;
|
||||||
|
const float DEFAULT_ANGULAR_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header)
|
||||||
|
const bool DEFAULT_VISIBLE = true;
|
||||||
|
const bool DEFAULT_IGNORE_FOR_COLLISIONS = false;
|
||||||
|
const bool DEFAULT_COLLISIONS_WILL_MOVE = false;
|
||||||
|
const bool DEFAULT_LOCKED = false;
|
||||||
|
const QString DEFAULT_USER_DATA = QString("");
|
||||||
|
|
||||||
/// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available
|
/// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available
|
||||||
/// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate
|
/// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate
|
||||||
/// one directly, instead you must only construct one of it's derived classes with additional features.
|
/// one directly, instead you must only construct one of it's derived classes with additional features.
|
||||||
class EntityItem {
|
class EntityItem {
|
||||||
|
friend class EntityTreeElement;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum EntityDirtyFlags {
|
enum EntityDirtyFlags {
|
||||||
|
@ -148,7 +174,6 @@ public:
|
||||||
glm::vec3 getCenter() const; /// calculates center of the entity in domain scale units (0.0 - 1.0)
|
glm::vec3 getCenter() const; /// calculates center of the entity in domain scale units (0.0 - 1.0)
|
||||||
glm::vec3 getCenterInMeters() const { return getCenter() * (float) TREE_SCALE; }
|
glm::vec3 getCenterInMeters() const { return getCenter() * (float) TREE_SCALE; }
|
||||||
|
|
||||||
static const glm::vec3 DEFAULT_DIMENSIONS;
|
|
||||||
const glm::vec3& getDimensions() const { return _dimensions; } /// get dimensions in domain scale units (0.0 - 1.0)
|
const glm::vec3& getDimensions() const { return _dimensions; } /// get dimensions in domain scale units (0.0 - 1.0)
|
||||||
glm::vec3 getDimensionsInMeters() const { return _dimensions * (float) TREE_SCALE; } /// get dimensions in meters
|
glm::vec3 getDimensionsInMeters() const { return _dimensions * (float) TREE_SCALE; } /// get dimensions in meters
|
||||||
float getDistanceToBottomOfEntity() const; /// get the distance from the position of the entity to its "bottom" in y axis
|
float getDistanceToBottomOfEntity() const; /// get the distance from the position of the entity to its "bottom" in y axis
|
||||||
|
@ -160,34 +185,24 @@ public:
|
||||||
/// set dimensions in meter units (0.0 - TREE_SCALE) this will also reset radius appropriately
|
/// set dimensions in meter units (0.0 - TREE_SCALE) this will also reset radius appropriately
|
||||||
void setDimensionsInMeters(const glm::vec3& value) { setDimensions(value / (float) TREE_SCALE); }
|
void setDimensionsInMeters(const glm::vec3& value) { setDimensions(value / (float) TREE_SCALE); }
|
||||||
|
|
||||||
static const glm::quat DEFAULT_ROTATION;
|
|
||||||
const glm::quat& getRotation() const { return _rotation; }
|
const glm::quat& getRotation() const { return _rotation; }
|
||||||
void setRotation(const glm::quat& rotation) { _rotation = rotation; recalculateCollisionShape(); }
|
void setRotation(const glm::quat& rotation) { _rotation = rotation; recalculateCollisionShape(); }
|
||||||
|
|
||||||
static const float DEFAULT_GLOW_LEVEL;
|
|
||||||
float getGlowLevel() const { return _glowLevel; }
|
float getGlowLevel() const { return _glowLevel; }
|
||||||
void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; }
|
void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; }
|
||||||
|
|
||||||
static const float DEFAULT_LOCAL_RENDER_ALPHA;
|
|
||||||
float getLocalRenderAlpha() const { return _localRenderAlpha; }
|
float getLocalRenderAlpha() const { return _localRenderAlpha; }
|
||||||
void setLocalRenderAlpha(float localRenderAlpha) { _localRenderAlpha = localRenderAlpha; }
|
void setLocalRenderAlpha(float localRenderAlpha) { _localRenderAlpha = localRenderAlpha; }
|
||||||
|
|
||||||
static const float DEFAULT_MASS;
|
|
||||||
float getMass() const { return _mass; }
|
float getMass() const { return _mass; }
|
||||||
void setMass(float value) { _mass = value; }
|
void setMass(float value) { _mass = value; }
|
||||||
|
|
||||||
static const glm::vec3 DEFAULT_VELOCITY;
|
|
||||||
static const glm::vec3 NO_VELOCITY;
|
|
||||||
static const float EPSILON_VELOCITY_LENGTH;
|
|
||||||
const glm::vec3& getVelocity() const { return _velocity; } /// velocity in domain scale units (0.0-1.0) per second
|
const glm::vec3& getVelocity() const { return _velocity; } /// velocity in domain scale units (0.0-1.0) per second
|
||||||
glm::vec3 getVelocityInMeters() const { return _velocity * (float) TREE_SCALE; } /// get velocity in meters
|
glm::vec3 getVelocityInMeters() const { return _velocity * (float) TREE_SCALE; } /// get velocity in meters
|
||||||
void setVelocity(const glm::vec3& value) { _velocity = value; } /// velocity in domain scale units (0.0-1.0) per second
|
void setVelocity(const glm::vec3& value) { _velocity = value; } /// velocity in domain scale units (0.0-1.0) per second
|
||||||
void setVelocityInMeters(const glm::vec3& value) { _velocity = value / (float) TREE_SCALE; } /// velocity in meters
|
void setVelocityInMeters(const glm::vec3& value) { _velocity = value / (float) TREE_SCALE; } /// velocity in meters
|
||||||
bool hasVelocity() const { return _velocity != NO_VELOCITY; }
|
bool hasVelocity() const { return _velocity != NO_VELOCITY; }
|
||||||
|
|
||||||
static const glm::vec3 DEFAULT_GRAVITY;
|
|
||||||
static const glm::vec3 REGULAR_GRAVITY;
|
|
||||||
static const glm::vec3 NO_GRAVITY;
|
|
||||||
const glm::vec3& getGravity() const { return _gravity; } /// gravity in domain scale units (0.0-1.0) per second squared
|
const glm::vec3& getGravity() const { return _gravity; } /// gravity in domain scale units (0.0-1.0) per second squared
|
||||||
glm::vec3 getGravityInMeters() const { return _gravity * (float) TREE_SCALE; } /// get gravity in meters
|
glm::vec3 getGravityInMeters() const { return _gravity * (float) TREE_SCALE; } /// get gravity in meters
|
||||||
void setGravity(const glm::vec3& value) { _gravity = value; } /// gravity in domain scale units (0.0-1.0) per second squared
|
void setGravity(const glm::vec3& value) { _gravity = value; } /// gravity in domain scale units (0.0-1.0) per second squared
|
||||||
|
@ -197,13 +212,10 @@ public:
|
||||||
// TODO: this should eventually be updated to support resting on collisions with other surfaces
|
// TODO: this should eventually be updated to support resting on collisions with other surfaces
|
||||||
bool isRestingOnSurface() const;
|
bool isRestingOnSurface() const;
|
||||||
|
|
||||||
static const float DEFAULT_DAMPING;
|
|
||||||
float getDamping() const { return _damping; }
|
float getDamping() const { return _damping; }
|
||||||
void setDamping(float value) { _damping = value; }
|
void setDamping(float value) { _damping = value; }
|
||||||
|
|
||||||
// lifetime related properties.
|
// lifetime related properties.
|
||||||
static const float IMMORTAL; /// special lifetime which means the entity lives for ever. default lifetime
|
|
||||||
static const float DEFAULT_LIFETIME;
|
|
||||||
float getLifetime() const { return _lifetime; } /// get the lifetime in seconds for the entity
|
float getLifetime() const { return _lifetime; } /// get the lifetime in seconds for the entity
|
||||||
void setLifetime(float value) { _lifetime = value; } /// set the lifetime in seconds for the entity
|
void setLifetime(float value) { _lifetime = value; } /// set the lifetime in seconds for the entity
|
||||||
|
|
||||||
|
@ -224,46 +236,36 @@ public:
|
||||||
AACube getMinimumAACube() const;
|
AACube getMinimumAACube() const;
|
||||||
AABox getAABox() const; /// axis aligned bounding box in domain scale units (0.0 - 1.0)
|
AABox getAABox() const; /// axis aligned bounding box in domain scale units (0.0 - 1.0)
|
||||||
|
|
||||||
static const QString DEFAULT_SCRIPT;
|
|
||||||
const QString& getScript() const { return _script; }
|
const QString& getScript() const { return _script; }
|
||||||
void setScript(const QString& value) { _script = value; }
|
void setScript(const QString& value) { _script = value; }
|
||||||
|
|
||||||
static const glm::vec3 DEFAULT_REGISTRATION_POINT;
|
|
||||||
const glm::vec3& getRegistrationPoint() const { return _registrationPoint; } /// registration point as ratio of entity
|
const glm::vec3& getRegistrationPoint() const { return _registrationPoint; } /// registration point as ratio of entity
|
||||||
|
|
||||||
/// registration point as ratio of entity
|
/// registration point as ratio of entity
|
||||||
void setRegistrationPoint(const glm::vec3& value)
|
void setRegistrationPoint(const glm::vec3& value)
|
||||||
{ _registrationPoint = glm::clamp(value, 0.0f, 1.0f); recalculateCollisionShape(); }
|
{ _registrationPoint = glm::clamp(value, 0.0f, 1.0f); recalculateCollisionShape(); }
|
||||||
|
|
||||||
static const glm::vec3 NO_ANGULAR_VELOCITY;
|
|
||||||
static const glm::vec3 DEFAULT_ANGULAR_VELOCITY;
|
|
||||||
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
||||||
void setAngularVelocity(const glm::vec3& value) { _angularVelocity = value; }
|
void setAngularVelocity(const glm::vec3& value) { _angularVelocity = value; }
|
||||||
bool hasAngularVelocity() const { return _angularVelocity != NO_ANGULAR_VELOCITY; }
|
bool hasAngularVelocity() const { return _angularVelocity != NO_ANGULAR_VELOCITY; }
|
||||||
|
|
||||||
static const float DEFAULT_ANGULAR_DAMPING;
|
|
||||||
float getAngularDamping() const { return _angularDamping; }
|
float getAngularDamping() const { return _angularDamping; }
|
||||||
void setAngularDamping(float value) { _angularDamping = value; }
|
void setAngularDamping(float value) { _angularDamping = value; }
|
||||||
|
|
||||||
static const bool DEFAULT_VISIBLE;
|
|
||||||
bool getVisible() const { return _visible; }
|
bool getVisible() const { return _visible; }
|
||||||
void setVisible(bool value) { _visible = value; }
|
void setVisible(bool value) { _visible = value; }
|
||||||
bool isVisible() const { return _visible; }
|
bool isVisible() const { return _visible; }
|
||||||
bool isInvisible() const { return !_visible; }
|
bool isInvisible() const { return !_visible; }
|
||||||
|
|
||||||
static const bool DEFAULT_IGNORE_FOR_COLLISIONS;
|
|
||||||
bool getIgnoreForCollisions() const { return _ignoreForCollisions; }
|
bool getIgnoreForCollisions() const { return _ignoreForCollisions; }
|
||||||
void setIgnoreForCollisions(bool value) { _ignoreForCollisions = value; }
|
void setIgnoreForCollisions(bool value) { _ignoreForCollisions = value; }
|
||||||
|
|
||||||
static const bool DEFAULT_COLLISIONS_WILL_MOVE;
|
|
||||||
bool getCollisionsWillMove() const { return _collisionsWillMove; }
|
bool getCollisionsWillMove() const { return _collisionsWillMove; }
|
||||||
void setCollisionsWillMove(bool value) { _collisionsWillMove = value; }
|
void setCollisionsWillMove(bool value) { _collisionsWillMove = value; }
|
||||||
|
|
||||||
static const bool DEFAULT_LOCKED;
|
|
||||||
bool getLocked() const { return _locked; }
|
bool getLocked() const { return _locked; }
|
||||||
void setLocked(bool value) { _locked = value; }
|
void setLocked(bool value) { _locked = value; }
|
||||||
|
|
||||||
static const QString DEFAULT_USER_DATA;
|
|
||||||
const QString& getUserData() const { return _userData; }
|
const QString& getUserData() const { return _userData; }
|
||||||
void setUserData(const QString& value) { _userData = value; }
|
void setUserData(const QString& value) { _userData = value; }
|
||||||
|
|
||||||
|
@ -301,6 +303,7 @@ public:
|
||||||
void* getPhysicsInfo() const { return _physicsInfo; }
|
void* getPhysicsInfo() const { return _physicsInfo; }
|
||||||
void setPhysicsInfo(void* data) { _physicsInfo = data; }
|
void setPhysicsInfo(void* data) { _physicsInfo = data; }
|
||||||
|
|
||||||
|
EntityTreeElement* getElement() const { return _element; }
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void initFromEntityItemID(const EntityItemID& entityItemID); // maybe useful to allow subclasses to init
|
virtual void initFromEntityItemID(const EntityItemID& entityItemID); // maybe useful to allow subclasses to init
|
||||||
|
@ -362,6 +365,8 @@ protected:
|
||||||
|
|
||||||
// DirtyFlags are set whenever a property changes that the EntitySimulation needs to know about.
|
// DirtyFlags are set whenever a property changes that the EntitySimulation needs to know about.
|
||||||
uint32_t _dirtyFlags; // things that have changed from EXTERNAL changes (via script or packet) but NOT from simulation
|
uint32_t _dirtyFlags; // things that have changed from EXTERNAL changes (via script or packet) but NOT from simulation
|
||||||
|
|
||||||
|
EntityTreeElement* _element; // back pointer to containing Element
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,27 +24,27 @@
|
||||||
|
|
||||||
EntityItemProperties::EntityItemProperties() :
|
EntityItemProperties::EntityItemProperties() :
|
||||||
|
|
||||||
CONSTRUCT_PROPERTY(visible, EntityItem::DEFAULT_VISIBLE),
|
CONSTRUCT_PROPERTY(visible, DEFAULT_VISIBLE),
|
||||||
CONSTRUCT_PROPERTY(position, 0),
|
CONSTRUCT_PROPERTY(position, 0),
|
||||||
CONSTRUCT_PROPERTY(dimensions, EntityItem::DEFAULT_DIMENSIONS),
|
CONSTRUCT_PROPERTY(dimensions, DEFAULT_DIMENSIONS),
|
||||||
CONSTRUCT_PROPERTY(rotation, EntityItem::DEFAULT_ROTATION),
|
CONSTRUCT_PROPERTY(rotation, DEFAULT_ROTATION),
|
||||||
CONSTRUCT_PROPERTY(mass, EntityItem::DEFAULT_MASS),
|
CONSTRUCT_PROPERTY(mass, DEFAULT_MASS),
|
||||||
CONSTRUCT_PROPERTY(velocity, EntityItem::DEFAULT_VELOCITY),
|
CONSTRUCT_PROPERTY(velocity, DEFAULT_VELOCITY),
|
||||||
CONSTRUCT_PROPERTY(gravity, EntityItem::DEFAULT_GRAVITY),
|
CONSTRUCT_PROPERTY(gravity, DEFAULT_GRAVITY),
|
||||||
CONSTRUCT_PROPERTY(damping, EntityItem::DEFAULT_DAMPING),
|
CONSTRUCT_PROPERTY(damping, DEFAULT_DAMPING),
|
||||||
CONSTRUCT_PROPERTY(lifetime, EntityItem::DEFAULT_LIFETIME),
|
CONSTRUCT_PROPERTY(lifetime, DEFAULT_LIFETIME),
|
||||||
CONSTRUCT_PROPERTY(script, EntityItem::DEFAULT_SCRIPT),
|
CONSTRUCT_PROPERTY(script, DEFAULT_SCRIPT),
|
||||||
CONSTRUCT_PROPERTY(color, ),
|
CONSTRUCT_PROPERTY(color, ),
|
||||||
CONSTRUCT_PROPERTY(modelURL, ""),
|
CONSTRUCT_PROPERTY(modelURL, ""),
|
||||||
CONSTRUCT_PROPERTY(animationURL, ""),
|
CONSTRUCT_PROPERTY(animationURL, ""),
|
||||||
CONSTRUCT_PROPERTY(animationFPS, ModelEntityItem::DEFAULT_ANIMATION_FPS),
|
CONSTRUCT_PROPERTY(animationFPS, ModelEntityItem::DEFAULT_ANIMATION_FPS),
|
||||||
CONSTRUCT_PROPERTY(animationFrameIndex, ModelEntityItem::DEFAULT_ANIMATION_FRAME_INDEX),
|
CONSTRUCT_PROPERTY(animationFrameIndex, ModelEntityItem::DEFAULT_ANIMATION_FRAME_INDEX),
|
||||||
CONSTRUCT_PROPERTY(animationIsPlaying, ModelEntityItem::DEFAULT_ANIMATION_IS_PLAYING),
|
CONSTRUCT_PROPERTY(animationIsPlaying, ModelEntityItem::DEFAULT_ANIMATION_IS_PLAYING),
|
||||||
CONSTRUCT_PROPERTY(registrationPoint, EntityItem::DEFAULT_REGISTRATION_POINT),
|
CONSTRUCT_PROPERTY(registrationPoint, DEFAULT_REGISTRATION_POINT),
|
||||||
CONSTRUCT_PROPERTY(angularVelocity, EntityItem::DEFAULT_ANGULAR_VELOCITY),
|
CONSTRUCT_PROPERTY(angularVelocity, DEFAULT_ANGULAR_VELOCITY),
|
||||||
CONSTRUCT_PROPERTY(angularDamping, EntityItem::DEFAULT_ANGULAR_DAMPING),
|
CONSTRUCT_PROPERTY(angularDamping, DEFAULT_ANGULAR_DAMPING),
|
||||||
CONSTRUCT_PROPERTY(ignoreForCollisions, EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS),
|
CONSTRUCT_PROPERTY(ignoreForCollisions, DEFAULT_IGNORE_FOR_COLLISIONS),
|
||||||
CONSTRUCT_PROPERTY(collisionsWillMove, EntityItem::DEFAULT_COLLISIONS_WILL_MOVE),
|
CONSTRUCT_PROPERTY(collisionsWillMove, DEFAULT_COLLISIONS_WILL_MOVE),
|
||||||
CONSTRUCT_PROPERTY(isSpotlight, false),
|
CONSTRUCT_PROPERTY(isSpotlight, false),
|
||||||
CONSTRUCT_PROPERTY(diffuseColor, ),
|
CONSTRUCT_PROPERTY(diffuseColor, ),
|
||||||
CONSTRUCT_PROPERTY(ambientColor, ),
|
CONSTRUCT_PROPERTY(ambientColor, ),
|
||||||
|
@ -57,7 +57,7 @@ EntityItemProperties::EntityItemProperties() :
|
||||||
CONSTRUCT_PROPERTY(locked, false),
|
CONSTRUCT_PROPERTY(locked, false),
|
||||||
CONSTRUCT_PROPERTY(textures, ""),
|
CONSTRUCT_PROPERTY(textures, ""),
|
||||||
CONSTRUCT_PROPERTY(animationSettings, ""),
|
CONSTRUCT_PROPERTY(animationSettings, ""),
|
||||||
CONSTRUCT_PROPERTY(userData, EntityItem::DEFAULT_USER_DATA),
|
CONSTRUCT_PROPERTY(userData, DEFAULT_USER_DATA),
|
||||||
CONSTRUCT_PROPERTY(text, TextEntityItem::DEFAULT_TEXT),
|
CONSTRUCT_PROPERTY(text, TextEntityItem::DEFAULT_TEXT),
|
||||||
CONSTRUCT_PROPERTY(lineHeight, TextEntityItem::DEFAULT_LINE_HEIGHT),
|
CONSTRUCT_PROPERTY(lineHeight, TextEntityItem::DEFAULT_LINE_HEIGHT),
|
||||||
CONSTRUCT_PROPERTY(textColor, TextEntityItem::DEFAULT_TEXT_COLOR),
|
CONSTRUCT_PROPERTY(textColor, TextEntityItem::DEFAULT_TEXT_COLOR),
|
||||||
|
|
|
@ -682,6 +682,7 @@ void EntityTreeElement::cleanupEntities() {
|
||||||
uint16_t numberOfEntities = _entityItems->size();
|
uint16_t numberOfEntities = _entityItems->size();
|
||||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||||
EntityItem* entity = (*_entityItems)[i];
|
EntityItem* entity = (*_entityItems)[i];
|
||||||
|
entity->_element = NULL;
|
||||||
delete entity;
|
delete entity;
|
||||||
}
|
}
|
||||||
_entityItems->clear();
|
_entityItems->clear();
|
||||||
|
@ -693,6 +694,7 @@ bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) {
|
||||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||||
if ((*_entityItems)[i]->getEntityItemID() == id) {
|
if ((*_entityItems)[i]->getEntityItemID() == id) {
|
||||||
foundEntity = true;
|
foundEntity = true;
|
||||||
|
(*_entityItems)[i]->_element = NULL;
|
||||||
_entityItems->removeAt(i);
|
_entityItems->removeAt(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -701,7 +703,13 @@ bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityTreeElement::removeEntityItem(EntityItem* entity) {
|
bool EntityTreeElement::removeEntityItem(EntityItem* entity) {
|
||||||
return _entityItems->removeAll(entity) > 0;
|
int numEntries = _entityItems->removeAll(entity);
|
||||||
|
if (numEntries > 0) {
|
||||||
|
assert(entity->_element == this);
|
||||||
|
entity->_element = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -808,7 +816,10 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeElement::addEntityItem(EntityItem* entity) {
|
void EntityTreeElement::addEntityItem(EntityItem* entity) {
|
||||||
|
assert(entity);
|
||||||
|
assert(entity->_element == NULL);
|
||||||
_entityItems->push_back(entity);
|
_entityItems->push_back(entity);
|
||||||
|
entity->_element = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// will average a "common reduced LOD view" from the the child elements...
|
// will average a "common reduced LOD view" from the the child elements...
|
||||||
|
|
|
@ -179,7 +179,7 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) {
|
||||||
|
|
||||||
// If this is one of the old elements we're looking for, then ask it to remove the old entity
|
// If this is one of the old elements we're looking for, then ask it to remove the old entity
|
||||||
if (!details.oldFound && entityTreeElement == details.oldContainingElement) {
|
if (!details.oldFound && entityTreeElement == details.oldContainingElement) {
|
||||||
entityTreeElement->removeEntityItem(details.entity);
|
// DO NOT remove the entity here. It will be removed when added to the destination element.
|
||||||
_foundOldCount++;
|
_foundOldCount++;
|
||||||
//details.oldFound = true; // TODO: would be nice to add this optimization
|
//details.oldFound = true; // TODO: would be nice to add this optimization
|
||||||
if (_wantDebug) {
|
if (_wantDebug) {
|
||||||
|
@ -193,8 +193,15 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) {
|
||||||
// If this element is the best fit for the new bounds of this entity then add the entity to the element
|
// If this element is the best fit for the new bounds of this entity then add the entity to the element
|
||||||
if (!details.newFound && entityTreeElement->bestFitBounds(details.newCube)) {
|
if (!details.newFound && entityTreeElement->bestFitBounds(details.newCube)) {
|
||||||
EntityItemID entityItemID = details.entity->getEntityItemID();
|
EntityItemID entityItemID = details.entity->getEntityItemID();
|
||||||
entityTreeElement->addEntityItem(details.entity);
|
// remove from the old before adding
|
||||||
_tree->setContainingElement(entityItemID, entityTreeElement);
|
EntityTreeElement* oldElement = details.entity->getElement();
|
||||||
|
if (oldElement != entityTreeElement) {
|
||||||
|
if (oldElement) {
|
||||||
|
oldElement->removeEntityItem(details.entity);
|
||||||
|
}
|
||||||
|
entityTreeElement->addEntityItem(details.entity);
|
||||||
|
_tree->setContainingElement(entityItemID, entityTreeElement);
|
||||||
|
}
|
||||||
_foundNewCount++;
|
_foundNewCount++;
|
||||||
//details.newFound = true; // TODO: would be nice to add this optimization
|
//details.newFound = true; // TODO: would be nice to add this optimization
|
||||||
if (_wantDebug) {
|
if (_wantDebug) {
|
||||||
|
@ -227,7 +234,7 @@ bool MovingEntitiesOperator::postRecursion(OctreeElement* element) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// It's not OK to prune if we have the potential of deleting the original containig element.
|
// It's not OK to prune if we have the potential of deleting the original containing element
|
||||||
// because if we prune the containing element then new might end up reallocating the same memory later
|
// because if we prune the containing element then new might end up reallocating the same memory later
|
||||||
// and that will confuse our logic.
|
// and that will confuse our logic.
|
||||||
//
|
//
|
||||||
|
|
|
@ -231,18 +231,19 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) {
|
||||||
qDebug() << " *** REMOVING from ELEMENT ***";
|
qDebug() << " *** REMOVING from ELEMENT ***";
|
||||||
}
|
}
|
||||||
|
|
||||||
entityTreeElement->removeEntityItem(_existingEntity); // NOTE: only removes the entity, doesn't delete it
|
// the entity knows what element it's in, so we remove it from that one
|
||||||
|
// NOTE: we know we haven't yet added it to its new element because _removeOld is true
|
||||||
|
EntityTreeElement* oldElement = _existingEntity->getElement();
|
||||||
|
oldElement->removeEntityItem(_existingEntity);
|
||||||
|
_tree->setContainingElement(_entityItemID, NULL);
|
||||||
|
|
||||||
// If we haven't yet found the new location, then we need to
|
if (oldElement != _containingElement) {
|
||||||
// make sure to remove our entity to element map, because for
|
qDebug() << "WARNING entity moved during UpdateEntityOperator recursion";
|
||||||
// now we're not in that map
|
_containingElement->removeEntityItem(_existingEntity);
|
||||||
if (!_foundNew) {
|
}
|
||||||
_tree->setContainingElement(_entityItemID, NULL);
|
|
||||||
|
|
||||||
if (_wantDebug) {
|
|
||||||
qDebug() << " *** REMOVING from MAP ***";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (_wantDebug) {
|
||||||
|
qDebug() << " *** REMOVING from MAP ***";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_foundOld = true;
|
_foundOld = true;
|
||||||
|
@ -263,7 +264,6 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) {
|
||||||
qDebug() << " entityTreeElement->bestFitBounds(_newEntityBox)=" << entityTreeElement->bestFitBounds(_newEntityBox);
|
qDebug() << " entityTreeElement->bestFitBounds(_newEntityBox)=" << entityTreeElement->bestFitBounds(_newEntityBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If this element is the best fit for the new entity properties, then add/or update it
|
// If this element is the best fit for the new entity properties, then add/or update it
|
||||||
if (entityTreeElement->bestFitBounds(_newEntityBox)) {
|
if (entityTreeElement->bestFitBounds(_newEntityBox)) {
|
||||||
|
|
||||||
|
@ -271,33 +271,14 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) {
|
||||||
qDebug() << " *** THIS ELEMENT IS BEST FIT ***";
|
qDebug() << " *** THIS ELEMENT IS BEST FIT ***";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityTreeElement* oldElement = _existingEntity->getElement();
|
||||||
// if we are the existing containing element, then we can just do the update of the entity properties
|
// if we are the existing containing element, then we can just do the update of the entity properties
|
||||||
if (entityTreeElement == _containingElement) {
|
if (entityTreeElement == oldElement) {
|
||||||
|
|
||||||
if (_wantDebug) {
|
if (_wantDebug) {
|
||||||
qDebug() << " *** This is the same OLD ELEMENT ***";
|
qDebug() << " *** This is the same OLD ELEMENT ***";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: We shouldn't be in a remove old case and also be the new best fit. This indicates that
|
|
||||||
// we have some kind of a logic error in this operator. But, it can handle it properly by setting
|
|
||||||
// the new properties for the entity and moving on. Still going to output a warning that if we
|
|
||||||
// see consistently we will want to address this.
|
|
||||||
if (_removeOld) {
|
|
||||||
qDebug() << "UNEXPECTED - UpdateEntityOperator - "
|
|
||||||
"we thought we needed to removeOld, but the old entity is our best fit.";
|
|
||||||
_removeOld = false;
|
|
||||||
|
|
||||||
// if we thought we were supposed to remove the old item, and we already did, then we need
|
|
||||||
// to repair this case.
|
|
||||||
if (_foundOld) {
|
|
||||||
if (_wantDebug) {
|
|
||||||
qDebug() << " *** REPAIRING PREVIOUS REMOVAL from ELEMENT and MAP ***";
|
|
||||||
}
|
|
||||||
entityTreeElement->addEntityItem(_existingEntity);
|
|
||||||
_tree->setContainingElement(_entityItemID, entityTreeElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the entity properties and mark our element as changed.
|
// set the entity properties and mark our element as changed.
|
||||||
_existingEntity->setProperties(_properties);
|
_existingEntity->setProperties(_properties);
|
||||||
if (_wantDebug) {
|
if (_wantDebug) {
|
||||||
|
@ -305,14 +286,22 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// otherwise, this is an add case.
|
// otherwise, this is an add case.
|
||||||
|
if (oldElement) {
|
||||||
|
oldElement->removeEntityItem(_existingEntity);
|
||||||
|
if (oldElement != _containingElement) {
|
||||||
|
qDebug() << "WARNING entity moved during UpdateEntityOperator recursion";
|
||||||
|
}
|
||||||
|
}
|
||||||
entityTreeElement->addEntityItem(_existingEntity);
|
entityTreeElement->addEntityItem(_existingEntity);
|
||||||
_existingEntity->setProperties(_properties); // still need to update the properties!
|
|
||||||
_tree->setContainingElement(_entityItemID, entityTreeElement);
|
_tree->setContainingElement(_entityItemID, entityTreeElement);
|
||||||
|
|
||||||
|
_existingEntity->setProperties(_properties); // still need to update the properties!
|
||||||
if (_wantDebug) {
|
if (_wantDebug) {
|
||||||
qDebug() << " *** ADDING ENTITY to ELEMENT and MAP and SETTING PROPERTIES ***";
|
qDebug() << " *** ADDING ENTITY to ELEMENT and MAP and SETTING PROPERTIES ***";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_foundNew = true; // we found the new item!
|
_foundNew = true; // we found the new element
|
||||||
|
_removeOld = false; // and it has already been removed from the old
|
||||||
} else {
|
} else {
|
||||||
keepSearching = true;
|
keepSearching = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ PacketVersion versionForPacketType(PacketType type) {
|
||||||
case PacketTypeInjectAudio:
|
case PacketTypeInjectAudio:
|
||||||
return 1;
|
return 1;
|
||||||
case PacketTypeAvatarData:
|
case PacketTypeAvatarData:
|
||||||
return 4;
|
return 5;
|
||||||
case PacketTypeAvatarIdentity:
|
case PacketTypeAvatarIdentity:
|
||||||
return 1;
|
return 1;
|
||||||
case PacketTypeEnvironmentData:
|
case PacketTypeEnvironmentData:
|
||||||
|
|
|
@ -154,8 +154,6 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame, float subStep
|
||||||
// NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame
|
// NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame
|
||||||
// due to _worldOffset.
|
// due to _worldOffset.
|
||||||
|
|
||||||
// TODO: Andrew to reconcile Bullet and legacy damping coefficients.
|
|
||||||
|
|
||||||
// compute position error
|
// compute position error
|
||||||
if (glm::length2(_sentVelocity) > 0.0f) {
|
if (glm::length2(_sentVelocity) > 0.0f) {
|
||||||
_sentVelocity += _sentAcceleration * dt;
|
_sentVelocity += _sentAcceleration * dt;
|
||||||
|
|
|
@ -111,7 +111,7 @@ protected:
|
||||||
glm::vec3 _sentPosition; // in simulation-frame (not world-frame)
|
glm::vec3 _sentPosition; // in simulation-frame (not world-frame)
|
||||||
glm::quat _sentRotation;;
|
glm::quat _sentRotation;;
|
||||||
glm::vec3 _sentVelocity;
|
glm::vec3 _sentVelocity;
|
||||||
glm::vec3 _sentAngularVelocity;
|
glm::vec3 _sentAngularVelocity; // radians per second
|
||||||
glm::vec3 _sentAcceleration;
|
glm::vec3 _sentAcceleration;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#define hifi_DependencyManager_h
|
#define hifi_DependencyManager_h
|
||||||
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
|
@ -22,10 +23,12 @@ public:\
|
||||||
private:\
|
private:\
|
||||||
void customDeleter() {\
|
void customDeleter() {\
|
||||||
QObject* thisObject = dynamic_cast<QObject*>(this);\
|
QObject* thisObject = dynamic_cast<QObject*>(this);\
|
||||||
if (thisObject) {\
|
if (thisObject && thisObject->parent()) {\
|
||||||
thisObject->deleteLater();\
|
thisObject->deleteLater();\
|
||||||
|
qDebug() << "Delete later:" << #T;\
|
||||||
} else {\
|
} else {\
|
||||||
delete this;\
|
delete this;\
|
||||||
|
qDebug() << "Deleted:" << #T;\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
friend class DependencyManager;
|
friend class DependencyManager;
|
||||||
|
|
Loading…
Reference in a new issue