Corrected infinite loop in octree generation that occurred due to NaN being returned as the AABB bounds for point lights and spot lights.

--HG--
branch : nfb
This commit is contained in:
2014-02-01 16:07:02 -08:00
parent 77550118f0
commit 9999b91ee1
4 changed files with 15 additions and 5 deletions

View File

@@ -34,7 +34,7 @@ std::string KRPointLight::getElementName() {
} }
KRAABB KRPointLight::getBounds() { KRAABB KRPointLight::getBounds() {
float influence_radius = sqrt((m_intensity / 100.0) / KRLIGHT_MIN_INFLUENCE - 1.0) + m_decayStart; float influence_radius = m_decayStart - sqrt(m_intensity * 0.01f) / sqrt(KRLIGHT_MIN_INFLUENCE);
if(influence_radius < m_flareOcclusionSize) { if(influence_radius < m_flareOcclusionSize) {
influence_radius = m_flareOcclusionSize; influence_radius = m_flareOcclusionSize;
} }
@@ -56,7 +56,7 @@ void KRPointLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
KRVector3 light_position = getLocalTranslation(); KRVector3 light_position = getLocalTranslation();
float influence_radius = sqrt((m_intensity / 100.0) / KRLIGHT_MIN_INFLUENCE - 1.0) + m_decayStart; float influence_radius = m_decayStart - sqrt(m_intensity * 0.01f) / sqrt(KRLIGHT_MIN_INFLUENCE);
KRMat4 sphereModelMatrix = KRMat4(); KRMat4 sphereModelMatrix = KRMat4();
sphereModelMatrix.scale(influence_radius); sphereModelMatrix.scale(influence_radius);

View File

@@ -479,8 +479,8 @@ void KRScene::updateOctree(const KRViewport &viewport)
{ {
m_pRootNode->updateLODVisibility(viewport); m_pRootNode->updateLODVisibility(viewport);
std::set<KRNode *> newNodes = m_newNodes; std::set<KRNode *> newNodes = std::move(m_newNodes);
std::set<KRNode *> modifiedNodes = m_modifiedNodes; std::set<KRNode *> modifiedNodes = std::move(m_modifiedNodes);
m_newNodes.clear(); m_newNodes.clear();
m_modifiedNodes.clear(); m_modifiedNodes.clear();

View File

@@ -49,3 +49,13 @@ void KRSpotLight::setInnerAngle(float innerAngle) {
void KRSpotLight::setOuterAngle(float outerAngle) { void KRSpotLight::setOuterAngle(float outerAngle) {
m_outerAngle = outerAngle; m_outerAngle = outerAngle;
} }
KRAABB KRSpotLight::getBounds() {
float influence_radius = m_decayStart - sqrt(m_intensity * 0.01f) / sqrt(KRLIGHT_MIN_INFLUENCE);
if(influence_radius < m_flareOcclusionSize) {
influence_radius = m_flareOcclusionSize;
}
return KRAABB(KRVector3(-influence_radius), KRVector3(influence_radius), getModelMatrix());
}

View File

@@ -19,7 +19,7 @@ public:
virtual std::string getElementName(); virtual std::string getElementName();
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent); virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
virtual void loadXML(tinyxml2::XMLElement *e); virtual void loadXML(tinyxml2::XMLElement *e);
virtual KRAABB getBounds();
float getInnerAngle(); float getInnerAngle();
float getOuterAngle(); float getOuterAngle();