Fix regression from stereo branch in wind tree

This commit is contained in:
kaetemi 2013-09-14 18:58:23 +02:00
parent 60cd1f6116
commit adcb3e032b
4 changed files with 18 additions and 4 deletions

View file

@ -280,7 +280,8 @@ public:
*/ */
void changeLightSetup(CLightContribution *lightContribution, bool useLocalAttenuation); void changeLightSetup(CLightContribution *lightContribution, bool useLocalAttenuation);
/// Must call before beginVPLightSetup
void prepareVPLightSetup();
/** setup the driver VP constants to get info from current LightSetup. /** setup the driver VP constants to get info from current LightSetup.
* Only 0..3 Light + SunLights are supported. The VP do NOT support distance/Spot attenuation * Only 0..3 Light + SunLights are supported. The VP do NOT support distance/Spot attenuation
* Also it does not handle World Matrix with non uniform scale correctly since lighting is made in ObjectSpace * Also it does not handle World Matrix with non uniform scale correctly since lighting is made in ObjectSpace

View file

@ -515,6 +515,7 @@ bool CMeshVPPerPixelLight::begin(IDriver *drv,
// //
CRenderTrav *renderTrav= &scene->getRenderTrav(); CRenderTrav *renderTrav= &scene->getRenderTrav();
/// Setup for gouraud lighting /// Setup for gouraud lighting
renderTrav->prepareVPLightSetup();
renderTrav->beginVPLightSetup(program, invertedModelMat); renderTrav->beginVPLightSetup(program, invertedModelMat);
// //
sint strongestLightIndex = renderTrav->getStrongestLightIndex(); sint strongestLightIndex = renderTrav->getStrongestLightIndex();

View file

@ -385,6 +385,8 @@ bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *m
// Activate the good VertexProgram // Activate the good VertexProgram
//=============== //===============
// Update nb vp lights
renderTrav->prepareVPLightSetup();
// Get how many pointLights are setuped now. // Get how many pointLights are setuped now.
nlassert(scene != NULL); nlassert(scene != NULL);
@ -510,6 +512,9 @@ void CMeshVPWindTree::beginMBRMesh(IDriver *driver, CScene *scene)
// *************************************************************************** // ***************************************************************************
void CMeshVPWindTree::beginMBRInstance(IDriver *driver, CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat) void CMeshVPWindTree::beginMBRInstance(IDriver *driver, CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat)
{ {
// Update nb vp lights
renderTrav->prepareVPLightSetup();
// Get how many pointLights are setuped now. // Get how many pointLights are setuped now.
nlassert(scene != NULL); nlassert(scene != NULL);
CRenderTrav *renderTrav= &scene->getRenderTrav(); CRenderTrav *renderTrav= &scene->getRenderTrav();

View file

@ -760,13 +760,20 @@ void CRenderTrav::changeLightSetup(CLightContribution *lightContribution, bool
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
void CRenderTrav::prepareVPLightSetup()
{
nlassert(MaxVPLight==4);
_VPNumLights= min(_NumLightEnabled, (uint)MaxVPLight);
// Must force real light setup at least the first time, in changeVPLightSetupMaterial()
_VPMaterialCacheDirty= true;
}
// *************************************************************************** // ***************************************************************************
void CRenderTrav::beginVPLightSetup(CVertexProgramLighted *program, const CMatrix &invObjectWM) void CRenderTrav::beginVPLightSetup(CVertexProgramLighted *program, const CMatrix &invObjectWM)
{ {
uint i; uint i;
nlassert(MaxVPLight==4); // nlassert(MaxVPLight==4);
_VPNumLights= min(_NumLightEnabled, (uint)MaxVPLight); // _VPNumLights= min(_NumLightEnabled, (uint)MaxVPLight);
// _VPCurrentCtStart= ctStart; // _VPCurrentCtStart= ctStart;
// _VPSupportSpecular= supportSpecular; // _VPSupportSpecular= supportSpecular;
_VPCurrent = program; _VPCurrent = program;