-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBoxColliderComponent.h
More file actions
197 lines (159 loc) · 5.29 KB
/
Copy pathBoxColliderComponent.h
File metadata and controls
197 lines (159 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#pragma once
#include "Component.h"
#include "Scene.h"
#include "SceneManager.h"
#include "../physics/PhysicsCommon.h"
#include "../Physics/ICollider.h"
class BoxColliderComponent : public meta::identity<BoxColliderComponent, Component>, public ICollider
{
public:
// CT4 파일럿: generated.h + Serializable/Property 어노테이션을 P2996 유사
// 매크로 프리 표기로 대체. 멤버 순서 = 구 generated.h(골든 diff 0의 전제).
// 주의: 주석에도 이중 대괄호 어노테이션 원문을 쓰지 말 것 — 생성기가
// regex_search로 줄을 훑는다.
// 마찰·반발 계수의 range는 속성 표기의 살아있는 예시다 — 어댑터는
// 무시하고(골든 무영향), CT6 인스펙터가 슬라이더 한계로 소비한다.
static consteval auto reflect()
{
return meta::schema<Self>(
meta::field<&Self::m_boxExtent>,
meta::field<&Self::m_posOffset>,
meta::field<&Self::m_rotOffset>,
meta::field<&Self::staticFriction>.with(
meta::range(0.0f, 1.0f)),
meta::field<&Self::dynamicFriction>.with(
meta::range(0.0f, 1.0f)),
meta::field<&Self::restitution>.with(
meta::range(0.0f, 1.0f)),
meta::field<&Self::density>);
}
public:
BoxColliderComponent()
{
m_Info.boxExtent = { 1.0f, 1.0f, 1.0f };
m_boxExtent = m_Info.boxExtent;
m_type = EColliderType::COLLISION; // �⺻�� ����
}
virtual ~BoxColliderComponent() = default;
void OnInitialized() override
{
auto scene = GetOwner()->m_ownerScene;
if (scene)
{
if (m_boxExtent != math::vector3{})
{
m_Info.boxExtent = { m_boxExtent.x, m_boxExtent.y, m_boxExtent.z };
}
else {
m_Info.boxExtent = { 0.001f, 0.001f ,0.001f };
}
scene->CollectColliderComponent(this);
}
}
void OnUninitializing() override
{
auto scene = GetOwner()->m_ownerScene;
if (scene)
{
scene->UnCollectColliderComponent(this);
}
}
math::vector3 m_boxExtent{ 1.0f, 1.0f, 1.0f };
math::vector3 m_posOffset{};
math::quaternion m_rotOffset{};
float staticFriction = 0.5f; //���� ��ü ���� ���
float dynamicFriction = 0.4f; //���� ��ü ���� ���
float restitution = 0.3f; //� ���
float density = 10.0f; //�е�
math::vector3 GetExtents()
{
if (m_boxExtent != math::vector3{})
{
m_Info.boxExtent = { m_boxExtent.x, m_boxExtent.y, m_boxExtent.z };
}
return m_Info.boxExtent;
}
void SetExtents(const math::vector3& extents)
{
m_Info.boxExtent = extents;
m_boxExtent = m_Info.boxExtent;
}
EColliderType GetColliderType() const override
{
return m_type;
}
void SetColliderType(EColliderType type) override
{
m_type = type;
}
BoxColliderInfo GetBoxInfo()
{
if (m_boxExtent != math::vector3{})
{
m_Info.boxExtent = { m_boxExtent.x, m_boxExtent.y, m_boxExtent.z };
}
else {
m_Info.boxExtent = { 0.001f, 0.001f ,0.001f };
}
// �ӽ� �ݸ��� ���̾�
m_Info.colliderInfo.layerNumber = GetOwner()->m_collisionType;
m_Info.colliderInfo.staticFriction = staticFriction;
m_Info.colliderInfo.dynamicFriction = dynamicFriction;
m_Info.colliderInfo.restitution = restitution;
m_Info.colliderInfo.density = density;
return m_Info;
}
void SetBoxInfoMation(const BoxColliderInfo& info)
{
m_Info = info;
m_boxExtent = m_Info.boxExtent;
}
float GetStaticFriction() const
{
return m_Info.colliderInfo.staticFriction;
}
void SetStaticFriction(float staticFriction)
{
m_Info.colliderInfo.staticFriction = staticFriction;
}
float GetDynamicFriction() const
{
return m_Info.colliderInfo.dynamicFriction;
}
void SetDynamicFriction(float dynamicFriction)
{
m_Info.colliderInfo.dynamicFriction = dynamicFriction;
}
float GetRestitution() const
{
return m_Info.colliderInfo.restitution;
}
void SetRestitution(float restitution)
{
m_Info.colliderInfo.restitution = restitution;
}
float GetDensity() const
{
return m_Info.colliderInfo.density;
}
void SetDensity(float density)
{
m_Info.colliderInfo.density = density;
}
//=========================================================
// ICollider��(��) ���� ��ӵ�
void SetPositionOffset(math::vector3 pos) override;
math::vector3 GetPositionOffset() override;
void SetRotationOffset(math::quaternion rotation) override;
math::quaternion GetRotationOffset() override;
BoxColliderInfo m_Info;
private:
void OnTriggerEnter(ICollider* other) override;
void OnTriggerStay(ICollider* other) override;
void OnTriggerExit(ICollider* other) override;
void OnCollisionEnter(ICollider* other) override;
void OnCollisionStay(ICollider* other) override;
void OnCollisionExit(ICollider* other) override;
EColliderType m_type;
unsigned int m_collsionCount = 0;
};