本文整理汇总了C++中AlignedArray::getBufferSize方法的典型用法代码示例。如果您正苦于以下问题:C++ AlignedArray::getBufferSize方法的具体用法?C++ AlignedArray::getBufferSize怎么用?C++ AlignedArray::getBufferSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AlignedArray
的用法示例。
在下文中一共展示了AlignedArray::getBufferSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lightPositions
void LightManager::_update4LightConsts( const SceneData &sgData,
GFXShaderConstHandle *lightPositionSC,
GFXShaderConstHandle *lightDiffuseSC,
GFXShaderConstHandle *lightAmbientSC,
GFXShaderConstHandle *lightInvRadiusSqSC,
GFXShaderConstHandle *lightSpotDirSC,
GFXShaderConstHandle *lightSpotAngleSC,
GFXShaderConstHandle *lightSpotFalloffSC,
GFXShaderConstBuffer *shaderConsts )
{
PROFILE_SCOPE( LightManager_Update4LightConsts );
// Skip over gathering lights if we don't have to!
if ( lightPositionSC->isValid() ||
lightDiffuseSC->isValid() ||
lightInvRadiusSqSC->isValid() ||
lightSpotDirSC->isValid() ||
lightSpotAngleSC->isValid() ||
lightSpotFalloffSC->isValid() )
{
PROFILE_SCOPE( LightManager_Update4LightConsts_setLights );
static AlignedArray<Point4F> lightPositions( 3, sizeof( Point4F ) );
static AlignedArray<Point4F> lightSpotDirs( 3, sizeof( Point4F ) );
static AlignedArray<Point4F> lightColors( 4, sizeof( Point4F ) );
static Point4F lightInvRadiusSq;
static Point4F lightSpotAngle;
static Point4F lightSpotFalloff;
F32 range;
// Need to clear the buffers so that we don't leak
// lights from previous passes or have NaNs.
dMemset( lightPositions.getBuffer(), 0, lightPositions.getBufferSize() );
dMemset( lightSpotDirs.getBuffer(), 0, lightSpotDirs.getBufferSize() );
dMemset( lightColors.getBuffer(), 0, lightColors.getBufferSize() );
lightInvRadiusSq = Point4F::Zero;
lightSpotAngle.set( -1.0f, -1.0f, -1.0f, -1.0f );
lightSpotFalloff.set( F32_MAX, F32_MAX, F32_MAX, F32_MAX );
// Gather the data for the first 4 lights.
const LightInfo *light;
for ( U32 i=0; i < 4; i++ )
{
light = sgData.lights[i];
if ( !light )
break;
// The light positions and spot directions are
// in SoA order to make optimal use of the GPU.
const Point3F &lightPos = light->getPosition();
lightPositions[0][i] = lightPos.x;
lightPositions[1][i] = lightPos.y;
lightPositions[2][i] = lightPos.z;
const VectorF &lightDir = light->getDirection();
lightSpotDirs[0][i] = lightDir.x;
lightSpotDirs[1][i] = lightDir.y;
lightSpotDirs[2][i] = lightDir.z;
if ( light->getType() == LightInfo::Spot )
{
lightSpotAngle[i] = mCos( mDegToRad( light->getOuterConeAngle() / 2.0f ) );
lightSpotFalloff[i] = 1.0f / getMax( F32_MIN, mCos( mDegToRad( light->getInnerConeAngle() / 2.0f ) ) - lightSpotAngle[i] );
}
// Prescale the light color by the brightness to
// avoid doing this in the shader.
lightColors[i] = Point4F(light->getColor()) * light->getBrightness();
// We need 1 over range^2 here.
range = light->getRange().x;
lightInvRadiusSq[i] = 1.0f / ( range * range );
}
shaderConsts->setSafe( lightPositionSC, lightPositions );
shaderConsts->setSafe( lightDiffuseSC, lightColors );
shaderConsts->setSafe( lightInvRadiusSqSC, lightInvRadiusSq );
shaderConsts->setSafe( lightSpotDirSC, lightSpotDirs );
shaderConsts->setSafe( lightSpotAngleSC, lightSpotAngle );
shaderConsts->setSafe( lightSpotFalloffSC, lightSpotFalloff );
}
// Setup the ambient lighting from the first
// light which is the directional light if
// one exists at all in the scene.
if ( lightAmbientSC->isValid() )
shaderConsts->set( lightAmbientSC, sgData.ambientLightColor );
}