mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
properties hold local velocities, not world-frame ones
This commit is contained in:
parent
6a646f1c24
commit
ffce38769f
2 changed files with 12 additions and 8 deletions
|
@ -76,8 +76,8 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) :
|
||||||
_physicsInfo(nullptr),
|
_physicsInfo(nullptr),
|
||||||
_simulated(false)
|
_simulated(false)
|
||||||
{
|
{
|
||||||
setVelocity(ENTITY_ITEM_DEFAULT_VELOCITY);
|
setLocalVelocity(ENTITY_ITEM_DEFAULT_VELOCITY);
|
||||||
setAngularVelocity(ENTITY_ITEM_DEFAULT_ANGULAR_VELOCITY);
|
setLocalAngularVelocity(ENTITY_ITEM_DEFAULT_ANGULAR_VELOCITY);
|
||||||
// explicitly set transform parts to set dirty flags used by batch rendering
|
// explicitly set transform parts to set dirty flags used by batch rendering
|
||||||
setScale(ENTITY_ITEM_DEFAULT_DIMENSIONS);
|
setScale(ENTITY_ITEM_DEFAULT_DIMENSIONS);
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
@ -244,8 +244,8 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SIMULATION_OWNER, _simulationOwner.toByteArray());
|
APPEND_ENTITY_PROPERTY(PROP_SIMULATION_OWNER, _simulationOwner.toByteArray());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_POSITION, getLocalPosition());
|
APPEND_ENTITY_PROPERTY(PROP_POSITION, getLocalPosition());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ROTATION, getLocalOrientation());
|
APPEND_ENTITY_PROPERTY(PROP_ROTATION, getLocalOrientation());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_VELOCITY, getVelocity());
|
APPEND_ENTITY_PROPERTY(PROP_VELOCITY, getLocalVelocity());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, getAngularVelocity());
|
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, getLocalAngularVelocity());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ACCELERATION, getAcceleration());
|
APPEND_ENTITY_PROPERTY(PROP_ACCELERATION, getAcceleration());
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_DIMENSIONS, getDimensions()); // NOTE: PROP_RADIUS obsolete
|
APPEND_ENTITY_PROPERTY(PROP_DIMENSIONS, getDimensions()); // NOTE: PROP_RADIUS obsolete
|
||||||
|
@ -1054,7 +1054,7 @@ EntityItemProperties EntityItem::getProperties(EntityPropertyFlags desiredProper
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(dimensions, getDimensions); // NOTE: radius is obsolete
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(dimensions, getDimensions); // NOTE: radius is obsolete
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(rotation, getLocalOrientation);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(rotation, getLocalOrientation);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(density, getDensity);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(density, getDensity);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(velocity, getVelocity);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(velocity, getLocalVelocity);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(gravity, getGravity);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(gravity, getGravity);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(acceleration, getAcceleration);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(acceleration, getAcceleration);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(damping, getDamping);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(damping, getDamping);
|
||||||
|
@ -1066,7 +1066,7 @@ EntityItemProperties EntityItem::getProperties(EntityPropertyFlags desiredProper
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(scriptTimestamp, getScriptTimestamp);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(scriptTimestamp, getScriptTimestamp);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(collisionSoundURL, getCollisionSoundURL);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(collisionSoundURL, getCollisionSoundURL);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(registrationPoint, getRegistrationPoint);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(registrationPoint, getRegistrationPoint);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularVelocity, getAngularVelocity);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularVelocity, getLocalAngularVelocity);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularDamping, getAngularDamping);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularDamping, getAngularDamping);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(glowLevel, getGlowLevel);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(glowLevel, getGlowLevel);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(localRenderAlpha, getLocalRenderAlpha);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(localRenderAlpha, getLocalRenderAlpha);
|
||||||
|
|
|
@ -81,6 +81,8 @@ EntityItemProperties convertLocationToScriptSemantics(const EntityItemProperties
|
||||||
entitySideProperties.getParentID(),
|
entitySideProperties.getParentID(),
|
||||||
entitySideProperties.getParentJointIndex(),
|
entitySideProperties.getParentJointIndex(),
|
||||||
success);
|
success);
|
||||||
|
// TODO -- handle velocity and angularVelocity
|
||||||
|
|
||||||
scriptSideProperties.setPosition(worldPosition);
|
scriptSideProperties.setPosition(worldPosition);
|
||||||
scriptSideProperties.setRotation(worldRotation);
|
scriptSideProperties.setRotation(worldRotation);
|
||||||
|
|
||||||
|
@ -94,6 +96,8 @@ EntityItemProperties convertLocationFromScriptSemantics(const EntityItemProperti
|
||||||
EntityItemProperties entitySideProperties = scriptSideProperties;
|
EntityItemProperties entitySideProperties = scriptSideProperties;
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
|
// TODO -- handle velocity and angularVelocity
|
||||||
|
|
||||||
if (scriptSideProperties.localPositionChanged()) {
|
if (scriptSideProperties.localPositionChanged()) {
|
||||||
entitySideProperties.setPosition(scriptSideProperties.getLocalPosition());
|
entitySideProperties.setPosition(scriptSideProperties.getLocalPosition());
|
||||||
} else if (scriptSideProperties.positionChanged()) {
|
} else if (scriptSideProperties.positionChanged()) {
|
||||||
|
@ -128,14 +132,14 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
||||||
auto newVelocity = propertiesWithSimID.getVelocity().length();
|
auto newVelocity = propertiesWithSimID.getVelocity().length();
|
||||||
float cost = calculateCost(density * volume, 0, newVelocity);
|
float cost = calculateCost(density * volume, 0, newVelocity);
|
||||||
cost *= costMultiplier;
|
cost *= costMultiplier;
|
||||||
|
|
||||||
if(cost > _currentAvatarEnergy) {
|
if(cost > _currentAvatarEnergy) {
|
||||||
return QUuid();
|
return QUuid();
|
||||||
} else {
|
} else {
|
||||||
//debit the avatar energy and continue
|
//debit the avatar energy and continue
|
||||||
emit debitEnergySource(cost);
|
emit debitEnergySource(cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItemID id = EntityItemID(QUuid::createUuid());
|
EntityItemID id = EntityItemID(QUuid::createUuid());
|
||||||
|
|
||||||
// If we have a local entity tree set, then also update it.
|
// If we have a local entity tree set, then also update it.
|
||||||
|
|
Loading…
Reference in a new issue