@@ -75,6 +75,44 @@ void OrthographicCamera::ClampRay(Ray *ray) const {
7575 ray->maxt = Min (ray->maxt , clipYon);
7676}
7777
78+ bool OrthographicCamera::ProjectToImage (Ray *ray, float *x, float *y) const {
79+ // check if point is behind camera
80+ const float cosi = Dot (ray->d , dir);
81+
82+ if ((cosi <= 0 .f ) || (!isinf (ray->maxt ) && (ray->maxt < clipHither ||
83+ ray->maxt > clipYon)))
84+ return false ;
85+
86+ // Get coordinates of point in image plane
87+ Point pO = Inverse (camTrans.rasterToWorld ) * ray->o ;
88+ if (motionSystem)
89+ pO *= motionSystem->Sample (ray->time );
90+
91+ *x = pO.x ;
92+ *y = filmHeight - 1 - pO.y ;
93+
94+ // Update the ray origin
95+ pO.z = 0 .f ;
96+ ray->o = camTrans.rasterToWorld * pO;
97+
98+ // Check if we are inside the image plane
99+ if ((*x < filmSubRegion[0 ]) || (*x >= filmSubRegion[1 ] + 1 ) ||
100+ (*y < filmSubRegion[2 ]) || (*y >= filmSubRegion[3 ] + 1 ))
101+ return false ;
102+ else {
103+ // World arbitrary clipping plane support
104+ if (enableClippingPlane) {
105+ // Check if the ray end point is on the not visible side of the plane
106+ if (Dot (clippingPlaneNormal, ray->o - clippingPlaneCenter) <= 0 .f )
107+ return false ;
108+ // Update ray mint/maxt
109+ ApplyArbitraryClippingPlane (ray);
110+ }
111+
112+ return true ;
113+ }
114+ }
115+
78116bool OrthographicCamera::GetSamplePosition (Ray *ray, float *x, float *y) const {
79117 const float cosi = Dot (ray->d , dir);
80118
0 commit comments