1#include <game/mLib/m_3d.hpp>
2#include <game/mLib/m_heap.hpp>
6 nw4r::g3d::AnmObjTexSrtRes::Construct(
nullptr, &size, anmTexSrt, mdl,
false);
13bool m3d::anmTexSrt_c::child_c::create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexSrt anmTexSrt, mAllocator_c *allocator,
size_t *objSize) {
14 if (allocator ==
nullptr) {
15 allocator = m3d::internal::l_allocator_p;
19 if (objSize ==
nullptr) {
23 *objSize = heapCost(mdl, anmTexSrt,
false);
24 if (!createAllocator(allocator, objSize)) {
28 mpObj = nw4r::g3d::AnmObjTexSrtRes::Construct(&mAllocator,
nullptr, anmTexSrt, mdl,
false);
29 if (mpObj ==
nullptr) {
33 if (!mpObj->Bind(mdl)) {
42void m3d::anmTexSrt_c::child_c::setAnm(m3d::bmdl_c &mdl, nw4r::g3d::ResAnmTexSrt anmTexSrt,
m3d::playMode_e playMode) {
44 mpObj = nw4r::g3d::AnmObjTexSrtRes::Construct(&mAllocator,
nullptr, anmTexSrt, mdl.getResMdl(),
false);
45 mpObj->Bind(mdl.getResMdl());
46 setFrmCtrlDefault(anmTexSrt, playMode);
49void m3d::anmTexSrt_c::child_c::releaseAnm() {
50 if (mpObj ==
nullptr) {
58void m3d::anmTexSrt_c::child_c::setFrmCtrlDefault(nw4r::g3d::ResAnmTexSrt &anmTexSrt,
m3d::playMode_e playMode) {
62 fanm_c::set(anmTexSrt.getDuration(), playMode, 1.0f, -1.0f);
65size_t m3d::anmTexSrt_c::heapCost(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexSrt anmTexSrt,
long count,
bool calcAligned) {
67 nw4r::g3d::AnmObjTexSrtOverride::Construct(
nullptr, &size, mdl, count);
76bool m3d::anmTexSrt_c::create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexSrt anmTexSrt, mAllocator_c *allocator,
size_t *objSize,
long count) {
77 if (allocator ==
nullptr) {
78 allocator = m3d::internal::l_allocator_p;
82 if (objSize ==
nullptr) {
86 *objSize = heapCost(mdl, anmTexSrt, count,
false);
87 if (!createAllocator(allocator, objSize)) {
91 mpObj = nw4r::g3d::AnmObjTexSrtOverride::Construct(&mAllocator,
nullptr, mdl, count);
92 if (mpObj ==
nullptr) {
96 children = (m3d::anmTexSrt_c::child_c *) MEMAllocFromAllocator(&mAllocator,
nw4r::ut::RoundUp(count *
sizeof(
child_c), 0x20));
97 if (children ==
nullptr) {
102 nw4r::g3d::AnmObjTexSrtOverride *texSrtOverride = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexSrtOverride>(mpObj);
105 for (
int i = 0; i < count; i++) {
107 if (!child->create(mdl, anmTexSrt, &mAllocator,
nullptr)) {
108 mHeap::destroyFrmHeap(mpHeap);
109 EGG::Heap::free(mpHeap,
nullptr);
113 nw4r::g3d::AnmObjTexSrtRes *texSrtRes = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexSrtRes>(child->getObj());
114 texSrtOverride->Attach(i, texSrtRes);
123m3d::anmTexSrt_c::~anmTexSrt_c() {
124 anmTexSrt_c::remove();
127void m3d::anmTexSrt_c::remove() {
128 nw4r::g3d::AnmObjTexSrtOverride *texSrt = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexSrtOverride>(mpObj);
129 if (texSrt !=
nullptr && children !=
nullptr) {
130 int count = texSrt->getCount();
131 for (
int i = 0; i < count; i++) {
132 children[i].remove();
139void m3d::anmTexSrt_c::setAnm(m3d::bmdl_c &mdl, nw4r::g3d::ResAnmTexSrt anmTexSrt,
long idx,
m3d::playMode_e playMode) {
140 nw4r::g3d::AnmObjTexSrtOverride *texSrt = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexSrtOverride>(mpObj);
142 children[idx].setAnm(mdl, anmTexSrt, playMode);
143 nw4r::g3d::AnmObjTexSrtRes *texSrtRes = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexSrtRes>(children[idx].getObj());
144 texSrt->Attach(idx, texSrtRes);
147void m3d::anmTexSrt_c::releaseAnm(
long idx) {
148 nw4r::g3d::AnmObjTexSrtOverride *texSrt = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexSrtOverride>(mpObj);
150 children[idx].releaseAnm();
153void m3d::anmTexSrt_c::play() {
154 nw4r::g3d::AnmObjTexSrtOverride *texSrt = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexSrtOverride>(mpObj);
155 int count = texSrt->getCount();
156 for (
int i = 0; i < count; i++) {
161void m3d::anmTexSrt_c::play(
long idx) {
162 if (children[idx].IsBound()) {
163 children[idx].play();
167float m3d::anmTexSrt_c::getFrame(
long idx)
const {
168 return children[idx].getFrame();
171void m3d::anmTexSrt_c::setFrame(
float frame,
long idx) {
172 children[idx].setFrame(frame);
175float m3d::anmTexSrt_c::getRate(
long idx)
const {
176 return children[idx].getRate();
179void m3d::anmTexSrt_c::setRate(
float rate,
long idx) {
180 children[idx].setRate(rate);
183bool m3d::anmTexSrt_c::isStop(
long idx)
const {
184 return children[idx].isStop();
188 children[idx].mPlayMode = mode;
191float m3d::anmTexSrt_c::getFrameMax(
long idx)
const {
192 return children[idx].mFrameMax;
195void m3d::anmTexSrt_c::setFrameStart(
float frame,
long idx) {
196 children[idx].mFrameStart = frame;
@ MEM_FRMHEAP_FREE_ALL
Deallocates all memory blocks from the heap.
void set(float duration, m3d::playMode_e playMode, float updateRate, float startFrame)
Starts the animation with the given parameters.
@ FORWARD_ONCE
Play the animation forward once.
@ FORWARD_LOOP
Play the animation forward in a loop.
@ PLAYMODE_INHERIT
Use the play mode of the parent.
T RoundUp(T x, u32 base)
Rounds x up to a multiple of base.