mirror of
https://github.com/lubosz/overte.git
synced 2025-04-16 09:29:16 +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
|
||||
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();
|
||||
|
||||
/* 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
|
||||
// are reported to client. Since you can encode without the lock
|
||||
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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
// 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
|
||||
playRandomMuzak();
|
||||
// playRandomMuzak();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,9 +353,9 @@ function update(deltaTime) {
|
|||
Overlays.editOverlay(descriptionText, { position: textOverlayPosition() });
|
||||
|
||||
// if the reticle is up then we may need to play the next muzak
|
||||
if (!Audio.isInjectorPlaying(currentMuzakInjector)) {
|
||||
playNextMuzak();
|
||||
}
|
||||
// if (!Audio.isInjectorPlaying(currentMuzakInjector)) {
|
||||
// playNextMuzak();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ Head::Head(Avatar* owningAvatar) :
|
|||
_deltaRoll(0.0f),
|
||||
_deltaLeanSideways(0.0f),
|
||||
_deltaLeanForward(0.0f),
|
||||
_torsoTwist(0.0f),
|
||||
_isCameraMoving(false),
|
||||
_isLookingAtMe(false),
|
||||
_faceModel(this),
|
||||
|
|
|
@ -76,9 +76,6 @@ public:
|
|||
float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; }
|
||||
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;
|
||||
|
||||
const glm::vec3& getRightEyePosition() const { return _rightEyePosition; }
|
||||
|
@ -151,8 +148,6 @@ private:
|
|||
// delta lean angles for lean perturbations (driven by collisions)
|
||||
float _deltaLeanSideways;
|
||||
float _deltaLeanForward;
|
||||
|
||||
float _torsoTwist;
|
||||
|
||||
bool _isCameraMoving;
|
||||
bool _isLookingAtMe;
|
||||
|
|
|
@ -158,15 +158,18 @@ QByteArray AvatarData::toByteArray() {
|
|||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
|
||||
|
||||
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalYaw());
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalPitch());
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalRoll());
|
||||
|
||||
// Head lean X,Z (head lateral and fwd/back motion relative to torso)
|
||||
memcpy(destinationBuffer, &_headData->_leanSideways, sizeof(_headData->_leanSideways));
|
||||
destinationBuffer += sizeof(_headData->_leanSideways);
|
||||
memcpy(destinationBuffer, &_headData->_leanForward, sizeof(_headData->_leanForward));
|
||||
destinationBuffer += sizeof(_headData->_leanForward);
|
||||
glm::vec3 pitchYawRoll = glm::vec3(_headData->getFinalPitch(),
|
||||
_headData->getFinalYaw(),
|
||||
_headData->getFinalRoll());
|
||||
if (this->isMyAvatar()) {
|
||||
glm::vec3 lean = glm::vec3(_headData->getFinalLeanForward(),
|
||||
_headData->getTorsoTwist(),
|
||||
_headData->getFinalLeanSideways());
|
||||
pitchYawRoll -= lean;
|
||||
}
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.x);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.y);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.z);
|
||||
|
||||
// Lookat Position
|
||||
memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition));
|
||||
|
@ -287,18 +290,16 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
|||
// bodyPitch = 2 (compressed float)
|
||||
// bodyRoll = 2 (compressed float)
|
||||
// targetScale = 2 (compressed float)
|
||||
// headYaw = 2 (compressed float)
|
||||
// headPitch = 2 (compressed float)
|
||||
// headYaw = 2 (compressed float)
|
||||
// headRoll = 2 (compressed float)
|
||||
// leanSideways = 4
|
||||
// leanForward = 4
|
||||
// lookAt = 12
|
||||
// audioLoudness = 4
|
||||
// }
|
||||
// + 1 byte for pupilSize
|
||||
// + 1 byte for numJoints (0)
|
||||
// = 53 bytes
|
||||
int minPossibleSize = 52;
|
||||
// = 45 bytes
|
||||
int minPossibleSize = 45;
|
||||
|
||||
int maxAvailableSize = packet.size() - offset;
|
||||
if (minPossibleSize > maxAvailableSize) {
|
||||
|
@ -356,8 +357,8 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
|||
{ // Head rotation
|
||||
//(NOTE: This needs to become a quaternion to save two bytes)
|
||||
float headYaw, headPitch, headRoll;
|
||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
|
||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headPitch);
|
||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
|
||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headRoll);
|
||||
if (glm::isnan(headYaw) || glm::isnan(headPitch) || glm::isnan(headRoll)) {
|
||||
if (shouldLogError(now)) {
|
||||
|
@ -365,27 +366,10 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
|||
}
|
||||
return maxAvailableSize;
|
||||
}
|
||||
_headData->setBaseYaw(headYaw);
|
||||
_headData->setBasePitch(headPitch);
|
||||
_headData->setBaseYaw(headYaw);
|
||||
_headData->setBaseRoll(headRoll);
|
||||
} // 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
|
||||
glm::vec3 lookAt;
|
||||
|
|
|
@ -152,6 +152,8 @@ class AvatarData : public QObject {
|
|||
public:
|
||||
AvatarData();
|
||||
virtual ~AvatarData();
|
||||
|
||||
virtual bool isMyAvatar() { return false; }
|
||||
|
||||
const QUuid& getSessionUUID() const { return _sessionUUID; }
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
|||
_baseRoll(0.0f),
|
||||
_leanSideways(0.0f),
|
||||
_leanForward(0.0f),
|
||||
_torsoTwist(0.0f),
|
||||
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
||||
_audioLoudness(0.0f),
|
||||
_isFaceshiftConnected(false),
|
||||
|
|
|
@ -71,11 +71,13 @@ public:
|
|||
|
||||
float getLeanSideways() const { return _leanSideways; }
|
||||
float getLeanForward() const { return _leanForward; }
|
||||
float getTorsoTwist() const { return _torsoTwist; }
|
||||
virtual float getFinalLeanSideways() const { return _leanSideways; }
|
||||
virtual float getFinalLeanForward() const { return _leanForward; }
|
||||
|
||||
void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; }
|
||||
void setLeanForward(float leanForward) { _leanForward = leanForward; }
|
||||
void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; }
|
||||
|
||||
friend class AvatarData;
|
||||
|
||||
|
@ -86,6 +88,7 @@ protected:
|
|||
float _baseRoll;
|
||||
float _leanSideways;
|
||||
float _leanForward;
|
||||
float _torsoTwist;
|
||||
|
||||
glm::vec3 _lookAtPosition;
|
||||
float _audioLoudness;
|
||||
|
|
|
@ -92,7 +92,8 @@ bool DeleteEntityOperator::preRecursion(OctreeElement* element) {
|
|||
// and we can stop searching.
|
||||
if (entityTreeElement == details.containingElement) {
|
||||
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
|
||||
_foundCount++;
|
||||
}
|
||||
|
|
|
@ -21,31 +21,6 @@
|
|||
#include "EntityItem.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) {
|
||||
_id = entityItemID.id;
|
||||
_creatorTokenID = entityItemID.creatorTokenID;
|
||||
|
@ -95,6 +70,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) {
|
|||
_physicsInfo = NULL;
|
||||
_dirtyFlags = 0;
|
||||
_changedOnServer = 0;
|
||||
_element = NULL;
|
||||
initFromEntityItemID(entityItemID);
|
||||
}
|
||||
|
||||
|
@ -110,6 +86,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert
|
|||
_physicsInfo = NULL;
|
||||
_dirtyFlags = 0;
|
||||
_changedOnServer = 0;
|
||||
_element = NULL;
|
||||
initFromEntityItemID(entityItemID);
|
||||
setProperties(properties);
|
||||
}
|
||||
|
@ -117,6 +94,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert
|
|||
EntityItem::~EntityItem() {
|
||||
// be sure to clean up _physicsInfo before calling this dtor
|
||||
assert(_physicsInfo == NULL);
|
||||
assert(_element == NULL);
|
||||
}
|
||||
|
||||
EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||
|
@ -1015,7 +993,6 @@ void EntityItem::recalculateCollisionShape() {
|
|||
entityAACube.scale(TREE_SCALE); // scale to meters
|
||||
_collisionShape.setTranslation(entityAACube.calcCenter());
|
||||
_collisionShape.setScale(entityAACube.getScale());
|
||||
// TODO: use motionState to update physics object
|
||||
}
|
||||
|
||||
const float MIN_POSITION_DELTA = 0.0001f;
|
||||
|
|
|
@ -35,10 +35,36 @@ class EntityTreeElementExtraEncodeData;
|
|||
#define DONT_ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() = 0;
|
||||
#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
|
||||
/// 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.
|
||||
class EntityItem {
|
||||
friend class EntityTreeElement;
|
||||
|
||||
public:
|
||||
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 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)
|
||||
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
|
||||
|
@ -160,34 +185,24 @@ public:
|
|||
/// 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); }
|
||||
|
||||
static const glm::quat DEFAULT_ROTATION;
|
||||
const glm::quat& getRotation() const { return _rotation; }
|
||||
void setRotation(const glm::quat& rotation) { _rotation = rotation; recalculateCollisionShape(); }
|
||||
|
||||
static const float DEFAULT_GLOW_LEVEL;
|
||||
float getGlowLevel() const { return _glowLevel; }
|
||||
void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; }
|
||||
|
||||
static const float DEFAULT_LOCAL_RENDER_ALPHA;
|
||||
float getLocalRenderAlpha() const { return _localRenderAlpha; }
|
||||
void setLocalRenderAlpha(float localRenderAlpha) { _localRenderAlpha = localRenderAlpha; }
|
||||
|
||||
static const float DEFAULT_MASS;
|
||||
float getMass() const { return _mass; }
|
||||
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
|
||||
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 setVelocityInMeters(const glm::vec3& value) { _velocity = value / (float) TREE_SCALE; } /// velocity in meters
|
||||
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
|
||||
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
|
||||
|
@ -197,13 +212,10 @@ public:
|
|||
// TODO: this should eventually be updated to support resting on collisions with other surfaces
|
||||
bool isRestingOnSurface() const;
|
||||
|
||||
static const float DEFAULT_DAMPING;
|
||||
float getDamping() const { return _damping; }
|
||||
void setDamping(float value) { _damping = value; }
|
||||
|
||||
// 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
|
||||
void setLifetime(float value) { _lifetime = value; } /// set the lifetime in seconds for the entity
|
||||
|
||||
|
@ -224,46 +236,36 @@ public:
|
|||
AACube getMinimumAACube() const;
|
||||
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; }
|
||||
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
|
||||
|
||||
/// registration point as ratio of entity
|
||||
void setRegistrationPoint(const glm::vec3& value)
|
||||
{ _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; }
|
||||
void setAngularVelocity(const glm::vec3& value) { _angularVelocity = value; }
|
||||
bool hasAngularVelocity() const { return _angularVelocity != NO_ANGULAR_VELOCITY; }
|
||||
|
||||
static const float DEFAULT_ANGULAR_DAMPING;
|
||||
float getAngularDamping() const { return _angularDamping; }
|
||||
void setAngularDamping(float value) { _angularDamping = value; }
|
||||
|
||||
static const bool DEFAULT_VISIBLE;
|
||||
bool getVisible() const { return _visible; }
|
||||
void setVisible(bool value) { _visible = value; }
|
||||
bool isVisible() const { return _visible; }
|
||||
bool isInvisible() const { return !_visible; }
|
||||
|
||||
static const bool DEFAULT_IGNORE_FOR_COLLISIONS;
|
||||
bool getIgnoreForCollisions() const { return _ignoreForCollisions; }
|
||||
void setIgnoreForCollisions(bool value) { _ignoreForCollisions = value; }
|
||||
|
||||
static const bool DEFAULT_COLLISIONS_WILL_MOVE;
|
||||
bool getCollisionsWillMove() const { return _collisionsWillMove; }
|
||||
void setCollisionsWillMove(bool value) { _collisionsWillMove = value; }
|
||||
|
||||
static const bool DEFAULT_LOCKED;
|
||||
bool getLocked() const { return _locked; }
|
||||
void setLocked(bool value) { _locked = value; }
|
||||
|
||||
static const QString DEFAULT_USER_DATA;
|
||||
const QString& getUserData() const { return _userData; }
|
||||
void setUserData(const QString& value) { _userData = value; }
|
||||
|
||||
|
@ -301,6 +303,7 @@ public:
|
|||
void* getPhysicsInfo() const { return _physicsInfo; }
|
||||
void setPhysicsInfo(void* data) { _physicsInfo = data; }
|
||||
|
||||
EntityTreeElement* getElement() const { return _element; }
|
||||
protected:
|
||||
|
||||
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.
|
||||
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() :
|
||||
|
||||
CONSTRUCT_PROPERTY(visible, EntityItem::DEFAULT_VISIBLE),
|
||||
CONSTRUCT_PROPERTY(visible, DEFAULT_VISIBLE),
|
||||
CONSTRUCT_PROPERTY(position, 0),
|
||||
CONSTRUCT_PROPERTY(dimensions, EntityItem::DEFAULT_DIMENSIONS),
|
||||
CONSTRUCT_PROPERTY(rotation, EntityItem::DEFAULT_ROTATION),
|
||||
CONSTRUCT_PROPERTY(mass, EntityItem::DEFAULT_MASS),
|
||||
CONSTRUCT_PROPERTY(velocity, EntityItem::DEFAULT_VELOCITY),
|
||||
CONSTRUCT_PROPERTY(gravity, EntityItem::DEFAULT_GRAVITY),
|
||||
CONSTRUCT_PROPERTY(damping, EntityItem::DEFAULT_DAMPING),
|
||||
CONSTRUCT_PROPERTY(lifetime, EntityItem::DEFAULT_LIFETIME),
|
||||
CONSTRUCT_PROPERTY(script, EntityItem::DEFAULT_SCRIPT),
|
||||
CONSTRUCT_PROPERTY(dimensions, DEFAULT_DIMENSIONS),
|
||||
CONSTRUCT_PROPERTY(rotation, DEFAULT_ROTATION),
|
||||
CONSTRUCT_PROPERTY(mass, DEFAULT_MASS),
|
||||
CONSTRUCT_PROPERTY(velocity, DEFAULT_VELOCITY),
|
||||
CONSTRUCT_PROPERTY(gravity, DEFAULT_GRAVITY),
|
||||
CONSTRUCT_PROPERTY(damping, DEFAULT_DAMPING),
|
||||
CONSTRUCT_PROPERTY(lifetime, DEFAULT_LIFETIME),
|
||||
CONSTRUCT_PROPERTY(script, DEFAULT_SCRIPT),
|
||||
CONSTRUCT_PROPERTY(color, ),
|
||||
CONSTRUCT_PROPERTY(modelURL, ""),
|
||||
CONSTRUCT_PROPERTY(animationURL, ""),
|
||||
CONSTRUCT_PROPERTY(animationFPS, ModelEntityItem::DEFAULT_ANIMATION_FPS),
|
||||
CONSTRUCT_PROPERTY(animationFrameIndex, ModelEntityItem::DEFAULT_ANIMATION_FRAME_INDEX),
|
||||
CONSTRUCT_PROPERTY(animationIsPlaying, ModelEntityItem::DEFAULT_ANIMATION_IS_PLAYING),
|
||||
CONSTRUCT_PROPERTY(registrationPoint, EntityItem::DEFAULT_REGISTRATION_POINT),
|
||||
CONSTRUCT_PROPERTY(angularVelocity, EntityItem::DEFAULT_ANGULAR_VELOCITY),
|
||||
CONSTRUCT_PROPERTY(angularDamping, EntityItem::DEFAULT_ANGULAR_DAMPING),
|
||||
CONSTRUCT_PROPERTY(ignoreForCollisions, EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS),
|
||||
CONSTRUCT_PROPERTY(collisionsWillMove, EntityItem::DEFAULT_COLLISIONS_WILL_MOVE),
|
||||
CONSTRUCT_PROPERTY(registrationPoint, DEFAULT_REGISTRATION_POINT),
|
||||
CONSTRUCT_PROPERTY(angularVelocity, DEFAULT_ANGULAR_VELOCITY),
|
||||
CONSTRUCT_PROPERTY(angularDamping, DEFAULT_ANGULAR_DAMPING),
|
||||
CONSTRUCT_PROPERTY(ignoreForCollisions, DEFAULT_IGNORE_FOR_COLLISIONS),
|
||||
CONSTRUCT_PROPERTY(collisionsWillMove, DEFAULT_COLLISIONS_WILL_MOVE),
|
||||
CONSTRUCT_PROPERTY(isSpotlight, false),
|
||||
CONSTRUCT_PROPERTY(diffuseColor, ),
|
||||
CONSTRUCT_PROPERTY(ambientColor, ),
|
||||
|
@ -57,7 +57,7 @@ EntityItemProperties::EntityItemProperties() :
|
|||
CONSTRUCT_PROPERTY(locked, false),
|
||||
CONSTRUCT_PROPERTY(textures, ""),
|
||||
CONSTRUCT_PROPERTY(animationSettings, ""),
|
||||
CONSTRUCT_PROPERTY(userData, EntityItem::DEFAULT_USER_DATA),
|
||||
CONSTRUCT_PROPERTY(userData, DEFAULT_USER_DATA),
|
||||
CONSTRUCT_PROPERTY(text, TextEntityItem::DEFAULT_TEXT),
|
||||
CONSTRUCT_PROPERTY(lineHeight, TextEntityItem::DEFAULT_LINE_HEIGHT),
|
||||
CONSTRUCT_PROPERTY(textColor, TextEntityItem::DEFAULT_TEXT_COLOR),
|
||||
|
|
|
@ -682,6 +682,7 @@ void EntityTreeElement::cleanupEntities() {
|
|||
uint16_t numberOfEntities = _entityItems->size();
|
||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||
EntityItem* entity = (*_entityItems)[i];
|
||||
entity->_element = NULL;
|
||||
delete entity;
|
||||
}
|
||||
_entityItems->clear();
|
||||
|
@ -693,6 +694,7 @@ bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) {
|
|||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||
if ((*_entityItems)[i]->getEntityItemID() == id) {
|
||||
foundEntity = true;
|
||||
(*_entityItems)[i]->_element = NULL;
|
||||
_entityItems->removeAt(i);
|
||||
break;
|
||||
}
|
||||
|
@ -701,7 +703,13 @@ bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) {
|
|||
}
|
||||
|
||||
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) {
|
||||
assert(entity);
|
||||
assert(entity->_element == NULL);
|
||||
_entityItems->push_back(entity);
|
||||
entity->_element = this;
|
||||
}
|
||||
|
||||
// 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 (!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++;
|
||||
//details.oldFound = true; // TODO: would be nice to add this optimization
|
||||
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 (!details.newFound && entityTreeElement->bestFitBounds(details.newCube)) {
|
||||
EntityItemID entityItemID = details.entity->getEntityItemID();
|
||||
entityTreeElement->addEntityItem(details.entity);
|
||||
_tree->setContainingElement(entityItemID, entityTreeElement);
|
||||
// remove from the old before adding
|
||||
EntityTreeElement* oldElement = details.entity->getElement();
|
||||
if (oldElement != entityTreeElement) {
|
||||
if (oldElement) {
|
||||
oldElement->removeEntityItem(details.entity);
|
||||
}
|
||||
entityTreeElement->addEntityItem(details.entity);
|
||||
_tree->setContainingElement(entityItemID, entityTreeElement);
|
||||
}
|
||||
_foundNewCount++;
|
||||
//details.newFound = true; // TODO: would be nice to add this optimization
|
||||
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
|
||||
// and that will confuse our logic.
|
||||
//
|
||||
|
|
|
@ -231,18 +231,19 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* 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
|
||||
// make sure to remove our entity to element map, because for
|
||||
// now we're not in that map
|
||||
if (!_foundNew) {
|
||||
_tree->setContainingElement(_entityItemID, NULL);
|
||||
|
||||
if (_wantDebug) {
|
||||
qDebug() << " *** REMOVING from MAP ***";
|
||||
}
|
||||
if (oldElement != _containingElement) {
|
||||
qDebug() << "WARNING entity moved during UpdateEntityOperator recursion";
|
||||
_containingElement->removeEntityItem(_existingEntity);
|
||||
}
|
||||
|
||||
if (_wantDebug) {
|
||||
qDebug() << " *** REMOVING from MAP ***";
|
||||
}
|
||||
}
|
||||
_foundOld = true;
|
||||
|
@ -263,7 +264,6 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) {
|
|||
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 (entityTreeElement->bestFitBounds(_newEntityBox)) {
|
||||
|
||||
|
@ -271,33 +271,14 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) {
|
|||
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 (entityTreeElement == _containingElement) {
|
||||
if (entityTreeElement == oldElement) {
|
||||
|
||||
if (_wantDebug) {
|
||||
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.
|
||||
_existingEntity->setProperties(_properties);
|
||||
if (_wantDebug) {
|
||||
|
@ -305,14 +286,22 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) {
|
|||
}
|
||||
} else {
|
||||
// otherwise, this is an add case.
|
||||
if (oldElement) {
|
||||
oldElement->removeEntityItem(_existingEntity);
|
||||
if (oldElement != _containingElement) {
|
||||
qDebug() << "WARNING entity moved during UpdateEntityOperator recursion";
|
||||
}
|
||||
}
|
||||
entityTreeElement->addEntityItem(_existingEntity);
|
||||
_existingEntity->setProperties(_properties); // still need to update the properties!
|
||||
_tree->setContainingElement(_entityItemID, entityTreeElement);
|
||||
|
||||
_existingEntity->setProperties(_properties); // still need to update the properties!
|
||||
if (_wantDebug) {
|
||||
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 {
|
||||
keepSearching = true;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ PacketVersion versionForPacketType(PacketType type) {
|
|||
case PacketTypeInjectAudio:
|
||||
return 1;
|
||||
case PacketTypeAvatarData:
|
||||
return 4;
|
||||
return 5;
|
||||
case PacketTypeAvatarIdentity:
|
||||
return 1;
|
||||
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
|
||||
// due to _worldOffset.
|
||||
|
||||
// TODO: Andrew to reconcile Bullet and legacy damping coefficients.
|
||||
|
||||
// compute position error
|
||||
if (glm::length2(_sentVelocity) > 0.0f) {
|
||||
_sentVelocity += _sentAcceleration * dt;
|
||||
|
|
|
@ -111,7 +111,7 @@ protected:
|
|||
glm::vec3 _sentPosition; // in simulation-frame (not world-frame)
|
||||
glm::quat _sentRotation;;
|
||||
glm::vec3 _sentVelocity;
|
||||
glm::vec3 _sentAngularVelocity;
|
||||
glm::vec3 _sentAngularVelocity; // radians per second
|
||||
glm::vec3 _sentAcceleration;
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define hifi_DependencyManager_h
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QDebug>
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
|
@ -22,10 +23,12 @@ public:\
|
|||
private:\
|
||||
void customDeleter() {\
|
||||
QObject* thisObject = dynamic_cast<QObject*>(this);\
|
||||
if (thisObject) {\
|
||||
if (thisObject && thisObject->parent()) {\
|
||||
thisObject->deleteLater();\
|
||||
qDebug() << "Delete later:" << #T;\
|
||||
} else {\
|
||||
delete this;\
|
||||
qDebug() << "Deleted:" << #T;\
|
||||
}\
|
||||
}\
|
||||
friend class DependencyManager;
|
||||
|
|
Loading…
Reference in a new issue