[Bf-blender-cvs] [f926428] cycles-ptex-06: back-to-sound
Nicholas Bishop
noreply at git.blender.org
Thu Jan 15 20:13:26 CET 2015
Commit: f9264280d8cd3f141ea98ca344ede517a29e47a1
Author: Nicholas Bishop
Date: Wed Jan 14 17:44:24 2015 +0100
Branches: cycles-ptex-06
https://developer.blender.org/rBf9264280d8cd3f141ea98ca344ede517a29e47a1
back-to-sound
===================================================================
M intern/cycles/render/image.cpp
===================================================================
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 05e8d48..cce8536 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -52,6 +52,10 @@ struct PtexPackedTexture {
int bytes_per_texel;
+ bool valid_pixel_index(int index) const {
+ return (index >= 0) && (index < texels.size() - num_channels);
+ }
+
void test_write() {
// Quick test to visually examine the packed output
const char *filename = "/tmp/packed.png";
@@ -117,17 +121,63 @@ static void ptex_read_border_pixel(PtexFaceData &face,
face.getPixel(u, v, pixel);
}
+#if 0
+struct PtexBorderIter {
+ PtexBorderIter(PtexPackedTexture &output,
+ PtexPtr<PtexTexture> &r,
+ const uint face_id,
+ const int dst_stride)
+ : elem(output.table[face_id]),
+ info(r->getFaceInfo(face_id)),
+ dst_stride(dst_stride),
+ cur_side(Ptex::e_bottom)
+ {
+ const int bpt = output.bytes_per_texel;
+
+ inc[0][0] = bpt;
+ inc[0][1] = 0;
+
+ inc[1][0] = 0;
+ inc[1][1] = dst_stride;
+
+ inc[2][0] = -bpt;
+ inc[2][1] = 0;
+
+ inc[3][0] = 0;
+ inc[3][1] = -dst_stride;
+
+ dst_offset = ((elem.co[1] - 1) * output.width +
+ (elem.co[0] - 1)) * bpt;
+ }
+
+ bool next() {
+ const int side_res = (cur_side == Ptex::e_bottom || cur_side == Ptex::e_top) {
+
+ }
+ const int side_res = elem.res[(i == 0 || i == 2) ? 0 : 1];
+ }
+
+ const PtexTableElement &elem;
+ const Ptex::FaceInfo &info;
+ const int dst_stride;
+ int dst_offset;
+ Ptex::EdgeId cur_side;
+ int inc[4][2];
+};
+#endif
+
static void ptex_copy_face_pixels(PtexPackedTexture &output,
PtexPtr<PtexTexture> &r,
const int dst_stride,
const uint face_id)
{
+#if 0
PtexTableElement &elem = output.table[face_id];
const int bpt = output.bytes_per_texel;
- const int dst_offset = ((elem.co[1] * output.width + elem.co[0]) * bpt);
+ int dst_offset = ((elem.co[1] * output.width + elem.co[0]) * bpt);
- if (face_id != 1)
+ if (face_id != 14)
return;
r->getData(face_id, output.texels.data() + dst_offset, dst_stride);
@@ -136,41 +186,47 @@ static void ptex_copy_face_pixels(PtexPackedTexture &output,
const Ptex::FaceInfo &info = r->getFaceInfo(face_id);
const int x_inc[4] = {bpt, 0, -bpt, 0};
const int y_inc[4] = {0, dst_stride, 0, -dst_stride};
- int x = elem.co[0], y = elem.co[1];
- int offset = ((y - 1) * output.width + (x - 1)) * bpt;
+ dst_offset = ((elem.co[1] - 1) * output.width +
+ (elem.co[0] - 1)) * bpt;
+ //PtexBorderIter iter(output, r, face_id, dst_stride);
for (int i = 0; i < 4; i++) {
- int adjface = info.adjface(i);
- Ptex::EdgeId adjedge = info.adjedge(i);
+ /* In general there is only one adjacent face, but when a quad
+ * is adjacent to a non-quad there are two adjacent subfaces */
+ int adj_face_id[2] = {info.adjface(i), -1};
+ Ptex::EdgeId adj_edge[2] = {info.adjedge(i)};
+
const int side_res = elem.res[(i == 0 || i == 2) ? 0 : 1];
bool flip = true;
- if (adjface == -1) {
+ if (adj_face_id[0] == -1) {
// If there's no adjacent face, pretend the face is
// adjacent to itself (i.e. copy its own borders)
- adjface = face_id;
- adjedge = (Ptex::EdgeId)i;
+ adj_face_id[0] = face_id;
+ adj_edge[0] = (Ptex::EdgeId)i;
flip = false;
}
- const Ptex::FaceInfo &adjinfo = r->getFaceInfo(adjface);
+ const Ptex::FaceInfo &adj_info = r->getFaceInfo(adj_face_id[0]);
+ if (!info.isSubface() && adj_info.isSubface()) {
+ // Face is adjacent to two subfaces
+ adj_face_id =
+ }
+
+
// TODO: handle faces adjacent to subfaces correctly
// TODO: handle subfaces adjacent to faces correctly
- if (info.isSubface() && !adjinfo.isSubface()) {
-
- }
// TODO: handle corners correctly
- offset += x_inc[i];
- offset += y_inc[i];
+ dst_offset += x_inc[i];
+ dst_offset += y_inc[i];
- PtexFaceData &face_data = *r->getData(adjface);
+ PtexFaceData &face_data = *r->getData(adj_face);
for (int j = 0; j < side_res; j++) {
- assert(offset >= 0);
- assert(offset < bpt * output.height * output.width);
+ assert(output.valid_pixel_index(dst_offset));
// TODO, all kinds of uglyness here
@@ -183,13 +239,7 @@ static void ptex_copy_face_pixels(PtexPackedTexture &output,
if (info.isSubface() && !adjinfo.isSubface()) {
t *= 0.5f;
- bool is_primary = false;
- for (int k = 0; k < 4; k++) {
- if (adjinfo.adjface(k) == face_id) {
- is_primary = true;
- break;
- }
- }
+ bool is_primary = adjinfo.adjface(adjedge) == face_id;
if (!is_primary) {
t += 0.5f;
}
@@ -198,7 +248,7 @@ static void ptex_copy_face_pixels(PtexPackedTexture &output,
bool regular = true;
if (!info.isSubface() && adjinfo.isSubface()) {
t *= 2.0f;
- if (t >= 1) {
+ if (t < 1) {
int neid = (adjedge + 3) % 4;
int afid = adjinfo.adjface(neid);
int aeid = adjinfo.adjedge(neid);
@@ -206,21 +256,24 @@ static void ptex_copy_face_pixels(PtexPackedTexture &output,
t -= 1;
ptex_read_border_pixel(ffd, (Ptex::EdgeId)aeid, t,
- output.texels.data() + offset);
+ output.texels.data() +
+ dst_offset);
regular = false;
}
}
if (regular) {
ptex_read_border_pixel(face_data, adjedge, t,
- output.texels.data() + offset);
+ output.texels.data() +
+ dst_offset);
}
- offset += x_inc[i];
- offset += y_inc[i];
+ dst_offset += x_inc[i];
+ dst_offset += y_inc[i];
}
// if (i == 0) break;
}
+#endif
}
// TODO
More information about the Bf-blender-cvs
mailing list