mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:58:03 +02:00
Merge pull request #3490 from ZappoMan/moreWorkOnCollidingEntitites
add support for ignore collisions and collisions will/wont move entities
This commit is contained in:
commit
7223cf8d2a
7 changed files with 123 additions and 29 deletions
|
@ -2907,8 +2907,6 @@ function handeMenuEvent(menuItem) {
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Linear Damping:", value: properties.damping.toFixed(decimals) });
|
array.push({ label: "Linear Damping:", value: properties.damping.toFixed(decimals) });
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Mass:", value: properties.mass.toFixed(decimals) });
|
|
||||||
index++;
|
|
||||||
array.push({ label: "Angular Pitch:", value: properties.angularVelocity.x.toFixed(decimals) });
|
array.push({ label: "Angular Pitch:", value: properties.angularVelocity.x.toFixed(decimals) });
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Angular Yaw:", value: properties.angularVelocity.y.toFixed(decimals) });
|
array.push({ label: "Angular Yaw:", value: properties.angularVelocity.y.toFixed(decimals) });
|
||||||
|
@ -2925,6 +2923,15 @@ function handeMenuEvent(menuItem) {
|
||||||
array.push({ label: "Gravity Z:", value: properties.gravity.z.toFixed(decimals) });
|
array.push({ label: "Gravity Z:", value: properties.gravity.z.toFixed(decimals) });
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
|
array.push({ label: "Collisions:", type: "header" });
|
||||||
|
index++;
|
||||||
|
array.push({ label: "Mass:", value: properties.mass.toFixed(decimals) });
|
||||||
|
index++;
|
||||||
|
array.push({ label: "Ignore for Collisions:", value: properties.ignoreForCollisions });
|
||||||
|
index++;
|
||||||
|
array.push({ label: "Collisions Will Move:", value: properties.collisionsWillMove });
|
||||||
|
index++;
|
||||||
|
|
||||||
array.push({ label: "Lifetime:", value: properties.lifetime.toFixed(decimals) });
|
array.push({ label: "Lifetime:", value: properties.lifetime.toFixed(decimals) });
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
|
@ -3055,7 +3062,6 @@ Window.nonBlockingFormClosed.connect(function() {
|
||||||
properties.velocity.y = array[index++].value;
|
properties.velocity.y = array[index++].value;
|
||||||
properties.velocity.z = array[index++].value;
|
properties.velocity.z = array[index++].value;
|
||||||
properties.damping = array[index++].value;
|
properties.damping = array[index++].value;
|
||||||
properties.mass = array[index++].value;
|
|
||||||
|
|
||||||
properties.angularVelocity.x = array[index++].value;
|
properties.angularVelocity.x = array[index++].value;
|
||||||
properties.angularVelocity.y = array[index++].value;
|
properties.angularVelocity.y = array[index++].value;
|
||||||
|
@ -3065,6 +3071,12 @@ Window.nonBlockingFormClosed.connect(function() {
|
||||||
properties.gravity.x = array[index++].value;
|
properties.gravity.x = array[index++].value;
|
||||||
properties.gravity.y = array[index++].value;
|
properties.gravity.y = array[index++].value;
|
||||||
properties.gravity.z = array[index++].value;
|
properties.gravity.z = array[index++].value;
|
||||||
|
|
||||||
|
index++; // skip header
|
||||||
|
properties.mass = array[index++].value;
|
||||||
|
properties.ignoreForCollisions = array[index++].value;
|
||||||
|
properties.collisionsWillMove = array[index++].value;
|
||||||
|
|
||||||
properties.lifetime = array[index++].value;
|
properties.lifetime = array[index++].value;
|
||||||
properties.visible = array[index++].value;
|
properties.visible = array[index++].value;
|
||||||
|
|
||||||
|
|
|
@ -105,10 +105,15 @@ void EntityCollisionSystem::updateCollisionWithVoxels(EntityItem* entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
||||||
|
|
||||||
|
if (entityA->getIgnoreForCollisions()) {
|
||||||
|
return; // bail early if this entity is to be ignored...
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 penetration;
|
glm::vec3 penetration;
|
||||||
EntityItem* entityB = NULL;
|
EntityItem* entityB = NULL;
|
||||||
|
|
||||||
const float MAX_COLLISIONS_PER_ENTITY = 32;
|
const int MAX_COLLISIONS_PER_ENTITY = 32;
|
||||||
CollisionList collisions(MAX_COLLISIONS_PER_ENTITY);
|
CollisionList collisions(MAX_COLLISIONS_PER_ENTITY);
|
||||||
bool shapeCollisionsAccurate = false;
|
bool shapeCollisionsAccurate = false;
|
||||||
|
|
||||||
|
@ -134,8 +139,13 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
||||||
// we don't want to count this as a collision.
|
// we don't want to count this as a collision.
|
||||||
glm::vec3 relativeVelocity = entityA->getVelocity() - entityB->getVelocity();
|
glm::vec3 relativeVelocity = entityA->getVelocity() - entityB->getVelocity();
|
||||||
|
|
||||||
|
bool wantToMoveA = entityA->getCollisionsWillMove();
|
||||||
|
bool wantToMoveB = entityB->getCollisionsWillMove();
|
||||||
bool movingTowardEachOther = glm::dot(relativeVelocity, penetrationInTreeUnits) > 0.0f;
|
bool movingTowardEachOther = glm::dot(relativeVelocity, penetrationInTreeUnits) > 0.0f;
|
||||||
bool doCollisions = movingTowardEachOther; // don't do collisions if the entities are moving away from each other
|
|
||||||
|
// only do collisions if the entities are moving toward each other and one or the other
|
||||||
|
// of the entities are movable from collisions
|
||||||
|
bool doCollisions = movingTowardEachOther && (wantToMoveA || wantToMoveB);
|
||||||
|
|
||||||
if (doCollisions) {
|
if (doCollisions) {
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
@ -152,9 +162,25 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
||||||
float massA = entityA->getMass();
|
float massA = entityA->getMass();
|
||||||
float massB = entityB->getMass();
|
float massB = entityB->getMass();
|
||||||
float totalMass = massA + massB;
|
float totalMass = massA + massB;
|
||||||
|
float massRatioA = (2.0f * massB / totalMass);
|
||||||
|
float massRatioB = (2.0f * massA / totalMass);
|
||||||
|
|
||||||
|
// in the event that one of our entities is non-moving, then fix up these ratios
|
||||||
|
if (wantToMoveA && !wantToMoveB) {
|
||||||
|
massRatioA = 2.0f;
|
||||||
|
massRatioB = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wantToMoveA && wantToMoveB) {
|
||||||
|
massRatioA = 0.0f;
|
||||||
|
massRatioB = 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unless the entity is configured to not be moved by collision, calculate it's new position
|
||||||
|
// and velocity and apply it
|
||||||
|
if (wantToMoveA) {
|
||||||
// handle Entity A
|
// handle Entity A
|
||||||
glm::vec3 newVelocityA = entityA->getVelocity() - axialVelocity * (2.0f * massB / totalMass);
|
glm::vec3 newVelocityA = entityA->getVelocity() - axialVelocity * massRatioA;
|
||||||
glm::vec3 newPositionA = entityA->getPosition() - 0.5f * penetrationInTreeUnits;
|
glm::vec3 newPositionA = entityA->getPosition() - 0.5f * penetrationInTreeUnits;
|
||||||
|
|
||||||
EntityItemProperties propertiesA = entityA->getProperties();
|
EntityItemProperties propertiesA = entityA->getProperties();
|
||||||
|
@ -165,8 +191,12 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
||||||
|
|
||||||
_entities->updateEntity(idA, propertiesA);
|
_entities->updateEntity(idA, propertiesA);
|
||||||
_packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idA, propertiesA);
|
_packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idA, propertiesA);
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 newVelocityB = entityB->getVelocity() + axialVelocity * (2.0f * massA / totalMass);
|
// unless the entity is configured to not be moved by collision, calculate it's new position
|
||||||
|
// and velocity and apply it
|
||||||
|
if (wantToMoveB) {
|
||||||
|
glm::vec3 newVelocityB = entityB->getVelocity() + axialVelocity * massRatioB;
|
||||||
glm::vec3 newPositionB = entityB->getPosition() + 0.5f * penetrationInTreeUnits;
|
glm::vec3 newPositionB = entityB->getPosition() + 0.5f * penetrationInTreeUnits;
|
||||||
|
|
||||||
EntityItemProperties propertiesB = entityB->getProperties();
|
EntityItemProperties propertiesB = entityB->getProperties();
|
||||||
|
@ -178,9 +208,7 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
||||||
|
|
||||||
_entities->updateEntity(idB, propertiesB);
|
_entities->updateEntity(idB, propertiesB);
|
||||||
_packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB);
|
_packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, idB, propertiesB);
|
||||||
|
}
|
||||||
// TODO: Do we need this?
|
|
||||||
//_packetSender->releaseQueuedMessages();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ 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 glm::vec3 EntityItem::DEFAULT_ANGULAR_VELOCITY = NO_ANGULAR_VELOCITY;
|
||||||
const float EntityItem::DEFAULT_ANGULAR_DAMPING = 0.5f;
|
const float EntityItem::DEFAULT_ANGULAR_DAMPING = 0.5f;
|
||||||
const bool EntityItem::DEFAULT_VISIBLE = true;
|
const bool EntityItem::DEFAULT_VISIBLE = true;
|
||||||
|
const bool EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS = false;
|
||||||
|
const bool EntityItem::DEFAULT_COLLISIONS_WILL_MOVE = false;
|
||||||
|
|
||||||
void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
||||||
_id = entityItemID.id;
|
_id = entityItemID.id;
|
||||||
|
@ -70,6 +72,8 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
||||||
_angularVelocity = DEFAULT_ANGULAR_VELOCITY;
|
_angularVelocity = DEFAULT_ANGULAR_VELOCITY;
|
||||||
_angularDamping = DEFAULT_ANGULAR_DAMPING;
|
_angularDamping = DEFAULT_ANGULAR_DAMPING;
|
||||||
_visible = DEFAULT_VISIBLE;
|
_visible = DEFAULT_VISIBLE;
|
||||||
|
_ignoreForCollisions = DEFAULT_IGNORE_FOR_COLLISIONS;
|
||||||
|
_collisionsWillMove = DEFAULT_COLLISIONS_WILL_MOVE;
|
||||||
|
|
||||||
recalculateCollisionShape();
|
recalculateCollisionShape();
|
||||||
}
|
}
|
||||||
|
@ -111,6 +115,8 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
|
||||||
requestedProperties += PROP_ANGULAR_VELOCITY;
|
requestedProperties += PROP_ANGULAR_VELOCITY;
|
||||||
requestedProperties += PROP_ANGULAR_DAMPING;
|
requestedProperties += PROP_ANGULAR_DAMPING;
|
||||||
requestedProperties += PROP_VISIBLE;
|
requestedProperties += PROP_VISIBLE;
|
||||||
|
requestedProperties += PROP_IGNORE_FOR_COLLISIONS;
|
||||||
|
requestedProperties += PROP_COLLISIONS_WILL_MOVE;
|
||||||
|
|
||||||
return requestedProperties;
|
return requestedProperties;
|
||||||
}
|
}
|
||||||
|
@ -224,6 +230,8 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, appendValue, getAngularVelocity());
|
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, appendValue, getAngularVelocity());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, appendValue, getAngularDamping());
|
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, appendValue, getAngularDamping());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_VISIBLE, appendValue, getVisible());
|
APPEND_ENTITY_PROPERTY(PROP_VISIBLE, appendValue, getVisible());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, appendValue, getIgnoreForCollisions());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_COLLISIONS_WILL_MOVE, appendValue, getCollisionsWillMove());
|
||||||
|
|
||||||
appendSubclassData(packetData, params, entityTreeElementExtraEncodeData,
|
appendSubclassData(packetData, params, entityTreeElementExtraEncodeData,
|
||||||
requestedProperties,
|
requestedProperties,
|
||||||
|
@ -484,10 +492,14 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
READ_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, glm::vec3, _angularVelocity);
|
READ_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, glm::vec3, _angularVelocity);
|
||||||
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, _angularDamping);
|
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, _angularDamping);
|
||||||
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, _visible);
|
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, _visible);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, bool, _ignoreForCollisions);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_COLLISIONS_WILL_MOVE, bool, _collisionsWillMove);
|
||||||
|
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
qDebug() << " readEntityDataFromBuffer() _registrationPoint:" << _registrationPoint;
|
qDebug() << " readEntityDataFromBuffer() _registrationPoint:" << _registrationPoint;
|
||||||
qDebug() << " readEntityDataFromBuffer() _visible:" << _visible;
|
qDebug() << " readEntityDataFromBuffer() _visible:" << _visible;
|
||||||
|
qDebug() << " readEntityDataFromBuffer() _ignoreForCollisions:" << _ignoreForCollisions;
|
||||||
|
qDebug() << " readEntityDataFromBuffer() _collisionsWillMove:" << _collisionsWillMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData);
|
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData);
|
||||||
|
@ -734,6 +746,8 @@ EntityItemProperties EntityItem::getProperties() const {
|
||||||
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(visible, getVisible);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(visible, getVisible);
|
||||||
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(ignoreForCollisions, getIgnoreForCollisions);
|
||||||
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(collisionsWillMove, getCollisionsWillMove);
|
||||||
|
|
||||||
properties._defaultSettings = false;
|
properties._defaultSettings = false;
|
||||||
|
|
||||||
|
@ -766,6 +780,8 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularDamping, setAngularDamping);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularDamping, setAngularDamping);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(glowLevel, setGlowLevel);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(glowLevel, setGlowLevel);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(visible, setVisible);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(visible, setVisible);
|
||||||
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(ignoreForCollisions, setIgnoreForCollisions);
|
||||||
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(collisionsWillMove, setCollisionsWillMove);
|
||||||
|
|
||||||
if (somethingChanged) {
|
if (somethingChanged) {
|
||||||
somethingChangedNotification(); // notify derived classes that something has changed
|
somethingChangedNotification(); // notify derived classes that something has changed
|
||||||
|
|
|
@ -231,6 +231,14 @@ public:
|
||||||
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; }
|
||||||
|
void setIgnoreForCollisions(bool value) { _ignoreForCollisions = value; }
|
||||||
|
|
||||||
|
static const bool DEFAULT_COLLISIONS_WILL_MOVE;
|
||||||
|
bool getCollisionsWillMove() const { return _collisionsWillMove; }
|
||||||
|
void setCollisionsWillMove(bool value) { _collisionsWillMove = value; }
|
||||||
|
|
||||||
// TODO: We need to get rid of these users of getRadius()...
|
// TODO: We need to get rid of these users of getRadius()...
|
||||||
float getRadius() const;
|
float getRadius() const;
|
||||||
|
|
||||||
|
@ -265,6 +273,8 @@ protected:
|
||||||
glm::vec3 _angularVelocity;
|
glm::vec3 _angularVelocity;
|
||||||
float _angularDamping;
|
float _angularDamping;
|
||||||
bool _visible;
|
bool _visible;
|
||||||
|
bool _ignoreForCollisions;
|
||||||
|
bool _collisionsWillMove;
|
||||||
|
|
||||||
// NOTE: Radius support is obsolete, but these private helper functions are available for this class to
|
// NOTE: Radius support is obsolete, but these private helper functions are available for this class to
|
||||||
// parse old data streams
|
// parse old data streams
|
||||||
|
|
|
@ -41,6 +41,8 @@ EntityItemProperties::EntityItemProperties() :
|
||||||
_angularVelocity(EntityItem::DEFAULT_ANGULAR_VELOCITY),
|
_angularVelocity(EntityItem::DEFAULT_ANGULAR_VELOCITY),
|
||||||
_angularDamping(EntityItem::DEFAULT_ANGULAR_DAMPING),
|
_angularDamping(EntityItem::DEFAULT_ANGULAR_DAMPING),
|
||||||
_visible(EntityItem::DEFAULT_VISIBLE),
|
_visible(EntityItem::DEFAULT_VISIBLE),
|
||||||
|
_ignoreForCollisions(EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS),
|
||||||
|
_collisionsWillMove(EntityItem::DEFAULT_COLLISIONS_WILL_MOVE),
|
||||||
|
|
||||||
_positionChanged(false),
|
_positionChanged(false),
|
||||||
_dimensionsChanged(false),
|
_dimensionsChanged(false),
|
||||||
|
@ -55,6 +57,8 @@ EntityItemProperties::EntityItemProperties() :
|
||||||
_angularVelocityChanged(false),
|
_angularVelocityChanged(false),
|
||||||
_angularDampingChanged(false),
|
_angularDampingChanged(false),
|
||||||
_visibleChanged(false),
|
_visibleChanged(false),
|
||||||
|
_ignoreForCollisionsChanged(false),
|
||||||
|
_collisionsWillMoveChanged(false),
|
||||||
|
|
||||||
_color(),
|
_color(),
|
||||||
_modelURL(""),
|
_modelURL(""),
|
||||||
|
@ -112,6 +116,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
CHECK_PROPERTY_CHANGE(PROP_REGISTRATION_POINT, registrationPoint);
|
CHECK_PROPERTY_CHANGE(PROP_REGISTRATION_POINT, registrationPoint);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_ANGULAR_VELOCITY, angularVelocity);
|
CHECK_PROPERTY_CHANGE(PROP_ANGULAR_VELOCITY, angularVelocity);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_ANGULAR_DAMPING, angularDamping);
|
CHECK_PROPERTY_CHANGE(PROP_ANGULAR_DAMPING, angularDamping);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_IGNORE_FOR_COLLISIONS, ignoreForCollisions);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_COLLISIONS_WILL_MOVE, collisionsWillMove);
|
||||||
|
|
||||||
return changedProperties;
|
return changedProperties;
|
||||||
}
|
}
|
||||||
|
@ -150,6 +156,8 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(animationFrameIndex);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(animationFrameIndex);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(animationFPS);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(animationFPS);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(glowLevel);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(glowLevel);
|
||||||
|
COPY_PROPERTY_TO_QSCRIPTVALUE(ignoreForCollisions);
|
||||||
|
COPY_PROPERTY_TO_QSCRIPTVALUE(collisionsWillMove);
|
||||||
|
|
||||||
// Sitting properties support
|
// Sitting properties support
|
||||||
QScriptValue sittingPoints = engine->newObject();
|
QScriptValue sittingPoints = engine->newObject();
|
||||||
|
@ -194,6 +202,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) {
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(animationFPS, setAnimationFPS);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(animationFPS, setAnimationFPS);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(animationFrameIndex, setAnimationFrameIndex);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(animationFrameIndex, setAnimationFrameIndex);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(glowLevel, setGlowLevel);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(glowLevel, setGlowLevel);
|
||||||
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(ignoreForCollisions, setIgnoreForCollisions);
|
||||||
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(collisionsWillMove, setCollisionsWillMove);
|
||||||
|
|
||||||
_lastEdited = usecTimestampNow();
|
_lastEdited = usecTimestampNow();
|
||||||
}
|
}
|
||||||
|
@ -342,6 +352,8 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, appendValue, properties.getAngularVelocity());
|
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, appendValue, properties.getAngularVelocity());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, appendValue, properties.getAngularDamping());
|
APPEND_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, appendValue, properties.getAngularDamping());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_VISIBLE, appendValue, properties.getVisible());
|
APPEND_ENTITY_PROPERTY(PROP_VISIBLE, appendValue, properties.getVisible());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, appendValue, properties.getIgnoreForCollisions());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_COLLISIONS_WILL_MOVE, appendValue, properties.getCollisionsWillMove());
|
||||||
}
|
}
|
||||||
if (propertyCount > 0) {
|
if (propertyCount > 0) {
|
||||||
int endOfEntityItemData = packetData->getUncompressedByteOffset();
|
int endOfEntityItemData = packetData->getUncompressedByteOffset();
|
||||||
|
@ -538,6 +550,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ANGULAR_VELOCITY, glm::vec3, setAngularVelocity);
|
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_ANGULAR_DAMPING, float, setAngularDamping);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_VISIBLE, bool, setVisible);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_VISIBLE, bool, setVisible);
|
||||||
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IGNORE_FOR_COLLISIONS, bool, setIgnoreForCollisions);
|
||||||
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLLISIONS_WILL_MOVE, bool, setCollisionsWillMove);
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,10 @@ enum EntityPropertyList {
|
||||||
PROP_REGISTRATION_POINT,
|
PROP_REGISTRATION_POINT,
|
||||||
PROP_ANGULAR_VELOCITY,
|
PROP_ANGULAR_VELOCITY,
|
||||||
PROP_ANGULAR_DAMPING,
|
PROP_ANGULAR_DAMPING,
|
||||||
|
PROP_IGNORE_FOR_COLLISIONS,
|
||||||
|
PROP_COLLISIONS_WILL_MOVE,
|
||||||
|
|
||||||
PROP_LAST_ITEM = PROP_ANGULAR_DAMPING
|
PROP_LAST_ITEM = PROP_COLLISIONS_WILL_MOVE
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef PropertyFlags<EntityPropertyList> EntityPropertyFlags;
|
typedef PropertyFlags<EntityPropertyList> EntityPropertyFlags;
|
||||||
|
@ -221,6 +223,12 @@ public:
|
||||||
bool getVisible() const { return _visible; }
|
bool getVisible() const { return _visible; }
|
||||||
void setVisible(bool value) { _visible = value; _visibleChanged = true; }
|
void setVisible(bool value) { _visible = value; _visibleChanged = true; }
|
||||||
|
|
||||||
|
bool getIgnoreForCollisions() const { return _ignoreForCollisions; }
|
||||||
|
void setIgnoreForCollisions(bool value) { _ignoreForCollisions = value; _ignoreForCollisionsChanged = true; }
|
||||||
|
|
||||||
|
bool getCollisionsWillMove() const { return _collisionsWillMove; }
|
||||||
|
void setCollisionsWillMove(bool value) { _collisionsWillMove = value; _collisionsWillMoveChanged = true; }
|
||||||
|
|
||||||
void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; }
|
void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -247,6 +255,8 @@ private:
|
||||||
glm::vec3 _angularVelocity;
|
glm::vec3 _angularVelocity;
|
||||||
float _angularDamping;
|
float _angularDamping;
|
||||||
bool _visible;
|
bool _visible;
|
||||||
|
bool _ignoreForCollisions;
|
||||||
|
bool _collisionsWillMove;
|
||||||
|
|
||||||
bool _positionChanged;
|
bool _positionChanged;
|
||||||
bool _dimensionsChanged;
|
bool _dimensionsChanged;
|
||||||
|
@ -261,6 +271,8 @@ private:
|
||||||
bool _angularVelocityChanged;
|
bool _angularVelocityChanged;
|
||||||
bool _angularDampingChanged;
|
bool _angularDampingChanged;
|
||||||
bool _visibleChanged;
|
bool _visibleChanged;
|
||||||
|
bool _ignoreForCollisionsChanged;
|
||||||
|
bool _collisionsWillMoveChanged;
|
||||||
|
|
||||||
// TODO: this need to be more generic. for now, we're going to have the properties class support these as
|
// TODO: this need to be more generic. for now, we're going to have the properties class support these as
|
||||||
// named getter/setters, but we want to move them to generic types...
|
// named getter/setters, but we want to move them to generic types...
|
||||||
|
|
|
@ -555,8 +555,10 @@ bool EntityTreeElement::findShapeCollisions(const Shape* shape, CollisionList& c
|
||||||
QList<EntityItem*>::const_iterator entityEnd = _entityItems->end();
|
QList<EntityItem*>::const_iterator entityEnd = _entityItems->end();
|
||||||
while(entityItr != entityEnd) {
|
while(entityItr != entityEnd) {
|
||||||
EntityItem* entity = (*entityItr);
|
EntityItem* entity = (*entityItr);
|
||||||
|
|
||||||
|
// entities that are set for ignore for collisions then don't consider them for collision
|
||||||
const Shape* otherCollisionShape = &entity->getCollisionShapeInMeters();
|
const Shape* otherCollisionShape = &entity->getCollisionShapeInMeters();
|
||||||
if (shape != otherCollisionShape) {
|
if (shape != otherCollisionShape && !entity->getIgnoreForCollisions()) {
|
||||||
if (ShapeCollider::collideShapes(shape, otherCollisionShape, collisions)) {
|
if (ShapeCollider::collideShapes(shape, otherCollisionShape, collisions)) {
|
||||||
CollisionInfo* lastCollision = collisions.getLastCollision();
|
CollisionInfo* lastCollision = collisions.getLastCollision();
|
||||||
lastCollision->_extraData = entity;
|
lastCollision->_extraData = entity;
|
||||||
|
|
Loading…
Reference in a new issue