History

removed cruft

amantley committed 8 years ago

Commit f2f4a552 parents 5365085 ec4f2f7888 files · +23435 −19797Browse files

Showing the changes to interface/src/avatar/MySkeletonModel.cpp (1 of 888 files). Show all

Unified · Split

interface/src/avatar/MySkeletonModel.cpp+24−45
@@ -36,9 +36,6 @@ Rig::CharacterControllerState convertCharacterControllerState(CharacterControlle · 35 unmodified lines
3636 static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) {
3737 glm::mat4 worldToSensorMat = glm::inverse(myAvatar->getSensorToWorldMatrix());
3838
39− //experiment to fix crazy legs.
40− glm::vec3 floorPosition = transformPoint(myAvatar->getSensorToWorldMatrix(), glm::vec3(0.0f, 0.0f, 0.0f));
41−
4239 // check for pinned hips.
4340 auto hipsIndex = myAvatar->getJointIndex("Hips");
4441 if (myAvatar->isJointPinned(hipsIndex)) {
@@ -59,14 +56,6 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) { · 14 unmodified lines
5956 glm::vec3 hipsPos = extractTranslation(hipsMat);
6057 glm::quat hipsRot = glmExtractRotation(hipsMat);
6158
62− // if we are less the floor with the hips then lock them to the floor.
63− // if, if that is, we are using cg or hmd lean is off.
64− if (myAvatar->getCenterOfGravityModelEnabled() || !myAvatar->getHMDLeanRecenterEnabled()) {
65− if (hipsPos.y < 0.02f) {
66− hipsPos.y = 0.02f;
67− }
68− }
69−
7059
7160 glm::mat4 avatarToWorldMat = myAvatar->getTransform().getMatrix();
7261 glm::mat4 avatarToSensorMat = worldToSensorMat * avatarToWorldMat;
@@ -101,7 +90,7 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) { · 28 unmodified lines
10190
10291 // Called within Model::simulate call, below.
10392 void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
104− const FBXGeometry& geometry = getFBXGeometry();
93+ const HFMModel& hfmModel = getHFMModel();
10594
10695 Head* head = _owningAvatar->getHead();
10796
@@ -211,49 +200,38 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { · 103 unmodified lines
211200 if (avatarHeadPose.isValid() && !(params.primaryControllerFlags[Rig::PrimaryControllerType_Hips] & (uint8_t)Rig::ControllerFlags::Enabled)) {
212201 bool isFlying = (myAvatar->getCharacterController()->getState() == CharacterController::State::Hover || myAvatar->getCharacterController()->computeCollisionGroup() == BULLET_COLLISION_GROUP_COLLISIONLESS);
213202
214− if (!_prevHipsValid) {
215− AnimPose hips = computeHipsInSensorFrame(myAvatar, isFlying);
216− _prevHips = hips;
217− }
218−
219− AnimPose hips = computeHipsInSensorFrame(myAvatar, isFlying);
220−
221203 // timescale in seconds
222204 const float TRANS_HORIZ_TIMESCALE = 0.15f;
223205 const float TRANS_VERT_TIMESCALE = 0.01f; // We want the vertical component of the hips to follow quickly to prevent spine squash/stretch.
224206 const float ROT_TIMESCALE = 0.15f;
225207 const float FLY_IDLE_TRANSITION_TIMESCALE = 0.25f;
226208
227− float transHorizAlpha, transVertAlpha, rotAlpha;
228209 if (_flyIdleTimer < 0.0f) {
229− transHorizAlpha = glm::min(deltaTime / TRANS_HORIZ_TIMESCALE, 1.0f);
230− transVertAlpha = glm::min(deltaTime / TRANS_VERT_TIMESCALE, 1.0f);
231− rotAlpha = glm::min(deltaTime / ROT_TIMESCALE, 1.0f);
210+ _smoothHipsHelper.setHorizontalTranslationTimescale(TRANS_HORIZ_TIMESCALE);
211+ _smoothHipsHelper.setVerticalTranslationTimescale(TRANS_VERT_TIMESCALE);
212+ _smoothHipsHelper.setRotationTimescale(ROT_TIMESCALE);
232213 } else {
233− transHorizAlpha = glm::min(deltaTime / FLY_IDLE_TRANSITION_TIMESCALE, 1.0f);
234− transVertAlpha = glm::min(deltaTime / FLY_IDLE_TRANSITION_TIMESCALE, 1.0f);
235− rotAlpha = glm::min(deltaTime / FLY_IDLE_TRANSITION_TIMESCALE, 1.0f);
214+ _smoothHipsHelper.setHorizontalTranslationTimescale(FLY_IDLE_TRANSITION_TIMESCALE);
215+ _smoothHipsHelper.setVerticalTranslationTimescale(FLY_IDLE_TRANSITION_TIMESCALE);
216+ _smoothHipsHelper.setRotationTimescale(FLY_IDLE_TRANSITION_TIMESCALE);
236217 }
237218
238− // smootly lerp hips, in sensorframe, with different coeff for horiz and vertical translation.
239− float hipsY = hips.trans().y;
240− hips.trans() = lerp(_prevHips.trans(), hips.trans(), transHorizAlpha);
241− hips.trans().y = lerp(_prevHips.trans().y, hipsY, transVertAlpha);
242− hips.rot() = safeLerp(_prevHips.rot(), hips.rot(), rotAlpha);
243−
244− _prevHips = hips;
245− _prevHipsValid = true;
219+ AnimPose sensorHips = computeHipsInSensorFrame(myAvatar, isFlying);
220+ if (!_prevIsEstimatingHips) {
221+ _smoothHipsHelper.teleport(sensorHips);
222+ }
223+ sensorHips = _smoothHipsHelper.update(sensorHips, deltaTime);
246224
247225 glm::mat4 invRigMat = glm::inverse(myAvatar->getTransform().getMatrix() * Matrices::Y_180);
248226 AnimPose sensorToRigPose(invRigMat * myAvatar->getSensorToWorldMatrix());
249227
250− params.primaryControllerPoses[Rig::PrimaryControllerType_Hips] = sensorToRigPose * hips;
228+ params.primaryControllerPoses[Rig::PrimaryControllerType_Hips] = sensorToRigPose * sensorHips;
251229 params.primaryControllerFlags[Rig::PrimaryControllerType_Hips] = (uint8_t)Rig::ControllerFlags::Enabled | (uint8_t)Rig::ControllerFlags::Estimated;
252230
253231 // set spine2 if we have hand controllers
254232 if (myAvatar->getControllerPoseInAvatarFrame(controller::Action::RIGHT_HAND).isValid() &&
255− myAvatar->getControllerPoseInAvatarFrame(controller::Action::LEFT_HAND).isValid() &&
256− !(params.primaryControllerFlags[Rig::PrimaryControllerType_Spine2] & (uint8_t)Rig::ControllerFlags::Enabled)) {
233+ myAvatar->getControllerPoseInAvatarFrame(controller::Action::LEFT_HAND).isValid() &&
234+ !(params.primaryControllerFlags[Rig::PrimaryControllerType_Spine2] & (uint8_t)Rig::ControllerFlags::Enabled)) {
257235
258236 AnimPose currentSpine2Pose;
259237 AnimPose currentHeadPose;
@@ -280,8 +258,9 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { · 20 unmodified lines
280258 }
281259 }
282260
261+ _prevIsEstimatingHips = true;
283262 } else {
284− _prevHipsValid = false;
263+ _prevIsEstimatingHips = false;
285264 }
286265
287266 params.isTalking = head->getTimeWithoutTalking() <= 1.5f;
@@ -289,19 +268,19 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { · 1 unmodified line
289268 // pass detailed torso k-dops to rig.
290269 int hipsJoint = _rig.indexOfJoint("Hips");
291270 if (hipsJoint >= 0) {
292− params.hipsShapeInfo = geometry.joints[hipsJoint].shapeInfo;
271+ params.hipsShapeInfo = hfmModel.joints[hipsJoint].shapeInfo;
293272 }
294273 int spineJoint = _rig.indexOfJoint("Spine");
295274 if (spineJoint >= 0) {
296− params.spineShapeInfo = geometry.joints[spineJoint].shapeInfo;
275+ params.spineShapeInfo = hfmModel.joints[spineJoint].shapeInfo;
297276 }
298277 int spine1Joint = _rig.indexOfJoint("Spine1");
299278 if (spine1Joint >= 0) {
300− params.spine1ShapeInfo = geometry.joints[spine1Joint].shapeInfo;
279+ params.spine1ShapeInfo = hfmModel.joints[spine1Joint].shapeInfo;
301280 }
302281 int spine2Joint = _rig.indexOfJoint("Spine2");
303282 if (spine2Joint >= 0) {
304− params.spine2ShapeInfo = geometry.joints[spine2Joint].shapeInfo;
283+ params.spine2ShapeInfo = hfmModel.joints[spine2Joint].shapeInfo;
305284 }
306285
307286 _rig.updateFromControllerParameters(params, deltaTime);
@@ -311,7 +290,7 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { · 3 unmodified lines
311290 auto velocity = myAvatar->getLocalVelocity() / myAvatar->getSensorToWorldScale();
312291 auto position = myAvatar->getLocalPosition();
313292 auto orientation = myAvatar->getLocalOrientation();
314− _rig.computeMotionAnimationState(deltaTime, position, velocity, orientation, ccState);
293+ _rig.computeMotionAnimationState(deltaTime, position, velocity, orientation, ccState, myAvatar->getSensorToWorldScale());
315294
316295 // evaluate AnimGraph animation and update jointStates.
317296 Model::updateRig(deltaTime, parentTransform);
@@ -321,8 +300,8 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { · 3 unmodified lines
321300 eyeParams.eyeSaccade = head->getSaccade();
322301 eyeParams.modelRotation = getRotation();
323302 eyeParams.modelTranslation = getTranslation();
324− eyeParams.leftEyeJointIndex = geometry.leftEyeJointIndex;
325− eyeParams.rightEyeJointIndex = geometry.rightEyeJointIndex;
303+ eyeParams.leftEyeJointIndex = hfmModel.leftEyeJointIndex;
304+ eyeParams.rightEyeJointIndex = hfmModel.rightEyeJointIndex;
326305
327306 _rig.updateFromEyeParameters(eyeParams);
328307

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t