@@ -304,33 +304,36 @@ void TMapObjWanwan::doFunc_Jumped() {
304304 mPos .add (mVel );
305305}
306306
307- void TMapObjWanwan::setRotate (f32 rotate)
308- {
307+ void TMapObjWanwan::setRotate (f32 rotate) {
309308 mRotate = rotate;
309+
310+ // might be mRotMtx.setEulerXYZ?
310311 const f32 x = 0 ;
311312 const f32 y = mRotate ;
312313 const f32 z = _230;
314+ f32 cr = cos (x); // f26
315+ f32 cp = cos (y); // f31
316+ f32 cy = cos (z); // f30
317+ f32 sr = sin (x); // f29
318+ f32 sp = sin (y); // f28
319+ f32 sy = sin (z); // f7
320+
321+ // ???
322+ f32 tmp = sy * sp;
323+ f32 cpy = (cy * cp);
324+ f32 spy = sp * sy;
325+
326+ mRotMtx [0 ][0 ] = ((tmp) * sr + (cp * cr));
327+ mRotMtx [1 ][0 ] = (sr * cy);
328+ mRotMtx [2 ][0 ] = -(sp * cr) + (sy * cp * sr);
313329
314- f32 dVar2 = cos (x); // f26
315- f32 dVar6 = cos (y); // f31
316- f32 dVar5 = cos (z); // f30
317- f32 dVar4 = sin (x); // f29
318- f32 dVar3 = sin (y); // f28
319- f32 dVar1 = sin (z); // f7
320-
321- f32 cxy = dVar6 * dVar2;
322-
323- mRotMtx [0 ][0 ] = (dVar1 * dVar3) * dVar4 + cxy;
324- mRotMtx [1 ][0 ] = (dVar4 * dVar5);
325- mRotMtx [2 ][0 ] = -(dVar3 * dVar2) + ((dVar1 * dVar6) * dVar4);
326-
327- mRotMtx [0 ][1 ] = ((-dVar4 * dVar6) + dVar2 * (dVar1 * dVar3));
328- mRotMtx [1 ][1 ] = (dVar5 * dVar2);
329- mRotMtx [2 ][1 ] = (dVar3 * dVar4 + dVar1 * (cxy));
330+ mRotMtx [0 ][1 ] = ((-sr * cp) + (spy) * cr);
331+ mRotMtx [1 ][1 ] = (cy * cr);
332+ mRotMtx [2 ][1 ] = (sp * sr + sy * (cp * cr));
330333
331- mRotMtx [0 ][2 ] = (dVar5 * dVar3 );
332- mRotMtx [1 ][2 ] = (-dVar1 );
333- mRotMtx [2 ][2 ] = (dVar5 * dVar6 );
334+ mRotMtx [0 ][2 ] = (cy * sp );
335+ mRotMtx [1 ][2 ] = (-sy );
336+ mRotMtx [2 ][2 ] = (cpy );
334337}
335338
336339void TMapObjWanwan::doFunc_Attack () {
@@ -433,7 +436,6 @@ void TMapObjWanwan::fallDown(s32 nextState, bool p2) {
433436 mVel .y = _218;
434437 }
435438 }
436-
437439 createEmitterOnGround (&mpEmitter, " mk_wanSmoke_a" );
438440}
439441
@@ -506,9 +508,10 @@ f32 TMapObjWanwan::getAngleToRand() {
506508 getWanwanBackPos (&backPos);
507509 backPos.sub (mObjData ->position );
508510
509- const f32 l = posDiff.x * mRotMtx [0 ][2 ] + posDiff.z * mRotMtx [2 ][2 ];
510-
511- if ((l < 0 .0f )
511+ JGeometry::TVec3f zDir;
512+ mRotMtx .getZDir (zDir);
513+
514+ if ((zDir.dotZX (posDiff) < 0 .0f )
512515 && (backPos.length () > mChainLength * 0 .8f ))
513516 {
514517 f32 a = std::atan2f (posDiff.x , posDiff.z );
@@ -532,7 +535,6 @@ f32 TMapObjWanwan::getRandRadius(u8 max, u8 min) {
532535 deg += min;
533536 }
534537 return MTXDegToRad (deg);
535-
536538}
537539
538540void TMapObjWanwan::getWanwanBackPos (JGeometry::TVec3f *out) {
@@ -544,9 +546,8 @@ void TMapObjWanwan::getWanwanBackPos(JGeometry::TVec3f *out) {
544546 return ;
545547 }
546548
547- // TODO: all matrices from J3D might already be TPos3f of itself
548- JGeometry::TPos3f *bumpMtx = (JGeometry::TPos3f *)mModel .getModel ()->getAnmMtx (sChainJointNo );
549- bumpMtx->getTrans (*out);
549+ Mtx &bumpMtx = mModel .getModel ()->getAnmMtx (sChainJointNo );
550+ out->set (bumpMtx[0 ][3 ], bumpMtx[1 ][3 ], bumpMtx[2 ][3 ]);
550551}
551552
552553f32 TMapObjWanwan::getAngleToAttack (JGeometry::TVec3f &v) {
@@ -572,17 +573,15 @@ void TMapObjWanwan::calc() {
572573 mFreeMove .update ();
573574 }
574575 chainCorrect ();
575- mpGround-> search ( mPos );
576- if (mPos . y - mHeightOffset <= mpGround-> getHeight () ) {
576+
577+ if (isTouchGround () ) {
577578 mpGround->search (mPos );
578579 mPos .y = mHeightOffset + mpGround->getHeight () - 0 .1f ;
579580 mVel .y = 0 .0f ;
580581 }
581582
582583 bool isWall = false ;
583584 mpGround->search (mPos , pos);
584-
585-
586585 if (mpGround->getAttribute () == CrsGround::Attr_2) {
587586 JGeometry::TVec3f wall;
588587
@@ -605,7 +604,6 @@ void TMapObjWanwan::calc() {
605604 for (; a >= F_PI; a -= F_TAU);
606605 mAttackAngle = a;
607606 }
608-
609607 }
610608 }
611609
@@ -667,8 +665,6 @@ void TMapObjWanwan::chainCorrect() {
667665
668666 vel.zero ();
669667 mpStringNodeMgr->setNodeVel (mNumChains - 1 , vel);
670-
671-
672668 fixChain ();
673669}
674670
@@ -723,18 +719,19 @@ void TMapObjWanwan::setChainPosition(TMapObjWanwanChain *pChain, JGeometry::TVec
723719 r_m.setXYZDir (cp, yDir, rPosDiff);
724720 PSMTXIdentity (b);
725721
722+ // might be setRotate?
726723 f32 s = sin (f);
727724 f32 c = cos (f);
728725
729726 b[0 ][0 ] = c;
730727 b[0 ][1 ] = -s;
731728 b[1 ][0 ] = s;
732729 b[1 ][1 ] = c;
733- b[2 ][2 ] = 1.0 ;
734- b[2 ][1 ] = 0.0 ;
735- b[1 ][2 ] = 0.0 ;
736- b[2 ][0 ] = 0.0 ;
737- b[0 ][2 ] = 0.0 ;
730+ b[2 ][2 ] = 1 .0f ;
731+ b[2 ][1 ] = 0 .0f ;
732+ b[1 ][2 ] = 0 .0f ;
733+ b[2 ][0 ] = 0 .0f ;
734+ b[0 ][2 ] = 0 .0f ;
738735
739736 PSMTXConcat (r_m, b, r_m);
740737 pChain->mRotMtx .set ( r_m );
0 commit comments