visual_server.cpp 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497
  1. /*************************************************************************/
  2. /* visual_server.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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 "visual_server.h"
  31. #include "core/method_bind_ext.gen.inc"
  32. #include "core/project_settings.h"
  33. VisualServer *VisualServer::singleton = NULL;
  34. VisualServer *(*VisualServer::create_func)() = NULL;
  35. VisualServer *VisualServer::get_singleton() {
  36. return singleton;
  37. }
  38. VisualServer *VisualServer::create() {
  39. ERR_FAIL_COND_V(singleton, NULL);
  40. if (create_func)
  41. return create_func();
  42. return NULL;
  43. }
  44. RID VisualServer::texture_create_from_image(const Ref<Image> &p_image, uint32_t p_flags) {
  45. ERR_FAIL_COND_V(!p_image.is_valid(), RID());
  46. RID texture = texture_create();
  47. texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_flags); //if it has mipmaps, use, else generate
  48. ERR_FAIL_COND_V(!texture.is_valid(), texture);
  49. texture_set_data(texture, p_image);
  50. return texture;
  51. }
  52. Array VisualServer::_texture_debug_usage_bind() {
  53. List<TextureInfo> list;
  54. texture_debug_usage(&list);
  55. Array arr;
  56. for (const List<TextureInfo>::Element *E = list.front(); E; E = E->next()) {
  57. Dictionary dict;
  58. dict["texture"] = E->get().texture;
  59. dict["width"] = E->get().width;
  60. dict["height"] = E->get().height;
  61. dict["depth"] = E->get().depth;
  62. dict["format"] = E->get().format;
  63. dict["bytes"] = E->get().bytes;
  64. dict["path"] = E->get().path;
  65. arr.push_back(dict);
  66. }
  67. return arr;
  68. }
  69. Array VisualServer::_shader_get_param_list_bind(RID p_shader) const {
  70. List<PropertyInfo> l;
  71. shader_get_param_list(p_shader, &l);
  72. return convert_property_list(&l);
  73. }
  74. static Array to_array(const Vector<ObjectID> &ids) {
  75. Array a;
  76. a.resize(ids.size());
  77. for (int i = 0; i < ids.size(); ++i) {
  78. a[i] = ids[i];
  79. }
  80. return a;
  81. }
  82. Array VisualServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {
  83. Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario);
  84. return to_array(ids);
  85. }
  86. Array VisualServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
  87. Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario);
  88. return to_array(ids);
  89. }
  90. Array VisualServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const {
  91. Vector<Plane> planes;
  92. for (int i = 0; i < p_convex.size(); ++i) {
  93. Variant v = p_convex[i];
  94. ERR_FAIL_COND_V(v.get_type() != Variant::PLANE, Array());
  95. planes.push_back(v);
  96. }
  97. Vector<ObjectID> ids = instances_cull_convex(planes, p_scenario);
  98. return to_array(ids);
  99. }
  100. RID VisualServer::get_test_texture() {
  101. if (test_texture.is_valid()) {
  102. return test_texture;
  103. };
  104. #define TEST_TEXTURE_SIZE 256
  105. PoolVector<uint8_t> test_data;
  106. test_data.resize(TEST_TEXTURE_SIZE * TEST_TEXTURE_SIZE * 3);
  107. {
  108. PoolVector<uint8_t>::Write w = test_data.write();
  109. for (int x = 0; x < TEST_TEXTURE_SIZE; x++) {
  110. for (int y = 0; y < TEST_TEXTURE_SIZE; y++) {
  111. Color c;
  112. int r = 255 - (x + y) / 2;
  113. if ((x % (TEST_TEXTURE_SIZE / 8)) < 2 || (y % (TEST_TEXTURE_SIZE / 8)) < 2) {
  114. c.r = y;
  115. c.g = r;
  116. c.b = x;
  117. } else {
  118. c.r = r;
  119. c.g = x;
  120. c.b = y;
  121. }
  122. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 0] = uint8_t(CLAMP(c.r * 255, 0, 255));
  123. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 1] = uint8_t(CLAMP(c.g * 255, 0, 255));
  124. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 2] = uint8_t(CLAMP(c.b * 255, 0, 255));
  125. }
  126. }
  127. }
  128. Ref<Image> data = memnew(Image(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data));
  129. test_texture = texture_create_from_image(data);
  130. return test_texture;
  131. }
  132. void VisualServer::_free_internal_rids() {
  133. if (test_texture.is_valid())
  134. free(test_texture);
  135. if (white_texture.is_valid())
  136. free(white_texture);
  137. if (test_material.is_valid())
  138. free(test_material);
  139. }
  140. RID VisualServer::_make_test_cube() {
  141. PoolVector<Vector3> vertices;
  142. PoolVector<Vector3> normals;
  143. PoolVector<float> tangents;
  144. PoolVector<Vector3> uvs;
  145. #define ADD_VTX(m_idx) \
  146. vertices.push_back(face_points[m_idx]); \
  147. normals.push_back(normal_points[m_idx]); \
  148. tangents.push_back(normal_points[m_idx][1]); \
  149. tangents.push_back(normal_points[m_idx][2]); \
  150. tangents.push_back(normal_points[m_idx][0]); \
  151. tangents.push_back(1.0); \
  152. uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0));
  153. for (int i = 0; i < 6; i++) {
  154. Vector3 face_points[4];
  155. Vector3 normal_points[4];
  156. float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 };
  157. for (int j = 0; j < 4; j++) {
  158. float v[3];
  159. v[0] = 1.0;
  160. v[1] = 1 - 2 * ((j >> 1) & 1);
  161. v[2] = v[1] * (1 - 2 * (j & 1));
  162. for (int k = 0; k < 3; k++) {
  163. if (i < 3)
  164. face_points[j][(i + k) % 3] = v[k];
  165. else
  166. face_points[3 - j][(i + k) % 3] = -v[k];
  167. }
  168. normal_points[j] = Vector3();
  169. normal_points[j][i % 3] = (i >= 3 ? -1 : 1);
  170. }
  171. //tri 1
  172. ADD_VTX(0);
  173. ADD_VTX(1);
  174. ADD_VTX(2);
  175. //tri 2
  176. ADD_VTX(2);
  177. ADD_VTX(3);
  178. ADD_VTX(0);
  179. }
  180. RID test_cube = mesh_create();
  181. Array d;
  182. d.resize(VS::ARRAY_MAX);
  183. d[VisualServer::ARRAY_NORMAL] = normals;
  184. d[VisualServer::ARRAY_TANGENT] = tangents;
  185. d[VisualServer::ARRAY_TEX_UV] = uvs;
  186. d[VisualServer::ARRAY_VERTEX] = vertices;
  187. PoolVector<int> indices;
  188. indices.resize(vertices.size());
  189. for (int i = 0; i < vertices.size(); i++)
  190. indices.set(i, i);
  191. d[VisualServer::ARRAY_INDEX] = indices;
  192. mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);
  193. /*
  194. test_material = fixed_material_create();
  195. //material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);
  196. fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
  197. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
  198. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );
  199. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
  200. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );
  201. */
  202. mesh_surface_set_material(test_cube, 0, test_material);
  203. return test_cube;
  204. }
  205. RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
  206. PoolVector<Vector3> vertices;
  207. PoolVector<Vector3> normals;
  208. for (int i = 1; i <= p_lats; i++) {
  209. double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats);
  210. double z0 = Math::sin(lat0);
  211. double zr0 = Math::cos(lat0);
  212. double lat1 = Math_PI * (-0.5 + (double)i / p_lats);
  213. double z1 = Math::sin(lat1);
  214. double zr1 = Math::cos(lat1);
  215. for (int j = p_lons; j >= 1; j--) {
  216. double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons;
  217. double x0 = Math::cos(lng0);
  218. double y0 = Math::sin(lng0);
  219. double lng1 = 2 * Math_PI * (double)(j) / p_lons;
  220. double x1 = Math::cos(lng1);
  221. double y1 = Math::sin(lng1);
  222. Vector3 v[4] = {
  223. Vector3(x1 * zr0, z0, y1 * zr0),
  224. Vector3(x1 * zr1, z1, y1 * zr1),
  225. Vector3(x0 * zr1, z1, y0 * zr1),
  226. Vector3(x0 * zr0, z0, y0 * zr0)
  227. };
  228. #define ADD_POINT(m_idx) \
  229. normals.push_back(v[m_idx]); \
  230. vertices.push_back(v[m_idx] * p_radius);
  231. ADD_POINT(0);
  232. ADD_POINT(1);
  233. ADD_POINT(2);
  234. ADD_POINT(2);
  235. ADD_POINT(3);
  236. ADD_POINT(0);
  237. }
  238. }
  239. RID mesh = mesh_create();
  240. Array d;
  241. d.resize(VS::ARRAY_MAX);
  242. d[ARRAY_VERTEX] = vertices;
  243. d[ARRAY_NORMAL] = normals;
  244. mesh_add_surface_from_arrays(mesh, PRIMITIVE_TRIANGLES, d);
  245. return mesh;
  246. }
  247. RID VisualServer::get_white_texture() {
  248. if (white_texture.is_valid())
  249. return white_texture;
  250. PoolVector<uint8_t> wt;
  251. wt.resize(16 * 3);
  252. {
  253. PoolVector<uint8_t>::Write w = wt.write();
  254. for (int i = 0; i < 16 * 3; i++)
  255. w[i] = 255;
  256. }
  257. Ref<Image> white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt));
  258. white_texture = texture_create();
  259. texture_allocate(white_texture, 4, 4, 0, Image::FORMAT_RGB8, TEXTURE_TYPE_2D);
  260. texture_set_data(white_texture, white);
  261. return white_texture;
  262. }
  263. #define SMALL_VEC2 Vector2(0.00001, 0.00001)
  264. #define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001)
  265. Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb) {
  266. PoolVector<uint8_t>::Write vw = r_vertex_array.write();
  267. PoolVector<uint8_t>::Write iw;
  268. if (r_index_array.size()) {
  269. iw = r_index_array.write();
  270. }
  271. int max_bone = 0;
  272. for (int ai = 0; ai < VS::ARRAY_MAX; ai++) {
  273. if (!(p_format & (1 << ai))) // no array
  274. continue;
  275. switch (ai) {
  276. case VS::ARRAY_VERTEX: {
  277. if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) {
  278. PoolVector<Vector2> array = p_arrays[ai];
  279. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  280. PoolVector<Vector2>::Read read = array.read();
  281. const Vector2 *src = read.ptr();
  282. // setting vertices means regenerating the AABB
  283. Rect2 aabb;
  284. if (p_format & ARRAY_COMPRESS_VERTEX) {
  285. for (int i = 0; i < p_vertex_array_len; i++) {
  286. uint16_t vector[2] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y) };
  287. copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(uint16_t) * 2);
  288. if (i == 0) {
  289. aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size
  290. } else {
  291. aabb.expand_to(src[i]);
  292. }
  293. }
  294. } else {
  295. for (int i = 0; i < p_vertex_array_len; i++) {
  296. float vector[2] = { src[i].x, src[i].y };
  297. copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(float) * 2);
  298. if (i == 0) {
  299. aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size
  300. } else {
  301. aabb.expand_to(src[i]);
  302. }
  303. }
  304. }
  305. r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0));
  306. } else {
  307. PoolVector<Vector3> array = p_arrays[ai];
  308. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  309. PoolVector<Vector3>::Read read = array.read();
  310. const Vector3 *src = read.ptr();
  311. // setting vertices means regenerating the AABB
  312. AABB aabb;
  313. if (p_format & ARRAY_COMPRESS_VERTEX) {
  314. for (int i = 0; i < p_vertex_array_len; i++) {
  315. uint16_t vector[4] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y), Math::make_half_float(src[i].z), Math::make_half_float(1.0) };
  316. copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(uint16_t) * 4);
  317. if (i == 0) {
  318. aabb = AABB(src[i], SMALL_VEC3);
  319. } else {
  320. aabb.expand_to(src[i]);
  321. }
  322. }
  323. } else {
  324. for (int i = 0; i < p_vertex_array_len; i++) {
  325. float vector[3] = { src[i].x, src[i].y, src[i].z };
  326. copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(float) * 3);
  327. if (i == 0) {
  328. aabb = AABB(src[i], SMALL_VEC3);
  329. } else {
  330. aabb.expand_to(src[i]);
  331. }
  332. }
  333. }
  334. r_aabb = aabb;
  335. }
  336. } break;
  337. case VS::ARRAY_NORMAL: {
  338. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
  339. PoolVector<Vector3> array = p_arrays[ai];
  340. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  341. PoolVector<Vector3>::Read read = array.read();
  342. const Vector3 *src = read.ptr();
  343. // setting vertices means regenerating the AABB
  344. if (p_format & ARRAY_COMPRESS_NORMAL) {
  345. for (int i = 0; i < p_vertex_array_len; i++) {
  346. int8_t vector[4] = {
  347. (int8_t)CLAMP(src[i].x * 127, -128, 127),
  348. (int8_t)CLAMP(src[i].y * 127, -128, 127),
  349. (int8_t)CLAMP(src[i].z * 127, -128, 127),
  350. 0,
  351. };
  352. copymem(&vw[p_offsets[ai] + i * p_stride], vector, 4);
  353. }
  354. } else {
  355. for (int i = 0; i < p_vertex_array_len; i++) {
  356. float vector[3] = { src[i].x, src[i].y, src[i].z };
  357. copymem(&vw[p_offsets[ai] + i * p_stride], vector, 3 * 4);
  358. }
  359. }
  360. } break;
  361. case VS::ARRAY_TANGENT: {
  362. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER);
  363. PoolVector<real_t> array = p_arrays[ai];
  364. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  365. PoolVector<real_t>::Read read = array.read();
  366. const real_t *src = read.ptr();
  367. if (p_format & ARRAY_COMPRESS_TANGENT) {
  368. for (int i = 0; i < p_vertex_array_len; i++) {
  369. int8_t xyzw[4] = {
  370. (int8_t)CLAMP(src[i * 4 + 0] * 127, -128, 127),
  371. (int8_t)CLAMP(src[i * 4 + 1] * 127, -128, 127),
  372. (int8_t)CLAMP(src[i * 4 + 2] * 127, -128, 127),
  373. (int8_t)CLAMP(src[i * 4 + 3] * 127, -128, 127)
  374. };
  375. copymem(&vw[p_offsets[ai] + i * p_stride], xyzw, 4);
  376. }
  377. } else {
  378. for (int i = 0; i < p_vertex_array_len; i++) {
  379. float xyzw[4] = {
  380. src[i * 4 + 0],
  381. src[i * 4 + 1],
  382. src[i * 4 + 2],
  383. src[i * 4 + 3]
  384. };
  385. copymem(&vw[p_offsets[ai] + i * p_stride], xyzw, 4 * 4);
  386. }
  387. }
  388. } break;
  389. case VS::ARRAY_COLOR: {
  390. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_COLOR_ARRAY, ERR_INVALID_PARAMETER);
  391. PoolVector<Color> array = p_arrays[ai];
  392. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  393. PoolVector<Color>::Read read = array.read();
  394. const Color *src = read.ptr();
  395. if (p_format & ARRAY_COMPRESS_COLOR) {
  396. for (int i = 0; i < p_vertex_array_len; i++) {
  397. uint8_t colors[4];
  398. for (int j = 0; j < 4; j++) {
  399. colors[j] = CLAMP(int((src[i][j]) * 255.0), 0, 255);
  400. }
  401. copymem(&vw[p_offsets[ai] + i * p_stride], colors, 4);
  402. }
  403. } else {
  404. for (int i = 0; i < p_vertex_array_len; i++) {
  405. copymem(&vw[p_offsets[ai] + i * p_stride], &src[i], 4 * 4);
  406. }
  407. }
  408. } break;
  409. case VS::ARRAY_TEX_UV: {
  410. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::POOL_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
  411. PoolVector<Vector2> array = p_arrays[ai];
  412. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  413. PoolVector<Vector2>::Read read = array.read();
  414. const Vector2 *src = read.ptr();
  415. if (p_format & ARRAY_COMPRESS_TEX_UV) {
  416. for (int i = 0; i < p_vertex_array_len; i++) {
  417. uint16_t uv[2] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y) };
  418. copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 2);
  419. }
  420. } else {
  421. for (int i = 0; i < p_vertex_array_len; i++) {
  422. float uv[2] = { src[i].x, src[i].y };
  423. copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 4);
  424. }
  425. }
  426. } break;
  427. case VS::ARRAY_TEX_UV2: {
  428. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::POOL_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
  429. PoolVector<Vector2> array = p_arrays[ai];
  430. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  431. PoolVector<Vector2>::Read read = array.read();
  432. const Vector2 *src = read.ptr();
  433. if (p_format & ARRAY_COMPRESS_TEX_UV2) {
  434. for (int i = 0; i < p_vertex_array_len; i++) {
  435. uint16_t uv[2] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y) };
  436. copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 2);
  437. }
  438. } else {
  439. for (int i = 0; i < p_vertex_array_len; i++) {
  440. float uv[2] = { src[i].x, src[i].y };
  441. copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 4);
  442. }
  443. }
  444. } break;
  445. case VS::ARRAY_WEIGHTS: {
  446. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER);
  447. PoolVector<real_t> array = p_arrays[ai];
  448. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
  449. PoolVector<real_t>::Read read = array.read();
  450. const real_t *src = read.ptr();
  451. if (p_format & ARRAY_COMPRESS_WEIGHTS) {
  452. for (int i = 0; i < p_vertex_array_len; i++) {
  453. uint16_t data[VS::ARRAY_WEIGHTS_SIZE];
  454. for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
  455. data[j] = CLAMP(src[i * VS::ARRAY_WEIGHTS_SIZE + j] * 65535, 0, 65535);
  456. }
  457. copymem(&vw[p_offsets[ai] + i * p_stride], data, 2 * 4);
  458. }
  459. } else {
  460. for (int i = 0; i < p_vertex_array_len; i++) {
  461. float data[VS::ARRAY_WEIGHTS_SIZE];
  462. for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
  463. data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j];
  464. }
  465. copymem(&vw[p_offsets[ai] + i * p_stride], data, 4 * 4);
  466. }
  467. }
  468. } break;
  469. case VS::ARRAY_BONES: {
  470. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY && p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER);
  471. PoolVector<int> array = p_arrays[ai];
  472. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
  473. PoolVector<int>::Read read = array.read();
  474. const int *src = read.ptr();
  475. if (!(p_format & ARRAY_FLAG_USE_16_BIT_BONES)) {
  476. for (int i = 0; i < p_vertex_array_len; i++) {
  477. uint8_t data[VS::ARRAY_WEIGHTS_SIZE];
  478. for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
  479. data[j] = CLAMP(src[i * VS::ARRAY_WEIGHTS_SIZE + j], 0, 255);
  480. max_bone = MAX(data[j], max_bone);
  481. }
  482. copymem(&vw[p_offsets[ai] + i * p_stride], data, 4);
  483. }
  484. } else {
  485. for (int i = 0; i < p_vertex_array_len; i++) {
  486. uint16_t data[VS::ARRAY_WEIGHTS_SIZE];
  487. for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
  488. data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j];
  489. max_bone = MAX(data[j], max_bone);
  490. }
  491. copymem(&vw[p_offsets[ai] + i * p_stride], data, 2 * 4);
  492. }
  493. }
  494. } break;
  495. case VS::ARRAY_INDEX: {
  496. ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA);
  497. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY, ERR_INVALID_PARAMETER);
  498. PoolVector<int> indices = p_arrays[ai];
  499. ERR_FAIL_COND_V(indices.size() == 0, ERR_INVALID_PARAMETER);
  500. ERR_FAIL_COND_V(indices.size() != p_index_array_len, ERR_INVALID_PARAMETER);
  501. /* determine whether using 16 or 32 bits indices */
  502. PoolVector<int>::Read read = indices.read();
  503. const int *src = read.ptr();
  504. for (int i = 0; i < p_index_array_len; i++) {
  505. if (p_vertex_array_len < (1 << 16)) {
  506. uint16_t v = src[i];
  507. copymem(&iw[i * 2], &v, 2);
  508. } else {
  509. uint32_t v = src[i];
  510. copymem(&iw[i * 4], &v, 4);
  511. }
  512. }
  513. } break;
  514. default: {
  515. ERR_FAIL_V(ERR_INVALID_DATA);
  516. }
  517. }
  518. }
  519. if (p_format & VS::ARRAY_FORMAT_BONES) {
  520. //create AABBs for each detected bone
  521. int total_bones = max_bone + 1;
  522. bool first = r_bone_aabb.size() == 0;
  523. r_bone_aabb.resize(total_bones);
  524. if (first) {
  525. for (int i = 0; i < total_bones; i++) {
  526. r_bone_aabb.write[i].size = Vector3(-1, -1, -1); //negative means unused
  527. }
  528. }
  529. PoolVector<Vector3> vertices = p_arrays[VS::ARRAY_VERTEX];
  530. PoolVector<int> bones = p_arrays[VS::ARRAY_BONES];
  531. PoolVector<float> weights = p_arrays[VS::ARRAY_WEIGHTS];
  532. bool any_valid = false;
  533. if (vertices.size() && bones.size() == vertices.size() * 4 && weights.size() == bones.size()) {
  534. int vs = vertices.size();
  535. PoolVector<Vector3>::Read rv = vertices.read();
  536. PoolVector<int>::Read rb = bones.read();
  537. PoolVector<float>::Read rw = weights.read();
  538. AABB *bptr = r_bone_aabb.ptrw();
  539. for (int i = 0; i < vs; i++) {
  540. Vector3 v = rv[i];
  541. for (int j = 0; j < 4; j++) {
  542. int idx = rb[i * 4 + j];
  543. float w = rw[i * 4 + j];
  544. if (w == 0)
  545. continue; //break;
  546. ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA);
  547. if (bptr[idx].size.x < 0) {
  548. //first
  549. bptr[idx] = AABB(v, SMALL_VEC3);
  550. any_valid = true;
  551. } else {
  552. bptr[idx].expand_to(v);
  553. }
  554. }
  555. }
  556. }
  557. if (!any_valid && first) {
  558. r_bone_aabb.clear();
  559. }
  560. }
  561. return OK;
  562. }
  563. uint32_t VisualServer::mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const {
  564. uint32_t offsets[ARRAY_MAX];
  565. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets);
  566. return offsets[p_array_index];
  567. }
  568. uint32_t VisualServer::mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len) const {
  569. uint32_t offsets[ARRAY_MAX];
  570. return mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets);
  571. }
  572. uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const {
  573. int total_elem_size = 0;
  574. for (int i = 0; i < VS::ARRAY_MAX; i++) {
  575. r_offsets[i] = 0; //reset
  576. if (!(p_format & (1 << i))) // no array
  577. continue;
  578. int elem_size = 0;
  579. switch (i) {
  580. case VS::ARRAY_VERTEX: {
  581. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  582. elem_size = 2;
  583. } else {
  584. elem_size = 3;
  585. }
  586. if (p_format & ARRAY_COMPRESS_VERTEX) {
  587. elem_size *= sizeof(int16_t);
  588. } else {
  589. elem_size *= sizeof(float);
  590. }
  591. if (elem_size == 6) {
  592. elem_size = 8;
  593. }
  594. } break;
  595. case VS::ARRAY_NORMAL: {
  596. if (p_format & ARRAY_COMPRESS_NORMAL) {
  597. elem_size = sizeof(uint32_t);
  598. } else {
  599. elem_size = sizeof(float) * 3;
  600. }
  601. } break;
  602. case VS::ARRAY_TANGENT: {
  603. if (p_format & ARRAY_COMPRESS_TANGENT) {
  604. elem_size = sizeof(uint32_t);
  605. } else {
  606. elem_size = sizeof(float) * 4;
  607. }
  608. } break;
  609. case VS::ARRAY_COLOR: {
  610. if (p_format & ARRAY_COMPRESS_COLOR) {
  611. elem_size = sizeof(uint32_t);
  612. } else {
  613. elem_size = sizeof(float) * 4;
  614. }
  615. } break;
  616. case VS::ARRAY_TEX_UV: {
  617. if (p_format & ARRAY_COMPRESS_TEX_UV) {
  618. elem_size = sizeof(uint32_t);
  619. } else {
  620. elem_size = sizeof(float) * 2;
  621. }
  622. } break;
  623. case VS::ARRAY_TEX_UV2: {
  624. if (p_format & ARRAY_COMPRESS_TEX_UV2) {
  625. elem_size = sizeof(uint32_t);
  626. } else {
  627. elem_size = sizeof(float) * 2;
  628. }
  629. } break;
  630. case VS::ARRAY_WEIGHTS: {
  631. if (p_format & ARRAY_COMPRESS_WEIGHTS) {
  632. elem_size = sizeof(uint16_t) * 4;
  633. } else {
  634. elem_size = sizeof(float) * 4;
  635. }
  636. } break;
  637. case VS::ARRAY_BONES: {
  638. if (p_format & ARRAY_FLAG_USE_16_BIT_BONES) {
  639. elem_size = sizeof(uint16_t) * 4;
  640. } else {
  641. elem_size = sizeof(uint32_t);
  642. }
  643. } break;
  644. case VS::ARRAY_INDEX: {
  645. if (p_index_len <= 0) {
  646. ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
  647. break;
  648. }
  649. /* determine whether using 16 or 32 bits indices */
  650. if (p_vertex_len >= (1 << 16)) {
  651. elem_size = 4;
  652. } else {
  653. elem_size = 2;
  654. }
  655. r_offsets[i] = elem_size;
  656. continue;
  657. }
  658. default: {
  659. ERR_FAIL_V(0);
  660. }
  661. }
  662. r_offsets[i] = total_elem_size;
  663. total_elem_size += elem_size;
  664. }
  665. return total_elem_size;
  666. }
  667. void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, uint32_t p_compress_format) {
  668. ERR_FAIL_INDEX(p_primitive, VS::PRIMITIVE_MAX);
  669. ERR_FAIL_COND(p_arrays.size() != VS::ARRAY_MAX);
  670. uint32_t format = 0;
  671. // validation
  672. int index_array_len = 0;
  673. int array_len = 0;
  674. for (int i = 0; i < p_arrays.size(); i++) {
  675. if (p_arrays[i].get_type() == Variant::NIL)
  676. continue;
  677. format |= (1 << i);
  678. if (i == VS::ARRAY_VERTEX) {
  679. Variant var = p_arrays[i];
  680. switch (var.get_type()) {
  681. case Variant::POOL_VECTOR2_ARRAY: {
  682. PoolVector<Vector2> v2 = var;
  683. } break;
  684. case Variant::POOL_VECTOR3_ARRAY: {
  685. PoolVector<Vector3> v3 = var;
  686. } break;
  687. default: {
  688. Array v = var;
  689. } break;
  690. }
  691. array_len = PoolVector3Array(p_arrays[i]).size();
  692. ERR_FAIL_COND(array_len == 0);
  693. } else if (i == VS::ARRAY_INDEX) {
  694. index_array_len = PoolIntArray(p_arrays[i]).size();
  695. }
  696. }
  697. ERR_FAIL_COND((format & VS::ARRAY_FORMAT_VERTEX) == 0); // mandatory
  698. if (p_blend_shapes.size()) {
  699. //validate format for morphs
  700. for (int i = 0; i < p_blend_shapes.size(); i++) {
  701. uint32_t bsformat = 0;
  702. Array arr = p_blend_shapes[i];
  703. for (int j = 0; j < arr.size(); j++) {
  704. if (arr[j].get_type() != Variant::NIL)
  705. bsformat |= (1 << j);
  706. }
  707. ERR_FAIL_COND((bsformat) != (format & (VS::ARRAY_FORMAT_INDEX - 1)));
  708. }
  709. }
  710. uint32_t offsets[VS::ARRAY_MAX];
  711. int total_elem_size = 0;
  712. for (int i = 0; i < VS::ARRAY_MAX; i++) {
  713. offsets[i] = 0; //reset
  714. if (!(format & (1 << i))) // no array
  715. continue;
  716. int elem_size = 0;
  717. switch (i) {
  718. case VS::ARRAY_VERTEX: {
  719. Variant arr = p_arrays[0];
  720. if (arr.get_type() == Variant::POOL_VECTOR2_ARRAY) {
  721. elem_size = 2;
  722. p_compress_format |= ARRAY_FLAG_USE_2D_VERTICES;
  723. } else if (arr.get_type() == Variant::POOL_VECTOR3_ARRAY) {
  724. p_compress_format &= ~ARRAY_FLAG_USE_2D_VERTICES;
  725. elem_size = 3;
  726. } else {
  727. elem_size = (p_compress_format & ARRAY_FLAG_USE_2D_VERTICES) ? 2 : 3;
  728. }
  729. if (p_compress_format & ARRAY_COMPRESS_VERTEX) {
  730. elem_size *= sizeof(int16_t);
  731. } else {
  732. elem_size *= sizeof(float);
  733. }
  734. if (elem_size == 6) {
  735. //had to pad
  736. elem_size = 8;
  737. }
  738. } break;
  739. case VS::ARRAY_NORMAL: {
  740. if (p_compress_format & ARRAY_COMPRESS_NORMAL) {
  741. elem_size = sizeof(uint32_t);
  742. } else {
  743. elem_size = sizeof(float) * 3;
  744. }
  745. } break;
  746. case VS::ARRAY_TANGENT: {
  747. if (p_compress_format & ARRAY_COMPRESS_TANGENT) {
  748. elem_size = sizeof(uint32_t);
  749. } else {
  750. elem_size = sizeof(float) * 4;
  751. }
  752. } break;
  753. case VS::ARRAY_COLOR: {
  754. if (p_compress_format & ARRAY_COMPRESS_COLOR) {
  755. elem_size = sizeof(uint32_t);
  756. } else {
  757. elem_size = sizeof(float) * 4;
  758. }
  759. } break;
  760. case VS::ARRAY_TEX_UV: {
  761. if (p_compress_format & ARRAY_COMPRESS_TEX_UV) {
  762. elem_size = sizeof(uint32_t);
  763. } else {
  764. elem_size = sizeof(float) * 2;
  765. }
  766. } break;
  767. case VS::ARRAY_TEX_UV2: {
  768. if (p_compress_format & ARRAY_COMPRESS_TEX_UV2) {
  769. elem_size = sizeof(uint32_t);
  770. } else {
  771. elem_size = sizeof(float) * 2;
  772. }
  773. } break;
  774. case VS::ARRAY_WEIGHTS: {
  775. if (p_compress_format & ARRAY_COMPRESS_WEIGHTS) {
  776. elem_size = sizeof(uint16_t) * 4;
  777. } else {
  778. elem_size = sizeof(float) * 4;
  779. }
  780. } break;
  781. case VS::ARRAY_BONES: {
  782. PoolVector<int> bones = p_arrays[VS::ARRAY_BONES];
  783. int max_bone = 0;
  784. {
  785. int bc = bones.size();
  786. PoolVector<int>::Read r = bones.read();
  787. for (int j = 0; j < bc; j++) {
  788. max_bone = MAX(r[j], max_bone);
  789. }
  790. }
  791. if (max_bone > 255) {
  792. p_compress_format |= ARRAY_FLAG_USE_16_BIT_BONES;
  793. elem_size = sizeof(uint16_t) * 4;
  794. } else {
  795. p_compress_format &= ~ARRAY_FLAG_USE_16_BIT_BONES;
  796. elem_size = sizeof(uint32_t);
  797. }
  798. } break;
  799. case VS::ARRAY_INDEX: {
  800. if (index_array_len <= 0) {
  801. ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
  802. break;
  803. }
  804. /* determine whether using 16 or 32 bits indices */
  805. if (array_len >= (1 << 16)) {
  806. elem_size = 4;
  807. } else {
  808. elem_size = 2;
  809. }
  810. offsets[i] = elem_size;
  811. continue;
  812. }
  813. default: {
  814. ERR_FAIL();
  815. }
  816. }
  817. offsets[i] = total_elem_size;
  818. total_elem_size += elem_size;
  819. }
  820. uint32_t mask = (1 << ARRAY_MAX) - 1;
  821. format |= (~mask) & p_compress_format; //make the full format
  822. int array_size = total_elem_size * array_len;
  823. PoolVector<uint8_t> vertex_array;
  824. vertex_array.resize(array_size);
  825. int index_array_size = offsets[VS::ARRAY_INDEX] * index_array_len;
  826. PoolVector<uint8_t> index_array;
  827. index_array.resize(index_array_size);
  828. AABB aabb;
  829. Vector<AABB> bone_aabb;
  830. Error err = _surface_set_data(p_arrays, format, offsets, total_elem_size, vertex_array, array_len, index_array, index_array_len, aabb, bone_aabb);
  831. ERR_FAIL_COND_MSG(err, "Invalid array format for surface.");
  832. Vector<PoolVector<uint8_t> > blend_shape_data;
  833. for (int i = 0; i < p_blend_shapes.size(); i++) {
  834. PoolVector<uint8_t> vertex_array_shape;
  835. vertex_array_shape.resize(array_size);
  836. PoolVector<uint8_t> noindex;
  837. AABB laabb;
  838. Error err2 = _surface_set_data(p_blend_shapes[i], format & ~ARRAY_FORMAT_INDEX, offsets, total_elem_size, vertex_array_shape, array_len, noindex, 0, laabb, bone_aabb);
  839. aabb.merge_with(laabb);
  840. ERR_FAIL_COND_MSG(err2 != OK, "Invalid blend shape array format for surface.");
  841. blend_shape_data.push_back(vertex_array_shape);
  842. }
  843. mesh_add_surface(p_mesh, format, p_primitive, vertex_array, array_len, index_array, index_array_len, aabb, blend_shape_data, bone_aabb);
  844. }
  845. Array VisualServer::_get_array_from_surface(uint32_t p_format, PoolVector<uint8_t> p_vertex_data, int p_vertex_len, PoolVector<uint8_t> p_index_data, int p_index_len) const {
  846. uint32_t offsets[ARRAY_MAX];
  847. int total_elem_size = 0;
  848. for (int i = 0; i < VS::ARRAY_MAX; i++) {
  849. offsets[i] = 0; //reset
  850. if (!(p_format & (1 << i))) // no array
  851. continue;
  852. int elem_size = 0;
  853. switch (i) {
  854. case VS::ARRAY_VERTEX: {
  855. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  856. elem_size = 2;
  857. } else {
  858. elem_size = 3;
  859. }
  860. if (p_format & ARRAY_COMPRESS_VERTEX) {
  861. elem_size *= sizeof(int16_t);
  862. } else {
  863. elem_size *= sizeof(float);
  864. }
  865. if (elem_size == 6) {
  866. elem_size = 8;
  867. }
  868. } break;
  869. case VS::ARRAY_NORMAL: {
  870. if (p_format & ARRAY_COMPRESS_NORMAL) {
  871. elem_size = sizeof(uint32_t);
  872. } else {
  873. elem_size = sizeof(float) * 3;
  874. }
  875. } break;
  876. case VS::ARRAY_TANGENT: {
  877. if (p_format & ARRAY_COMPRESS_TANGENT) {
  878. elem_size = sizeof(uint32_t);
  879. } else {
  880. elem_size = sizeof(float) * 4;
  881. }
  882. } break;
  883. case VS::ARRAY_COLOR: {
  884. if (p_format & ARRAY_COMPRESS_COLOR) {
  885. elem_size = sizeof(uint32_t);
  886. } else {
  887. elem_size = sizeof(float) * 4;
  888. }
  889. } break;
  890. case VS::ARRAY_TEX_UV: {
  891. if (p_format & ARRAY_COMPRESS_TEX_UV) {
  892. elem_size = sizeof(uint32_t);
  893. } else {
  894. elem_size = sizeof(float) * 2;
  895. }
  896. } break;
  897. case VS::ARRAY_TEX_UV2: {
  898. if (p_format & ARRAY_COMPRESS_TEX_UV2) {
  899. elem_size = sizeof(uint32_t);
  900. } else {
  901. elem_size = sizeof(float) * 2;
  902. }
  903. } break;
  904. case VS::ARRAY_WEIGHTS: {
  905. if (p_format & ARRAY_COMPRESS_WEIGHTS) {
  906. elem_size = sizeof(uint16_t) * 4;
  907. } else {
  908. elem_size = sizeof(float) * 4;
  909. }
  910. } break;
  911. case VS::ARRAY_BONES: {
  912. if (p_format & ARRAY_FLAG_USE_16_BIT_BONES) {
  913. elem_size = sizeof(uint16_t) * 4;
  914. } else {
  915. elem_size = sizeof(uint32_t);
  916. }
  917. } break;
  918. case VS::ARRAY_INDEX: {
  919. if (p_index_len <= 0) {
  920. ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
  921. break;
  922. }
  923. /* determine whether using 16 or 32 bits indices */
  924. if (p_vertex_len >= (1 << 16)) {
  925. elem_size = 4;
  926. } else {
  927. elem_size = 2;
  928. }
  929. offsets[i] = elem_size;
  930. continue;
  931. }
  932. default: {
  933. ERR_FAIL_V(Array());
  934. }
  935. }
  936. offsets[i] = total_elem_size;
  937. total_elem_size += elem_size;
  938. }
  939. Array ret;
  940. ret.resize(VS::ARRAY_MAX);
  941. PoolVector<uint8_t>::Read r = p_vertex_data.read();
  942. for (int i = 0; i < VS::ARRAY_MAX; i++) {
  943. if (!(p_format & (1 << i)))
  944. continue;
  945. switch (i) {
  946. case VS::ARRAY_VERTEX: {
  947. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  948. PoolVector<Vector2> arr_2d;
  949. arr_2d.resize(p_vertex_len);
  950. if (p_format & ARRAY_COMPRESS_VERTEX) {
  951. PoolVector<Vector2>::Write w = arr_2d.write();
  952. for (int j = 0; j < p_vertex_len; j++) {
  953. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  954. w[j] = Vector2(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]));
  955. }
  956. } else {
  957. PoolVector<Vector2>::Write w = arr_2d.write();
  958. for (int j = 0; j < p_vertex_len; j++) {
  959. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  960. w[j] = Vector2(v[0], v[1]);
  961. }
  962. }
  963. ret[i] = arr_2d;
  964. } else {
  965. PoolVector<Vector3> arr_3d;
  966. arr_3d.resize(p_vertex_len);
  967. if (p_format & ARRAY_COMPRESS_VERTEX) {
  968. PoolVector<Vector3>::Write w = arr_3d.write();
  969. for (int j = 0; j < p_vertex_len; j++) {
  970. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  971. w[j] = Vector3(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]), Math::halfptr_to_float(&v[2]));
  972. }
  973. } else {
  974. PoolVector<Vector3>::Write w = arr_3d.write();
  975. for (int j = 0; j < p_vertex_len; j++) {
  976. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  977. w[j] = Vector3(v[0], v[1], v[2]);
  978. }
  979. }
  980. ret[i] = arr_3d;
  981. }
  982. } break;
  983. case VS::ARRAY_NORMAL: {
  984. PoolVector<Vector3> arr;
  985. arr.resize(p_vertex_len);
  986. if (p_format & ARRAY_COMPRESS_NORMAL) {
  987. PoolVector<Vector3>::Write w = arr.write();
  988. const float multiplier = 1.f / 127.f;
  989. for (int j = 0; j < p_vertex_len; j++) {
  990. const int8_t *v = (const int8_t *)&r[j * total_elem_size + offsets[i]];
  991. w[j] = Vector3(float(v[0]) * multiplier, float(v[1]) * multiplier, float(v[2]) * multiplier);
  992. }
  993. } else {
  994. PoolVector<Vector3>::Write w = arr.write();
  995. for (int j = 0; j < p_vertex_len; j++) {
  996. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  997. w[j] = Vector3(v[0], v[1], v[2]);
  998. }
  999. }
  1000. ret[i] = arr;
  1001. } break;
  1002. case VS::ARRAY_TANGENT: {
  1003. PoolVector<float> arr;
  1004. arr.resize(p_vertex_len * 4);
  1005. if (p_format & ARRAY_COMPRESS_TANGENT) {
  1006. PoolVector<float>::Write w = arr.write();
  1007. for (int j = 0; j < p_vertex_len; j++) {
  1008. const int8_t *v = (const int8_t *)&r[j * total_elem_size + offsets[i]];
  1009. for (int k = 0; k < 4; k++) {
  1010. w[j * 4 + k] = float(v[k] / 127.0);
  1011. }
  1012. }
  1013. } else {
  1014. PoolVector<float>::Write w = arr.write();
  1015. for (int j = 0; j < p_vertex_len; j++) {
  1016. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1017. for (int k = 0; k < 4; k++) {
  1018. w[j * 4 + k] = v[k];
  1019. }
  1020. }
  1021. }
  1022. ret[i] = arr;
  1023. } break;
  1024. case VS::ARRAY_COLOR: {
  1025. PoolVector<Color> arr;
  1026. arr.resize(p_vertex_len);
  1027. if (p_format & ARRAY_COMPRESS_COLOR) {
  1028. PoolVector<Color>::Write w = arr.write();
  1029. for (int j = 0; j < p_vertex_len; j++) {
  1030. const uint8_t *v = (const uint8_t *)&r[j * total_elem_size + offsets[i]];
  1031. w[j] = Color(float(v[0] / 255.0), float(v[1] / 255.0), float(v[2] / 255.0), float(v[3] / 255.0));
  1032. }
  1033. } else {
  1034. PoolVector<Color>::Write w = arr.write();
  1035. for (int j = 0; j < p_vertex_len; j++) {
  1036. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1037. w[j] = Color(v[0], v[1], v[2], v[3]);
  1038. }
  1039. }
  1040. ret[i] = arr;
  1041. } break;
  1042. case VS::ARRAY_TEX_UV: {
  1043. PoolVector<Vector2> arr;
  1044. arr.resize(p_vertex_len);
  1045. if (p_format & ARRAY_COMPRESS_TEX_UV) {
  1046. PoolVector<Vector2>::Write w = arr.write();
  1047. for (int j = 0; j < p_vertex_len; j++) {
  1048. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  1049. w[j] = Vector2(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]));
  1050. }
  1051. } else {
  1052. PoolVector<Vector2>::Write w = arr.write();
  1053. for (int j = 0; j < p_vertex_len; j++) {
  1054. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1055. w[j] = Vector2(v[0], v[1]);
  1056. }
  1057. }
  1058. ret[i] = arr;
  1059. } break;
  1060. case VS::ARRAY_TEX_UV2: {
  1061. PoolVector<Vector2> arr;
  1062. arr.resize(p_vertex_len);
  1063. if (p_format & ARRAY_COMPRESS_TEX_UV2) {
  1064. PoolVector<Vector2>::Write w = arr.write();
  1065. for (int j = 0; j < p_vertex_len; j++) {
  1066. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  1067. w[j] = Vector2(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]));
  1068. }
  1069. } else {
  1070. PoolVector<Vector2>::Write w = arr.write();
  1071. for (int j = 0; j < p_vertex_len; j++) {
  1072. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1073. w[j] = Vector2(v[0], v[1]);
  1074. }
  1075. }
  1076. ret[i] = arr;
  1077. } break;
  1078. case VS::ARRAY_WEIGHTS: {
  1079. PoolVector<float> arr;
  1080. arr.resize(p_vertex_len * 4);
  1081. if (p_format & ARRAY_COMPRESS_WEIGHTS) {
  1082. PoolVector<float>::Write w = arr.write();
  1083. for (int j = 0; j < p_vertex_len; j++) {
  1084. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  1085. for (int k = 0; k < 4; k++) {
  1086. w[j * 4 + k] = float(v[k] / 65535.0);
  1087. }
  1088. }
  1089. } else {
  1090. PoolVector<float>::Write w = arr.write();
  1091. for (int j = 0; j < p_vertex_len; j++) {
  1092. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1093. for (int k = 0; k < 4; k++) {
  1094. w[j * 4 + k] = v[k];
  1095. }
  1096. }
  1097. }
  1098. ret[i] = arr;
  1099. } break;
  1100. case VS::ARRAY_BONES: {
  1101. PoolVector<int> arr;
  1102. arr.resize(p_vertex_len * 4);
  1103. if (p_format & ARRAY_FLAG_USE_16_BIT_BONES) {
  1104. PoolVector<int>::Write w = arr.write();
  1105. for (int j = 0; j < p_vertex_len; j++) {
  1106. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  1107. for (int k = 0; k < 4; k++) {
  1108. w[j * 4 + k] = v[k];
  1109. }
  1110. }
  1111. } else {
  1112. PoolVector<int>::Write w = arr.write();
  1113. for (int j = 0; j < p_vertex_len; j++) {
  1114. const uint8_t *v = (const uint8_t *)&r[j * total_elem_size + offsets[i]];
  1115. for (int k = 0; k < 4; k++) {
  1116. w[j * 4 + k] = v[k];
  1117. }
  1118. }
  1119. }
  1120. ret[i] = arr;
  1121. } break;
  1122. case VS::ARRAY_INDEX: {
  1123. /* determine whether using 16 or 32 bits indices */
  1124. PoolVector<uint8_t>::Read ir = p_index_data.read();
  1125. PoolVector<int> arr;
  1126. arr.resize(p_index_len);
  1127. if (p_vertex_len < (1 << 16)) {
  1128. PoolVector<int>::Write w = arr.write();
  1129. for (int j = 0; j < p_index_len; j++) {
  1130. const uint16_t *v = (const uint16_t *)&ir[j * 2];
  1131. w[j] = *v;
  1132. }
  1133. } else {
  1134. PoolVector<int>::Write w = arr.write();
  1135. for (int j = 0; j < p_index_len; j++) {
  1136. const int *v = (const int *)&ir[j * 4];
  1137. w[j] = *v;
  1138. }
  1139. }
  1140. ret[i] = arr;
  1141. } break;
  1142. default: {
  1143. ERR_FAIL_V(ret);
  1144. }
  1145. }
  1146. }
  1147. return ret;
  1148. }
  1149. Array VisualServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
  1150. PoolVector<uint8_t> vertex_data = mesh_surface_get_array(p_mesh, p_surface);
  1151. ERR_FAIL_COND_V(vertex_data.size() == 0, Array());
  1152. int vertex_len = mesh_surface_get_array_len(p_mesh, p_surface);
  1153. PoolVector<uint8_t> index_data = mesh_surface_get_index_array(p_mesh, p_surface);
  1154. int index_len = mesh_surface_get_array_index_len(p_mesh, p_surface);
  1155. uint32_t format = mesh_surface_get_format(p_mesh, p_surface);
  1156. return _get_array_from_surface(format, vertex_data, vertex_len, index_data, index_len);
  1157. }
  1158. Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
  1159. Vector<PoolVector<uint8_t> > blend_shape_data = mesh_surface_get_blend_shapes(p_mesh, p_surface);
  1160. if (blend_shape_data.size() > 0) {
  1161. int vertex_len = mesh_surface_get_array_len(p_mesh, p_surface);
  1162. PoolVector<uint8_t> index_data = mesh_surface_get_index_array(p_mesh, p_surface);
  1163. int index_len = mesh_surface_get_array_index_len(p_mesh, p_surface);
  1164. uint32_t format = mesh_surface_get_format(p_mesh, p_surface);
  1165. Array blend_shape_array;
  1166. blend_shape_array.resize(blend_shape_data.size());
  1167. for (int i = 0; i < blend_shape_data.size(); i++) {
  1168. blend_shape_array.set(i, _get_array_from_surface(format, blend_shape_data[i], vertex_len, index_data, index_len));
  1169. }
  1170. return blend_shape_array;
  1171. } else {
  1172. return Array();
  1173. }
  1174. }
  1175. Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {
  1176. Vector<AABB> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);
  1177. Array arr;
  1178. for (int i = 0; i < vec.size(); i++) {
  1179. arr[i] = vec[i];
  1180. }
  1181. return arr;
  1182. }
  1183. void VisualServer::_bind_methods() {
  1184. ClassDB::bind_method(D_METHOD("force_sync"), &VisualServer::sync);
  1185. ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0));
  1186. // "draw" and "sync" are deprecated duplicates of "force_draw" and "force_sync"
  1187. // FIXME: Add deprecation messages using GH-4397 once available, and retire
  1188. // once the warnings have been enabled for a full release cycle
  1189. ClassDB::bind_method(D_METHOD("sync"), &VisualServer::sync);
  1190. ClassDB::bind_method(D_METHOD("draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0));
  1191. ClassDB::bind_method(D_METHOD("texture_create"), &VisualServer::texture_create);
  1192. ClassDB::bind_method(D_METHOD("texture_create_from_image", "image", "flags"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT));
  1193. ClassDB::bind_method(D_METHOD("texture_allocate", "texture", "width", "height", "depth_3d", "format", "type", "flags"), &VisualServer::texture_allocate, DEFVAL(TEXTURE_FLAGS_DEFAULT));
  1194. ClassDB::bind_method(D_METHOD("texture_set_data", "texture", "image", "layer"), &VisualServer::texture_set_data, DEFVAL(0));
  1195. ClassDB::bind_method(D_METHOD("texture_set_data_partial", "texture", "image", "src_x", "src_y", "src_w", "src_h", "dst_x", "dst_y", "dst_mip", "layer"), &VisualServer::texture_set_data_partial, DEFVAL(0));
  1196. ClassDB::bind_method(D_METHOD("texture_get_data", "texture", "cube_side"), &VisualServer::texture_get_data, DEFVAL(CUBEMAP_LEFT));
  1197. ClassDB::bind_method(D_METHOD("texture_set_flags", "texture", "flags"), &VisualServer::texture_set_flags);
  1198. ClassDB::bind_method(D_METHOD("texture_get_flags", "texture"), &VisualServer::texture_get_flags);
  1199. ClassDB::bind_method(D_METHOD("texture_get_format", "texture"), &VisualServer::texture_get_format);
  1200. ClassDB::bind_method(D_METHOD("texture_get_type", "texture"), &VisualServer::texture_get_type);
  1201. ClassDB::bind_method(D_METHOD("texture_get_texid", "texture"), &VisualServer::texture_get_texid);
  1202. ClassDB::bind_method(D_METHOD("texture_get_width", "texture"), &VisualServer::texture_get_width);
  1203. ClassDB::bind_method(D_METHOD("texture_get_height", "texture"), &VisualServer::texture_get_height);
  1204. ClassDB::bind_method(D_METHOD("texture_get_depth", "texture"), &VisualServer::texture_get_depth);
  1205. ClassDB::bind_method(D_METHOD("texture_set_size_override", "texture", "width", "height", "depth"), &VisualServer::texture_set_size_override);
  1206. ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &VisualServer::texture_set_path);
  1207. ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &VisualServer::texture_get_path);
  1208. ClassDB::bind_method(D_METHOD("texture_set_shrink_all_x2_on_set_data", "shrink"), &VisualServer::texture_set_shrink_all_x2_on_set_data);
  1209. ClassDB::bind_method(D_METHOD("texture_bind", "texture", "number"), &VisualServer::texture_bind);
  1210. ClassDB::bind_method(D_METHOD("texture_debug_usage"), &VisualServer::_texture_debug_usage_bind);
  1211. ClassDB::bind_method(D_METHOD("textures_keep_original", "enable"), &VisualServer::textures_keep_original);
  1212. #ifndef _3D_DISABLED
  1213. ClassDB::bind_method(D_METHOD("sky_create"), &VisualServer::sky_create);
  1214. ClassDB::bind_method(D_METHOD("sky_set_texture", "sky", "cube_map", "radiance_size"), &VisualServer::sky_set_texture);
  1215. #endif
  1216. ClassDB::bind_method(D_METHOD("shader_create"), &VisualServer::shader_create);
  1217. ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &VisualServer::shader_set_code);
  1218. ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &VisualServer::shader_get_code);
  1219. ClassDB::bind_method(D_METHOD("shader_get_param_list", "shader"), &VisualServer::_shader_get_param_list_bind);
  1220. ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "name", "texture"), &VisualServer::shader_set_default_texture_param);
  1221. ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "name"), &VisualServer::shader_get_default_texture_param);
  1222. ClassDB::bind_method(D_METHOD("material_create"), &VisualServer::material_create);
  1223. ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &VisualServer::material_set_shader);
  1224. ClassDB::bind_method(D_METHOD("material_get_shader", "shader_material"), &VisualServer::material_get_shader);
  1225. ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &VisualServer::material_set_param);
  1226. ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &VisualServer::material_get_param);
  1227. ClassDB::bind_method(D_METHOD("material_get_param_default", "material", "parameter"), &VisualServer::material_get_param_default);
  1228. ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &VisualServer::material_set_render_priority);
  1229. ClassDB::bind_method(D_METHOD("material_set_line_width", "material", "width"), &VisualServer::material_set_line_width);
  1230. ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &VisualServer::material_set_next_pass);
  1231. ClassDB::bind_method(D_METHOD("mesh_create"), &VisualServer::mesh_create);
  1232. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_len", "index_len", "array_index"), &VisualServer::mesh_surface_get_format_offset);
  1233. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_stride", "format", "vertex_len", "index_len"), &VisualServer::mesh_surface_get_format_stride);
  1234. ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primitive", "arrays", "blend_shapes", "compress_format"), &VisualServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(ARRAY_COMPRESS_DEFAULT));
  1235. ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_count", "mesh", "amount"), &VisualServer::mesh_set_blend_shape_count);
  1236. ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count);
  1237. ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode);
  1238. ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode);
  1239. ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &VisualServer::mesh_surface_update_region);
  1240. ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material);
  1241. ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material);
  1242. ClassDB::bind_method(D_METHOD("mesh_surface_get_array_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_len);
  1243. ClassDB::bind_method(D_METHOD("mesh_surface_get_array_index_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_index_len);
  1244. ClassDB::bind_method(D_METHOD("mesh_surface_get_array", "mesh", "surface"), &VisualServer::mesh_surface_get_array);
  1245. ClassDB::bind_method(D_METHOD("mesh_surface_get_index_array", "mesh", "surface"), &VisualServer::mesh_surface_get_index_array);
  1246. ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_arrays);
  1247. ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_blend_shape_arrays);
  1248. ClassDB::bind_method(D_METHOD("mesh_surface_get_format", "mesh", "surface"), &VisualServer::mesh_surface_get_format);
  1249. ClassDB::bind_method(D_METHOD("mesh_surface_get_primitive_type", "mesh", "surface"), &VisualServer::mesh_surface_get_primitive_type);
  1250. ClassDB::bind_method(D_METHOD("mesh_surface_get_aabb", "mesh", "surface"), &VisualServer::mesh_surface_get_aabb);
  1251. ClassDB::bind_method(D_METHOD("mesh_surface_get_skeleton_aabb", "mesh", "surface"), &VisualServer::_mesh_surface_get_skeleton_aabb_bind);
  1252. ClassDB::bind_method(D_METHOD("mesh_remove_surface", "mesh", "index"), &VisualServer::mesh_remove_surface);
  1253. ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &VisualServer::mesh_get_surface_count);
  1254. ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &VisualServer::mesh_set_custom_aabb);
  1255. ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &VisualServer::mesh_get_custom_aabb);
  1256. ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &VisualServer::mesh_clear);
  1257. ClassDB::bind_method(D_METHOD("multimesh_create"), &VisualServer::multimesh_create);
  1258. ClassDB::bind_method(D_METHOD("multimesh_allocate", "multimesh", "instances", "transform_format", "color_format", "custom_data_format"), &VisualServer::multimesh_allocate, DEFVAL(MULTIMESH_CUSTOM_DATA_NONE));
  1259. ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &VisualServer::multimesh_get_instance_count);
  1260. ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &VisualServer::multimesh_set_mesh);
  1261. ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &VisualServer::multimesh_instance_set_transform);
  1262. ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &VisualServer::multimesh_instance_set_transform_2d);
  1263. ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &VisualServer::multimesh_instance_set_color);
  1264. ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &VisualServer::multimesh_instance_set_custom_data);
  1265. ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &VisualServer::multimesh_get_mesh);
  1266. ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &VisualServer::multimesh_get_aabb);
  1267. ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &VisualServer::multimesh_instance_get_transform);
  1268. ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &VisualServer::multimesh_instance_get_transform_2d);
  1269. ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &VisualServer::multimesh_instance_get_color);
  1270. ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &VisualServer::multimesh_instance_get_custom_data);
  1271. ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &VisualServer::multimesh_set_visible_instances);
  1272. ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &VisualServer::multimesh_get_visible_instances);
  1273. ClassDB::bind_method(D_METHOD("multimesh_set_as_bulk_array", "multimesh", "array"), &VisualServer::multimesh_set_as_bulk_array);
  1274. #ifndef _3D_DISABLED
  1275. ClassDB::bind_method(D_METHOD("immediate_create"), &VisualServer::immediate_create);
  1276. ClassDB::bind_method(D_METHOD("immediate_begin", "immediate", "primitive", "texture"), &VisualServer::immediate_begin, DEFVAL(RID()));
  1277. ClassDB::bind_method(D_METHOD("immediate_vertex", "immediate", "vertex"), &VisualServer::immediate_vertex);
  1278. ClassDB::bind_method(D_METHOD("immediate_vertex_2d", "immediate", "vertex"), &VisualServer::immediate_vertex_2d);
  1279. ClassDB::bind_method(D_METHOD("immediate_normal", "immediate", "normal"), &VisualServer::immediate_normal);
  1280. ClassDB::bind_method(D_METHOD("immediate_tangent", "immediate", "tangent"), &VisualServer::immediate_tangent);
  1281. ClassDB::bind_method(D_METHOD("immediate_color", "immediate", "color"), &VisualServer::immediate_color);
  1282. ClassDB::bind_method(D_METHOD("immediate_uv", "immediate", "tex_uv"), &VisualServer::immediate_uv);
  1283. ClassDB::bind_method(D_METHOD("immediate_uv2", "immediate", "tex_uv"), &VisualServer::immediate_uv2);
  1284. ClassDB::bind_method(D_METHOD("immediate_end", "immediate"), &VisualServer::immediate_end);
  1285. ClassDB::bind_method(D_METHOD("immediate_clear", "immediate"), &VisualServer::immediate_clear);
  1286. ClassDB::bind_method(D_METHOD("immediate_set_material", "immediate", "material"), &VisualServer::immediate_set_material);
  1287. ClassDB::bind_method(D_METHOD("immediate_get_material", "immediate"), &VisualServer::immediate_get_material);
  1288. #endif
  1289. ClassDB::bind_method(D_METHOD("skeleton_create"), &VisualServer::skeleton_create);
  1290. ClassDB::bind_method(D_METHOD("skeleton_allocate", "skeleton", "bones", "is_2d_skeleton"), &VisualServer::skeleton_allocate, DEFVAL(false));
  1291. ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &VisualServer::skeleton_get_bone_count);
  1292. ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform);
  1293. ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform);
  1294. ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform_2d);
  1295. ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform_2d);
  1296. #ifndef _3D_DISABLED
  1297. ClassDB::bind_method(D_METHOD("directional_light_create"), &VisualServer::directional_light_create);
  1298. ClassDB::bind_method(D_METHOD("omni_light_create"), &VisualServer::omni_light_create);
  1299. ClassDB::bind_method(D_METHOD("spot_light_create"), &VisualServer::spot_light_create);
  1300. ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &VisualServer::light_set_color);
  1301. ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &VisualServer::light_set_param);
  1302. ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &VisualServer::light_set_shadow);
  1303. ClassDB::bind_method(D_METHOD("light_set_shadow_color", "light", "color"), &VisualServer::light_set_shadow_color);
  1304. ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &VisualServer::light_set_projector);
  1305. ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &VisualServer::light_set_negative);
  1306. ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &VisualServer::light_set_cull_mask);
  1307. ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &VisualServer::light_set_reverse_cull_face_mode);
  1308. ClassDB::bind_method(D_METHOD("light_set_use_gi", "light", "enabled"), &VisualServer::light_set_use_gi);
  1309. ClassDB::bind_method(D_METHOD("light_set_bake_mode", "light", "bake_mode"), &VisualServer::light_set_bake_mode);
  1310. ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &VisualServer::light_omni_set_shadow_mode);
  1311. ClassDB::bind_method(D_METHOD("light_omni_set_shadow_detail", "light", "detail"), &VisualServer::light_omni_set_shadow_detail);
  1312. ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &VisualServer::light_directional_set_shadow_mode);
  1313. ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &VisualServer::light_directional_set_blend_splits);
  1314. ClassDB::bind_method(D_METHOD("light_directional_set_shadow_depth_range_mode", "light", "range_mode"), &VisualServer::light_directional_set_shadow_depth_range_mode);
  1315. ClassDB::bind_method(D_METHOD("reflection_probe_create"), &VisualServer::reflection_probe_create);
  1316. ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &VisualServer::reflection_probe_set_update_mode);
  1317. ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &VisualServer::reflection_probe_set_intensity);
  1318. ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient", "probe", "color"), &VisualServer::reflection_probe_set_interior_ambient);
  1319. ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_energy", "probe", "energy"), &VisualServer::reflection_probe_set_interior_ambient_energy);
  1320. ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_probe_contribution", "probe", "contrib"), &VisualServer::reflection_probe_set_interior_ambient_probe_contribution);
  1321. ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &VisualServer::reflection_probe_set_max_distance);
  1322. ClassDB::bind_method(D_METHOD("reflection_probe_set_extents", "probe", "extents"), &VisualServer::reflection_probe_set_extents);
  1323. ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &VisualServer::reflection_probe_set_origin_offset);
  1324. ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &VisualServer::reflection_probe_set_as_interior);
  1325. ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &VisualServer::reflection_probe_set_enable_box_projection);
  1326. ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &VisualServer::reflection_probe_set_enable_shadows);
  1327. ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &VisualServer::reflection_probe_set_cull_mask);
  1328. ClassDB::bind_method(D_METHOD("gi_probe_create"), &VisualServer::gi_probe_create);
  1329. ClassDB::bind_method(D_METHOD("gi_probe_set_bounds", "probe", "bounds"), &VisualServer::gi_probe_set_bounds);
  1330. ClassDB::bind_method(D_METHOD("gi_probe_get_bounds", "probe"), &VisualServer::gi_probe_get_bounds);
  1331. ClassDB::bind_method(D_METHOD("gi_probe_set_cell_size", "probe", "range"), &VisualServer::gi_probe_set_cell_size);
  1332. ClassDB::bind_method(D_METHOD("gi_probe_get_cell_size", "probe"), &VisualServer::gi_probe_get_cell_size);
  1333. ClassDB::bind_method(D_METHOD("gi_probe_set_to_cell_xform", "probe", "xform"), &VisualServer::gi_probe_set_to_cell_xform);
  1334. ClassDB::bind_method(D_METHOD("gi_probe_get_to_cell_xform", "probe"), &VisualServer::gi_probe_get_to_cell_xform);
  1335. ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_data", "probe", "data"), &VisualServer::gi_probe_set_dynamic_data);
  1336. ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_data", "probe"), &VisualServer::gi_probe_get_dynamic_data);
  1337. ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_range", "probe", "range"), &VisualServer::gi_probe_set_dynamic_range);
  1338. ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_range", "probe"), &VisualServer::gi_probe_get_dynamic_range);
  1339. ClassDB::bind_method(D_METHOD("gi_probe_set_energy", "probe", "energy"), &VisualServer::gi_probe_set_energy);
  1340. ClassDB::bind_method(D_METHOD("gi_probe_get_energy", "probe"), &VisualServer::gi_probe_get_energy);
  1341. ClassDB::bind_method(D_METHOD("gi_probe_set_bias", "probe", "bias"), &VisualServer::gi_probe_set_bias);
  1342. ClassDB::bind_method(D_METHOD("gi_probe_get_bias", "probe"), &VisualServer::gi_probe_get_bias);
  1343. ClassDB::bind_method(D_METHOD("gi_probe_set_normal_bias", "probe", "bias"), &VisualServer::gi_probe_set_normal_bias);
  1344. ClassDB::bind_method(D_METHOD("gi_probe_get_normal_bias", "probe"), &VisualServer::gi_probe_get_normal_bias);
  1345. ClassDB::bind_method(D_METHOD("gi_probe_set_propagation", "probe", "propagation"), &VisualServer::gi_probe_set_propagation);
  1346. ClassDB::bind_method(D_METHOD("gi_probe_get_propagation", "probe"), &VisualServer::gi_probe_get_propagation);
  1347. ClassDB::bind_method(D_METHOD("gi_probe_set_interior", "probe", "enable"), &VisualServer::gi_probe_set_interior);
  1348. ClassDB::bind_method(D_METHOD("gi_probe_is_interior", "probe"), &VisualServer::gi_probe_is_interior);
  1349. ClassDB::bind_method(D_METHOD("gi_probe_set_compress", "probe", "enable"), &VisualServer::gi_probe_set_compress);
  1350. ClassDB::bind_method(D_METHOD("gi_probe_is_compressed", "probe"), &VisualServer::gi_probe_is_compressed);
  1351. ClassDB::bind_method(D_METHOD("lightmap_capture_create"), &VisualServer::lightmap_capture_create);
  1352. ClassDB::bind_method(D_METHOD("lightmap_capture_set_bounds", "capture", "bounds"), &VisualServer::lightmap_capture_set_bounds);
  1353. ClassDB::bind_method(D_METHOD("lightmap_capture_get_bounds", "capture"), &VisualServer::lightmap_capture_get_bounds);
  1354. ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree", "capture", "octree"), &VisualServer::lightmap_capture_set_octree);
  1355. ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_transform", "capture", "xform"), &VisualServer::lightmap_capture_set_octree_cell_transform);
  1356. ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_transform", "capture"), &VisualServer::lightmap_capture_get_octree_cell_transform);
  1357. ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_subdiv", "capture", "subdiv"), &VisualServer::lightmap_capture_set_octree_cell_subdiv);
  1358. ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_subdiv", "capture"), &VisualServer::lightmap_capture_get_octree_cell_subdiv);
  1359. ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree", "capture"), &VisualServer::lightmap_capture_get_octree);
  1360. ClassDB::bind_method(D_METHOD("lightmap_capture_set_energy", "capture", "energy"), &VisualServer::lightmap_capture_set_energy);
  1361. ClassDB::bind_method(D_METHOD("lightmap_capture_get_energy", "capture"), &VisualServer::lightmap_capture_get_energy);
  1362. ClassDB::bind_method(D_METHOD("lightmap_capture_set_interior", "capture", "interior"), &VisualServer::lightmap_capture_set_interior);
  1363. ClassDB::bind_method(D_METHOD("lightmap_capture_is_interior", "capture"), &VisualServer::lightmap_capture_is_interior);
  1364. #endif
  1365. ClassDB::bind_method(D_METHOD("particles_create"), &VisualServer::particles_create);
  1366. ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &VisualServer::particles_set_emitting);
  1367. ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &VisualServer::particles_get_emitting);
  1368. ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &VisualServer::particles_set_amount);
  1369. ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &VisualServer::particles_set_lifetime);
  1370. ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &VisualServer::particles_set_one_shot);
  1371. ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &VisualServer::particles_set_pre_process_time);
  1372. ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &VisualServer::particles_set_explosiveness_ratio);
  1373. ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &VisualServer::particles_set_randomness_ratio);
  1374. ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &VisualServer::particles_set_custom_aabb);
  1375. ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &VisualServer::particles_set_speed_scale);
  1376. ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &VisualServer::particles_set_use_local_coordinates);
  1377. ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &VisualServer::particles_set_process_material);
  1378. ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &VisualServer::particles_set_fixed_fps);
  1379. ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &VisualServer::particles_set_fractional_delta);
  1380. ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &VisualServer::particles_is_inactive);
  1381. ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &VisualServer::particles_request_process);
  1382. ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &VisualServer::particles_restart);
  1383. ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &VisualServer::particles_set_draw_order);
  1384. ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &VisualServer::particles_set_draw_passes);
  1385. ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &VisualServer::particles_set_draw_pass_mesh);
  1386. ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &VisualServer::particles_get_current_aabb);
  1387. ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &VisualServer::particles_set_emission_transform);
  1388. ClassDB::bind_method(D_METHOD("camera_create"), &VisualServer::camera_create);
  1389. ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &VisualServer::camera_set_perspective);
  1390. ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &VisualServer::camera_set_orthogonal);
  1391. ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &VisualServer::camera_set_frustum);
  1392. ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &VisualServer::camera_set_transform);
  1393. ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &VisualServer::camera_set_cull_mask);
  1394. ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &VisualServer::camera_set_environment);
  1395. ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &VisualServer::camera_set_use_vertical_aspect);
  1396. ClassDB::bind_method(D_METHOD("viewport_create"), &VisualServer::viewport_create);
  1397. ClassDB::bind_method(D_METHOD("viewport_set_use_arvr", "viewport", "use_arvr"), &VisualServer::viewport_set_use_arvr);
  1398. ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &VisualServer::viewport_set_size);
  1399. ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &VisualServer::viewport_set_active);
  1400. ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &VisualServer::viewport_set_parent_viewport);
  1401. ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &VisualServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(0));
  1402. ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &VisualServer::viewport_set_render_direct_to_screen);
  1403. ClassDB::bind_method(D_METHOD("viewport_detach", "viewport"), &VisualServer::viewport_detach);
  1404. ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &VisualServer::viewport_set_update_mode);
  1405. ClassDB::bind_method(D_METHOD("viewport_set_vflip", "viewport", "enabled"), &VisualServer::viewport_set_vflip);
  1406. ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &VisualServer::viewport_set_clear_mode);
  1407. ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &VisualServer::viewport_get_texture);
  1408. ClassDB::bind_method(D_METHOD("viewport_set_hide_scenario", "viewport", "hidden"), &VisualServer::viewport_set_hide_scenario);
  1409. ClassDB::bind_method(D_METHOD("viewport_set_hide_canvas", "viewport", "hidden"), &VisualServer::viewport_set_hide_canvas);
  1410. ClassDB::bind_method(D_METHOD("viewport_set_disable_environment", "viewport", "disabled"), &VisualServer::viewport_set_disable_environment);
  1411. ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disabled"), &VisualServer::viewport_set_disable_3d);
  1412. ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &VisualServer::viewport_attach_camera);
  1413. ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &VisualServer::viewport_set_scenario);
  1414. ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &VisualServer::viewport_attach_canvas);
  1415. ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &VisualServer::viewport_remove_canvas);
  1416. ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &VisualServer::viewport_set_canvas_transform);
  1417. ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &VisualServer::viewport_set_transparent_background);
  1418. ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &VisualServer::viewport_set_global_canvas_transform);
  1419. ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &VisualServer::viewport_set_canvas_stacking);
  1420. ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_size", "viewport", "size"), &VisualServer::viewport_set_shadow_atlas_size);
  1421. ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &VisualServer::viewport_set_shadow_atlas_quadrant_subdivision);
  1422. ClassDB::bind_method(D_METHOD("viewport_set_msaa", "viewport", "msaa"), &VisualServer::viewport_set_msaa);
  1423. ClassDB::bind_method(D_METHOD("viewport_set_use_fxaa", "viewport", "fxaa"), &VisualServer::viewport_set_use_fxaa);
  1424. ClassDB::bind_method(D_METHOD("viewport_set_use_debanding", "viewport", "debanding"), &VisualServer::viewport_set_use_debanding);
  1425. ClassDB::bind_method(D_METHOD("viewport_set_hdr", "viewport", "enabled"), &VisualServer::viewport_set_hdr);
  1426. ClassDB::bind_method(D_METHOD("viewport_set_usage", "viewport", "usage"), &VisualServer::viewport_set_usage);
  1427. ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "info"), &VisualServer::viewport_get_render_info);
  1428. ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &VisualServer::viewport_set_debug_draw);
  1429. ClassDB::bind_method(D_METHOD("environment_create"), &VisualServer::environment_create);
  1430. ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &VisualServer::environment_set_background);
  1431. ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &VisualServer::environment_set_sky);
  1432. ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &VisualServer::environment_set_sky_custom_fov);
  1433. ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &VisualServer::environment_set_sky_orientation);
  1434. ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &VisualServer::environment_set_bg_color);
  1435. ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "energy"), &VisualServer::environment_set_bg_energy);
  1436. ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &VisualServer::environment_set_canvas_max_layer);
  1437. ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "energy", "sky_contibution"), &VisualServer::environment_set_ambient_light, DEFVAL(1.0), DEFVAL(0.0));
  1438. ClassDB::bind_method(D_METHOD("environment_set_dof_blur_near", "env", "enable", "distance", "transition", "far_amount", "quality"), &VisualServer::environment_set_dof_blur_near);
  1439. ClassDB::bind_method(D_METHOD("environment_set_dof_blur_far", "env", "enable", "distance", "transition", "far_amount", "quality"), &VisualServer::environment_set_dof_blur_far);
  1440. ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap", "bicubic_upscale"), &VisualServer::environment_set_glow);
  1441. ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white", "auto_exposure", "min_luminance", "max_luminance", "auto_exp_speed", "auto_exp_grey"), &VisualServer::environment_set_tonemap);
  1442. ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "ramp"), &VisualServer::environment_set_adjustment);
  1443. ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance", "roughness"), &VisualServer::environment_set_ssr);
  1444. ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "radius2", "intensity2", "bias", "light_affect", "ao_channel_affect", "color", "quality", "blur", "bilateral_sharpness"), &VisualServer::environment_set_ssao);
  1445. ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "color", "sun_color", "sun_amount"), &VisualServer::environment_set_fog);
  1446. ClassDB::bind_method(D_METHOD("environment_set_fog_depth", "env", "enable", "depth_begin", "depth_end", "depth_curve", "transmit", "transmit_curve"), &VisualServer::environment_set_fog_depth);
  1447. ClassDB::bind_method(D_METHOD("environment_set_fog_height", "env", "enable", "min_height", "max_height", "height_curve"), &VisualServer::environment_set_fog_height);
  1448. ClassDB::bind_method(D_METHOD("scenario_create"), &VisualServer::scenario_create);
  1449. ClassDB::bind_method(D_METHOD("scenario_set_debug", "scenario", "debug_mode"), &VisualServer::scenario_set_debug);
  1450. ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &VisualServer::scenario_set_environment);
  1451. ClassDB::bind_method(D_METHOD("scenario_set_reflection_atlas_size", "scenario", "size", "subdiv"), &VisualServer::scenario_set_reflection_atlas_size);
  1452. ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &VisualServer::scenario_set_fallback_environment);
  1453. #ifndef _3D_DISABLED
  1454. ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &VisualServer::instance_create2);
  1455. ClassDB::bind_method(D_METHOD("instance_create"), &VisualServer::instance_create);
  1456. ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &VisualServer::instance_set_base);
  1457. ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &VisualServer::instance_set_scenario);
  1458. ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &VisualServer::instance_set_layer_mask);
  1459. ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &VisualServer::instance_set_transform);
  1460. ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &VisualServer::instance_attach_object_instance_id);
  1461. ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &VisualServer::instance_set_blend_shape_weight);
  1462. ClassDB::bind_method(D_METHOD("instance_set_surface_material", "instance", "surface", "material"), &VisualServer::instance_set_surface_material);
  1463. ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &VisualServer::instance_set_visible);
  1464. ClassDB::bind_method(D_METHOD("instance_set_use_lightmap", "instance", "lightmap_instance", "lightmap", "lightmap_slice", "lightmap_uv_rect"), &VisualServer::instance_set_use_lightmap, DEFVAL(-1), DEFVAL(Rect2(0, 0, 1, 1)));
  1465. ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &VisualServer::instance_set_custom_aabb);
  1466. ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &VisualServer::instance_attach_skeleton);
  1467. ClassDB::bind_method(D_METHOD("instance_set_exterior", "instance", "enabled"), &VisualServer::instance_set_exterior);
  1468. ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &VisualServer::instance_set_extra_visibility_margin);
  1469. ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &VisualServer::instance_geometry_set_flag);
  1470. ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &VisualServer::instance_geometry_set_cast_shadows_setting);
  1471. ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &VisualServer::instance_geometry_set_material_override);
  1472. ClassDB::bind_method(D_METHOD("instance_geometry_set_draw_range", "instance", "min", "max", "min_margin", "max_margin"), &VisualServer::instance_geometry_set_draw_range);
  1473. ClassDB::bind_method(D_METHOD("instance_geometry_set_as_instance_lod", "instance", "as_lod_of_instance"), &VisualServer::instance_geometry_set_as_instance_lod);
  1474. ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &VisualServer::_instances_cull_aabb_bind, DEFVAL(RID()));
  1475. ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &VisualServer::_instances_cull_ray_bind, DEFVAL(RID()));
  1476. ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &VisualServer::_instances_cull_convex_bind, DEFVAL(RID()));
  1477. #endif
  1478. ClassDB::bind_method(D_METHOD("canvas_create"), &VisualServer::canvas_create);
  1479. ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &VisualServer::canvas_set_item_mirroring);
  1480. ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &VisualServer::canvas_set_modulate);
  1481. ClassDB::bind_method(D_METHOD("canvas_item_create"), &VisualServer::canvas_item_create);
  1482. ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &VisualServer::canvas_item_set_parent);
  1483. ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &VisualServer::canvas_item_set_visible);
  1484. ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &VisualServer::canvas_item_set_light_mask);
  1485. ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &VisualServer::canvas_item_set_transform);
  1486. ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &VisualServer::canvas_item_set_clip);
  1487. ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &VisualServer::canvas_item_set_distance_field_mode);
  1488. ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &VisualServer::canvas_item_set_custom_rect, DEFVAL(Rect2()));
  1489. ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &VisualServer::canvas_item_set_modulate);
  1490. ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &VisualServer::canvas_item_set_self_modulate);
  1491. ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &VisualServer::canvas_item_set_draw_behind_parent);
  1492. ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &VisualServer::canvas_item_add_line, DEFVAL(1.0), DEFVAL(false));
  1493. ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &VisualServer::canvas_item_add_polyline, DEFVAL(1.0), DEFVAL(false));
  1494. ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &VisualServer::canvas_item_add_rect);
  1495. ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &VisualServer::canvas_item_add_circle);
  1496. ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose", "normal_map"), &VisualServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()));
  1497. ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &VisualServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()), DEFVAL(true));
  1498. ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &VisualServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()));
  1499. ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID()));
  1500. ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false));
  1501. ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased", "antialiasing_use_indices"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false), DEFVAL(false));
  1502. ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID()));
  1503. ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID()));
  1504. ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &VisualServer::canvas_item_add_particles);
  1505. ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &VisualServer::canvas_item_add_set_transform);
  1506. ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &VisualServer::canvas_item_add_clip_ignore);
  1507. ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &VisualServer::canvas_item_set_sort_children_by_y);
  1508. ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &VisualServer::canvas_item_set_z_index);
  1509. ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &VisualServer::canvas_item_set_z_as_relative_to_parent);
  1510. ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &VisualServer::canvas_item_set_copy_to_backbuffer);
  1511. ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &VisualServer::canvas_item_clear);
  1512. ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &VisualServer::canvas_item_set_draw_index);
  1513. ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &VisualServer::canvas_item_set_material);
  1514. ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &VisualServer::canvas_item_set_use_parent_material);
  1515. ClassDB::bind_method(D_METHOD("canvas_light_create"), &VisualServer::canvas_light_create);
  1516. ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &VisualServer::canvas_light_attach_to_canvas);
  1517. ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &VisualServer::canvas_light_set_enabled);
  1518. ClassDB::bind_method(D_METHOD("canvas_light_set_scale", "light", "scale"), &VisualServer::canvas_light_set_scale);
  1519. ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &VisualServer::canvas_light_set_transform);
  1520. ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &VisualServer::canvas_light_set_texture);
  1521. ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &VisualServer::canvas_light_set_texture_offset);
  1522. ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &VisualServer::canvas_light_set_color);
  1523. ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &VisualServer::canvas_light_set_height);
  1524. ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &VisualServer::canvas_light_set_energy);
  1525. ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &VisualServer::canvas_light_set_z_range);
  1526. ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &VisualServer::canvas_light_set_layer_range);
  1527. ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_cull_mask);
  1528. ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_shadow_cull_mask);
  1529. ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &VisualServer::canvas_light_set_mode);
  1530. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &VisualServer::canvas_light_set_shadow_enabled);
  1531. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_buffer_size", "light", "size"), &VisualServer::canvas_light_set_shadow_buffer_size);
  1532. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_gradient_length", "light", "length"), &VisualServer::canvas_light_set_shadow_gradient_length);
  1533. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &VisualServer::canvas_light_set_shadow_filter);
  1534. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &VisualServer::canvas_light_set_shadow_color);
  1535. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &VisualServer::canvas_light_set_shadow_smooth);
  1536. ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &VisualServer::canvas_light_occluder_create);
  1537. ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &VisualServer::canvas_light_occluder_attach_to_canvas);
  1538. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &VisualServer::canvas_light_occluder_set_enabled);
  1539. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &VisualServer::canvas_light_occluder_set_polygon);
  1540. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &VisualServer::canvas_light_occluder_set_transform);
  1541. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &VisualServer::canvas_light_occluder_set_light_mask);
  1542. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &VisualServer::canvas_occluder_polygon_create);
  1543. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &VisualServer::canvas_occluder_polygon_set_shape);
  1544. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape_as_lines", "occluder_polygon", "shape"), &VisualServer::canvas_occluder_polygon_set_shape_as_lines);
  1545. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &VisualServer::canvas_occluder_polygon_set_cull_mode);
  1546. ClassDB::bind_method(D_METHOD("black_bars_set_margins", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_margins);
  1547. ClassDB::bind_method(D_METHOD("black_bars_set_images", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_images);
  1548. ClassDB::bind_method(D_METHOD("free_rid", "rid"), &VisualServer::free); // shouldn't conflict with Object::free()
  1549. ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "where", "method", "userdata"), &VisualServer::request_frame_drawn_callback);
  1550. ClassDB::bind_method(D_METHOD("has_changed"), &VisualServer::has_changed);
  1551. ClassDB::bind_method(D_METHOD("init"), &VisualServer::init);
  1552. ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish);
  1553. ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info);
  1554. ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &VisualServer::get_video_adapter_name);
  1555. ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &VisualServer::get_video_adapter_vendor);
  1556. #ifndef _3D_DISABLED
  1557. ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh);
  1558. ClassDB::bind_method(D_METHOD("get_test_cube"), &VisualServer::get_test_cube);
  1559. #endif
  1560. ClassDB::bind_method(D_METHOD("get_test_texture"), &VisualServer::get_test_texture);
  1561. ClassDB::bind_method(D_METHOD("get_white_texture"), &VisualServer::get_white_texture);
  1562. ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &VisualServer::set_boot_image, DEFVAL(true));
  1563. ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &VisualServer::set_default_clear_color);
  1564. ClassDB::bind_method(D_METHOD("set_shader_time_scale", "scale"), &VisualServer::set_shader_time_scale);
  1565. ClassDB::bind_method(D_METHOD("has_feature", "feature"), &VisualServer::has_feature);
  1566. ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &VisualServer::has_os_feature);
  1567. ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &VisualServer::set_debug_generate_wireframes);
  1568. ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &VisualServer::is_render_loop_enabled);
  1569. ClassDB::bind_method(D_METHOD("set_render_loop_enabled", "enabled"), &VisualServer::set_render_loop_enabled);
  1570. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_loop_enabled"), "set_render_loop_enabled", "is_render_loop_enabled");
  1571. BIND_CONSTANT(NO_INDEX_ARRAY);
  1572. BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
  1573. BIND_CONSTANT(CANVAS_ITEM_Z_MIN);
  1574. BIND_CONSTANT(CANVAS_ITEM_Z_MAX);
  1575. BIND_CONSTANT(MAX_GLOW_LEVELS);
  1576. BIND_CONSTANT(MAX_CURSORS);
  1577. BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MIN);
  1578. BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MAX);
  1579. BIND_ENUM_CONSTANT(CUBEMAP_LEFT);
  1580. BIND_ENUM_CONSTANT(CUBEMAP_RIGHT);
  1581. BIND_ENUM_CONSTANT(CUBEMAP_BOTTOM);
  1582. BIND_ENUM_CONSTANT(CUBEMAP_TOP);
  1583. BIND_ENUM_CONSTANT(CUBEMAP_FRONT);
  1584. BIND_ENUM_CONSTANT(CUBEMAP_BACK);
  1585. BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D);
  1586. BIND_ENUM_CONSTANT(TEXTURE_TYPE_CUBEMAP);
  1587. BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D_ARRAY);
  1588. BIND_ENUM_CONSTANT(TEXTURE_TYPE_3D);
  1589. BIND_ENUM_CONSTANT(TEXTURE_FLAG_MIPMAPS);
  1590. BIND_ENUM_CONSTANT(TEXTURE_FLAG_REPEAT);
  1591. BIND_ENUM_CONSTANT(TEXTURE_FLAG_FILTER);
  1592. BIND_ENUM_CONSTANT(TEXTURE_FLAG_ANISOTROPIC_FILTER);
  1593. BIND_ENUM_CONSTANT(TEXTURE_FLAG_CONVERT_TO_LINEAR);
  1594. BIND_ENUM_CONSTANT(TEXTURE_FLAG_MIRRORED_REPEAT);
  1595. BIND_ENUM_CONSTANT(TEXTURE_FLAG_USED_FOR_STREAMING);
  1596. BIND_ENUM_CONSTANT(TEXTURE_FLAGS_DEFAULT);
  1597. BIND_ENUM_CONSTANT(SHADER_SPATIAL);
  1598. BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM);
  1599. BIND_ENUM_CONSTANT(SHADER_PARTICLES);
  1600. BIND_ENUM_CONSTANT(SHADER_MAX);
  1601. BIND_ENUM_CONSTANT(ARRAY_VERTEX);
  1602. BIND_ENUM_CONSTANT(ARRAY_NORMAL);
  1603. BIND_ENUM_CONSTANT(ARRAY_TANGENT);
  1604. BIND_ENUM_CONSTANT(ARRAY_COLOR);
  1605. BIND_ENUM_CONSTANT(ARRAY_TEX_UV);
  1606. BIND_ENUM_CONSTANT(ARRAY_TEX_UV2);
  1607. BIND_ENUM_CONSTANT(ARRAY_BONES);
  1608. BIND_ENUM_CONSTANT(ARRAY_WEIGHTS);
  1609. BIND_ENUM_CONSTANT(ARRAY_INDEX);
  1610. BIND_ENUM_CONSTANT(ARRAY_MAX);
  1611. BIND_ENUM_CONSTANT(ARRAY_FORMAT_VERTEX);
  1612. BIND_ENUM_CONSTANT(ARRAY_FORMAT_NORMAL);
  1613. BIND_ENUM_CONSTANT(ARRAY_FORMAT_TANGENT);
  1614. BIND_ENUM_CONSTANT(ARRAY_FORMAT_COLOR);
  1615. BIND_ENUM_CONSTANT(ARRAY_FORMAT_TEX_UV);
  1616. BIND_ENUM_CONSTANT(ARRAY_FORMAT_TEX_UV2);
  1617. BIND_ENUM_CONSTANT(ARRAY_FORMAT_BONES);
  1618. BIND_ENUM_CONSTANT(ARRAY_FORMAT_WEIGHTS);
  1619. BIND_ENUM_CONSTANT(ARRAY_FORMAT_INDEX);
  1620. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_VERTEX);
  1621. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_NORMAL);
  1622. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TANGENT);
  1623. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_COLOR);
  1624. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TEX_UV);
  1625. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TEX_UV2);
  1626. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_BONES);
  1627. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_WEIGHTS);
  1628. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_INDEX);
  1629. BIND_ENUM_CONSTANT(ARRAY_FLAG_USE_2D_VERTICES);
  1630. BIND_ENUM_CONSTANT(ARRAY_FLAG_USE_16_BIT_BONES);
  1631. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_DEFAULT);
  1632. BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);
  1633. BIND_ENUM_CONSTANT(PRIMITIVE_LINES);
  1634. BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);
  1635. BIND_ENUM_CONSTANT(PRIMITIVE_LINE_LOOP);
  1636. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);
  1637. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
  1638. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
  1639. BIND_ENUM_CONSTANT(PRIMITIVE_MAX);
  1640. BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);
  1641. BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE);
  1642. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL);
  1643. BIND_ENUM_CONSTANT(LIGHT_OMNI);
  1644. BIND_ENUM_CONSTANT(LIGHT_SPOT);
  1645. BIND_ENUM_CONSTANT(LIGHT_PARAM_ENERGY);
  1646. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPECULAR);
  1647. BIND_ENUM_CONSTANT(LIGHT_PARAM_RANGE);
  1648. BIND_ENUM_CONSTANT(LIGHT_PARAM_ATTENUATION);
  1649. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ANGLE);
  1650. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ATTENUATION);
  1651. BIND_ENUM_CONSTANT(LIGHT_PARAM_CONTACT_SHADOW_SIZE);
  1652. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_MAX_DISTANCE);
  1653. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET);
  1654. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET);
  1655. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET);
  1656. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_NORMAL_BIAS);
  1657. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS);
  1658. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE);
  1659. BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX);
  1660. BIND_ENUM_CONSTANT(LIGHT_BAKE_DISABLED);
  1661. BIND_ENUM_CONSTANT(LIGHT_BAKE_INDIRECT);
  1662. BIND_ENUM_CONSTANT(LIGHT_BAKE_ALL);
  1663. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DUAL_PARABOLOID);
  1664. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_CUBE);
  1665. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DETAIL_VERTICAL);
  1666. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL);
  1667. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
  1668. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS);
  1669. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS);
  1670. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE);
  1671. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED);
  1672. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED);
  1673. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE);
  1674. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE);
  1675. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS);
  1676. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ALWAYS);
  1677. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_NEVER);
  1678. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ONLY_NEXT_FRAME);
  1679. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_DISABLED);
  1680. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_2X);
  1681. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_4X);
  1682. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_8X);
  1683. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_16X);
  1684. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_EXT_2X);
  1685. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_EXT_4X);
  1686. BIND_ENUM_CONSTANT(VIEWPORT_USAGE_2D);
  1687. BIND_ENUM_CONSTANT(VIEWPORT_USAGE_2D_NO_SAMPLING);
  1688. BIND_ENUM_CONSTANT(VIEWPORT_USAGE_3D);
  1689. BIND_ENUM_CONSTANT(VIEWPORT_USAGE_3D_NO_EFFECTS);
  1690. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME);
  1691. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME);
  1692. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME);
  1693. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME);
  1694. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME);
  1695. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME);
  1696. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_2D_ITEMS_IN_FRAME);
  1697. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_2D_DRAW_CALLS_IN_FRAME);
  1698. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MAX);
  1699. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLED);
  1700. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_UNSHADED);
  1701. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW);
  1702. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME);
  1703. BIND_ENUM_CONSTANT(SCENARIO_DEBUG_DISABLED);
  1704. BIND_ENUM_CONSTANT(SCENARIO_DEBUG_WIREFRAME);
  1705. BIND_ENUM_CONSTANT(SCENARIO_DEBUG_OVERDRAW);
  1706. BIND_ENUM_CONSTANT(SCENARIO_DEBUG_SHADELESS);
  1707. BIND_ENUM_CONSTANT(INSTANCE_NONE);
  1708. BIND_ENUM_CONSTANT(INSTANCE_MESH);
  1709. BIND_ENUM_CONSTANT(INSTANCE_MULTIMESH);
  1710. BIND_ENUM_CONSTANT(INSTANCE_IMMEDIATE);
  1711. BIND_ENUM_CONSTANT(INSTANCE_PARTICLES);
  1712. BIND_ENUM_CONSTANT(INSTANCE_LIGHT);
  1713. BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE);
  1714. BIND_ENUM_CONSTANT(INSTANCE_GI_PROBE);
  1715. BIND_ENUM_CONSTANT(INSTANCE_LIGHTMAP_CAPTURE);
  1716. BIND_ENUM_CONSTANT(INSTANCE_MAX);
  1717. BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK);
  1718. BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_BAKED_LIGHT);
  1719. BIND_ENUM_CONSTANT(INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE);
  1720. BIND_ENUM_CONSTANT(INSTANCE_FLAG_MAX);
  1721. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_OFF);
  1722. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_ON);
  1723. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);
  1724. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
  1725. BIND_ENUM_CONSTANT(NINE_PATCH_STRETCH);
  1726. BIND_ENUM_CONSTANT(NINE_PATCH_TILE);
  1727. BIND_ENUM_CONSTANT(NINE_PATCH_TILE_FIT);
  1728. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_ADD);
  1729. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_SUB);
  1730. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_MIX);
  1731. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_MASK);
  1732. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_NONE);
  1733. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF3);
  1734. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF5);
  1735. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF7);
  1736. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF9);
  1737. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF13);
  1738. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_DISABLED);
  1739. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE);
  1740. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE);
  1741. BIND_ENUM_CONSTANT(INFO_OBJECTS_IN_FRAME);
  1742. BIND_ENUM_CONSTANT(INFO_VERTICES_IN_FRAME);
  1743. BIND_ENUM_CONSTANT(INFO_MATERIAL_CHANGES_IN_FRAME);
  1744. BIND_ENUM_CONSTANT(INFO_SHADER_CHANGES_IN_FRAME);
  1745. BIND_ENUM_CONSTANT(INFO_SURFACE_CHANGES_IN_FRAME);
  1746. BIND_ENUM_CONSTANT(INFO_DRAW_CALLS_IN_FRAME);
  1747. BIND_ENUM_CONSTANT(INFO_2D_ITEMS_IN_FRAME);
  1748. BIND_ENUM_CONSTANT(INFO_2D_DRAW_CALLS_IN_FRAME);
  1749. BIND_ENUM_CONSTANT(INFO_USAGE_VIDEO_MEM_TOTAL);
  1750. BIND_ENUM_CONSTANT(INFO_VIDEO_MEM_USED);
  1751. BIND_ENUM_CONSTANT(INFO_TEXTURE_MEM_USED);
  1752. BIND_ENUM_CONSTANT(INFO_VERTEX_MEM_USED);
  1753. BIND_ENUM_CONSTANT(FEATURE_SHADERS);
  1754. BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED);
  1755. BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_2D);
  1756. BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_3D);
  1757. BIND_ENUM_CONSTANT(MULTIMESH_COLOR_NONE);
  1758. BIND_ENUM_CONSTANT(MULTIMESH_COLOR_8BIT);
  1759. BIND_ENUM_CONSTANT(MULTIMESH_COLOR_FLOAT);
  1760. BIND_ENUM_CONSTANT(MULTIMESH_CUSTOM_DATA_NONE);
  1761. BIND_ENUM_CONSTANT(MULTIMESH_CUSTOM_DATA_8BIT);
  1762. BIND_ENUM_CONSTANT(MULTIMESH_CUSTOM_DATA_FLOAT);
  1763. BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ONCE);
  1764. BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ALWAYS);
  1765. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_INDEX);
  1766. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_LIFETIME);
  1767. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_VIEW_DEPTH);
  1768. BIND_ENUM_CONSTANT(ENV_BG_CLEAR_COLOR);
  1769. BIND_ENUM_CONSTANT(ENV_BG_COLOR);
  1770. BIND_ENUM_CONSTANT(ENV_BG_SKY);
  1771. BIND_ENUM_CONSTANT(ENV_BG_COLOR_SKY);
  1772. BIND_ENUM_CONSTANT(ENV_BG_CANVAS);
  1773. BIND_ENUM_CONSTANT(ENV_BG_KEEP);
  1774. BIND_ENUM_CONSTANT(ENV_BG_MAX);
  1775. BIND_ENUM_CONSTANT(ENV_DOF_BLUR_QUALITY_LOW);
  1776. BIND_ENUM_CONSTANT(ENV_DOF_BLUR_QUALITY_MEDIUM);
  1777. BIND_ENUM_CONSTANT(ENV_DOF_BLUR_QUALITY_HIGH);
  1778. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
  1779. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SCREEN);
  1780. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT);
  1781. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_REPLACE);
  1782. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_LINEAR);
  1783. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_REINHARD);
  1784. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_FILMIC);
  1785. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_ACES);
  1786. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_LOW);
  1787. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_MEDIUM);
  1788. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_HIGH);
  1789. BIND_ENUM_CONSTANT(ENV_SSAO_BLUR_DISABLED);
  1790. BIND_ENUM_CONSTANT(ENV_SSAO_BLUR_1x1);
  1791. BIND_ENUM_CONSTANT(ENV_SSAO_BLUR_2x2);
  1792. BIND_ENUM_CONSTANT(ENV_SSAO_BLUR_3x3);
  1793. ADD_SIGNAL(MethodInfo("frame_pre_draw"));
  1794. ADD_SIGNAL(MethodInfo("frame_post_draw"));
  1795. }
  1796. void VisualServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) {
  1797. ERR_FAIL_COND(p_margins.size() != 4);
  1798. //canvas_item_add_style_box(p_item,p_rect,p_source,p_texture,Vector2(p_margins[0],p_margins[1]),Vector2(p_margins[2],p_margins[3]),true,p_modulate);
  1799. }
  1800. void VisualServer::_camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
  1801. camera_set_orthogonal(p_camera, p_size, p_z_near, p_z_far);
  1802. }
  1803. void VisualServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) {
  1804. PoolVector<Vector3> vertices;
  1805. PoolVector<Vector3> normals;
  1806. for (int i = 0; i < p_mesh_data.faces.size(); i++) {
  1807. const Geometry::MeshData::Face &f = p_mesh_data.faces[i];
  1808. for (int j = 2; j < f.indices.size(); j++) {
  1809. #define _ADD_VERTEX(m_idx) \
  1810. vertices.push_back(p_mesh_data.vertices[f.indices[m_idx]]); \
  1811. normals.push_back(f.plane.normal);
  1812. _ADD_VERTEX(0);
  1813. _ADD_VERTEX(j - 1);
  1814. _ADD_VERTEX(j);
  1815. }
  1816. }
  1817. Array d;
  1818. d.resize(VS::ARRAY_MAX);
  1819. d[ARRAY_VERTEX] = vertices;
  1820. d[ARRAY_NORMAL] = normals;
  1821. mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d);
  1822. }
  1823. void VisualServer::mesh_add_surface_from_planes(RID p_mesh, const PoolVector<Plane> &p_planes) {
  1824. Geometry::MeshData mdata = Geometry::build_convex_mesh(p_planes);
  1825. mesh_add_surface_from_mesh_data(p_mesh, mdata);
  1826. }
  1827. void VisualServer::immediate_vertex_2d(RID p_immediate, const Vector2 &p_vertex) {
  1828. immediate_vertex(p_immediate, Vector3(p_vertex.x, p_vertex.y, 0));
  1829. }
  1830. RID VisualServer::instance_create2(RID p_base, RID p_scenario) {
  1831. RID instance = instance_create();
  1832. instance_set_base(instance, p_base);
  1833. instance_set_scenario(instance, p_scenario);
  1834. return instance;
  1835. }
  1836. bool VisualServer::is_render_loop_enabled() const {
  1837. return render_loop_enabled;
  1838. }
  1839. void VisualServer::set_render_loop_enabled(bool p_enabled) {
  1840. render_loop_enabled = p_enabled;
  1841. }
  1842. VisualServer::VisualServer() {
  1843. //ERR_FAIL_COND(singleton);
  1844. singleton = this;
  1845. GLOBAL_DEF_RST("rendering/vram_compression/import_bptc", false);
  1846. GLOBAL_DEF_RST("rendering/vram_compression/import_s3tc", true);
  1847. GLOBAL_DEF_RST("rendering/vram_compression/import_etc", false);
  1848. GLOBAL_DEF_RST("rendering/vram_compression/import_etc2", true);
  1849. GLOBAL_DEF_RST("rendering/vram_compression/import_pvrtc", false);
  1850. GLOBAL_DEF("rendering/limits/time/time_rollover_secs", 3600);
  1851. ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/time/time_rollover_secs", PropertyInfo(Variant::REAL, "rendering/limits/time/time_rollover_secs", PROPERTY_HINT_RANGE, "0,10000,1,or_greater"));
  1852. GLOBAL_DEF_RST("rendering/quality/directional_shadow/size", 4096);
  1853. GLOBAL_DEF("rendering/quality/directional_shadow/size.mobile", 2048);
  1854. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/directional_shadow/size", PropertyInfo(Variant::INT, "rendering/quality/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384"));
  1855. GLOBAL_DEF_RST("rendering/quality/shadow_atlas/size", 4096);
  1856. GLOBAL_DEF("rendering/quality/shadow_atlas/size.mobile", 2048);
  1857. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/size", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/size", PROPERTY_HINT_RANGE, "256,16384"));
  1858. GLOBAL_DEF_RST("rendering/quality/shadow_atlas/cubemap_size", 512);
  1859. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/cubemap_size", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/cubemap_size", PROPERTY_HINT_RANGE, "64,16384"));
  1860. GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_0_subdiv", 1);
  1861. GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_1_subdiv", 2);
  1862. GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_2_subdiv", 3);
  1863. GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_3_subdiv", 4);
  1864. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_0_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_0_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
  1865. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_1_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_1_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
  1866. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_2_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_2_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
  1867. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_3_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_3_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
  1868. GLOBAL_DEF("rendering/quality/shadows/filter_mode", 1);
  1869. GLOBAL_DEF("rendering/quality/shadows/filter_mode.mobile", 0);
  1870. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadows/filter_mode", PropertyInfo(Variant::INT, "rendering/quality/shadows/filter_mode", PROPERTY_HINT_ENUM, "Disabled,PCF5,PCF13"));
  1871. GLOBAL_DEF("rendering/quality/reflections/texture_array_reflections", true);
  1872. GLOBAL_DEF("rendering/quality/reflections/texture_array_reflections.mobile", false);
  1873. GLOBAL_DEF("rendering/quality/reflections/high_quality_ggx", true);
  1874. GLOBAL_DEF("rendering/quality/reflections/high_quality_ggx.mobile", false);
  1875. GLOBAL_DEF("rendering/quality/reflections/irradiance_max_size", 128);
  1876. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/reflections/irradiance_max_size", PropertyInfo(Variant::INT, "rendering/quality/reflections/irradiance_max_size", PROPERTY_HINT_RANGE, "32,2048"));
  1877. GLOBAL_DEF("rendering/quality/shading/force_vertex_shading", false);
  1878. GLOBAL_DEF("rendering/quality/shading/force_vertex_shading.mobile", true);
  1879. GLOBAL_DEF("rendering/quality/shading/force_lambert_over_burley", false);
  1880. GLOBAL_DEF("rendering/quality/shading/force_lambert_over_burley.mobile", true);
  1881. GLOBAL_DEF("rendering/quality/shading/force_blinn_over_ggx", false);
  1882. GLOBAL_DEF("rendering/quality/shading/force_blinn_over_ggx.mobile", true);
  1883. GLOBAL_DEF("rendering/quality/depth_prepass/enable", true);
  1884. GLOBAL_DEF("rendering/quality/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");
  1885. GLOBAL_DEF("rendering/quality/filters/anisotropic_filter_level", 4);
  1886. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/anisotropic_filter_level", PropertyInfo(Variant::INT, "rendering/quality/filters/anisotropic_filter_level", PROPERTY_HINT_RANGE, "1,16,1"));
  1887. GLOBAL_DEF("rendering/quality/filters/use_nearest_mipmap_filter", false);
  1888. GLOBAL_DEF("rendering/quality/skinning/software_skinning_fallback", true);
  1889. GLOBAL_DEF("rendering/quality/skinning/force_software_skinning", false);
  1890. const char *sz_balance_render_tree = "rendering/quality/spatial_partitioning/render_tree_balance";
  1891. GLOBAL_DEF(sz_balance_render_tree, 0.0f);
  1892. ProjectSettings::get_singleton()->set_custom_property_info(sz_balance_render_tree, PropertyInfo(Variant::REAL, sz_balance_render_tree, PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));
  1893. GLOBAL_DEF_RST("rendering/2d/options/use_software_skinning", true);
  1894. GLOBAL_DEF_RST("rendering/2d/options/ninepatch_mode", 1);
  1895. ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/options/ninepatch_mode", PropertyInfo(Variant::INT, "rendering/2d/options/ninepatch_mode", PROPERTY_HINT_ENUM, "Fixed,Scaling"));
  1896. GLOBAL_DEF_RST("rendering/2d/opengl/batching_send_null", 0);
  1897. ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/batching_send_null", PropertyInfo(Variant::INT, "rendering/2d/opengl/batching_send_null", PROPERTY_HINT_ENUM, "Default (On),Off,On"));
  1898. GLOBAL_DEF_RST("rendering/2d/opengl/batching_stream", 0);
  1899. ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/batching_stream", PropertyInfo(Variant::INT, "rendering/2d/opengl/batching_stream", PROPERTY_HINT_ENUM, "Default (Off),Off,On"));
  1900. GLOBAL_DEF_RST("rendering/2d/opengl/legacy_orphan_buffers", 0);
  1901. ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/legacy_orphan_buffers", PropertyInfo(Variant::INT, "rendering/2d/opengl/legacy_orphan_buffers", PROPERTY_HINT_ENUM, "Default (On),Off,On"));
  1902. GLOBAL_DEF_RST("rendering/2d/opengl/legacy_stream", 0);
  1903. ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/legacy_stream", PropertyInfo(Variant::INT, "rendering/2d/opengl/legacy_stream", PROPERTY_HINT_ENUM, "Default (On),Off,On"));
  1904. GLOBAL_DEF("rendering/batching/options/use_batching", true);
  1905. GLOBAL_DEF_RST("rendering/batching/options/use_batching_in_editor", true);
  1906. GLOBAL_DEF("rendering/batching/options/single_rect_fallback", false);
  1907. GLOBAL_DEF("rendering/batching/parameters/max_join_item_commands", 16);
  1908. GLOBAL_DEF("rendering/batching/parameters/colored_vertex_format_threshold", 0.25f);
  1909. GLOBAL_DEF("rendering/batching/lights/scissor_area_threshold", 1.0f);
  1910. GLOBAL_DEF("rendering/batching/lights/max_join_items", 32);
  1911. GLOBAL_DEF("rendering/batching/parameters/batch_buffer_size", 16384);
  1912. GLOBAL_DEF("rendering/batching/parameters/item_reordering_lookahead", 4);
  1913. GLOBAL_DEF("rendering/batching/debug/flash_batching", false);
  1914. GLOBAL_DEF("rendering/batching/debug/diagnose_frame", false);
  1915. GLOBAL_DEF("rendering/gles2/compatibility/disable_half_float", false);
  1916. GLOBAL_DEF("rendering/gles2/compatibility/enable_high_float.Android", false);
  1917. GLOBAL_DEF("rendering/batching/precision/uv_contract", false);
  1918. GLOBAL_DEF("rendering/batching/precision/uv_contract_amount", 100);
  1919. ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/max_join_item_commands", PropertyInfo(Variant::INT, "rendering/batching/parameters/max_join_item_commands", PROPERTY_HINT_RANGE, "0,65535"));
  1920. ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/colored_vertex_format_threshold", PropertyInfo(Variant::REAL, "rendering/batching/parameters/colored_vertex_format_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));
  1921. ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/batch_buffer_size", PropertyInfo(Variant::INT, "rendering/batching/parameters/batch_buffer_size", PROPERTY_HINT_RANGE, "1024,65535,1024"));
  1922. ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/scissor_area_threshold", PropertyInfo(Variant::REAL, "rendering/batching/lights/scissor_area_threshold", PROPERTY_HINT_RANGE, "0.0,1.0"));
  1923. ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/max_join_items", PropertyInfo(Variant::INT, "rendering/batching/lights/max_join_items", PROPERTY_HINT_RANGE, "0,512"));
  1924. ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/item_reordering_lookahead", PropertyInfo(Variant::INT, "rendering/batching/parameters/item_reordering_lookahead", PROPERTY_HINT_RANGE, "0,256"));
  1925. ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/precision/uv_contract_amount", PropertyInfo(Variant::INT, "rendering/batching/precision/uv_contract_amount", PROPERTY_HINT_RANGE, "0,10000"));
  1926. }
  1927. VisualServer::~VisualServer() {
  1928. singleton = NULL;
  1929. }