Raycast now track previous voxel, for working out which direction you came from.
This commit is contained in:
parent
b84147f650
commit
ddc54e0862
@ -41,6 +41,7 @@ namespace PolyVox
|
||||
bool foundIntersection;
|
||||
///If an intersection was found then this field holds the intersecting voxel, otherwise it is undefined.
|
||||
Vector3DInt32 intersectionVoxel;
|
||||
Vector3DInt32 previousVoxel;
|
||||
};
|
||||
|
||||
/// The Raycast class can be used to find the fist filled voxel along a given path.
|
||||
|
@ -134,6 +134,7 @@ namespace PolyVox
|
||||
float deltatz = 1.0f / abs(z2 - z1);
|
||||
|
||||
m_sampVolume.setPosition(i,j,k);
|
||||
m_result.previousVoxel = Vector3DInt32(i,j,k);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
@ -143,7 +144,7 @@ namespace PolyVox
|
||||
m_result.intersectionVoxel = Vector3DInt32(i,j,k);
|
||||
return;
|
||||
}
|
||||
|
||||
m_result.previousVoxel = Vector3DInt32(i,j,k);
|
||||
if(tx <= ty && tx <= tz)
|
||||
{
|
||||
if(i == iend) break;
|
||||
@ -174,5 +175,6 @@ namespace PolyVox
|
||||
//Didn't hit anything
|
||||
m_result.foundIntersection = false;
|
||||
m_result.intersectionVoxel = Vector3DInt32(0,0,0);
|
||||
m_result.previousVoxel = Vector3DInt32(0,0,0);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user