Merge branch 'master' of https://github.com/highfidelity/hifi into punk

This commit is contained in:
samcake 2018-05-29 08:59:37 -07:00
commit 82503a9e64
12 changed files with 83 additions and 62 deletions

View file

@ -163,10 +163,18 @@ TextField {
text: textField.label text: textField.label
colorScheme: textField.colorScheme colorScheme: textField.colorScheme
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right
Binding on anchors.right {
when: parent.right
value: parent.right
}
Binding on wrapMode {
when: parent.right
value: Text.WordWrap
}
anchors.bottom: parent.top anchors.bottom: parent.top
anchors.bottomMargin: 3 anchors.bottomMargin: 3
wrapMode: Text.WordWrap
visible: label != "" visible: label != ""
} }
} }

View file

@ -4632,12 +4632,6 @@ void Application::idle() {
_overlayConductor.update(secondsSinceLastUpdate); _overlayConductor.update(secondsSinceLastUpdate);
auto myAvatar = getMyAvatar();
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
cameraMenuChanged();
}
_gameLoopCounter.increment(); _gameLoopCounter.increment();
} }
@ -5184,6 +5178,21 @@ void Application::cameraModeChanged() {
cameraMenuChanged(); cameraMenuChanged();
} }
void Application::changeViewAsNeeded(float boomLength) {
// Switch between first and third person views as needed
// This is called when the boom length has changed
bool boomLengthGreaterThanMinimum = (boomLength > MyAvatar::ZOOM_MIN);
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON && boomLengthGreaterThanMinimum) {
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, false);
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, true);
cameraMenuChanged();
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON && !boomLengthGreaterThanMinimum) {
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, true);
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, false);
cameraMenuChanged();
}
}
void Application::cameraMenuChanged() { void Application::cameraMenuChanged() {
auto menu = Menu::getInstance(); auto menu = Menu::getInstance();

View file

@ -417,6 +417,8 @@ public slots:
void updateVerboseLogging(); void updateVerboseLogging();
void changeViewAsNeeded(float boomLength);
private slots: private slots:
void onDesktopRootItemCreated(QQuickItem* qmlContext); void onDesktopRootItemCreated(QQuickItem* qmlContext);
void onDesktopRootContextCreated(QQmlContext* qmlContext); void onDesktopRootContextCreated(QQmlContext* qmlContext);

View file

@ -2251,9 +2251,15 @@ void MyAvatar::updateActionMotor(float deltaTime) {
_actionMotorVelocity = getSensorToWorldScale() * (_walkSpeed.get() * _walkSpeedScalar) * direction; _actionMotorVelocity = getSensorToWorldScale() * (_walkSpeed.get() * _walkSpeedScalar) * direction;
} }
float previousBoomLength = _boomLength;
float boomChange = getDriveKey(ZOOM); float boomChange = getDriveKey(ZOOM);
_boomLength += 2.0f * _boomLength * boomChange + boomChange * boomChange; _boomLength += 2.0f * _boomLength * boomChange + boomChange * boomChange;
_boomLength = glm::clamp<float>(_boomLength, ZOOM_MIN, ZOOM_MAX); _boomLength = glm::clamp<float>(_boomLength, ZOOM_MIN, ZOOM_MAX);
// May need to change view if boom length has changed
if (previousBoomLength != _boomLength) {
qApp->changeViewAsNeeded(_boomLength);
}
} }
void MyAvatar::updatePosition(float deltaTime) { void MyAvatar::updatePosition(float deltaTime) {

View file

@ -259,7 +259,6 @@ void Web3DOverlay::setupQmlSurface() {
_webSurface->getSurfaceContext()->setContextProperty("Web3DOverlay", this); _webSurface->getSurfaceContext()->setContextProperty("Web3DOverlay", this);
_webSurface->getSurfaceContext()->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data()); _webSurface->getSurfaceContext()->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data());
_webSurface->getSurfaceContext()->setContextProperty("Reticle", qApp->getApplicationCompositor().getReticleInterface()); _webSurface->getSurfaceContext()->setContextProperty("Reticle", qApp->getApplicationCompositor().getReticleInterface());
_webSurface->getSurfaceContext()->setContextProperty("desktop", DependencyManager::get<OffscreenUi>()->getDesktop());
_webSurface->getSurfaceContext()->setContextProperty("HiFiAbout", AboutUtil::getInstance()); _webSurface->getSurfaceContext()->setContextProperty("HiFiAbout", AboutUtil::getInstance());
// Override min fps for tablet UI, for silky smooth scrolling // Override min fps for tablet UI, for silky smooth scrolling

View file

@ -252,11 +252,9 @@ void EntityMotionState::getWorldTransform(btTransform& worldTrans) const {
uint32_t thisStep = ObjectMotionState::getWorldSimulationStep(); uint32_t thisStep = ObjectMotionState::getWorldSimulationStep();
float dt = (thisStep - _lastKinematicStep) * PHYSICS_ENGINE_FIXED_SUBSTEP; float dt = (thisStep - _lastKinematicStep) * PHYSICS_ENGINE_FIXED_SUBSTEP;
_lastKinematicStep = thisStep;
_entity->stepKinematicMotion(dt); _entity->stepKinematicMotion(dt);
// bypass const-ness so we can remember the step
const_cast<EntityMotionState*>(this)->_lastKinematicStep = thisStep;
// and set the acceleration-matches-gravity count high so that if we send an update // and set the acceleration-matches-gravity count high so that if we send an update
// it will use the correct acceleration for remote simulations // it will use the correct acceleration for remote simulations
_accelerationNearlyGravityCount = (uint8_t)(-1); _accelerationNearlyGravityCount = (uint8_t)(-1);

View file

@ -184,7 +184,7 @@ protected:
btRigidBody* _body { nullptr }; btRigidBody* _body { nullptr };
float _density { 1.0f }; float _density { 1.0f };
uint32_t _lastKinematicStep; mutable uint32_t _lastKinematicStep;
bool _hasInternalKinematicChanges { false }; bool _hasInternalKinematicChanges { false };
}; };

