From cacf9ebb7fd8df8845daca9da2fe55456cc179aa Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 9 Nov 2016 23:55:06 -0300 Subject: all light types and shadows are working, pending a lot of clean-up --- servers/visual_server.cpp | 450 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 449 insertions(+), 1 deletion(-) (limited to 'servers/visual_server.cpp') diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 95636d2bc..953448db5 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1021,7 +1021,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi break; } /* determine wether using 16 or 32 bits indices */ - if (array_len>(1<<16)) { + if (array_len>=(1<<16)) { elem_size=4; @@ -1089,6 +1089,454 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi } +Array VisualServer::_get_array_from_surface(uint32_t p_format,DVector p_vertex_data,int p_vertex_len,DVector p_index_data,int p_index_len) const { + + + uint32_t offsets[ARRAY_MAX]; + + int total_elem_size=0; + + for (int i=0;i=(1<<16)) { + + elem_size=4; + + } else { + elem_size=2; + } + offsets[i]=elem_size; + continue; + } break; + default: { + ERR_FAIL_V( Array() ); + } + } + + offsets[i]=total_elem_size; + total_elem_size+=elem_size; + + + } + + Array ret; + ret.resize(VS::ARRAY_MAX); + + DVector::Read r = p_vertex_data.read(); + + for(int i=0;i arr_2d; + arr_2d.resize(p_vertex_len); + + if (p_format&ARRAY_COMPRESS_VERTEX) { + + DVector::Write w = arr_2d.write(); + + for(int j=0;j::Write w = arr_2d.write(); + + for(int j=0;j arr_3d; + arr_3d.resize(p_vertex_len); + + if (p_format&ARRAY_COMPRESS_VERTEX) { + + DVector::Write w = arr_3d.write(); + + for(int j=0;j::Write w = arr_3d.write(); + + for(int j=0;j arr; + arr.resize(p_vertex_len); + + if (p_format&ARRAY_COMPRESS_NORMAL) { + + DVector::Write w = arr.write(); + + for(int j=0;j::Write w = arr.write(); + + for(int j=0;j arr; + arr.resize(p_vertex_len*4); + if (p_format&ARRAY_COMPRESS_TANGENT) { + DVector::Write w = arr.write(); + + for(int j=0;j::Write w = arr.write(); + + for(int j=0;j arr; + arr.resize(p_vertex_len); + + if (p_format&ARRAY_COMPRESS_COLOR) { + + DVector::Write w = arr.write(); + + for(int j=0;j::Write w = arr.write(); + + for(int j=0;j arr; + arr.resize(p_vertex_len); + + if (p_format&ARRAY_COMPRESS_TEX_UV) { + + DVector::Write w = arr.write(); + + for(int j=0;j::Write w = arr.write(); + + for(int j=0;j arr; + arr.resize(p_vertex_len); + + if (p_format&ARRAY_COMPRESS_TEX_UV2) { + + DVector::Write w = arr.write(); + + for(int j=0;j::Write w = arr.write(); + + for(int j=0;j arr; + arr.resize(p_vertex_len*4); + if (p_format&ARRAY_COMPRESS_WEIGHTS) { + DVector::Write w = arr.write(); + + for(int j=0;j::Write w = arr.write(); + + for(int j=0;j arr; + arr.resize(p_vertex_len*4); + if (p_format&ARRAY_FLAG_USE_16_BIT_BONES) { + + DVector::Write w = arr.write(); + + for(int j=0;j::Write w = arr.write(); + + for(int j=0;j::Read ir = p_index_data.read(); + + DVector arr; + arr.resize(p_index_len); + if (p_index_len<(1<<16)) { + + DVector::Write w = arr.write(); + + for(int j=0;j::Write w = arr.write(); + + for(int j=0;j vertex_data = mesh_surface_get_array(p_mesh,p_surface); + ERR_FAIL_COND_V(vertex_data.size()==0,Array()); + int vertex_len = mesh_surface_get_array_len(p_mesh,p_surface); + + DVector index_data = mesh_surface_get_index_array(p_mesh,p_surface); + int index_len = mesh_surface_get_array_index_len(p_mesh,p_surface); + + uint32_t format = mesh_surface_get_format(p_mesh,p_surface); + + + return _get_array_from_surface(format,vertex_data,vertex_len,index_data,index_len); + +} + void VisualServer::_bind_methods() { -- cgit v1.2.3-70-g09d2