This commit is contained in:
aozhiwei 2023-02-06 18:59:49 +08:00
parent 18cfd1aefb
commit 31f4494c1b
2 changed files with 61 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "mt/Param.h"
#include "mt/Map.h"
#include "mt/MapArea.h"
#include "mt/MapCollider.h"
#include "roommgr.h"

View File

@ -0,0 +1,60 @@
#pragma once
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
namespace mt
{
struct Bounds
{
glm::vec3 center = glm::vec3(0.0f, 0.0f, 0.0f);
glm::vec3 size = glm::vec3(0.0f, 0.0f, 0.0f);
};
struct Transform
{
glm::vec3 local_position = glm::vec3(0.0f, 0.0f, 0.0f);
glm::quat local_rotation = glm::quat(0.0f, 0.0f, 0.0f, 0.0f);
glm::vec3 local_scale = glm::vec3(0.0f, 0.0f, 0.0f);
};
struct Mesh
{
std::vector<glm::vec3> vertices;
std::vector<int> triangles;
Bounds bounds;
};
struct Collider
{
bool enabled = false;
bool is_trigge = false;
Bounds bounds;
};
struct MeshCollider : public Collider
{
Mesh mesh;
};
struct BoxCollider : public Collider
{
glm::vec3 center = glm::vec3(0.0f, 0.0f, 0.0f);
glm::vec3 size = glm::vec3(0.0f, 0.0f, 0.0f);
};
struct ColliderNode
{
ColliderNode* parent = nullptr;
std::string name;
std::vector<Collider*> colliders;
std::map<std::string, ColliderNode*> childs;
};
class MapCollider
{
private:
std::map<std::string, ColliderNode*> nodes;
};
}