OROCHI
 
Loading...
Searching...
No Matches
GxBackgroundHit.h
Go to the documentation of this file.
1//===========================================================================
12//===========================================================================
13#pragma once
14
16
17#define USE_OBJ_ADJUST 1 // ver-2.9.0削除予定
18
19//===========================================================================
21//===========================================================================
23{
24 //-------------------------------------------------------------
26 //-------------------------------------------------------------
28public:
29 // RTTI定義
30 GX_RTTI_CLASS( GxBackgroundHit, GxAdjustHit )
31 // ClassBaseReference継承クラス用禁止宣言
33
34
35 static const GxColor COLOR_OBJECT;
36
37 class GxWorld;
38 class GxObject;
39
41 struct GxRayCallback;
42 struct GxConvexCallback;
43
44protected:
47 {
48 ON,
49 END,
50 OLD_POS,
53 };
54
56 //-------------------------------------------------------------
58 //-------------------------------------------------------------
60public:
62 GxBackgroundHit(void);
63
65 ~GxBackgroundHit(void) override;
66
68 //-----------------------------------------------------------
70 //-----------------------------------------------------------
72
74 GxCollision::GxObject* allocObject(void) override;
75
77 GxObject* getObject(u32 index);
78
80 void checkOldPosition( GxRayResult& result, const GxVector3& moveVector, const GxVector3& offset, GxCollision::GxConditionInformation* pCondition = nullptr ) override;
81
83 const GxVector3& calculateAdjustVector( void ) override;
84
86 void update(void) override;
87
89 void executePostCheckCallback(void) override;
90
91#if GX_DEVELOP
93 void developDrawObject(const GxColor& color = GxColor::WHITE, PRIMITIVE_FILL_MODE fillMode = PRIMITIVE_FILL_MODE::WIRE) override;
94
96 GX_FORCE_INLINE static void setDevelopDrawBackgroundHitObject(b32 display) { getGxSysMain()->setDevelopFlag(DEVELOP_FLAG_COLLISION_DRAW_BACKGROUND_HIT_OBJECT, display); }
98 GX_FORCE_INLINE static void setDevelopDrawBackgroundHitMesh(b32 display) { getGxSysMain()->setDevelopFlag(DEVELOP_FLAG_COLLISION_DRAW_BACKGROUND_HIT_MESH, display); }
99
101 GX_FORCE_INLINE static b32 getDevelopDrawBackgroundHitObject(void) { return getGxSysMain()->isOnDevelopFlag(DEVELOP_FLAG_COLLISION_DRAW_BACKGROUND_HIT_OBJECT); }
103 GX_FORCE_INLINE static b32 getDevelopDrawBackgroundHitMesh(void) { return getGxSysMain()->isOnDevelopFlag(DEVELOP_FLAG_COLLISION_DRAW_BACKGROUND_HIT_MESH); }
104#endif // GX_DEVELOP
105
107 //-----------------------------------------------------------
109 //-----------------------------------------------------------
111
113 GX_FORCE_INLINE void addObjectHitAdjust( const GxVector3& adjust ) { _isAdjustedObjectHit = true; _objectHitAdjust += adjust; }
115 GX_FORCE_INLINE const GxVector3& getObjectHitAdjust( void ) const { return _objectHitAdjust; }
117 GX_FORCE_INLINE void resetObjectHitAdjust( void ) { _isAdjustedObjectHit = false; _objectHitAdjust = GxVector3::ZERO; }
119 GX_FORCE_INLINE b32 isAdjustedObjectHit( void ) const { return _isAdjustedObjectHit; }
120
122 //-----------------------------------------------------------
124 //-----------------------------------------------------------
126protected:
128 GX_FORCE_INLINE void getPropertyCheckMargin(void* const pValue) const { *static_cast<f32*>(pValue) = _checkMargin; }
130 GX_FORCE_INLINE void setPropertyCheckMargin(const void* const pValue) { _checkMargin = *static_cast<f32*>(const_cast<void*>(pValue)); }
131
133 //-----------------------------------------------------------
135 //-----------------------------------------------------------
137private:
138 GxFlag32Index<ADJUST_FLAG_INDEX> _backgroundHitFlag;
139
140 GxVector3 _objectHitAdjust;
141 b32 _isAdjustedObjectHit;
142
144};
145
146//===========================================================================
148//===========================================================================
150{
151 //-------------------------------------------------------------
153 //-------------------------------------------------------------
155public:
156 // RTTI定義
158 // ClassBaseReference継承クラス用禁止宣言
160
161
162 //-----------------------------------------------------------
164 //-----------------------------------------------------------
166
168 GxWorld(void);
169
171 ~GxWorld( void ) override;
172
174 //-----------------------------------------------------------
176 //-----------------------------------------------------------
178
180 void postCheck( void ) override;
181
186 GxCollision::GxRayCallback* createRayCallback( const btVector3& rayFrom, const btVector3& rayEnd, GxConditionInformation* pConditionInfo ) override;
187
189 b32 checkRayClosestVsTrimesh( GxCollision::GxRayResult& rayResult, const GxVector3& startPosition, const GxVector3& endPosition, GxConditionInformationBackgroundHit* pConditionInfo = nullptr );
190
195 GxCollision::GxConvexCallback* createConvexCallback( const btVector3& checkFrom, const btVector3& checkEnd, GxConditionInformation* pConditionInfo ) override;
196
198 b32 checkCapsuleClosestVsTrimesh( GxCollision::GxRayResult& rayResult, const GxVector3& startPosition, const GxVector3& endPosition, f32 radius, GxConditionInformationBackgroundHit* pConditionInfo = nullptr );
199
200protected:
202 f32 calculateAdjustRate( GxAdjustHit::GxObject* pObjectA, GxAdjustHit::GxObject* pObjectB) override;
203
205};
206
207//===========================================================================
209//===========================================================================
211{
212 //-------------------------------------------------------------
214 //-------------------------------------------------------------
216public:
217 // RTTI定義
219 // ClassBaseReference継承クラス用禁止宣言
221
222
226 enum class TYPE
227 {
228 KINEMATIC,
229 STATIC,
230 ERROR_,
231 MAX,
232 };
233#if GX_DEVELOP
235 GX_ENUM_TABLE_MAX(TYPE)
236#endif //GX_DEVELOP
237
242 enum GROUP
243 {
244 GROUP_OBJECT = (0x01 << 0),
245 GROUP_BACKGROUND = (0x01 << 1),
246 };
247
249 //-----------------------------------------------------------
251 //-----------------------------------------------------------
253
255 GxObject(void);
256
258 ~GxObject(void) override;
259
261 //-----------------------------------------------------------
263 //-----------------------------------------------------------
265
267 constexpr TYPE getType(void) const { return _type; }
268
274 void setType(TYPE type);
275
277 //-----------------------------------------------------------
279 //-----------------------------------------------------------
281#if GX_DEVELOP
283 static GxGuiBase* createGui(GxProperty& property, GxTypedObject* pOwner, const GxRtti& rtti, u32 index = 0);
284#endif // GX_DEVELOP
285
286protected:
288 GxVector3 checkOldPositionMultisphere(const GxVector3& adjustVector, const GxVector3& moveVector);
290 GxVector3 checkOldPositionCapsule(const GxVector3& adjustVector, const GxVector3& moveVector);
291
293 //-----------------------------------------------------------
295 //-----------------------------------------------------------
297private:
299 TYPE _type;
300
302};
303
304//===========================================================================
306//===========================================================================
308{
309 //-------------------------------------------------------------
311 //-------------------------------------------------------------
313public:
314 // RTTI定義
316
317
318 //-----------------------------------------------------------
320 //-----------------------------------------------------------
322
325
328 {
329 *static_cast<GxConditionInformation*>(this) = rhs;
330 return *this;
331 }
332
334 //-----------------------------------------------------------
336 //-----------------------------------------------------------
338
340
342};
343
344//===========================================================================
349//===========================================================================
351{
352 //-------------------------------------------------------------
354 //-------------------------------------------------------------
356public:
358 GxRayCallback( const btVector3& rayFromWorld,const btVector3& rayToWorld, GxConditionInformation* pConditionInfo )
359 : GxCollision::GxRayCallback( rayFromWorld, rayToWorld, pConditionInfo )
360 {}
361
363 //-----------------------------------------------------------
365 //-----------------------------------------------------------
367
373 bool needsCollision(btBroadphaseProxy* pProxy) const override;
374
376};
377
378//===========================================================================
383//===========================================================================
385{
386 //-------------------------------------------------------------
388 //-------------------------------------------------------------
390public:
392 GxConvexCallback( const btVector3& rayFromWorld,const btVector3& rayToWorld, GxConditionInformation* pConditionInfo )
393 : GxCollision::GxConvexCallback( rayFromWorld, rayToWorld, pConditionInfo )
394 {}
395
397 //-----------------------------------------------------------
399 //-----------------------------------------------------------
401
407 bool needsCollision(btBroadphaseProxy* pProxy) const override;
408
410};
411
412GX_PHYSICS_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
void GxTypedObject
その他
Definition GxDefine.h:213
#define GX_PHYSICS_NAMESPACE_BEGIN()
ネームスペースマクロ
Definition GxPhysics.h:28
PRIMITIVE_FILL_MODE
塗りつぶしモード
Definition GxPrimitive.h:31
@ WIRE
ワイヤーフレーム
背景あたりオブジェクトクラス
Definition GxAdjustHit.h:266
背景あたりワールドクラス
Definition GxAdjustHit.h:170
補正あたりクラス
Definition GxAdjustHit.h:18
static f32 _checkMargin
判定用マージン
Definition GxAdjustHit.h:156
判定条件
Definition GxBackgroundHit.h:308
GxObject::TYPE _type
チェックするオブジェクトのタイプ
Definition GxBackgroundHit.h:339
const GxConditionInformationBackgroundHit & operator=(const GxConditionInformation &rhs)
代入
Definition GxBackgroundHit.h:327
背景あたりオブジェクトクラス
Definition GxBackgroundHit.h:211
GxVector3 checkOldPositionMultisphere(const GxVector3 &adjustVector, const GxVector3 &moveVector)
マルチ球の専用追加補正処理
GROUP
Definition GxBackgroundHit.h:243
@ GROUP_OBJECT
オブジェクト側のあたり
Definition GxBackgroundHit.h:244
@ GROUP_BACKGROUND
背景側のあたり
Definition GxBackgroundHit.h:245
GxVector3 checkOldPositionCapsule(const GxVector3 &adjustVector, const GxVector3 &moveVector)
カプセルの専用追加補正処理
TYPE
Definition GxBackgroundHit.h:227
@ KINEMATIC
オブジェクト側の当たり
@ STATIC
背景側の当たり
~GxObject(void) override
デストラクタ
Definition GxBackgroundHit.cpp:343
GxObject(void)
デフォルトコンストラクタ
Definition GxBackgroundHit.cpp:335
constexpr TYPE getType(void) const
タイプの取得
Definition GxBackgroundHit.h:267
void setType(TYPE type)
Definition GxBackgroundHit.cpp:353
背景あたりワールドクラス
Definition GxBackgroundHit.h:150
~GxWorld(void) override
解放
Definition GxBackgroundHit.cpp:200
GxCollision::GxRayCallback * createRayCallback(const btVector3 &rayFrom, const btVector3 &rayEnd, GxConditionInformation *pConditionInfo) override
Definition GxBackgroundHit.cpp:226
b32 checkRayClosestVsTrimesh(GxCollision::GxRayResult &rayResult, const GxVector3 &startPosition, const GxVector3 &endPosition, GxConditionInformationBackgroundHit *pConditionInfo=nullptr)
登録されている全メッシュ形状とのレイチェック(最も近い交差点)
Definition GxBackgroundHit.cpp:239
GxWorld(void)
デフォルトコンストラクタ
Definition GxBackgroundHit.cpp:190
GxCollision::GxConvexCallback * createConvexCallback(const btVector3 &checkFrom, const btVector3 &checkEnd, GxConditionInformation *pConditionInfo) override
Definition GxBackgroundHit.cpp:262
f32 calculateAdjustRate(GxAdjustHit::GxObject *pObjectA, GxAdjustHit::GxObject *pObjectB) override
補正割合の計算
Definition GxBackgroundHit.cpp:296
void postCheck(void) override
check後処理
Definition GxBackgroundHit.cpp:207
b32 checkCapsuleClosestVsTrimesh(GxCollision::GxRayResult &rayResult, const GxVector3 &startPosition, const GxVector3 &endPosition, f32 radius, GxConditionInformationBackgroundHit *pConditionInfo=nullptr)
登録されている全メッシュ形状とのカプセルチェック(最も近い交差点)
Definition GxBackgroundHit.cpp:276
背景あたりクラス
Definition GxBackgroundHit.h:23
void checkOldPosition(GxRayResult &result, const GxVector3 &moveVector, const GxVector3 &offset, GxCollision::GxConditionInformation *pCondition=nullptr) override
現在位置と前回位置の貫通チェック
Definition GxBackgroundHit.cpp:71
GX_FORCE_INLINE void getPropertyCheckMargin(void *const pValue) const
当たり判定マージン取得
Definition GxBackgroundHit.h:128
GxBackgroundHit(void)
デフォルトコンストラクタ
Definition GxBackgroundHit.cpp:31
GX_FORCE_INLINE void setPropertyCheckMargin(const void *const pValue)
当たり判定マージン設定
Definition GxBackgroundHit.h:130
void executePostCheckCallback(void) override
チェック後コールバック関数の呼び出し
Definition GxBackgroundHit.cpp:128
GxObject * getObject(u32 index)
指定インデックスのオブジェクトを取得
Definition GxBackgroundHit.cpp:59
GX_FORCE_INLINE const GxVector3 & getObjectHitAdjust(void) const
オブジェクトあたり補正ベクトルを取得
Definition GxBackgroundHit.h:115
GX_FORCE_INLINE b32 isAdjustedObjectHit(void) const
オブジェクトあたり補正結果取得
Definition GxBackgroundHit.h:119
~GxBackgroundHit(void) override
デストラクタ
Definition GxBackgroundHit.cpp:41
static const GxColor COLOR_OBJECT
描画色
Definition GxBackgroundHit.h:35
GX_FORCE_INLINE void resetObjectHitAdjust(void)
オブジェクトあたり補正結果リセット
Definition GxBackgroundHit.h:117
ADJUST_FLAG_INDEX
補正用フラグ
Definition GxBackgroundHit.h:47
@ THROUGH_ONCE_OLD
前回、一度スルーするフラグが立っていたかどうか
@ ON
上に乗れる補正方向かどうか
@ END
もう補正をしなくても良い
@ THROUGH_ONCE
OLD~POSの補正を一度スルーする
@ OLD_POS
OLD~POSで補正した直後(calcAdjustVector()で返す値はOLD~POSのベクトル)
GxCollision::GxObject * allocObject(void) override
オブジェクトのメモリ確保
Definition GxBackgroundHit.cpp:49
const GxVector3 & calculateAdjustVector(void) override
当たり判定後の補正処理
Definition GxBackgroundHit.cpp:86
GX_FORCE_INLINE void addObjectHitAdjust(const GxVector3 &adjust)
オブジェクトあたり補正ベクトルを設定
Definition GxBackgroundHit.h:113
void update(void) override
位置の更新
Definition GxBackgroundHit.cpp:100
Definition GxCollision.h:806
Collision基本オブジェクトクラス
Definition GxCollision.h:489
コリジョン基本クラス
Definition GxCollision.h:20
プロパティクラス
Definition GxProperty.h:48
実行時型情報クラス
Definition GxRtti.h:154
Definition GxBackgroundHit.h:385
bool needsCollision(btBroadphaseProxy *pProxy) const override
Definition GxBackgroundHit.cpp:455
GxConvexCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, GxConditionInformation *pConditionInfo)
コンストラクタ
Definition GxBackgroundHit.h:392
Definition GxBackgroundHit.h:351
GxRayCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, GxConditionInformation *pConditionInfo)
コンストラクタ
Definition GxBackgroundHit.h:358
bool needsCollision(btBroadphaseProxy *pProxy) const override
Definition GxBackgroundHit.cpp:419
Definition GxCollision.h:898
Definition GxCollision.h:848
レイ判定情報
Definition GxCollision.h:945
Definition GxColor.h:21
static const GxColor WHITE
Definition GxColor.h:37
インデックス指定型フラグ
Definition GxStruct.h:1294
3次元ベクトル
Definition GxVector.h:245
static const GxVector3 ZERO
(0, 0, 0)
Definition GxVector.h:256
32bitブーリアン
Definition GxDefine.h:173