Well I applied the fix, and I'm still not getting any hits.
I suppose it would be more accurate to say that foundIntersection is never true.
Code:
//Generate some plants. This method will be replaced by voxel plants later.
int numTrees = rand() % 10;
int numPlants = rand() % 15;
Ogre::Vector4 * plantList = new Ogre::Vector4[numTrees + numPlants];
PolyVox::RaycastResult groundCheckResult;
Raycast<LargeVolume, MaterialDensityPair44> groundCheck(mWorldVoxels, Vector3DFloat(0,0,0), Vector3DFloat(0,0,0), groundCheckResult);
for(int i = 0; i < numTrees; i++)
{
int x = rand() % 32 + 1;
int z = rand() % 32 + 1;
x += reg.getLowerCorner().getX();
z += reg.getLowerCorner().getZ();
stringstream test;
test << "Chunk Number: " << x / 32 << " " << reg.getLowerCorner().getY() / 32 << " " << z / 32 << "\n";
test << "generated coordinates: " << x << " " << z << "\n";
OutputDebugString(test.str().c_str());
groundCheck.setStart(Vector3DFloat(x,75,z));
groundCheck.setDirection(Vector3DFloat(0,-1,0));
groundCheck.execute();
//If we hit something
if(groundCheckResult.foundIntersection)
{
OutputDebugString("Hit!\n");
//check if it is within bounds
if(groundCheckResult.intersectionVoxel.getY() < reg.getUpperCorner().getY() && groundCheckResult.intersectionVoxel.getY() > 32 && groundCheckResult.intersectionVoxel.getY() > -64)
{
plantList[i] = Ogre::Vector4(x,groundCheckResult.intersectionVoxel.getY(),z,0);
stringstream ss;
ss << "new loc" << plantList[i].x << " " << plantList[i].y << " " << plantList[i].z << " " << plantList[i].w << "\n";
OutputDebugString(ss.str().c_str());
}
else
break;
}
}
I never get the "Hit!" debug message which would indicate that my ray never hits anything in my volume.
I am now using a proper direction, but it still never hits anything in my volume. I'm following the example pretty closely, I'm not sure where I could be going wrong this time.