Minor refactorings
All checks were successful
Build and Publish WASM version of demo / Build-And-Deploy (push) Successful in 17s

This commit is contained in:
Stephen Seo 2023-08-11 14:20:35 +09:00
parent 46e7bcd595
commit b0d50c6589

View file

@ -35,9 +35,9 @@ class Walker {
Walker(float x, float z, bool auto_roaming, float body_height = 2.0F, Walker(float x, float z, bool auto_roaming, float body_height = 2.0F,
float body_feet_radius = 1.7F, float feet_radius = 1.5F); float body_feet_radius = 1.7F, float feet_radius = 1.5F);
template <typename TBBS> template <typename BBCountT, BBCountT BBCount>
void update(float dt, const TBBS &bbs, unsigned int width, void update(float dt, const std::array<BoundingBox, BBCount> &bbs,
unsigned int height); unsigned int width, unsigned int height);
void draw(const Model &model); void draw(const Model &model);
@ -76,9 +76,9 @@ class Walker {
float roaming_timer; float roaming_timer;
}; };
template <typename TBBS> template <typename BBCountT, BBCountT BBCount>
void Walker::update(float dt, const TBBS &bbs, unsigned int width, void Walker::update(float dt, const std::array<BoundingBox, BBCount> &bbs,
unsigned int height) { unsigned int width, unsigned int height) {
if ((flags & 4) != 0 && (flags & 3) == 0) { if ((flags & 4) != 0 && (flags & 3) == 0) {
roaming_timer += dt; roaming_timer += dt;
if (roaming_timer > roaming_time) { if (roaming_timer > roaming_time) {
@ -223,6 +223,7 @@ void Walker::update(float dt, const TBBS &bbs, unsigned int width,
for (const auto &bb : bbs) { for (const auto &bb : bbs) {
if (GetRayCollisionBox(downwards, bb).hit) { if (GetRayCollisionBox(downwards, bb).hit) {
leg_target.y = (bb.min.y + bb.max.y) / 2.0F; leg_target.y = (bb.min.y + bb.max.y) / 2.0F;
break;
} }
} }
} }