OROCHI
 
Loading...
Searching...
No Matches
GxShape.h
Go to the documentation of this file.
1//===========================================================================
11//===========================================================================
12#pragma once
13
14GX_CORE_NAMESPACE_BEGIN()
15
16class GxShapeSphere; // 球
17class GxShapeBox; // 箱
18class GxShapeAxisAlignedBox; // 軸方向固定の箱
19class GxShapeFrustum; // 角錐台
20class GxShapeCylinder; // 円柱
21class GxShapeCapsule; // カプセル
22class GxShapeMultisphere; // マルチ球
23class GxShapeTrimesh; // 三角メッシュ
24class GxShapePlane; // 平面
25class GxShapeRay; // レイ
26class GxShapeBeam; // 太さのあるレイ
27
28#define GX_USE_AAB_MIN_MAX 1 // AABをmin-max形式で記述するかどうか
29
30//===========================================================================
32//===========================================================================
34{
35 OUTSIDE = 0,
36 CROSS,
37 INSIDE,
38 MAX
39};
40
41//===========================================================================
43//===========================================================================
44class GxShape : public GxClassBase
45{
46 //-----------------------------------------------------------
48 //-----------------------------------------------------------
50public:
51 GX_RTTI_ABSTRACT_CLASS(GxShape, GxClassBase)
52
53
54 static const f32 HIT_DISTANCE;
56 static const f32 NORMALIZED_JUDGE_MAX;
57
59 //-----------------------------------------------------------
61 //-----------------------------------------------------------
63
65 GxShape(void){}
67 ~GxShape( void ) override {}
68
70 //-----------------------------------------------------------
72 //-----------------------------------------------------------
74
76 virtual const GxVector3 getNormal(const GxVector3& position) const = 0;
77
81 virtual b32 isInclude(const GxVector3& /*point*/) const { GX_ERROR(false, "この形状に対するisInclude()は未対応です。"); return false; };
82
84 // note:未テスト
85 static b32 isHit(const GxShapeSphere& sphere0, const GxShapeSphere& sphere1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
87 // note:未テスト
88 static b32 isHit(const GxShapeSphere& sphere, const GxShapeBox& box, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
90 // note:未テスト
91 static b32 isHit(const GxShapeSphere& sphere, const GxShapeCylinder& cylinder, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
93 // note:未テスト
94 static b32 isHit(const GxShapeSphere& sphere, const GxShapeMultisphere& multisphere, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
96 // note:未テスト
97 static b32 isHit(const GxShapeSphere& sphere, const GxShapePlane& plane, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
99 // note:未テスト
100 static b32 isHit(const GxShapeSphere& sphere, const GxShapeTrimesh& trimesh, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
102 static b32 isHitSphereRay(const GxShapeSphere& sphere, const GxShapeRay& ray, f32* pParameter = nullptr, GxVector3* pHitNormal = nullptr);
104 // note:未テスト
105 static b32 isHit(const GxShapeSphere& sphere, const GxShapeBeam& beam, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
106
108 // note:未テスト
109 static b32 isHit(const GxShapeBox& box0, const GxShapeBox& box1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
111 // note:未テスト
112 static b32 isHit(const GxShapeBox& box, const GxShapeCylinder& cylinder, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
114 // note:未テスト
115 static b32 isHit(const GxShapeBox& box, const GxShapeMultisphere& multisphere, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
117 // note:未テスト
118 static b32 isHit(const GxShapeBox& box, const GxShapePlane& plane, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
120 // note:未テスト
121 static b32 isHit(const GxShapeBox& box, const GxVector3& n, const GxVector3& p, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
122
124 // note:未テスト
125 static b32 isHit(const GxShapeBox& box, const GxShapeTrimesh& trimesh, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
127 static b32 isHitBoxRay(const GxShapeBox& box, const GxShapeRay& ray, f32* pParam = nullptr, GxVector3* pHitNormal = nullptr);
129 // note:未テスト
130 static b32 isHit(const GxShapeBox& box, const GxShapeBeam& beam, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
131
133 // note:未テスト
134 static b32 isHit(const GxShapeCylinder& cylinder0, const GxShapeCylinder& cylinder1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
136 // note:未テスト
137 static b32 isHit(const GxShapeCylinder& cylinder, const GxShapeMultisphere& multisphere, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
139 // note:未テスト
140 static b32 isHit(const GxShapeCylinder& cylinder, const GxShapePlane& plane, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
142 // note:未テスト
143 static b32 isHit(const GxShapeCylinder& cylinder, const GxShapeTrimesh& trimesh, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
145 static b32 isHitCylinderRay(const GxShapeCylinder& cylinder, const GxShapeRay& ray, f32* pParameter = nullptr, GxVector3* pHitNormal = nullptr);
147 // note:未テスト
148 static b32 isHit(const GxShapeCylinder& cylinder, const GxShapeBeam& beam, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
149
151 // note:未テスト
152 static b32 isHit(const GxShapeCapsule& multisphere0, const GxShapeCapsule& multisphere1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
154 // note:未テスト
155 static b32 isHit(const GxShapeCapsule& multisphere, const GxShapePlane& plane, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
157 // note:未テスト
158 static b32 isHit(const GxShapeCapsule& multisphere, const GxShapeTrimesh& trimesh, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
160 // note:未テスト
161 static b32 isHitCapsuleRay(const GxShapeCapsule& multisphere, const GxShapeRay& ray, f32* pParameter = nullptr, GxVector3* pHitNormal = nullptr);
163 // note:未テスト
164 static b32 isHit(const GxShapeCapsule& multisphere, const GxShapeBeam& beam, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
165
167 // note:未テスト
168 static b32 isHit(const GxShapeMultisphere& multisphere0, const GxShapeMultisphere& multisphere1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
170 // note:未テスト
171 static b32 isHit(const GxShapeMultisphere& multisphere, const GxShapePlane& plane, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
173 // note:未テスト
174 static b32 isHit(const GxShapeMultisphere& multisphere, const GxShapeTrimesh& trimesh, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
176 // note:未テスト
177 static b32 isHitMultisphereRay(const GxShapeMultisphere& multisphere, const GxShapeRay& ray, f32* pParameter = nullptr, GxVector3* pHitNormal = nullptr);
179 // note:未テスト
180 static b32 isHit(const GxShapeMultisphere& multisphere, const GxShapeBeam& beam, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
181
183 // note:未テスト
184 static b32 isHit(const GxShapeAxisAlignedBox& aab0, const GxShapeAxisAlignedBox& aab1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
185
187 static b32 isHit(const GxShapeAxisAlignedBox& aabb, const GxShapePlane& plane, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
188
190 static b32 isHit(const GxShapeAxisAlignedBox& aabb, const GxVector3& n, const GxVector3& p, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
191
193 // note:未テスト
194 static b32 isHit(const GxShapePlane& plane0, const GxShapePlane& plane1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
196 // note:未テスト
197 static b32 isHit(const GxShapePlane& plane, const GxShapeTrimesh& trimesh, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
199 // note:未テスト
200 static b32 isHitPlaneRay(const GxShapePlane& plane, const GxShapeRay& ray, f32* pParameter = nullptr, GxVector3* pHitNormal = nullptr);
202 // note:未テスト
203 static b32 isHit(const GxShapePlane& plane, const GxShapeBeam& beam, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
204
206 // note:未テスト
207 static b32 isHit(const GxShapeTrimesh& trimesh0, const GxShapeTrimesh& trimesh1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
209 // note:未テスト
210 static b32 isHit(const GxShapeTrimesh& trimesh, const GxShapeRay& ray, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
212 // note:未テスト
213 static b32 isHit(const GxShapeTrimesh& trimesh, const GxShapeBeam& beam, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
214
216 // note:未テスト
217 static b32 isHit(const GxShapeRay& ray0, const GxShapeRay& ray1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
219 // note:未テスト
220 static b32 isHit(const GxShapeRay& ray, const GxShapeBeam& beam, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
221
223 // note:未テスト
224 static b32 isHit(const GxShapeBeam& beam0, const GxShapeBeam& beam1, GxVector3* pHitPosition = nullptr, GxVector3* pAdjustVector = nullptr);
225
227 // note:未テスト
228 static void getClosestPoint(const GxVector3& point, const GxShapeBox& box, GxVector3& closestPoint, GxVector3& surfacePoint);
230 // note:未テスト
231 static void getClosestPoint(const GxVector3& point, const GxShapeRay& ray, GxVector3& closestPoint);
232
234};
235
236//===========================================================================
238//===========================================================================
239class GxShapeSphere : public GxShape
240{
241 //-------------------------------------------------------------------
243 //-------------------------------------------------------------------
245public:
246 GX_RTTI_CLASS(GxShapeSphere, GxShape)
247
248
249 //-----------------------------------------------------------
251 //-----------------------------------------------------------
253
255 GxShapeSphere(void) : _radius(0.f){}
257 GxShapeSphere(f32 radius, const GxVector3& position) : _radius(radius), _position(position){}
259 ~GxShapeSphere( void ) override {}
260
262 //-----------------------------------------------------------
264 //-----------------------------------------------------------
266
267#if GX_DEVELOP
269 static GxGuiBase* createGui(GxProperty& property, GxTypedObject* pOwner, const GxRtti& rtti, u32 index = 0);
270#endif //GX_DEVELOP
271
273 b32 createBounding(const GxVector3* pVertex, const u32 vertexCount);
275 b32 createBounding(const void* pVertex, const u32 vertexCount, const u32 stride);
276
279 b32 createMinSphereRough(const u32 vertexCount, const GxVector3* pVertex);
280
281private:
283 static void getSurfaceAverage(const GxVector3* pVertex, u32 vertexCount, const u8* pSurfaceFlag, GxVector3& average);
284
286 static f32 getFarthestLength(const GxVector3* pVertex, u32 vertexCount, const GxVector3& basePosition);
287
289 static u32 checkSurfaceVertex(const GxVector3* pVertex, u32 vertexCount, u8* pSurfaceFlag, f32 radius, const GxVector3& center);
290
292 static b32 adjust(const GxVector3* pVertex, u32 vertexCount, const u8* pSurfaceFlag, f32& radius, GxVector3& center);
293
295 //-----------------------------------------------------------
297 //-----------------------------------------------------------
299public:
301 constexpr f32 getRadius(void) const { return _radius; }
303 constexpr void setRadius(f32 radius){ _radius = radius; }
305 GX_FORCE_INLINE const GxVector3& getPosition(void) const { return _position; }
307 GX_FORCE_INLINE void setPosition(const GxVector3& position){ _position = position; }
309 const GxVector3 getNormal(const GxVector3& position) const override;
310
312 b32 isInclude(const GxVector3& point) const override;
313
315 b32 isHitRay(const GxVector3& rayStart, const GxVector3& rayEnd, GxVector3* pHitPosition = nullptr, GxVector3* pNormal = nullptr ) const;
316
318 //-----------------------------------------------------------
320 //-----------------------------------------------------------
322private:
323 f32 _radius;
324 GxVector3 _position;
325
327};
328
329//===========================================================================
331//===========================================================================
332class GxShapeBox : public GxShape
333{
334 //-------------------------------------------------------------------
336 //-------------------------------------------------------------------
338public:
339 GX_RTTI_CLASS(GxShapeBox, GxShape)
340
341
342 //-----------------------------------------------------------
344 //-----------------------------------------------------------
346
350 GxShapeBox(const GxVector3& extent, const GxMatrixAffine& matrix = GxMatrixAffine::IDENTITY) : _extent(extent), _matrix(matrix){}
354 ~GxShapeBox( void ) override {}
355
357 //-----------------------------------------------------------
359 //-----------------------------------------------------------
361#if GX_DEVELOP
362 // 書き込み
363 b32 write(GxStreamWriter& writer);
364#endif //GX_DEVELOP
365
367 //-----------------------------------------------------------
369 //-----------------------------------------------------------
371
373 GX_FORCE_INLINE const GxVector3& getExtent(void) const { return _extent; }
375 GX_FORCE_INLINE void setExtent(const GxVector3& extent){ _extent = extent; }
377 constexpr void setExtent(const f32 x, const f32 y, const f32 z){ _extent._x = x; _extent._y = y; _extent._z = z; }
379 GX_FORCE_INLINE const GxMatrixAffine& getMatrix(void) const { return _matrix; }
381 GX_FORCE_INLINE GxMatrixAffine& getMatrix(void) { return _matrix; }
383 GX_FORCE_INLINE void setMatrix(const GxMatrixAffine& matrix)
384 {
385 // 本来の意味ではcolumnだがrowで代用
386 // todo:スケールマトリクスをはじく処理
387 _matrix = matrix;
388 }
389
391 GX_FORCE_INLINE void setPosition(const GxVector3& position){ _matrix.setPosition(position); }
392
394 const GxVector3 getNormal(const GxVector3& position) const override;
395
397 b32 isInclude(const GxVector3& point) const override;
398
400 b32 isHitRay(const GxVector3& rayStart, const GxVector3& rayEnd, GxVector3* pHitPosition = nullptr, GxVector3* pNormal = nullptr ) const;
401
403 //-----------------------------------------------------------
405 //-----------------------------------------------------------
407private:
408 GxVector3 _extent;
409 GxMatrixAffine _matrix;
410
412};
413
414//===========================================================================
416//===========================================================================
418{
419 //-------------------------------------------------------------------
421 //-------------------------------------------------------------------
423public:
424 GX_RTTI_CLASS(GxShapeAxisAlignedBox, GxShape)
425
426
427 //-----------------------------------------------------------
429 //-----------------------------------------------------------
431
432#if GX_USE_AAB_MIN_MAX
436 GxShapeAxisAlignedBox( const GxVector3& min, const GxVector3& max ) : _min(min), _max(max){}
437#else // GX_USE_AAB_MIN_MAX
439 GxShapeAxisAlignedBox(void) : _extent(GxVector3::ZERO), _position(GxVector3::ZERO) {}
441 GxShapeAxisAlignedBox( const GxVector3& extent, const GxVector3& position ) : _extent(extent), _position(position){}
442#endif // !GX_USE_AAB_MIN_MAX
444 ~GxShapeAxisAlignedBox( void ) override {}
445
447 //-----------------------------------------------------------
449 //-----------------------------------------------------------
451
452#if GX_USE_AAB_MIN_MAX
454 GX_FORCE_INLINE const GxVector3& getMin( void ) const { return _min; }
456 GX_FORCE_INLINE const GxVector3& getMax( void ) const { return _max; }
457
459 GX_FORCE_INLINE void setMin( const GxVector3& position ) { _min = position; }
461 GX_FORCE_INLINE void setMax( const GxVector3& position) { _max = position; }
462
464 GX_FORCE_INLINE GxVector3 getExtent(void) const { return GxVector3( 0.5f * (_max._x - _min._x), 0.5f * (_max._y - _min._y), 0.5f * (_max._z - _min._z) ); }
466 GX_FORCE_INLINE GxVector3 getPosition(void) const { return GxVector3( 0.5f * (_max._x + _min._x), 0.5f * (_max._y + _min._y), 0.5f * (_max._z + _min._z) ); }
468 GX_FORCE_INLINE void setPosition( const GxVector3& position) { GxVector3 extent(getExtent()); _max = position; _max += extent; _min = position; _min -= extent;}
469#else // GX_USE_AAB_MIN_MAX
471 GX_FORCE_INLINE const GxVector3& getExtent(void) const { return _extent; }
473 GX_FORCE_INLINE void setExtent(const GxVector3& extent){ _extent = extent; }
475 constexpr void setExtent(const f32 x, const f32 y, const f32 z){ _extent._x = x; _extent._y = y; _extent._z = z; }
476
478 GX_FORCE_INLINE const GxVector3& getPosition(void) const { return _position; }
479
481 GX_FORCE_INLINE GxVector3 getMin( void ) const { GxVector3 retval( _position ); retval -= _extent; return retval; }
483 GX_FORCE_INLINE void getMin( GxVector3& min ) const { min = _position; min -= _extent; }
485 GX_FORCE_INLINE GxVector3 getMax( void ) const { GxVector3 retval( _position ); retval += _extent; return retval; }
487 GX_FORCE_INLINE void getMax( GxVector3& max ) const { max = _position; max += _extent; }
488#endif // !GX_USE_AAB_MIN_MAX
489
491 //-----------------------------------------------------------
493 //-----------------------------------------------------------
495
497 b32 createBounding( const GxVector3* pVertex, const u32 count );
499 b32 createBounding( const void* pVertex, const u32 count, const u32 stride );
500
502 const GxVector3 getNormal(const GxVector3& position) const override;
503
505 b32 isInclude(const GxVector3& point) const override;
506
508 virtual b32 checkWithAABB(const GxShapeAxisAlignedBox& aabb) const;
509
511 //-----------------------------------------------------------
513 //-----------------------------------------------------------
515private:
516#if GX_USE_AAB_MIN_MAX
517 GxVector3 _min; //<! aab最小座標
518 GxVector3 _max; //<! aab最大座標
519#else // GX_USE_AAB_MIN_MAX
520 GxVector3 _position;
521 GxVector3 _extent;
522#endif // else GX_USE_AAB_MIN_MAX
523
525};
526
527//===========================================================================
529//===========================================================================
531{
532 //-------------------------------------------------------------------
534 //-------------------------------------------------------------------
536public:
537 GX_RTTI_CLASS(GxShapeFrustum, GxShape)
538
539
540 //-----------------------------------------------------------
542 //-----------------------------------------------------------
544
546 GxShapeFrustum(void);
548 GxShapeFrustum( const GxMatrixAffine& top, f32 nearZ, f32 farZ, f32 fov, f32 aspectRatio );
550 ~GxShapeFrustum( void ) override {}
551
553 //-----------------------------------------------------------
555 //-----------------------------------------------------------
557
560 GX_FORCE_INLINE const GxMatrixAffine& getTop( void ) const { return _top; }
563 constexpr f32 getNearZ( void ) const { return _nearZ; }
566 constexpr f32 getFarZ( void ) const { return _farZ; }
569 constexpr f32 getFov( void ) const { return _fov; }
572 constexpr f32 getAspectRatio( void ) const { return _aspectRatio; }
573
575 void updateParameter( const GxMatrixAffine& top, f32 nearZ, f32 farZ, f32 fov, f32 aspectRatio );
576
578 //-----------------------------------------------------------
580 //-----------------------------------------------------------
582
584 b32 checkBounding( const GxShapeSphere& sphere ) const;
586 b32 checkWithAABB( const GxShapeAxisAlignedBox& aabb , u32& intersect) const;
587
589 b32 checkWithOBB( const GxShapeBox& obb ) const;
591 b32 checkBounding( const GxShapeCylinder& cylinder ) const;
592
594 const GxVector3 getNormal(const GxVector3& position) const override;
595
597 b32 isInclude(const GxVector3& point) const override;
598
600 void getVertex( GxVector3* pNearPlane, GxVector3* pFarPlane ) const;
602 void getVertex( GxVector3* pVertex ) const;
604 void getFarPlaneVertex( GxVector3* pFarPlane ) const;
605
606private:
608 void getPlaneVertex( GxVector3* pVertex, f32 tanFov, f32 z ) const;
610 b32 checkCylinderVsPlane( const GxVector3& normalPlane, const f32 distPlane, const f32 radiusEff, const GxVector3& normalCylinder, GxVector3& diff0, GxVector3& diff1, b32 needsUpdate ) const;
611
613 //-----------------------------------------------------------
615 //-----------------------------------------------------------
617private:
618 GxMatrixAffine _top;
619 f32 _nearZ;
620 f32 _farZ;
621
622 f32 _fov;
623 f32 _aspectRatio;
624
625 GxVector3 _sideNormal[4];
626
628};
629
630//===========================================================================
632//===========================================================================
634{
635 //-------------------------------------------------------------------
637 //-------------------------------------------------------------------
639public:
640 GX_RTTI_CLASS(GxShapeCylinder, GxShape)
641
642
643 //-----------------------------------------------------------
645 //-----------------------------------------------------------
647
654 GxShapeCylinder(f32 radius, f32 heightHalf, const GxMatrixAffine& matrix = GxMatrixAffine::IDENTITY) : _extent(radius, heightHalf, radius), _matrix(matrix){}
659 GxShapeCylinder(const f32 radius, const GxVector3& center0, const GxVector3& center1 );
661 ~GxShapeCylinder( void ) override {}
662
664 //-----------------------------------------------------------
666 //-----------------------------------------------------------
668
670 GX_FORCE_INLINE const GxVector3& getExtent(void) const { return _extent; }
672 GX_FORCE_INLINE void setExtent(const GxVector3& extent){ _extent = extent; }
674 GX_FORCE_INLINE const GxMatrixAffine& getMatrix(void) const { return _matrix; }
676 GX_FORCE_INLINE void setMatrix(const GxMatrixAffine& matrix)
677 {
678 // 本来の意味ではcolumnだがrowで代用
679 // todo:スケールマトリクスをはじく処理
680 _matrix = matrix;
681 }
683 const GxVector3 getNormal(const GxVector3& position) const override;
684
686 b32 isInclude(const GxVector3& point) const override;
687
689 b32 isHitRay(const GxVector3& rayStart, const GxVector3& rayEnd, GxVector3* pHitPosition = nullptr, GxVector3* pNormal = nullptr ) const;
690
692 //-----------------------------------------------------------
694 //-----------------------------------------------------------
696private:
697 GxVector3 _extent;
698 GxMatrixAffine _matrix;
699
701};
702
703//===========================================================================
705//===========================================================================
707{
708 //-------------------------------------------------------------------
710 //-------------------------------------------------------------------
712public:
713 GX_RTTI_CLASS(GxShapeCapsule, GxShape)
714
715
716 //-----------------------------------------------------------
718 //-----------------------------------------------------------
720
722 GxShapeCapsule( void ) : _radius(0.f), _height(0.f){}
724 GxShapeCapsule( f32 radius, f32 height, const GxMatrixAffine& matrix = GxMatrixAffine::IDENTITY );
726 ~GxShapeCapsule( void ) override {}
727
729 //-----------------------------------------------------------
731 //-----------------------------------------------------------
733
735 constexpr f32 getRadius(void) const { return _radius; }
737 constexpr void setRadius(f32 radius) { _radius = radius; }
738
740 constexpr f32 getHeight( void ) const { return _height; }
742 constexpr void setHeight( f32 height ) { _height = height;}
743
745 GX_FORCE_INLINE const GxMatrixAffine& getMatrix(void) const { return _matrix; }
747 GX_FORCE_INLINE void setMatrix(const GxMatrixAffine& matrix)
748 {
749 // 本来の意味ではcolumnだがrowで代用
750 // todo:スケールマトリクスをはじく処理
751 _matrix = matrix;
752 }
754 const GxVector3 getNormal(const GxVector3& position) const override;
755
757 b32 isHitRay(const GxVector3& rayStart, const GxVector3& rayEnd, GxVector3* pHitPosition = nullptr, GxVector3* pNormal = nullptr, f32* pParameter = nullptr ) const;
758
760 //-----------------------------------------------------------
762 //-----------------------------------------------------------
764private:
765 f32 _radius;
766 f32 _height;
767 GxMatrixAffine _matrix;
768
770};
771
772//===========================================================================
774//===========================================================================
776{
777 //-------------------------------------------------------------------
779 //-------------------------------------------------------------------
781public:
782 GX_RTTI_CLASS(GxShapeMultisphere, GxShape)
783
784
785 //-----------------------------------------------------------
787 //-----------------------------------------------------------
789
793 GxShapeMultisphere(f32 radius0, f32 radius1, const GxVector3& position0 = GxVector3::ZERO, const GxVector3& position1 = GxVector3::ZERO);
795 ~GxShapeMultisphere( void ) override {}
796
798 //-----------------------------------------------------------
800 //-----------------------------------------------------------
802
803#if GX_DEVELOP
805 static GxGuiBase* createGui(GxProperty& property, GxTypedObject* pOwner, const GxRtti& rtti, u32 index = 0);
806#endif //GX_DEVELOP
807
809 //-----------------------------------------------------------
811 //-----------------------------------------------------------
813
815 constexpr f32 getRadius0(void) const { return _radius[0]; }
817 constexpr void setRadius0(f32 radius){ _radius[0] = radius; }
819 constexpr f32 getRadius1(void) const { return _radius[1]; }
821 constexpr void setRadius1(f32 radius){ _radius[1] = radius; }
823 GX_FORCE_INLINE const GxVector3& getPosition0(void) const { return _position[0]; }
825 GX_FORCE_INLINE void setPosition0(const GxVector3& position){ _position[0] = position; }
827 GX_FORCE_INLINE const GxVector3& getPosition1(void) const { return _position[1]; }
829 GX_FORCE_INLINE void setPosition1(const GxVector3& position){ _position[1] = position; }
831 const GxVector3 getNormal(const GxVector3& position) const override;
832
834 b32 isHitRay(const GxVector3& rayStart, const GxVector3& rayEnd, GxVector3* pHitPosition = nullptr, GxVector3* pNormal = nullptr, f32* pParameter = nullptr ) const;
835
837 //-----------------------------------------------------------
839 //-----------------------------------------------------------
841private:
842 f32 _radius[2];
843 GxVector3 _position[2];
844
846};
847
848//===========================================================================
850//===========================================================================
852{
853 //-----------------------------------------------------------
855 //-----------------------------------------------------------
857public:
858 static const u32 VERTEX_COUNT = 3;
859
860 // RTTI定義
861 GX_RTTI_CLASS(GxShapeTriangle, GxShape)
862
863
864 //-----------------------------------------------------------
866 //-----------------------------------------------------------
868
870 GxShapeTriangle(void);
872 GxShapeTriangle(const GxVector3* pVertex0, const GxVector3* pVertex1, const GxVector3* pVertex2);
873
875 //-----------------------------------------------------------
877 //-----------------------------------------------------------
879
881 b32 operator == (const GxShapeTriangle& triangle) const;
883 b32 operator < (const GxShapeTriangle& triangle) const;
884
886 //-----------------------------------------------------------
888 //-----------------------------------------------------------
890
892 GX_FORCE_INLINE static b32 compareVertex(const GxVector3* pVertex0, const GxVector3* pVertex1) { return *pVertex0 < *pVertex1; }
894 GX_FORCE_INLINE const GxVector3 getNormal(const GxVector3& /*position*/) const override { return GxVector3::ZERO; }
895
897 //-----------------------------------------------------------
899 //-----------------------------------------------------------
901private:
902 const GxVector3* _pVertex[VERTEX_COUNT];
903
905};
906
907//===========================================================================
909// note:pVertex等のコピーは行っていないので、元を保持し続ける必要がある。
910//===========================================================================
912{
913 //-------------------------------------------------------------------
915 //-------------------------------------------------------------------
917public:
918 GX_RTTI_CLASS(GxShapeTrimesh, GxShape)
919 //GX_PROHIBIT_CLASS_BASE(GxShapeTrimesh);
920
921
922 //-----------------------------------------------------------
924 //-----------------------------------------------------------
926
928 GxShapeTrimesh(void) : _pVertex(nullptr), _pIndex(nullptr), _pCheckFlag(nullptr), _pMaterial(nullptr){}
937 GxShapeTrimesh(const GxMatrixAffine& matrix, const GxVector3* pVertex, u32 numVertex, const u32* pIndex, u32 numIndex, const u32* pCheckFlag, const s32* pMaterial) :
938 _matrix(matrix), _pVertex(pVertex), _pIndex(pIndex), _pCheckFlag(pCheckFlag), _pMaterial(pMaterial), _numVertex(numVertex), _numIndex(numIndex) {}
939
941 //-----------------------------------------------------------
943 //-----------------------------------------------------------
945public:
947 static void getRingTriangleIndices(const GxVector3* pVertexList, u32 vertexCount, GxArray& triangleIndices, u32 vertexStartIndex = 0);
949 static void getDelaunayTriangles(const GxVector3* pVertexList, u32 vertexCount, GxArray& triangleVertices);
951 static void getDelaunayTriangleIndices(const GxVector3* pVertexList, u32 vertexCount, GxArray& triangleIndices, u32 vertexStartIndex = 0);
952private:
954 static b32 findTriangle(const GxArray& triangles, const GxShapeTriangle& triangle);
955
957 //-----------------------------------------------------------
959 //-----------------------------------------------------------
961public:
963 GX_FORCE_INLINE const GxVector3& getVertex(u32 number) const
964 {
965 GX_ASSERT(number < _numVertex, "vertex access error");
966 return *(_pVertex + number);
967 }
969 GX_FORCE_INLINE const GxVector3* getVertexAddress( void ) const { return _pVertex; }
971 GX_FORCE_INLINE const u32* getIndexAddress( void ) const { return _pIndex; }
972
974 b32 getTriangleVertex(u32 triangleIndex, GxVector3& vertex0, GxVector3& vertex1, GxVector3& vertex2) const;
975
977 const GxVector3 getNormal(const GxVector3& position) const override;
978
980 GX_FORCE_INLINE const GxMatrixAffine& getMatrix(void) const { return _matrix; }
982 GX_FORCE_INLINE void setMatrix(const GxMatrixAffine& matrix)
983 {
984 // 本来の意味ではcolumnだがrowで代用
985 // todo:スケールマトリクスをはじく処理
986 _matrix = matrix;
987 }
988
990 constexpr u32 getNumVertex(void) const { return _numVertex; }
992 constexpr u32 getNumTriangle(void) const { return _numIndex / 3; }
993
995 constexpr u32 getCheckFlag(u32 triangleIndex) const
996 {
997 GX_ASSERT(triangleIndex < _numIndex / 3, "checkFlag access error");
998 return *(_pCheckFlag + triangleIndex);
999 }
1001 // todo:_pCheckFlagのallocをGxShapeTrimesh内に入れられないか考察
1002 GX_FORCE_INLINE b32 isCheckFlagExist( void ) const { return _pCheckFlag ? true : false; }
1003
1005 constexpr s32 getMaterial(u32 triangleIndex) const
1006 {
1007 GX_ASSERT(triangleIndex < _numIndex / 3, "material access error");
1008 return *(_pMaterial + triangleIndex);
1009 }
1011 // todo:_pMaterialのallocをGxShapeTrimesh内に入れられないか考察
1012 GX_FORCE_INLINE b32 isMaterialExist( void ) const { return _pMaterial ? true : false; }
1013
1015 //-----------------------------------------------------------
1017 //-----------------------------------------------------------
1019private:
1020 GxMatrixAffine _matrix;
1021 const GxVector3* _pVertex;
1022 const u32* _pIndex;
1023 const u32* _pCheckFlag;
1024 const s32* _pMaterial;
1025 u32 _numVertex;
1026 u32 _numIndex;
1027
1029};
1030
1031//===========================================================================
1033//===========================================================================
1035{
1036 //-----------------------------------------------------------
1038 //-----------------------------------------------------------
1040public:
1041 const static size_t VERTEX_COUNT = 4;
1042
1043 // RTTI定義
1044 GX_RTTI_CLASS(GxShapeTetrahedron, GxShape)
1045
1046
1047 //-----------------------------------------------------------
1049 //-----------------------------------------------------------
1051public:
1053 GxShapeTetrahedron(void);
1055 GxShapeTetrahedron(const GxVector3* pVertex0, const GxVector3* pVertex1, const GxVector3* pVertex2, const GxVector3* pVertex3);
1056
1058 //-----------------------------------------------------------
1060 //-----------------------------------------------------------
1062
1064 b32 operator == (const GxShapeTetrahedron& tetrahedron) const;
1066 b32 operator < (const GxShapeTetrahedron& tetrahedron) const;
1067
1069 //-----------------------------------------------------------
1071 //-----------------------------------------------------------
1073
1075 GX_FORCE_INLINE static b32 compareVertex(const GxVector3* pVertex0, const GxVector3* pVertex1) { return *pVertex0 < *pVertex1; }
1077 GX_FORCE_INLINE const GxVector3 getNormal(const GxVector3& /*position*/) const override { return GxVector3::ZERO; }
1079 b32 hasCommonPoints(const GxShapeTetrahedron& tetrahedron) const;
1081 static f32 luDecomposition(f32 a[3][3], s32 ip[3]);
1083 static f32 gauss(f32 a[3][3], f32 b[3], f32 x[3]);
1085 void getCircumsphere(GxVector3& center, f32& radius) const;
1086
1088 //-----------------------------------------------------------
1090 //-----------------------------------------------------------
1092
1094
1096};
1097
1098//===========================================================================
1100//===========================================================================
1101class GxShapePlane : public GxShape
1102{
1103 //-------------------------------------------------------------------
1105 //-------------------------------------------------------------------
1107public:
1108 GX_RTTI_CLASS(GxShapePlane, GxShape)
1109
1110
1111 //-----------------------------------------------------------
1113 //-----------------------------------------------------------
1115
1119 GxShapePlane(const GxVector3& position, const GxVector3& normal);
1121 ~GxShapePlane( void ) override {}
1122
1124 //-----------------------------------------------------------
1126 //-----------------------------------------------------------
1128
1130 GX_FORCE_INLINE const GxVector3 getNormal(const GxVector3& /*position*/ = GxVector3::ZERO) const override { return GxVector3(_plane); }
1132 GX_FORCE_INLINE const GxVector4& getVector(void) const { return _plane; }
1134 GX_FORCE_INLINE f32 getDistance(const GxVector3& position) const { return (GxVector3::getDot(GxVector3(_plane), position) + _plane._w); }
1136 GX_FORCE_INLINE const GxVector3 getProjectivePosition(const GxVector3& position) const { return (position + (GxVector3(_plane) * -getDistance(position))); }
1137
1139 b32 isHitRay( const GxVector3& position0, const GxVector3& position1, GxVector3* pHitPosition = nullptr, GxVector3* pNormal = nullptr ) const;
1141 b32 isHitHalfLine( const GxVector3& start, const GxVector3& direction, GxVector3* pHitPosition = nullptr, GxVector3* pNormal = nullptr ) const;
1142
1144 //-----------------------------------------------------------
1146 //-----------------------------------------------------------
1148private:
1151 GxVector4 _plane;
1152
1154};
1155
1156//===========================================================================
1158//===========================================================================
1159class GxShapeRay : public GxShape
1160{
1161 //-------------------------------------------------------------------
1163 //-------------------------------------------------------------------
1165public:
1166 GX_RTTI_CLASS(GxShapeRay, GxShape)
1167
1168
1169 //-----------------------------------------------------------
1171 //-----------------------------------------------------------
1173
1177 GxShapeRay(const GxVector3& position0, const GxVector3& position1){ _position[0] = position0; _position[1] = position1; }
1179 ~GxShapeRay( void ) override {}
1180
1182 //-----------------------------------------------------------
1184 //-----------------------------------------------------------
1186
1188 GX_FORCE_INLINE const GxVector3& getPosition0(void) const { return _position[0]; }
1190 GX_FORCE_INLINE void setPosition0(const GxVector3& position){ _position[0] = position; }
1192 GX_FORCE_INLINE const GxVector3& getPosition1(void) const { return _position[1]; }
1194 GX_FORCE_INLINE void setPosition1(const GxVector3& position){ _position[1] = position; }
1196 GX_FORCE_INLINE const GxVector3 getNormal(const GxVector3& /*position*/) const override { return GxVector3::ZERO; }
1197
1199 //-----------------------------------------------------------
1201 //-----------------------------------------------------------
1203private:
1204 GxVector3 _position[2];
1205
1207};
1208
1209//===========================================================================
1211//===========================================================================
1213{
1214 //-------------------------------------------------------------------
1216 //-------------------------------------------------------------------
1218public:
1219 GX_RTTI_CLASS(GxShapeBeam, GxShapeRay)
1220
1221
1222 //-----------------------------------------------------------
1224 //-----------------------------------------------------------
1226
1228 GxShapeBeam(void) : _radius(0.f){}
1230 ~GxShapeBeam( void ) override {}
1231
1233 //-----------------------------------------------------------
1235 //-----------------------------------------------------------
1237
1239 constexpr f32 getRadius(void) const { return _radius; }
1241 constexpr void setRadius(f32 radius){ _radius = radius; }
1242
1244 //-----------------------------------------------------------
1246 //-----------------------------------------------------------
1248private:
1249 f32 _radius;
1250
1252};
1253
1254GX_CORE_NAMESPACE_END()
void GxTypedObject
その他
Definition GxDefine.h:213
@ ZERO
全て 0 で初期化
SHAPE_HIT_STATE
形状同士の交差判定時
Definition GxShape.h:34
@ MAX
定義数
配列クラス
Definition GxArray.h:18
オブジェクト基底クラス
Definition GxBase.h:88
プロパティクラス
Definition GxProperty.h:48
実行時型情報クラス
Definition GxRtti.h:154
軸方向固定の箱形状クラス
Definition GxShape.h:418
GxShapeAxisAlignedBox(void)
デフォルトコンストラクタ
Definition GxShape.h:434
GX_FORCE_INLINE const GxVector3 & getMax(void) const
最大取得
Definition GxShape.h:456
b32 isInclude(const GxVector3 &point) const override
指定点が含まれているか判定
Definition GxShape.cpp:2056
GX_FORCE_INLINE GxVector3 getExtent(void) const
大きさ取得
Definition GxShape.h:464
GX_FORCE_INLINE GxVector3 getPosition(void) const
位置取得
Definition GxShape.h:466
const GxVector3 getNormal(const GxVector3 &position) const override
指定位置への法線を求める
Definition GxShape.cpp:2028
GX_FORCE_INLINE void setMax(const GxVector3 &position)
最大設定
Definition GxShape.h:461
GxShapeAxisAlignedBox(const GxVector3 &min, const GxVector3 &max)
コンストラクタ
Definition GxShape.h:436
GX_FORCE_INLINE void setMin(const GxVector3 &position)
最小設定
Definition GxShape.h:459
GX_FORCE_INLINE const GxVector3 & getMin(void) const
最小取得
Definition GxShape.h:454
b32 createBounding(const GxVector3 *pVertex, const u32 count)
境界作成(GxVector3指定)
Definition GxShape.cpp:1932
GX_FORCE_INLINE void setPosition(const GxVector3 &position)
位置設定
Definition GxShape.h:468
virtual b32 checkWithAABB(const GxShapeAxisAlignedBox &aabb) const
指定点が含まれているか判定
Definition GxShape.cpp:2040
光束形状クラス
Definition GxShape.h:1213
~GxShapeBeam(void) override
デストラクタ
Definition GxShape.h:1230
constexpr void setRadius(f32 radius)
半径を設定
Definition GxShape.h:1241
constexpr f32 getRadius(void) const
半径を取得
Definition GxShape.h:1239
箱形状クラス
Definition GxShape.h:333
GX_FORCE_INLINE const GxVector3 & getExtent(void) const
大きさ取得
Definition GxShape.h:373
GX_FORCE_INLINE const GxMatrixAffine & getMatrix(void) const
マトリクス取得
Definition GxShape.h:379
constexpr void setExtent(const f32 x, const f32 y, const f32 z)
大きさ設定
Definition GxShape.h:377
GX_FORCE_INLINE void setExtent(const GxVector3 &extent)
大きさ設定
Definition GxShape.h:375
GxShapeBox(const GxVector3 &extent, const GxMatrixAffine &matrix=GxMatrixAffine::IDENTITY)
コンストラクタ
Definition GxShape.h:350
GxShapeBox(void)
デフォルトコンストラクタ
Definition GxShape.h:348
~GxShapeBox(void) override
デストラクタ
Definition GxShape.h:354
GX_FORCE_INLINE void setPosition(const GxVector3 &position)
マトリクス設定(スケールは許可しない)
Definition GxShape.h:391
GX_FORCE_INLINE GxMatrixAffine & getMatrix(void)
マトリクス取得
Definition GxShape.h:381
GX_FORCE_INLINE void setMatrix(const GxMatrixAffine &matrix)
マトリクス設定(スケールは許可しない)
Definition GxShape.h:383
b32 isInclude(const GxVector3 &point) const override
指定点が含まれているか判定
Definition GxShape.cpp:1868
b32 isHitRay(const GxVector3 &rayStart, const GxVector3 &rayEnd, GxVector3 *pHitPosition=nullptr, GxVector3 *pNormal=nullptr) const
線分の衝突判定
Definition GxShape.cpp:1893
const GxVector3 getNormal(const GxVector3 &position) const override
表面位置から法線を求める
Definition GxShape.cpp:1855
カプセル形状クラス
Definition GxShape.h:707
constexpr f32 getRadius(void) const
半径を取得
Definition GxShape.h:735
GX_FORCE_INLINE void setMatrix(const GxMatrixAffine &matrix)
マトリクス設定(スケールは許可しない)
Definition GxShape.h:747
GX_FORCE_INLINE const GxMatrixAffine & getMatrix(void) const
マトリクス取得
Definition GxShape.h:745
constexpr f32 getHeight(void) const
高さを取得
Definition GxShape.h:740
constexpr void setRadius(f32 radius)
半径を設定
Definition GxShape.h:737
GxShapeCapsule(void)
デフォルトコンストラクタ
Definition GxShape.h:722
b32 isHitRay(const GxVector3 &rayStart, const GxVector3 &rayEnd, GxVector3 *pHitPosition=nullptr, GxVector3 *pNormal=nullptr, f32 *pParameter=nullptr) const
線分の衝突判定
Definition GxShape.cpp:2780
const GxVector3 getNormal(const GxVector3 &position) const override
指定位置への法線を取得
Definition GxShape.cpp:2764
constexpr void setHeight(f32 height)
高さを設定
Definition GxShape.h:742
~GxShapeCapsule(void) override
デストラクタ
Definition GxShape.h:726
円柱形状クラス
Definition GxShape.h:634
b32 isHitRay(const GxVector3 &rayStart, const GxVector3 &rayEnd, GxVector3 *pHitPosition=nullptr, GxVector3 *pNormal=nullptr) const
線分の衝突判定
Definition GxShape.cpp:2717
GxShapeCylinder(f32 radius, f32 heightHalf, const GxMatrixAffine &matrix=GxMatrixAffine::IDENTITY)
Definition GxShape.h:654
GX_FORCE_INLINE void setExtent(const GxVector3 &extent)
大きさ設定
Definition GxShape.h:672
const GxVector3 getNormal(const GxVector3 &position) const override
指定位置への法線を求める
Definition GxShape.cpp:2669
~GxShapeCylinder(void) override
デストラクタ
Definition GxShape.h:661
GX_FORCE_INLINE const GxVector3 & getExtent(void) const
大きさ取得
Definition GxShape.h:670
GxShapeCylinder(void)
デフォルトコンストラクタ
Definition GxShape.h:649
GX_FORCE_INLINE const GxMatrixAffine & getMatrix(void) const
マトリクス取得
Definition GxShape.h:674
b32 isInclude(const GxVector3 &point) const override
指定点が含まれているか判定
Definition GxShape.cpp:2681
GX_FORCE_INLINE void setMatrix(const GxMatrixAffine &matrix)
マトリクス設定(スケールは許可しない)
Definition GxShape.h:676
角錐台
Definition GxShape.h:531
constexpr f32 getFov(void) const
Definition GxShape.h:569
const GxVector3 getNormal(const GxVector3 &position) const override
指定位置への法線を求める
Definition GxShape.cpp:2551
void getFarPlaneVertex(GxVector3 *pFarPlane) const
遠面の頂点を取得
Definition GxShape.cpp:2607
~GxShapeFrustum(void) override
デストラクタ
Definition GxShape.h:550
GxShapeFrustum(void)
デフォルトコンストラクタ
Definition GxShape.cpp:2105
void getVertex(GxVector3 *pNearPlane, GxVector3 *pFarPlane) const
頂点を取得(近面と遠面を別で取得)
Definition GxShape.cpp:2578
constexpr f32 getFarZ(void) const
Definition GxShape.h:566
void updateParameter(const GxMatrixAffine &top, f32 nearZ, f32 farZ, f32 fov, f32 aspectRatio)
パラメタ更新
Definition GxShape.cpp:2140
b32 checkWithOBB(const GxShapeBox &obb) const
境界形状との交差判定:OBB
Definition GxShape.cpp:2308
constexpr f32 getAspectRatio(void) const
Definition GxShape.h:572
GX_FORCE_INLINE const GxMatrixAffine & getTop(void) const
Definition GxShape.h:560
b32 checkWithAABB(const GxShapeAxisAlignedBox &aabb, u32 &intersect) const
境界形状との交差判定:AABB
Definition GxShape.cpp:2217
b32 checkBounding(const GxShapeSphere &sphere) const
境界形状との交差判定:球
Definition GxShape.cpp:2181
constexpr f32 getNearZ(void) const
Definition GxShape.h:563
b32 isInclude(const GxVector3 &point) const override
指定点が含まれているか判定
Definition GxShape.cpp:2562
形状基礎クラス
Definition GxShape.h:45
static b32 isHit(const GxShapeSphere &sphere0, const GxShapeSphere &sphere1, GxVector3 *pHitPosition=nullptr, GxVector3 *pAdjustVector=nullptr)
球と球の衝突判定
Definition GxShape.cpp:38
static b32 isHitSphereRay(const GxShapeSphere &sphere, const GxShapeRay &ray, f32 *pParameter=nullptr, GxVector3 *pHitNormal=nullptr)
球と線分の衝突判定
Definition GxShape.cpp:192
static void getClosestPoint(const GxVector3 &point, const GxShapeBox &box, GxVector3 &closestPoint, GxVector3 &surfacePoint)
点と箱の最近接点を求める
Definition GxShape.cpp:1359
virtual const GxVector3 getNormal(const GxVector3 &position) const =0
指定位置への法線を求める
static const f32 NORMALIZED_JUDGE_MAX
fabs(lengthSquare - 1.f)がこの値未満なら正規化と判定
Definition GxShape.h:56
static b32 isHitPlaneRay(const GxShapePlane &plane, const GxShapeRay &ray, f32 *pParameter=nullptr, GxVector3 *pHitNormal=nullptr)
平面と線分の衝突判定
Definition GxShape.cpp:1224
virtual b32 isInclude(const GxVector3 &) const
Definition GxShape.h:81
static b32 isHitCylinderRay(const GxShapeCylinder &cylinder, const GxShapeRay &ray, f32 *pParameter=nullptr, GxVector3 *pHitNormal=nullptr)
円柱と線分の衝突判定
Definition GxShape.cpp:617
static b32 isHitBoxRay(const GxShapeBox &box, const GxShapeRay &ray, f32 *pParam=nullptr, GxVector3 *pHitNormal=nullptr)
箱と線分の衝突判定
Definition GxShape.cpp:448
static b32 isHitMultisphereRay(const GxShapeMultisphere &multisphere, const GxShapeRay &ray, f32 *pParameter=nullptr, GxVector3 *pHitNormal=nullptr)
マルチ球と線分の衝突判定
Definition GxShape.cpp:980
static const f32 HIT_DISTANCE
この距離未満なら衝突と判定
Definition GxShape.h:54
~GxShape(void) override
デストラクタ
Definition GxShape.h:67
static b32 isHitCapsuleRay(const GxShapeCapsule &multisphere, const GxShapeRay &ray, f32 *pParameter=nullptr, GxVector3 *pHitNormal=nullptr)
カプセルと線分の衝突判定
Definition GxShape.cpp:855
マルチ球形状クラス
Definition GxShape.h:776
constexpr f32 getRadius0(void) const
半径0を取得
Definition GxShape.h:815
constexpr void setRadius1(f32 radius)
半径1を設定
Definition GxShape.h:821
GX_FORCE_INLINE const GxVector3 & getPosition0(void) const
位置0を取得
Definition GxShape.h:823
GxShapeMultisphere(void)
デフォルトコンストラクタ
Definition GxShape.h:791
GX_FORCE_INLINE void setPosition1(const GxVector3 &position)
位置1を設定
Definition GxShape.h:829
GX_FORCE_INLINE void setPosition0(const GxVector3 &position)
位置0を設定
Definition GxShape.h:825
GX_FORCE_INLINE const GxVector3 & getPosition1(void) const
位置1を取得
Definition GxShape.h:827
constexpr f32 getRadius1(void) const
半径1を取得
Definition GxShape.h:819
b32 isHitRay(const GxVector3 &rayStart, const GxVector3 &rayEnd, GxVector3 *pHitPosition=nullptr, GxVector3 *pNormal=nullptr, f32 *pParameter=nullptr) const
線分の衝突判定
Definition GxShape.cpp:2849
~GxShapeMultisphere(void) override
デストラクタ
Definition GxShape.h:795
const GxVector3 getNormal(const GxVector3 &position) const override
指定位置への法線を取得
Definition GxShape.cpp:2833
constexpr void setRadius0(f32 radius)
半径0を設定
Definition GxShape.h:817
平面形状クラス
Definition GxShape.h:1102
GX_FORCE_INLINE f32 getDistance(const GxVector3 &position) const
距離を取得
Definition GxShape.h:1134
GX_FORCE_INLINE const GxVector3 getNormal(const GxVector3 &=GxVector3::ZERO) const override
指定位置への法線を取得
Definition GxShape.h:1130
GxShapePlane(void)
デフォルトコンストラクタ
Definition GxShape.h:1117
b32 isHitHalfLine(const GxVector3 &start, const GxVector3 &direction, GxVector3 *pHitPosition=nullptr, GxVector3 *pNormal=nullptr) const
半直線との衝突判定
Definition GxShape.cpp:3555
~GxShapePlane(void) override
デストラクタ
Definition GxShape.h:1121
b32 isHitRay(const GxVector3 &position0, const GxVector3 &position1, GxVector3 *pHitPosition=nullptr, GxVector3 *pNormal=nullptr) const
線分との衝突判定
Definition GxShape.cpp:3530
GX_FORCE_INLINE const GxVector3 getProjectivePosition(const GxVector3 &position) const
射影した位置を取得
Definition GxShape.h:1136
GX_FORCE_INLINE const GxVector4 & getVector(void) const
ベクトルを取得
Definition GxShape.h:1132
線分形状クラス
Definition GxShape.h:1160
GX_FORCE_INLINE void setPosition1(const GxVector3 &position)
位置1を設定
Definition GxShape.h:1194
~GxShapeRay(void) override
デストラクタ
Definition GxShape.h:1179
GxShapeRay(const GxVector3 &position0, const GxVector3 &position1)
コンストラクタ
Definition GxShape.h:1177
GX_FORCE_INLINE const GxVector3 getNormal(const GxVector3 &) const override
指定位置への法線を取得
Definition GxShape.h:1196
GX_FORCE_INLINE const GxVector3 & getPosition1(void) const
位置1を取得
Definition GxShape.h:1192
GX_FORCE_INLINE const GxVector3 & getPosition0(void) const
位置0を取得
Definition GxShape.h:1188
GX_FORCE_INLINE void setPosition0(const GxVector3 &position)
位置0を設定
Definition GxShape.h:1190
球形状クラス
Definition GxShape.h:240
GX_FORCE_INLINE const GxVector3 & getPosition(void) const
位置取得
Definition GxShape.h:305
b32 createBounding(const GxVector3 *pVertex, const u32 vertexCount)
境界作成(GxVector3指定)
Definition GxShape.cpp:1507
constexpr void setRadius(f32 radius)
半径設定
Definition GxShape.h:303
const GxVector3 getNormal(const GxVector3 &position) const override
指定位置への法線を求める
Definition GxShape.cpp:1457
~GxShapeSphere(void) override
デストラクタ
Definition GxShape.h:259
GX_FORCE_INLINE void setPosition(const GxVector3 &position)
位置設定
Definition GxShape.h:307
b32 isInclude(const GxVector3 &point) const override
指定点が含まれているか判定
Definition GxShape.cpp:1469
b32 createMinSphereRough(const u32 vertexCount, const GxVector3 *pVertex)
Definition GxShape.cpp:1599
GxShapeSphere(f32 radius, const GxVector3 &position)
コンストラクタ
Definition GxShape.h:257
b32 isHitRay(const GxVector3 &rayStart, const GxVector3 &rayEnd, GxVector3 *pHitPosition=nullptr, GxVector3 *pNormal=nullptr) const
線分の衝突判定
Definition GxShape.cpp:1484
constexpr f32 getRadius(void) const
半径取得
Definition GxShape.h:301
四面体形状クラス
Definition GxShape.h:1035
b32 hasCommonPoints(const GxShapeTetrahedron &tetrahedron) const
同じ頂点を持つか判定
Definition GxShape.cpp:3342
static f32 gauss(f32 a[3][3], f32 b[3], f32 x[3])
ガウスの消去法
Definition GxShape.cpp:3430
GX_FORCE_INLINE const GxVector3 getNormal(const GxVector3 &) const override
指定位置への法線を取得
Definition GxShape.h:1077
const GxVector3 * _pVertex[VERTEX_COUNT]
頂点
Definition GxShape.h:1093
void getCircumsphere(GxVector3 &center, f32 &radius) const
外接球を取得
Definition GxShape.cpp:3468
b32 operator==(const GxShapeTetrahedron &tetrahedron) const
一致
Definition GxShape.cpp:3289
static GX_FORCE_INLINE b32 compareVertex(const GxVector3 *pVertex0, const GxVector3 *pVertex1)
頂点ソート用比較関数
Definition GxShape.h:1075
static f32 luDecomposition(f32 a[3][3], s32 ip[3])
LU分解
Definition GxShape.cpp:3363
GxShapeTetrahedron(void)
デフォルトコンストラクタ
Definition GxShape.cpp:3264
static const size_t VERTEX_COUNT
頂点数
Definition GxShape.h:1041
b32 operator<(const GxShapeTetrahedron &tetrahedron) const
小なり
Definition GxShape.cpp:3315
三角形形状クラス
Definition GxShape.h:852
b32 operator<(const GxShapeTriangle &triangle) const
小なり
Definition GxShape.cpp:2957
static GX_FORCE_INLINE b32 compareVertex(const GxVector3 *pVertex0, const GxVector3 *pVertex1)
頂点ソート用比較関数
Definition GxShape.h:892
static const u32 VERTEX_COUNT
頂点数
Definition GxShape.h:858
GxShapeTriangle(void)
デフォルトコンストラクタ
Definition GxShape.cpp:2907
b32 operator==(const GxShapeTriangle &triangle) const
一致
Definition GxShape.cpp:2930
GX_FORCE_INLINE const GxVector3 getNormal(const GxVector3 &) const override
指定位置への法線を取得
Definition GxShape.h:894
三角メッシュ形状クラス
Definition GxShape.h:912
GxShapeTrimesh(const GxMatrixAffine &matrix, const GxVector3 *pVertex, u32 numVertex, const u32 *pIndex, u32 numIndex, const u32 *pCheckFlag, const s32 *pMaterial)
Definition GxShape.h:937
GX_FORCE_INLINE b32 isMaterialExist(void) const
マテリアルが存在するかチェック
Definition GxShape.h:1012
b32 getTriangleVertex(u32 triangleIndex, GxVector3 &vertex0, GxVector3 &vertex1, GxVector3 &vertex2) const
Indexから3頂点を取得
Definition GxShape.cpp:3229
constexpr u32 getNumTriangle(void) const
三角メッシュの数を取得する
Definition GxShape.h:992
constexpr u32 getNumVertex(void) const
頂点数を取得
Definition GxShape.h:990
GX_FORCE_INLINE const u32 * getIndexAddress(void) const
インデックスアドレスを取得
Definition GxShape.h:971
GX_FORCE_INLINE b32 isCheckFlagExist(void) const
判定用フラグが存在するかチェック
Definition GxShape.h:1002
constexpr u32 getCheckFlag(u32 triangleIndex) const
判定用フラグを取得
Definition GxShape.h:995
GX_FORCE_INLINE const GxVector3 * getVertexAddress(void) const
頂点アドレスを取得
Definition GxShape.h:969
constexpr s32 getMaterial(u32 triangleIndex) const
マテリアルを取得
Definition GxShape.h:1005
GX_FORCE_INLINE void setMatrix(const GxMatrixAffine &matrix)
マトリクス設定(スケールは許可しない)
Definition GxShape.h:982
static void getDelaunayTriangles(const GxVector3 *pVertexList, u32 vertexCount, GxArray &triangleVertices)
ドロネー分割三角形を取得
Definition GxShape.cpp:3023
GX_FORCE_INLINE const GxVector3 & getVertex(u32 number) const
頂点を取得
Definition GxShape.h:963
const GxVector3 getNormal(const GxVector3 &position) const override
指定位置への法線を取得
Definition GxShape.cpp:3245
static void getRingTriangleIndices(const GxVector3 *pVertexList, u32 vertexCount, GxArray &triangleIndices, u32 vertexStartIndex=0)
リング状の頂点配列をそのままポリゴン化したインデックスを取得
Definition GxShape.cpp:2994
GX_FORCE_INLINE const GxMatrixAffine & getMatrix(void) const
マトリクス取得
Definition GxShape.h:980
static void getDelaunayTriangleIndices(const GxVector3 *pVertexList, u32 vertexCount, GxArray &triangleIndices, u32 vertexStartIndex=0)
ドロネー分割三角形をインデックスで取得
Definition GxShape.cpp:3185
ストリーム書き込みクラス
Definition GxStreamWriter.h:19
アフィン変換行列(行優先)
Definition GxMatrix.h:330
static const GxMatrixAffine IDENTITY
単位行列
Definition GxMatrix.h:341
GX_FORCE_INLINE void setPosition(const GxVector3 &position)
平行移動量のみを設定
Definition GxMatrix.inl:2141
3次元ベクトル
Definition GxVector.h:245
f32 _z
Z値
Definition GxVector.h:572
f32 _y
Y値
Definition GxVector.h:571
static const GxVector3 ZERO
(0, 0, 0)
Definition GxVector.h:256
static GX_FORCE_INLINE f32 getDot(const GxVector3 &vector0, const GxVector3 &vector1)
内積を取得
Definition GxVector.inl:2083
f32 _x
X値
Definition GxVector.h:570
4次元ベクトル
Definition GxVector.h:582
f32 _w
W値
Definition GxVector.h:796
32bitブーリアン
Definition GxDefine.h:173