Change Encyclo button name and macros icon
[ryzomcore.git] / nel / src / 3d / light_influence_interpolator.cpp
blobd6e90bd182e7fd85fbf8c121af5b99c087fbd5ff
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std3d.h"
19 #include "nel/3d/light_influence_interpolator.h"
20 #include "nel/misc/debug.h"
21 #include "nel/3d/point_light_named.h"
23 #ifdef DEBUG_NEW
24 #define new DEBUG_NEW
25 #endif
27 namespace NL3D
31 // ***************************************************************************
32 void CLightInfluenceInterpolator::interpolate(std::vector<CPointLightInfluence> &pointLightList, float subX, float subY)
34 uint crn;
35 // UnRolled loops.
36 nlassert(NumLightPerCorner==2);
38 // Reset index for each light.
39 for(crn= 0; crn<4; crn++)
41 CCorner &corner= Corners[crn];
42 // UnRolled.
43 if(corner.Lights[0])
44 corner.Lights[0]->_IdInInfluenceList= -1;
45 if(corner.Lights[1])
46 corner.Lights[1]->_IdInInfluenceList= -1;
49 // Compute biLinear influence on each corner
50 Corners[0].Influence= (1-subX) * (1-subY);
51 Corners[1].Influence= subX * (1-subY);
52 Corners[2].Influence= (1-subX) * subY;
53 Corners[3].Influence= subX * subY;
55 // For each light of each corner
56 for(crn= 0; crn<4; crn++)
58 CCorner &corner= Corners[crn];
59 // UnRolled.
60 // light 0.
61 if(corner.Lights[0])
63 if(corner.Lights[0]->_IdInInfluenceList==-1)
65 // append a PointLightInfluence
66 pointLightList.push_back(CPointLightInfluence());
67 sint id= (sint)pointLightList.size()-1;
68 // setup the PointLightInfluence
69 corner.Lights[0]->_IdInInfluenceList= id;
70 pointLightList[id].PointLight= corner.Lights[0];
71 pointLightList[id].Influence= corner.Influence;
73 else
75 // get the PointLightInfluence
76 sint id= corner.Lights[0]->_IdInInfluenceList;
77 // increment the influence of the PointLightInfluence
78 pointLightList[id].Influence+= corner.Influence;
81 // light 1.
82 if(corner.Lights[1])
84 if(corner.Lights[1]->_IdInInfluenceList==-1)
86 // append a PointLightInfluence
87 pointLightList.push_back(CPointLightInfluence());
88 sint id= (sint)pointLightList.size()-1;
89 // setup the PointLightInfluence
90 corner.Lights[1]->_IdInInfluenceList= id;
91 pointLightList[id].PointLight= corner.Lights[1];
92 pointLightList[id].Influence= corner.Influence;
94 else
96 // get the PointLightInfluence
97 sint id= corner.Lights[1]->_IdInInfluenceList;
98 // increment the influence of the PointLightInfluence
99 pointLightList[id].Influence+= corner.Influence;
107 } // NL3D