mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 15:10:43 +02:00
changed rotational to angular and added angular damping
This commit is contained in:
parent
f33690cc38
commit
8023735eb3
6 changed files with 149 additions and 95 deletions
|
@ -2897,13 +2897,15 @@ function handeMenuEvent(menuItem) {
|
|||
index++;
|
||||
array.push({ label: "Linear Z:", value: properties.velocity.z.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Angular Pitch:", value: properties.rotationalVelocity.x.toFixed(decimals) });
|
||||
array.push({ label: "Linear Damping:", value: properties.damping.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Angular Yaw:", value: properties.rotationalVelocity.y.toFixed(decimals) });
|
||||
array.push({ label: "Angular Pitch:", value: properties.angularVelocity.x.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Angular Roll:", value: properties.rotationalVelocity.z.toFixed(decimals) });
|
||||
array.push({ label: "Angular Yaw:", value: properties.angularVelocity.y.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Damping:", value: properties.damping.toFixed(decimals) });
|
||||
array.push({ label: "Angular Roll:", value: properties.angularVelocity.z.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Angular Damping:", value: properties.angularDamping.toFixed(decimals) });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Gravity X:", value: properties.gravity.x.toFixed(decimals) });
|
||||
|
@ -3043,12 +3045,13 @@ Window.nonBlockingFormClosed.connect(function() {
|
|||
properties.velocity.x = array[index++].value;
|
||||
properties.velocity.y = array[index++].value;
|
||||
properties.velocity.z = array[index++].value;
|
||||
|
||||
properties.rotationalVelocity.x = array[index++].value;
|
||||
properties.rotationalVelocity.y = array[index++].value;
|
||||
properties.rotationalVelocity.z = array[index++].value;
|
||||
|
||||
properties.damping = array[index++].value;
|
||||
|
||||
properties.angularVelocity.x = array[index++].value;
|
||||
properties.angularVelocity.y = array[index++].value;
|
||||
properties.angularVelocity.z = array[index++].value;
|
||||
properties.angularDamping = array[index++].value;
|
||||
|
||||
properties.gravity.x = array[index++].value;
|
||||
properties.gravity.y = array[index++].value;
|
||||
properties.gravity.z = array[index++].value;
|
||||
|
|
|
@ -27,7 +27,7 @@ const float EntityItem::IMMORTAL = -1.0f; /// special lifetime which means the e
|
|||
const float EntityItem::DEFAULT_GLOW_LEVEL = 0.0f;
|
||||
const float EntityItem::DEFAULT_MASS = 1.0f;
|
||||
const float EntityItem::DEFAULT_LIFETIME = EntityItem::IMMORTAL;
|
||||
const float EntityItem::DEFAULT_DAMPING = 0.99f;
|
||||
const float EntityItem::DEFAULT_DAMPING = 0.5f;
|
||||
const glm::vec3 EntityItem::NO_VELOCITY = glm::vec3(0, 0, 0);
|
||||
const float EntityItem::EPSILON_VELOCITY_LENGTH = (1.0f / 10000.0f) / (float)TREE_SCALE; // really small
|
||||
const glm::vec3 EntityItem::DEFAULT_VELOCITY = EntityItem::NO_VELOCITY;
|
||||
|
@ -38,11 +38,11 @@ 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_ROTATIONAL_VELOCITY = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
const glm::vec3 EntityItem::DEFAULT_ROTATIONAL_VELOCITY = NO_ROTATIONAL_VELOCITY;
|
||||
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 = 0.5f;
|
||||
const bool EntityItem::DEFAULT_VISIBLE = true;
|
||||
|
||||
|
||||
void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
||||
_id = entityItemID.id;
|
||||
_creatorTokenID = entityItemID.creatorTokenID;
|
||||
|
@ -67,7 +67,8 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
|||
_damping = DEFAULT_DAMPING;
|
||||
_lifetime = DEFAULT_LIFETIME;
|
||||
_registrationPoint = DEFAULT_REGISTRATION_POINT;
|
||||
_rotationalVelocity = DEFAULT_ROTATIONAL_VELOCITY;
|
||||
_angularVelocity = DEFAULT_ANGULAR_VELOCITY;
|
||||
_angularDamping = DEFAULT_ANGULAR_DAMPING;
|
||||
_visible = DEFAULT_VISIBLE;
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,8 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
|
|||
requestedProperties += PROP_LIFETIME;
|
||||
requestedProperties += PROP_SCRIPT;
|
||||
requestedProperties += PROP_REGISTRATION_POINT;
|
||||
requestedProperties += PROP_ROTATIONAL_VELOCITY;
|
||||
requestedProperties += PROP_ANGULAR_VELOCITY;
|
||||
requestedProperties += PROP_ANGULAR_DAMPING;
|
||||
requestedProperties += PROP_VISIBLE;
|
||||
|
||||
return requestedProperties;
|
||||
|
@ -212,7 +214,8 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
|||
APPEND_ENTITY_PROPERTY(PROP_LIFETIME, appendValue, getLifetime());
|
||||
APPEND_ENTITY_PROPERTY(PROP_SCRIPT, appendValue, getScript());
|
||||
APPEND_ENTITY_PROPERTY(PROP_REGISTRATION_POINT, appendValue, getRegistrationPoint());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ROTATIONAL_VELOCITY, appendValue, getRotationalVelocity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, appendValue, getAngularVelocity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, appendValue, getAngularDamping());
|
||||
APPEND_ENTITY_PROPERTY(PROP_VISIBLE, appendValue, getVisible());
|
||||
|
||||
appendSubclassData(packetData, params, entityTreeElementExtraEncodeData,
|
||||
|
@ -458,7 +461,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
READ_ENTITY_PROPERTY(PROP_LIFETIME, float, _lifetime);
|
||||
READ_ENTITY_PROPERTY_STRING(PROP_SCRIPT,setScript);
|
||||
READ_ENTITY_PROPERTY(PROP_REGISTRATION_POINT, glm::vec3, _registrationPoint);
|
||||
READ_ENTITY_PROPERTY(PROP_ROTATIONAL_VELOCITY, glm::vec3, _rotationalVelocity);
|
||||
READ_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, glm::vec3, _angularVelocity);
|
||||
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, _angularDamping);
|
||||
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, _visible);
|
||||
|
||||
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData);
|
||||
|
@ -497,6 +501,9 @@ void EntityItem::adjustEditPacketForClockSkew(unsigned char* editPacketBuffer, s
|
|||
|
||||
float EntityItem::getDistanceToBottomOfEntity() const {
|
||||
// TODO: change this to support registration point
|
||||
// TODO: fix this to correctly handle rotation... since _dimensions is in entity space,
|
||||
// if the entity has been rotated, then the distance to world.y=0 is not the same
|
||||
// as the dimensions.y
|
||||
return _dimensions.y / 2.0f;
|
||||
}
|
||||
|
||||
|
@ -525,13 +532,25 @@ void EntityItem::update(const quint64& updateTime) {
|
|||
qDebug() << "********** EntityItem::update() .... SETTING _lastUpdated=" << _lastUpdated;
|
||||
}
|
||||
|
||||
if (hasRotationalVelocity()) {
|
||||
if (hasAngularVelocity()) {
|
||||
glm::quat rotation = getRotation();
|
||||
glm::vec3 rotationalVelocity = glm::radians(getRotationalVelocity());
|
||||
float angle = timeElapsed * glm::length(rotationalVelocity);
|
||||
glm::quat dQ = glm::angleAxis(angle, glm::normalize(rotationalVelocity));
|
||||
glm::vec3 angularVelocity = glm::radians(getAngularVelocity());
|
||||
float angle = timeElapsed * glm::length(angularVelocity);
|
||||
glm::quat dQ = glm::angleAxis(angle, glm::normalize(angularVelocity));
|
||||
rotation = dQ * rotation;
|
||||
setRotation(rotation);
|
||||
|
||||
// handle damping for angular velocity
|
||||
if (getAngularDamping() > 0.0f) {
|
||||
glm::vec3 dampingResistance = getAngularVelocity() * getAngularDamping();
|
||||
if (wantDebug) {
|
||||
qDebug() << " getDamping():" << getDamping();
|
||||
qDebug() << " dampingResistance:" << dampingResistance;
|
||||
qDebug() << " dampingResistance * timeElapsed:" << dampingResistance * timeElapsed;
|
||||
}
|
||||
glm::vec3 newAngularVelocity = getAngularVelocity() - (dampingResistance * timeElapsed);
|
||||
setAngularVelocity(newAngularVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasVelocity() || hasGravity()) {
|
||||
|
@ -610,7 +629,7 @@ EntityItem::SimulationState EntityItem::getSimulationState() const {
|
|||
if (hasVelocity() || (hasGravity() && !isRestingOnSurface())) {
|
||||
return EntityItem::Moving;
|
||||
}
|
||||
if (hasRotationalVelocity()) {
|
||||
if (hasAngularVelocity()) {
|
||||
return EntityItem::Changing;
|
||||
}
|
||||
if (isMortal()) {
|
||||
|
@ -647,7 +666,8 @@ EntityItemProperties EntityItem::getProperties() const {
|
|||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(lifetime, getLifetime);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(script, getScript);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(registrationPoint, getRegistrationPoint);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(rotationalVelocity, getRotationalVelocity);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularVelocity, getAngularVelocity);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularDamping, getAngularDamping);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(glowLevel, getGlowLevel);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(visible, getVisible);
|
||||
|
||||
|
@ -678,7 +698,8 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc
|
|||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lifetime, setLifetime);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(script, setScript);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(registrationPoint, setRegistrationPoint);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(rotationalVelocity, setRotationalVelocity);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularVelocity, setAngularVelocity);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularDamping, setAngularDamping);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(glowLevel, setGlowLevel);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(visible, setVisible);
|
||||
|
||||
|
|
|
@ -205,11 +205,15 @@ public:
|
|||
const glm::vec3& getRegistrationPoint() const { return _registrationPoint; } /// registration point as ratio of entity
|
||||
void setRegistrationPoint(const glm::vec3& value) { _registrationPoint = value; } /// registration point as ratio of entity
|
||||
|
||||
static const glm::vec3 NO_ROTATIONAL_VELOCITY;
|
||||
static const glm::vec3 DEFAULT_ROTATIONAL_VELOCITY;
|
||||
const glm::vec3& getRotationalVelocity() const { return _rotationalVelocity; }
|
||||
void setRotationalVelocity(const glm::vec3& value) { _rotationalVelocity = value; }
|
||||
bool hasRotationalVelocity() const { return _rotationalVelocity != NO_ROTATIONAL_VELOCITY; }
|
||||
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; }
|
||||
|
@ -241,7 +245,8 @@ protected:
|
|||
float _lifetime;
|
||||
QString _script;
|
||||
glm::vec3 _registrationPoint;
|
||||
glm::vec3 _rotationalVelocity;
|
||||
glm::vec3 _angularVelocity;
|
||||
float _angularDamping;
|
||||
bool _visible;
|
||||
|
||||
// NOTE: Radius support is obsolete, but these private helper functions are available for this class to
|
||||
|
|
|
@ -38,7 +38,8 @@ EntityItemProperties::EntityItemProperties() :
|
|||
_lifetime(EntityItem::DEFAULT_LIFETIME),
|
||||
_script(EntityItem::DEFAULT_SCRIPT),
|
||||
_registrationPoint(EntityItem::DEFAULT_REGISTRATION_POINT),
|
||||
_rotationalVelocity(EntityItem::DEFAULT_ROTATIONAL_VELOCITY),
|
||||
_angularVelocity(EntityItem::DEFAULT_ANGULAR_VELOCITY),
|
||||
_angularDamping(EntityItem::DEFAULT_ANGULAR_DAMPING),
|
||||
_visible(EntityItem::DEFAULT_VISIBLE),
|
||||
|
||||
_positionChanged(false),
|
||||
|
@ -51,7 +52,8 @@ EntityItemProperties::EntityItemProperties() :
|
|||
_lifetimeChanged(false),
|
||||
_scriptChanged(false),
|
||||
_registrationPointChanged(false),
|
||||
_rotationalVelocityChanged(false),
|
||||
_angularVelocityChanged(false),
|
||||
_angularDampingChanged(false),
|
||||
_visibleChanged(false),
|
||||
|
||||
_color(),
|
||||
|
@ -108,7 +110,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
|||
CHECK_PROPERTY_CHANGE(PROP_ANIMATION_FPS, animationFPS);
|
||||
CHECK_PROPERTY_CHANGE(PROP_VISIBLE, visible);
|
||||
CHECK_PROPERTY_CHANGE(PROP_REGISTRATION_POINT, registrationPoint);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ROTATIONAL_VELOCITY, rotationalVelocity);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANGULAR_VELOCITY, angularVelocity);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANGULAR_DAMPING, angularDamping);
|
||||
|
||||
return changedProperties;
|
||||
}
|
||||
|
@ -117,51 +120,36 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
|
|||
QScriptValue properties = engine->newObject();
|
||||
|
||||
if (_idSet) {
|
||||
properties.setProperty("id", _id.toString());
|
||||
bool isKnownID = (_id != UNKNOWN_ENTITY_ID);
|
||||
properties.setProperty("isKnownID", isKnownID);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(id, _id.toString());
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(isKnownID, (_id != UNKNOWN_ENTITY_ID));
|
||||
} else {
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(isKnownID, false);
|
||||
}
|
||||
|
||||
properties.setProperty("type", EntityTypes::getEntityTypeName(_type));
|
||||
|
||||
QScriptValue position = vec3toScriptValue(engine, _position);
|
||||
properties.setProperty("position", position);
|
||||
QScriptValue dimensions = vec3toScriptValue(engine, _dimensions);
|
||||
properties.setProperty("dimensions", dimensions);
|
||||
|
||||
QScriptValue naturalDimensions = vec3toScriptValue(engine, _naturalDimensions);
|
||||
properties.setProperty("naturalDimensions", naturalDimensions);
|
||||
|
||||
QScriptValue rotation = quatToScriptValue(engine, _rotation);
|
||||
properties.setProperty("rotation", rotation);
|
||||
properties.setProperty("mass", _mass);
|
||||
QScriptValue velocity = vec3toScriptValue(engine, _velocity);
|
||||
properties.setProperty("velocity", velocity);
|
||||
QScriptValue gravity = vec3toScriptValue(engine, _gravity);
|
||||
properties.setProperty("gravity", gravity);
|
||||
properties.setProperty("damping", _damping);
|
||||
properties.setProperty("lifetime", _lifetime);
|
||||
properties.setProperty("age", getAge()); // gettable, but not settable
|
||||
properties.setProperty("ageAsText", formatSecondsElapsed(getAge())); // gettable, but not settable
|
||||
properties.setProperty("script", _script);
|
||||
|
||||
QScriptValue registrationPoint = vec3toScriptValue(engine, _registrationPoint);
|
||||
properties.setProperty("registrationPoint", registrationPoint);
|
||||
|
||||
QScriptValue rotationalVelocity = vec3toScriptValue(engine, _rotationalVelocity);
|
||||
properties.setProperty("rotationalVelocity", rotationalVelocity);
|
||||
|
||||
properties.setProperty("visible", _visible);
|
||||
|
||||
QScriptValue color = xColorToScriptValue(engine, _color);
|
||||
properties.setProperty("color", color);
|
||||
properties.setProperty("modelURL", _modelURL);
|
||||
|
||||
properties.setProperty("animationURL", _animationURL);
|
||||
properties.setProperty("animationIsPlaying", _animationIsPlaying);
|
||||
properties.setProperty("animationFrameIndex", _animationFrameIndex);
|
||||
properties.setProperty("animationFPS", _animationFPS);
|
||||
properties.setProperty("glowLevel", _glowLevel);
|
||||
//properties.setProperty("type", EntityTypes::getEntityTypeName(_type));
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(type, EntityTypes::getEntityTypeName(_type));
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_VEC3(position);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_VEC3(dimensions);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_VEC3(naturalDimensions); // gettable, but not settable
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_QUAT(rotation);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_VEC3(velocity);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_VEC3(gravity);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(damping);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(lifetime);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(age, getAge()); // gettable, but not settable
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(ageAsText, formatSecondsElapsed(getAge())); // gettable, but not settable
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(script);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_VEC3(registrationPoint);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_VEC3(angularVelocity);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(angularDamping);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(visible);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR(color);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(modelURL);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(animationURL);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(animationIsPlaying);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(animationFrameIndex);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(animationFPS);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(glowLevel);
|
||||
|
||||
// Sitting properties support
|
||||
QScriptValue sittingPoints = engine->newObject();
|
||||
|
@ -173,7 +161,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
|
|||
sittingPoints.setProperty(i, sittingPoint);
|
||||
}
|
||||
sittingPoints.setProperty("length", _sittingPoints.size());
|
||||
properties.setProperty("sittingPoints", sittingPoints);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(sittingPoints, sittingPoints); // gettable, but not settable
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
@ -328,23 +316,33 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) {
|
|||
}
|
||||
}
|
||||
|
||||
QScriptValue rotationalVelocity = object.property("rotationalVelocity");
|
||||
if (rotationalVelocity.isValid()) {
|
||||
QScriptValue x = rotationalVelocity.property("x");
|
||||
QScriptValue y = rotationalVelocity.property("y");
|
||||
QScriptValue z = rotationalVelocity.property("z");
|
||||
QScriptValue angularVelocity = object.property("angularVelocity");
|
||||
if (angularVelocity.isValid()) {
|
||||
QScriptValue x = angularVelocity.property("x");
|
||||
QScriptValue y = angularVelocity.property("y");
|
||||
QScriptValue z = angularVelocity.property("z");
|
||||
if (x.isValid() && y.isValid() && z.isValid()) {
|
||||
glm::vec3 newRotation;
|
||||
newRotation.x = x.toVariant().toFloat();
|
||||
newRotation.y = y.toVariant().toFloat();
|
||||
newRotation.z = z.toVariant().toFloat();
|
||||
if (_defaultSettings || newRotation != _rotationalVelocity) {
|
||||
_rotationalVelocity = newRotation;
|
||||
_rotationalVelocityChanged = true;
|
||||
if (_defaultSettings || newRotation != _angularVelocity) {
|
||||
_angularVelocity = newRotation;
|
||||
_angularVelocityChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue angularDamping = object.property("angularDamping");
|
||||
if (angularDamping.isValid()) {
|
||||
float newValue;
|
||||
newValue = angularDamping.toVariant().toFloat();
|
||||
if (_defaultSettings || newValue != _angularDamping) {
|
||||
_angularDamping = newValue;
|
||||
_angularDampingChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
QScriptValue visible = object.property("visible");
|
||||
if (visible.isValid()) {
|
||||
bool newValue;
|
||||
|
@ -577,7 +575,8 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
|||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, appendValue, properties.getAnimationFrameIndex());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, appendValue, properties.getAnimationIsPlaying());
|
||||
APPEND_ENTITY_PROPERTY(PROP_REGISTRATION_POINT, appendValue, properties.getRegistrationPoint());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ROTATIONAL_VELOCITY, appendValue, properties.getRotationalVelocity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, appendValue, properties.getAngularVelocity());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, appendValue, properties.getAngularDamping());
|
||||
APPEND_ENTITY_PROPERTY(PROP_VISIBLE, appendValue, properties.getVisible());
|
||||
}
|
||||
if (propertyCount > 0) {
|
||||
|
@ -772,7 +771,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
|||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANIMATION_FRAME_INDEX, float, setAnimationFrameIndex);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANIMATION_PLAYING, bool, setAnimationIsPlaying);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_REGISTRATION_POINT, glm::vec3, setRegistrationPoint);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ROTATIONAL_VELOCITY, glm::vec3, setRotationalVelocity);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANGULAR_VELOCITY, glm::vec3, setAngularVelocity);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANGULAR_DAMPING, float, setAngularDamping);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_VISIBLE, bool, setVisible);
|
||||
|
||||
return valid;
|
||||
|
|
|
@ -60,9 +60,10 @@ enum EntityPropertyList {
|
|||
|
||||
// these properties are supported by the EntityItem base class
|
||||
PROP_REGISTRATION_POINT,
|
||||
PROP_ROTATIONAL_VELOCITY,
|
||||
PROP_ANGULAR_VELOCITY,
|
||||
PROP_ANGULAR_DAMPING,
|
||||
|
||||
PROP_LAST_ITEM = PROP_ROTATIONAL_VELOCITY
|
||||
PROP_LAST_ITEM = PROP_ANGULAR_DAMPING
|
||||
};
|
||||
|
||||
typedef PropertyFlags<EntityPropertyList> EntityPropertyFlags;
|
||||
|
@ -217,14 +218,15 @@ public:
|
|||
const glm::vec3& getRegistrationPoint() const { return _registrationPoint; }
|
||||
void setRegistrationPoint(const glm::vec3& value) { _registrationPoint = value; _registrationPointChanged = true; }
|
||||
|
||||
const glm::vec3& getRotationalVelocity() const { return _rotationalVelocity; }
|
||||
void setRotationalVelocity(const glm::vec3& value) { _rotationalVelocity = value; _rotationalVelocityChanged = true; }
|
||||
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
||||
void setAngularVelocity(const glm::vec3& value) { _angularVelocity = value; _angularVelocityChanged = true; }
|
||||
|
||||
float getAngularDamping() const { return _angularDamping; }
|
||||
void setAngularDamping(float value) { _angularDamping = value; _angularDampingChanged = true; }
|
||||
|
||||
bool getVisible() const { return _visible; }
|
||||
void setVisible(bool value) { _visible = value; _visibleChanged = true; }
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; }
|
||||
|
||||
|
@ -244,7 +246,8 @@ private:
|
|||
float _lifetime;
|
||||
QString _script;
|
||||
glm::vec3 _registrationPoint;
|
||||
glm::vec3 _rotationalVelocity;
|
||||
glm::vec3 _angularVelocity;
|
||||
float _angularDamping;
|
||||
bool _visible;
|
||||
|
||||
bool _positionChanged;
|
||||
|
@ -257,7 +260,8 @@ private:
|
|||
bool _lifetimeChanged;
|
||||
bool _scriptChanged;
|
||||
bool _registrationPointChanged;
|
||||
bool _rotationalVelocityChanged;
|
||||
bool _angularVelocityChanged;
|
||||
bool _angularDampingChanged;
|
||||
bool _visibleChanged;
|
||||
|
||||
// TODO: this need to be more generic. for now, we're going to have the properties class support these as
|
||||
|
|
|
@ -134,4 +134,25 @@
|
|||
changedProperties += P; \
|
||||
}
|
||||
|
||||
|
||||
#define COPY_PROPERTY_TO_QSCRIPTVALUE_VEC3(P) \
|
||||
QScriptValue P = vec3toScriptValue(engine, _##P); \
|
||||
properties.setProperty(#P, P);
|
||||
|
||||
#define COPY_PROPERTY_TO_QSCRIPTVALUE_QUAT(P) \
|
||||
QScriptValue P = quatToScriptValue(engine, _##P); \
|
||||
properties.setProperty(#P, P);
|
||||
|
||||
#define COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR(P) \
|
||||
QScriptValue P = xColorToScriptValue(engine, _##P); \
|
||||
properties.setProperty(#P, P);
|
||||
|
||||
#define COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(P, G) \
|
||||
properties.setProperty(#P, G);
|
||||
|
||||
|
||||
#define COPY_PROPERTY_TO_QSCRIPTVALUE(P) \
|
||||
properties.setProperty(#P, _##P);
|
||||
|
||||
|
||||
#endif // hifi_EntityItemPropertiesMacros_h
|
||||
|
|
Loading…
Reference in a new issue