Project

General

Profile

« Previous | Next » 

Revision 4135693b

Added by Leszek Koltunski about 2 years ago

Slight memory saving.

View differences:

src/main/java/org/distorted/objectlib/main/Cubit.java
28 28

  
29 29
public class Cubit
30 30
  {
31
  private final float[] mTmp;
31 32
  private final float[] mOrigPosition;
32 33
  private final float[] mCurrentPosition;
33 34
  private final int mNumAxis;
......
47 48

  
48 49
    mOrigPosition    = new float[mLen];
49 50
    mCurrentPosition = new float[mLen];
51
    mTmp             = new float[4];
50 52

  
51 53
    for(int i=0; i<mLen; i++)
52 54
      {
......
127 129

  
128 130
  void modifyCurrentPosition(Static4D quat)
129 131
    {
130
    Static4D cubitCenter;
131
    Static4D rotatedCenter;
132 132
    int len = mLen/3;
133 133

  
134 134
    for(int i=0; i<len; i++)
135 135
      {
136
      cubitCenter =  new Static4D(mCurrentPosition[3*i], mCurrentPosition[3*i+1], mCurrentPosition[3*i+2], 0);
137
      rotatedCenter = QuatHelper.rotateVectorByQuat( cubitCenter, quat);
136
      QuatHelper.rotateVectorByQuat( mTmp, mCurrentPosition[3*i], mCurrentPosition[3*i+1], mCurrentPosition[3*i+2], 0, quat);
138 137

  
139
      mCurrentPosition[3*i  ] = rotatedCenter.get0();
140
      mCurrentPosition[3*i+1] = rotatedCenter.get1();
141
      mCurrentPosition[3*i+2] = rotatedCenter.get2();
138
      mCurrentPosition[3*i  ] = mTmp[0];
139
      mCurrentPosition[3*i+1] = mTmp[1];
140
      mCurrentPosition[3*i+2] = mTmp[2];
142 141

  
143 142
      mParent.clampPos(mCurrentPosition, 3*i);
144 143
      }

Also available in: Unified diff