MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoCycledAnim

Function DoCycledAnim

Descent3/object.cpp:2121–2171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2119}
2120
2121void DoCycledAnim(object *obj) {
2122 float from;
2123 float to;
2124 float delta;
2125 float spc;
2126
2127 float anim_time = Frametime;
2128
2129 if (!(obj->flags & OF_POLYGON_OBJECT))
2130 return;
2131
2132 from = Object_info[obj->id].anim[MC_STANDING].elem[AS_ALERT].from;
2133 to = Object_info[obj->id].anim[MC_STANDING].elem[AS_ALERT].to;
2134 spc = Object_info[obj->id].anim[MC_STANDING].elem[AS_ALERT].spc;
2135
2136 if (spc <= 0.0)
2137 return;
2138 ASSERT(from <= to);
2139
2140 if (obj->rtype.pobj_info.anim_frame < from || obj->rtype.pobj_info.anim_frame > to) {
2141 mprintf(0, "NonAI-Animation: Correcting for an incorrect frame number\n");
2142 obj->rtype.pobj_info.anim_frame = from;
2143 }
2144
2145 delta = to - from;
2146
2147 ASSERT(delta >= 0.0f);
2148
2149 if (delta > 0.0f) {
2150 // Frames per second will be on the animation page
2151 float step = (1.0f / (spc / (delta))) * anim_time;
2152
2153 while (step > delta) {
2154 step -= delta;
2155 }
2156
2157 ASSERT(step >= 0.0f);
2158
2159 obj->rtype.pobj_info.anim_frame += step;
2160
2161 if (obj->rtype.pobj_info.anim_frame >= to) {
2162
2163 // We are guarenteed that this is between 'to' and 'from' from the above asserts() :)
2164 obj->rtype.pobj_info.anim_frame -= delta;
2165 }
2166 } else {
2167 obj->rtype.pobj_info.anim_frame = from;
2168 }
2169
2170 ASSERT(obj->rtype.pobj_info.anim_frame >= from && obj->rtype.pobj_info.anim_frame <= to);
2171}
2172
2173void TimeoutObject(object *obj) {
2174 switch (obj->type) {

Callers 1

ObjDoFrameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected