Project

General

Profile

« Previous | Next » 

Revision eaf57f1c

Added by Leszek Koltunski over 5 years ago

Modify the 'convexity' param in Dynamics.

This finally satisfies the requirements of the 'Spin' effect in MagicCube: achieving constant speed ( by setting a 1D Dynamic's convexity to 0)

View differences:

src/main/java/org/distorted/library/type/Dynamic1D.java
57 57
      
58 58
      if( q>1 )
59 59
        {
60
        tmp1.tangent[0] = mConvexity*(nx+px/q);
60
        tmp1.tangent[0] = nx+px/q;
61 61
        }
62 62
      else
63 63
        {
64
        tmp1.tangent[0] = mConvexity*(px+nx*q);
64
        tmp1.tangent[0] = px+nx*q;
65 65
        }
66 66
      }
67 67
    else
......
118 118
    
119 119
        tmp1.cached[0] = curr.x;
120 120
        
121
        tmp1.a[0] =  2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0];
122
        tmp1.b[0] = -3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0];
123
        tmp1.c[0] = tmp1.tangent[0];
121
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
122
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
123
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
124 124
        tmp1.d[0] = curr.x;
125 125
        }
126 126
      }
src/main/java/org/distorted/library/type/Dynamic2D.java
59 59
      
60 60
      if( q>1 )
61 61
        {
62
        tmp1.tangent[0] = mConvexity*(nx+px/q);
63
        tmp1.tangent[1] = mConvexity*(ny+py/q);
62
        tmp1.tangent[0] = nx+px/q;
63
        tmp1.tangent[1] = ny+py/q;
64 64
        }
65 65
      else
66 66
        {
67
        tmp1.tangent[0] = mConvexity*(px+nx*q);
68
        tmp1.tangent[1] = mConvexity*(py+ny*q);
67
        tmp1.tangent[0] = px+nx*q;
68
        tmp1.tangent[1] = py+ny*q;
69 69
        }
70 70
      }
71 71
    else
......
129 129
        tmp1.cached[0] = curr.x;
130 130
        tmp1.cached[1] = curr.y;
131 131

  
132
        tmp1.a[0] =  2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0];
133
        tmp1.b[0] = -3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0];
134
        tmp1.c[0] = tmp1.tangent[0];
132
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
133
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
134
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
135 135
        tmp1.d[0] = curr.x;
136 136

  
137
        tmp1.a[1] =  2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1];
138
        tmp1.b[1] = -3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1];
139
        tmp1.c[1] = tmp1.tangent[1];
137
        tmp1.a[1] = mConvexity*( 2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1]);
138
        tmp1.b[1] = mConvexity*(-3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1]);
139
        tmp1.c[1] = mConvexity*(tmp1.tangent[1]) + (1.0f-mConvexity)*(next.y-curr.y);
140 140
        tmp1.d[1] = curr.y;
141 141
        }
142 142
      }
src/main/java/org/distorted/library/type/Dynamic3D.java
61 61
      
62 62
      if( q>1 )
63 63
        {
64
        tmp1.tangent[0] = mConvexity*(nx+px/q);
65
        tmp1.tangent[1] = mConvexity*(ny+py/q);
66
        tmp1.tangent[2] = mConvexity*(nz+pz/q);
64
        tmp1.tangent[0] = nx+px/q;
65
        tmp1.tangent[1] = ny+py/q;
66
        tmp1.tangent[2] = nz+pz/q;
67 67
        }
68 68
      else
69 69
        {
70
        tmp1.tangent[0] = mConvexity*(px+nx*q);
71
        tmp1.tangent[1] = mConvexity*(py+ny*q);
72
        tmp1.tangent[2] = mConvexity*(pz+nz*q);
70
        tmp1.tangent[0] = px+nx*q;
71
        tmp1.tangent[1] = py+ny*q;
72
        tmp1.tangent[2] = pz+nz*q;
73 73
        }
74 74
      }
75 75
    else
......
140 140
        tmp1.cached[1] = curr.y;
141 141
        tmp1.cached[2] = curr.z;
142 142
        
143
        tmp1.a[0] =  2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0];
144
        tmp1.b[0] = -3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0];
145
        tmp1.c[0] = tmp1.tangent[0];
143
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
144
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
145
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
146 146
        tmp1.d[0] = curr.x;
147 147
      
148
        tmp1.a[1] =  2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1];
149
        tmp1.b[1] = -3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1];
150
        tmp1.c[1] = tmp1.tangent[1];
148
        tmp1.a[1] = mConvexity*( 2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1]);
149
        tmp1.b[1] = mConvexity*(-3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1]);
150
        tmp1.c[1] = mConvexity*(tmp1.tangent[1]) + (1.0f-mConvexity)*(next.y-curr.y);
151 151
        tmp1.d[1] = curr.y;
152 152
      
153
        tmp1.a[2] =  2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2];
154
        tmp1.b[2] = -3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2];
155
        tmp1.c[2] = tmp1.tangent[2];
153
        tmp1.a[2] = mConvexity*( 2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2]);
154
        tmp1.b[2] = mConvexity*(-3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2]);
155
        tmp1.c[2] = mConvexity*(tmp1.tangent[2]) + (1.0f-mConvexity)*(next.z-curr.z);
156 156
        tmp1.d[2] = curr.z;
157 157
        }
158 158
      }
src/main/java/org/distorted/library/type/Dynamic4D.java
63 63
      
64 64
      if( q>1 )
65 65
        {
66
        tmp1.tangent[0] = mConvexity*(nx+px/q);
67
        tmp1.tangent[1] = mConvexity*(ny+py/q);
68
        tmp1.tangent[2] = mConvexity*(nz+pz/q);
69
        tmp1.tangent[3] = mConvexity*(nw+pw/q);
66
        tmp1.tangent[0] = nx+px/q;
67
        tmp1.tangent[1] = ny+py/q;
68
        tmp1.tangent[2] = nz+pz/q;
69
        tmp1.tangent[3] = nw+pw/q;
70 70
        }
71 71
      else
72 72
        {
73
        tmp1.tangent[0] = mConvexity*(px+nx*q);
74
        tmp1.tangent[1] = mConvexity*(py+ny*q);
75
        tmp1.tangent[2] = mConvexity*(pz+nz*q);
76
        tmp1.tangent[3] = mConvexity*(pw+nw*q);
73
        tmp1.tangent[0] = px+nx*q;
74
        tmp1.tangent[1] = py+ny*q;
75
        tmp1.tangent[2] = pz+nz*q;
76
        tmp1.tangent[3] = pw+nw*q;
77 77
        }
78 78
      }
79 79
    else
......
151 151
        tmp1.cached[2] = curr.z;
152 152
        tmp1.cached[3] = curr.w;
153 153
        
154
        tmp1.a[0] =  2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0];
155
        tmp1.b[0] = -3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0];
156
        tmp1.c[0] = tmp1.tangent[0];
154
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
155
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
156
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
157 157
        tmp1.d[0] = curr.x;
158 158
      
159
        tmp1.a[1] =  2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1];
160
        tmp1.b[1] = -3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1];
161
        tmp1.c[1] = tmp1.tangent[1];
159
        tmp1.a[1] = mConvexity*( 2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1]);
160
        tmp1.b[1] = mConvexity*(-3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1]);
161
        tmp1.c[1] = mConvexity*(tmp1.tangent[1]) + (1.0f-mConvexity)*(next.y-curr.y);
162 162
        tmp1.d[1] = curr.y;
163 163
      
164
        tmp1.a[2] =  2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2];
165
        tmp1.b[2] = -3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2];
166
        tmp1.c[2] = tmp1.tangent[2];
164
        tmp1.a[2] = mConvexity*( 2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2]);
165
        tmp1.b[2] = mConvexity*(-3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2]);
166
        tmp1.c[2] = mConvexity*(tmp1.tangent[2]) + (1.0f-mConvexity)*(next.z-curr.z);
167 167
        tmp1.d[2] = curr.z;
168 168
        
169
        tmp1.a[3] =  2*curr.w +   tmp1.tangent[3] - 2*next.w + tmp2.tangent[3];
170
        tmp1.b[3] = -3*curr.w - 2*tmp1.tangent[3] + 3*next.w - tmp2.tangent[3];
171
        tmp1.c[3] = tmp1.tangent[3];
169
        tmp1.a[3] = mConvexity*( 2*curr.w +   tmp1.tangent[3] - 2*next.w + tmp2.tangent[3]);
170
        tmp1.b[3] = mConvexity*(-3*curr.w - 2*tmp1.tangent[3] + 3*next.w - tmp2.tangent[3]);
171
        tmp1.c[3] = mConvexity*(tmp1.tangent[3]) + (1.0f-mConvexity)*(next.w-curr.w);
172 172
        tmp1.d[3] = curr.w;
173 173
        }
174 174
      }
src/main/java/org/distorted/library/type/Dynamic5D.java
65 65
      
66 66
      if( q>1 )
67 67
        {
68
        tmp1.tangent[0] = mConvexity*(nx+px/q);
69
        tmp1.tangent[1] = mConvexity*(ny+py/q);
70
        tmp1.tangent[2] = mConvexity*(nz+pz/q);
71
        tmp1.tangent[3] = mConvexity*(nw+pw/q);
72
        tmp1.tangent[4] = mConvexity*(nv+pv/q);
68
        tmp1.tangent[0] = nx+px/q;
69
        tmp1.tangent[1] = ny+py/q;
70
        tmp1.tangent[2] = nz+pz/q;
71
        tmp1.tangent[3] = nw+pw/q;
72
        tmp1.tangent[4] = nv+pv/q;
73 73
        }
74 74
      else
75 75
        {
76
        tmp1.tangent[0] = mConvexity*(px+nx*q);
77
        tmp1.tangent[1] = mConvexity*(py+ny*q);
78
        tmp1.tangent[2] = mConvexity*(pz+nz*q);
79
        tmp1.tangent[3] = mConvexity*(pw+nw*q);
80
        tmp1.tangent[4] = mConvexity*(pv+nv*q);
76
        tmp1.tangent[0] = px+nx*q;
77
        tmp1.tangent[1] = py+ny*q;
78
        tmp1.tangent[2] = pz+nz*q;
79
        tmp1.tangent[3] = pw+nw*q;
80
        tmp1.tangent[4] = pv+nv*q;
81 81
        }
82 82
      }
83 83
    else
......
162 162
        tmp1.cached[3] = curr.w;
163 163
        tmp1.cached[4] = curr.v;
164 164
        
165
        tmp1.a[0] =  2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0];
166
        tmp1.b[0] = -3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0];
167
        tmp1.c[0] = tmp1.tangent[0];
165
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
166
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
167
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
168 168
        tmp1.d[0] = curr.x;
169 169
      
170
        tmp1.a[1] =  2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1];
171
        tmp1.b[1] = -3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1];
172
        tmp1.c[1] = tmp1.tangent[1];
170
        tmp1.a[1] = mConvexity*( 2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1]);
171
        tmp1.b[1] = mConvexity*(-3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1]);
172
        tmp1.c[1] = mConvexity*(tmp1.tangent[1]) + (1.0f-mConvexity)*(next.y-curr.y);
173 173
        tmp1.d[1] = curr.y;
174 174
      
175
        tmp1.a[2] =  2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2];
176
        tmp1.b[2] = -3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2];
177
        tmp1.c[2] = tmp1.tangent[2];
175
        tmp1.a[2] = mConvexity*( 2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2]);
176
        tmp1.b[2] = mConvexity*(-3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2]);
177
        tmp1.c[2] = mConvexity*(tmp1.tangent[2]) + (1.0f-mConvexity)*(next.z-curr.z);
178 178
        tmp1.d[2] = curr.z;
179 179
        
180
        tmp1.a[3] =  2*curr.w +   tmp1.tangent[3] - 2*next.w + tmp2.tangent[3];
181
        tmp1.b[3] = -3*curr.w - 2*tmp1.tangent[3] + 3*next.w - tmp2.tangent[3];
182
        tmp1.c[3] = tmp1.tangent[3];
180
        tmp1.a[3] = mConvexity*( 2*curr.w +   tmp1.tangent[3] - 2*next.w + tmp2.tangent[3]);
181
        tmp1.b[3] = mConvexity*(-3*curr.w - 2*tmp1.tangent[3] + 3*next.w - tmp2.tangent[3]);
182
        tmp1.c[3] = mConvexity*(tmp1.tangent[3]) + (1.0f-mConvexity)*(next.w-curr.w);
183 183
        tmp1.d[3] = curr.w;
184 184
        
185
        tmp1.a[4] =  2*curr.v +   tmp1.tangent[4] - 2*next.v + tmp2.tangent[4];
186
        tmp1.b[4] = -3*curr.v - 2*tmp1.tangent[4] + 3*next.v - tmp2.tangent[4];
187
        tmp1.c[4] = tmp1.tangent[4];
185
        tmp1.a[4] = mConvexity*( 2*curr.v +   tmp1.tangent[4] - 2*next.v + tmp2.tangent[4]);
186
        tmp1.b[4] = mConvexity*(-3*curr.v - 2*tmp1.tangent[4] + 3*next.v - tmp2.tangent[4]);
187
        tmp1.c[4] = mConvexity*(tmp1.tangent[4]) + (1.0f-mConvexity)*(next.v-curr.v);
188 188
        tmp1.d[4] = curr.v;
189 189
        }
190 190
      }

Also available in: Unified diff