Added set_shape to MLPPTensor3.

This commit is contained in:
Relintai 2023-04-23 11:46:35 +02:00
parent b1d00a629f
commit 83f4c22e74

View File

@ -225,6 +225,15 @@ public:
CRASH_COND_MSG(!_data, "Out of memory");
}
void set_shape(const Size3i &p_size) {
int ds = data_size();
int new_data_size = p_size.x * p_size.y * p_size.z;
ERR_FAIL_COND_MSG(ds != new_data_size, "The new size has a different volume than the old. If this is intended use resize()!");
_size = p_size;
}
_FORCE_INLINE_ int calculate_index(int p_index_y, int p_index_x, int p_index_z) const {
return p_index_y * _size.x + p_index_x + _size.x * _size.y * p_index_z;
}