mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-05 21:40:31 +00:00
fix misbehaving imposter display
corrects display of imposters when pole capture is on
This commit is contained in:
parent
0d07823ecd
commit
39300b18a8
2 changed files with 25 additions and 23 deletions
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "torque.glsl"
|
||||
|
||||
|
||||
#line 25
|
||||
#define IMPOSTER_MAX_UVS 64
|
||||
|
||||
|
||||
|
|
@ -94,24 +94,22 @@ void imposter_v(
|
|||
|
||||
// First check to see if we need to render the top billboard.
|
||||
int index;
|
||||
/*
|
||||
if ( includePoles && ( lookPitch < polarAngle || lookPitch > sPi - polarAngle ) )
|
||||
if ( includePoles && ( lookPitch < polarHalfStep || lookPitch > M_PI_F - polarHalfStep ) )
|
||||
{
|
||||
index = numEquatorSteps * 3;
|
||||
index = numEquatorSteps * numPolarSteps;
|
||||
|
||||
// When we render the top/bottom billboard we always use
|
||||
// a fixed vector that matches the rotation of the object.
|
||||
rightVec = vec3( 1, 0, 0 ) * sCornerRight[corner];
|
||||
upVec = vec3( 0, 1, 0 ) * sCornerUp[corner];
|
||||
upVec = vec3( 0, -1, 0 ) * sCornerUp[corner];
|
||||
|
||||
if ( lookPitch > sPi - polarAngle )
|
||||
if ( lookPitch < polarHalfStep )
|
||||
{
|
||||
upVec = -upVec;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
// Calculate the rotation around the z axis then add the
|
||||
// equator half step. This gets the images to switch a
|
||||
|
|
@ -126,20 +124,23 @@ void imposter_v(
|
|||
|
||||
// TODO: How can we do this without conditionals?
|
||||
// Normalize the result to 0 to 2PI.
|
||||
if ( rotZ < 0.0 )
|
||||
if ( rotZ < 0 )
|
||||
rotZ += M_2PI_F;
|
||||
if ( rotZ > M_2PI_F )
|
||||
else if ( rotZ > M_2PI_F )
|
||||
rotZ -= M_2PI_F;
|
||||
if ( rotY < 0.0 )
|
||||
|
||||
if ( rotY < 0 )
|
||||
rotY += M_2PI_F;
|
||||
if ( rotY > M_PI_F ) // Not M_2PI_F?
|
||||
else if ( rotY > M_2PI_F )
|
||||
rotY -= M_2PI_F;
|
||||
|
||||
float polarIdx = round( abs( rotY ) / polarStepSize );
|
||||
int polarIdx = int(max(min(round( rotY / polarStepSize ), numPolarSteps-2),0));
|
||||
|
||||
// Get the index to the start of the right polar
|
||||
// images for this viewing angle.
|
||||
int numPolarOffset = int( float( numEquatorSteps ) * polarIdx );
|
||||
int numPolarOffset = numEquatorSteps * polarIdx;
|
||||
if (includePoles)
|
||||
numPolarOffset = (numEquatorSteps+2) * polarIdx;
|
||||
|
||||
// Calculate the final image index for lookup
|
||||
// of the texture coords.
|
||||
|
|
|
|||
|
|
@ -82,24 +82,22 @@ void imposter_v(
|
|||
|
||||
// First check to see if we need to render the top billboard.
|
||||
int index;
|
||||
/*
|
||||
if ( includePoles && ( lookPitch < polarAngle || lookPitch > sPi - polarAngle ) )
|
||||
if ( includePoles && ( lookPitch < polarHalfStep || lookPitch > (M_PI_F - polarHalfStep) ) )
|
||||
{
|
||||
index = numEquatorSteps * 3;
|
||||
index = numEquatorSteps * numPolarSteps;
|
||||
|
||||
// When we render the top/bottom billboard we always use
|
||||
// a fixed vector that matches the rotation of the object.
|
||||
rightVec = float3( 1, 0, 0 ) * sCornerRight[corner];
|
||||
upVec = float3( 0, 1, 0 ) * sCornerUp[corner];
|
||||
upVec = float3( 0, -1, 0 ) * sCornerUp[corner];
|
||||
|
||||
if ( lookPitch > sPi - polarAngle )
|
||||
if ( lookPitch < polarHalfStep )
|
||||
{
|
||||
upVec = -upVec;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
// Calculate the rotation around the z axis then add the
|
||||
// equator half step. This gets the images to switch a
|
||||
|
|
@ -116,19 +114,22 @@ void imposter_v(
|
|||
// Normalize the result to 0 to 2PI.
|
||||
if ( rotZ < 0 )
|
||||
rotZ += M_2PI_F;
|
||||
if ( rotZ > M_2PI_F )
|
||||
else if ( rotZ > M_2PI_F )
|
||||
rotZ -= M_2PI_F;
|
||||
|
||||
if ( rotY < 0 )
|
||||
rotY += M_2PI_F;
|
||||
if ( rotY > M_PI_F ) // Not M_2PI_F?
|
||||
else if ( rotY > M_2PI_F )
|
||||
rotY -= M_2PI_F;
|
||||
|
||||
float polarIdx = round( abs( rotY ) / polarStepSize );
|
||||
int polarIdx = max(min(round( rotY / polarStepSize ), numPolarSteps-2),0);
|
||||
|
||||
// Get the index to the start of the right polar
|
||||
// images for this viewing angle.
|
||||
int numPolarOffset = numEquatorSteps * polarIdx;
|
||||
|
||||
if (includePoles)
|
||||
numPolarOffset = (numEquatorSteps+2) * polarIdx;
|
||||
|
||||
// Calculate the final image index for lookup
|
||||
// of the texture coords.
|
||||
index = ( rotZ / equatorStepSize ) + numPolarOffset;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue