Skip to content

Commit 00eda9c

Browse files
committed
pspRT updates windows compat
1 parent 445e671 commit 00eda9c

File tree

2 files changed

+0
-138
lines changed

2 files changed

+0
-138
lines changed

cpp/include/utils/pspRTmem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
*/
3232

3333
#if defined(_MSC_VER)
34-
#define NOMINMAX
3534
#pragma once
3635
#endif
3736

cpp/raycast/pspRT.cpp

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
//#define DBG
55
#include "utils/pspRT.h"
6-
#include "utils/pspDbg.h"
76
#include "utils/pspTimer.h"
87

98
using namespace std;
@@ -47,13 +46,8 @@ rt::Ray::Ray(const V3f& orig, const V3f& dir) :
4746
{
4847
// blute: 2019-May-28 watertight fixes
4948

50-
VAR3( o[0],o[1],o[2] );
51-
VAR3( d[0],d[1],d[2] );
52-
5349
V3f ad = ABS(d);
5450
int md = MAX_DIM(ad);
55-
VAR( ad );
56-
VAR( md );
5751

5852
// calculate dimension where the raydirection is maximal
5953
kz = MAX_DIM( ABS(d) );
@@ -62,16 +56,10 @@ rt::Ray::Ray(const V3f& orig, const V3f& dir) :
6256
// swap kx and ky dim to preserve winding dir of triangles
6357
if( d[kz] < 0.f ) std::swap(kx,ky);
6458

65-
VAR3( kx,ky,kz );
66-
6759
// calculate shear constants, to make ray unit length aligned with Z
6860
Sx = d[kx] / d[kz];
6961
Sy = d[ky] / d[kz];
7062
Sz = 1.f / d[kz];
71-
VAR( d[kz] );
72-
VAR( (1.f/d[kz]) )
73-
74-
VAR3( Sx,Sy,Sz );
7563

7664
// old
7765
i[0] = 1.0f / d[0];
@@ -117,31 +105,15 @@ rt::Triangle::bounds(void) const
117105
return res;
118106
}
119107

120-
#if 1
121-
122108
bool
123109
rt::Triangle::intersect(const Ray &ray, Hit *hit) const
124110
{
125-
VAR( ray.kx );
126-
VAR( ray.ky );
127-
VAR( ray.kz );
128-
129-
VAR( ray.Sx );
130-
VAR( ray.Sy );
131-
VAR( ray.Sz );
132-
133111
const Imath::V3f &origA = mesh->p[vi[0]];
134112
const Imath::V3f &origB = mesh->p[vi[1]];
135113
const Imath::V3f &origC = mesh->p[vi[2]];
136-
VAR( origA );
137-
VAR( origB );
138-
VAR( origC );
139114
const Imath::V3f A = origA - ray.o;
140115
const Imath::V3f B = origB - ray.o;
141116
const Imath::V3f C = origC - ray.o;
142-
VAR( A );
143-
VAR( B );
144-
VAR( C );
145117

146118
// shear/scale verts
147119
const float Ax = A[ray.kx] - ray.Sx * A[ray.kz];
@@ -156,10 +128,6 @@ rt::Triangle::intersect(const Ray &ray, Hit *hit) const
156128
float V = Ax*Cy - Ay*Cx;
157129
float W = Bx*Ay - By*Ax;
158130

159-
VAR( U );
160-
VAR( V );
161-
VAR( W );
162-
163131
// fall back to dbl prec test for edges
164132
if( U==0.f or V==0.f or W==0.f )
165133
{
@@ -223,83 +191,6 @@ rt::Triangle::intersect(const Ray &ray, Hit *hit) const
223191
return true;
224192
}
225193

226-
#else
227-
228-
bool
229-
rt::Triangle::intersect(const Ray &ray, Hit *hit) const
230-
{
231-
const Imath::V3f &v0 = mesh->p[vi[0]];
232-
const Imath::V3f &v1 = mesh->p[vi[1]];
233-
const Imath::V3f &v2 = mesh->p[vi[2]];
234-
const Imath::V3f edge1 = v1 - v0;
235-
const Imath::V3f edge2 = v2 - v0;
236-
const Imath::V3f pvec = ray.d.cross(edge2);
237-
const float det = edge1.dot(pvec);
238-
if (det == 0.f ) {
239-
MESG("rt::hitTri: missed 0");
240-
VAR( ray.o );
241-
VAR( ray.d );
242-
VAR( v0 );
243-
VAR( v1 );
244-
VAR( v2 );
245-
return false;
246-
}
247-
const float idet = 1.f/det;
248-
const Imath::V3f tvec = ray.o - v0;
249-
const float u = idet * tvec.dot(pvec);
250-
if (u < 0.0f || u > 1.0f) {
251-
MESG("rt::hitTri: missed 1");
252-
VAR( ray.o );
253-
VAR( ray.d );
254-
VAR( v0 );
255-
VAR( v1 );
256-
VAR( v2 );
257-
VAR( u );
258-
return false;
259-
}
260-
const Imath::V3f qvec = tvec.cross(edge1);
261-
const float v = idet * ray.d.dot(qvec);
262-
if (v < 0.0f || u + v > 1.0f) {
263-
MESG("rt::hitTri: missed 2");
264-
VAR( ray.o );
265-
VAR( ray.d );
266-
VAR( v0 );
267-
VAR( v1 );
268-
VAR( v2 );
269-
VAR( u );
270-
VAR( v );
271-
return false;
272-
}
273-
const float t = idet * edge2.dot(qvec);
274-
if( t < 0.f or t > ray.tmax ) {
275-
MESG("rt::hitTri: missed 3");
276-
VAR( ray.o );
277-
VAR( ray.d );
278-
VAR( ray.tmax );
279-
VAR( v0 );
280-
VAR( v1 );
281-
VAR( v2 );
282-
VAR( u );
283-
VAR( v );
284-
VAR( t );
285-
286-
return false;
287-
}
288-
289-
//std::cerr<<" === tri hit ===\n";
290-
hit->t = t;
291-
hit->pos = ray.o + t * ray.d;
292-
hit->nrm = edge1.cross(edge2);
293-
hit->u=u;
294-
hit->v=v;
295-
hit->w=1.f - (u + v);
296-
hit->primID = primID;
297-
298-
if( hit->nrm.dot(ray.d) > 0.f ) hit->nrm = -hit->nrm;
299-
return true;
300-
}
301-
#endif
302-
303194
////////////////////////////// TriangleMesh //////////////////////////////
304195

305196
rt::TriangleMesh::TriangleMesh(const std::vector<Imath::V3f>& t, const size_t stride) :
@@ -309,23 +200,18 @@ rt::TriangleMesh::TriangleMesh(const std::vector<Imath::V3f>& t, const size_t st
309200
p = t;
310201
for(int tidx=0;tidx<nVertices;++tidx)
311202
vertexIndices.push_back(tidx);
312-
VAR( nVertices );
313-
VAR( nTriangles );
314-
VAR( vertexIndices.size() );
315203
}
316204

317205
std::vector<std::shared_ptr<rt::Primitive>>
318206
rt::CreateTriangleMesh(const std::vector<float>& raw, size_t stride)
319207
{
320208

321209
size_t nv = raw.size()/stride;
322-
VAR( nv );
323210
std::vector<Imath::V3f> inTris( nv );
324211
for( size_t vidx=0; vidx<nv ; ++vidx ){
325212
const float* v = raw.data() + vidx*stride;
326213
inTris[vidx] = Imath::V3f(v[0],v[1],v[2]);
327214
}
328-
VAR( inTris.size() );
329215
std::shared_ptr<TriangleMesh> mesh = std::make_shared<TriangleMesh>(inTris, stride);
330216
std::vector<std::shared_ptr<Primitive>> outTris;
331217
outTris.reserve(mesh->nTriangles);
@@ -449,31 +335,11 @@ rt::BVH::BVH(const std::vector<std::shared_ptr<Primitive>> &p, int maxPrimsInNod
449335
BuildNode *root = recursiveBuild(arena, primitiveInfo, 0, primitives.size(), &totalNodes, orderedPrims);
450336
primitives.swap(orderedPrims);
451337

452-
//Box3f buildbox = checkbuild(root);
453-
//VAR( buildbox.min );
454-
//VAR( buildbox.max );
455-
456338
nodes = AllocAligned<LinearNode>(totalNodes);
457339

458340
int offset = 0;
459341
flattenTree(root, &offset);
460342
ASSERT(offset == totalNodes);
461-
462-
//Box3f bvhbox = bounds();
463-
//VAR( bvhbox.min );
464-
//VAR( bvhbox.max );
465-
//for(int d=0;d<3;++d){ASSERT( bvhbox.min[d] <= buildbox.min[d] and buildbox.max[d] <= bvhbox.max[d] );}
466-
467-
//auto aend = std::chrono::system_clock::now();
468-
//std::chrono::duration<double> atime = aend - abgn;
469-
//std::cout << "time to build BVH " << atime.count() << "s" << std::endl;
470-
471-
/*
472-
std::cout << " total primitives "<<commas(totalPrimitives)<<"\n";
473-
std::cout << " leaf nodes "<<commas(leafNodes)<<"\n";
474-
std::cout << " interior nodes "<<commas(interiorNodes)<<"\n";
475-
std::cout << " total nodes "<<commas(totalNodes)<<"\n";
476-
*/
477343
}
478344

479345
rt::BVH::~BVH(void)
@@ -508,8 +374,6 @@ rt::BVH::intersect(const Ray &ray, Hit *isect) const
508374

509375
while (true) {
510376

511-
VAR( currentNodeIndex );
512-
513377
const LinearNode *node = &nodes[currentNodeIndex];
514378

515379
// Check ray against BVH node
@@ -659,7 +523,6 @@ rt::BVH::recursiveBuild(MemoryArena &arena,
659523
}
660524
cost[i] = 1.f + ((float)count0 * rt::SurfaceArea(b0) +
661525
(float)count1 * rt::SurfaceArea(b1)) / rt::SurfaceArea(bounds);
662-
//VAR2( i, cost[i] );
663526
} // for i
664527

665528
// Find bucket to split at that minimizes SAH metric

0 commit comments

Comments
 (0)