Skip to content

Commit

Permalink
director filter npe fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashqal committed Jul 2, 2017
1 parent 2828523 commit cce76cc
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions vrlib/src/main/java/com/asha/vrlib/MD360Director.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,27 @@ private void updateViewMatrixIfNeed(){

if (camera || world){
Matrix.multiplyMM(mViewMatrix, 0, mCameraMatrix, 0, mWorldRotationMatrix, 0);
mViewQuaternion.fromMatrix(mViewMatrix);
float pitch = mViewQuaternion.getPitch();
float yaw = mViewQuaternion.getYaw();
float roll = mViewQuaternion.getRoll();

float filterPitch = mDirectorFilter.onFilterPitch(pitch);
float filterYaw = mDirectorFilter.onFilterYaw(yaw);
float filterRoll = mDirectorFilter.onFilterRoll(roll);

if (pitch != filterPitch || yaw != filterYaw || roll != filterRoll){
mViewQuaternion.setEulerAngles(filterPitch, filterYaw, filterRoll);
mViewQuaternion.toMatrix(mViewMatrix);
}
filterViewMatrix();
}
}

private void filterViewMatrix() {
if (mDirectorFilter == null) {
return;
}

mViewQuaternion.fromMatrix(mViewMatrix);
float pitch = mViewQuaternion.getPitch();
float yaw = mViewQuaternion.getYaw();
float roll = mViewQuaternion.getRoll();

float filterPitch = mDirectorFilter.onFilterPitch(pitch);
float filterYaw = mDirectorFilter.onFilterYaw(yaw);
float filterRoll = mDirectorFilter.onFilterRoll(roll);

if (pitch != filterPitch || yaw != filterYaw || roll != filterRoll){
mViewQuaternion.setEulerAngles(filterPitch, filterYaw, filterRoll);
mViewQuaternion.toMatrix(mViewMatrix);
}
}

Expand Down

0 comments on commit cce76cc

Please sign in to comment.