Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/subd/subd_patch.cpp')
-rw-r--r--intern/cycles/subd/subd_patch.cpp106
1 files changed, 55 insertions, 51 deletions
diff --git a/intern/cycles/subd/subd_patch.cpp b/intern/cycles/subd/subd_patch.cpp
index f8f5aa25d19..a975b7b6342 100644
--- a/intern/cycles/subd/subd_patch.cpp
+++ b/intern/cycles/subd/subd_patch.cpp
@@ -29,89 +29,93 @@ CCL_NAMESPACE_BEGIN
static void decasteljau_cubic(float3 *P, float3 *dt, float t, const float3 cp[4])
{
- float3 d0 = cp[0] + t*(cp[1] - cp[0]);
- float3 d1 = cp[1] + t*(cp[2] - cp[1]);
- float3 d2 = cp[2] + t*(cp[3] - cp[2]);
+ float3 d0 = cp[0] + t * (cp[1] - cp[0]);
+ float3 d1 = cp[1] + t * (cp[2] - cp[1]);
+ float3 d2 = cp[2] + t * (cp[3] - cp[2]);
- d0 += t*(d1 - d0);
- d1 += t*(d2 - d1);
+ d0 += t * (d1 - d0);
+ d1 += t * (d2 - d1);
- *P = d0 + t*(d1 - d0);
- if(dt) *dt = d1 - d0;
+ *P = d0 + t * (d1 - d0);
+ if (dt)
+ *dt = d1 - d0;
}
-static void decasteljau_bicubic(float3 *P, float3 *du, float3 *dv, const float3 cp[16], float u, float v)
+static void decasteljau_bicubic(
+ float3 *P, float3 *du, float3 *dv, const float3 cp[16], float u, float v)
{
- float3 ucp[4], utn[4];
-
- /* interpolate over u */
- decasteljau_cubic(ucp+0, utn+0, u, cp);
- decasteljau_cubic(ucp+1, utn+1, u, cp+4);
- decasteljau_cubic(ucp+2, utn+2, u, cp+8);
- decasteljau_cubic(ucp+3, utn+3, u, cp+12);
-
- /* interpolate over v */
- decasteljau_cubic(P, dv, v, ucp);
- if(du) decasteljau_cubic(du, NULL, v, utn);
+ float3 ucp[4], utn[4];
+
+ /* interpolate over u */
+ decasteljau_cubic(ucp + 0, utn + 0, u, cp);
+ decasteljau_cubic(ucp + 1, utn + 1, u, cp + 4);
+ decasteljau_cubic(ucp + 2, utn + 2, u, cp + 8);
+ decasteljau_cubic(ucp + 3, utn + 3, u, cp + 12);
+
+ /* interpolate over v */
+ decasteljau_cubic(P, dv, v, ucp);
+ if (du)
+ decasteljau_cubic(du, NULL, v, utn);
}
/* Linear Quad Patch */
void LinearQuadPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v)
{
- float3 d0 = interp(hull[0], hull[1], u);
- float3 d1 = interp(hull[2], hull[3], u);
+ float3 d0 = interp(hull[0], hull[1], u);
+ float3 d1 = interp(hull[2], hull[3], u);
- *P = interp(d0, d1, v);
+ *P = interp(d0, d1, v);
- if(dPdu && dPdv) {
- *dPdu = interp(hull[1] - hull[0], hull[3] - hull[2], v);
- *dPdv = interp(hull[2] - hull[0], hull[3] - hull[1], u);
- }
+ if (dPdu && dPdv) {
+ *dPdu = interp(hull[1] - hull[0], hull[3] - hull[2], v);
+ *dPdv = interp(hull[2] - hull[0], hull[3] - hull[1], u);
+ }
- if(N) {
- *N = normalize(interp(interp(normals[0], normals[1], u), interp(normals[2], normals[3], u), v));
- }
+ if (N) {
+ *N = normalize(
+ interp(interp(normals[0], normals[1], u), interp(normals[2], normals[3], u), v));
+ }
}
BoundBox LinearQuadPatch::bound()
{
- BoundBox bbox = BoundBox::empty;
+ BoundBox bbox = BoundBox::empty;
- for(int i = 0; i < 4; i++)
- bbox.grow(hull[i]);
+ for (int i = 0; i < 4; i++)
+ bbox.grow(hull[i]);
- return bbox;
+ return bbox;
}
/* Bicubic Patch */
void BicubicPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v)
{
- if(N) {
- float3 dPdu_, dPdv_;
- decasteljau_bicubic(P, &dPdu_, &dPdv_, hull, u, v);
-
- if(dPdu && dPdv) {
- *dPdu = dPdu_;
- *dPdv = dPdv_;
- }
-
- *N = normalize(cross(dPdu_, dPdv_));
- }
- else {
- decasteljau_bicubic(P, dPdu, dPdv, hull, u, v);
- }
+ if (N) {
+ float3 dPdu_, dPdv_;
+ decasteljau_bicubic(P, &dPdu_, &dPdv_, hull, u, v);
+
+ if (dPdu && dPdv) {
+ *dPdu = dPdu_;
+ *dPdv = dPdv_;
+ }
+
+ *N = normalize(cross(dPdu_, dPdv_));
+ }
+ else {
+ decasteljau_bicubic(P, dPdu, dPdv, hull, u, v);
+ }
}
BoundBox BicubicPatch::bound()
{
- BoundBox bbox = BoundBox::empty;
+ BoundBox bbox = BoundBox::empty;
- for(int i = 0; i < 16; i++)
- bbox.grow(hull[i]);
+ for (int i = 0; i < 16; i++)
+ bbox.grow(hull[i]);
- return bbox;
+ return bbox;
}
CCL_NAMESPACE_END