1 /*************************************************************************/
2 /*  mesh_data_tool.cpp                                                   */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md)    */
10 /*                                                                       */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the       */
13 /* "Software"), to deal in the Software without restriction, including   */
14 /* without limitation the rights to use, copy, modify, merge, publish,   */
15 /* distribute, sublicense, and/or sell copies of the Software, and to    */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions:                                             */
18 /*                                                                       */
19 /* The above copyright notice and this permission notice shall be        */
20 /* included in all copies or substantial portions of the Software.       */
21 /*                                                                       */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
29 /*************************************************************************/
30 #include "mesh_data_tool.h"
31 
clear()32 void MeshDataTool::clear() {
33 
34 	vertices.clear();
35 	edges.clear();
36 	faces.clear();
37 	material = Ref<Material>();
38 	format = 0;
39 }
40 
create_from_surface(const Ref<Mesh> & p_mesh,int p_surface)41 Error MeshDataTool::create_from_surface(const Ref<Mesh> &p_mesh, int p_surface) {
42 
43 	ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
44 
45 	ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
46 	ERR_FAIL_COND_V(p_mesh->surface_get_primitive_type(p_surface) != Mesh::PRIMITIVE_TRIANGLES, ERR_INVALID_PARAMETER);
47 
48 	Array arrays = p_mesh->surface_get_arrays(p_surface);
49 	ERR_FAIL_COND_V(arrays.empty(), ERR_INVALID_PARAMETER);
50 
51 	DVector<Vector3> varray = arrays[Mesh::ARRAY_VERTEX];
52 
53 	int vcount = varray.size();
54 	ERR_FAIL_COND_V(vcount == 0, ERR_INVALID_PARAMETER);
55 
56 	clear();
57 	format = p_mesh->surface_get_format(p_surface);
58 	material = p_mesh->surface_get_material(p_surface);
59 
60 	DVector<Vector3>::Read vr = varray.read();
61 
62 	DVector<Vector3>::Read nr;
63 	if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL)
64 		nr = arrays[Mesh::ARRAY_NORMAL].operator DVector<Vector3>().read();
65 
66 	DVector<real_t>::Read ta;
67 	if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL)
68 		ta = arrays[Mesh::ARRAY_TANGENT].operator DVector<real_t>().read();
69 
70 	DVector<Vector2>::Read uv;
71 	if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL)
72 		uv = arrays[Mesh::ARRAY_TEX_UV].operator DVector<Vector2>().read();
73 	DVector<Vector2>::Read uv2;
74 	if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL)
75 		uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator DVector<Vector2>().read();
76 
77 	DVector<Color>::Read col;
78 	if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL)
79 		col = arrays[Mesh::ARRAY_COLOR].operator DVector<Color>().read();
80 
81 	DVector<real_t>::Read bo;
82 	if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL)
83 		bo = arrays[Mesh::ARRAY_BONES].operator DVector<real_t>().read();
84 
85 	DVector<real_t>::Read we;
86 	if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL)
87 		we = arrays[Mesh::ARRAY_WEIGHTS].operator DVector<real_t>().read();
88 
89 	vertices.resize(vcount);
90 
91 	for (int i = 0; i < vcount; i++) {
92 
93 		Vertex v;
94 		v.vertex = vr[i];
95 		if (nr.ptr())
96 			v.normal = nr[i];
97 		if (ta.ptr())
98 			v.tangent = Plane(ta[i * 4 + 0], ta[i * 4 + 1], ta[i * 4 + 2], ta[i * 4 + 3]);
99 		if (uv.ptr())
100 			v.uv = uv[i];
101 		if (uv2.ptr())
102 			v.uv2 = uv2[i];
103 		if (col.ptr())
104 			v.color = col[i];
105 
106 		if (we.ptr()) {
107 
108 			v.weights.push_back(we[i * 4 + 0]);
109 			v.weights.push_back(we[i * 4 + 1]);
110 			v.weights.push_back(we[i * 4 + 2]);
111 			v.weights.push_back(we[i * 4 + 3]);
112 		}
113 
114 		if (bo.ptr()) {
115 
116 			v.bones.push_back(bo[i * 4 + 0]);
117 			v.bones.push_back(bo[i * 4 + 1]);
118 			v.bones.push_back(bo[i * 4 + 2]);
119 			v.bones.push_back(bo[i * 4 + 3]);
120 		}
121 
122 		vertices[i] = v;
123 	}
124 
125 	DVector<int> indices;
126 
127 	if (arrays[Mesh::ARRAY_INDEX].get_type() != Variant::NIL) {
128 
129 		indices = arrays[Mesh::ARRAY_INDEX];
130 	} else {
131 		//make code simpler
132 		indices.resize(vcount);
133 		DVector<int>::Write iw = indices.write();
134 		for (int i = 0; i < vcount; i++)
135 			iw[i] = i;
136 	}
137 
138 	int icount = indices.size();
139 	DVector<int>::Read r = indices.read();
140 
141 	Map<Point2i, int> edge_indices;
142 
143 	for (int i = 0; i < icount; i += 3) {
144 
145 		Vertex *v[3] = { &vertices[r[i + 0]], &vertices[r[i + 1]], &vertices[r[i + 2]] };
146 
147 		int fidx = faces.size();
148 		Face face;
149 
150 		for (int j = 0; j < 3; j++) {
151 
152 			face.v[j] = r[i + j];
153 
154 			Point2i edge(r[i + j], r[i + (j + 1) % 3]);
155 			if (edge.x > edge.y) {
156 				SWAP(edge.x, edge.y);
157 			}
158 
159 			if (edge_indices.has(edge)) {
160 				face.edges[j] = edge_indices[edge];
161 
162 			} else {
163 				face.edges[j] = edge_indices.size();
164 				edge_indices[edge] = face.edges[j];
165 				Edge e;
166 				e.vertex[0] = edge.x;
167 				e.vertex[1] = edge.y;
168 				edges.push_back(e);
169 			}
170 
171 			edges[face.edges[j]].faces.push_back(fidx);
172 			v[j]->faces.push_back(fidx);
173 			v[j]->edges.push_back(face.edges[j]);
174 		}
175 
176 		faces.push_back(face);
177 	}
178 
179 	return OK;
180 }
181 
commit_to_surface(const Ref<Mesh> & p_mesh)182 Error MeshDataTool::commit_to_surface(const Ref<Mesh> &p_mesh) {
183 
184 	ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
185 	Array arr;
186 	arr.resize(Mesh::ARRAY_MAX);
187 
188 	int vcount = vertices.size();
189 
190 	DVector<Vector3> v;
191 	DVector<Vector3> n;
192 	DVector<real_t> t;
193 	DVector<Vector2> u;
194 	DVector<Vector2> u2;
195 	DVector<Color> c;
196 	DVector<real_t> b;
197 	DVector<real_t> w;
198 	DVector<int> in;
199 
200 	{
201 
202 		v.resize(vcount);
203 		DVector<Vector3>::Write vr = v.write();
204 
205 		DVector<Vector3>::Write nr;
206 		if (format & Mesh::ARRAY_FORMAT_NORMAL) {
207 			n.resize(vcount);
208 			nr = n.write();
209 		}
210 
211 		DVector<real_t>::Write ta;
212 		if (format & Mesh::ARRAY_FORMAT_TANGENT) {
213 			t.resize(vcount * 4);
214 			ta = t.write();
215 		}
216 
217 		DVector<Vector2>::Write uv;
218 		if (format & Mesh::ARRAY_FORMAT_TEX_UV) {
219 			u.resize(vcount);
220 			uv = u.write();
221 		}
222 
223 		DVector<Vector2>::Write uv2;
224 		if (format & Mesh::ARRAY_FORMAT_TEX_UV2) {
225 			u2.resize(vcount);
226 			uv2 = u2.write();
227 		}
228 
229 		DVector<Color>::Write col;
230 		if (format & Mesh::ARRAY_FORMAT_COLOR) {
231 			c.resize(vcount);
232 			col = c.write();
233 		}
234 
235 		DVector<real_t>::Write bo;
236 		if (format & Mesh::ARRAY_FORMAT_BONES) {
237 			b.resize(vcount * 4);
238 			bo = b.write();
239 		}
240 
241 		DVector<real_t>::Write we;
242 		if (format & Mesh::ARRAY_FORMAT_WEIGHTS) {
243 			w.resize(vcount * 4);
244 			we = w.write();
245 		}
246 
247 		for (int i = 0; i < vcount; i++) {
248 
249 			Vertex &vtx = vertices[i];
250 
251 			vr[i] = vtx.vertex;
252 			if (nr.ptr())
253 				nr[i] = vtx.normal;
254 			if (ta.ptr()) {
255 				ta[i * 4 + 0] = vtx.tangent.normal.x;
256 				ta[i * 4 + 1] = vtx.tangent.normal.y;
257 				ta[i * 4 + 2] = vtx.tangent.normal.z;
258 				ta[i * 4 + 3] = vtx.tangent.d;
259 			}
260 			if (uv.ptr())
261 				uv[i] = vtx.uv;
262 			if (uv2.ptr())
263 				uv2[i] = vtx.uv2;
264 			if (col.ptr())
265 				col[i] = vtx.color;
266 
267 			if (we.ptr()) {
268 
269 				we[i * 4 + 0] = vtx.weights[0];
270 				we[i * 4 + 1] = vtx.weights[1];
271 				we[i * 4 + 2] = vtx.weights[2];
272 				we[i * 4 + 3] = vtx.weights[3];
273 			}
274 
275 			if (bo.ptr()) {
276 
277 				bo[i * 4 + 0] = vtx.bones[0];
278 				bo[i * 4 + 1] = vtx.bones[1];
279 				bo[i * 4 + 2] = vtx.bones[2];
280 				bo[i * 4 + 3] = vtx.bones[3];
281 			}
282 		}
283 
284 		int fc = faces.size();
285 		in.resize(fc * 3);
286 		DVector<int>::Write iw = in.write();
287 		for (int i = 0; i < fc; i++) {
288 
289 			iw[i * 3 + 0] = faces[i].v[0];
290 			iw[i * 3 + 1] = faces[i].v[1];
291 			iw[i * 3 + 2] = faces[i].v[2];
292 		}
293 	}
294 
295 	arr[Mesh::ARRAY_VERTEX] = v;
296 	arr[Mesh::ARRAY_INDEX] = in;
297 	if (n.size())
298 		arr[Mesh::ARRAY_NORMAL] = n;
299 	if (c.size())
300 		arr[Mesh::ARRAY_COLOR] = c;
301 	if (u.size())
302 		arr[Mesh::ARRAY_TEX_UV] = u;
303 	if (u2.size())
304 		arr[Mesh::ARRAY_TEX_UV2] = u2;
305 	if (t.size())
306 		arr[Mesh::ARRAY_TANGENT] = t;
307 	if (b.size())
308 		arr[Mesh::ARRAY_BONES] = b;
309 	if (w.size())
310 		arr[Mesh::ARRAY_WEIGHTS] = w;
311 
312 	Ref<Mesh> ncmesh = p_mesh;
313 	int sc = ncmesh->get_surface_count();
314 	ncmesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, arr);
315 	ncmesh->surface_set_material(sc, material);
316 
317 	return OK;
318 }
319 
get_format() const320 int MeshDataTool::get_format() const {
321 
322 	return format;
323 }
324 
get_vertex_count() const325 int MeshDataTool::get_vertex_count() const {
326 
327 	return vertices.size();
328 }
get_edge_count() const329 int MeshDataTool::get_edge_count() const {
330 
331 	return edges.size();
332 }
get_face_count() const333 int MeshDataTool::get_face_count() const {
334 
335 	return faces.size();
336 }
337 
get_vertex(int p_idx) const338 Vector3 MeshDataTool::get_vertex(int p_idx) const {
339 
340 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3());
341 	return vertices[p_idx].vertex;
342 }
set_vertex(int p_idx,const Vector3 & p_vertex)343 void MeshDataTool::set_vertex(int p_idx, const Vector3 &p_vertex) {
344 
345 	ERR_FAIL_INDEX(p_idx, vertices.size());
346 	vertices[p_idx].vertex = p_vertex;
347 }
348 
get_vertex_normal(int p_idx) const349 Vector3 MeshDataTool::get_vertex_normal(int p_idx) const {
350 
351 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3());
352 	return vertices[p_idx].normal;
353 }
set_vertex_normal(int p_idx,const Vector3 & p_normal)354 void MeshDataTool::set_vertex_normal(int p_idx, const Vector3 &p_normal) {
355 
356 	ERR_FAIL_INDEX(p_idx, vertices.size());
357 	vertices[p_idx].normal = p_normal;
358 	format |= Mesh::ARRAY_FORMAT_NORMAL;
359 }
360 
get_vertex_tangent(int p_idx) const361 Plane MeshDataTool::get_vertex_tangent(int p_idx) const {
362 
363 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Plane());
364 	return vertices[p_idx].tangent;
365 }
set_vertex_tangent(int p_idx,const Plane & p_tangent)366 void MeshDataTool::set_vertex_tangent(int p_idx, const Plane &p_tangent) {
367 
368 	ERR_FAIL_INDEX(p_idx, vertices.size());
369 	vertices[p_idx].tangent = p_tangent;
370 	format |= Mesh::ARRAY_FORMAT_TANGENT;
371 }
372 
get_vertex_uv(int p_idx) const373 Vector2 MeshDataTool::get_vertex_uv(int p_idx) const {
374 
375 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2());
376 	return vertices[p_idx].uv;
377 }
set_vertex_uv(int p_idx,const Vector2 & p_uv)378 void MeshDataTool::set_vertex_uv(int p_idx, const Vector2 &p_uv) {
379 
380 	ERR_FAIL_INDEX(p_idx, vertices.size());
381 	vertices[p_idx].uv = p_uv;
382 	format |= Mesh::ARRAY_FORMAT_TEX_UV;
383 }
384 
get_vertex_uv2(int p_idx) const385 Vector2 MeshDataTool::get_vertex_uv2(int p_idx) const {
386 
387 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2());
388 	return vertices[p_idx].uv2;
389 }
set_vertex_uv2(int p_idx,const Vector2 & p_uv2)390 void MeshDataTool::set_vertex_uv2(int p_idx, const Vector2 &p_uv2) {
391 
392 	ERR_FAIL_INDEX(p_idx, vertices.size());
393 	vertices[p_idx].uv2 = p_uv2;
394 	format |= Mesh::ARRAY_FORMAT_TEX_UV2;
395 }
396 
get_vertex_color(int p_idx) const397 Color MeshDataTool::get_vertex_color(int p_idx) const {
398 
399 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Color());
400 	return vertices[p_idx].color;
401 }
set_vertex_color(int p_idx,const Color & p_color)402 void MeshDataTool::set_vertex_color(int p_idx, const Color &p_color) {
403 
404 	ERR_FAIL_INDEX(p_idx, vertices.size());
405 	vertices[p_idx].color = p_color;
406 	format |= Mesh::ARRAY_FORMAT_COLOR;
407 }
408 
get_vertex_bones(int p_idx) const409 Vector<int> MeshDataTool::get_vertex_bones(int p_idx) const {
410 
411 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
412 	return vertices[p_idx].bones;
413 }
set_vertex_bones(int p_idx,const Vector<int> & p_bones)414 void MeshDataTool::set_vertex_bones(int p_idx, const Vector<int> &p_bones) {
415 
416 	ERR_FAIL_INDEX(p_idx, vertices.size());
417 	vertices[p_idx].bones = p_bones;
418 	format |= Mesh::ARRAY_FORMAT_BONES;
419 }
420 
get_vertex_weights(int p_idx) const421 Vector<float> MeshDataTool::get_vertex_weights(int p_idx) const {
422 
423 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<float>());
424 	return vertices[p_idx].weights;
425 }
set_vertex_weights(int p_idx,const Vector<float> & p_weights)426 void MeshDataTool::set_vertex_weights(int p_idx, const Vector<float> &p_weights) {
427 	ERR_FAIL_INDEX(p_idx, vertices.size());
428 	vertices[p_idx].weights = p_weights;
429 	format |= Mesh::ARRAY_FORMAT_WEIGHTS;
430 }
431 
get_vertex_meta(int p_idx) const432 Variant MeshDataTool::get_vertex_meta(int p_idx) const {
433 
434 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Variant());
435 	return vertices[p_idx].meta;
436 }
437 
set_vertex_meta(int p_idx,const Variant & p_meta)438 void MeshDataTool::set_vertex_meta(int p_idx, const Variant &p_meta) {
439 
440 	ERR_FAIL_INDEX(p_idx, vertices.size());
441 	vertices[p_idx].meta = p_meta;
442 }
443 
get_vertex_edges(int p_idx) const444 Vector<int> MeshDataTool::get_vertex_edges(int p_idx) const {
445 
446 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
447 	return vertices[p_idx].edges;
448 }
get_vertex_faces(int p_idx) const449 Vector<int> MeshDataTool::get_vertex_faces(int p_idx) const {
450 
451 	ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
452 	return vertices[p_idx].faces;
453 }
454 
get_edge_vertex(int p_edge,int p_vertex) const455 int MeshDataTool::get_edge_vertex(int p_edge, int p_vertex) const {
456 
457 	ERR_FAIL_INDEX_V(p_edge, edges.size(), -1);
458 	ERR_FAIL_INDEX_V(p_vertex, 2, -1);
459 	return edges[p_edge].vertex[p_vertex];
460 }
get_edge_faces(int p_edge) const461 Vector<int> MeshDataTool::get_edge_faces(int p_edge) const {
462 
463 	ERR_FAIL_INDEX_V(p_edge, edges.size(), Vector<int>());
464 	return edges[p_edge].faces;
465 }
get_edge_meta(int p_idx) const466 Variant MeshDataTool::get_edge_meta(int p_idx) const {
467 
468 	ERR_FAIL_INDEX_V(p_idx, edges.size(), Variant());
469 	return edges[p_idx].meta;
470 }
set_edge_meta(int p_idx,const Variant & p_meta)471 void MeshDataTool::set_edge_meta(int p_idx, const Variant &p_meta) {
472 
473 	ERR_FAIL_INDEX(p_idx, edges.size());
474 	edges[p_idx].meta = p_meta;
475 }
476 
get_face_vertex(int p_face,int p_vertex) const477 int MeshDataTool::get_face_vertex(int p_face, int p_vertex) const {
478 
479 	ERR_FAIL_INDEX_V(p_face, faces.size(), -1);
480 	ERR_FAIL_INDEX_V(p_vertex, 3, -1);
481 	return faces[p_face].v[p_vertex];
482 }
get_face_edge(int p_face,int p_vertex) const483 int MeshDataTool::get_face_edge(int p_face, int p_vertex) const {
484 
485 	ERR_FAIL_INDEX_V(p_face, faces.size(), -1);
486 	ERR_FAIL_INDEX_V(p_vertex, 3, -1);
487 	return faces[p_face].edges[p_vertex];
488 }
get_face_meta(int p_face) const489 Variant MeshDataTool::get_face_meta(int p_face) const {
490 
491 	ERR_FAIL_INDEX_V(p_face, faces.size(), Variant());
492 	return faces[p_face].meta;
493 }
set_face_meta(int p_face,const Variant & p_meta)494 void MeshDataTool::set_face_meta(int p_face, const Variant &p_meta) {
495 
496 	ERR_FAIL_INDEX(p_face, faces.size());
497 	faces[p_face].meta = p_meta;
498 }
499 
get_face_normal(int p_face) const500 Vector3 MeshDataTool::get_face_normal(int p_face) const {
501 
502 	ERR_FAIL_INDEX_V(p_face, faces.size(), Vector3());
503 	Vector3 v0 = vertices[faces[p_face].v[0]].vertex;
504 	Vector3 v1 = vertices[faces[p_face].v[1]].vertex;
505 	Vector3 v2 = vertices[faces[p_face].v[2]].vertex;
506 
507 	return Plane(v0, v1, v2).normal;
508 }
509 
get_material() const510 Ref<Material> MeshDataTool::get_material() const {
511 
512 	return material;
513 }
514 
set_material(const Ref<Material> & p_material)515 void MeshDataTool::set_material(const Ref<Material> &p_material) {
516 
517 	material = p_material;
518 }
519 
_bind_methods()520 void MeshDataTool::_bind_methods() {
521 
522 	ObjectTypeDB::bind_method(_MD("clear"), &MeshDataTool::clear);
523 	ObjectTypeDB::bind_method(_MD("create_from_surface", "mesh", "surface"), &MeshDataTool::create_from_surface);
524 	ObjectTypeDB::bind_method(_MD("commit_to_surface", "mesh"), &MeshDataTool::commit_to_surface);
525 
526 	ObjectTypeDB::bind_method(_MD("get_format"), &MeshDataTool::get_format);
527 
528 	ObjectTypeDB::bind_method(_MD("get_vertex_count"), &MeshDataTool::get_vertex_count);
529 	ObjectTypeDB::bind_method(_MD("get_edge_count"), &MeshDataTool::get_edge_count);
530 	ObjectTypeDB::bind_method(_MD("get_face_count"), &MeshDataTool::get_face_count);
531 
532 	ObjectTypeDB::bind_method(_MD("set_vertex", "idx", "vertex"), &MeshDataTool::set_vertex);
533 	ObjectTypeDB::bind_method(_MD("get_vertex", "idx"), &MeshDataTool::get_vertex);
534 
535 	ObjectTypeDB::bind_method(_MD("set_vertex_normal", "idx", "normal"), &MeshDataTool::set_vertex_normal);
536 	ObjectTypeDB::bind_method(_MD("get_vertex_normal", "idx"), &MeshDataTool::get_vertex_normal);
537 
538 	ObjectTypeDB::bind_method(_MD("set_vertex_tangent", "idx", "tangent"), &MeshDataTool::set_vertex_tangent);
539 	ObjectTypeDB::bind_method(_MD("get_vertex_tangent", "idx"), &MeshDataTool::get_vertex_tangent);
540 
541 	ObjectTypeDB::bind_method(_MD("set_vertex_uv", "idx", "uv"), &MeshDataTool::set_vertex_uv);
542 	ObjectTypeDB::bind_method(_MD("get_vertex_uv", "idx"), &MeshDataTool::get_vertex_uv);
543 
544 	ObjectTypeDB::bind_method(_MD("set_vertex_uv2", "idx", "uv2"), &MeshDataTool::set_vertex_uv2);
545 	ObjectTypeDB::bind_method(_MD("get_vertex_uv2", "idx"), &MeshDataTool::get_vertex_uv2);
546 
547 	ObjectTypeDB::bind_method(_MD("set_vertex_color", "idx", "color"), &MeshDataTool::set_vertex_color);
548 	ObjectTypeDB::bind_method(_MD("get_vertex_color", "idx"), &MeshDataTool::get_vertex_color);
549 
550 	ObjectTypeDB::bind_method(_MD("set_vertex_bones", "idx", "bones"), &MeshDataTool::set_vertex_bones);
551 	ObjectTypeDB::bind_method(_MD("get_vertex_bones", "idx"), &MeshDataTool::get_vertex_bones);
552 
553 	ObjectTypeDB::bind_method(_MD("set_vertex_weights", "idx", "weights"), &MeshDataTool::set_vertex_weights);
554 	ObjectTypeDB::bind_method(_MD("get_vertex_weights", "idx"), &MeshDataTool::get_vertex_weights);
555 
556 	ObjectTypeDB::bind_method(_MD("set_vertex_meta", "idx", "meta"), &MeshDataTool::set_vertex_meta);
557 	ObjectTypeDB::bind_method(_MD("get_vertex_meta", "idx"), &MeshDataTool::get_vertex_meta);
558 
559 	ObjectTypeDB::bind_method(_MD("get_vertex_edges", "idx"), &MeshDataTool::get_vertex_edges);
560 	ObjectTypeDB::bind_method(_MD("get_vertex_faces", "idx"), &MeshDataTool::get_vertex_faces);
561 
562 	ObjectTypeDB::bind_method(_MD("get_edge_vertex", "idx", "vertex"), &MeshDataTool::get_edge_vertex);
563 	ObjectTypeDB::bind_method(_MD("get_edge_faces", "idx", "faces"), &MeshDataTool::get_edge_faces);
564 
565 	ObjectTypeDB::bind_method(_MD("set_edge_meta", "idx", "meta"), &MeshDataTool::set_edge_meta);
566 	ObjectTypeDB::bind_method(_MD("get_edge_meta", "idx"), &MeshDataTool::get_edge_meta);
567 
568 	ObjectTypeDB::bind_method(_MD("get_face_vertex", "idx", "vertex"), &MeshDataTool::get_face_vertex);
569 	ObjectTypeDB::bind_method(_MD("get_face_edge", "idx", "edge"), &MeshDataTool::get_face_edge);
570 
571 	ObjectTypeDB::bind_method(_MD("set_face_meta", "idx", "meta"), &MeshDataTool::set_face_meta);
572 	ObjectTypeDB::bind_method(_MD("get_face_meta", "idx"), &MeshDataTool::get_face_meta);
573 
574 	ObjectTypeDB::bind_method(_MD("get_face_normal", "idx"), &MeshDataTool::get_face_normal);
575 
576 	ObjectTypeDB::bind_method(_MD("set_material", "material:Material"), &MeshDataTool::set_material);
577 	ObjectTypeDB::bind_method(_MD("get_material", "material"), &MeshDataTool::get_material);
578 }
579 
MeshDataTool()580 MeshDataTool::MeshDataTool() {
581 
582 	clear();
583 }
584