MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xEntMotionInit

Function xEntMotionInit

src/SB/Core/x/xEntMotion.cpp:36–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34char* xbtoa(U32 param);
35
36void xEntMotionInit(xEntMotion* motion, xEnt* owner, xEntMotionAsset* asset)
37{
38 motion->asset = asset;
39 motion->type = asset->type;
40 motion->flags = asset->flags;
41
42 if (motion->type == XENTMOTION_TYPE_ER)
43 {
44 xVec3Copy(&motion->er.a, &asset->er.ret_pos);
45 xVec3Add(&motion->er.b, &asset->er.ret_pos, &asset->er.ext_dpos);
46
47 motion->er.et = asset->er.ext_tm;
48 motion->er.wet = asset->er.ext_wait_tm;
49 motion->er.rt = asset->er.ret_tm;
50 motion->er.wrt = asset->er.ret_wait_tm;
51
52 if (motion->er.p <= 0)
53 {
54 motion->er.p = 1.0f;
55 }
56
57 motion->er.brt = motion->er.et + motion->er.wet;
58 motion->er.ert = motion->er.brt + motion->er.rt;
59 motion->er.p = motion->er.ert + motion->er.wrt;
60 }
61 else if (motion->type == XENTMOTION_TYPE_ORB)
62 {
63 xVec3Copy(&motion->er.b, &asset->er.ret_pos);
64
65 motion->orb.a = asset->orb.w;
66 motion->orb.b = asset->orb.h;
67
68 if (asset->orb.period <= 1e-5f)
69 {
70 asset->orb.period = 1.0f;
71 }
72
73 motion->orb.p = asset->orb.period;
74 motion->orb.w = (2 * PI) / asset->orb.period;
75 }
76 else if (motion->type == XENTMOTION_TYPE_MP)
77 {
78 // literally nothing
79 }
80 else if (motion->type == XENTMOTION_TYPE_PEN)
81 {
82 if (asset->pen.period <= 1e-5f)
83 {
84 asset->pen.period = 1.0f;
85 }
86
87 motion->pen.w = (2 * PI) / asset->pen.period;
88 }
89 else if (motion->type == XENTMOTION_TYPE_MECH)
90 {
91 if (asset->mp.speed < 1e-5f)
92 {
93 asset->mp.speed = 1.0f;

Callers 6

zPendulum_InitFunction · 0.50
zPendulum_ResetFunction · 0.50
zEntButton_InitFunction · 0.50
zEntButton_ResetFunction · 0.50
zPlatform_InitFunction · 0.50
zPlatform_ResetFunction · 0.50

Calls 3

xVec3CopyFunction · 0.85
xVec3AddFunction · 0.85
xEntMotionDebugAddFunction · 0.85

Tested by

no test coverage detected