Skip to content

Commit 0f96277

Browse files
author
Victor Widell
committedSep 1, 2013
Added support for scaling transforms to SceneObjectTransform. Intersection distance, photon energy and flux needs to be scaled.
1 parent 26baaed commit 0f96277

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎SceneObjectTransform.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Intersection sceneObjectTransformIntersectRay(const SceneObject *superobject, co
2828

2929
intersection.normal = mvMulDir(object->transform, intersection.normal );
3030
intersection.position = mvMul (object->transform, intersection.position);
31+
intersection.distance = intersection.distance * mScale(object->transform);
3132
}
3233

3334
return intersection;
@@ -46,9 +47,12 @@ bool sceneObjectTransformEmitPhotons(const SceneObject *superobject, const int n
4647
if (success) {
4748

4849
// Transform the photons.
50+
float scale = mScale(object->transform);
51+
float areaScale = scale * scale;
4952
containerForeach(Photon, photon, newPhotons) {
5053

5154
photon->heading = mrMul(object->transform, photon->heading);
55+
photon->energy = csMul(photon->energy, areaScale);
5256
}
5357

5458
// "Return" the new, transformed photons.
@@ -67,8 +71,8 @@ Color sceneObjectTransformRadiantFlux(const SceneObject *superobject) {
6771

6872
// Forward the flux calculation.
6973
Color radiantFlux = sceneObjectRadiantFlux(object->subject);
70-
71-
// TODO: Take scaling transforms into account.
7274

73-
return radiantFlux;
75+
float scale = mScale(object->transform);
76+
77+
return csMul(radiantFlux, scale * scale);
7478
}

0 commit comments

Comments
 (0)
Please sign in to comment.