Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Letwory <nathan@letworyinteractive.com>2011-06-13 19:07:36 +0400
committerNathan Letwory <nathan@letworyinteractive.com>2011-06-13 19:07:36 +0400
commit0af94b45e4220b213df3d344c71abc47abdd4612 (patch)
treec7f4f96f3fa595bf31b5c7852a5cb5b5f9a1d81a
parent4ca197ba590331246fbbcf7a78724ae3343ed0fc (diff)
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
-rw-r--r--source/blender/collada/DocumentImporter.cpp14
-rw-r--r--source/blender/collada/LightExporter.cpp6
2 files changed, 12 insertions, 8 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 72341e1caa2..10e6d611cc5 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -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:
diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
index 89599c62768..12ccf77f6ad 100644
--- a/source/blender/collada/LightExporter.cpp
+++ b/source/blender/collada/LightExporter.cpp
@@ -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