Browse Source

Add a directional light to the physics playground

Panagiotis Christopoulos Charitos 7 years ago
parent
commit
2372bb5373

BIN
samples/physics_playground/assets/physics_playground.blend


+ 3 - 4
samples/physics_playground/assets/scene.lua

@@ -232,18 +232,17 @@ trf:setScale(1)
 node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
 node = scene:newStaticCollisionNode("wallwalls_001-materialnone20_cl", "assets/wall.ankicl", trf)
 
-node = scene:newPointLightNode("Lamp")
+node = scene:newDirectionalLightNode("Lamp")
 lcomp = node:getSceneNodeBase():getLightComponent()
 lcomp:setDiffuseColor(Vec4.new(50, 50, 50, 1))
-lcomp:setRadius(300)
 trf = Transform.new()
 trf:setOrigin(Vec4.new(4.07624, 74.4447, -1.00545, 0))
 rot = Mat3x4.new()
-rot:setAll(-0.290865, -0.771075, 0.566429, 0, -0.0551891, 0.604562, 0.794644, 0, -0.955171, 0.199873, -0.2184, 0)
+rot:setAll(0.649201, -0.658201, -0.381195, 0, 0.506372, 3.995e-05, 0.862315, 0, -0.567562, -0.752842, 0.33332, 0)
 trf:setRotation(rot)
 trf:setScale(1)
 node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
-lcomp:setShadowEnabled(0)
+lcomp:setShadowEnabled(1)
 
 node = scene:newPointLightNode("Lamp_001")
 lcomp = node:getSceneNodeBase():getLightComponent()

+ 2 - 1
src/anki/scene/components/LightComponent.cpp

@@ -134,7 +134,8 @@ void LightComponent::setupDirectionalLightQueueElement(const Frustum& frustum,
 			const F32 a = f * tan(fovY / 2.0f) * fovX / fovY;
 			const F32 b = n * tan(fovY / 2.0f) * fovX / fovY;
 			const F32 z = (b * b + n * n - a * a - f * f) / (2.0f * (f - n));
-			ANKI_ASSERT(isZero((Vec2(a, -f) - Vec2(0, z)).getLength() - (Vec2(b, -n) - Vec2(0, z)).getLength()));
+			ANKI_ASSERT(absolute((Vec2(a, -f) - Vec2(0, z)).getLength() - (Vec2(b, -n) - Vec2(0, z)).getLength())
+						<= EPSILON * 100.0f);
 
 			Vec3 C(0.0f, 0.0f, z); // Sphere center