goat3d

annotate src/xform_node.cc @ 88:7941e89798e5

selections
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 15 May 2014 06:52:01 +0300
parents 8970ca3d55e0
children da100bf13f7f
rev   line source
nuclear@54 1 /*
nuclear@54 2 goat3d - 3D scene, character, and animation file format library.
nuclear@54 3 Copyright (C) 2013-2014 John Tsiombikas <nuclear@member.fsf.org>
nuclear@54 4
nuclear@54 5 This program is free software: you can redistribute it and/or modify
nuclear@54 6 it under the terms of the GNU Lesser General Public License as published by
nuclear@54 7 the Free Software Foundation, either version 3 of the License, or
nuclear@54 8 (at your option) any later version.
nuclear@54 9
nuclear@54 10 This program is distributed in the hope that it will be useful,
nuclear@54 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
nuclear@54 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
nuclear@54 13 GNU Lesser General Public License for more details.
nuclear@54 14
nuclear@54 15 You should have received a copy of the GNU Lesser General Public License
nuclear@54 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
nuclear@54 17 */
nuclear@1 18 #include <assert.h>
nuclear@1 19 #include <algorithm>
nuclear@1 20 #include "xform_node.h"
nuclear@47 21 #include "anim/anim.h"
nuclear@47 22 #include "anim/track.h"
nuclear@47 23
nuclear@47 24 using namespace g3dimpl;
nuclear@1 25
nuclear@1 26 static inline anm_interpolator track_interpolator(Interp in);
nuclear@1 27 static inline anm_extrapolator track_extrapolator(Extrap ex);
nuclear@1 28
nuclear@1 29 XFormNode::XFormNode()
nuclear@1 30 {
nuclear@1 31 anm = new anm_node;
nuclear@1 32 anm_init_node(anm);
nuclear@47 33 parent = 0;
nuclear@30 34
nuclear@47 35 // TODO read them from anm to get the correct initial values
nuclear@47 36 interp = INTERP_LINEAR;
nuclear@47 37 extrap = EXTRAP_EXTEND;
nuclear@1 38 }
nuclear@1 39
nuclear@1 40 XFormNode::~XFormNode()
nuclear@1 41 {
nuclear@1 42 anm_destroy_node(anm);
nuclear@1 43 delete anm;
nuclear@1 44 }
nuclear@1 45
nuclear@47 46 struct anm_node *XFormNode::get_libanim_node() const
nuclear@47 47 {
nuclear@47 48 return anm;
nuclear@47 49 }
nuclear@47 50
nuclear@1 51 void XFormNode::set_name(const char *name)
nuclear@1 52 {
nuclear@1 53 anm_set_node_name(anm, name);
nuclear@1 54 }
nuclear@1 55
nuclear@1 56 const char *XFormNode::get_name() const
nuclear@1 57 {
nuclear@1 58 return anm_get_node_name(anm);
nuclear@1 59 }
nuclear@1 60
nuclear@1 61 void XFormNode::set_interpolator(Interp in)
nuclear@1 62 {
nuclear@1 63 anm_set_interpolator(anm, track_interpolator(in));
nuclear@1 64 interp = in;
nuclear@1 65 }
nuclear@1 66
nuclear@1 67 Interp XFormNode::get_interpolator() const
nuclear@1 68 {
nuclear@1 69 return interp;
nuclear@1 70 }
nuclear@1 71
nuclear@1 72 void XFormNode::set_extrapolator(Extrap ex)
nuclear@1 73 {
nuclear@1 74 anm_set_extrapolator(anm, track_extrapolator(ex));
nuclear@1 75 extrap = ex;
nuclear@1 76 }
nuclear@1 77
nuclear@1 78 Extrap XFormNode::get_extrapolator() const
nuclear@1 79 {
nuclear@1 80 return extrap;
nuclear@1 81 }
nuclear@1 82
nuclear@47 83 XFormNode *XFormNode::get_parent()
nuclear@47 84 {
nuclear@47 85 return parent;
nuclear@47 86 }
nuclear@47 87
nuclear@47 88 const XFormNode *XFormNode::get_parent() const
nuclear@47 89 {
nuclear@47 90 return parent;
nuclear@47 91 }
nuclear@47 92
nuclear@1 93 void XFormNode::add_child(XFormNode *child)
nuclear@1 94 {
nuclear@66 95 if(!child || child == this) return;
nuclear@66 96
nuclear@1 97 children.push_back(child);
nuclear@1 98 anm_link_node(anm, child->anm);
nuclear@30 99 child->parent = this;
nuclear@1 100 }
nuclear@1 101
nuclear@1 102 void XFormNode::remove_child(XFormNode *child)
nuclear@1 103 {
nuclear@1 104 std::vector<XFormNode*>::iterator it;
nuclear@1 105 it = std::find(children.begin(), children.end(), child);
nuclear@1 106 if(it != children.end()) {
nuclear@1 107 children.erase(it);
nuclear@1 108 anm_unlink_node(anm, child->anm);
nuclear@47 109
nuclear@47 110 if(child->parent == this) {
nuclear@47 111 child->parent = 0;
nuclear@47 112 }
nuclear@1 113 }
nuclear@1 114 }
nuclear@1 115
nuclear@1 116 int XFormNode::get_children_count() const
nuclear@1 117 {
nuclear@1 118 return (int)children.size();
nuclear@1 119 }
nuclear@1 120
nuclear@1 121 XFormNode *XFormNode::get_child(int idx)
nuclear@1 122 {
nuclear@1 123 if(idx >= 0 && idx < get_children_count()) {
nuclear@1 124 return children[idx];
nuclear@1 125 }
nuclear@1 126 return 0;
nuclear@1 127 }
nuclear@1 128
nuclear@1 129 const XFormNode *XFormNode::get_child(int idx) const
nuclear@1 130 {
nuclear@1 131 if(idx >= 0 && idx < get_children_count()) {
nuclear@1 132 return children[idx];
nuclear@1 133 }
nuclear@1 134 return 0;
nuclear@1 135 }
nuclear@1 136
nuclear@47 137
nuclear@47 138 void XFormNode::use_animation(int idx)
nuclear@30 139 {
nuclear@47 140 if(idx >= 0) {
nuclear@47 141 anm_use_animation(anm, idx);
nuclear@47 142 }
nuclear@30 143 }
nuclear@30 144
nuclear@47 145 void XFormNode::use_animation(const char *name)
nuclear@47 146 {
nuclear@47 147 anm_use_animation(anm, anm_find_animation(anm, name));
nuclear@47 148 }
nuclear@47 149
nuclear@47 150 void XFormNode::use_animation(int aidx, int bidx, float t)
nuclear@47 151 {
nuclear@47 152 anm_use_animations(anm, aidx, bidx, t);
nuclear@47 153 }
nuclear@47 154
nuclear@47 155 void XFormNode::use_animation(const char *aname, const char *bname, float t)
nuclear@47 156 {
nuclear@47 157 int aidx = anm_find_animation(anm, aname);
nuclear@47 158 int bidx = anm_find_animation(anm, bname);
nuclear@47 159
nuclear@47 160 if(aidx == -1) {
nuclear@47 161 use_animation(bidx);
nuclear@47 162 }
nuclear@47 163 if(bidx == -1) {
nuclear@47 164 use_animation(aidx);
nuclear@47 165 }
nuclear@47 166 anm_use_animations(anm, aidx, bidx, t);
nuclear@47 167 }
nuclear@47 168
nuclear@47 169 int XFormNode::get_active_animation_index(int which) const
nuclear@47 170 {
nuclear@47 171 return anm_get_active_animation_index(anm, which);
nuclear@47 172 }
nuclear@47 173
nuclear@47 174 float XFormNode::get_active_animation_mix() const
nuclear@47 175 {
nuclear@47 176 return anm_get_active_animation_mix(anm);
nuclear@47 177 }
nuclear@47 178
nuclear@47 179 int XFormNode::get_animation_count() const
nuclear@47 180 {
nuclear@47 181 return anm_get_animation_count(anm);
nuclear@47 182 }
nuclear@47 183
nuclear@47 184 void XFormNode::add_animation(const char *name)
nuclear@47 185 {
nuclear@47 186 int idx = get_animation_count();
nuclear@47 187
nuclear@47 188 anm_add_animation(anm);
nuclear@47 189 use_animation(idx);
nuclear@47 190
nuclear@47 191 if(name) {
nuclear@47 192 set_animation_name(name);
nuclear@47 193 }
nuclear@47 194 }
nuclear@47 195
nuclear@47 196 void XFormNode::set_animation_name(const char *name)
nuclear@47 197 {
nuclear@47 198 anm_set_active_animation_name(anm, name);
nuclear@47 199 }
nuclear@47 200
nuclear@47 201 const char *XFormNode::get_animation_name() const
nuclear@47 202 {
nuclear@47 203 return anm_get_active_animation_name(anm);
nuclear@47 204 }
nuclear@47 205
nuclear@48 206 static const int track_type_base[] = {ANM_TRACK_POS_X, ANM_TRACK_ROT_X, ANM_TRACK_SCL_X};
nuclear@48 207 static const int track_type_nelem[] = {3, 4, 3};
nuclear@47 208
nuclear@48 209 int XFormNode::get_key_count(int trackid) const
nuclear@48 210 {
nuclear@48 211 struct anm_animation *anim = anm_get_active_animation(anm, 0);
nuclear@68 212 if(anim) {
nuclear@68 213 return anim->tracks[track_type_base[trackid]].count;
nuclear@68 214 }
nuclear@68 215 return 0;
nuclear@48 216 }
nuclear@48 217
nuclear@48 218 int XFormNode::get_position_key_count() const
nuclear@48 219 {
nuclear@48 220 return get_key_count(POSITION_TRACK);
nuclear@48 221 }
nuclear@48 222
nuclear@48 223 int XFormNode::get_rotation_key_count() const
nuclear@48 224 {
nuclear@48 225 return get_key_count(ROTATION_TRACK);
nuclear@48 226 }
nuclear@48 227
nuclear@48 228 int XFormNode::get_scaling_key_count() const
nuclear@48 229 {
nuclear@48 230 return get_key_count(SCALING_TRACK);
nuclear@48 231 }
nuclear@48 232
nuclear@48 233 long XFormNode::get_key_time(int trackid, int idx) const
nuclear@48 234 {
nuclear@48 235 struct anm_animation *anim = anm_get_active_animation(anm, 0);
nuclear@48 236 struct anm_keyframe *key = anm_get_keyframe(anim->tracks + track_type_base[trackid], idx);
nuclear@48 237 return ANM_TM2MSEC(key->time);
nuclear@48 238 }
nuclear@48 239
nuclear@48 240 long XFormNode::get_position_key_time(int idx) const
nuclear@48 241 {
nuclear@48 242 return get_key_time(POSITION_TRACK, idx);
nuclear@48 243 }
nuclear@48 244
nuclear@48 245 long XFormNode::get_rotation_key_time(int idx) const
nuclear@48 246 {
nuclear@48 247 return get_key_time(ROTATION_TRACK, idx);
nuclear@48 248 }
nuclear@48 249
nuclear@48 250 long XFormNode::get_scaling_key_time(int idx) const
nuclear@48 251 {
nuclear@48 252 return get_key_time(SCALING_TRACK, idx);
nuclear@48 253 }
nuclear@48 254
nuclear@48 255 int XFormNode::get_key_value(int trackid, int idx, float *val) const
nuclear@48 256 {
nuclear@48 257 struct anm_animation *anim = anm_get_active_animation(anm, 0);
nuclear@48 258
nuclear@48 259 int nelem = track_type_nelem[trackid];
nuclear@48 260 for(int i=0; i<nelem; i++) {
nuclear@48 261 struct anm_keyframe *key = anm_get_keyframe(anim->tracks + track_type_base[trackid] + i, idx);
nuclear@48 262 val[i] = key->val;
nuclear@48 263 }
nuclear@48 264 return nelem;
nuclear@48 265 }
nuclear@48 266
nuclear@48 267 Vector3 XFormNode::get_position_key_value(int idx) const
nuclear@48 268 {
nuclear@48 269 float val[3];
nuclear@48 270 get_key_value(POSITION_TRACK, idx, val);
nuclear@48 271 return Vector3(val[0], val[1], val[2]);
nuclear@48 272 }
nuclear@48 273
nuclear@48 274 Quaternion XFormNode::get_rotation_key_value(int idx) const
nuclear@48 275 {
nuclear@48 276 float val[4];
nuclear@48 277 get_key_value(ROTATION_TRACK, idx, val);
nuclear@48 278 return Quaternion(val[3], val[0], val[1], val[2]);
nuclear@48 279 }
nuclear@48 280
nuclear@48 281 Vector3 XFormNode::get_scaling_key_value(int idx) const
nuclear@48 282 {
nuclear@48 283 float val[3];
nuclear@48 284 get_key_value(SCALING_TRACK, idx, val);
nuclear@48 285 return Vector3(val[0], val[1], val[2]);
nuclear@48 286 }
nuclear@47 287
nuclear@1 288 void XFormNode::set_position(const Vector3 &pos, long tmsec)
nuclear@1 289 {
nuclear@1 290 anm_set_position(anm, v3_cons(pos.x, pos.y, pos.z), ANM_MSEC2TM(tmsec));
nuclear@1 291 }
nuclear@1 292
nuclear@1 293 Vector3 XFormNode::get_node_position(long tmsec) const
nuclear@1 294 {
nuclear@1 295 vec3_t p = anm_get_node_position(anm, ANM_MSEC2TM(tmsec));
nuclear@1 296 return Vector3(p.x, p.y, p.z);
nuclear@1 297 }
nuclear@1 298
nuclear@1 299 void XFormNode::set_rotation(const Quaternion &quat, long tmsec)
nuclear@1 300 {
nuclear@1 301 anm_set_rotation(anm, quat_cons(quat.s, quat.v.x, quat.v.y, quat.v.z), ANM_MSEC2TM(tmsec));
nuclear@1 302 }
nuclear@1 303
nuclear@1 304 Quaternion XFormNode::get_node_rotation(long tmsec) const
nuclear@1 305 {
nuclear@1 306 quat_t q = anm_get_node_rotation(anm, ANM_MSEC2TM(tmsec));
nuclear@1 307 return Quaternion(q.w, q.x, q.y, q.z);
nuclear@1 308 }
nuclear@1 309
nuclear@1 310 void XFormNode::set_scaling(const Vector3 &pos, long tmsec)
nuclear@1 311 {
nuclear@1 312 anm_set_scaling(anm, v3_cons(pos.x, pos.y, pos.z), ANM_MSEC2TM(tmsec));
nuclear@1 313 }
nuclear@1 314
nuclear@1 315 Vector3 XFormNode::get_node_scaling(long tmsec) const
nuclear@1 316 {
nuclear@1 317 vec3_t s = anm_get_node_scaling(anm, ANM_MSEC2TM(tmsec));
nuclear@1 318 return Vector3(s.x, s.y, s.z);
nuclear@1 319 }
nuclear@1 320
nuclear@1 321 // these take hierarchy into account
nuclear@1 322 Vector3 XFormNode::get_position(long tmsec) const
nuclear@1 323 {
nuclear@1 324 vec3_t v = anm_get_position(anm, ANM_MSEC2TM(tmsec));
nuclear@1 325 return Vector3(v.x, v.y, v.z);
nuclear@1 326 }
nuclear@1 327
nuclear@1 328 Quaternion XFormNode::get_rotation(long tmsec) const
nuclear@1 329 {
nuclear@1 330 quat_t q = anm_get_rotation(anm, tmsec);
nuclear@1 331 return Quaternion(q.w, q.x, q.y, q.z);
nuclear@1 332 }
nuclear@1 333
nuclear@1 334 Vector3 XFormNode::get_scaling(long tmsec) const
nuclear@1 335 {
nuclear@1 336 vec3_t v = anm_get_scaling(anm, ANM_MSEC2TM(tmsec));
nuclear@1 337 return Vector3(v.x, v.y, v.z);
nuclear@1 338 }
nuclear@1 339
nuclear@1 340 void XFormNode::set_pivot(const Vector3 &pivot)
nuclear@1 341 {
nuclear@1 342 anm_set_pivot(anm, v3_cons(pivot.x, pivot.y, pivot.z));
nuclear@1 343 }
nuclear@1 344
nuclear@1 345 Vector3 XFormNode::get_pivot() const
nuclear@1 346 {
nuclear@1 347 vec3_t p = anm_get_pivot(anm);
nuclear@1 348 return Vector3(p.x, p.y, p.z);
nuclear@1 349 }
nuclear@1 350
nuclear@1 351 void XFormNode::set_local_matrix(const Matrix4x4 &mat)
nuclear@1 352 {
nuclear@1 353 local_matrix = mat;
nuclear@1 354 }
nuclear@1 355
nuclear@1 356 const Matrix4x4 &XFormNode::get_local_matrix() const
nuclear@1 357 {
nuclear@1 358 return local_matrix;
nuclear@1 359 }
nuclear@1 360
nuclear@1 361 void XFormNode::set_bone_matrix(const Matrix4x4 &bmat)
nuclear@1 362 {
nuclear@1 363 bone_matrix = bmat;
nuclear@1 364 }
nuclear@1 365
nuclear@1 366 const Matrix4x4 &XFormNode::get_bone_matrix() const
nuclear@1 367 {
nuclear@1 368 return bone_matrix;
nuclear@1 369 }
nuclear@1 370
nuclear@1 371 #define FOO
nuclear@1 372
nuclear@1 373 void XFormNode::get_node_xform(long tmsec, Matrix4x4 *mat, Matrix4x4 *inv_mat) const
nuclear@1 374 {
nuclear@1 375 anm_time_t tm = ANM_MSEC2TM(tmsec);
nuclear@1 376
nuclear@1 377 if(mat) {
nuclear@1 378 anm_get_node_matrix(anm, (scalar_t(*)[4])mat, tm);
nuclear@1 379 #ifdef FOO
nuclear@1 380 *mat = local_matrix * *mat;
nuclear@1 381 #else
nuclear@1 382 *mat = *mat * local_matrix;
nuclear@1 383 #endif
nuclear@1 384 }
nuclear@1 385 if(inv_mat) {
nuclear@1 386 anm_get_inv_matrix(anm, (scalar_t(*)[4])inv_mat, tm);
nuclear@1 387 }
nuclear@1 388 }
nuclear@1 389
nuclear@1 390 void XFormNode::get_xform(long tmsec, Matrix4x4 *mat, Matrix4x4 *inv_mat) const
nuclear@1 391 {
nuclear@1 392 anm_time_t tm = ANM_MSEC2TM(tmsec);
nuclear@1 393
nuclear@1 394 if(mat) {
nuclear@1 395 anm_get_matrix(anm, (scalar_t(*)[4])mat, tm);
nuclear@1 396 #ifdef FOO
nuclear@1 397 *mat = local_matrix * *mat;
nuclear@1 398 #else
nuclear@1 399 *mat = *mat * local_matrix;
nuclear@1 400 #endif
nuclear@1 401 }
nuclear@1 402 if(inv_mat) {
nuclear@1 403 anm_get_inv_matrix(anm, (scalar_t(*)[4])inv_mat, tm);
nuclear@1 404 }
nuclear@1 405 }
nuclear@1 406
nuclear@1 407
nuclear@1 408 // ---- Track ----
nuclear@1 409
nuclear@1 410 Track::Track()
nuclear@1 411 {
nuclear@1 412 trk = new anm_track;
nuclear@1 413 anm_init_track(trk);
nuclear@1 414 }
nuclear@1 415
nuclear@1 416 Track::~Track()
nuclear@1 417 {
nuclear@1 418 anm_destroy_track(trk);
nuclear@1 419 delete trk;
nuclear@1 420 }
nuclear@1 421
nuclear@1 422 Track::Track(const Track &rhs)
nuclear@1 423 {
nuclear@1 424 trk = new anm_track;
nuclear@1 425 anm_init_track(trk);
nuclear@1 426 anm_copy_track(trk, rhs.trk);
nuclear@1 427 interp = rhs.interp;
nuclear@1 428 extrap = rhs.extrap;
nuclear@1 429 }
nuclear@1 430
nuclear@1 431 Track &Track::operator =(const Track &rhs)
nuclear@1 432 {
nuclear@1 433 if(&rhs == this) {
nuclear@1 434 return *this;
nuclear@1 435 }
nuclear@1 436
nuclear@1 437 anm_copy_track(trk, rhs.trk);
nuclear@1 438 interp = rhs.interp;
nuclear@1 439 extrap = rhs.extrap;
nuclear@1 440 return *this;
nuclear@1 441 }
nuclear@1 442
nuclear@1 443
nuclear@1 444 void Track::set_interpolator(Interp in)
nuclear@1 445 {
nuclear@1 446 anm_set_track_interpolator(trk, track_interpolator(in));
nuclear@1 447 interp = in;
nuclear@1 448 }
nuclear@1 449
nuclear@1 450 Interp Track::get_interpolator() const
nuclear@1 451 {
nuclear@1 452 return interp;
nuclear@1 453 }
nuclear@1 454
nuclear@1 455 void Track::set_extrapolator(Extrap ex)
nuclear@1 456 {
nuclear@1 457 anm_set_track_extrapolator(trk, track_extrapolator(ex));
nuclear@1 458 extrap = ex;
nuclear@1 459 }
nuclear@1 460
nuclear@1 461 Extrap Track::get_extrapolator() const
nuclear@1 462 {
nuclear@1 463 return extrap;
nuclear@1 464 }
nuclear@1 465
nuclear@1 466 void Track::set_default(double def)
nuclear@1 467 {
nuclear@1 468 anm_set_track_default(trk, def);
nuclear@1 469 }
nuclear@1 470
nuclear@1 471 void Track::set_value(float val, long tmsec)
nuclear@1 472 {
nuclear@1 473 anm_set_value(trk, ANM_MSEC2TM(tmsec), val);
nuclear@1 474 }
nuclear@1 475
nuclear@1 476 float Track::get_value(long tmsec) const
nuclear@1 477 {
nuclear@1 478 return anm_get_value(trk, ANM_MSEC2TM(tmsec));
nuclear@1 479 }
nuclear@1 480
nuclear@1 481 float Track::operator ()(long tmsec) const
nuclear@1 482 {
nuclear@1 483 return anm_get_value(trk, ANM_MSEC2TM(tmsec));
nuclear@1 484 }
nuclear@1 485
nuclear@1 486
nuclear@1 487 // ---- Track3 ----
nuclear@1 488
nuclear@1 489 void Track3::set_interpolator(Interp in)
nuclear@1 490 {
nuclear@1 491 for(int i=0; i<3; i++) {
nuclear@1 492 track[i].set_interpolator(in);
nuclear@1 493 }
nuclear@1 494 }
nuclear@1 495
nuclear@1 496 Interp Track3::get_interpolator() const
nuclear@1 497 {
nuclear@1 498 return track[0].get_interpolator();
nuclear@1 499 }
nuclear@1 500
nuclear@1 501 void Track3::set_extrapolator(Extrap ex)
nuclear@1 502 {
nuclear@1 503 for(int i=0; i<3; i++) {
nuclear@1 504 track[i].set_extrapolator(ex);
nuclear@1 505 }
nuclear@1 506 }
nuclear@1 507
nuclear@1 508 Extrap Track3::get_extrapolator() const
nuclear@1 509 {
nuclear@1 510 return track[0].get_extrapolator();
nuclear@1 511 }
nuclear@1 512
nuclear@1 513 void Track3::set_default(const Vector3 &def)
nuclear@1 514 {
nuclear@1 515 for(int i=0; i<3; i++) {
nuclear@1 516 track[i].set_default(def[i]);
nuclear@1 517 }
nuclear@1 518 }
nuclear@1 519
nuclear@1 520 void Track3::set_value(const Vector3 &val, long tmsec)
nuclear@1 521 {
nuclear@1 522 for(int i=0; i<3; i++) {
nuclear@1 523 track[i].set_value(val[i], tmsec);
nuclear@1 524 }
nuclear@1 525 }
nuclear@1 526
nuclear@1 527 Vector3 Track3::get_value(long tmsec) const
nuclear@1 528 {
nuclear@1 529 return Vector3(track[0](tmsec), track[1](tmsec), track[2](tmsec));
nuclear@1 530 }
nuclear@1 531
nuclear@1 532 Vector3 Track3::operator ()(long tmsec) const
nuclear@1 533 {
nuclear@1 534 return Vector3(track[0](tmsec), track[1](tmsec), track[2](tmsec));
nuclear@1 535 }
nuclear@1 536
nuclear@1 537
nuclear@1 538 static inline anm_interpolator track_interpolator(Interp in)
nuclear@1 539 {
nuclear@1 540 switch(in) {
nuclear@1 541 case INTERP_STEP:
nuclear@1 542 return ANM_INTERP_STEP;
nuclear@1 543 case INTERP_LINEAR:
nuclear@1 544 return ANM_INTERP_LINEAR;
nuclear@1 545 case INTERP_CUBIC:
nuclear@1 546 return ANM_INTERP_CUBIC;
nuclear@1 547 }
nuclear@1 548
nuclear@1 549 assert(0);
nuclear@1 550 return ANM_INTERP_STEP;
nuclear@1 551 }
nuclear@1 552
nuclear@1 553 static inline anm_extrapolator track_extrapolator(Extrap ex)
nuclear@1 554 {
nuclear@1 555 switch(ex) {
nuclear@1 556 case EXTRAP_EXTEND:
nuclear@1 557 return ANM_EXTRAP_EXTEND;
nuclear@1 558 case EXTRAP_CLAMP:
nuclear@1 559 return ANM_EXTRAP_CLAMP;
nuclear@1 560 case EXTRAP_REPEAT:
nuclear@1 561 return ANM_EXTRAP_REPEAT;
nuclear@1 562 }
nuclear@1 563
nuclear@1 564 assert(0);
nuclear@1 565 return ANM_EXTRAP_EXTEND;
nuclear@1 566 }
nuclear@1 567