mirror of https://github.com/bkaradzic/bgfx
Moving bounds from bgfx to bx.
This commit is contained in:
parent
ffeba57b8a
commit
c5d1a1a8e3
|
@ -919,9 +919,9 @@ struct Group
|
||||||
uint8_t* m_vertices;
|
uint8_t* m_vertices;
|
||||||
uint32_t m_numIndices;
|
uint32_t m_numIndices;
|
||||||
uint16_t* m_indices;
|
uint16_t* m_indices;
|
||||||
Sphere m_sphere;
|
bx::Sphere m_sphere;
|
||||||
Aabb m_aabb;
|
bx::Aabb m_aabb;
|
||||||
Obb m_obb;
|
bx::Obb m_obb;
|
||||||
PrimitiveArray m_prims;
|
PrimitiveArray m_prims;
|
||||||
uint32_t m_numEdges;
|
uint32_t m_numEdges;
|
||||||
Edge* m_edges;
|
Edge* m_edges;
|
||||||
|
@ -990,9 +990,9 @@ struct Mesh
|
||||||
group.m_ibh = bgfx::createIndexBuffer(mem);
|
group.m_ibh = bgfx::createIndexBuffer(mem);
|
||||||
|
|
||||||
group.m_sphere = it->m_sphere;
|
group.m_sphere = it->m_sphere;
|
||||||
group.m_aabb = it->m_aabb;
|
group.m_aabb = it->m_aabb;
|
||||||
group.m_obb = it->m_obb;
|
group.m_obb = it->m_obb;
|
||||||
group.m_prims = it->m_prims;
|
group.m_prims = it->m_prims;
|
||||||
|
|
||||||
m_groups.push_back(group);
|
m_groups.push_back(group);
|
||||||
}
|
}
|
||||||
|
@ -1686,7 +1686,7 @@ bool clipTest(const float* _planes, uint8_t _planeNum, const Mesh& _mesh, const
|
||||||
{
|
{
|
||||||
const Group& group = *it;
|
const Group& group = *it;
|
||||||
|
|
||||||
Sphere sphere = group.m_sphere;
|
bx::Sphere sphere = group.m_sphere;
|
||||||
sphere.center.x = sphere.center.x * scale + _translate[0];
|
sphere.center.x = sphere.center.x * scale + _translate[0];
|
||||||
sphere.center.y = sphere.center.y * scale + _translate[1];
|
sphere.center.y = sphere.center.y * scale + _translate[1];
|
||||||
sphere.center.z = sphere.center.z * scale + _translate[2];
|
sphere.center.z = sphere.center.z * scale + _translate[2];
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <bx/bounds.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "bgfx_utils.h"
|
#include "bgfx_utils.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "bounds.h"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -679,7 +679,7 @@ public:
|
||||||
// Draw lights into light buffer.
|
// Draw lights into light buffer.
|
||||||
for (int32_t light = 0; light < m_numLights; ++light)
|
for (int32_t light = 0; light < m_numLights; ++light)
|
||||||
{
|
{
|
||||||
Sphere lightPosRadius;
|
bx::Sphere lightPosRadius;
|
||||||
|
|
||||||
float lightTime = time * m_lightAnimationSpeed * (bx::sin(light/float(m_numLights) * bx::kPiHalf ) * 0.5f + 0.5f);
|
float lightTime = time * m_lightAnimationSpeed * (bx::sin(light/float(m_numLights) * bx::kPiHalf ) * 0.5f + 0.5f);
|
||||||
lightPosRadius.center.x = bx::sin( ( (lightTime + light*0.47f) + bx::kPiHalf*1.37f ) )*offset;
|
lightPosRadius.center.x = bx::sin( ( (lightTime + light*0.47f) + bx::kPiHalf*1.37f ) )*offset;
|
||||||
|
@ -687,7 +687,7 @@ public:
|
||||||
lightPosRadius.center.z = bx::sin( ( (lightTime + light*0.37f) + bx::kPiHalf*1.57f ) )*2.0f;
|
lightPosRadius.center.z = bx::sin( ( (lightTime + light*0.37f) + bx::kPiHalf*1.57f ) )*2.0f;
|
||||||
lightPosRadius.radius = 2.0f;
|
lightPosRadius.radius = 2.0f;
|
||||||
|
|
||||||
Aabb aabb;
|
bx::Aabb aabb;
|
||||||
toAabb(aabb, lightPosRadius);
|
toAabb(aabb, lightPosRadius);
|
||||||
|
|
||||||
const bx::Vec3 box[8] =
|
const bx::Vec3 box[8] =
|
||||||
|
|
|
@ -3,14 +3,13 @@
|
||||||
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <bx/allocator.h>
|
||||||
|
#include <bx/debug.h>
|
||||||
|
#include <bx/math.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "bgfx_utils.h"
|
#include "bgfx_utils.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "bounds.h"
|
|
||||||
#include <bx/allocator.h>
|
|
||||||
#include <bx/debug.h>
|
|
||||||
#include <bx/math.h>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
|
@ -485,15 +485,15 @@ struct Shape
|
||||||
};
|
};
|
||||||
|
|
||||||
Shape() : type(uint8_t(Type::Count) ) {}
|
Shape() : type(uint8_t(Type::Count) ) {}
|
||||||
Shape(const Aabb & _a) : type(uint8_t(Type::Aabb ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Aabb & _a) : type(uint8_t(Type::Aabb ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
Shape(const Capsule & _a) : type(uint8_t(Type::Capsule ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Capsule & _a) : type(uint8_t(Type::Capsule ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
Shape(const Cone & _a) : type(uint8_t(Type::Cone ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Cone & _a) : type(uint8_t(Type::Cone ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
Shape(const Cylinder & _a) : type(uint8_t(Type::Cylinder) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Cylinder & _a) : type(uint8_t(Type::Cylinder) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
Shape(const Disk & _a) : type(uint8_t(Type::Disk ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Disk & _a) : type(uint8_t(Type::Disk ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
Shape(const Obb & _a) : type(uint8_t(Type::Obb ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Obb & _a) : type(uint8_t(Type::Obb ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
Shape(const bx::Plane& _a) : type(uint8_t(Type::Plane ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Plane & _a) : type(uint8_t(Type::Plane ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
Shape(const Sphere & _a) : type(uint8_t(Type::Sphere ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Sphere & _a) : type(uint8_t(Type::Sphere ) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
Shape(const Triangle & _a) : type(uint8_t(Type::Triangle) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
Shape(const bx::Triangle & _a) : type(uint8_t(Type::Triangle) ) { bx::memCopy(data, &_a, sizeof(_a) ); }
|
||||||
|
|
||||||
uint8_t data[64];
|
uint8_t data[64];
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
|
@ -504,28 +504,28 @@ struct Shape
|
||||||
{ \
|
{ \
|
||||||
switch (_shapeB.type) \
|
switch (_shapeB.type) \
|
||||||
{ \
|
{ \
|
||||||
case Shape::Type::Aabb: return ::overlap(_shapeA, *reinterpret_cast<const Aabb *>(_shapeB.data) ); \
|
case Shape::Type::Aabb: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Aabb *>(_shapeB.data) ); \
|
||||||
case Shape::Type::Capsule: return ::overlap(_shapeA, *reinterpret_cast<const Capsule *>(_shapeB.data) ); \
|
case Shape::Type::Capsule: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Capsule *>(_shapeB.data) ); \
|
||||||
case Shape::Type::Cone: return ::overlap(_shapeA, *reinterpret_cast<const Cone *>(_shapeB.data) ); \
|
case Shape::Type::Cone: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Cone *>(_shapeB.data) ); \
|
||||||
case Shape::Type::Cylinder: return ::overlap(_shapeA, *reinterpret_cast<const Cylinder *>(_shapeB.data) ); \
|
case Shape::Type::Cylinder: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Cylinder *>(_shapeB.data) ); \
|
||||||
case Shape::Type::Disk: return ::overlap(_shapeA, *reinterpret_cast<const Disk *>(_shapeB.data) ); \
|
case Shape::Type::Disk: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Disk *>(_shapeB.data) ); \
|
||||||
case Shape::Type::Obb: return ::overlap(_shapeA, *reinterpret_cast<const Obb *>(_shapeB.data) ); \
|
case Shape::Type::Obb: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Obb *>(_shapeB.data) ); \
|
||||||
case Shape::Type::Plane: return ::overlap(_shapeA, *reinterpret_cast<const bx::Plane*>(_shapeB.data) ); \
|
case Shape::Type::Plane: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Plane *>(_shapeB.data) ); \
|
||||||
case Shape::Type::Sphere: return ::overlap(_shapeA, *reinterpret_cast<const Sphere *>(_shapeB.data) ); \
|
case Shape::Type::Sphere: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Sphere *>(_shapeB.data) ); \
|
||||||
case Shape::Type::Triangle: return ::overlap(_shapeA, *reinterpret_cast<const Triangle *>(_shapeB.data) ); \
|
case Shape::Type::Triangle: return bx::overlap(_shapeA, *reinterpret_cast<const bx::Triangle *>(_shapeB.data) ); \
|
||||||
} \
|
} \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
OVERLAP(Aabb);
|
OVERLAP(bx::Aabb);
|
||||||
OVERLAP(Capsule);
|
OVERLAP(bx::Capsule);
|
||||||
OVERLAP(Cone);
|
OVERLAP(bx::Cone);
|
||||||
OVERLAP(Cylinder);
|
OVERLAP(bx::Cylinder);
|
||||||
OVERLAP(Disk);
|
OVERLAP(bx::Disk);
|
||||||
OVERLAP(Obb);
|
OVERLAP(bx::Obb);
|
||||||
OVERLAP(bx::Plane);
|
OVERLAP(bx::Plane);
|
||||||
OVERLAP(Sphere);
|
OVERLAP(bx::Sphere);
|
||||||
OVERLAP(Triangle);
|
OVERLAP(bx::Triangle);
|
||||||
|
|
||||||
#undef OVERLAP
|
#undef OVERLAP
|
||||||
|
|
||||||
|
@ -535,14 +535,14 @@ void initA(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
{
|
{
|
||||||
case Shape::Type::Aabb:
|
case Shape::Type::Aabb:
|
||||||
{
|
{
|
||||||
Aabb aabb;
|
bx::Aabb aabb;
|
||||||
toAabb(aabb, _pos, { 0.5f, 0.5f, 0.5f });
|
toAabb(aabb, _pos, { 0.5f, 0.5f, 0.5f });
|
||||||
_outShape = Shape(aabb);
|
_outShape = Shape(aabb);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Capsule:
|
case Shape::Type::Capsule:
|
||||||
_outShape = Shape(Capsule
|
_outShape = Shape(bx::Capsule
|
||||||
{
|
{
|
||||||
{ bx::add(_pos, {0.0f, -1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, -1.0f, 0.0f}) },
|
||||||
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
||||||
|
@ -551,7 +551,7 @@ void initA(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Cone:
|
case Shape::Type::Cone:
|
||||||
_outShape = Shape(Cone
|
_outShape = Shape(bx::Cone
|
||||||
{
|
{
|
||||||
{ bx::add(_pos, {0.0f, -1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, -1.0f, 0.0f}) },
|
||||||
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
||||||
|
@ -560,7 +560,7 @@ void initA(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Cylinder:
|
case Shape::Type::Cylinder:
|
||||||
_outShape = Shape(Cylinder
|
_outShape = Shape(bx::Cylinder
|
||||||
{
|
{
|
||||||
{ bx::add(_pos, {0.0f, -1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, -1.0f, 0.0f}) },
|
||||||
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
||||||
|
@ -569,7 +569,7 @@ void initA(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Disk:
|
case Shape::Type::Disk:
|
||||||
_outShape = Shape(Disk
|
_outShape = Shape(bx::Disk
|
||||||
{
|
{
|
||||||
_pos,
|
_pos,
|
||||||
bx::normalize(bx::Vec3{0.0f, 1.0f, 1.0f}),
|
bx::normalize(bx::Vec3{0.0f, 1.0f, 1.0f}),
|
||||||
|
@ -579,7 +579,7 @@ void initA(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
|
|
||||||
case Shape::Type::Obb:
|
case Shape::Type::Obb:
|
||||||
{
|
{
|
||||||
Obb obb;
|
bx::Obb obb;
|
||||||
bx::mtxSRT(obb.mtx
|
bx::mtxSRT(obb.mtx
|
||||||
, 0.25f
|
, 0.25f
|
||||||
, 1.0f
|
, 1.0f
|
||||||
|
@ -596,7 +596,7 @@ void initA(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Sphere:
|
case Shape::Type::Sphere:
|
||||||
_outShape = Shape(Sphere{_pos, 0.5f});
|
_outShape = Shape(bx::Sphere{_pos, 0.5f});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Plane:
|
case Shape::Type::Plane:
|
||||||
|
@ -608,7 +608,7 @@ void initA(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Triangle:
|
case Shape::Type::Triangle:
|
||||||
_outShape = Shape(Triangle
|
_outShape = Shape(bx::Triangle
|
||||||
{
|
{
|
||||||
{ bx::add(_pos, {-0.4f, 0.0f, -0.4f}) },
|
{ bx::add(_pos, {-0.4f, 0.0f, -0.4f}) },
|
||||||
{ bx::add(_pos, { 0.0f, -0.3f, 0.5f}) },
|
{ bx::add(_pos, { 0.0f, -0.3f, 0.5f}) },
|
||||||
|
@ -626,14 +626,14 @@ void initB(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
{
|
{
|
||||||
case Shape::Type::Aabb:
|
case Shape::Type::Aabb:
|
||||||
{
|
{
|
||||||
Aabb aabb;
|
bx::Aabb aabb;
|
||||||
toAabb(aabb, _pos, { 0.5f, 0.5f, 0.5f });
|
toAabb(aabb, _pos, { 0.5f, 0.5f, 0.5f });
|
||||||
_outShape = Shape(aabb);
|
_outShape = Shape(aabb);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Capsule:
|
case Shape::Type::Capsule:
|
||||||
_outShape = Shape(Capsule
|
_outShape = Shape(bx::Capsule
|
||||||
{
|
{
|
||||||
{ bx::add(_pos, {0.0f, -1.0f, 0.1f}) },
|
{ bx::add(_pos, {0.0f, -1.0f, 0.1f}) },
|
||||||
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
||||||
|
@ -642,7 +642,7 @@ void initB(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Cone:
|
case Shape::Type::Cone:
|
||||||
_outShape = Shape(Cone
|
_outShape = Shape(bx::Cone
|
||||||
{
|
{
|
||||||
{ bx::add(_pos, {0.0f, -1.0f, 0.1f}) },
|
{ bx::add(_pos, {0.0f, -1.0f, 0.1f}) },
|
||||||
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
||||||
|
@ -651,7 +651,7 @@ void initB(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Cylinder:
|
case Shape::Type::Cylinder:
|
||||||
_outShape = Shape(Cylinder
|
_outShape = Shape(bx::Cylinder
|
||||||
{
|
{
|
||||||
{ bx::add(_pos, {0.0f, -1.0f, 0.1f}) },
|
{ bx::add(_pos, {0.0f, -1.0f, 0.1f}) },
|
||||||
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
{ bx::add(_pos, {0.0f, 1.0f, 0.0f}) },
|
||||||
|
@ -660,7 +660,7 @@ void initB(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Disk:
|
case Shape::Type::Disk:
|
||||||
_outShape = Shape(Disk
|
_outShape = Shape(bx::Disk
|
||||||
{
|
{
|
||||||
_pos,
|
_pos,
|
||||||
bx::normalize(bx::Vec3{1.0f, 1.0f, 0.0f}),
|
bx::normalize(bx::Vec3{1.0f, 1.0f, 0.0f}),
|
||||||
|
@ -670,7 +670,7 @@ void initB(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
|
|
||||||
case Shape::Type::Obb:
|
case Shape::Type::Obb:
|
||||||
{
|
{
|
||||||
Obb obb;
|
bx::Obb obb;
|
||||||
bx::mtxSRT(obb.mtx
|
bx::mtxSRT(obb.mtx
|
||||||
, 1.0f
|
, 1.0f
|
||||||
, 0.25f
|
, 0.25f
|
||||||
|
@ -695,11 +695,11 @@ void initB(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Sphere:
|
case Shape::Type::Sphere:
|
||||||
_outShape = Shape(Sphere{_pos, 0.5f});
|
_outShape = Shape(bx::Sphere{_pos, 0.5f});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shape::Type::Triangle:
|
case Shape::Type::Triangle:
|
||||||
_outShape = Shape(Triangle
|
_outShape = Shape(bx::Triangle
|
||||||
{
|
{
|
||||||
{ bx::add(_pos, {-0.4f, 0.0f, -0.4f}) },
|
{ bx::add(_pos, {-0.4f, 0.0f, -0.4f}) },
|
||||||
{ bx::add(_pos, {-0.5f, -0.3f, 0.0f}) },
|
{ bx::add(_pos, {-0.5f, -0.3f, 0.0f}) },
|
||||||
|
@ -715,15 +715,15 @@ int32_t overlap(const Shape& _shapeA, const Shape& _shapeB)
|
||||||
{
|
{
|
||||||
switch (_shapeA.type)
|
switch (_shapeA.type)
|
||||||
{
|
{
|
||||||
case Shape::Type::Aabb: return overlap(*reinterpret_cast<const Aabb *>(_shapeA.data), _shapeB);
|
case Shape::Type::Aabb: return ::overlap(*reinterpret_cast<const bx::Aabb *>(_shapeA.data), _shapeB);
|
||||||
case Shape::Type::Capsule: return overlap(*reinterpret_cast<const Capsule *>(_shapeA.data), _shapeB);
|
case Shape::Type::Capsule: return ::overlap(*reinterpret_cast<const bx::Capsule *>(_shapeA.data), _shapeB);
|
||||||
case Shape::Type::Cone: return overlap(*reinterpret_cast<const Cone *>(_shapeA.data), _shapeB);
|
case Shape::Type::Cone: return ::overlap(*reinterpret_cast<const bx::Cone *>(_shapeA.data), _shapeB);
|
||||||
case Shape::Type::Cylinder: return overlap(*reinterpret_cast<const Cylinder *>(_shapeA.data), _shapeB);
|
case Shape::Type::Cylinder: return ::overlap(*reinterpret_cast<const bx::Cylinder *>(_shapeA.data), _shapeB);
|
||||||
case Shape::Type::Disk: return overlap(*reinterpret_cast<const Disk *>(_shapeA.data), _shapeB);
|
case Shape::Type::Disk: return ::overlap(*reinterpret_cast<const bx::Disk *>(_shapeA.data), _shapeB);
|
||||||
case Shape::Type::Obb: return overlap(*reinterpret_cast<const Obb *>(_shapeA.data), _shapeB);
|
case Shape::Type::Obb: return ::overlap(*reinterpret_cast<const bx::Obb *>(_shapeA.data), _shapeB);
|
||||||
case Shape::Type::Plane: return overlap(*reinterpret_cast<const bx::Plane*>(_shapeA.data), _shapeB);
|
case Shape::Type::Plane: return ::overlap(*reinterpret_cast<const bx::Plane *>(_shapeA.data), _shapeB);
|
||||||
case Shape::Type::Sphere: return overlap(*reinterpret_cast<const Sphere *>(_shapeA.data), _shapeB);
|
case Shape::Type::Sphere: return ::overlap(*reinterpret_cast<const bx::Sphere *>(_shapeA.data), _shapeB);
|
||||||
case Shape::Type::Triangle: return overlap(*reinterpret_cast<const Triangle *>(_shapeA.data), _shapeB);
|
case Shape::Type::Triangle: return ::overlap(*reinterpret_cast<const bx::Triangle *>(_shapeA.data), _shapeB);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -733,15 +733,15 @@ void draw(DebugDrawEncoder& _dde, const Shape& _shape, const bx::Vec3 _pos)
|
||||||
{
|
{
|
||||||
switch (_shape.type)
|
switch (_shape.type)
|
||||||
{
|
{
|
||||||
case Shape::Type::Aabb: _dde.draw (*reinterpret_cast<const Aabb *>(_shape.data) ); break;
|
case Shape::Type::Aabb: _dde.draw (*reinterpret_cast<const bx::Aabb *>(_shape.data) ); break;
|
||||||
case Shape::Type::Capsule: _dde.draw (*reinterpret_cast<const Capsule *>(_shape.data) ); break;
|
case Shape::Type::Capsule: _dde.draw (*reinterpret_cast<const bx::Capsule *>(_shape.data) ); break;
|
||||||
case Shape::Type::Cone: _dde.draw (*reinterpret_cast<const Cone *>(_shape.data) ); break;
|
case Shape::Type::Cone: _dde.draw (*reinterpret_cast<const bx::Cone *>(_shape.data) ); break;
|
||||||
case Shape::Type::Cylinder: _dde.draw (*reinterpret_cast<const Cylinder *>(_shape.data) ); break;
|
case Shape::Type::Cylinder: _dde.draw (*reinterpret_cast<const bx::Cylinder *>(_shape.data) ); break;
|
||||||
case Shape::Type::Disk: _dde.draw (*reinterpret_cast<const Disk *>(_shape.data) ); break;
|
case Shape::Type::Disk: _dde.draw (*reinterpret_cast<const bx::Disk *>(_shape.data) ); break;
|
||||||
case Shape::Type::Obb: _dde.draw (*reinterpret_cast<const Obb *>(_shape.data) ); break;
|
case Shape::Type::Obb: _dde.draw (*reinterpret_cast<const bx::Obb *>(_shape.data) ); break;
|
||||||
case Shape::Type::Plane: { _dde.drawGrid( reinterpret_cast<const bx::Plane*>(_shape.data)->normal, _pos, 9, 0.3f); } break;
|
case Shape::Type::Plane: { _dde.drawGrid( reinterpret_cast<const bx::Plane *>(_shape.data)->normal, _pos, 9, 0.3f); } break;
|
||||||
case Shape::Type::Sphere: _dde.draw (*reinterpret_cast<const Sphere *>(_shape.data) ); break;
|
case Shape::Type::Sphere: _dde.draw (*reinterpret_cast<const bx::Sphere *>(_shape.data) ); break;
|
||||||
case Shape::Type::Triangle: _dde.draw (*reinterpret_cast<const Triangle *>(_shape.data) ); break;
|
case Shape::Type::Triangle: _dde.draw (*reinterpret_cast<const bx::Triangle *>(_shape.data) ); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -835,10 +835,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Ty>
|
template<typename Ty>
|
||||||
bool intersect(DebugDrawEncoder* _dde, const Ray& _ray, const Ty& _shape)
|
bool intersect(DebugDrawEncoder* _dde, const bx::Ray& _ray, const Ty& _shape)
|
||||||
{
|
{
|
||||||
Hit hit;
|
bx::Hit hit;
|
||||||
if (::intersect(_ray, _shape, &hit) )
|
if (bx::intersect(_ray, _shape, &hit) )
|
||||||
{
|
{
|
||||||
_dde->push();
|
_dde->push();
|
||||||
|
|
||||||
|
@ -931,7 +931,7 @@ public:
|
||||||
bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f, bgfx::getCaps()->homogeneousDepth);
|
bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f, bgfx::getCaps()->homogeneousDepth);
|
||||||
bx::mtxMul(mtxVp, view, proj);
|
bx::mtxMul(mtxVp, view, proj);
|
||||||
|
|
||||||
Ray ray = makeRay(
|
bx::Ray ray = bx::makeRay(
|
||||||
(float(m_mouseState.m_mx)/float(m_width) * 2.0f - 1.0f)
|
(float(m_mouseState.m_mx)/float(m_width) * 2.0f - 1.0f)
|
||||||
, -(float(m_mouseState.m_my)/float(m_height) * 2.0f - 1.0f)
|
, -(float(m_mouseState.m_my)/float(m_height) * 2.0f - 1.0f)
|
||||||
, mtxInvVp
|
, mtxInvVp
|
||||||
|
@ -947,7 +947,7 @@ public:
|
||||||
dde.drawAxis(0.0f, 0.0f, 0.0f);
|
dde.drawAxis(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
dde.push();
|
dde.push();
|
||||||
Aabb aabb =
|
bx::Aabb aabb =
|
||||||
{
|
{
|
||||||
{ 5.0f, 1.0f, 1.0f },
|
{ 5.0f, 1.0f, 1.0f },
|
||||||
{ 10.0f, 5.0f, 5.0f },
|
{ 10.0f, 5.0f, 5.0f },
|
||||||
|
@ -960,7 +960,7 @@ public:
|
||||||
static float time = 0.0f;
|
static float time = 0.0f;
|
||||||
time += deltaTime*timeScale;
|
time += deltaTime*timeScale;
|
||||||
|
|
||||||
Obb obb;
|
bx::Obb obb;
|
||||||
bx::mtxRotateX(obb.mtx, time);
|
bx::mtxRotateX(obb.mtx, time);
|
||||||
dde.setWireframe(true);
|
dde.setWireframe(true);
|
||||||
dde.setColor(intersect(&dde, ray, obb) ? kSelected : 0xffffffff);
|
dde.setColor(intersect(&dde, ray, obb) ? kSelected : 0xffffffff);
|
||||||
|
@ -969,7 +969,7 @@ public:
|
||||||
bx::mtxSRT(obb.mtx, 1.0f, 1.0f, 1.0f, time*0.23f, time, 0.0f, 3.0f, 0.0f, 0.0f);
|
bx::mtxSRT(obb.mtx, 1.0f, 1.0f, 1.0f, time*0.23f, time, 0.0f, 3.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
dde.push();
|
dde.push();
|
||||||
toAabb(aabb, obb);
|
bx::toAabb(aabb, obb);
|
||||||
dde.setWireframe(true);
|
dde.setWireframe(true);
|
||||||
dde.setColor(0xff0000ff);
|
dde.setColor(0xff0000ff);
|
||||||
dde.draw(aabb);
|
dde.draw(aabb);
|
||||||
|
@ -1014,7 +1014,7 @@ public:
|
||||||
dde.drawFrustum(mtxVp);
|
dde.drawFrustum(mtxVp);
|
||||||
|
|
||||||
dde.push();
|
dde.push();
|
||||||
Sphere sphere = { { 0.0f, 5.0f, 0.0f }, 1.0f };
|
bx::Sphere sphere = { { 0.0f, 5.0f, 0.0f }, 1.0f };
|
||||||
dde.setColor(intersect(&dde, ray, sphere) ? kSelected : 0xfff0c0ff);
|
dde.setColor(intersect(&dde, ray, sphere) ? kSelected : 0xfff0c0ff);
|
||||||
dde.setWireframe(true);
|
dde.setWireframe(true);
|
||||||
dde.setLod(3);
|
dde.setLod(3);
|
||||||
|
@ -1065,14 +1065,14 @@ public:
|
||||||
dde.push();
|
dde.push();
|
||||||
dde.setSpin(time*0.3f);
|
dde.setSpin(time*0.3f);
|
||||||
{
|
{
|
||||||
Cone cone =
|
bx::Cone cone =
|
||||||
{
|
{
|
||||||
{ -11.0f, 4.0f, 0.0f },
|
{ -11.0f, 4.0f, 0.0f },
|
||||||
{ -13.0f, 6.0f, 1.0f },
|
{ -13.0f, 6.0f, 1.0f },
|
||||||
1.0f
|
1.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
Cylinder cylinder =
|
bx::Cylinder cylinder =
|
||||||
{
|
{
|
||||||
{ -9.0f, 2.0f, -1.0f },
|
{ -9.0f, 2.0f, -1.0f },
|
||||||
{ -11.0f, 4.0f, 0.0f },
|
{ -11.0f, 4.0f, 0.0f },
|
||||||
|
@ -1093,7 +1093,7 @@ public:
|
||||||
|
|
||||||
{
|
{
|
||||||
dde.setLod(0);
|
dde.setLod(0);
|
||||||
Capsule capsule =
|
bx::Capsule capsule =
|
||||||
{
|
{
|
||||||
{ 0.0f, 7.0f, 0.0f },
|
{ 0.0f, 7.0f, 0.0f },
|
||||||
{ -6.0f, 7.0f, 0.0f },
|
{ -6.0f, 7.0f, 0.0f },
|
||||||
|
@ -1113,7 +1113,7 @@ public:
|
||||||
, -10.0f, 1.0f, 10.0f
|
, -10.0f, 1.0f, 10.0f
|
||||||
);
|
);
|
||||||
|
|
||||||
Cylinder cylinder =
|
bx::Cylinder cylinder =
|
||||||
{
|
{
|
||||||
{ -10.0f, 1.0f, 10.0f },
|
{ -10.0f, 1.0f, 10.0f },
|
||||||
{ 0.0f, 0.0f, 0.0f },
|
{ 0.0f, 0.0f, 0.0f },
|
||||||
|
|
|
@ -417,7 +417,7 @@ public:
|
||||||
|
|
||||||
if (showBounds)
|
if (showBounds)
|
||||||
{
|
{
|
||||||
Aabb aabb;
|
bx::Aabb aabb;
|
||||||
psGetAabb(m_emitter[currentEmitter].m_handle, aabb);
|
psGetAabb(m_emitter[currentEmitter].m_handle, aabb);
|
||||||
dde.push();
|
dde.push();
|
||||||
dde.setWireframe(true);
|
dde.setWireframe(true);
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
#include "bgfx_utils.h"
|
#include "bgfx_utils.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "bounds.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "bgfx_utils.h"
|
#include "bgfx_utils.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "bounds.h"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "bgfx_utils.h"
|
#include "bgfx_utils.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "bounds.h"
|
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <bx/math.h>
|
#include <bx/math.h>
|
||||||
|
|
||||||
#include "bgfx_utils.h"
|
#include "bgfx_utils.h"
|
||||||
#include "bounds.h"
|
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
#ifndef BGFX_UTILS_H_HEADER_GUARD
|
#ifndef BGFX_UTILS_H_HEADER_GUARD
|
||||||
#define BGFX_UTILS_H_HEADER_GUARD
|
#define BGFX_UTILS_H_HEADER_GUARD
|
||||||
|
|
||||||
|
#include <bx/bounds.h>
|
||||||
#include <bx/pixelformat.h>
|
#include <bx/pixelformat.h>
|
||||||
#include <bx/string.h>
|
#include <bx/string.h>
|
||||||
#include <bgfx/bgfx.h>
|
#include <bgfx/bgfx.h>
|
||||||
#include <bimg/bimg.h>
|
#include <bimg/bimg.h>
|
||||||
#include "bounds.h"
|
|
||||||
|
|
||||||
#include <tinystl/allocator.h>
|
#include <tinystl/allocator.h>
|
||||||
#include <tinystl/vector.h>
|
#include <tinystl/vector.h>
|
||||||
|
@ -92,9 +92,9 @@ struct Primitive
|
||||||
uint32_t m_startVertex;
|
uint32_t m_startVertex;
|
||||||
uint32_t m_numVertices;
|
uint32_t m_numVertices;
|
||||||
|
|
||||||
Sphere m_sphere;
|
bx::Sphere m_sphere;
|
||||||
Aabb m_aabb;
|
bx::Aabb m_aabb;
|
||||||
Obb m_obb;
|
bx::Obb m_obb;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef stl::vector<Primitive> PrimitiveArray;
|
typedef stl::vector<Primitive> PrimitiveArray;
|
||||||
|
@ -110,9 +110,9 @@ struct Group
|
||||||
uint8_t* m_vertices;
|
uint8_t* m_vertices;
|
||||||
uint32_t m_numIndices;
|
uint32_t m_numIndices;
|
||||||
uint16_t* m_indices;
|
uint16_t* m_indices;
|
||||||
Sphere m_sphere;
|
bx::Sphere m_sphere;
|
||||||
Aabb m_aabb;
|
bx::Aabb m_aabb;
|
||||||
Obb m_obb;
|
bx::Obb m_obb;
|
||||||
PrimitiveArray m_prims;
|
PrimitiveArray m_prims;
|
||||||
};
|
};
|
||||||
typedef stl::vector<Group> GroupArray;
|
typedef stl::vector<Group> GroupArray;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,456 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
|
||||||
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BOUNDS_H_HEADER_GUARD
|
|
||||||
#define BOUNDS_H_HEADER_GUARD
|
|
||||||
|
|
||||||
#include <bx/math.h>
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Aabb
|
|
||||||
{
|
|
||||||
bx::Vec3 min = bx::init::None;
|
|
||||||
bx::Vec3 max = bx::init::None;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Capsule
|
|
||||||
{
|
|
||||||
bx::Vec3 pos = bx::init::None;
|
|
||||||
bx::Vec3 end = bx::init::None;
|
|
||||||
float radius;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Cone
|
|
||||||
{
|
|
||||||
bx::Vec3 pos = bx::init::None;
|
|
||||||
bx::Vec3 end = bx::init::None;
|
|
||||||
float radius;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Cylinder
|
|
||||||
{
|
|
||||||
bx::Vec3 pos = bx::init::None;
|
|
||||||
bx::Vec3 end = bx::init::None;
|
|
||||||
float radius;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Disk
|
|
||||||
{
|
|
||||||
bx::Vec3 center = bx::init::None;
|
|
||||||
bx::Vec3 normal = bx::init::None;
|
|
||||||
float radius;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Obb
|
|
||||||
{
|
|
||||||
float mtx[16];
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Sphere
|
|
||||||
{
|
|
||||||
bx::Vec3 center = bx::init::None;
|
|
||||||
float radius;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Triangle
|
|
||||||
{
|
|
||||||
bx::Vec3 v0 = bx::init::None;
|
|
||||||
bx::Vec3 v1 = bx::init::None;
|
|
||||||
bx::Vec3 v2 = bx::init::None;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Ray
|
|
||||||
{
|
|
||||||
bx::Vec3 pos = bx::init::None;
|
|
||||||
bx::Vec3 dir = bx::init::None;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
struct Hit
|
|
||||||
{
|
|
||||||
bx::Vec3 pos = bx::init::None;
|
|
||||||
bx::Plane plane = bx::init::None;
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
bx::Vec3 getPointAt(const Ray& _ray, float _t);
|
|
||||||
|
|
||||||
///
|
|
||||||
bx::Vec3 getCenter(const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bx::Vec3 getExtents(const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bx::Vec3 getCenter(const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
void toAabb(Aabb& _outAabb, const bx::Vec3& _extents);
|
|
||||||
|
|
||||||
///
|
|
||||||
void toAabb(Aabb& _outAabb, const bx::Vec3& _center, const bx::Vec3& _extents);
|
|
||||||
|
|
||||||
/// Convert cylinder to axis aligned bounding box.
|
|
||||||
void toAabb(Aabb& _outAabb, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
/// Convert disk to axis aligned bounding box.
|
|
||||||
void toAabb(Aabb& _outAabb, const Disk& _disk);
|
|
||||||
|
|
||||||
/// Convert oriented bounding box to axis aligned bounding box.
|
|
||||||
void toAabb(Aabb& _outAabb, const Obb& _obb);
|
|
||||||
|
|
||||||
/// Convert sphere to axis aligned bounding box.
|
|
||||||
void toAabb(Aabb& _outAabb, const Sphere& _sphere);
|
|
||||||
|
|
||||||
/// Convert triangle to axis aligned bounding box.
|
|
||||||
void toAabb(Aabb& _outAabb, const Triangle& _triangle);
|
|
||||||
|
|
||||||
/// Calculate axis aligned bounding box.
|
|
||||||
void toAabb(Aabb& _outAabb, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
|
|
||||||
|
|
||||||
/// Transform vertices and calculate axis aligned bounding box.
|
|
||||||
void toAabb(Aabb& _outAabb, const float* _mtx, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
|
|
||||||
|
|
||||||
/// Expand AABB.
|
|
||||||
void aabbExpand(Aabb& _outAabb, float _factor);
|
|
||||||
|
|
||||||
/// Expand AABB with xyz.
|
|
||||||
void aabbExpand(Aabb& _outAabb, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
/// Calculate surface area of axis aligned bounding box.
|
|
||||||
float calcAreaAabb(const Aabb& _aabb);
|
|
||||||
|
|
||||||
/// Convert axis aligned bounding box to oriented bounding box.
|
|
||||||
void toObb(Obb& _outObb, const Aabb& _aabb);
|
|
||||||
|
|
||||||
/// Calculate oriented bounding box.
|
|
||||||
void calcObb(Obb& _outObb, const void* _vertices, uint32_t _numVertices, uint32_t _stride, uint32_t _steps = 17);
|
|
||||||
|
|
||||||
/// Calculate maximum bounding sphere.
|
|
||||||
void calcMaxBoundingSphere(Sphere& _outSphere, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
|
|
||||||
|
|
||||||
/// Calculate minimum bounding sphere.
|
|
||||||
void calcMinBoundingSphere(Sphere& _outSphere, const void* _vertices, uint32_t _numVertices, uint32_t _stride, float _step = 0.01f);
|
|
||||||
|
|
||||||
/// Returns 6 (near, far, left, right, top, bottom) planes representing frustum planes.
|
|
||||||
void buildFrustumPlanes(bx::Plane* _outPlanes, const float* _viewProj);
|
|
||||||
|
|
||||||
/// Returns point from 3 intersecting planes.
|
|
||||||
bx::Vec3 intersectPlanes(const bx::Plane& _pa, const bx::Plane& _pb, const bx::Plane& _pc);
|
|
||||||
|
|
||||||
/// Make screen space ray from x, y coordinate and inverse view-projection matrix.
|
|
||||||
Ray makeRay(float _x, float _y, const float* _invVp);
|
|
||||||
|
|
||||||
/// Intersect ray / AABB.
|
|
||||||
bool intersect(const Ray& _ray, const Aabb& _aabb, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / OBB.
|
|
||||||
bool intersect(const Ray& _ray, const Obb& _obb, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / cylinder.
|
|
||||||
bool intersect(const Ray& _ray, const Cylinder& _cylinder, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / capsule.
|
|
||||||
bool intersect(const Ray& _ray, const Capsule& _capsule, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / cone.
|
|
||||||
bool intersect(const Ray& _ray, const Cone& _cone, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / disk.
|
|
||||||
bool intersect(const Ray& _ray, const Disk& _disk, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / plane.
|
|
||||||
bool intersect(const Ray& _ray, const bx::Plane& _plane, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / plane.
|
|
||||||
bool intersect(const Ray& _ray, const bx::Plane& _plane, bool _doublesided, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / sphere.
|
|
||||||
bool intersect(const Ray& _ray, const Sphere& _sphere, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
/// Intersect ray / triangle.
|
|
||||||
bool intersect(const Ray& _ray, const Triangle& _triangle, Hit* _hit = NULL);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const Sphere& _sphere);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabbA, const Aabb& _aabbB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const bx::Plane& _plane);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const Capsule& _capsule);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const Cone& _cone);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const Disk& _disk);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Aabb& _aabb, const Obb& _obb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const Sphere& _sphere);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const bx::Plane& _plane);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsuleA, const Capsule& _capsuleB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const Cone& _cone);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const Disk& _disk);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Capsule& _capsule, const Obb& _obb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const Sphere& _sphere);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const bx::Plane& _plane);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const Capsule& _capsule);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _coneA, const Cone& _coneB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const Disk& _disk);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cone& _cone, const Obb& _obb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const Sphere& _sphere);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const bx::Plane& _plane);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinderA, const Cylinder& _cylinderB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const Capsule& _capsule);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const Cone& _cone);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const Disk& _disk);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Cylinder& _cylinder, const Obb& _obb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const Sphere& _sphere);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const bx::Plane& _plane);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const Capsule& _capsule);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const Cone& _cone);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _diskA, const Disk& _diskB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Disk& _disk, const Obb& _obb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const Sphere& _sphere);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const bx::Plane& _plane);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const Capsule& _capsule);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const Cone& _cone);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obb, const Disk& _disk);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Obb& _obbA, const Obb& _obbB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const Sphere& _sphere);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _planeA, const bx::Plane& _planeB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const Capsule& _capsule);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const Cone& _cone);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const Disk& _disk);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const bx::Plane& _plane, const Obb& _obb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphereA, const Sphere& _sphereB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const bx::Plane& _plane);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const Triangle& _triangle);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const Capsule& _capsule);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const Cone& _cone);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const Disk& _disk);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Sphere& _sphere, const Obb& _obb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const bx::Vec3& _pos);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const Sphere& _sphere);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const Aabb& _aabb);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const bx::Plane& _plane);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangleA, const Triangle& _triangleB);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const Cylinder& _cylinder);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const Capsule& _capsule);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const Cone& _cone);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const Disk& _disk);
|
|
||||||
|
|
||||||
///
|
|
||||||
bool overlap(const Triangle& _triangle, const Obb& _obb);
|
|
||||||
|
|
||||||
#include "bounds.inl"
|
|
||||||
|
|
||||||
#endif // BOUNDS_H_HEADER_GUARD
|
|
|
@ -1,198 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
|
||||||
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BOUNDS_H_HEADER_GUARD
|
|
||||||
# error "Must be included from bounds.h!"
|
|
||||||
#endif // BOUNDS_H_HEADER_GUARD
|
|
||||||
|
|
||||||
inline bx::Vec3 getPointAt(const Ray& _ray, float _t)
|
|
||||||
{
|
|
||||||
return bx::mad(_ray.dir, _t, _ray.pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool intersect(const Ray& _ray, const bx::Plane& _plane, Hit* _hit)
|
|
||||||
{
|
|
||||||
return intersect(_ray, _plane, false, _hit);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Aabb& _aabb, const Sphere& _sphere)
|
|
||||||
{
|
|
||||||
return overlap(_sphere, _aabb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Aabb& _aabb, const Cylinder& _cylinder)
|
|
||||||
{
|
|
||||||
return overlap(_cylinder, _aabb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Capsule& _capsule, const Sphere& _sphere)
|
|
||||||
{
|
|
||||||
return overlap(_sphere, _capsule);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Capsule& _capsule, const Aabb& _aabb)
|
|
||||||
{
|
|
||||||
return overlap(_aabb, _capsule);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Capsule& _capsule, const Triangle& _triangle)
|
|
||||||
{
|
|
||||||
return overlap(_triangle, _capsule);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Capsule& _capsule, const Cone& _cone)
|
|
||||||
{
|
|
||||||
return overlap(_cone, _capsule);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Capsule& _capsule, const Cylinder& _cylinder)
|
|
||||||
{
|
|
||||||
return overlap(_cylinder, _capsule);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Capsule& _capsule, const Disk& _disk)
|
|
||||||
{
|
|
||||||
return overlap(_disk, _capsule);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Capsule& _capsule, const Obb& _obb)
|
|
||||||
{
|
|
||||||
return overlap(_obb, _capsule);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Cone& _cone, const Sphere& _sphere)
|
|
||||||
{
|
|
||||||
return overlap(_sphere, _cone);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Cone& _cone, const Aabb& _aabb)
|
|
||||||
{
|
|
||||||
return overlap(_aabb, _cone);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Cone& _cone, const bx::Plane& _plane)
|
|
||||||
{
|
|
||||||
return overlap(_plane, _cone);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Cone& _cone, const Triangle& _triangle)
|
|
||||||
{
|
|
||||||
return overlap(_triangle, _cone);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Cylinder& _cylinder, const Triangle& _triangle)
|
|
||||||
{
|
|
||||||
return overlap(_triangle, _cylinder);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Cylinder& _cylinder, const Cone& _cone)
|
|
||||||
{
|
|
||||||
return overlap(_cone, _cylinder);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Disk& _disk, const Sphere& _sphere)
|
|
||||||
{
|
|
||||||
return overlap(_sphere, _disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Disk& _disk, const Aabb& _aabb)
|
|
||||||
{
|
|
||||||
return overlap(_aabb, _disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Disk& _disk, const Triangle& _triangle)
|
|
||||||
{
|
|
||||||
return overlap(_triangle, _disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Disk& _disk, const Cylinder& _cylinder)
|
|
||||||
{
|
|
||||||
return overlap(_cylinder, _disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Disk& _disk, const Cone& _cone)
|
|
||||||
{
|
|
||||||
return overlap(_cone, _disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Obb& _obb, const Sphere& _sphere)
|
|
||||||
{
|
|
||||||
return overlap(_sphere, _obb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Obb& _obb, const Aabb& _aabb)
|
|
||||||
{
|
|
||||||
return overlap(_aabb, _obb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Obb& _obb, const Triangle& _triangle)
|
|
||||||
{
|
|
||||||
return overlap(_triangle, _obb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Obb& _obb, const Cylinder& _cylinder)
|
|
||||||
{
|
|
||||||
return overlap(_cylinder, _obb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Obb& _obb, const Cone& _cone)
|
|
||||||
{
|
|
||||||
return overlap(_cone, _obb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Obb& _obb, const Disk& _disk)
|
|
||||||
{
|
|
||||||
return overlap(_disk, _obb);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const bx::Plane& _plane, const Sphere& _sphere)
|
|
||||||
{
|
|
||||||
return overlap(_sphere, _plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const bx::Plane& _plane, const Aabb& _aabb)
|
|
||||||
{
|
|
||||||
return overlap(_aabb, _plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const bx::Plane& _plane, const Triangle& _triangle)
|
|
||||||
{
|
|
||||||
return overlap(_triangle, _plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const bx::Plane& _plane, const Cylinder& _cylinder)
|
|
||||||
{
|
|
||||||
return overlap(_cylinder, _plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const bx::Plane& _plane, const Capsule& _capsule)
|
|
||||||
{
|
|
||||||
return overlap(_capsule, _plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const bx::Plane& _plane, const Disk& _disk)
|
|
||||||
{
|
|
||||||
return overlap(_disk, _plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const bx::Plane& _plane, const Obb& _obb)
|
|
||||||
{
|
|
||||||
return overlap(_obb, _plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Sphere& _sphere, const Cylinder& _cylinder)
|
|
||||||
{
|
|
||||||
return overlap(_cylinder, _sphere);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Triangle& _triangle, const Sphere& _sphere)
|
|
||||||
{
|
|
||||||
return overlap(_sphere, _triangle);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool overlap(const Triangle& _triangle, const Aabb& _aabb)
|
|
||||||
{
|
|
||||||
return overlap(_aabb, _triangle);
|
|
||||||
}
|
|
|
@ -1383,7 +1383,7 @@ struct DebugDrawEncoderImpl
|
||||||
m_state = State::None;
|
m_state = State::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(const Aabb& _aabb)
|
void draw(const bx::Aabb& _aabb)
|
||||||
{
|
{
|
||||||
const Attrib& attrib = m_attrib[m_stack];
|
const Attrib& attrib = m_attrib[m_stack];
|
||||||
if (attrib.m_wireframe)
|
if (attrib.m_wireframe)
|
||||||
|
@ -1414,23 +1414,23 @@ struct DebugDrawEncoderImpl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Obb obb;
|
bx::Obb obb;
|
||||||
toObb(obb, _aabb);
|
toObb(obb, _aabb);
|
||||||
draw(DebugMesh::Cube, obb.mtx, 1, false);
|
draw(DebugMesh::Cube, obb.mtx, 1, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(const Cylinder& _cylinder, bool _capsule)
|
void draw(const bx::Cylinder& _cylinder, bool _capsule)
|
||||||
{
|
{
|
||||||
drawCylinder(_cylinder.pos, _cylinder.end, _cylinder.radius, _capsule);
|
drawCylinder(_cylinder.pos, _cylinder.end, _cylinder.radius, _capsule);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(const Disk& _disk)
|
void draw(const bx::Disk& _disk)
|
||||||
{
|
{
|
||||||
drawCircle(_disk.normal, _disk.center, _disk.radius, 0.0f);
|
drawCircle(_disk.normal, _disk.center, _disk.radius, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(const Obb& _obb)
|
void draw(const bx::Obb& _obb)
|
||||||
{
|
{
|
||||||
const Attrib& attrib = m_attrib[m_stack];
|
const Attrib& attrib = m_attrib[m_stack];
|
||||||
if (attrib.m_wireframe)
|
if (attrib.m_wireframe)
|
||||||
|
@ -1469,7 +1469,7 @@ struct DebugDrawEncoderImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(const Sphere& _sphere)
|
void draw(const bx::Sphere& _sphere)
|
||||||
{
|
{
|
||||||
const Attrib& attrib = m_attrib[m_stack];
|
const Attrib& attrib = m_attrib[m_stack];
|
||||||
float mtx[16];
|
float mtx[16];
|
||||||
|
@ -1491,7 +1491,7 @@ struct DebugDrawEncoderImpl
|
||||||
draw(DebugMesh::Enum(DebugMesh::Sphere0 + lod), mtx, 1, attrib.m_wireframe);
|
draw(DebugMesh::Enum(DebugMesh::Sphere0 + lod), mtx, 1, attrib.m_wireframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(const Triangle& _triangle)
|
void draw(const bx::Triangle& _triangle)
|
||||||
{
|
{
|
||||||
Attrib& attrib = m_attrib[m_stack];
|
Attrib& attrib = m_attrib[m_stack];
|
||||||
if (attrib.m_wireframe)
|
if (attrib.m_wireframe)
|
||||||
|
@ -1955,7 +1955,7 @@ struct DebugDrawEncoderImpl
|
||||||
;
|
;
|
||||||
draw(DebugMesh::Enum(DebugMesh::Capsule0 + lod), mtx[0], 2, attrib.m_wireframe);
|
draw(DebugMesh::Enum(DebugMesh::Capsule0 + lod), mtx[0], 2, attrib.m_wireframe);
|
||||||
|
|
||||||
Sphere sphere;
|
bx::Sphere sphere;
|
||||||
sphere.center = _from;
|
sphere.center = _from;
|
||||||
sphere.radius = _radius;
|
sphere.radius = _radius;
|
||||||
draw(sphere);
|
draw(sphere);
|
||||||
|
@ -2425,42 +2425,42 @@ void DebugDrawEncoder::close()
|
||||||
DEBUG_DRAW_ENCODER(close() );
|
DEBUG_DRAW_ENCODER(close() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDrawEncoder::draw(const Aabb& _aabb)
|
void DebugDrawEncoder::draw(const bx::Aabb& _aabb)
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_ENCODER(draw(_aabb) );
|
DEBUG_DRAW_ENCODER(draw(_aabb) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDrawEncoder::draw(const Cylinder& _cylinder)
|
void DebugDrawEncoder::draw(const bx::Cylinder& _cylinder)
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_ENCODER(draw(_cylinder, false) );
|
DEBUG_DRAW_ENCODER(draw(_cylinder, false) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDrawEncoder::draw(const Capsule& _capsule)
|
void DebugDrawEncoder::draw(const bx::Capsule& _capsule)
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_ENCODER(draw(*( (const Cylinder*)&_capsule), true) );
|
DEBUG_DRAW_ENCODER(draw(*( (const bx::Cylinder*)&_capsule), true) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDrawEncoder::draw(const Disk& _disk)
|
void DebugDrawEncoder::draw(const bx::Disk& _disk)
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_ENCODER(draw(_disk) );
|
DEBUG_DRAW_ENCODER(draw(_disk) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDrawEncoder::draw(const Obb& _obb)
|
void DebugDrawEncoder::draw(const bx::Obb& _obb)
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_ENCODER(draw(_obb) );
|
DEBUG_DRAW_ENCODER(draw(_obb) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDrawEncoder::draw(const Sphere& _sphere)
|
void DebugDrawEncoder::draw(const bx::Sphere& _sphere)
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_ENCODER(draw(_sphere) );
|
DEBUG_DRAW_ENCODER(draw(_sphere) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDrawEncoder::draw(const Triangle& _triangle)
|
void DebugDrawEncoder::draw(const bx::Triangle& _triangle)
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_ENCODER(draw(_triangle) );
|
DEBUG_DRAW_ENCODER(draw(_triangle) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugDrawEncoder::draw(const Cone& _cone)
|
void DebugDrawEncoder::draw(const bx::Cone& _cone)
|
||||||
{
|
{
|
||||||
DEBUG_DRAW_ENCODER(drawCone(_cone.pos, _cone.end, _cone.radius) );
|
DEBUG_DRAW_ENCODER(drawCone(_cone.pos, _cone.end, _cone.radius) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#define DEBUGDRAW_H_HEADER_GUARD
|
#define DEBUGDRAW_H_HEADER_GUARD
|
||||||
|
|
||||||
#include <bx/allocator.h>
|
#include <bx/allocator.h>
|
||||||
|
#include <bx/bounds.h>
|
||||||
#include <bgfx/bgfx.h>
|
#include <bgfx/bgfx.h>
|
||||||
#include "../bounds.h"
|
|
||||||
|
|
||||||
struct Axis
|
struct Axis
|
||||||
{
|
{
|
||||||
|
@ -121,28 +121,28 @@ struct DebugDrawEncoder
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(const Aabb& _aabb);
|
void draw(const bx::Aabb& _aabb);
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(const Cylinder& _cylinder);
|
void draw(const bx::Cylinder& _cylinder);
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(const Capsule& _capsule);
|
void draw(const bx::Capsule& _capsule);
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(const Disk& _disk);
|
void draw(const bx::Disk& _disk);
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(const Obb& _obb);
|
void draw(const bx::Obb& _obb);
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(const Sphere& _sphere);
|
void draw(const bx::Sphere& _sphere);
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(const Triangle& _triangle);
|
void draw(const bx::Triangle& _triangle);
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(const Cone& _cone);
|
void draw(const bx::Cone& _cone);
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw(GeometryHandle _handle);
|
void draw(GeometryHandle _handle);
|
||||||
|
|
|
@ -190,7 +190,7 @@ namespace ps
|
||||||
m_dt = 0.0f;
|
m_dt = 0.0f;
|
||||||
m_uniforms.reset();
|
m_uniforms.reset();
|
||||||
m_num = 0;
|
m_num = 0;
|
||||||
bx::memSet(&m_aabb, 0, sizeof(Aabb) );
|
bx::memSet(&m_aabb, 0, sizeof(bx::Aabb) );
|
||||||
|
|
||||||
m_rng.reset();
|
m_rng.reset();
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ namespace ps
|
||||||
bx::EaseFn easeBlend = bx::getEaseFunc(m_uniforms.m_easeBlend);
|
bx::EaseFn easeBlend = bx::getEaseFunc(m_uniforms.m_easeBlend);
|
||||||
bx::EaseFn easeScale = bx::getEaseFunc(m_uniforms.m_easeScale);
|
bx::EaseFn easeScale = bx::getEaseFunc(m_uniforms.m_easeScale);
|
||||||
|
|
||||||
Aabb aabb =
|
bx::Aabb aabb =
|
||||||
{
|
{
|
||||||
{ bx::kInfinity, bx::kInfinity, bx::kInfinity },
|
{ bx::kInfinity, bx::kInfinity, bx::kInfinity },
|
||||||
{ -bx::kInfinity, -bx::kInfinity, -bx::kInfinity },
|
{ -bx::kInfinity, -bx::kInfinity, -bx::kInfinity },
|
||||||
|
@ -425,7 +425,7 @@ namespace ps
|
||||||
bx::RngMwc m_rng;
|
bx::RngMwc m_rng;
|
||||||
EmitterUniforms m_uniforms;
|
EmitterUniforms m_uniforms;
|
||||||
|
|
||||||
Aabb m_aabb;
|
bx::Aabb m_aabb;
|
||||||
|
|
||||||
Particle* m_particles;
|
Particle* m_particles;
|
||||||
uint32_t m_num;
|
uint32_t m_num;
|
||||||
|
@ -643,7 +643,7 @@ namespace ps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAabb(EmitterHandle _handle, Aabb& _outAabb)
|
void getAabb(EmitterHandle _handle, bx::Aabb& _outAabb)
|
||||||
{
|
{
|
||||||
BX_ASSERT(m_emitterAlloc.isValid(_handle.idx)
|
BX_ASSERT(m_emitterAlloc.isValid(_handle.idx)
|
||||||
, "getAabb handle %d is not valid."
|
, "getAabb handle %d is not valid."
|
||||||
|
@ -730,7 +730,7 @@ void psUpdateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms)
|
||||||
s_ctx.updateEmitter(_handle, _uniforms);
|
s_ctx.updateEmitter(_handle, _uniforms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void psGetAabb(EmitterHandle _handle, Aabb& _outAabb)
|
void psGetAabb(EmitterHandle _handle, bx::Aabb& _outAabb)
|
||||||
{
|
{
|
||||||
s_ctx.getAabb(_handle, _outAabb);
|
s_ctx.getAabb(_handle, _outAabb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
#define PARTICLE_SYSTEM_H_HEADER_GUARD
|
#define PARTICLE_SYSTEM_H_HEADER_GUARD
|
||||||
|
|
||||||
#include <bx/allocator.h>
|
#include <bx/allocator.h>
|
||||||
|
#include <bx/bounds.h>
|
||||||
#include <bx/easing.h>
|
#include <bx/easing.h>
|
||||||
#include <bx/rng.h>
|
#include <bx/rng.h>
|
||||||
|
|
||||||
#include "../bounds.h"
|
|
||||||
|
|
||||||
struct EmitterHandle { uint16_t idx; };
|
struct EmitterHandle { uint16_t idx; };
|
||||||
struct EmitterSpriteHandle { uint16_t idx; };
|
struct EmitterSpriteHandle { uint16_t idx; };
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ EmitterHandle psCreateEmitter(EmitterShape::Enum _shape, EmitterDirection::Enum
|
||||||
void psUpdateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms = NULL);
|
void psUpdateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms = NULL);
|
||||||
|
|
||||||
///
|
///
|
||||||
void psGetAabb(EmitterHandle _handle, Aabb& _outAabb);
|
void psGetAabb(EmitterHandle _handle, bx::Aabb& _outAabb);
|
||||||
|
|
||||||
///
|
///
|
||||||
void psDestroyEmitter(EmitterHandle _handle);
|
void psDestroyEmitter(EmitterHandle _handle);
|
||||||
|
|
|
@ -307,11 +307,11 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _la
|
||||||
|
|
||||||
void write(bx::WriterI* _writer, const void* _vertices, uint32_t _numVertices, uint32_t _stride)
|
void write(bx::WriterI* _writer, const void* _vertices, uint32_t _numVertices, uint32_t _stride)
|
||||||
{
|
{
|
||||||
Sphere maxSphere;
|
bx::Sphere maxSphere;
|
||||||
calcMaxBoundingSphere(maxSphere, _vertices, _numVertices, _stride);
|
bx::calcMaxBoundingSphere(maxSphere, _vertices, _numVertices, _stride);
|
||||||
|
|
||||||
Sphere minSphere;
|
bx::Sphere minSphere;
|
||||||
calcMinBoundingSphere(minSphere, _vertices, _numVertices, _stride);
|
bx::calcMinBoundingSphere(minSphere, _vertices, _numVertices, _stride);
|
||||||
|
|
||||||
if (minSphere.radius > maxSphere.radius)
|
if (minSphere.radius > maxSphere.radius)
|
||||||
{
|
{
|
||||||
|
@ -322,12 +322,12 @@ void write(bx::WriterI* _writer, const void* _vertices, uint32_t _numVertices, u
|
||||||
bx::write(_writer, minSphere);
|
bx::write(_writer, minSphere);
|
||||||
}
|
}
|
||||||
|
|
||||||
Aabb aabb;
|
bx::Aabb aabb;
|
||||||
toAabb(aabb, _vertices, _numVertices, _stride);
|
bx::toAabb(aabb, _vertices, _numVertices, _stride);
|
||||||
bx::write(_writer, aabb);
|
bx::write(_writer, aabb);
|
||||||
|
|
||||||
Obb obb;
|
bx::Obb obb;
|
||||||
calcObb(obb, _vertices, _numVertices, _stride, s_obbSteps);
|
bx::calcObb(obb, _vertices, _numVertices, _stride, s_obbSteps);
|
||||||
bx::write(_writer, obb);
|
bx::write(_writer, obb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1002,20 +1002,40 @@ int _main_(int _argc, char** _argv)
|
||||||
ImGui::Text("Name: %s %s", view.m_fileList[view.m_fileIndex].c_str(), layout);
|
ImGui::Text("Name: %s %s", view.m_fileList[view.m_fileIndex].c_str(), layout);
|
||||||
|
|
||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
for (GroupArray::const_iterator itGroup = mesh->m_groups.begin(), itGroupEnd = mesh->m_groups.end(); itGroup != itGroupEnd; ++itGroup)
|
for (GroupArray::const_iterator itGroup = mesh->m_groups.begin(), itGroupEnd = mesh->m_groups.end()
|
||||||
|
; itGroup != itGroupEnd
|
||||||
|
; ++itGroup
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ImGui::Text("Group v %d i %d c %.2f %.2f %.2f r %.2f", itGroup->m_numVertices, itGroup->m_numIndices,
|
ImGui::Text("Group v %d i %d c %.2f %.2f %.2f r %.2f"
|
||||||
itGroup->m_sphere.center.x, itGroup->m_sphere.center.y, itGroup->m_sphere.center.z,
|
, itGroup->m_numVertices
|
||||||
itGroup->m_sphere.radius);
|
, itGroup->m_numIndices
|
||||||
|
, itGroup->m_sphere.center.x
|
||||||
|
, itGroup->m_sphere.center.y
|
||||||
|
, itGroup->m_sphere.center.z
|
||||||
|
, itGroup->m_sphere.radius
|
||||||
|
);
|
||||||
|
|
||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
for (PrimitiveArray::const_iterator itPrim = itGroup->m_prims.begin(), itPrimEnd = itGroup->m_prims.end(); itPrim != itPrimEnd; ++itPrim)
|
|
||||||
|
for (PrimitiveArray::const_iterator itPrim = itGroup->m_prims.begin(), itPrimEnd = itGroup->m_prims.end()
|
||||||
|
; itPrim != itPrimEnd
|
||||||
|
; ++itPrim
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ImGui::Text("Primitive v %d i %d c %.2f %.2f %.2f r %.2f", itPrim->m_numVertices, itPrim->m_numIndices,
|
ImGui::Text("Primitive v %d i %d c %.2f %.2f %.2f r %.2f"
|
||||||
itPrim->m_sphere.center.x, itPrim->m_sphere.center.y, itPrim->m_sphere.center.z,
|
, itPrim->m_numVertices
|
||||||
itPrim->m_sphere.radius);
|
, itPrim->m_numIndices
|
||||||
|
, itPrim->m_sphere.center.x
|
||||||
|
, itPrim->m_sphere.center.y
|
||||||
|
, itPrim->m_sphere.center.z
|
||||||
|
, itPrim->m_sphere.radius
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
@ -1189,7 +1209,7 @@ int _main_(int _argc, char** _argv)
|
||||||
uint32_t numPrimitives = 0;
|
uint32_t numPrimitives = 0;
|
||||||
uint32_t numVertices = 0;
|
uint32_t numVertices = 0;
|
||||||
uint32_t numIndices = 0;
|
uint32_t numIndices = 0;
|
||||||
Aabb boundingBox = {};
|
bx::Aabb boundingBox = {};
|
||||||
|
|
||||||
for (GroupArray::const_iterator it = mesh->m_groups.begin(), itEnd = mesh->m_groups.end(); it != itEnd; ++it)
|
for (GroupArray::const_iterator it = mesh->m_groups.begin(), itEnd = mesh->m_groups.end(); it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
|
@ -1218,8 +1238,8 @@ int _main_(int _argc, char** _argv)
|
||||||
, numIndices
|
, numIndices
|
||||||
);
|
);
|
||||||
|
|
||||||
view.m_meshCenter = getCenter(boundingBox);
|
view.m_meshCenter = bx::getCenter(boundingBox);
|
||||||
view.m_meshRadius = bx::length(getExtents(boundingBox));
|
view.m_meshRadius = bx::length(bx::getExtents(boundingBox) );
|
||||||
|
|
||||||
view.m_camera.init( view.m_meshCenter, view.m_meshRadius * 2.0f, 0.01f, view.m_meshRadius * 10.0f);
|
view.m_camera.init( view.m_meshCenter, view.m_meshRadius * 2.0f, 0.01f, view.m_meshRadius * 10.0f);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue