mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
- Introduce HitboxID, EntityID, and ModelID types for safer ID-based lookups - Replace AABB struct with Hitbox (includes HitboxID) - Convert ModelManager and HitboxManager to singletons with Handle structs - Update Entity to store IDs for model and hitbox, removing direct references - Reorganize creature model assets into subdirectories per entity type - Add player model (player.glb) and collision data for pig - Remove ModelManager dependency from App and Renderer - Add namespace parsing utility for asset paths - Mark sparse_vector::insert() with [[nodiscard]]
26 lines
689 B
C++
26 lines
689 B
C++
#pragma once
|
|
#include <glm/glm.hpp>
|
|
|
|
namespace Cubed {
|
|
|
|
using HitboxID = uint32_t;
|
|
|
|
struct Hitbox {
|
|
glm::vec3 center{0.0f};
|
|
glm::vec3 half{0.0f};
|
|
|
|
Hitbox(glm::vec3 center_point, glm::vec3 half_size)
|
|
: center(center_point), half(half_size) {}
|
|
|
|
glm::vec3 min() const { return center - half; }
|
|
|
|
glm::vec3 max() const { return center + half; }
|
|
|
|
bool intersects(const Hitbox& other) const {
|
|
return (glm::abs(center.x - other.center.x) <= half.x + other.half.x) &&
|
|
(glm::abs(center.y - other.center.y) <= half.y + other.half.y) &&
|
|
(glm::abs(center.z - other.center.z) <= half.z + other.half.z);
|
|
}
|
|
};
|
|
|
|
} // namespace Cubed
|