Revision: 37454
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37454
Author: jesterking
Date: 2011-06-13 15:07:36 +0000 (Mon, 13 Jun 2011)
Log Message:
-----------
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
Modified Paths:
--------------
trunk/blender/source/blender/collada/DocumentImporter.cpp
trunk/blender/source/blender/collada/LightExporter.cpp
Modified: trunk/blender/source/blender/collada/DocumentImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentImporter.cpp 2011-06-13
14:56:47 UTC (rev 37453)
+++ trunk/blender/source/blender/collada/DocumentImporter.cpp 2011-06-13
15:07:36 UTC (rev 37454)
@@ -959,12 +959,12 @@
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 @@
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 @@
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:
Modified: trunk/blender/source/blender/collada/LightExporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/LightExporter.cpp 2011-06-13
14:56:47 UTC (rev 37453)
+++ trunk/blender/source/blender/collada/LightExporter.cpp 2011-06-13
15:07:36 UTC (rev 37454)
@@ -68,20 +68,18 @@
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
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs