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:
authorNicholas Bishop <nicholasbishop@gmail.com>2015-02-11 19:06:39 +0300
committerNicholas Bishop <nicholasbishop@gmail.com>2015-02-11 19:06:39 +0300
commit0d4dd0df6cfc0e97082faba78d7f05e3e24119d7 (patch)
tree9662d90cb22ed045eaa7dec58d7c68d5df5dbfc6
parent2a34d36f4453051de30dc9871a4d51232eb98dff (diff)
Code cleanup: use BPXRect in Ptex layout interface
-rw-r--r--extern/ptex/BPX_packed_layout.h2
-rw-r--r--extern/ptex/BPX_ptex.h4
-rw-r--r--extern/ptex/BPX_rect.h3
-rw-r--r--extern/ptex/bpx_c_api.cpp13
-rw-r--r--intern/cycles/render/image.cpp12
-rw-r--r--source/blender/imbuf/intern/imb_ptex.c12
6 files changed, 26 insertions, 20 deletions
diff --git a/extern/ptex/BPX_packed_layout.h b/extern/ptex/BPX_packed_layout.h
index ad8ea080494..082a4c5e474 100644
--- a/extern/ptex/BPX_packed_layout.h
+++ b/extern/ptex/BPX_packed_layout.h
@@ -5,6 +5,8 @@
#include <cassert>
#include <vector>
+#include "BPX_rect.h"
+
// TODO(nicholasbishop): there's a lot of room for improvement
// here. None of this data is saved to a file, so we should be able to
// safely improve it to improve performance, decrease memory usage,
diff --git a/extern/ptex/BPX_ptex.h b/extern/ptex/BPX_ptex.h
index 15dcae28c70..3351637f6b9 100644
--- a/extern/ptex/BPX_ptex.h
+++ b/extern/ptex/BPX_ptex.h
@@ -121,8 +121,8 @@ void BPX_packed_layout_finalize(struct BPXPackedLayout *layout);
int BPX_packed_layout_width(const struct BPXPackedLayout *layout);
int BPX_packed_layout_height(const struct BPXPackedLayout *layout);
bool BPX_packed_layout_item(const struct BPXPackedLayout *layout,
- int id, int *x, int *y,
- int *width, int *height);
+ const int index,
+ struct BPXRect *r_rect);
void BPX_packed_layout_delete(struct BPXPackedLayout *layout);
#ifdef __cplusplus
diff --git a/extern/ptex/BPX_rect.h b/extern/ptex/BPX_rect.h
index 5702265ae26..b3393fe9895 100644
--- a/extern/ptex/BPX_rect.h
+++ b/extern/ptex/BPX_rect.h
@@ -6,8 +6,9 @@ extern "C"{
#endif
/* TODO(nicholasbishop): this is yet another 2D integer rect
- * structure. Would be better to reuse rcti. */
+ * structure. Could be nicer to reuse rcti. */
+/* Note: begin is inclusive, end is exclusive to match OIIO::ROI */
typedef struct BPXRect {
int xbegin;
int xend;
diff --git a/extern/ptex/bpx_c_api.cpp b/extern/ptex/bpx_c_api.cpp
index 253cc75461d..19565cc5f61 100644
--- a/extern/ptex/bpx_c_api.cpp
+++ b/extern/ptex/bpx_c_api.cpp
@@ -1239,16 +1239,15 @@ int BPX_packed_layout_height(const BPXPackedLayout * const layout)
}
bool BPX_packed_layout_item(const BPXPackedLayout * const layout,
- const int item_id, int *x, int *y,
- int *width, int *height)
+ const int item_id, BPXRect *r_rect)
{
- if (layout && x && y && width && height) {
+ if (layout && r_rect) {
const BPXPackedLayout::Items &items = layout->get_items();
if (item_id >= 0 && item_id < items.size()) {
- (*x) = items[item_id].x;
- (*y) = items[item_id].y;
- (*width) = items[item_id].u_res;
- (*height) = items[item_id].v_res;
+ r_rect->xbegin = items[item_id].x;
+ r_rect->ybegin = items[item_id].y;
+ r_rect->xend = items[item_id].x + items[item_id].u_res;
+ r_rect->yend = items[item_id].y + items[item_id].v_res;
return true;
}
}
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 144a83714f3..4cd2124aa0d 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -406,12 +406,12 @@ static BPXImageBuf *ptex_pack_uchar_cb(const struct BPXPackedLayout *layout,
width, height, num_regions*4);
for (int i = 0; i < num_regions; i++) {
- int x, y, w, h;
- if (BPX_packed_layout_item(layout, i, &x, &y, &w, &h)) {
- regions[i][0] = x;
- regions[i][1] = y;
- regions[i][2] = w;
- regions[i][3] = h;
+ BPXRect rect;
+ if (BPX_packed_layout_item(layout, i, &rect)) {
+ regions[i][0] = rect.xbegin;
+ regions[i][1] = rect.ybegin;
+ regions[i][2] = rect.xend - rect.xbegin;
+ regions[i][3] = rect.yend - rect.ybegin;
}
else {
// TODO
diff --git a/source/blender/imbuf/intern/imb_ptex.c b/source/blender/imbuf/intern/imb_ptex.c
index 622f29a1a89..96a7364645f 100644
--- a/source/blender/imbuf/intern/imb_ptex.c
+++ b/source/blender/imbuf/intern/imb_ptex.c
@@ -42,10 +42,14 @@ ImBuf *IMB_alloc_from_ptex_layout(const struct BPXPackedLayout *layout)
for (i = 0; i < ibuf->num_ptex_regions; i++) {
ImPtexRegion *dst_region = &ibuf->ptex_regions[i];
- if (!BPX_packed_layout_item(layout, i, &dst_region->x,
- &dst_region->y, &dst_region->width,
- &dst_region->height))
- {
+ BPXRect rect;
+ if (BPX_packed_layout_item(layout, i, &rect)) {
+ dst_region->x = rect.xbegin;
+ dst_region->y = rect.ybegin;
+ dst_region->width = rect.xend - rect.xbegin;
+ dst_region->height = rect.yend - rect.ybegin;
+ }
+ else {
/* Error */
IMB_freeImBuf(ibuf);
return NULL;