Given a texture handle, returns that textures bitmap If the texture is animated, returns framenum mod num_of_frames in the animation Force is to force the evaluation of a procedural Also figures in gametime
| 469 | // Force is to force the evaluation of a procedural |
| 470 | // Also figures in gametime |
| 471 | int GetTextureBitmap(int handle, int framenum, bool force) { |
| 472 | int src_bitmap; |
| 473 | |
| 474 | if (!GameTextures[handle].used) |
| 475 | return 0; |
| 476 | |
| 477 | if (GameTextures[handle].flags & TF_ANIMATED) { |
| 478 | float cur_frametime; |
| 479 | int int_frame; |
| 480 | texture *tex = &GameTextures[handle]; |
| 481 | PageInVClip(GameTextures[handle].bm_handle); |
| 482 | |
| 483 | vclip *vc = &GameVClips[GameTextures[handle].bm_handle]; |
| 484 | ASSERT(vc->used >= 1); |
| 485 | |
| 486 | if (GameTextures[handle].flags & TF_PING_PONG) { |
| 487 | // Ping pong this texture |
| 488 | |
| 489 | float frametime = tex->speed / vc->num_frames; |
| 490 | cur_frametime = Gametime / frametime; |
| 491 | int_frame = cur_frametime; |
| 492 | int_frame += framenum; |
| 493 | |
| 494 | int_frame %= (vc->num_frames * 2); |
| 495 | if (int_frame >= vc->num_frames) |
| 496 | int_frame = (vc->num_frames - 1) - (int_frame % vc->num_frames); |
| 497 | else |
| 498 | int_frame %= vc->num_frames; |
| 499 | src_bitmap = vc->frames[int_frame]; |
| 500 | } else { |
| 501 | float frametime = tex->speed / vc->num_frames; |
| 502 | cur_frametime = Gametime / frametime; |
| 503 | int_frame = cur_frametime; |
| 504 | int_frame += framenum; |
| 505 | src_bitmap = vc->frames[int_frame % vc->num_frames]; |
| 506 | } |
| 507 | } else { |
| 508 | src_bitmap = GameTextures[handle].bm_handle; |
| 509 | } |
| 510 | |
| 511 | if (GameTextures[handle].flags & TF_PROCEDURAL) // Do a procedural |
| 512 | { |
| 513 | int do_eval = 1; |
| 514 | |
| 515 | if (GameTextures[handle].procedural == NULL) |
| 516 | AllocateProceduralForTexture(handle); |
| 517 | |
| 518 | if (GameTextures[handle].procedural->last_procedural_frame == FrameCount) |
| 519 | do_eval = 0; |
| 520 | if (timer_GetTime() < |
| 521 | GameTextures[handle].procedural->last_evaluation_time + GameTextures[handle].procedural->evaluation_time) |
| 522 | do_eval = 0; |
| 523 | |
| 524 | if (!force && !Detail_settings.Procedurals_enabled) { |
| 525 | if (timer_GetTime() < GameTextures[handle].procedural->last_evaluation_time + 10.0) |
| 526 | do_eval = 0; |
| 527 | } |
| 528 |
no test coverage detected