Formatting
This commit is contained in:
parent
c46d5e973d
commit
8adbe86da6
@ -52,7 +52,7 @@ inline uint64_t get_max_value_for_depth(VoxelBuffer::Depth d) {
|
||||
}
|
||||
|
||||
inline uint64_t clamp_value_for_depth(uint64_t value, VoxelBuffer::Depth d) {
|
||||
uint64_t max_val = get_max_value_for_depth(d);
|
||||
const uint64_t max_val = get_max_value_for_depth(d);
|
||||
if (value >= max_val) {
|
||||
return max_val;
|
||||
}
|
||||
@ -168,7 +168,7 @@ void VoxelBuffer::clear() {
|
||||
void VoxelBuffer::clear_channel(unsigned int channel_index, uint64_t clear_value) {
|
||||
ERR_FAIL_INDEX(channel_index, MAX_CHANNELS);
|
||||
Channel &channel = _channels[channel_index];
|
||||
if (channel.data) {
|
||||
if (channel.data != nullptr) {
|
||||
delete_channel(channel_index);
|
||||
}
|
||||
channel.defval = clamp_value_for_depth(clear_value, channel.depth);
|
||||
@ -291,7 +291,7 @@ void VoxelBuffer::fill(uint64_t defval, unsigned int channel_index) {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int volume = get_volume();
|
||||
const unsigned int volume = get_volume();
|
||||
|
||||
switch (channel.depth) {
|
||||
case DEPTH_8_BIT:
|
||||
@ -329,7 +329,7 @@ void VoxelBuffer::fill_area(uint64_t defval, Vector3i min, Vector3i max, unsigne
|
||||
|
||||
min.clamp_to(Vector3i(0, 0, 0), _size + Vector3i(1, 1, 1));
|
||||
max.clamp_to(Vector3i(0, 0, 0), _size + Vector3i(1, 1, 1));
|
||||
Vector3i area_size = max - min;
|
||||
const Vector3i area_size = max - min;
|
||||
|
||||
if (area_size.x == 0 || area_size.y == 0 || area_size.z == 0) {
|
||||
return;
|
||||
@ -347,10 +347,10 @@ void VoxelBuffer::fill_area(uint64_t defval, Vector3i min, Vector3i max, unsigne
|
||||
}
|
||||
|
||||
Vector3i pos;
|
||||
unsigned int volume = get_volume();
|
||||
const unsigned int volume = get_volume();
|
||||
for (pos.z = min.z; pos.z < max.z; ++pos.z) {
|
||||
for (pos.x = min.x; pos.x < max.x; ++pos.x) {
|
||||
unsigned int dst_ri = get_index(pos.x, pos.y + min.y, pos.z);
|
||||
const unsigned int dst_ri = get_index(pos.x, pos.y + min.y, pos.z);
|
||||
CRASH_COND(dst_ri >= volume);
|
||||
|
||||
switch (channel.depth) {
|
||||
@ -393,7 +393,7 @@ void VoxelBuffer::fill_f(real_t value, unsigned int channel) {
|
||||
template <typename T>
|
||||
inline bool is_uniform(const uint8_t *p_data, uint32_t size) {
|
||||
const T *data = (const T *)p_data;
|
||||
T v0 = data[0];
|
||||
const T v0 = data[0];
|
||||
for (unsigned int i = 1; i < size; ++i) {
|
||||
if (data[i] != v0) {
|
||||
return false;
|
||||
@ -411,7 +411,7 @@ bool VoxelBuffer::is_uniform(unsigned int channel_index) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int volume = get_volume();
|
||||
const unsigned int volume = get_volume();
|
||||
|
||||
// Channel isn't optimized, so must look at each voxel
|
||||
switch (channel.depth) {
|
||||
|
@ -717,6 +717,7 @@ void VoxelInstancer::update_block_from_transforms(int block_index, ArraySlice<co
|
||||
if (collision_shapes.size() > 0) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
|
||||
// Add new bodies
|
||||
for (unsigned int instance_index = 0; instance_index < transforms.size(); ++instance_index) {
|
||||
const Transform body_transform = block_transform * transforms[instance_index];
|
||||
|
||||
@ -746,6 +747,7 @@ void VoxelInstancer::update_block_from_transforms(int block_index, ArraySlice<co
|
||||
body->set_transform(body_transform);
|
||||
}
|
||||
|
||||
// Remove old bodies
|
||||
for (int instance_index = transforms.size(); instance_index < block->bodies.size(); ++instance_index) {
|
||||
VoxelInstancerRigidBody *body = block->bodies[instance_index];
|
||||
body->detach_and_destroy();
|
||||
|
@ -204,10 +204,10 @@ private:
|
||||
void update(unsigned int node_index, Vector3i node_pos, int lod, Vector3 view_pos, UpdateActions_T &actions) {
|
||||
// This function should be called regularly over frames.
|
||||
|
||||
int lod_factor = get_lod_factor(lod);
|
||||
int chunk_size = _base_size * lod_factor;
|
||||
Vector3 world_center = static_cast<real_t>(chunk_size) * (node_pos.to_vec3() + Vector3(0.5, 0.5, 0.5));
|
||||
float split_distance = chunk_size * _split_scale;
|
||||
const int lod_factor = get_lod_factor(lod);
|
||||
const int chunk_size = _base_size * lod_factor;
|
||||
const Vector3 world_center = static_cast<real_t>(chunk_size) * (node_pos.to_vec3() + Vector3(0.5, 0.5, 0.5));
|
||||
const float split_distance = chunk_size * _split_scale;
|
||||
Node *node = get_node(node_index);
|
||||
|
||||
if (!node->has_children()) {
|
||||
@ -216,7 +216,7 @@ private:
|
||||
if (lod > 0 && world_center.distance_to(view_pos) < split_distance && actions.can_split(node_pos, lod - 1)) {
|
||||
// Split
|
||||
|
||||
unsigned int first_child = _pool.allocate_children();
|
||||
const unsigned int first_child = _pool.allocate_children();
|
||||
// Get node again because `allocate_children` may invalidate the pointer
|
||||
node = get_node(node_index);
|
||||
node->first_child = first_child;
|
||||
@ -232,12 +232,11 @@ private:
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
bool has_split_child = false;
|
||||
unsigned int first_child = node->first_child;
|
||||
const unsigned int first_child = node->first_child;
|
||||
|
||||
for (unsigned int i = 0; i < 8; ++i) {
|
||||
unsigned int child_index = first_child + i;
|
||||
const unsigned int child_index = first_child + i;
|
||||
update(child_index, get_child_position(node_pos, i), lod - 1, view_pos, actions);
|
||||
has_split_child |= _pool.get_node(child_index)->has_children();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user