[Bf-blender-cvs] [8d051a8] cycles-ptex-06: First pass of cleanups of edge iterator, more to come
Nicholas Bishop
noreply at git.blender.org
Thu Jan 15 20:13:30 CET 2015
Commit: 8d051a8d6973967888beb93dc5d6277b0c6cb582
Author: Nicholas Bishop
Date: Thu Jan 15 17:20:44 2015 +0100
Branches: cycles-ptex-06
https://developer.blender.org/rB8d051a8d6973967888beb93dc5d6277b0c6cb582
First pass of cleanups of edge iterator, more to come
===================================================================
M intern/cycles/render/image.cpp
===================================================================
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index ec98654..bccc93c 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -180,43 +180,6 @@ struct PtexEdgeIter {
float2 step;
};
-// TODO: probably excessive calculation here, might look at making
-// into an iterator design
-//
-// Also TODO: not doing any special filtering for adjacent faces of
-// differing resolutions, not sure if that will matter in practice...
-static void ptex_read_border_pixel(PtexFaceData &face,
- const Ptex::EdgeId eid,
- const float t, void *pixel)
-{
- const Ptex::Res &res = face.res();
- const int u_res = res.u() - 1;
- const int v_res = res.v() - 1;
- int u = 0, v = 0;
- switch (eid) {
- case Ptex::e_bottom:
- u = (int)(t * u_res + 0.5f);
- v = 0;
- break;
-
- case Ptex::e_right:
- u = u_res;
- v = (int)(t * v_res + 0.5f);
- break;
-
- case Ptex::e_top:
- u = (int)((1.0f - t) * u_res + 0.5f);
- v = v_res;
- break;
-
- case Ptex::e_left:
- u = 0;
- v = (int)((1.0f - t) * v_res + 0.5f);
- break;
- }
- face.getPixel(u, v, pixel);
-}
-
#if 0
struct PtexBorderIter {
PtexBorderIter(PtexPackedTexture &output,
@@ -272,8 +235,8 @@ static void ptex_copy_face_pixels(PtexPackedTexture &output,
const int bpt = output.bytes_per_texel;
int dst_offset = ((elem.co[1] * output.width + elem.co[0]) * bpt);
- if (face_id != 0)
- return;
+ if (face_id != 1)
+ ;//return;
r->getData(face_id, output.texels.data() + dst_offset, dst_stride);
@@ -330,12 +293,7 @@ static void ptex_copy_face_pixels(PtexPackedTexture &output,
if (no_adj) {
PtexEdgeIter iter(*face_data[0], adj_edge[0], side_res, false);
for (int j = 0; j < side_res; j++) {
- float t = (float)j / (float)(side_res - 1);
-
assert(output.valid_pixel_index(dst_offset));
- // ptex_read_border_pixel(*face_data[0], adj_edge[0], t,
- // output.texels.data() +
- // dst_offset);
iter.read_texel(output.texels.data() + dst_offset);
dst_offset += x_inc[i] + y_inc[i];
@@ -343,59 +301,34 @@ static void ptex_copy_face_pixels(PtexPackedTexture &output,
}
}
else if (is_subface && !adj_info.isSubface()) {
- for (int j = 0; j < side_res; j++) {
- assert(output.valid_pixel_index(dst_offset));
-
- float t = (float)j / (float)(side_res - 1);
-
- // Adjacent edge will have opposite direction
- t = 1 - t;
-
- if (is_subface && !adj_info.isSubface()) {
- t *= 0.5f;
- bool is_primary = adj_info.adjface(adj_edge[0]) == face_id;
- if (!is_primary) {
- t += 0.5f;
- }
+ PtexEdgeIter iter(*face_data[0], adj_edge[0], side_res * 2, true);
+ const bool is_primary = adj_info.adjface(adj_edge[0]) == face_id;
+ if (is_primary) {
+ for (int j = 0; j < side_res; j++) {
+ iter.next();
}
+ }
- ptex_read_border_pixel(*face_data[0], adj_edge[0], t,
- output.texels.data() +
- dst_offset);
+ for (int j = 0; j < side_res; j++) {
+ assert(output.valid_pixel_index(dst_offset));
+ iter.read_texel(output.texels.data() + dst_offset);
dst_offset += x_inc[i] + y_inc[i];
+ iter.next();
}
}
else if (!is_subface && adj_info.isSubface()) {
const int half_side_res = side_res / 2;
- for (int j = 0; j < half_side_res; j++) {
- assert(output.valid_pixel_index(dst_offset));
-
- float t = (float)j / (float)(half_side_res - 1);
-
- // Adjacent edge will have opposite direction
- t = 1 - t;
-
- ptex_read_border_pixel(*face_data[0], adj_edge[0], t,
- output.texels.data() +
- dst_offset);
-
- dst_offset += x_inc[i] + y_inc[i];
- }
-
- for (int j = 0; j < half_side_res; j++) {
- assert(output.valid_pixel_index(dst_offset));
-
- float t = (float)j / (float)(half_side_res - 1);
-
- // Adjacent edge will have opposite direction
- t = 1 - t;
-
- ptex_read_border_pixel(*face_data[1], adj_edge[1], t,
- output.texels.data() +
- dst_offset);
-
- dst_offset += x_inc[i] + y_inc[i];
+ for (int sf = 0; sf <= 1; sf++) {
+ PtexEdgeIter iter(*face_data[sf], adj_edge[sf],
+ half_side_res, true);
+ for (int j = 0; j < half_side_res; j++) {
+ assert(output.valid_pixel_index(dst_offset));
+ iter.read_texel(output.texels.data() + dst_offset);
+
+ dst_offset += x_inc[i] + y_inc[i];
+ iter.next();
+ }
}
}
else {
@@ -403,18 +336,7 @@ static void ptex_copy_face_pixels(PtexPackedTexture &output,
for (int j = 0; j < side_res; j++) {
assert(output.valid_pixel_index(dst_offset));
-
- // TODO, all kinds of uglyness here
-
- float t = (float)j / (float)(side_res - 1);
-
- // Adjacent edge will have opposite direction
- t = 1 - t;
-
iter.read_texel(output.texels.data() + dst_offset);
- // ptex_read_border_pixel(*face_data[0], adj_edge[0], t,
- // output.texels.data() +
- // dst_offset);
dst_offset += x_inc[i] + y_inc[i];
iter.next();
More information about the Bf-blender-cvs
mailing list