1#include <game/mLib/m_3d.hpp>
2#include <game/mLib/m_heap.hpp>
6 nw4r::g3d::AnmObjTexPatRes::Construct(
nullptr, &size, anmTexPat, mdl,
false);
13bool m3d::anmTexPat_c::child_c::create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexPat anmTexPat, 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, anmTexPat,
false);
24 if (!createAllocator(allocator, objSize)) {
28 mpObj = nw4r::g3d::AnmObjTexPatRes::Construct(&mAllocator,
nullptr, anmTexPat, mdl,
false);
29 if (!mpObj->Bind(mdl)) {
38void m3d::anmTexPat_c::child_c::setAnm(m3d::bmdl_c &mdl, nw4r::g3d::ResAnmTexPat anmTexPat,
m3d::playMode_e playMode) {
40 mpObj = nw4r::g3d::AnmObjTexPatRes::Construct(&mAllocator,
nullptr, anmTexPat, mdl.getResMdl(),
false);
41 mpObj->Bind(mdl.getResMdl());
42 setFrmCtrlDefault(anmTexPat, playMode);
45void m3d::anmTexPat_c::child_c::releaseAnm() {
46 if (mpObj ==
nullptr) {
54void m3d::anmTexPat_c::child_c::setFrmCtrlDefault(nw4r::g3d::ResAnmTexPat &anmTexPat,
m3d::playMode_e playMode) {
58 fanm_c::set(anmTexPat.getDuration(), playMode, 1.0f, -1.0f);
61size_t m3d::anmTexPat_c::heapCost(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexPat anmTexPat,
long count,
bool calcAligned) {
63 nw4r::g3d::AnmObjTexPatOverride::Construct(
nullptr, &size, mdl, count);
72bool m3d::anmTexPat_c::create(nw4r::g3d::ResMdl mdl, nw4r::g3d::ResAnmTexPat anmTexPat, mAllocator_c *allocator,
size_t *objSize,
long count) {
73 if (allocator ==
nullptr) {
74 allocator = m3d::internal::l_allocator_p;
78 if (objSize ==
nullptr) {
82 *objSize = heapCost(mdl, anmTexPat, count,
false);
83 if (!createAllocator(allocator, objSize)) {
87 mpObj = nw4r::g3d::AnmObjTexPatOverride::Construct(&mAllocator,
nullptr, mdl, count);
88 children = (m3d::anmTexPat_c::child_c *) MEMAllocFromAllocator(&mAllocator,
nw4r::ut::RoundUp(count *
sizeof(
child_c), 0x20));
90 nw4r::g3d::AnmObjTexPatOverride *texPatOverride = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexPatOverride>(mpObj);
93 for (
int i = 0; i < count; i++) {
95 if (!child->create(mdl, anmTexPat, &mAllocator,
nullptr)) {
96 mHeap::destroyFrmHeap(mpHeap);
100 nw4r::g3d::AnmObjTexPatRes *texPatRes = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexPatRes>(child->getObj());
101 texPatOverride->Attach(i, texPatRes);
110m3d::anmTexPat_c::~anmTexPat_c() {
111 anmTexPat_c::remove();
114void m3d::anmTexPat_c::remove() {
115 nw4r::g3d::AnmObjTexPatOverride *texPat = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexPatOverride>(mpObj);
116 if (texPat !=
nullptr && children !=
nullptr) {
117 int count = texPat->getCount();
118 for (
int i = 0; i < count; i++) {
119 children[i].remove();
126void m3d::anmTexPat_c::setAnm(m3d::bmdl_c &mdl, nw4r::g3d::ResAnmTexPat anmTexPat,
long idx,
m3d::playMode_e playMode) {
127 nw4r::g3d::AnmObjTexPatOverride *texPat = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexPatOverride>(mpObj);
129 children[idx].setAnm(mdl, anmTexPat, playMode);
130 nw4r::g3d::AnmObjTexPatRes *texPatRes = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexPatRes>(children[idx].getObj());
131 texPat->Attach(idx, texPatRes);
134void m3d::anmTexPat_c::releaseAnm(
long idx) {
135 nw4r::g3d::AnmObjTexPatOverride *texPat = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexPatOverride>(mpObj);
137 children[idx].releaseAnm();
140void m3d::anmTexPat_c::play() {
141 nw4r::g3d::AnmObjTexPatOverride *texPat = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::AnmObjTexPatOverride>(mpObj);
142 int count = texPat->getCount();
143 for (
int i = 0; i < count; i++) {
148void m3d::anmTexPat_c::play(
long idx) {
149 if (children[idx].IsBound()) {
150 children[idx].play();
154float m3d::anmTexPat_c::getFrame(
long idx)
const {
155 return children[idx].getFrame();
158void m3d::anmTexPat_c::setFrame(
float frame,
long idx) {
159 children[idx].setFrame(frame);
162float m3d::anmTexPat_c::getRate(
long idx)
const {
163 return children[idx].getRate();
166void m3d::anmTexPat_c::setRate(
float rate,
long idx) {
167 children[idx].setRate(rate);
170bool m3d::anmTexPat_c::isStop(
long idx)
const {
171 return children[idx].isStop();
174bool m3d::anmTexPat_c::checkFrame(
float frame,
long idx)
const {
175 return children[idx].checkFrame(frame);
179 children[idx].mPlayMode = mode;
182float m3d::anmTexPat_c::getFrameMax(
long idx)
const {
183 return children[idx].mFrameMax;
@ 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.