View file

@ -71,8 +71,8 @@ void PhysicsEngine::init() {
} }
} }
uint32_t PhysicsEngine::getNumSubsteps() { uint32_t PhysicsEngine::getNumSubsteps() const {
return _numSubsteps; return _dynamicsWorld->getNumSubsteps();
} }
// private // private
@ -329,13 +329,9 @@ void PhysicsEngine::stepSimulation() {
PHYSICS_ENGINE_FIXED_SUBSTEP, onSubStep); PHYSICS_ENGINE_FIXED_SUBSTEP, onSubStep);
if (numSubsteps > 0) { if (numSubsteps > 0) {
BT_PROFILE("postSimulation"); BT_PROFILE("postSimulation");
_numSubsteps += (uint32_t)numSubsteps;
ObjectMotionState::setWorldSimulationStep(_numSubsteps);
if (_myAvatarController) { if (_myAvatarController) {
_myAvatarController->postSimulation(); _myAvatarController->postSimulation();
} }
_hasOutgoingChanges = true; _hasOutgoingChanges = true;
} }

View file

@ -52,7 +52,7 @@ public:
~PhysicsEngine(); ~PhysicsEngine();
void init(); void init();
uint32_t getNumSubsteps(); uint32_t getNumSubsteps() const;
void removeObjects(const VectorOfMotionStates& objects); void removeObjects(const VectorOfMotionStates& objects);
void removeSetOfObjects(const SetOfMotionStates& objects); // only called during teardown void removeSetOfObjects(const SetOfMotionStates& objects); // only called during teardown
@ -135,7 +135,6 @@ private:
CharacterController* _myAvatarController; CharacterController* _myAvatarController;
uint32_t _numContactFrames = 0; uint32_t _numContactFrames = 0;
uint32_t _numSubsteps;
bool _dumpNextStats { false }; bool _dumpNextStats { false };
bool _saveNextStats { false }; bool _saveNextStats { false };

View file

