Added initializer types.

This commit is contained in:
Бранимир Караџић 2021-09-06 09:03:26 -07:00
parent 9ab8494bdd
commit f1ddf67114
12 changed files with 105 additions and 119 deletions

View File

@ -291,8 +291,8 @@ struct Camera
struct Interp3f struct Interp3f
{ {
bx::Vec3 curr; bx::Vec3 curr = bx::init::None;
bx::Vec3 dest; bx::Vec3 dest = bx::init::None;
}; };
Interp3f m_target; Interp3f m_target;

View File

@ -29,8 +29,8 @@ struct Camera
void reset() void reset()
{ {
m_target.curr = { 0.0f, 0.0f, 0.0f }; m_target.curr = bx::init::Zero;
m_target.dest = { 0.0f, 0.0f, 0.0f }; m_target.dest = bx::init::Zero;
m_pos.curr = { 0.0f, 0.0f, -2.0f }; m_pos.curr = { 0.0f, 0.0f, -2.0f };
m_pos.dest = { 0.0f, 0.0f, -2.0f }; m_pos.dest = { 0.0f, 0.0f, -2.0f };
@ -135,8 +135,8 @@ struct Camera
struct Interp3f struct Interp3f
{ {
bx::Vec3 curr; bx::Vec3 curr = bx::init::None;
bx::Vec3 dest; bx::Vec3 dest = bx::init::None;
}; };
Interp3f m_target; Interp3f m_target;

View File

@ -601,7 +601,7 @@ void initA(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
case Shape::Type::Plane: case Shape::Type::Plane:
{ {
bx::Plane plane; bx::Plane plane(bx::init::None);
bx::calcPlane(plane, bx::normalize(bx::Vec3{0.0f, 1.0f, 1.0f}), _pos); bx::calcPlane(plane, bx::normalize(bx::Vec3{0.0f, 1.0f, 1.0f}), _pos);
_outShape = Shape(plane); _outShape = Shape(plane);
} }
@ -688,7 +688,7 @@ void initB(Shape& _outShape, Shape::Type::Enum _type, bx::Vec3 _pos)
case Shape::Type::Plane: case Shape::Type::Plane:
{ {
bx::Plane plane; bx::Plane plane(bx::init::None);
bx::calcPlane(plane, bx::normalize(bx::Vec3{1.0f, 1.0f, 0.0f}), _pos); bx::calcPlane(plane, bx::normalize(bx::Vec3{1.0f, 1.0f, 0.0f}), _pos);
_outShape = Shape(plane); _outShape = Shape(plane);
} }
@ -999,7 +999,7 @@ public:
const bx::Vec3 normal = { 0.0f, 1.0f, 0.0f }; const bx::Vec3 normal = { 0.0f, 1.0f, 0.0f };
const bx::Vec3 pos = { 0.0f, -2.0f, 0.0f }; const bx::Vec3 pos = { 0.0f, -2.0f, 0.0f };
bx::Plane plane; bx::Plane plane(bx::init::None);
bx::calcPlane(plane, normal, pos); bx::calcPlane(plane, normal, pos);
dde.setColor(false dde.setColor(false

View File

@ -63,7 +63,7 @@ namespace
typedef bx::Vec3 Color; typedef bx::Vec3 Color;
// HDTV rec. 709 matrix. // HDTV rec. 709 matrix.
static float M_XYZ2RGB[] = static constexpr float M_XYZ2RGB[] =
{ {
3.240479f, -0.969256f, 0.055648f, 3.240479f, -0.969256f, 0.055648f,
-1.53715f, 1.875991f, -0.204043f, -1.53715f, 1.875991f, -0.204043f,
@ -73,18 +73,18 @@ namespace
// Converts color repesentation from CIE XYZ to RGB color-space. // Converts color repesentation from CIE XYZ to RGB color-space.
Color xyzToRgb(const Color& xyz) Color xyzToRgb(const Color& xyz)
{ {
Color rgb; Color rgb(bx::init::None);
rgb.x = M_XYZ2RGB[0] * xyz.x + M_XYZ2RGB[3] * xyz.y + M_XYZ2RGB[6] * xyz.z; rgb.x = M_XYZ2RGB[0] * xyz.x + M_XYZ2RGB[3] * xyz.y + M_XYZ2RGB[6] * xyz.z;
rgb.y = M_XYZ2RGB[1] * xyz.x + M_XYZ2RGB[4] * xyz.y + M_XYZ2RGB[7] * xyz.z; rgb.y = M_XYZ2RGB[1] * xyz.x + M_XYZ2RGB[4] * xyz.y + M_XYZ2RGB[7] * xyz.z;
rgb.z = M_XYZ2RGB[2] * xyz.x + M_XYZ2RGB[5] * xyz.y + M_XYZ2RGB[8] * xyz.z; rgb.z = M_XYZ2RGB[2] * xyz.x + M_XYZ2RGB[5] * xyz.y + M_XYZ2RGB[8] * xyz.z;
return rgb; return rgb;
}; };
// Precomputed luminance of sunlight in XYZ colorspace. // Precomputed luminance of sunlight in XYZ colorspace.
// Computed using code from Game Engine Gems, Volume One, chapter 15. Implementation based on Dr. Richard Bird model. // Computed using code from Game Engine Gems, Volume One, chapter 15. Implementation based on Dr. Richard Bird model.
// This table is used for piecewise linear interpolation. Transitions from and to 0.0 at sunset and sunrise are highly inaccurate // This table is used for piecewise linear interpolation. Transitions from and to 0.0 at sunset and sunrise are highly inaccurate
static std::map<float, Color> sunLuminanceXYZTable = { static std::map<float, Color> sunLuminanceXYZTable =
{
{ 5.0f, { 0.000000f, 0.000000f, 0.000000f } }, { 5.0f, { 0.000000f, 0.000000f, 0.000000f } },
{ 7.0f, { 12.703322f, 12.989393f, 9.100411f } }, { 7.0f, { 12.703322f, 12.989393f, 9.100411f } },
{ 8.0f, { 13.202644f, 13.597814f, 11.524929f } }, { 8.0f, { 13.202644f, 13.597814f, 11.524929f } },
@ -107,7 +107,8 @@ namespace
// This table is used for piecewise linear interpolation. Day/night transitions are highly inaccurate. // This table is used for piecewise linear interpolation. Day/night transitions are highly inaccurate.
// The scale of luminance change in Day/night transitions is not preserved. // The scale of luminance change in Day/night transitions is not preserved.
// Luminance at night was increased to eliminate need the of HDR render. // Luminance at night was increased to eliminate need the of HDR render.
static std::map<float, Color> skyLuminanceXYZTable = { static std::map<float, Color> skyLuminanceXYZTable =
{
{ 0.0f, { 0.308f, 0.308f, 0.411f } }, { 0.0f, { 0.308f, 0.308f, 0.411f } },
{ 1.0f, { 0.308f, 0.308f, 0.410f } }, { 1.0f, { 0.308f, 0.308f, 0.410f } },
{ 2.0f, { 0.301f, 0.301f, 0.402f } }, { 2.0f, { 0.301f, 0.301f, 0.402f } },
@ -136,7 +137,7 @@ namespace
// Turbidity tables. Taken from: // Turbidity tables. Taken from:
// A. J. Preetham, P. Shirley, and B. Smits. A Practical Analytic Model for Daylight. SIGGRAPH '99 // A. J. Preetham, P. Shirley, and B. Smits. A Practical Analytic Model for Daylight. SIGGRAPH '99
// Coefficients correspond to xyY colorspace. // Coefficients correspond to xyY colorspace.
static Color ABCDE[] = static constexpr Color ABCDE[] =
{ {
{ -0.2592f, -0.2608f, -1.4630f }, { -0.2592f, -0.2608f, -1.4630f },
{ 0.0008f, 0.0092f, 0.4275f }, { 0.0008f, 0.0092f, 0.4275f },
@ -144,7 +145,8 @@ namespace
{ -0.8989f, -1.6537f, -2.5771f }, { -0.8989f, -1.6537f, -2.5771f },
{ 0.0452f, 0.0529f, 0.3703f }, { 0.0452f, 0.0529f, 0.3703f },
}; };
static Color ABCDE_t[] =
static constexpr Color ABCDE_t[] =
{ {
{ -0.0193f, -0.0167f, 0.1787f }, { -0.0193f, -0.0167f, 0.1787f },
{ -0.0665f, -0.0950f, -0.3554f }, { -0.0665f, -0.0950f, -0.3554f },
@ -241,14 +243,14 @@ namespace
}; };
SunController() SunController()
: m_latitude(50.0f) : m_northDir(1.0f, 0.0f, 0.0f)
, m_sunDir(0.0f, -1.0f, 0.0f)
, m_upDir(0.0f, 1.0f, 0.0f)
, m_latitude(50.0f)
, m_month(June) , m_month(June)
, m_eclipticObliquity(bx::toRad(23.4f) ) , m_eclipticObliquity(bx::toRad(23.4f) )
, m_delta(0.0f) , m_delta(0.0f)
{ {
m_northDir = { 1.0f, 0.0f, 0.0f };
m_sunDir = { 0.0f, -1.0f, 0.0f };
m_upDir = { 0.0f, 1.0f, 0.0f };
} }
void Update(float _time) void Update(float _time)

View File

@ -139,8 +139,8 @@ struct Camera
struct Interp3f struct Interp3f
{ {
bx::Vec3 curr; bx::Vec3 curr = bx::init::None;
bx::Vec3 dest; bx::Vec3 dest = bx::init::None;
}; };
Interp3f m_target; Interp3f m_target;

View File

@ -128,7 +128,8 @@ void aabbTransformToObb(Obb& _obb, const Aabb& _aabb, const float* _mtx)
void toAabb(Aabb& _outAabb, const void* _vertices, uint32_t _numVertices, uint32_t _stride) void toAabb(Aabb& _outAabb, const void* _vertices, uint32_t _numVertices, uint32_t _stride)
{ {
Vec3 mn, mx; Vec3 mn(init::None);
Vec3 mx(init::None);
uint8_t* vertex = (uint8_t*)_vertices; uint8_t* vertex = (uint8_t*)_vertices;
mn = mx = load<Vec3>(vertex); mn = mx = load<Vec3>(vertex);
@ -149,7 +150,8 @@ void toAabb(Aabb& _outAabb, const void* _vertices, uint32_t _numVertices, uint32
void toAabb(Aabb& _outAabb, const float* _mtx, const void* _vertices, uint32_t _numVertices, uint32_t _stride) void toAabb(Aabb& _outAabb, const float* _mtx, const void* _vertices, uint32_t _numVertices, uint32_t _stride)
{ {
Vec3 mn, mx; Vec3 mn(init::None);
Vec3 mx(init::None);
uint8_t* vertex = (uint8_t*)_vertices; uint8_t* vertex = (uint8_t*)_vertices;
mn = mx = mul(load<Vec3>(vertex), _mtx); mn = mx = mul(load<Vec3>(vertex), _mtx);
@ -282,7 +284,7 @@ void calcMinBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _num
uint8_t* vertex = (uint8_t*)_vertices; uint8_t* vertex = (uint8_t*)_vertices;
Vec3 center; Vec3 center(init::None);
float* position = (float*)&vertex[0]; float* position = (float*)&vertex[0];
center.x = position[0]; center.x = position[0];
center.y = position[1]; center.y = position[1];
@ -500,9 +502,7 @@ bool intersect(const Ray& _ray, const Obb& _obb, Hit* _hit)
bool intersect(const Ray& _ray, const Disk& _disk, Hit* _hit) bool intersect(const Ray& _ray, const Disk& _disk, Hit* _hit)
{ {
Plane plane; Plane plane(_disk.normal, -dot(_disk.center, _disk.normal) );
plane.normal = _disk.normal;
plane.dist = -dot(_disk.center, _disk.normal);
Hit tmpHit; Hit tmpHit;
_hit = NULL != _hit ? _hit : &tmpHit; _hit = NULL != _hit ? _hit : &tmpHit;
@ -597,8 +597,8 @@ static bool intersect(const Ray& _ray, const Cylinder& _cylinder, bool _capsule,
return intersect(_ray, sphere, _hit); return intersect(_ray, sphere, _hit);
} }
Plane plane; Plane plane(init::None);
Vec3 pos; Vec3 pos(init::None);
if (0.0f >= height) if (0.0f >= height)
{ {
@ -907,9 +907,9 @@ Interval projectToAxis(const Vec3& _axis, const Triangle& _triangle)
struct Srt struct Srt
{ {
Quaternion rotation; Quaternion rotation = init::Identity;
Vec3 translation; Vec3 translation = init::Zero;
Vec3 scale; Vec3 scale = init::Zero;
}; };
Srt toSrt(const void* _mtx) Srt toSrt(const void* _mtx)
@ -1026,8 +1026,8 @@ bool isNearZero(const Vec3& _v)
struct Line struct Line
{ {
Vec3 pos; Vec3 pos = init::None;
Vec3 dir; Vec3 dir = init::None;
}; };
inline Vec3 getPointAt(const Line& _line, float _t) inline Vec3 getPointAt(const Line& _line, float _t)
@ -1222,7 +1222,7 @@ Vec3 closestPoint(const Obb& _obb, const Vec3& _point)
Vec3 closestPoint(const Triangle& _triangle, const Vec3& _point) Vec3 closestPoint(const Triangle& _triangle, const Vec3& _point)
{ {
Plane plane; Plane plane(init::None);
calcPlane(plane, _triangle); calcPlane(plane, _triangle);
const Vec3 pos = closestPoint(plane, _point); const Vec3 pos = closestPoint(plane, _point);
@ -1284,7 +1284,7 @@ bool overlap(const Aabb& _aabb, const Triangle& _triangle)
return false; return false;
} }
Plane plane; Plane plane(init::None);
calcPlane(plane, _triangle); calcPlane(plane, _triangle);
if (!overlap(_aabb, plane) ) if (!overlap(_aabb, plane) )
@ -1343,7 +1343,7 @@ bool overlap(const Aabb& _aabb, const Disk& _disk)
return false; return false;
} }
Plane plane; Plane plane(init::None);
calcPlane(plane, _disk.normal, _disk.center); calcPlane(plane, _disk.normal, _disk.center);
return overlap(_aabb, plane); return overlap(_aabb, plane);
@ -1500,7 +1500,7 @@ bool overlap(const Cylinder& _cylinder, const Obb& _obb)
bool overlap(const Disk& _disk, const Vec3& _pos) bool overlap(const Disk& _disk, const Vec3& _pos)
{ {
Plane plane; Plane plane(init::None);
calcPlane(plane, _disk.normal, _disk.center); calcPlane(plane, _disk.normal, _disk.center);
if (!isNearZero(distance(plane, _pos) ) ) if (!isNearZero(distance(plane, _pos) ) )
@ -1513,7 +1513,7 @@ bool overlap(const Disk& _disk, const Vec3& _pos)
bool overlap(const Disk& _disk, const Plane& _plane) bool overlap(const Disk& _disk, const Plane& _plane)
{ {
Plane plane; Plane plane(init::None);
calcPlane(plane, _disk.normal, _disk.center); calcPlane(plane, _disk.normal, _disk.center);
if (!overlap(plane, _plane) ) if (!overlap(plane, _plane) )
@ -1531,7 +1531,7 @@ bool overlap(const Disk& _disk, const Capsule& _capsule)
return false; return false;
} }
Plane plane; Plane plane(init::None);
calcPlane(plane, _disk.normal, _disk.center); calcPlane(plane, _disk.normal, _disk.center);
return overlap(_capsule, plane); return overlap(_capsule, plane);
@ -1539,10 +1539,10 @@ bool overlap(const Disk& _disk, const Capsule& _capsule)
bool overlap(const Disk& _diskA, const Disk& _diskB) bool overlap(const Disk& _diskA, const Disk& _diskB)
{ {
Plane planeA; Plane planeA(init::None);
calcPlane(planeA, _diskA.normal, _diskA.center); calcPlane(planeA, _diskA.normal, _diskA.center);
Plane planeB; Plane planeB(init::None);
calcPlane(planeB, _diskB); calcPlane(planeB, _diskB);
Line line; Line line;
@ -1571,7 +1571,7 @@ bool overlap(const Disk& _disk, const Obb& _obb)
return false; return false;
} }
Plane plane; Plane plane(init::None);
calcPlane(plane, _disk.normal, _disk.center); calcPlane(plane, _disk.normal, _disk.center);
return overlap(_obb, plane); return overlap(_obb, plane);
@ -1699,7 +1699,7 @@ bool overlap(const Sphere& _sphere, const Plane& _plane)
bool overlap(const Sphere& _sphere, const Triangle& _triangle) bool overlap(const Sphere& _sphere, const Triangle& _triangle)
{ {
Plane plane; Plane plane(init::None);
calcPlane(plane, _triangle); calcPlane(plane, _triangle);
if (!overlap(_sphere, plane) ) if (!overlap(_sphere, plane) )
@ -1737,7 +1737,7 @@ bool overlap(const Sphere& _sphere, const Disk& _disk)
return false; return false;
} }
Plane plane; Plane plane(init::None);
calcPlane(plane, _disk.normal, _disk.center); calcPlane(plane, _disk.normal, _disk.center);
return overlap(_sphere, plane); return overlap(_sphere, plane);
@ -1807,7 +1807,7 @@ bool overlap(const Triangle& _triangleA, const Triangle& _triangleB)
template<typename Ty> template<typename Ty>
bool overlap(const Triangle& _triangle, const Ty& _ty) bool overlap(const Triangle& _triangle, const Ty& _ty)
{ {
Plane plane; Plane plane(init::None);
calcPlane(plane, _triangle); calcPlane(plane, _triangle);
plane.normal = neg(plane.normal); plane.normal = neg(plane.normal);
@ -1966,7 +1966,7 @@ bool overlap(const Triangle& _triangle, const Disk& _disk)
return false; return false;
} }
Plane plane; Plane plane(init::None);
calcPlane(plane, _disk.normal, _disk.center); calcPlane(plane, _disk.normal, _disk.center);
return overlap(_triangle, plane); return overlap(_triangle, plane);

View File

@ -11,39 +11,39 @@
/// ///
struct Aabb struct Aabb
{ {
bx::Vec3 min; bx::Vec3 min = bx::init::None;
bx::Vec3 max; bx::Vec3 max = bx::init::None;
}; };
/// ///
struct Capsule struct Capsule
{ {
bx::Vec3 pos; bx::Vec3 pos = bx::init::None;
bx::Vec3 end; bx::Vec3 end = bx::init::None;
float radius; float radius;
}; };
/// ///
struct Cone struct Cone
{ {
bx::Vec3 pos; bx::Vec3 pos = bx::init::None;
bx::Vec3 end; bx::Vec3 end = bx::init::None;
float radius; float radius;
}; };
/// ///
struct Cylinder struct Cylinder
{ {
bx::Vec3 pos; bx::Vec3 pos = bx::init::None;
bx::Vec3 end; bx::Vec3 end = bx::init::None;
float radius; float radius;
}; };
/// ///
struct Disk struct Disk
{ {
bx::Vec3 center; bx::Vec3 center = bx::init::None;
bx::Vec3 normal; bx::Vec3 normal = bx::init::None;
float radius; float radius;
}; };
@ -56,30 +56,30 @@ struct Obb
/// ///
struct Sphere struct Sphere
{ {
bx::Vec3 center; bx::Vec3 center = bx::init::None;
float radius; float radius;
}; };
/// ///
struct Triangle struct Triangle
{ {
bx::Vec3 v0; bx::Vec3 v0 = bx::init::None;
bx::Vec3 v1; bx::Vec3 v1 = bx::init::None;
bx::Vec3 v2; bx::Vec3 v2 = bx::init::None;
}; };
/// ///
struct Ray struct Ray
{ {
bx::Vec3 pos; bx::Vec3 pos = bx::init::None;
bx::Vec3 dir; bx::Vec3 dir = bx::init::None;
}; };
/// ///
struct Hit struct Hit
{ {
bx::Vec3 pos; bx::Vec3 pos = bx::init::None;
bx::Plane plane; bx::Plane plane = bx::init::None;
}; };
/// ///

View File

@ -264,9 +264,9 @@ struct Camera
MouseCoords m_mouseNow; MouseCoords m_mouseNow;
MouseCoords m_mouseLast; MouseCoords m_mouseLast;
bx::Vec3 m_eye; bx::Vec3 m_eye = bx::init::Zero;
bx::Vec3 m_at; bx::Vec3 m_at = bx::init::Zero;
bx::Vec3 m_up; bx::Vec3 m_up = bx::init::Zero;
float m_horizontalAngle; float m_horizontalAngle;
float m_verticalAngle; float m_verticalAngle;

View File

@ -295,30 +295,14 @@ uint32_t genSphere(uint8_t _subdiv0, void* _pos0 = NULL, uint16_t _posStride0 =
bx::Vec3 getPoint(Axis::Enum _axis, float _x, float _y) bx::Vec3 getPoint(Axis::Enum _axis, float _x, float _y)
{ {
bx::Vec3 result;
switch (_axis) switch (_axis)
{ {
case Axis::X: case Axis::X: return { 0.0f, _x, _y };
result.x = 0.0f; case Axis::Y: return { _y, 0.0f, _x };
result.y = _x; default: break;
result.z = _y;
break;
case Axis::Y:
result.x = _y;
result.y = 0.0f;
result.z = _x;
break;
default:
result.x = _x;
result.y = _y;
result.z = 0.0f;
break;
} }
return result; return { _x, _y, 0.0f };
} }
#include "vs_debugdraw_lines.bin.h" #include "vs_debugdraw_lines.bin.h"
@ -1664,7 +1648,7 @@ struct DebugDrawEncoderImpl
void drawFrustum(const float* _viewProj) void drawFrustum(const float* _viewProj)
{ {
bx::Plane planes[6]; bx::Plane planes[6] = { bx::init::None, bx::init::None, bx::init::None, bx::init::None, bx::init::None, bx::init::None };
buildFrustumPlanes(planes, _viewProj); buildFrustumPlanes(planes, _viewProj);
const bx::Vec3 points[8] = const bx::Vec3 points[8] =
@ -1761,8 +1745,8 @@ struct DebugDrawEncoderImpl
const float step = bx::kPi * 2.0f / num; const float step = bx::kPi * 2.0f / num;
_weight = bx::clamp(_weight, 0.0f, 2.0f); _weight = bx::clamp(_weight, 0.0f, 2.0f);
bx::Vec3 udir; bx::Vec3 udir(bx::init::None);
bx::Vec3 vdir; bx::Vec3 vdir(bx::init::None);
bx::calcTangentFrame(udir, vdir, _normal, attrib.m_spin); bx::calcTangentFrame(udir, vdir, _normal, attrib.m_spin);
float xy0[2]; float xy0[2];
@ -1833,7 +1817,8 @@ struct DebugDrawEncoderImpl
const Attrib& attrib = m_attrib[m_stack]; const Attrib& attrib = m_attrib[m_stack];
if (attrib.m_wireframe) if (attrib.m_wireframe)
{ {
bx::Vec3 udir, vdir; bx::Vec3 udir(bx::init::None);
bx::Vec3 vdir(bx::init::None);
bx::calcTangentFrame(udir, vdir, _normal, attrib.m_spin); bx::calcTangentFrame(udir, vdir, _normal, attrib.m_spin);
const float halfExtent = _size*0.5f; const float halfExtent = _size*0.5f;
@ -1874,7 +1859,8 @@ struct DebugDrawEncoderImpl
const Attrib& attrib = m_attrib[m_stack]; const Attrib& attrib = m_attrib[m_stack];
bx::Vec3 udir, vdir; bx::Vec3 udir(bx::init::None);
bx::Vec3 vdir(bx::init::None);
bx::calcTangentFrame(udir, vdir, _normal, attrib.m_spin); bx::calcTangentFrame(udir, vdir, _normal, attrib.m_spin);
const Pack2D& pack = s_dds.m_sprite.get(_handle); const Pack2D& pack = s_dds.m_sprite.get(_handle);
@ -1994,8 +1980,8 @@ struct DebugDrawEncoderImpl
if (_thickness > 0.0f) if (_thickness > 0.0f)
{ {
const bx::Vec3 from = { _x, _y, _z }; const bx::Vec3 from = { _x, _y, _z };
bx::Vec3 mid; bx::Vec3 mid(bx::init::None);
bx::Vec3 to; bx::Vec3 to(bx::init::None);
setColor(Axis::X == _highlight ? 0xff00ffff : 0xff0000ff); setColor(Axis::X == _highlight ? 0xff00ffff : 0xff0000ff);
mid = { _x + _len - _thickness, _y, _z }; mid = { _x + _len - _thickness, _y, _z };
@ -2037,8 +2023,8 @@ struct DebugDrawEncoderImpl
{ {
const Attrib& attrib = m_attrib[m_stack]; const Attrib& attrib = m_attrib[m_stack];
bx::Vec3 udir; bx::Vec3 udir(bx::init::None);
bx::Vec3 vdir; bx::Vec3 vdir(bx::init::None);
bx::calcTangentFrame(udir, vdir, _normal, attrib.m_spin); bx::calcTangentFrame(udir, vdir, _normal, attrib.m_spin);
udir = bx::mul(udir, _step); udir = bx::mul(udir, _step);

View File

@ -248,7 +248,7 @@ namespace ps
Particle& particle = m_particles[m_num]; Particle& particle = m_particles[m_num];
m_num++; m_num++;
bx::Vec3 pos; bx::Vec3 pos(bx::init::None);
switch (m_shape) switch (m_shape)
{ {
default: default:
@ -281,7 +281,7 @@ namespace ps
break; break;
} }
bx::Vec3 dir; bx::Vec3 dir(bx::init::None);
switch (m_direction) switch (m_direction)
{ {
default: default:

View File

@ -589,7 +589,7 @@ void parseObj(char* _data, uint32_t _size, Mesh* _mesh, bool _hasBc)
if (0 == bx::strCmp(argv[0], "vn") ) if (0 == bx::strCmp(argv[0], "vn") )
{ {
bx::Vec3 normal; bx::Vec3 normal(bx::init::None);
bx::fromString(&normal.x, argv[1]); bx::fromString(&normal.x, argv[1]);
bx::fromString(&normal.y, argv[2]); bx::fromString(&normal.y, argv[2]);
bx::fromString(&normal.z, argv[3]); bx::fromString(&normal.z, argv[3]);
@ -607,7 +607,7 @@ void parseObj(char* _data, uint32_t _size, Mesh* _mesh, bool _hasBc)
} }
else if (0 == bx::strCmp(argv[0], "vt") ) else if (0 == bx::strCmp(argv[0], "vt") )
{ {
bx::Vec3 texcoord; bx::Vec3 texcoord(bx::init::None);
texcoord.y = 0.0f; texcoord.y = 0.0f;
texcoord.z = 0.0f; texcoord.z = 0.0f;
@ -645,15 +645,10 @@ void parseObj(char* _data, uint32_t _size, Mesh* _mesh, bool _hasBc)
pw = 1.0f; pw = 1.0f;
} }
float invW = 1.0f/pw; bx::Vec3 pos(px, py, pz);
px *= invW;
py *= invW;
pz *= invW;
bx::Vec3 pos; const float invW = bx::rcp(pw);
pos.x = px; pos = bx::mul(pos, invW);
pos.y = py;
pos.z = pz;
_mesh->m_positions.push_back(pos); _mesh->m_positions.push_back(pos);
} }
@ -753,8 +748,9 @@ void processGltfNode(cgltf_node* _node, Mesh* _mesh, Group* _group, bool _hasBc)
{ {
_mesh->m_positions.reserve(_mesh->m_positions.size() + accessorCount); _mesh->m_positions.reserve(_mesh->m_positions.size() + accessorCount);
bx::Vec3 pos; bx::Vec3 pos(bx::init::None);
for (cgltf_size v=0;v<accessorCount;++v)
for (cgltf_size v = 0; v < accessorCount; ++v)
{ {
gltfReadFloat(accessorData, numComponents, v, &pos.x, 3); gltfReadFloat(accessorData, numComponents, v, &pos.x, 3);
pos = mul(pos, nodeToWorld); pos = mul(pos, nodeToWorld);
@ -766,8 +762,9 @@ void processGltfNode(cgltf_node* _node, Mesh* _mesh, Group* _group, bool _hasBc)
_mesh->m_normals.reserve(_mesh->m_normals.size() + accessorCount); _mesh->m_normals.reserve(_mesh->m_normals.size() + accessorCount);
hasNormal = true; hasNormal = true;
bx::Vec3 normal; bx::Vec3 normal(bx::init::None);
for (cgltf_size v=0;v<accessorCount;++v)
for (cgltf_size v = 0; v < accessorCount; ++v)
{ {
gltfReadFloat(accessorData, numComponents, v, &normal.x, 3); gltfReadFloat(accessorData, numComponents, v, &normal.x, 3);
normal = mul(normal, nodeToWorldNormal); normal = mul(normal, nodeToWorldNormal);
@ -779,8 +776,9 @@ void processGltfNode(cgltf_node* _node, Mesh* _mesh, Group* _group, bool _hasBc)
_mesh->m_texcoords.reserve(_mesh->m_texcoords.size() + accessorCount); _mesh->m_texcoords.reserve(_mesh->m_texcoords.size() + accessorCount);
hasTexcoord = true; hasTexcoord = true;
bx::Vec3 texcoord; bx::Vec3 texcoord(bx::init::None);
for (cgltf_size v=0;v<accessorCount;++v)
for (cgltf_size v = 0; v < accessorCount; ++v)
{ {
gltfReadFloat(accessorData, numComponents, v, &texcoord.x, 3); gltfReadFloat(accessorData, numComponents, v, &texcoord.x, 3);
_mesh->m_texcoords.push_back(texcoord); _mesh->m_texcoords.push_back(texcoord);

View File

@ -169,7 +169,7 @@ struct Camera
{ {
Camera() Camera()
{ {
init(bx::Vec3(0.0f,0.0f,0.0f), 2.0f, 0.01f, 100.0f); init(bx::init::Zero, 2.0f, 0.01f, 100.0f);
} }
void init(const bx::Vec3& _center, float _distance, float _near, float _far) void init(const bx::Vec3& _center, float _distance, float _near, float _far)
@ -265,8 +265,8 @@ struct Camera
struct Interp3f struct Interp3f
{ {
bx::Vec3 curr; bx::Vec3 curr = bx::init::None;
bx::Vec3 dest; bx::Vec3 dest = bx::init::None;
}; };
Interp3f m_target; Interp3f m_target;