@@ -14,13 +14,24 @@ void xMat3x3RMulVec(xVec3* o, const xMat3x3* m, const xVec3* v)
1414 o->z = z;
1515}
1616
17+ // Artificial
18+ enum en_MOTIONTYPE
19+ {
20+ MOTION_TYPE_EXRT,
21+ MOTION_TYPE_ORBT,
22+ MOTION_TYPE_SPLN,
23+ MOTION_TYPE_MVPT,
24+ MOTION_TYPE_MECH,
25+ MOTION_TYPE_PEND
26+ };
27+
1728void xEntMotionInit (xEntMotion* a, xEnt* b, xEntMotionAsset* c)
1829{
1930 a->asset = c;
2031 a->type = c->type ;
2132 a->flags = c->flags ;
2233
23- if (a->type == 0 ) // ER
34+ if (a->type == MOTION_TYPE_EXRT)
2435 {
2536 xVec3Copy (&a->er .a , &c->er .ret_pos );
2637 xVec3Add (&a->er .b , &c->er .ret_pos , &c->er .ext_dpos );
@@ -39,7 +50,7 @@ void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c)
3950 a->er .ert = a->er .brt + a->er .rt ;
4051 a->er .p = a->er .ert + a->er .wrt ;
4152 }
42- else if (a->type == 1 ) // Orbit
53+ else if (a->type == MOTION_TYPE_ORBT)
4354 {
4455 xVec3Copy ((xVec3*)(&a->er .b ), &c->er .ret_pos );
4556
@@ -54,11 +65,11 @@ void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c)
5465 a->orb .p = c->orb .period ;
5566 a->orb .w = (2 * PI) / c->orb .period ;
5667 }
57- else if (a->type == 3 ) // MP
68+ else if (a->type == MOTION_TYPE_MVPT)
5869 {
5970 // literally nothing
6071 }
61- else if (a->type == 5 ) // Pen
72+ else if (a->type == MOTION_TYPE_PEND)
6273 {
6374 if (c->pen .period <= 1e-5f )
6475 {
@@ -67,7 +78,7 @@ void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c)
6778
6879 a->pen .w = (2 * PI) / c->pen .period ;
6980 }
70- else if (a->type == 4 ) // Mech
81+ else if (a->type == MOTION_TYPE_MECH)
7182 {
7283 if (c->mp .speed < 1e-5f )
7384 {
@@ -105,4 +116,45 @@ void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c)
105116 a->target = NULL ;
106117
107118 xEntMotionDebugAdd (a);
108- }
119+ }
120+
121+ void xEntMechForward (xEntMotion* motion)
122+ {
123+ xEntMotionMechData* mech = &(motion->asset ->mech );
124+ xEntMotionAsset* mkasst = motion->asset ;
125+
126+ xEntMotionRun (motion);
127+
128+ if ((motion->mech .state != 0 ) && (motion->mech .state != 1 ) && (motion->mech .state != 2 ))
129+ {
130+ if (motion->mech .state == 3 )
131+ {
132+ motion->mech .ss = -motion->mech .ss ;
133+ motion->mech .sr = -motion->mech .sr ;
134+ motion->tmr = mkasst->mech .sld_tm - motion->tmr ;
135+ motion->mech .state = 0 ;
136+ }
137+ else if (motion->mech .state == 4 )
138+ {
139+ motion->mech .ss = -motion->mech .ss ;
140+ motion->mech .sr = -motion->mech .sr ;
141+ motion->tmr = mkasst->mech .rot_tm - motion->tmr ;
142+ motion->mech .state = 1 ;
143+ }
144+ else if ((motion->mech .state != 5 ) && (motion->mech .state != 6 ) && (motion->mech .state == 7 ))
145+ {
146+ motion->mech .ss = -motion->mech .ss ;
147+ motion->mech .sr = -motion->mech .sr ;
148+ motion->tmr = 0 .0f ;
149+
150+ if ((mech->type == 0 ) || (mech->type == 2 ) || (mech->type == 4 ))
151+ {
152+ motion->mech .state = 0 ;
153+ }
154+ else
155+ {
156+ motion->mech .state = 1 ;
157+ }
158+ }
159+ }
160+ }
0 commit comments