@ -59,14 +59,11 @@ int ThreadSafeDynamicsWorld::stepSimulationWithSubstepCallback(btScalar timeStep
} }
} }
/*//process some debugging flags
if (getDebugDrawer()) {
btIDebugDraw* debugDrawer = getDebugDrawer();
gDisableDeactivation = (debugDrawer->getDebugMode() & btIDebugDraw::DBG_NoDeactivation) != 0;
}*/
if (subSteps) { if (subSteps) {
//clamp the number of substeps, to prevent simulation grinding spiralling down to a halt //clamp the number of substeps, to prevent simulation grinding spiralling down to a halt
int clampedSimulationSteps = (subSteps > maxSubSteps)? maxSubSteps : subSteps; int clampedSimulationSteps = (subSteps > maxSubSteps)? maxSubSteps : subSteps;
_numSubsteps += clampedSimulationSteps;
ObjectMotionState::setWorldSimulationStep(_numSubsteps);
saveKinematicState(fixedTimeStep*clampedSimulationSteps); saveKinematicState(fixedTimeStep*clampedSimulationSteps);
@ -98,28 +95,24 @@ int ThreadSafeDynamicsWorld::stepSimulationWithSubstepCallback(btScalar timeStep
// call this instead of non-virtual btDiscreteDynamicsWorld::synchronizeSingleMotionState() // call this instead of non-virtual btDiscreteDynamicsWorld::synchronizeSingleMotionState()
void ThreadSafeDynamicsWorld::synchronizeMotionState(btRigidBody* body) { void ThreadSafeDynamicsWorld::synchronizeMotionState(btRigidBody* body) {
btAssert(body); btAssert(body);
if (body->getMotionState() && !body->isStaticObject()) { btAssert(body->getMotionState());
//we need to call the update at least once, even for sleeping objects
//otherwise the 'graphics' transform never updates properly if (body->isKinematicObject()) {
///@todo: add 'dirty' flag ObjectMotionState* objectMotionState = static_cast<ObjectMotionState*>(body->getMotionState());
//if (body->getActivationState() != ISLAND_SLEEPING) if (objectMotionState->hasInternalKinematicChanges()) {
{ // this is a special case where the kinematic motion has been updated by an Action
if (body->isKinematicObject()) { // so we supply the body's current transform to the MotionState
ObjectMotionState* objectMotionState = static_cast<ObjectMotionState*>(body->getMotionState()); objectMotionState->clearInternalKinematicChanges();
if (objectMotionState->hasInternalKinematicChanges()) { body->getMotionState()->setWorldTransform(body->getWorldTransform());
objectMotionState->clearInternalKinematicChanges();
body->getMotionState()->setWorldTransform(body->getWorldTransform());
}
return;
}
btTransform interpolatedTransform;
btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(),
body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),
(m_latencyMotionStateInterpolation && m_fixedTimeStep) ? m_localTime - m_fixedTimeStep : m_localTime*body->getHitFraction(),
interpolatedTransform);
body->getMotionState()->setWorldTransform(interpolatedTransform);
} }
return;
} }
btTransform interpolatedTransform;
btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(),
body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),
(m_latencyMotionStateInterpolation && m_fixedTimeStep) ? m_localTime - m_fixedTimeStep : m_localTime*body->getHitFraction(),
interpolatedTransform);
body->getMotionState()->setWorldTransform(interpolatedTransform);
} }
void ThreadSafeDynamicsWorld::synchronizeMotionStates() { void ThreadSafeDynamicsWorld::synchronizeMotionStates() {
@ -164,24 +157,12 @@ void ThreadSafeDynamicsWorld::synchronizeMotionStates() {
} }
void ThreadSafeDynamicsWorld::saveKinematicState(btScalar timeStep) { void ThreadSafeDynamicsWorld::saveKinematicState(btScalar timeStep) {
///would like to iterate over m_nonStaticRigidBodies, but unfortunately old API allows
///to switch status _after_ adding kinematic objects to the world
///fix it for Bullet 3.x release
DETAILED_PROFILE_RANGE(simulation_physics, "saveKinematicState"); DETAILED_PROFILE_RANGE(simulation_physics, "saveKinematicState");
BT_PROFILE("saveKinematicState"); BT_PROFILE("saveKinematicState");
for (int i=0;i<m_collisionObjects.size();i++) for (int i=0;i<m_nonStaticRigidBodies.size();i++) {
{ btRigidBody* body = m_nonStaticRigidBodies[i];
btCollisionObject* colObj = m_collisionObjects[i]; if (body && body->isKinematicObject() && body->getActivationState() != ISLAND_SLEEPING) {
btRigidBody* body = btRigidBody::upcast(colObj); body->saveKinematicState(timeStep);
if (body && body->getActivationState() != ISLAND_SLEEPING)
{
if (body->isKinematicObject())
{
//to calculate velocities next frame
body->saveKinematicState(timeStep);
}
} }
} }
} }

View file

@ -37,6 +37,7 @@ public:
btConstraintSolver* constraintSolver, btConstraintSolver* constraintSolver,
btCollisionConfiguration* collisionConfiguration); btCollisionConfiguration* collisionConfiguration);
int getNumSubsteps() const { return _numSubsteps; }
int stepSimulationWithSubstepCallback(btScalar timeStep, int maxSubSteps = 1, int stepSimulationWithSubstepCallback(btScalar timeStep, int maxSubSteps = 1,
btScalar fixedTimeStep = btScalar(1.)/btScalar(60.), btScalar fixedTimeStep = btScalar(1.)/btScalar(60.),
SubStepCallback onSubStep = []() { }); SubStepCallback onSubStep = []() { });
@ -61,6 +62,7 @@ private:
VectorOfMotionStates _deactivatedStates; VectorOfMotionStates _deactivatedStates;
SetOfMotionStates _activeStates; SetOfMotionStates _activeStates;
SetOfMotionStates _lastActiveStates; SetOfMotionStates _lastActiveStates;
int _numSubsteps { 0 };
}; };
#endif // hifi_ThreadSafeDynamicsWorld_h #endif // hifi_ThreadSafeDynamicsWorld_h

View file

@ -171,4 +171,25 @@
Messages.subscribe(HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL); Messages.subscribe(HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL);
Messages.messageReceived.connect(handleMessage); Messages.messageReceived.connect(handleMessage);
function initializeControls() {
if(HMD.active) {
if (Controller.Hardware.Vive !== undefined || Controller.Hardware.OculusTouch !== undefined) {
if (MyAvatar.useAdvancedMovementControls) {
Controller.disableMapping(DRIVING_MAPPING_NAME);
} else {
Controller.enableMapping(DRIVING_MAPPING_NAME);
}
if (MyAvatar.getFlyingEnabled()) {
Controller.disableMapping(FLYING_MAPPING_NAME);
} else {
Controller.enableMapping(FLYING_MAPPING_NAME);
}
});
}
}
initializeControls();
}()); // END LOCAL_SCOPE }()); // END LOCAL_SCOPE