parent
0810ecaafd
commit
cf9df3b5d4
19 changed files with 295 additions and 187 deletions
|
|
@ -542,13 +542,14 @@ void OccluderInstance3D::_bake_surface(const Transform3D &p_transform, Array p_s
|
|||
float error = -1.0f;
|
||||
int target_index_count = MIN(indices.size(), 36);
|
||||
|
||||
const int simplify_options = SurfaceTool::SIMPLIFY_LOCK_BORDER;
|
||||
|
||||
uint32_t index_count = SurfaceTool::simplify_func(
|
||||
(unsigned int *)indices.ptrw(),
|
||||
(unsigned int *)indices.ptr(),
|
||||
indices.size(),
|
||||
vertices_f32.ptr(), vertices.size(), sizeof(float) * 3,
|
||||
target_index_count, target_error, &error);
|
||||
|
||||
target_index_count, target_error, simplify_options, &error);
|
||||
indices.resize(index_count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -452,6 +452,7 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
|
|||
new_indices.resize(index_count);
|
||||
|
||||
Vector<float> merged_normals_f32 = vector3_to_float32_array(merged_normals.ptr(), merged_normals.size());
|
||||
const int simplify_options = SurfaceTool::SIMPLIFY_LOCK_BORDER;
|
||||
|
||||
size_t new_index_count = SurfaceTool::simplify_with_attrib_func(
|
||||
(unsigned int *)new_indices.ptrw(),
|
||||
|
|
@ -460,6 +461,7 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
|
|||
sizeof(float) * 3, // Vertex stride
|
||||
index_target,
|
||||
max_mesh_error,
|
||||
simplify_options,
|
||||
&mesh_error,
|
||||
merged_normals_f32.ptr(),
|
||||
normal_weights.ptr(), 3);
|
||||
|
|
|
|||
|
|
@ -1307,7 +1307,8 @@ Vector<int> SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun
|
|||
}
|
||||
|
||||
float error;
|
||||
uint32_t index_count = simplify_func((unsigned int *)lod.ptrw(), (unsigned int *)index_array.ptr(), index_array.size(), vertices.ptr(), vertex_array.size(), sizeof(float) * 3, p_target_index_count, p_threshold, &error);
|
||||
const int simplify_options = SIMPLIFY_LOCK_BORDER;
|
||||
uint32_t index_count = simplify_func((unsigned int *)lod.ptrw(), (unsigned int *)index_array.ptr(), index_array.size(), vertices.ptr(), vertex_array.size(), sizeof(float) * 3, p_target_index_count, p_threshold, simplify_options, &error);
|
||||
ERR_FAIL_COND_V(index_count == 0, lod);
|
||||
lod.resize(index_count);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,11 +74,16 @@ public:
|
|||
SKIN_8_WEIGHTS
|
||||
};
|
||||
|
||||
enum {
|
||||
/* Do not move vertices that are located on the topological border (vertices on triangle edges that don't have a paired triangle). Useful for simplifying portions of the larger mesh. */
|
||||
SIMPLIFY_LOCK_BORDER = 1 << 0, // From meshopt_SimplifyLockBorder
|
||||
};
|
||||
|
||||
typedef void (*OptimizeVertexCacheFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, size_t vertex_count);
|
||||
static OptimizeVertexCacheFunc optimize_vertex_cache_func;
|
||||
typedef size_t (*SimplifyFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float *r_error);
|
||||
typedef size_t (*SimplifyFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float *r_error);
|
||||
static SimplifyFunc simplify_func;
|
||||
typedef size_t (*SimplifyWithAttribFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, float *result_error, const float *attributes, const float *attribute_weights, size_t attribute_count);
|
||||
typedef size_t (*SimplifyWithAttribFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_data, size_t vertex_count, size_t vertex_stride, size_t target_index_count, float target_error, unsigned int options, float *result_error, const float *attributes, const float *attribute_weights, size_t attribute_count);
|
||||
static SimplifyWithAttribFunc simplify_with_attrib_func;
|
||||
typedef float (*SimplifyScaleFunc)(const float *vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
||||
static SimplifyScaleFunc simplify_scale_func;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue