Added optimization to doRaycast().

This commit is contained in:
David Williams 2012-01-13 22:23:50 +00:00
parent a79633de09
commit a82dc7f1ca
2 changed files with 14 additions and 14 deletions

View File

@ -122,17 +122,17 @@ namespace PolyVox
int dj = ((y1 < y2) ? 1 : ((y1 > y2) ? -1 : 0));
int dk = ((z1 < z2) ? 1 : ((z1 > z2) ? -1 : 0));
float minx = floorf(x1), maxx = minx + 1.0f;
float tx = ((x1 > x2) ? (x1 - minx) : (maxx - x1)) / std::abs(x2 - x1);
float miny = floorf(y1), maxy = miny + 1.0f;
float ty = ((y1 > y2) ? (y1 - miny) : (maxy - y1)) / std::abs(y2 - y1);
float minz = floorf(z1), maxz = minz + 1.0f;
float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) / std::abs(z2 - z1);
float deltatx = 1.0f / std::abs(x2 - x1);
float deltaty = 1.0f / std::abs(y2 - y1);
float deltatz = 1.0f / std::abs(z2 - z1);
float minx = floorf(x1), maxx = minx + 1.0f;
float tx = ((x1 > x2) ? (x1 - minx) : (maxx - x1)) * deltatx;
float miny = floorf(y1), maxy = miny + 1.0f;
float ty = ((y1 > y2) ? (y1 - miny) : (maxy - y1)) * deltaty;
float minz = floorf(z1), maxz = minz + 1.0f;
float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) * deltatz;
m_sampVolume.setPosition(i,j,k);
m_result.previousVoxel = Vector3DInt32(i,j,k);

View File

@ -107,17 +107,17 @@ namespace PolyVox
int dj = ((y1 < y2) ? 1 : ((y1 > y2) ? -1 : 0));
int dk = ((z1 < z2) ? 1 : ((z1 > z2) ? -1 : 0));
float minx = floorf(x1), maxx = minx + 1.0f;
float tx = ((x1 > x2) ? (x1 - minx) : (maxx - x1)) / std::abs(x2 - x1);
float miny = floorf(y1), maxy = miny + 1.0f;
float ty = ((y1 > y2) ? (y1 - miny) : (maxy - y1)) / std::abs(y2 - y1);
float minz = floorf(z1), maxz = minz + 1.0f;
float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) / std::abs(z2 - z1);
float deltatx = 1.0f / std::abs(x2 - x1);
float deltaty = 1.0f / std::abs(y2 - y1);
float deltatz = 1.0f / std::abs(z2 - z1);
float minx = floorf(x1), maxx = minx + 1.0f;
float tx = ((x1 > x2) ? (x1 - minx) : (maxx - x1)) * deltatx;
float miny = floorf(y1), maxy = miny + 1.0f;
float ty = ((y1 > y2) ? (y1 - miny) : (maxy - y1)) * deltaty;
float minz = floorf(z1), maxz = minz + 1.0f;
float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) * deltatz;
m_sampVolume.setPosition(i,j,k);
for(;;)