Fix [#27463] COLLADA light quadratic attenuation exported wrong?
Reported by Pelle Johnsen Fix falloff import. Point light and Spot light always were set to inverse quad, instead of choosing the proper one based on imported values. The
This commit is contained in:
@@ -959,12 +959,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
|
||||
|
||||
if(IS_EQ(linatt, 0.0f) && quadatt > 0.0f) {
|
||||
att2 = quadatt;
|
||||
d = (1.0f/quadatt) * 2;
|
||||
d = sqrt(1.0f/quadatt);
|
||||
}
|
||||
// linear light
|
||||
else if(IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
|
||||
att1 = linatt;
|
||||
d = (1.0f/linatt) * 2;
|
||||
d = (1.0f/linatt);
|
||||
} else if (IS_EQ(constatt, 1.0f)) {
|
||||
att1 = 1.0f;
|
||||
} else {
|
||||
@@ -987,9 +987,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
|
||||
case COLLADAFW::Light::SPOT_LIGHT:
|
||||
{
|
||||
lamp->type = LA_SPOT;
|
||||
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
|
||||
lamp->att1 = att1;
|
||||
lamp->att2 = att2;
|
||||
if(IS_EQ(att1, 0.0f) && att2 > 0)
|
||||
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
|
||||
if(IS_EQ(att2, 0.0f) && att1 > 0)
|
||||
lamp->falloff_type = LA_FALLOFF_INVLINEAR;
|
||||
lamp->spotsize = light->getFallOffAngle().getValue();
|
||||
lamp->spotblend = light->getFallOffExponent().getValue();
|
||||
}
|
||||
@@ -1004,9 +1007,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
|
||||
case COLLADAFW::Light::POINT_LIGHT:
|
||||
{
|
||||
lamp->type = LA_LOCAL;
|
||||
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
|
||||
lamp->att1 = att1;
|
||||
lamp->att2 = att2;
|
||||
if(IS_EQ(att1, 0.0f) && att2 > 0)
|
||||
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
|
||||
if(IS_EQ(att2, 0.0f) && att1 > 0)
|
||||
lamp->falloff_type = LA_FALLOFF_INVLINEAR;
|
||||
}
|
||||
break;
|
||||
case COLLADAFW::Light::UNDEFINED:
|
||||
|
||||
@@ -68,20 +68,18 @@ void LightsExporter::operator()(Object *ob)
|
||||
std::string la_name(id_name(la));
|
||||
COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy);
|
||||
float e, d, constatt, linatt, quadatt;
|
||||
float r;
|
||||
|
||||
d = la->dist;
|
||||
r = d/2.0f;
|
||||
|
||||
constatt = 1.0f;
|
||||
|
||||
if(la->falloff_type==LA_FALLOFF_INVLINEAR) {
|
||||
linatt = 1.0f / r;
|
||||
linatt = 1.0f / d;
|
||||
quadatt = 0.0f;
|
||||
}
|
||||
else {
|
||||
linatt = 0.0f;
|
||||
quadatt = 1.0f / r;
|
||||
quadatt = 1.0f / (d * d);
|
||||
}
|
||||
|
||||
// sun
|
||||
|
||||
Reference in New Issue
Block a user