This commit is contained in:
howard-stearns 2016-01-26 11:00:21 -08:00
commit ed98e65bab
7 changed files with 61 additions and 29 deletions

View file

@ -1515,6 +1515,7 @@ SelectionDisplay = (function() {
}
that.updateRotationHandles();
that.highlightSelectable();
var rotation, dimensions, position, registrationPoint;

View file

@ -32,7 +32,22 @@ KeyLightPropertyGroup EntityItemProperties::_staticKeyLight;
EntityPropertyList PROP_LAST_ITEM = (EntityPropertyList)(PROP_AFTER_LAST_ITEM - 1);
EntityItemProperties::EntityItemProperties(EntityPropertyFlags desiredProperties) :
_desiredProperties(desiredProperties) //,
_id(UNKNOWN_ENTITY_ID),
_idSet(false),
_lastEdited(0),
_type(EntityTypes::Unknown),
_glowLevel(0.0f),
_localRenderAlpha(1.0f),
_glowLevelChanged(false),
_localRenderAlphaChanged(false),
_defaultSettings(true),
_naturalDimensions(1.0f, 1.0f, 1.0f),
_naturalPosition(0.0f, 0.0f, 0.0f),
_desiredProperties(desiredProperties)
{
}
@ -306,11 +321,6 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
QScriptValue properties = engine->newObject();
EntityItemProperties defaultEntityProperties;
if (!_entityFound) {
// Return without setting any default property values so that properties are reported in JavaScript as undefined.
return properties;
}
if (_idSet) {
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_ALWAYS(id, _id.toString());
}

View file

@ -272,36 +272,32 @@ public:
void setJointRotationsDirty() { _jointRotationsSetChanged = true; _jointRotationsChanged = true; }
void setJointTranslationsDirty() { _jointTranslationsSetChanged = true; _jointTranslationsChanged = true; }
void setEntityFound() { _entityFound = true; }
protected:
QString getCollisionMaskAsString() const;
void setCollisionMaskFromString(const QString& maskString);
private:
QUuid _id { UNKNOWN_ENTITY_ID };
bool _idSet { false };
quint64 _lastEdited { 0 };
EntityTypes::EntityType _type { EntityTypes::Unknown };
QUuid _id;
bool _idSet;
quint64 _lastEdited;
EntityTypes::EntityType _type;
void setType(const QString& typeName) { _type = EntityTypes::getEntityTypeFromName(typeName); }
float _glowLevel { 0.0f };
float _localRenderAlpha { 1.0f };
bool _glowLevelChanged { false };
bool _localRenderAlphaChanged { false };
bool _defaultSettings { true };
bool _dimensionsInitialized { true }; // Only false if creating an entity locally with no dimensions properties
float _glowLevel;
float _localRenderAlpha;
bool _glowLevelChanged;
bool _localRenderAlphaChanged;
bool _defaultSettings;
bool _dimensionsInitialized = true; // Only false if creating an entity localy with no dimensions properties
// NOTE: The following are pseudo client only properties. They are only used in clients which can access
// properties of model geometry. But these properties are not serialized like other properties.
QVector<SittingPoint> _sittingPoints;
QStringList _textureNames;
glm::vec3 _naturalDimensions { 1.0f, 1.0f, 1.0f };
glm::vec3 _naturalPosition { 0.0f, 0.0f, 0.0f };
glm::vec3 _naturalDimensions;
glm::vec3 _naturalPosition;
EntityPropertyFlags _desiredProperties; // if set will narrow scopes of copy/to/from to just these properties
bool _entityFound { false };
};
Q_DECLARE_METATYPE(EntityItemProperties);

View file

@ -202,13 +202,11 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit
}
}
results = convertLocationToScriptSemantics(results);
results.setEntityFound();
}
});
}
return results;
return convertLocationToScriptSemantics(results);
}
QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& scriptSideProperties) {

View file

@ -60,6 +60,7 @@ CharacterController::CharacterController() {
_followTime = 0.0f;
_followLinearDisplacement = btVector3(0, 0, 0);
_followAngularDisplacement = btQuaternion::getIdentity();
_hasSupport = false;
_pendingFlags = PENDING_FLAG_UPDATE_SHAPE;
@ -106,6 +107,28 @@ void CharacterController::setDynamicsWorld(btDynamicsWorld* world) {
}
}
bool CharacterController::checkForSupport(btCollisionWorld* collisionWorld) const {
int numManifolds = collisionWorld->getDispatcher()->getNumManifolds();
for (int i = 0; i < numManifolds; i++) {
btPersistentManifold* contactManifold = collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
const btCollisionObject* obA = static_cast<const btCollisionObject*>(contactManifold->getBody0());
const btCollisionObject* obB = static_cast<const btCollisionObject*>(contactManifold->getBody1());
if (obA == _rigidBody || obB == _rigidBody) {
int numContacts = contactManifold->getNumContacts();
for (int j = 0; j < numContacts; j++) {
btManifoldPoint& pt = contactManifold->getContactPoint(j);
// check to see if contact point is touching the bottom sphere of the capsule.
float contactPointY = (obA == _rigidBody) ? pt.m_localPointA.getY() : pt.m_localPointB.getY();
if (contactPointY < -_halfHeight) {
return true;
}
}
}
}
return false;
}
void CharacterController::preStep(btCollisionWorld* collisionWorld) {
// trace a ray straight down to see if we're standing on the ground
const btTransform& xform = _rigidBody->getWorldTransform();
@ -125,6 +148,8 @@ void CharacterController::preStep(btCollisionWorld* collisionWorld) {
if (rayCallback.hasHit()) {
_floorDistance = rayLength * rayCallback.m_closestHitFraction - _radius;
}
_hasSupport = checkForSupport(collisionWorld);
}
void CharacterController::playerStep(btCollisionWorld* dynaWorld, btScalar dt) {
@ -248,7 +273,7 @@ void CharacterController::jump() {
bool CharacterController::onGround() const {
const btScalar FLOOR_PROXIMITY_THRESHOLD = 0.3f * _radius;
return _floorDistance < FLOOR_PROXIMITY_THRESHOLD;
return _floorDistance < FLOOR_PROXIMITY_THRESHOLD || _hasSupport;
}
void CharacterController::setHovering(bool hover) {
@ -400,7 +425,7 @@ void CharacterController::preSimulation() {
if (_floorDistance < JUMP_PROXIMITY_THRESHOLD) {
_isJumping = false;
}
} else {
} else if (!_hasSupport) {
_floorDistance = FLT_MAX;
setHovering(true);
}

View file

@ -86,6 +86,7 @@ public:
protected:
void updateUpAxis(const glm::quat& rotation);
bool checkForSupport(btCollisionWorld* collisionWorld) const;
protected:
btVector3 _currentUp;
@ -104,6 +105,7 @@ protected:
btScalar _radius;
btScalar _floorDistance;
bool _hasSupport;
btScalar _gravity;

View file

@ -110,8 +110,8 @@ function shutdown() {
dialog.showMessageBox({
type: 'question',
buttons: ['Yes', 'No'],
title: 'Are you sure?',
message: 'Quitting will stop your Server Console and your Home domain will no longer be running.'
title: 'Stopping Server Console',
message: 'Quitting will stop your Server Console and your Home domain will no longer be running.\nDo you wish to continue?'
}, shutdownCallback);
} else {
shutdownCallback(0);