1 #ifndef GUARD_GGEMS_GEOMETRIES_GGEMSRAYTRACING_HH
2 #define GUARD_GGEMS_GEOMETRIES_GGEMSRAYTRACING_HH
34 #ifdef __OPENCL_C_VERSION__
63 GGfloat safmin = fabs(position->x - xmin);
64 GGfloat safmax = fabs(position->x - xmax);
66 position->x = (safmin < tolerance) ? xmin + tolerance : position->x;
67 position->x = (safmax < tolerance) ? xmax - tolerance : position->x;
70 safmin = fabs(position->y - ymin);
71 safmax = fabs(position->y - ymax);
73 position->y = (safmin < tolerance) ? ymin + tolerance : position->y;
74 position->y = (safmax < tolerance) ? ymax - tolerance : position->y;
77 safmin = fabs(position->z - zmin);
78 safmax = fabs(position->z - zmax);
80 position->z = (safmin < tolerance) ? zmin + tolerance : position->z;
81 position->z = (safmax < tolerance) ? zmax - tolerance : position->z;
94 inline void TransportGetSafetyInsideOBB(
GGfloat3 const* position, global
GGEMSOBB* obb_data)
97 GGfloat3 local_position = GlobalToLocalPosition(&obb_data->matrix_transformation_, position);
99 TransportGetSafetyInsideAABB(
101 obb_data->border_min_xyz_.x, obb_data->border_max_xyz_.x,
102 obb_data->border_min_xyz_.y, obb_data->border_max_xyz_.y,
103 obb_data->border_min_xyz_.z, obb_data->border_max_xyz_.z,
128 GGfloat safmin = fabs(position->x - xmin);
129 GGfloat safmax = fabs(position->x - xmax);
131 position->x = (safmin < tolerance) ? xmin - tolerance : position->x;
132 position->x = (safmax < tolerance) ? xmax + tolerance : position->x;
135 safmin = fabs(position->y - ymin);
136 safmax = fabs(position->y - ymax);
138 position->y = (safmin < tolerance) ? ymin - tolerance : position->y;
139 position->y = (safmax < tolerance) ? ymax + tolerance : position->y;
142 safmin = fabs(position->z - zmin);
143 safmax = fabs(position->z - zmax);
145 position->z = (safmin < tolerance) ? zmin - tolerance : position->z;
146 position->z = (safmax < tolerance) ? zmax + tolerance : position->z;
189 GGfloat3 local_position = GlobalToLocalPosition(&obb_data->matrix_transformation_, position);
191 return IsParticleInAABB(
193 obb_data->border_min_xyz_.x, obb_data->border_max_xyz_.x,
194 obb_data->border_min_xyz_.y, obb_data->border_max_xyz_.y,
195 obb_data->border_min_xyz_.z, obb_data->border_max_xyz_.z,
233 if (fabs(direction->x) <
EPSILON6) {
234 if (position->x < x_min || position->x > x_max)
return OUT_OF_WORLD;
237 idx = 1.0f / direction->x;
238 tmin = (x_min - position->x) * idx;
239 tmax = (x_max - position->x) * idx;
249 if (fabs(direction->y) <
EPSILON6) {
250 if (position->y < y_min || position->y > y_max)
return OUT_OF_WORLD;
253 idy = 1.0f / direction->y;
254 tymin = (y_min - position->y) * idy;
255 tymax = (y_max - position->y) * idy;
262 if (tymin > tmin) tmin = tymin;
263 if (tymax < tmax) tmax = tymax;
268 if (fabs(direction->z) <
EPSILON6) {
269 if (position->z < z_min || position->z > z_max)
return OUT_OF_WORLD;
272 idz = 1.0f / direction->z;
273 tzmin = (z_min - position->z) * idz;
274 tzmax = (z_max - position->z) * idz;
280 if (tzmin > tmin) tmin = tzmin;
281 if (tzmax < tmax) tmax = tzmax;
286 if (tmin < 0.0f && (tmax < 0.0f || tmax == 0.0f))
return OUT_OF_WORLD;
310 GGfloat3 local_position = GlobalToLocalPosition(&obb_data->matrix_transformation_, position);
311 GGfloat3 local_direction = GlobalToLocalDirection(&obb_data->matrix_transformation_, direction);
313 return ComputeDistanceToAABB(
316 obb_data->border_min_xyz_.x, obb_data->border_max_xyz_.x,
317 obb_data->border_min_xyz_.y, obb_data->border_max_xyz_.y,
318 obb_data->border_min_xyz_.z, obb_data->border_max_xyz_.z,
325 #endif // End of GUARD_GGEMS_GEOMETRIES_GGEMSRAYTRACING_HH