Use generic error macros in storage funcs
This commit is contained in:
parent
f60c506e75
commit
6fa4416984
@ -16,17 +16,17 @@ void copy_3d_region_zxy(Span<uint8_t> dst, Vector3i dst_size, Vector3i dst_min,
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (src.data() == dst.data()) {
|
||||
ERR_FAIL_COND_MSG(
|
||||
Box3i::from_min_max(src_min, src_max).intersects(Box3i::from_min_max(dst_min, dst_min + area_size)),
|
||||
ZN_ASSERT_RETURN_MSG(
|
||||
!Box3i::from_min_max(src_min, src_max).intersects(Box3i::from_min_max(dst_min, dst_min + area_size)),
|
||||
"Copy across the same buffer to an overlapping area is not supported");
|
||||
}
|
||||
ERR_FAIL_COND(Vector3iUtil::get_volume(area_size) * item_size > dst.size());
|
||||
ERR_FAIL_COND(Vector3iUtil::get_volume(area_size) * item_size > src.size());
|
||||
ZN_ASSERT_RETURN(Vector3iUtil::get_volume(area_size) * item_size <= dst.size());
|
||||
ZN_ASSERT_RETURN(Vector3iUtil::get_volume(area_size) * item_size <= src.size());
|
||||
#endif
|
||||
|
||||
if (area_size == src_size && area_size == dst_size) {
|
||||
// Copy everything
|
||||
ERR_FAIL_COND(dst.size() != src.size());
|
||||
ZN_ASSERT_RETURN(dst.size() == src.size());
|
||||
memcpy(dst.data(), src.data(), dst.size());
|
||||
|
||||
} else {
|
||||
@ -42,8 +42,8 @@ void copy_3d_region_zxy(Span<uint8_t> dst, Vector3i dst_size, Vector3i dst_min,
|
||||
unsigned int dst_ri = Vector3iUtil::get_zxy_index(Vector3i(dst_min + pos), dst_size) * item_size;
|
||||
for (; pos.x < area_size.x; ++pos.x) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_FAIL_COND(dst_ri >= dst.size());
|
||||
ERR_FAIL_COND(dst.size() - dst_ri < area_size.y * item_size);
|
||||
ZN_ASSERT_RETURN(dst_ri < dst.size());
|
||||
ZN_ASSERT_RETURN(dst.size() - dst_ri >= area_size.y * item_size);
|
||||
#endif
|
||||
// TODO Cast src and dst to `restrict` so the optimizer can assume adresses don't overlap,
|
||||
// which might allow to write as a for loop (which may compile as a `memcpy`)?
|
||||
|
@ -68,7 +68,7 @@ void fill_3d_region_zxy(Span<T> dst, Vector3i dst_size, Vector3i dst_min, Vector
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_FAIL_COND(Vector3iUtil::get_volume(area_size) > dst.size());
|
||||
ZN_ASSERT_RETURN(Vector3iUtil::get_volume(area_size) <= dst.size());
|
||||
#endif
|
||||
|
||||
if (area_size == dst_size) {
|
||||
@ -191,7 +191,7 @@ inline void debug_check_texture_indices(FixedArray<uint8_t, 4> indices) {
|
||||
fill(checked, false);
|
||||
for (unsigned int i = 0; i < indices.size(); ++i) {
|
||||
unsigned int ti = indices[i];
|
||||
CRASH_COND(checked[ti]);
|
||||
ZN_ASSERT(!checked[ti]);
|
||||
checked[ti] = true;
|
||||
}
|
||||
}
|
||||
@ -211,7 +211,7 @@ struct IntBasis {
|
||||
case Vector3i::AXIS_Z:
|
||||
return z;
|
||||
default:
|
||||
CRASH_NOW();
|
||||
ZN_CRASH();
|
||||
}
|
||||
return Vector3i();
|
||||
}
|
||||
@ -222,11 +222,11 @@ struct IntBasis {
|
||||
// The array's coordinate convention uses ZXY (index+1 does Y+1).
|
||||
template <typename T>
|
||||
Vector3i transform_3d_array_zxy(Span<const T> src_grid, Span<T> dst_grid, Vector3i src_size, IntBasis basis) {
|
||||
ERR_FAIL_COND_V(!Vector3iUtil::is_unit_vector(basis.x), src_size);
|
||||
ERR_FAIL_COND_V(!Vector3iUtil::is_unit_vector(basis.y), src_size);
|
||||
ERR_FAIL_COND_V(!Vector3iUtil::is_unit_vector(basis.z), src_size);
|
||||
ERR_FAIL_COND_V(src_grid.size() != static_cast<size_t>(Vector3iUtil::get_volume(src_size)), src_size);
|
||||
ERR_FAIL_COND_V(dst_grid.size() != static_cast<size_t>(Vector3iUtil::get_volume(src_size)), src_size);
|
||||
ZN_ASSERT_RETURN_V(Vector3iUtil::is_unit_vector(basis.x), src_size);
|
||||
ZN_ASSERT_RETURN_V(Vector3iUtil::is_unit_vector(basis.y), src_size);
|
||||
ZN_ASSERT_RETURN_V(Vector3iUtil::is_unit_vector(basis.z), src_size);
|
||||
ZN_ASSERT_RETURN_V(src_grid.size() == static_cast<size_t>(Vector3iUtil::get_volume(src_size)), src_size);
|
||||
ZN_ASSERT_RETURN_V(dst_grid.size() == static_cast<size_t>(Vector3iUtil::get_volume(src_size)), src_size);
|
||||
|
||||
const int xa = basis.x.x != 0 ? 0 : basis.x.y != 0 ? 1 : 2;
|
||||
const int ya = basis.y.x != 0 ? 0 : basis.y.y != 0 ? 1 : 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user