godotengine / godotengine/godot
when use surface_tool, can't set the skin_weights as SKIN_8_WEIGHTS
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Both GODOT4.4 and GODOT4.5 DEV5 have this issue, not test on other version.
### System information
windows11, godot4.4, vulkan, 4070tis
### Issue description
1. when surface_tool begin, it will call clear to set the ```skin_weights = SKIN_4_WEIGHTS;```
```cpp
void SurfaceTool::begin(Mesh::PrimitiveType p_primitive) {
clear();
primitive = p_primitive;
begun = true;
first = true;
}
void SurfaceTool::clear() {
begun = false;
primitive = Mesh::PRIMITIVE_LINES;
format = 0;
last_bones.clear();
last_weights.clear();
index_array.clear();
vertex_array.clear();
material.unref();
last_smooth_group = 0;
for (int i = 0; i < RS::ARRAY_CUSTOM_COUNT; i++) {
last_custom_format[i] = CUSTOM_MAX;
}
skin_weights = SKIN_4_WEIGHTS;
}
```
2. so if we use set_skin_weight_count to set skin_weights as ```SKIN_8_WEIGHTS``` before begin, the skin_weights will re-init to SKIN_4_WEIGHTS
```cpp
void SurfaceTool::set_skin_weight_count(SkinWeightCount p_weights) {
ERR_FAIL_COND(begun);
skin_weights = p_weights;
}
```
3. but if we use set_skin_weight_count to set skin_weights as ```SKIN_8_WEIGHTS``` after begin, it will failed also, due to: ```ERR_FAIL_COND(begun);```
so the conclusion is that, we can't set the skin_weights as ```SKIN_8_WEIGHTS```.
### Steps to reproduce
here is my scripts on godot
```gdscript
extends Node3D
@export var mesh_1:MeshInstance3D
@export var mesh_2:MeshInstance3D
var _surface_tool: SurfaceTool = SurfaceTool.new()
_surface_tool.set_skin_weight_count(SurfaceTool.SKIN_8_WEIGHTS)
print(_surface_tool.get_skin_weight_count())
_surface_tool.begin(Mesh.PRIMITIVE_TRIANGLES)
for node in [mesh_1, mesh_2]:
if node is MeshInstance3D and node.mesh:
var mesh_data = node.mesh.surface_get_arrays(0)
var vertices = mesh_data[ArrayMesh.ARRAY_VERTEX]
var bones = mesh_data[ArrayMesh.ARRAY_BONES]
var weights = mesh_data[ArrayMesh.ARRAY_WEIGHTS]
print("Processing Mesh: ", node.name)
print("Bones Size: ", bones.size())
print("vertices Size: ", vertices.size())
print("Weights Size: ", weights.size())
print("bones sieze and weight sieze: %s, %s" % [bones.size() / vertices.size(), weights.size() / vertices.size()])
_surface_tool.append_from(node.mesh, 0, node.transform)
rst_arraymesh = _surface_tool.commit()
```
### Minimal reproduction project (MRP)
same as above
Contributor guide
Research direction
Start with the SurfaceTool entry points shown in the report: begin(), clear(), and set_skin_weight_count(), then trace how append_from() and commit() consume the skin-weight setting. Use the provided Godot script to reproduce the behavior; done means SKIN_8_WEIGHTS remains usable through begin(), append_from(), and commit().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100