|
|
@@ -46,7 +46,7 @@ ReflectionProbeNode::~ReflectionProbeNode()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-Error ReflectionProbeNode::init(F32 radius)
|
|
|
+Error ReflectionProbeNode::init(const Vec4& aabbMinLSpace, const Vec4& aabbMaxLSpace)
|
|
|
{
|
|
|
// Move component first
|
|
|
newComponent<MoveComponent>(this);
|
|
|
@@ -55,28 +55,28 @@ Error ReflectionProbeNode::init(F32 radius)
|
|
|
newComponent<ReflectionProbeMoveFeedbackComponent>(this);
|
|
|
|
|
|
// The frustum components
|
|
|
- const F32 ang = toRad(90.0);
|
|
|
+ const F32 ang = toRad(90.0f);
|
|
|
const F32 zNear = FRUSTUM_NEAR_PLANE;
|
|
|
|
|
|
Mat3 rot;
|
|
|
|
|
|
- rot = Mat3(Euler(0.0, -PI / 2.0, 0.0)) * Mat3(Euler(0.0, 0.0, PI));
|
|
|
+ rot = Mat3(Euler(0.0f, -PI / 2.0f, 0.0f)) * Mat3(Euler(0.0f, 0.0f, PI));
|
|
|
m_cubeSides[0].m_localTrf.setRotation(Mat3x4(rot));
|
|
|
- rot = Mat3(Euler(0.0, PI / 2.0, 0.0)) * Mat3(Euler(0.0, 0.0, PI));
|
|
|
+ rot = Mat3(Euler(0.0f, PI / 2.0f, 0.0f)) * Mat3(Euler(0.0f, 0.0f, PI));
|
|
|
m_cubeSides[1].m_localTrf.setRotation(Mat3x4(rot));
|
|
|
- rot = Mat3(Euler(PI / 2.0, 0.0, 0.0));
|
|
|
+ rot = Mat3(Euler(PI / 2.0f, 0.0f, 0.0f));
|
|
|
m_cubeSides[2].m_localTrf.setRotation(Mat3x4(rot));
|
|
|
- rot = Mat3(Euler(-PI / 2.0, 0.0, 0.0));
|
|
|
+ rot = Mat3(Euler(-PI / 2.0f, 0.0f, 0.0f));
|
|
|
m_cubeSides[3].m_localTrf.setRotation(Mat3x4(rot));
|
|
|
- rot = Mat3(Euler(0.0, PI, 0.0)) * Mat3(Euler(0.0, 0.0, PI));
|
|
|
+ rot = Mat3(Euler(0.0f, PI, 0.0f)) * Mat3(Euler(0.0f, 0.0f, PI));
|
|
|
m_cubeSides[4].m_localTrf.setRotation(Mat3x4(rot));
|
|
|
- rot = Mat3(Euler(0.0, 0.0, PI));
|
|
|
+ rot = Mat3(Euler(0.0f, 0.0f, PI));
|
|
|
m_cubeSides[5].m_localTrf.setRotation(Mat3x4(rot));
|
|
|
|
|
|
for(U i = 0; i < 6; ++i)
|
|
|
{
|
|
|
- m_cubeSides[i].m_localTrf.setOrigin(Vec4(0.0));
|
|
|
- m_cubeSides[i].m_localTrf.setScale(1.0);
|
|
|
+ m_cubeSides[i].m_localTrf.setOrigin(Vec4(0.0f));
|
|
|
+ m_cubeSides[i].m_localTrf.setScale(1.0f);
|
|
|
|
|
|
m_cubeSides[i].m_frustum.setAll(ang, ang, zNear, EFFECTIVE_DISTANCE);
|
|
|
m_cubeSides[i].m_frustum.resetTransform(m_cubeSides[i].m_localTrf);
|
|
|
@@ -87,13 +87,16 @@ Error ReflectionProbeNode::init(F32 radius)
|
|
|
}
|
|
|
|
|
|
// Spatial component
|
|
|
- m_spatialSphere.setCenter(Vec4(0.0));
|
|
|
- m_spatialSphere.setRadius(radius);
|
|
|
- newComponent<SpatialComponent>(this, &m_spatialSphere);
|
|
|
+ m_aabbMinLSpace = aabbMinLSpace.xyz();
|
|
|
+ m_aabbMaxLSpace = aabbMaxLSpace.xyz();
|
|
|
+ m_spatialAabb.setMin(aabbMinLSpace);
|
|
|
+ m_spatialAabb.setMax(aabbMaxLSpace);
|
|
|
+ newComponent<SpatialComponent>(this, &m_spatialAabb);
|
|
|
|
|
|
// Reflection probe comp
|
|
|
ReflectionProbeComponent* reflc = newComponent<ReflectionProbeComponent>(this);
|
|
|
- reflc->setRadius(radius);
|
|
|
+ reflc->setPosition(Vec4(0.0f));
|
|
|
+ reflc->setBoundingBox(aabbMinLSpace, aabbMaxLSpace);
|
|
|
|
|
|
return Error::NONE;
|
|
|
}
|
|
|
@@ -120,11 +123,15 @@ void ReflectionProbeNode::onMoveUpdate(MoveComponent& move)
|
|
|
SpatialComponent& sp = getComponent<SpatialComponent>();
|
|
|
sp.markForUpdate();
|
|
|
sp.setSpatialOrigin(move.getWorldTransform().getOrigin());
|
|
|
- m_spatialSphere.setCenter(move.getWorldTransform().getOrigin());
|
|
|
+ const Vec3 aabbMinWSpace = m_aabbMinLSpace + move.getWorldTransform().getOrigin().xyz();
|
|
|
+ const Vec3 aabbMaxWSpace = m_aabbMaxLSpace + move.getWorldTransform().getOrigin().xyz();
|
|
|
+ m_spatialAabb.setMin(aabbMinWSpace);
|
|
|
+ m_spatialAabb.setMax(aabbMaxWSpace);
|
|
|
|
|
|
// Update the refl comp
|
|
|
ReflectionProbeComponent& reflc = getComponent<ReflectionProbeComponent>();
|
|
|
reflc.setPosition(move.getWorldTransform().getOrigin());
|
|
|
+ reflc.setBoundingBox(aabbMinWSpace.xyz0(), aabbMaxWSpace.xyz0());
|
|
|
}
|
|
|
|
|
|
Error ReflectionProbeNode::frameUpdate(Second prevUpdateTime, Second crntTime)
|