152 sceVu0FVECTOR(*work)[16];
158 sceVu0FMATRIX matrix;
159 sceVu0FVECTOR scratch;
160 sceVu0FVECTOR *stretch_params;
170 scratchpad = (
float *) 0x70000000;
171 work = (sceVu0FVECTOR(*)[16]) scratchpad;
173 for (i = 0; i <
num_i; i++) {
174 for (j = 0; j <
num_j; j++) {
175 *(u_long128 *) work[i][j] = *(u_long128 *)
point[i][j];
179 scratchpad +=
sizeof(
point) /
sizeof(
float);
182 frame->GetLWMatrix(matrix);
183 sceVu0ApplyMatrix(root, matrix, this->
position);
186 if (vuabs(delta) > 10.0f ||
stop != 0) {
201 register float *stiffness_ptr;
202 register float *matrix_ptr;
204 matrix_ptr = &matrix[0][0];
208 lqc2 $vf1, 0x0(matrix_ptr)
209 lqc2 $vf2, 0x10(matrix_ptr)
210 lqc2 $vf3, 0x20(matrix_ptr)
211 lqc2 $vf4, 0x30(matrix_ptr)
212 lqc2 $vf5, 0x0(stiffness_ptr)
217 for (j = 0; j <
num_j; j++) {
218 for (i = 0; i <
num_i; i++) {
220 velocity =
speed[i][j];
223 vertex[0] += delta[0];
224 vertex[1] += delta[1];
225 vertex[2] += delta[2];
226 }
else if (
frame != NULL) {
227 register float *delta_ptr;
228 register float *home_ptr;
229 register float *world_home_ptr;
230 register float *vel_ptr;
231 register float *vertex_ptr;
236 home_ptr =
home[i][j];
240 lqc2 $vf13, 0x0(home_ptr)
241 lqc2 $vf10, 0x0(vertex_ptr)
242 lqc2 $vf11, 0x0(vel_ptr)
243 lqc2 $vf12, 0x0(delta_ptr)
244 vmulax.xyzw $ACC, $vf1, $vf13x
245 vmadday.xyzw $ACC, $vf2, $vf13y
246 vmaddaz.xyzw $ACC, $vf3, $vf13z
247 vmaddw.xyzw $vf23, $vf4, $vf13w
248 vaddx.w $vf10, $vf0, $vf0x
249 vaddx.w $vf11, $vf0, $vf0x
250 sqc2 $vf23, 0x0(world_home_ptr)
251 vsub.xyzw $vf20, $vf23, $vf10
252 vmulaw.xyzw $ACC, $vf12, $vf0w
253 vmadd.xyzw $vf26, $vf20, $vf5
254 vmulaw.xyzw $ACC, $vf10, $vf0w
255 vmaddaw.xyzw $ACC, $vf11, $vf0w
256 vmaddw.xyz $vf10, $vf26, $vf0w
257 vmulax.xyzw $ACC, $vf0, $vf0x
258 vmsubw.xyz $vf11, $vf26, $vf0w
259 sqc2 $vf10, 0x0(vertex_ptr)
260 sqc2 $vf11, 0x0(vel_ptr)
263 vertex[0] += velocity[0];
264 vertex[1] += velocity[1];
265 vertex[2] += velocity[2];
270 sceVu0FVECTOR origin = {0.0f, 0.0f, 0.0f, 1.0f};
271 stretch_params = (sceVu0FVECTOR *) scratchpad;
272 scratchpad +=
num_j *
sizeof(sceVu0FVECTOR) /
sizeof(
float);
273 hit_point = scratchpad;
277 for (j = 0; j <
num_j - 1; j++) {
278 stretch_params[j][1] = 0.3f + 0.2f * ((float) j / (
float)
num_j);
279 stretch_params[j][2] = 1.0f - stretch_params[j][1];
282 for (pass = 0; pass < 4 && reset == 0; pass++) {
283 for (j = 0; j <
num_j - 1; j++) {
284 for (i = 0; i <
num_i; i++) {
286 scratch[0] = 2.0f *
rest[i][j][0];
287 StretchBind2(work[i][j], work[i - 2][j], scratch);
292 stretch_params[j][0] =
rest[i][j][1];
293 StretchBind2(work[i][j], work[i][j + 1], stretch_params[j]);
297 for (j = 0; j <
num_i; j++) {
299 sceVu0CopyVector(work[j][0],
home[j][0]);
301 *(u_long128 *) work[j][0] = *(u_long128 *)
world_home[j][0];
311 for (j = 1; j <
num_j; j++) {
312 for (i = 0; i <
num_i; i++) {
315 float hit_count = 0.0f;
316 sceVu0FVECTOR hit_sum;
320 float friction = 0.0f;
322 for (; box != NULL; box = box->
next) {
325 sceVu0AddVector(hit_sum, hit_sum, hit_point);
332 work[i][j][0] = hit_sum[0] / hit_count;
333 work[i][j][1] = hit_sum[1] / hit_count;
334 work[i][j][2] = hit_sum[2] / hit_count;
335 rest[i][j][3] = friction / hit_count;
337 rest[i][j][3] = -1.0f;
343 sceVu0FVECTOR wind_force = {0.0f, 0.0f, 0.0f, 0.0f};
345 for (i = 0; i <
num_i; i++) {
347 ((
CWind *)
wind)->GetWindNoise(wind_force);
348 sceVu0ScaleVector(wind_force, wind_force,
wind_effect);
351 for (j = 0; j <
num_j; j++) {
355 sceVu0CopyVector(
last[i][j], work[i][j]);
356 sceVu0Normalize(scratch,
speed[i][j]);
357 float facing = sceVu0InnerProduct(scratch,
normal_grid[i][j]);
363 float damping = 0.6f + (1.0f - facing);
365 if (damping > 1.0f) {
369 speed[i][j][0] += facing * wind_force[0];
370 speed[i][j][1] += facing * wind_force[1];
371 speed[i][j][2] += facing * wind_force[2];
372 speed[i][j][0] *= damping;
373 speed[i][j][1] *= damping;
374 speed[i][j][2] *= damping;
377 speed[i][j][0] = 0.0f;
378 speed[i][j][1] = 0.0f;
379 speed[i][j][2] = 0.0f;
381 if (
rest[i][j][3] > 0.0f) {
387 if (work[i][j][1] <= ground &&
floor_on != 0) {
388 work[i][j][1] = ground;
389 speed[i][j][0] *= 0.4f;
390 speed[i][j][2] *= 0.4f;
397 sceVu0FVECTOR edge[4];
398 sceVu0FVECTOR normal;
399 sceVu0FVECTOR cross[4];
405 for (j = 0; j <
num_j; j++) {
406 for (i = 0; i <
num_i; i++) {
425 if (next_i >=
num_i) {
429 if (next_j >=
num_j) {
433 sceVu0SubVector(edge[0], work[next_i][j], work[i][j]);
434 sceVu0SubVector(edge[1], work[prev_i][j], work[i][j]);
435 sceVu0SubVector(edge[2], work[i][prev_j], work[i][j]);
436 sceVu0SubVector(edge[3], work[i][next_j], work[i][j]);
437 sceVu0OuterProduct(cross[0], edge[3], edge[0]);
438 sceVu0OuterProduct(cross[1], edge[1], edge[3]);
439 sceVu0OuterProduct(cross[2], edge[2], edge[1]);
440 sceVu0OuterProduct(cross[3], edge[0], edge[2]);
441 sceVu0AddVector(normal, cross[0], cross[1]);
442 sceVu0AddVector(normal, normal, cross[2]);
443 sceVu0AddVector(normal, normal, cross[3]);
449 for (i = 0; i <
num_i; i++) {
450 for (j = 0; j <
num_j; j++) {
451 *(u_long128 *)
point[i][j] = *(u_long128 *) work[i][j];