@@ -153,15 +153,35 @@ void DrawOneInst(struct Instance* curr)
153153 gte_SetGeomScreen (pb -> distanceToScreen_PREV );
154154#endif
155155
156+ // ============ Get Scale ==============
157+
158+ struct Model * m = curr -> model ;
159+ struct ModelHeader * mh = & m -> headers [0 ];
160+
161+ // Can this be applied to the GTE matrix,
162+ // to remove the need to multiply vertices by scale?
163+ int scale [3 ];
164+ scale [0 ] = (mh -> scale [0 ] * curr -> scale [0 ]) >> 12 ;
165+ scale [1 ] = (mh -> scale [1 ] * curr -> scale [1 ]) >> 12 ;
166+ scale [2 ] = (mh -> scale [2 ] * curr -> scale [2 ]) >> 12 ;
167+
156168 // ============ Get ModelViewProj Matrix ==============
157169
158170 MATRIX mvp ;
159171 MATRIX * mat2 = & mvp ;
160172
161173 // why is this shifting by 0x10 instead of 0xC?
162174
163- #define RCC (row , col , index ) \
164- ((int)((int)pb->matrix_ViewProj.m[row][index] * (int)curr->matrix.m[index][col]) >> 0x10)
175+ #define RCC (row , col , index ) \
176+ ( \
177+ ( \
178+ pb->matrix_ViewProj.m[row][index] * \
179+ (( \
180+ curr->matrix.m[index][col] * \
181+ scale[col] \
182+ ) >> 8) \
183+ ) >> 0x10 \
184+ )
165185
166186 mvp .m [0 ][0 ] = RCC (0 , 0 , 0 ) + RCC (0 , 0 , 1 ) + RCC (0 , 0 , 2 );
167187 mvp .m [0 ][1 ] = RCC (0 , 1 , 0 ) + RCC (0 , 1 , 1 ) + RCC (0 , 1 , 2 );
@@ -202,9 +222,6 @@ void DrawOneInst(struct Instance* curr)
202222
203223 // ============ Draw Instance ==============
204224
205- struct Model * m = curr -> model ;
206- struct ModelHeader * mh = & m -> headers [0 ];
207-
208225 // assume unanimated
209226 struct ModelFrame * mf = mh -> ptrFrameData ;
210227 struct ModelAnim * ma = 0 ;
@@ -277,7 +294,7 @@ void DrawOneInst(struct Instance* curr)
277294 int y_alu = 0 ;
278295 int z_alu = 0 ;
279296 bi = 0 ;
280-
297+
281298 //loop commands until we hit the end marker
282299 for (
283300 /* */ ;
@@ -393,30 +410,25 @@ void DrawOneInst(struct Instance* curr)
393410
394411 void * pCurr ;
395412 void * pNext ;
396-
397- int scale [3 ];
398- scale [0 ] = (mh -> scale [0 ] * curr -> scale [0 ]) >> 12 ;
399- scale [1 ] = (mh -> scale [1 ] * curr -> scale [1 ]) >> 12 ;
400- scale [2 ] = (mh -> scale [2 ] * curr -> scale [2 ]) >> 12 ;
401-
413+
402414 // The X, Z, Y, is not a typo
403- posWorld1 [0 ] = ((( mf -> pos [0 ] + tempCoords [1 ].X ) * scale [ 0 ]) >> 8 ) ;
404- posWorld1 [1 ] = ((( mf -> pos [1 ] + tempCoords [1 ].Z ) * scale [ 1 ]) >> 8 ) ;
405- posWorld1 [2 ] = ((( mf -> pos [2 ] + tempCoords [1 ].Y ) * scale [ 2 ]) >> 8 ) ;
415+ posWorld1 [0 ] = mf -> pos [0 ] + tempCoords [1 ].X ;
416+ posWorld1 [1 ] = mf -> pos [1 ] + tempCoords [1 ].Z ;
417+ posWorld1 [2 ] = mf -> pos [2 ] + tempCoords [1 ].Y ;
406418 posWorld1 [3 ] = 0 ;
407419 gte_ldv0 (& posWorld1 [0 ]);
408420
409421 // The X, Z, Y, is not a typo
410- posWorld2 [0 ] = ((( mf -> pos [0 ] + tempCoords [2 ].X ) * scale [ 0 ]) >> 8 ) ;
411- posWorld2 [1 ] = ((( mf -> pos [1 ] + tempCoords [2 ].Z ) * scale [ 1 ]) >> 8 ) ;
412- posWorld2 [2 ] = ((( mf -> pos [2 ] + tempCoords [2 ].Y ) * scale [ 2 ]) >> 8 ) ;
422+ posWorld2 [0 ] = mf -> pos [0 ] + tempCoords [2 ].X ;
423+ posWorld2 [1 ] = mf -> pos [1 ] + tempCoords [2 ].Z ;
424+ posWorld2 [2 ] = mf -> pos [2 ] + tempCoords [2 ].Y ;
413425 posWorld2 [3 ] = 0 ;
414426 gte_ldv1 (& posWorld2 [0 ]);
415427
416428 // The X, Z, Y, is not a typo
417- posWorld3 [0 ] = ((( mf -> pos [0 ] + tempCoords [3 ].X ) * scale [ 0 ]) >> 8 ) ;
418- posWorld3 [1 ] = ((( mf -> pos [1 ] + tempCoords [3 ].Z ) * scale [ 1 ]) >> 8 ) ;
419- posWorld3 [2 ] = ((( mf -> pos [2 ] + tempCoords [3 ].Y ) * scale [ 2 ]) >> 8 ) ;
429+ posWorld3 [0 ] = mf -> pos [0 ] + tempCoords [3 ].X ;
430+ posWorld3 [1 ] = mf -> pos [1 ] + tempCoords [3 ].Z ;
431+ posWorld3 [2 ] = mf -> pos [2 ] + tempCoords [3 ].Y ;
420432 posWorld3 [3 ] = 0 ;
421433 gte_ldv2 (& posWorld3 [0 ]);
422434
0 commit comments