1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: anim_AnimFrameController.cpp
4
5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain proprietary
8 information of Nintendo and/or its licensed developers and are protected by
9 national and international copyright laws. They may not be disclosed to third
10 parties or copied or duplicated in any form, in whole or in part, without the
11 prior written consent of Nintendo.
12
13 The content herein is highly confidential and should be handled accordingly.
14
15 $Revision: 31311 $
16 *---------------------------------------------------------------------------*/
17
18 #include "precompiled.h"
19
20 #include <nw/math.h>
21 #include <nw/anim/anim_AnimFrameController.h>
22
23 using namespace nw::math;
24
25 namespace nw {
26 namespace anim {
27
28 //----------------------------------------------------------
PlayPolicy_Onetime(f32 startFrame,f32 endFrame,f32 inputFrame,void *)29 f32 PlayPolicy_Onetime(f32 startFrame, f32 endFrame, f32 inputFrame, void* /*pUserData*/)
30 {
31 // 再生方向終端時間で停止。
32 if (inputFrame > endFrame)
33 {
34 return endFrame;
35 }
36
37 // 再生方向終端時間で停止。
38 if (inputFrame < startFrame)
39 {
40 return startFrame;
41 }
42
43 return inputFrame;
44 }
45
46 //----------------------------------------------------------
PlayPolicy_Loop(f32 startFrame,f32 endFrame,f32 inputFrame,void *)47 f32 PlayPolicy_Loop(f32 startFrame, f32 endFrame, f32 inputFrame, void* /*pUserData*/)
48 {
49 NW_ASSERT(startFrame <= endFrame);
50 f32 length = endFrame - startFrame;
51 if (length == 0.0f)
52 {
53 return startFrame;
54 }
55 else
56 {
57 f32 offset = inputFrame - startFrame;
58 if (offset < 0.0f)
59 {
60 offset += (FFloor(-offset / length) + 1) * length;
61 }
62 return FMod(offset, length) + startFrame;
63 }
64 }
65
66 } /* namespace anim */
67 } /* namespace nw */
68
69