29#ifndef GU_CUBE_INDEX_H
30#define GU_CUBE_INDEX_H
32#include "foundation/PxVec3.h"
33#include "foundation/PxFPU.h"
47 CUBE_FORCE_DWORD = 0x7fffffff
86 PX_INLINE PxU32 ComputeCubemapOffset(
const PxVec3& dir, PxU32 subdiv)
92 const float Coeff = 0.5f * float(subdiv-1);
93 u += 1.0f; u *= Coeff;
94 v += 1.0f; v *= Coeff;
97 return PxU32(CI)*(subdiv*subdiv) + PxU32(u)*subdiv + PxU32(v);
101 PX_INLINE PxU32 ComputeCubemapNearestOffset(
const PxVec3& dir, PxU32 subdiv)
107 const float Coeff = 0.5f * float(subdiv-1);
108 u += 1.0f; u *= Coeff;
109 v += 1.0f; v *= Coeff;
112 return PxU32(CI)*(subdiv*subdiv) + PxU32(u + 0.5f)*subdiv + PxU32(v + 0.5f);
118 const PxU32* binary =
reinterpret_cast<const PxU32*
>(&direction.x);
120 const PxU32 absPx = binary[0] & ~PX_SIGN_BITMASK;
121 const PxU32 absNy = binary[1] & ~PX_SIGN_BITMASK;
122 const PxU32 absNz = binary[2] & ~PX_SIGN_BITMASK;
127 if( (absNy > absPx) & (absNy > absNz))
134 else if(absNz > absPx)
142 const PxF32* data = &direction.x;
143 const float Coeff = 1.0f / fabsf(data[Index1]);
144 u = data[Index2] * Coeff;
145 v = data[Index3] * Coeff;
147 const PxU32 Sign = binary[Index1]>>31;
148 return CubeIndex(Sign|(Index1+Index1));
3 Element vector class.
Definition PxVec3.h:50
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_INLINE CubeIndex CubemapLookup(const PxVec3 &direction, float &u, float &v)
Definition GuCubeIndex.h:116