Skip to content

Commit e4ef6fa

Browse files
committed
Fix various MATH_AUTOMATIC_SSE build issues with MATH_GRAPHICSENGINE_INTEROP.
1 parent a739ace commit e4ef6fa

File tree

8 files changed

+43
-43
lines changed

8 files changed

+43
-43
lines changed

src/Geometry/AABB.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,8 @@ AABB AABB::Intersection(const AABB &aabb) const
11411141
#ifdef MATH_GRAPHICSENGINE_INTEROP
11421142
void AABB::Triangulate(VertexBuffer &vb, int numFacesX, int numFacesY, int numFacesZ, bool ccwIsFrontFacing) const
11431143
{
1144-
Array<float3> pos;
1145-
Array<float3> normal;
1144+
Array<vec> pos;
1145+
Array<vec> normal;
11461146
Array<float2> uv;
11471147
int numVertices = (numFacesX*numFacesY + numFacesY*numFacesZ + numFacesX*numFacesZ)*2*6;
11481148
pos.Resize_pod(numVertices);
@@ -1152,22 +1152,22 @@ void AABB::Triangulate(VertexBuffer &vb, int numFacesX, int numFacesY, int numFa
11521152
int startIndex = vb.AppendVertices(numVertices);
11531153
for(int i = 0; i < (int)pos.size(); ++i)
11541154
{
1155-
vb.Set(startIndex+i, VDPosition, float4(pos[i],1.f));
1155+
vb.Set(startIndex+i, VDPosition, POINT_TO_FLOAT4(pos[i]));
11561156
if (vb.Declaration()->TypeOffset(VDNormal) >= 0)
1157-
vb.Set(startIndex+i, VDNormal, float4(normal[i],0.f));
1157+
vb.Set(startIndex+i, VDNormal, DIR_TO_FLOAT4(normal[i]));
11581158
if (vb.Declaration()->TypeOffset(VDUV) >= 0)
11591159
vb.SetFloat2(startIndex+i, VDUV, 0, uv[i]);
11601160
}
11611161
}
11621162

11631163
void AABB::ToLineList(VertexBuffer &vb) const
11641164
{
1165-
Array<float3> pos;
1165+
Array<vec> pos;
11661166
pos.Resize_pod(NumVerticesInEdgeList());
11671167
ToEdgeList(&pos[0]);
11681168
int startIndex = vb.AppendVertices((int)pos.size());
11691169
for(int i = 0; i < (int)pos.size(); ++i)
1170-
vb.Set(startIndex+i, VDPosition, float4(pos[i], 1.f));
1170+
vb.Set(startIndex+i, VDPosition, POINT_TO_FLOAT4(pos[i]));
11711171
}
11721172

11731173
#endif

src/Geometry/Frustum.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,10 @@ float2 Frustum::ScreenToViewportSpace(const float2 &point, int screenWidth, int
313313

314314
Ray Frustum::UnProject(float x, float y) const
315315
{
316-
assume(x >= -1.f);
317-
assume(x <= 1.f);
318-
assume(y >= -1.f);
319-
assume(y <= 1.f);
316+
assume1(x >= -1.f, x);
317+
assume1(x <= 1.f, x);
318+
assume1(y >= -1.f, y);
319+
assume1(y <= 1.f, y);
320320
if (type == PerspectiveFrustum)
321321
{
322322
vec nearPlanePos = NearPlanePos(x, y);

src/Geometry/LineSegment.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ std::ostream &operator <<(std::ostream &o, const LineSegment &lineSegment)
486486
void LineSegment::ToLineList(VertexBuffer &vb) const
487487
{
488488
int startIndex = vb.AppendVertices(2);
489-
vb.Set(startIndex, VDPosition, float4(a, 1.f));
490-
vb.Set(startIndex+1, VDPosition, float4(b, 1.f));
489+
vb.Set(startIndex, VDPosition, POINT_TO_FLOAT4(a));
490+
vb.Set(startIndex+1, VDPosition, POINT_TO_FLOAT4(b));
491491
}
492492

493493
#endif

src/Geometry/OBB.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ bool OBB::SetFrom(const Polyhedron &polyhedron)
134134
{
135135
if (!polyhedron.v.empty())
136136
{
137-
*this = OBB::OptimalEnclosingOBB(&polyhedron.v[0], (int)polyhedron.v.size());
137+
*this = OBB::OptimalEnclosingOBB((vec*)&polyhedron.v[0], (int)polyhedron.v.size());
138138
return true;
139139
}
140140
else
@@ -488,7 +488,7 @@ OBB OBB::OptimalEnclosingOBB(const vec *pointArray, int numPoints)
488488
float distX = dirs[i].x - dirs[j].x;
489489
if (distX > 1e-1f)
490490
break;
491-
if (dirs[i].DistanceSq(dirs[j]) < 1e-3f)
491+
if (vec(dirs[i]).DistanceSq(dirs[j]) < 1e-3f)
492492
{
493493
dirs.erase(dirs.begin() + j);
494494
--i;
@@ -1054,9 +1054,9 @@ void OBB::Triangulate(VertexBuffer &vb, int x, int y, int z, bool ccwIsFrontFaci
10541054
int startIndex = vb.AppendVertices(numVertices);
10551055
for(int i = 0; i < (int)pos.size(); ++i)
10561056
{
1057-
vb.Set(startIndex+i, VDPosition, float4(pos[i],1.f));
1057+
vb.Set(startIndex+i, VDPosition, POINT_TO_FLOAT4(pos[i]));
10581058
if (vb.Declaration()->TypeOffset(VDNormal) >= 0)
1059-
vb.Set(startIndex+i, VDNormal, float4(normal[i],0.f));
1059+
vb.Set(startIndex+i, VDNormal, DIR_TO_FLOAT4(normal[i]));
10601060
if (vb.Declaration()->TypeOffset(VDUV) >= 0)
10611061
vb.SetFloat2(startIndex+i, VDUV, 0, uv[i]);
10621062
}
@@ -1069,7 +1069,7 @@ void OBB::ToLineList(VertexBuffer &vb) const
10691069
ToEdgeList(&pos[0]);
10701070
int startIndex = vb.AppendVertices((int)pos.size());
10711071
for(int i = 0; i < (int)pos.size(); ++i)
1072-
vb.Set(startIndex+i, VDPosition, float4(pos[i], 1.f));
1072+
vb.Set(startIndex+i, VDPosition, POINT_TO_FLOAT4(pos[i]));
10731073
}
10741074

10751075
#endif

src/Geometry/Plane.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -928,10 +928,10 @@ void Plane::Triangulate(VertexBuffer &vb, float uWidth, float vHeight, const vec
928928
for(int y = 0; y < numFacesV; ++y)
929929
for(int x = 0; x < numFacesU; ++x)
930930
{
931-
float4 tl = float4(topLeft + uEdge * (float)x + vEdge * (float)y, 1.f);
932-
float4 tr = float4(topLeft + uEdge * (float)(x+1) + vEdge * (float)y, 1.f);
933-
float4 bl = float4(topLeft + uEdge * (float)x + vEdge * (float)(y+1), 1.f);
934-
float4 br = float4(topLeft + uEdge * (float)(x+1) + vEdge * (float)(y+1), 1.f);
931+
float4 tl = POINT_TO_FLOAT4(topLeft + uEdge * (float)x + vEdge * (float)y);
932+
float4 tr = POINT_TO_FLOAT4(topLeft + uEdge * (float)(x+1) + vEdge * (float)y);
933+
float4 bl = POINT_TO_FLOAT4(topLeft + uEdge * (float)x + vEdge * (float)(y+1));
934+
float4 br = POINT_TO_FLOAT4(topLeft + uEdge * (float)(x+1) + vEdge * (float)(y+1));
935935
int i0 = ccwIsFrontFacing ? i : i+5;
936936
int i1 = ccwIsFrontFacing ? i+5 : i;
937937
vb.Set(i0, VDPosition, tl);
@@ -959,7 +959,7 @@ void Plane::Triangulate(VertexBuffer &vb, float uWidth, float vHeight, const vec
959959
if (vb.Declaration()->HasType(VDNormal))
960960
{
961961
for(int k = 0; k < 6; ++k)
962-
vb.Set(i+k, VDNormal, float4(normal, 0.f));
962+
vb.Set(i+k, VDNormal, DIR_TO_FLOAT4(normal));
963963
}
964964

965965
i += 6;
@@ -975,17 +975,17 @@ void Plane::ToLineList(VertexBuffer &vb, float uWidth, float vHeight, const vec
975975
int i = vb.AppendVertices((numLinesU + numLinesV) * 2);
976976
for(int y = 0; y < numLinesV; ++y)
977977
{
978-
float4 start = float4(topLeft + vEdge * (float)y, 1.f);
979-
float4 end = float4(topLeft + uWidth * uEdge + vEdge * (float)y, 1.f);
978+
float4 start = POINT_TO_FLOAT4(topLeft + vEdge * (float)y);
979+
float4 end = POINT_TO_FLOAT4(topLeft + uWidth * uEdge + vEdge * (float)y);
980980
vb.Set(i, VDPosition, start);
981981
vb.Set(i+1, VDPosition, end);
982982
i += 2;
983983
}
984984

985985
for(int x = 0; x < numLinesU; ++x)
986986
{
987-
float4 start = float4(topLeft + uEdge * (float)x, 1.f);
988-
float4 end = float4(topLeft + vHeight * vEdge + uEdge * (float)x, 1.f);
987+
float4 start = POINT_TO_FLOAT4(topLeft + uEdge * (float)x);
988+
float4 end = POINT_TO_FLOAT4(topLeft + vHeight * vEdge + uEdge * (float)x);
989989
vb.Set(i, VDPosition, start);
990990
vb.Set(i+1, VDPosition, end);
991991
i += 2;

src/Geometry/Plane.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ class Plane
394394
#endif
395395

396396
#ifdef MATH_GRAPHICSENGINE_INTEROP
397-
void Triangulate(VertexBuffer &vb, float uWidth, float vHeight, const float3 &centerPoint, int numFacesU, int numFacesV, bool ccwIsFrontFacing) const;
398-
void ToLineList(VertexBuffer &vb, float uWidth, float vHeight, const float3 &centerPoint, int numLinesU, int numLinesV) const;
397+
void Triangulate(VertexBuffer &vb, float uWidth, float vHeight, const vec &centerPoint, int numFacesU, int numFacesV, bool ccwIsFrontFacing) const;
398+
void ToLineList(VertexBuffer &vb, float uWidth, float vHeight, const vec &centerPoint, int numLinesU, int numLinesV) const;
399399
#endif
400400

401401
};

src/Geometry/Polyhedron.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ AABB Polyhedron::MinimalEnclosingAABB() const
242242
#ifdef MATH_CONTAINERLIB_SUPPORT
243243
OBB Polyhedron::MinimalEnclosingOBB() const
244244
{
245-
return OBB::OptimalEnclosingOBB(&v[0], (int)v.size());
245+
return OBB::OptimalEnclosingOBB((vec*)&v[0], (int)v.size());
246246
}
247247
#endif
248248

@@ -1468,24 +1468,24 @@ void Polyhedron::Triangulate(VertexBuffer &vb, bool ccwIsFrontFacing) const
14681468
int idx = vb.AppendVertices(3*(int)tris.size());
14691469
for(size_t j = 0; j < tris.size(); ++j)
14701470
{
1471-
vb.Set(idx, VDPosition, float4(tris[j].a, 1.f));
1471+
vb.Set(idx, VDPosition, POINT_TO_FLOAT4(TRIANGLE(tris[j]).a));
14721472
if (ccwIsFrontFacing)
14731473
{
1474-
vb.Set(idx+1, VDPosition, float4(tris[j].c, 1.f));
1475-
vb.Set(idx+2, VDPosition, float4(tris[j].b, 1.f));
1474+
vb.Set(idx+1, VDPosition, POINT_TO_FLOAT4(TRIANGLE(tris[j]).c));
1475+
vb.Set(idx+2, VDPosition, POINT_TO_FLOAT4(TRIANGLE(tris[j]).b));
14761476
}
14771477
else
14781478
{
1479-
vb.Set(idx+1, VDPosition, float4(tris[j].b, 1.f));
1480-
vb.Set(idx+2, VDPosition, float4(tris[j].c, 1.f));
1479+
vb.Set(idx+1, VDPosition, POINT_TO_FLOAT4(TRIANGLE(tris[j]).b));
1480+
vb.Set(idx+2, VDPosition, POINT_TO_FLOAT4(TRIANGLE(tris[j]).c));
14811481
}
14821482
// Generate flat normals if VB has space for normals.
14831483
if (vb.Declaration()->TypeOffset(VDNormal) >= 0)
14841484
{
1485-
vec normal = ccwIsFrontFacing ? tris[j].NormalCCW() : tris[j].NormalCW();
1486-
vb.Set(idx, VDNormal, float4(normal, 0.f));
1487-
vb.Set(idx+1, VDNormal, float4(normal, 0.f));
1488-
vb.Set(idx+2, VDNormal, float4(normal, 0.f));
1485+
vec normal = ccwIsFrontFacing ? TRIANGLE(tris[j]).NormalCCW() : TRIANGLE(tris[j]).NormalCW();
1486+
vb.Set(idx, VDNormal, DIR_TO_FLOAT4(normal));
1487+
vb.Set(idx+1, VDNormal, DIR_TO_FLOAT4(normal));
1488+
vb.Set(idx+2, VDNormal, DIR_TO_FLOAT4(normal));
14891489
}
14901490
idx += 3;
14911491
}
@@ -1494,13 +1494,13 @@ void Polyhedron::Triangulate(VertexBuffer &vb, bool ccwIsFrontFacing) const
14941494

14951495
void Polyhedron::ToLineList(VertexBuffer &vb) const
14961496
{
1497-
std::vector<LineSegment> edges = Edges();
1497+
LineSegmentArray edges = Edges();
14981498

14991499
int startIndex = vb.AppendVertices((int)edges.size()*2);
15001500
for(int i = 0; i < (int)edges.size(); ++i)
15011501
{
1502-
vb.Set(startIndex+2*i, VDPosition, float4(edges[i].a, 1.f));
1503-
vb.Set(startIndex+2*i+1, VDPosition, float4(edges[i].b, 1.f));
1502+
vb.Set(startIndex+2*i, VDPosition, POINT_TO_FLOAT4(edges[i].a));
1503+
vb.Set(startIndex+2*i+1, VDPosition, POINT_TO_FLOAT4(edges[i].b));
15041504
}
15051505
}
15061506
#endif

src/Geometry/Sphere.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,9 @@ void Sphere::Triangulate(VertexBuffer &vb, int numVertices, bool ccwIsFrontFacin
13421342
int startIndex = vb.AppendVertices(numVertices);
13431343
for(int i = 0; i < (int)pos.size(); ++i)
13441344
{
1345-
vb.Set(startIndex+i, VDPosition, float4(pos[i],1.f));
1345+
vb.Set(startIndex+i, VDPosition, POINT_TO_FLOAT4(pos[i]));
13461346
if (vb.Declaration()->TypeOffset(VDNormal) >= 0)
1347-
vb.Set(startIndex+i, VDNormal, float4(normal[i],0.f));
1347+
vb.Set(startIndex+i, VDNormal, DIR_TO_FLOAT4(normal[i]));
13481348
if (vb.Declaration()->TypeOffset(VDUV) >= 0)
13491349
vb.SetFloat2(startIndex+i, VDUV, 0, uv[i]);
13501350
}

0 commit comments

Comments
 (0)