mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Merge pull request #1306 from Azaezel/alpha41/sus
fix misbehaving imposter display
This commit is contained in:
commit
6fcfff44a3
2 changed files with 25 additions and 23 deletions
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "torque.glsl"
|
#include "torque.glsl"
|
||||||
|
|
||||||
|
#line 25
|
||||||
#define IMPOSTER_MAX_UVS 64
|
#define IMPOSTER_MAX_UVS 64
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -94,24 +94,22 @@ void imposter_v(
|
||||||
|
|
||||||
// First check to see if we need to render the top billboard.
|
// First check to see if we need to render the top billboard.
|
||||||
int index;
|
int index;
|
||||||
/*
|
if ( includePoles && ( lookPitch < polarHalfStep || lookPitch > M_PI_F - polarHalfStep ) )
|
||||||
if ( includePoles && ( lookPitch < polarAngle || lookPitch > sPi - polarAngle ) )
|
|
||||||
{
|
{
|
||||||
index = numEquatorSteps * 3;
|
index = numEquatorSteps * numPolarSteps;
|
||||||
|
|
||||||
// When we render the top/bottom billboard we always use
|
// When we render the top/bottom billboard we always use
|
||||||
// a fixed vector that matches the rotation of the object.
|
// a fixed vector that matches the rotation of the object.
|
||||||
rightVec = vec3( 1, 0, 0 ) * sCornerRight[corner];
|
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;
|
upVec = -upVec;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
// Calculate the rotation around the z axis then add the
|
// Calculate the rotation around the z axis then add the
|
||||||
// equator half step. This gets the images to switch a
|
// 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?
|
// TODO: How can we do this without conditionals?
|
||||||
// Normalize the result to 0 to 2PI.
|
// Normalize the result to 0 to 2PI.
|
||||||
if ( rotZ < 0.0 )
|
if ( rotZ < 0 )
|
||||||
rotZ += M_2PI_F;
|
rotZ += M_2PI_F;
|
||||||
if ( rotZ > M_2PI_F )
|
else if ( rotZ > M_2PI_F )
|
||||||
rotZ -= M_2PI_F;
|
rotZ -= M_2PI_F;
|
||||||
if ( rotY < 0.0 )
|
|
||||||
|
if ( rotY < 0 )
|
||||||
rotY += M_2PI_F;
|
rotY += M_2PI_F;
|
||||||
if ( rotY > M_PI_F ) // Not M_2PI_F?
|
else if ( rotY > M_2PI_F )
|
||||||
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
|
// Get the index to the start of the right polar
|
||||||
// images for this viewing angle.
|
// 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
|
// Calculate the final image index for lookup
|
||||||
// of the texture coords.
|
// of the texture coords.
|
||||||
|
|
|
||||||
|
|
@ -82,24 +82,22 @@ void imposter_v(
|
||||||
|
|
||||||
// First check to see if we need to render the top billboard.
|
// First check to see if we need to render the top billboard.
|
||||||
int index;
|
int index;
|
||||||
/*
|
if ( includePoles && ( lookPitch < polarHalfStep || lookPitch > (M_PI_F - polarHalfStep) ) )
|
||||||
if ( includePoles && ( lookPitch < polarAngle || lookPitch > sPi - polarAngle ) )
|
|
||||||
{
|
{
|
||||||
index = numEquatorSteps * 3;
|
index = numEquatorSteps * numPolarSteps;
|
||||||
|
|
||||||
// When we render the top/bottom billboard we always use
|
// When we render the top/bottom billboard we always use
|
||||||
// a fixed vector that matches the rotation of the object.
|
// a fixed vector that matches the rotation of the object.
|
||||||
rightVec = float3( 1, 0, 0 ) * sCornerRight[corner];
|
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;
|
upVec = -upVec;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
// Calculate the rotation around the z axis then add the
|
// Calculate the rotation around the z axis then add the
|
||||||
// equator half step. This gets the images to switch a
|
// equator half step. This gets the images to switch a
|
||||||
|
|
@ -116,19 +114,22 @@ void imposter_v(
|
||||||
// Normalize the result to 0 to 2PI.
|
// Normalize the result to 0 to 2PI.
|
||||||
if ( rotZ < 0 )
|
if ( rotZ < 0 )
|
||||||
rotZ += M_2PI_F;
|
rotZ += M_2PI_F;
|
||||||
if ( rotZ > M_2PI_F )
|
else if ( rotZ > M_2PI_F )
|
||||||
rotZ -= M_2PI_F;
|
rotZ -= M_2PI_F;
|
||||||
|
|
||||||
if ( rotY < 0 )
|
if ( rotY < 0 )
|
||||||
rotY += M_2PI_F;
|
rotY += M_2PI_F;
|
||||||
if ( rotY > M_PI_F ) // Not M_2PI_F?
|
else if ( rotY > M_2PI_F )
|
||||||
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
|
// Get the index to the start of the right polar
|
||||||
// images for this viewing angle.
|
// images for this viewing angle.
|
||||||
int numPolarOffset = numEquatorSteps * polarIdx;
|
int numPolarOffset = numEquatorSteps * polarIdx;
|
||||||
|
if (includePoles)
|
||||||
|
numPolarOffset = (numEquatorSteps+2) * polarIdx;
|
||||||
|
|
||||||
// Calculate the final image index for lookup
|
// Calculate the final image index for lookup
|
||||||
// of the texture coords.
|
// of the texture coords.
|
||||||
index = ( rotZ / equatorStepSize ) + numPolarOffset;
|
index = ( rotZ / equatorStepSize ) + numPolarOffset;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue