Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit 47405b6

Browse files
committed
remove a couple asserts
1 parent 10ee261 commit 47405b6

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/apcomp/internal/ImageCompositor.hpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <algorithm>
66

77
#include <apcomp/apcomp_exports.h>
8-
#include <assert.h>
8+
#include <apcomp/error.hpp>
99

1010
namespace apcomp
1111
{
@@ -24,10 +24,17 @@ class APCOMP_API ImageCompositor
2424
void Blend(apcomp::Image &front, apcomp::Image &back)
2525
{
2626

27-
assert(front.m_bounds.m_min_x == back.m_bounds.m_min_x);
28-
assert(front.m_bounds.m_min_y == back.m_bounds.m_min_y);
29-
assert(front.m_bounds.m_max_x == back.m_bounds.m_max_x);
30-
assert(front.m_bounds.m_max_y == back.m_bounds.m_max_y);
27+
bool valid = true;
28+
valid &= front.m_bounds.m_min_x == back.m_bounds.m_min_x;
29+
valid &= front.m_bounds.m_min_y == back.m_bounds.m_min_y;
30+
valid &= front.m_bounds.m_max_x == back.m_bounds.m_max_x;
31+
valid &= front.m_bounds.m_max_y == back.m_bounds.m_max_y;
32+
33+
if(!valid)
34+
{
35+
throw Error("image bounds do not match");
36+
}
37+
3138
const int size = static_cast<int>(front.m_pixels.size() / 4);
3239

3340
#ifdef APCOMP_USE_OPENMP
@@ -57,11 +64,16 @@ class APCOMP_API ImageCompositor
5764

5865
void ZBufferComposite(apcomp::Image &front, const apcomp::Image &image)
5966
{
60-
assert(front.m_depths.size() == front.m_pixels.size() / 4);
61-
assert(front.m_bounds.m_min_x == image.m_bounds.m_min_x);
62-
assert(front.m_bounds.m_min_y == image.m_bounds.m_min_y);
63-
assert(front.m_bounds.m_max_x == image.m_bounds.m_max_x);
64-
assert(front.m_bounds.m_max_y == image.m_bounds.m_max_y);
67+
bool valid = true;
68+
valid &= front.m_depths.size() == front.m_pixels.size() / 4;
69+
valid &= front.m_bounds.m_min_x == image.m_bounds.m_min_x;
70+
valid &= front.m_bounds.m_min_y == image.m_bounds.m_min_y;
71+
valid &= front.m_bounds.m_max_x == image.m_bounds.m_max_x;
72+
valid &= front.m_bounds.m_max_y == image.m_bounds.m_max_y;
73+
if(!valid)
74+
{
75+
throw Error("image bounds do not match");
76+
}
6577

6678
const int size = static_cast<int>(front.m_depths.size());
6779
bool gl_depth = front.m_gl_depth;
@@ -191,14 +203,6 @@ void ZBufferBlend(std::vector<apcomp::Image> &images)
191203
std::sort(pixels.begin() + begin, pixels.begin() + end);
192204
}
193205

194-
// check to see if that worked
195-
int pixel_id_0 = pixels[0].m_pixel_id;
196-
for(int i = 1; i < num_images; ++i)
197-
{
198-
assert(pixel_id_0 == pixels[i].m_pixel_id);
199-
}
200-
201-
202206
#ifdef APCOMP_USE_OPENMP
203207
#pragma omp parallel for
204208
#endif

0 commit comments

Comments
 (0)