summaryrefslogtreecommitdiffstats
path: root/scene/resources/surface_tool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/surface_tool.cpp')
-rw-r--r--scene/resources/surface_tool.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index e1769d099b..bcfacc62fa 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -355,7 +355,30 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
w=DVector<Color>::Write();
a[i]=array;
} break;
- case Mesh::ARRAY_FORMAT_BONES:
+ case Mesh::ARRAY_FORMAT_BONES: {
+
+
+ DVector<int> array;
+ array.resize(varr_len*4);
+ DVector<int>::Write w = array.write();
+
+ int idx=0;
+ for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
+
+ const Vertex &v=E->get();
+
+ ERR_CONTINUE( v.bones.size()!=4 );
+
+ for(int j=0;j<4;j++) {
+ w[idx+j]=v.bones[j];
+ }
+
+ }
+
+ w=DVector<int>::Write();
+ a[i]=array;
+
+ } break;
case Mesh::ARRAY_FORMAT_WEIGHTS: {
@@ -367,18 +390,11 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
const Vertex &v=E->get();
+ ERR_CONTINUE( v.weights.size()!=4 );
for(int j=0;j<4;j++) {
- switch(i) {
- case Mesh::ARRAY_WEIGHTS: {
- ERR_CONTINUE( v.weights.size()!=4 );
- w[idx+j]=v.weights[j];
- } break;
- case Mesh::ARRAY_BONES: {
- ERR_CONTINUE( v.bones.size()!=4 );
- w[idx+j]=v.bones[j];
- } break;
- }
+
+ w[idx+j]=v.weights[j];
}
}
@@ -410,7 +426,7 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
}
- mesh->add_surface(primitive,a);
+ mesh->add_surface_from_arrays(primitive,a);
if (material.is_valid())
mesh->surface_set_material(surface,material);