summaryrefslogtreecommitdiff
path: root/servers/visual
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /servers/visual
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
Diffstat (limited to 'servers/visual')
-rw-r--r--servers/visual/rasterizer.cpp11
-rw-r--r--servers/visual/rasterizer.h861
-rw-r--r--servers/visual/shader_language.cpp3466
-rw-r--r--servers/visual/shader_language.h172
-rw-r--r--servers/visual/shader_types.cpp242
-rw-r--r--servers/visual/shader_types.h14
-rw-r--r--servers/visual/visual_server_canvas.cpp902
-rw-r--r--servers/visual/visual_server_canvas.h156
-rw-r--r--servers/visual/visual_server_global.cpp14
-rw-r--r--servers/visual/visual_server_global.h4
-rw-r--r--servers/visual/visual_server_light_baker.cpp4
-rw-r--r--servers/visual/visual_server_light_baker.h7
-rw-r--r--servers/visual/visual_server_raster.cpp85
-rw-r--r--servers/visual/visual_server_raster.h770
-rw-r--r--servers/visual/visual_server_scene.cpp2230
-rw-r--r--servers/visual/visual_server_scene.h284
-rw-r--r--servers/visual/visual_server_viewport.cpp378
-rw-r--r--servers/visual/visual_server_viewport.h102
18 files changed, 4533 insertions, 5169 deletions
diff --git a/servers/visual/rasterizer.cpp b/servers/visual/rasterizer.cpp
index ba85f92e37..fdcc4f5633 100644
--- a/servers/visual/rasterizer.cpp
+++ b/servers/visual/rasterizer.cpp
@@ -27,22 +27,21 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rasterizer.h"
-#include "print_string.h"
#include "os/os.h"
+#include "print_string.h"
-
-Rasterizer* (*Rasterizer::_create_func)()=NULL;
+Rasterizer *(*Rasterizer::_create_func)() = NULL;
Rasterizer *Rasterizer::create() {
return _create_func();
}
-RasterizerStorage*RasterizerStorage::base_signleton=NULL;
+RasterizerStorage *RasterizerStorage::base_signleton = NULL;
RasterizerStorage::RasterizerStorage() {
- base_signleton=this;
+ base_signleton = this;
}
#if 0
@@ -78,7 +77,7 @@ RID Rasterizer::_create_shader(const FixedSpatialMaterialShaderKey& p_key) {
String code;
static const char* _uv_str[4]={"UV","uv_xform","UV2","uv_sphere"};
-#define _TEXUVSTR(m_idx) String( _uv_str[(p_key.texcoord_mask>>(m_idx*2))&0x3] )
+#define _TEXUVSTR(m_idx) String(_uv_str[(p_key.texcoord_mask >> (m_idx * 2)) & 0x3])
if (p_key.use_pointsize) {
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index dd22986865..527230895c 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -29,49 +29,46 @@
#ifndef RASTERIZER_H
#define RASTERIZER_H
-
-#include "servers/visual_server.h"
#include "camera_matrix.h"
+#include "servers/visual_server.h"
#include "self_list.h"
-
class RasterizerScene {
public:
-
/* SHADOW ATLAS API */
- virtual RID shadow_atlas_create()=0;
- virtual void shadow_atlas_set_size(RID p_atlas,int p_size)=0;
- virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas,int p_quadrant,int p_subdivision)=0;
- virtual bool shadow_atlas_update_light(RID p_atlas,RID p_light_intance,float p_coverage,uint64_t p_light_version)=0;
+ virtual RID shadow_atlas_create() = 0;
+ virtual void shadow_atlas_set_size(RID p_atlas, int p_size) = 0;
+ virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) = 0;
+ virtual bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) = 0;
- virtual int get_directional_light_shadow_size(RID p_light_intance)=0;
- virtual void set_directional_shadow_count(int p_count)=0;
+ virtual int get_directional_light_shadow_size(RID p_light_intance) = 0;
+ virtual void set_directional_shadow_count(int p_count) = 0;
/* ENVIRONMENT API */
- virtual RID environment_create()=0;
+ virtual RID environment_create() = 0;
- virtual void environment_set_background(RID p_env,VS::EnvironmentBG p_bg)=0;
- virtual void environment_set_skybox(RID p_env,RID p_skybox)=0;
- virtual void environment_set_skybox_scale(RID p_env,float p_scale)=0;
- virtual void environment_set_bg_color(RID p_env,const Color& p_color)=0;
- virtual void environment_set_bg_energy(RID p_env,float p_energy)=0;
- virtual void environment_set_canvas_max_layer(RID p_env,int p_max_layer)=0;
- virtual void environment_set_ambient_light(RID p_env,const Color& p_color,float p_energy=1.0,float p_skybox_contribution=0.0)=0;
+ virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) = 0;
+ virtual void environment_set_skybox(RID p_env, RID p_skybox) = 0;
+ virtual void environment_set_skybox_scale(RID p_env, float p_scale) = 0;
+ virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0;
+ virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0;
+ virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0;
+ virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_skybox_contribution = 0.0) = 0;
- virtual void environment_set_dof_blur_near(RID p_env,bool p_enable,float p_distance,float p_transition,float p_far_amount,VS::EnvironmentDOFBlurQuality p_quality)=0;
- virtual void environment_set_dof_blur_far(RID p_env,bool p_enable,float p_distance,float p_transition,float p_far_amount,VS::EnvironmentDOFBlurQuality p_quality)=0;
- virtual void environment_set_glow(RID p_env,bool p_enable,int p_level_flags,float p_intensity,float p_strength,float p_bloom_treshold,VS::EnvironmentGlowBlendMode p_blend_mode,float p_hdr_bleed_treshold,float p_hdr_bleed_scale,bool p_bicubic_upscale)=0;
- virtual void environment_set_fog(RID p_env,bool p_enable,float p_begin,float p_end,RID p_gradient_texture)=0;
+ virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0;
+ virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0;
+ virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0;
+ virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) = 0;
- virtual void environment_set_ssr(RID p_env,bool p_enable, int p_max_steps,float p_accel,float p_fade,float p_depth_tolerance,bool p_smooth,bool p_roughness)=0;
- virtual void environment_set_ssao(RID p_env,bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect,const Color &p_color,bool p_blur)=0;
+ virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_accel, float p_fade, float p_depth_tolerance, bool p_smooth, bool p_roughness) = 0;
+ virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, const Color &p_color, bool p_blur) = 0;
- virtual void environment_set_tonemap(RID p_env,VS::EnvironmentToneMapper p_tone_mapper,float p_exposure,float p_white,bool p_auto_exposure,float p_min_luminance,float p_max_luminance,float p_auto_exp_speed,float p_auto_exp_scale)=0;
+ virtual void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) = 0;
- virtual void environment_set_adjustment(RID p_env,bool p_enable,float p_brightness,float p_contrast,float p_saturation,RID p_ramp)=0;
+ virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) = 0;
struct InstanceBase : RID_Data {
@@ -100,10 +97,10 @@ public:
//Transform *baked_light_octree_xform;
//int baked_lightmap_id;
- bool mirror :8;
- bool depth_scale :8;
- bool billboard :8;
- bool billboard_y :8;
+ bool mirror : 8;
+ bool depth_scale : 8;
+ bool billboard : 8;
+ bool billboard_y : 8;
bool receive_shadows : 8;
bool visible : 8;
@@ -113,338 +110,323 @@ public:
InstanceBase *baked_light; //baked light to use
SelfList<InstanceBase> baked_light_item;
- virtual void base_removed()=0;
- virtual void base_changed()=0;
- virtual void base_material_changed()=0;
-
- InstanceBase() : dependency_item(this), baked_light_item(this) {
-
- base_type=VS::INSTANCE_NONE;
- cast_shadows=VS::SHADOW_CASTING_SETTING_ON;
- receive_shadows=true;
- depth_scale=false;
- billboard=false;
- billboard_y=false;
- visible=true;
- depth_layer=0;
- layer_mask=1;
- baked_light=NULL;
-
-
+ virtual void base_removed() = 0;
+ virtual void base_changed() = 0;
+ virtual void base_material_changed() = 0;
+
+ InstanceBase()
+ : dependency_item(this), baked_light_item(this) {
+
+ base_type = VS::INSTANCE_NONE;
+ cast_shadows = VS::SHADOW_CASTING_SETTING_ON;
+ receive_shadows = true;
+ depth_scale = false;
+ billboard = false;
+ billboard_y = false;
+ visible = true;
+ depth_layer = 0;
+ layer_mask = 1;
+ baked_light = NULL;
}
};
- virtual RID light_instance_create(RID p_light)=0;
- virtual void light_instance_set_transform(RID p_light_instance,const Transform& p_transform)=0;
- virtual void light_instance_set_shadow_transform(RID p_light_instance,const CameraMatrix& p_projection,const Transform& p_transform,float p_far,float p_split,int p_pass)=0;
- virtual void light_instance_mark_visible(RID p_light_instance)=0;
+ virtual RID light_instance_create(RID p_light) = 0;
+ virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform) = 0;
+ virtual void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass) = 0;
+ virtual void light_instance_mark_visible(RID p_light_instance) = 0;
- virtual RID reflection_atlas_create()=0;
- virtual void reflection_atlas_set_size(RID p_ref_atlas,int p_size)=0;
- virtual void reflection_atlas_set_subdivision(RID p_ref_atlas,int p_subdiv)=0;
+ virtual RID reflection_atlas_create() = 0;
+ virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_size) = 0;
+ virtual void reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv) = 0;
- virtual RID reflection_probe_instance_create(RID p_probe)=0;
- virtual void reflection_probe_instance_set_transform(RID p_instance,const Transform& p_transform)=0;
- virtual void reflection_probe_release_atlas_index(RID p_instance)=0;
- virtual bool reflection_probe_instance_needs_redraw(RID p_instance)=0;
- virtual bool reflection_probe_instance_has_reflection(RID p_instance)=0;
- virtual bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas)=0;
- virtual bool reflection_probe_instance_postprocess_step(RID p_instance)=0;
+ virtual RID reflection_probe_instance_create(RID p_probe) = 0;
+ virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) = 0;
+ virtual void reflection_probe_release_atlas_index(RID p_instance) = 0;
+ virtual bool reflection_probe_instance_needs_redraw(RID p_instance) = 0;
+ virtual bool reflection_probe_instance_has_reflection(RID p_instance) = 0;
+ virtual bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) = 0;
+ virtual bool reflection_probe_instance_postprocess_step(RID p_instance) = 0;
- virtual RID gi_probe_instance_create()=0;
- virtual void gi_probe_instance_set_light_data(RID p_probe,RID p_base,RID p_data)=0;
- virtual void gi_probe_instance_set_transform_to_data(RID p_probe,const Transform& p_xform)=0;
- virtual void gi_probe_instance_set_bounds(RID p_probe,const Vector3& p_bounds)=0;
+ virtual RID gi_probe_instance_create() = 0;
+ virtual void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data) = 0;
+ virtual void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) = 0;
+ virtual void gi_probe_instance_set_bounds(RID p_probe, const Vector3 &p_bounds) = 0;
- virtual void render_scene(const Transform& p_cam_transform,const CameraMatrix& p_cam_projection,bool p_cam_ortogonal,InstanceBase** p_cull_result,int p_cull_count,RID* p_light_cull_result,int p_light_cull_count,RID* p_reflection_probe_cull_result,int p_reflection_probe_cull_count,RID p_environment,RID p_shadow_atlas,RID p_reflection_atlas,RID p_reflection_probe,int p_reflection_probe_pass)=0;
- virtual void render_shadow(RID p_light,RID p_shadow_atlas,int p_pass,InstanceBase** p_cull_result,int p_cull_count)=0;
+ virtual void render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) = 0;
+ virtual void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) = 0;
- virtual void set_scene_pass(uint64_t p_pass)=0;
+ virtual void set_scene_pass(uint64_t p_pass) = 0;
- virtual bool free(RID p_rid)=0;
+ virtual bool free(RID p_rid) = 0;
virtual ~RasterizerScene() {}
};
-
-
-
-
-
-
class RasterizerStorage {
public:
/* TEXTURE API */
- virtual RID texture_create()=0;
- virtual void texture_allocate(RID p_texture,int p_width, int p_height,Image::Format p_format,uint32_t p_flags=VS::TEXTURE_FLAGS_DEFAULT)=0;
- virtual void texture_set_data(RID p_texture,const Image& p_image,VS::CubeMapSide p_cube_side=VS::CUBEMAP_LEFT)=0;
- virtual Image texture_get_data(RID p_texture,VS::CubeMapSide p_cube_side=VS::CUBEMAP_LEFT) const=0;
- virtual void texture_set_flags(RID p_texture,uint32_t p_flags)=0;
- virtual uint32_t texture_get_flags(RID p_texture) const=0;
- virtual Image::Format texture_get_format(RID p_texture) const=0;
- virtual uint32_t texture_get_width(RID p_texture) const=0;
- virtual uint32_t texture_get_height(RID p_texture) const=0;
- virtual void texture_set_size_override(RID p_texture,int p_width, int p_height)=0;
+ virtual RID texture_create() = 0;
+ virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT) = 0;
+ virtual void texture_set_data(RID p_texture, const Image &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) = 0;
+ virtual Image texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const = 0;
+ virtual void texture_set_flags(RID p_texture, uint32_t p_flags) = 0;
+ virtual uint32_t texture_get_flags(RID p_texture) const = 0;
+ virtual Image::Format texture_get_format(RID p_texture) const = 0;
+ virtual uint32_t texture_get_width(RID p_texture) const = 0;
+ virtual uint32_t texture_get_height(RID p_texture) const = 0;
+ virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) = 0;
- virtual void texture_set_path(RID p_texture,const String& p_path)=0;
- virtual String texture_get_path(RID p_texture) const=0;
+ virtual void texture_set_path(RID p_texture, const String &p_path) = 0;
+ virtual String texture_get_path(RID p_texture) const = 0;
- virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable)=0;
+ virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable) = 0;
- virtual void texture_debug_usage(List<VS::TextureInfo> *r_info)=0;
+ virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) = 0;
- virtual RID texture_create_radiance_cubemap(RID p_source,int p_resolution=-1) const=0;
+ virtual RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const = 0;
- virtual void texture_set_detect_3d_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata)=0;
- virtual void texture_set_detect_srgb_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata)=0;
+ virtual void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) = 0;
+ virtual void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) = 0;
- virtual void textures_keep_original(bool p_enable)=0;
+ virtual void textures_keep_original(bool p_enable) = 0;
/* SKYBOX API */
- virtual RID skybox_create()=0;
- virtual void skybox_set_texture(RID p_skybox,RID p_cube_map,int p_radiance_size)=0;
+ virtual RID skybox_create() = 0;
+ virtual void skybox_set_texture(RID p_skybox, RID p_cube_map, int p_radiance_size) = 0;
/* SHADER API */
+ virtual RID shader_create(VS::ShaderMode p_mode = VS::SHADER_SPATIAL) = 0;
- virtual RID shader_create(VS::ShaderMode p_mode=VS::SHADER_SPATIAL)=0;
-
- virtual void shader_set_mode(RID p_shader,VS::ShaderMode p_mode)=0;
- virtual VS::ShaderMode shader_get_mode(RID p_shader) const=0;
+ virtual void shader_set_mode(RID p_shader, VS::ShaderMode p_mode) = 0;
+ virtual VS::ShaderMode shader_get_mode(RID p_shader) const = 0;
- virtual void shader_set_code(RID p_shader, const String& p_code)=0;
- virtual String shader_get_code(RID p_shader) const=0;
- virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const=0;
-
- virtual void shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture)=0;
- virtual RID shader_get_default_texture_param(RID p_shader, const StringName& p_name) const=0;
+ virtual void shader_set_code(RID p_shader, const String &p_code) = 0;
+ virtual String shader_get_code(RID p_shader) const = 0;
+ virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0;
+ virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) = 0;
+ virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const = 0;
/* COMMON MATERIAL API */
- virtual RID material_create()=0;
+ virtual RID material_create() = 0;
- virtual void material_set_shader(RID p_shader_material, RID p_shader)=0;
- virtual RID material_get_shader(RID p_shader_material) const=0;
+ virtual void material_set_shader(RID p_shader_material, RID p_shader) = 0;
+ virtual RID material_get_shader(RID p_shader_material) const = 0;
- virtual void material_set_param(RID p_material, const StringName& p_param, const Variant& p_value)=0;
- virtual Variant material_get_param(RID p_material, const StringName& p_param) const=0;
+ virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0;
+ virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0;
- virtual void material_set_line_width(RID p_material, float p_width)=0;
+ virtual void material_set_line_width(RID p_material, float p_width) = 0;
- virtual bool material_is_animated(RID p_material)=0;
- virtual bool material_casts_shadows(RID p_material)=0;
+ virtual bool material_is_animated(RID p_material) = 0;
+ virtual bool material_casts_shadows(RID p_material) = 0;
- virtual void material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance)=0;
- virtual void material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance)=0;
+ virtual void material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) = 0;
+ virtual void material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) = 0;
/* MESH API */
- virtual RID mesh_create()=0;
+ virtual RID mesh_create() = 0;
- virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<Rect3>& p_bone_aabbs=Vector<Rect3>())=0;
+ virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()) = 0;
- virtual void mesh_set_blend_shape_count(RID p_mesh,int p_amount)=0;
- virtual int mesh_get_blend_shape_count(RID p_mesh) const=0;
+ virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount) = 0;
+ virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0;
+ virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) = 0;
+ virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
- virtual void mesh_set_blend_shape_mode(RID p_mesh,VS::BlendShapeMode p_mode)=0;
- virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const=0;
+ virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
+ virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0;
- virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material)=0;
- virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const=0;
+ virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const = 0;
+ virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const = 0;
- virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const=0;
- virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const=0;
+ virtual PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const = 0;
+ virtual PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const = 0;
- virtual PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const=0;
- virtual PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const=0;
+ virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0;
+ virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0;
+ virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0;
+ virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0;
+ virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0;
- virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const=0;
- virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const=0;
+ virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0;
+ virtual int mesh_get_surface_count(RID p_mesh) const = 0;
- virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const=0;
- virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const=0;
- virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const=0;
+ virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) = 0;
+ virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const = 0;
- virtual void mesh_remove_surface(RID p_mesh,int p_index)=0;
- virtual int mesh_get_surface_count(RID p_mesh) const=0;
-
- virtual void mesh_set_custom_aabb(RID p_mesh,const Rect3& p_aabb)=0;
- virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const=0;
-
- virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const=0;
- virtual void mesh_clear(RID p_mesh)=0;
+ virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0;
+ virtual void mesh_clear(RID p_mesh) = 0;
/* MULTIMESH API */
+ virtual RID multimesh_create() = 0;
- virtual RID multimesh_create()=0;
+ virtual void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, VS::MultimeshColorFormat p_color_format) = 0;
+ virtual int multimesh_get_instance_count(RID p_multimesh) const = 0;
- virtual void multimesh_allocate(RID p_multimesh,int p_instances,VS::MultimeshTransformFormat p_transform_format,VS::MultimeshColorFormat p_color_format)=0;
- virtual int multimesh_get_instance_count(RID p_multimesh) const=0;
-
- virtual void multimesh_set_mesh(RID p_multimesh,RID p_mesh)=0;
- virtual void multimesh_instance_set_transform(RID p_multimesh,int p_index,const Transform& p_transform)=0;
- virtual void multimesh_instance_set_transform_2d(RID p_multimesh,int p_index,const Transform2D& p_transform)=0;
- virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color)=0;
+ virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh) = 0;
+ virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform) = 0;
+ virtual void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) = 0;
+ virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0;
- virtual RID multimesh_get_mesh(RID p_multimesh) const=0;
+ virtual RID multimesh_get_mesh(RID p_multimesh) const = 0;
- virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const=0;
- virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh,int p_index) const=0;
- virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const=0;
+ virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0;
+ virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0;
+ virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const = 0;
- virtual void multimesh_set_visible_instances(RID p_multimesh,int p_visible)=0;
- virtual int multimesh_get_visible_instances(RID p_multimesh) const=0;
+ virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;
+ virtual int multimesh_get_visible_instances(RID p_multimesh) const = 0;
- virtual Rect3 multimesh_get_aabb(RID p_multimesh) const=0;
+ virtual Rect3 multimesh_get_aabb(RID p_multimesh) const = 0;
/* IMMEDIATE API */
- virtual RID immediate_create()=0;
- virtual void immediate_begin(RID p_immediate,VS::PrimitiveType p_rimitive,RID p_texture=RID())=0;
- virtual void immediate_vertex(RID p_immediate,const Vector3& p_vertex)=0;
- virtual void immediate_normal(RID p_immediate,const Vector3& p_normal)=0;
- virtual void immediate_tangent(RID p_immediate,const Plane& p_tangent)=0;
- virtual void immediate_color(RID p_immediate,const Color& p_color)=0;
- virtual void immediate_uv(RID p_immediate,const Vector2& tex_uv)=0;
- virtual void immediate_uv2(RID p_immediate,const Vector2& tex_uv)=0;
- virtual void immediate_end(RID p_immediate)=0;
- virtual void immediate_clear(RID p_immediate)=0;
- virtual void immediate_set_material(RID p_immediate,RID p_material)=0;
- virtual RID immediate_get_material(RID p_immediate) const=0;
- virtual Rect3 immediate_get_aabb(RID p_immediate) const=0;
-
+ virtual RID immediate_create() = 0;
+ virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) = 0;
+ virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) = 0;
+ virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal) = 0;
+ virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent) = 0;
+ virtual void immediate_color(RID p_immediate, const Color &p_color) = 0;
+ virtual void immediate_uv(RID p_immediate, const Vector2 &tex_uv) = 0;
+ virtual void immediate_uv2(RID p_immediate, const Vector2 &tex_uv) = 0;
+ virtual void immediate_end(RID p_immediate) = 0;
+ virtual void immediate_clear(RID p_immediate) = 0;
+ virtual void immediate_set_material(RID p_immediate, RID p_material) = 0;
+ virtual RID immediate_get_material(RID p_immediate) const = 0;
+ virtual Rect3 immediate_get_aabb(RID p_immediate) const = 0;
/* SKELETON API */
- virtual RID skeleton_create()=0;
- virtual void skeleton_allocate(RID p_skeleton,int p_bones,bool p_2d_skeleton=false)=0;
- virtual int skeleton_get_bone_count(RID p_skeleton) const=0;
- virtual void skeleton_bone_set_transform(RID p_skeleton,int p_bone, const Transform& p_transform)=0;
- virtual Transform skeleton_bone_get_transform(RID p_skeleton,int p_bone) const =0;
- virtual void skeleton_bone_set_transform_2d(RID p_skeleton,int p_bone, const Transform2D& p_transform)=0;
- virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton,int p_bone) const=0;
+ virtual RID skeleton_create() = 0;
+ virtual void skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) = 0;
+ virtual int skeleton_get_bone_count(RID p_skeleton) const = 0;
+ virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) = 0;
+ virtual Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone) const = 0;
+ virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) = 0;
+ virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const = 0;
/* Light API */
- virtual RID light_create(VS::LightType p_type)=0;
+ virtual RID light_create(VS::LightType p_type) = 0;
- virtual void light_set_color(RID p_light,const Color& p_color)=0;
- virtual void light_set_param(RID p_light,VS::LightParam p_param,float p_value)=0;
- virtual void light_set_shadow(RID p_light,bool p_enabled)=0;
- virtual void light_set_shadow_color(RID p_light,const Color& p_color)=0;
- virtual void light_set_projector(RID p_light,RID p_texture)=0;
- virtual void light_set_negative(RID p_light,bool p_enable)=0;
- virtual void light_set_cull_mask(RID p_light,uint32_t p_mask)=0;
+ virtual void light_set_color(RID p_light, const Color &p_color) = 0;
+ virtual void light_set_param(RID p_light, VS::LightParam p_param, float p_value) = 0;
+ virtual void light_set_shadow(RID p_light, bool p_enabled) = 0;
+ virtual void light_set_shadow_color(RID p_light, const Color &p_color) = 0;
+ virtual void light_set_projector(RID p_light, RID p_texture) = 0;
+ virtual void light_set_negative(RID p_light, bool p_enable) = 0;
+ virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0;
- virtual void light_omni_set_shadow_mode(RID p_light,VS::LightOmniShadowMode p_mode)=0;
- virtual void light_omni_set_shadow_detail(RID p_light,VS::LightOmniShadowDetail p_detail)=0;
-
- virtual void light_directional_set_shadow_mode(RID p_light,VS::LightDirectionalShadowMode p_mode)=0;
- virtual void light_directional_set_blend_splits(RID p_light,bool p_enable)=0;
- virtual bool light_directional_get_blend_splits(RID p_light) const=0;
+ virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) = 0;
+ virtual void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail) = 0;
- virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light)=0;
- virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light)=0;
+ virtual void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) = 0;
+ virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) = 0;
+ virtual bool light_directional_get_blend_splits(RID p_light) const = 0;
- virtual bool light_has_shadow(RID p_light) const=0;
+ virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) = 0;
+ virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) = 0;
- virtual VS::LightType light_get_type(RID p_light) const=0;
- virtual Rect3 light_get_aabb(RID p_light) const=0;
- virtual float light_get_param(RID p_light,VS::LightParam p_param)=0;
- virtual Color light_get_color(RID p_light)=0;
- virtual uint64_t light_get_version(RID p_light) const=0;
+ virtual bool light_has_shadow(RID p_light) const = 0;
+ virtual VS::LightType light_get_type(RID p_light) const = 0;
+ virtual Rect3 light_get_aabb(RID p_light) const = 0;
+ virtual float light_get_param(RID p_light, VS::LightParam p_param) = 0;
+ virtual Color light_get_color(RID p_light) = 0;
+ virtual uint64_t light_get_version(RID p_light) const = 0;
/* PROBE API */
- virtual RID reflection_probe_create()=0;
-
- virtual void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode)=0;
- virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity)=0;
- virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color& p_ambient)=0;
- virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy)=0;
- virtual void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib)=0;
- virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance)=0;
- virtual void reflection_probe_set_extents(RID p_probe, const Vector3& p_extents)=0;
- virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3& p_offset)=0;
- virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable)=0;
- virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable)=0;
- virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable)=0;
- virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers)=0;
-
- virtual Rect3 reflection_probe_get_aabb(RID p_probe) const=0;
- virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const=0;
- virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const=0;
- virtual Vector3 reflection_probe_get_extents(RID p_probe) const=0;
- virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const=0;
- virtual float reflection_probe_get_origin_max_distance(RID p_probe) const=0;
- virtual bool reflection_probe_renders_shadows(RID p_probe) const=0;
-
+ virtual RID reflection_probe_create() = 0;
+
+ virtual void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) = 0;
+ virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0;
+ virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) = 0;
+ virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) = 0;
+ virtual void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) = 0;
+ virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) = 0;
+ virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) = 0;
+ virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) = 0;
+ virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) = 0;
+ virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) = 0;
+ virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0;
+ virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
+
+ virtual Rect3 reflection_probe_get_aabb(RID p_probe) const = 0;
+ virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0;
+ virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const = 0;
+ virtual Vector3 reflection_probe_get_extents(RID p_probe) const = 0;
+ virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const = 0;
+ virtual float reflection_probe_get_origin_max_distance(RID p_probe) const = 0;
+ virtual bool reflection_probe_renders_shadows(RID p_probe) const = 0;
/* ROOM API */
- virtual RID room_create()=0;
- virtual void room_add_bounds(RID p_room, const PoolVector<Vector2>& p_convex_polygon,float p_height,const Transform& p_transform)=0;
- virtual void room_clear_bounds(RID p_room)=0;
+ virtual RID room_create() = 0;
+ virtual void room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform) = 0;
+ virtual void room_clear_bounds(RID p_room) = 0;
/* PORTAL API */
// portals are only (x/y) points, forming a convex shape, which its clockwise
// order points outside. (z is 0)=0;
- virtual RID portal_create()=0;
- virtual void portal_set_shape(RID p_portal, const Vector<Point2>& p_shape)=0;
- virtual void portal_set_enabled(RID p_portal, bool p_enabled)=0;
- virtual void portal_set_disable_distance(RID p_portal, float p_distance)=0;
- virtual void portal_set_disabled_color(RID p_portal, const Color& p_color)=0;
+ virtual RID portal_create() = 0;
+ virtual void portal_set_shape(RID p_portal, const Vector<Point2> &p_shape) = 0;
+ virtual void portal_set_enabled(RID p_portal, bool p_enabled) = 0;
+ virtual void portal_set_disable_distance(RID p_portal, float p_distance) = 0;
+ virtual void portal_set_disabled_color(RID p_portal, const Color &p_color) = 0;
- virtual void instance_add_skeleton(RID p_skeleton,RasterizerScene::InstanceBase *p_instance)=0;
- virtual void instance_remove_skeleton(RID p_skeleton,RasterizerScene::InstanceBase *p_instance)=0;
+ virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) = 0;
+ virtual void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) = 0;
- virtual void instance_add_dependency(RID p_base,RasterizerScene::InstanceBase *p_instance)=0;
- virtual void instance_remove_dependency(RID p_base,RasterizerScene::InstanceBase *p_instance)=0;
+ virtual void instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) = 0;
+ virtual void instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) = 0;
/* GI PROBE API */
- virtual RID gi_probe_create()=0;
+ virtual RID gi_probe_create() = 0;
- virtual void gi_probe_set_bounds(RID p_probe,const Rect3& p_bounds)=0;
- virtual Rect3 gi_probe_get_bounds(RID p_probe) const=0;
+ virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) = 0;
+ virtual Rect3 gi_probe_get_bounds(RID p_probe) const = 0;
- virtual void gi_probe_set_cell_size(RID p_probe,float p_range)=0;
- virtual float gi_probe_get_cell_size(RID p_probe) const=0;
+ virtual void gi_probe_set_cell_size(RID p_probe, float p_range) = 0;
+ virtual float gi_probe_get_cell_size(RID p_probe) const = 0;
- virtual void gi_probe_set_to_cell_xform(RID p_probe,const Transform& p_xform)=0;
- virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const=0;
+ virtual void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform) = 0;
+ virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const = 0;
- virtual void gi_probe_set_dynamic_data(RID p_probe,const PoolVector<int>& p_data)=0;
- virtual PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const=0;
+ virtual void gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data) = 0;
+ virtual PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const = 0;
- virtual void gi_probe_set_dynamic_range(RID p_probe,int p_range)=0;
- virtual int gi_probe_get_dynamic_range(RID p_probe) const=0;
+ virtual void gi_probe_set_dynamic_range(RID p_probe, int p_range) = 0;
+ virtual int gi_probe_get_dynamic_range(RID p_probe) const = 0;
- virtual void gi_probe_set_energy(RID p_probe,float p_range)=0;
- virtual float gi_probe_get_energy(RID p_probe) const=0;
+ virtual void gi_probe_set_energy(RID p_probe, float p_range) = 0;
+ virtual float gi_probe_get_energy(RID p_probe) const = 0;
- virtual void gi_probe_set_bias(RID p_probe,float p_range)=0;
- virtual float gi_probe_get_bias(RID p_probe) const=0;
+ virtual void gi_probe_set_bias(RID p_probe, float p_range) = 0;
+ virtual float gi_probe_get_bias(RID p_probe) const = 0;
- virtual void gi_probe_set_propagation(RID p_probe,float p_range)=0;
- virtual float gi_probe_get_propagation(RID p_probe) const=0;
+ virtual void gi_probe_set_propagation(RID p_probe, float p_range) = 0;
+ virtual float gi_probe_get_propagation(RID p_probe) const = 0;
- virtual void gi_probe_set_interior(RID p_probe,bool p_enable)=0;
- virtual bool gi_probe_is_interior(RID p_probe) const=0;
+ virtual void gi_probe_set_interior(RID p_probe, bool p_enable) = 0;
+ virtual bool gi_probe_is_interior(RID p_probe) const = 0;
- virtual void gi_probe_set_compress(RID p_probe,bool p_enable)=0;
- virtual bool gi_probe_is_compressed(RID p_probe) const=0;
+ virtual void gi_probe_set_compress(RID p_probe, bool p_enable) = 0;
+ virtual bool gi_probe_is_compressed(RID p_probe) const = 0;
- virtual uint32_t gi_probe_get_version(RID p_probe)=0;
+ virtual uint32_t gi_probe_get_version(RID p_probe) = 0;
enum GIProbeCompression {
GI_PROBE_UNCOMPRESSED,
@@ -452,41 +434,37 @@ public:
GI_PROBE_ETC2
};
- virtual GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const=0;
- virtual RID gi_probe_dynamic_data_create(int p_width,int p_height,int p_depth,GIProbeCompression p_compression)=0;
- virtual void gi_probe_dynamic_data_update(RID p_gi_probe_data,int p_depth_slice,int p_slice_count,int p_mipmap,const void* p_data)=0;
-
+ virtual GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const = 0;
+ virtual RID gi_probe_dynamic_data_create(int p_width, int p_height, int p_depth, GIProbeCompression p_compression) = 0;
+ virtual void gi_probe_dynamic_data_update(RID p_gi_probe_data, int p_depth_slice, int p_slice_count, int p_mipmap, const void *p_data) = 0;
/* PARTICLES */
- virtual RID particles_create()=0;
-
- virtual void particles_set_emitting(RID p_particles,bool p_emitting)=0;
- virtual void particles_set_amount(RID p_particles,int p_amount)=0;
- virtual void particles_set_lifetime(RID p_particles,float p_lifetime)=0;
- virtual void particles_set_pre_process_time(RID p_particles,float p_time)=0;
- virtual void particles_set_explosiveness_ratio(RID p_particles,float p_ratio)=0;
- virtual void particles_set_randomness_ratio(RID p_particles,float p_ratio)=0;
- virtual void particles_set_custom_aabb(RID p_particles,const Rect3& p_aabb)=0;
- virtual void particles_set_gravity(RID p_particles,const Vector3& p_gravity)=0;
- virtual void particles_set_use_local_coordinates(RID p_particles,bool p_enable)=0;
- virtual void particles_set_process_material(RID p_particles,RID p_material)=0;
-
- virtual void particles_set_emission_shape(RID p_particles,VS::ParticlesEmissionShape p_shape)=0;
- virtual void particles_set_emission_sphere_radius(RID p_particles,float p_radius)=0;
- virtual void particles_set_emission_box_extents(RID p_particles,const Vector3& p_extents)=0;
- virtual void particles_set_emission_points(RID p_particles,const PoolVector<Vector3>& p_points)=0;
+ virtual RID particles_create() = 0;
+ virtual void particles_set_emitting(RID p_particles, bool p_emitting) = 0;
+ virtual void particles_set_amount(RID p_particles, int p_amount) = 0;
+ virtual void particles_set_lifetime(RID p_particles, float p_lifetime) = 0;
+ virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0;
+ virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0;
+ virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0;
+ virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) = 0;
+ virtual void particles_set_gravity(RID p_particles, const Vector3 &p_gravity) = 0;
+ virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0;
+ virtual void particles_set_process_material(RID p_particles, RID p_material) = 0;
- virtual void particles_set_draw_order(RID p_particles,VS::ParticlesDrawOrder p_order)=0;
+ virtual void particles_set_emission_shape(RID p_particles, VS::ParticlesEmissionShape p_shape) = 0;
+ virtual void particles_set_emission_sphere_radius(RID p_particles, float p_radius) = 0;
+ virtual void particles_set_emission_box_extents(RID p_particles, const Vector3 &p_extents) = 0;
+ virtual void particles_set_emission_points(RID p_particles, const PoolVector<Vector3> &p_points) = 0;
- virtual void particles_set_draw_passes(RID p_particles,int p_count)=0;
- virtual void particles_set_draw_pass_material(RID p_particles,int p_pass, RID p_material)=0;
- virtual void particles_set_draw_pass_mesh(RID p_particles,int p_pass, RID p_mesh)=0;
-
- virtual Rect3 particles_get_current_aabb(RID p_particles)=0;
+ virtual void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) = 0;
+ virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0;
+ virtual void particles_set_draw_pass_material(RID p_particles, int p_pass, RID p_material) = 0;
+ virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0;
+ virtual Rect3 particles_get_current_aabb(RID p_particles) = 0;
/* RENDER TARGET */
@@ -499,57 +477,47 @@ public:
RENDER_TARGET_FLAG_MAX
};
- virtual RID render_target_create()=0;
- virtual void render_target_set_size(RID p_render_target,int p_width, int p_height)=0;
- virtual RID render_target_get_texture(RID p_render_target) const=0;
- virtual void render_target_set_flag(RID p_render_target,RenderTargetFlags p_flag,bool p_value)=0;
- virtual bool render_target_renedered_in_frame(RID p_render_target)=0;
- virtual void render_target_set_msaa(RID p_render_target,VS::ViewportMSAA p_msaa)=0;
-
+ virtual RID render_target_create() = 0;
+ virtual void render_target_set_size(RID p_render_target, int p_width, int p_height) = 0;
+ virtual RID render_target_get_texture(RID p_render_target) const = 0;
+ virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) = 0;
+ virtual bool render_target_renedered_in_frame(RID p_render_target) = 0;
+ virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) = 0;
/* CANVAS SHADOW */
- virtual RID canvas_light_shadow_buffer_create(int p_width)=0;
+ virtual RID canvas_light_shadow_buffer_create(int p_width) = 0;
/* LIGHT SHADOW MAPPING */
- virtual RID canvas_light_occluder_create()=0;
- virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2>& p_lines)=0;
-
+ virtual RID canvas_light_occluder_create() = 0;
+ virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) = 0;
- virtual VS::InstanceType get_base_type(RID p_rid) const=0;
- virtual bool free(RID p_rid)=0;
+ virtual VS::InstanceType get_base_type(RID p_rid) const = 0;
+ virtual bool free(RID p_rid) = 0;
- virtual bool has_os_feature(const String& p_feature) const=0;
+ virtual bool has_os_feature(const String &p_feature) const = 0;
- virtual void update_dirty_resources()=0;
+ virtual void update_dirty_resources() = 0;
- static RasterizerStorage*base_signleton;
+ static RasterizerStorage *base_signleton;
RasterizerStorage();
virtual ~RasterizerStorage() {}
};
-
-
-
-
class RasterizerCanvas {
public:
-
enum CanvasRectFlags {
- CANVAS_RECT_REGION=1,
- CANVAS_RECT_TILE=2,
- CANVAS_RECT_FLIP_H=4,
- CANVAS_RECT_FLIP_V=8,
- CANVAS_RECT_TRANSPOSE=16
+ CANVAS_RECT_REGION = 1,
+ CANVAS_RECT_TILE = 2,
+ CANVAS_RECT_FLIP_H = 4,
+ CANVAS_RECT_FLIP_V = 8,
+ CANVAS_RECT_TRANSPOSE = 16
};
-
struct Light : public RID_Data {
-
-
bool enabled;
Color color;
Transform2D xform;
@@ -572,7 +540,6 @@ public:
VS::CanvasLightShadowFilter shadow_filter;
Color shadow_color;
-
void *texture_cache; // implementation dependent
Rect2 rect_cache;
Transform2D xform_cache;
@@ -590,33 +557,32 @@ public:
RID light_internal;
Light() {
- enabled=true;
- color=Color(1,1,1);
- shadow_color=Color(0,0,0,0);
- height=0;
- z_min=-1024;
- z_max=1024;
- layer_min=0;
- layer_max=0;
- item_mask=1;
- scale=1.0;
- energy=1.0;
- item_shadow_mask=-1;
- mode=VS::CANVAS_LIGHT_MODE_ADD;
- texture_cache=NULL;
- next_ptr=NULL;
- mask_next_ptr=NULL;
- filter_next_ptr=NULL;
- shadow_buffer_size=256;
- shadow_gradient_length=0;
- shadow_filter=VS::CANVAS_LIGHT_FILTER_NONE;
-
+ enabled = true;
+ color = Color(1, 1, 1);
+ shadow_color = Color(0, 0, 0, 0);
+ height = 0;
+ z_min = -1024;
+ z_max = 1024;
+ layer_min = 0;
+ layer_max = 0;
+ item_mask = 1;
+ scale = 1.0;
+ energy = 1.0;
+ item_shadow_mask = -1;
+ mode = VS::CANVAS_LIGHT_MODE_ADD;
+ texture_cache = NULL;
+ next_ptr = NULL;
+ mask_next_ptr = NULL;
+ filter_next_ptr = NULL;
+ shadow_buffer_size = 256;
+ shadow_gradient_length = 0;
+ shadow_filter = VS::CANVAS_LIGHT_FILTER_NONE;
}
};
- virtual RID light_internal_create()=0;
- virtual void light_internal_update(RID p_rid, Light* p_light)=0;
- virtual void light_internal_free(RID p_rid)=0;
+ virtual RID light_internal_create() = 0;
+ virtual void light_internal_update(RID p_rid, Light *p_light) = 0;
+ virtual void light_internal_free(RID p_rid) = 0;
struct Item : public RID_Data {
@@ -637,12 +603,12 @@ public:
};
Type type;
- virtual ~Command(){}
+ virtual ~Command() {}
};
struct CommandLine : public Command {
- Point2 from,to;
+ Point2 from, to;
Color color;
float width;
bool antialiased;
@@ -657,7 +623,10 @@ public:
Rect2 source;
uint8_t flags;
- CommandRect() { flags=0; type = TYPE_RECT; }
+ CommandRect() {
+ flags = 0;
+ type = TYPE_RECT;
+ }
};
struct CommandNinePatch : public Command {
@@ -670,7 +639,10 @@ public:
Color color;
VS::NinePatchAxisMode axis_x;
VS::NinePatchAxisMode axis_y;
- CommandNinePatch() { draw_center=true; type = TYPE_NINEPATCH; }
+ CommandNinePatch() {
+ draw_center = true;
+ type = TYPE_NINEPATCH;
+ }
};
struct CommandPrimitive : public Command {
@@ -681,7 +653,10 @@ public:
RID texture;
float width;
- CommandPrimitive() { type = TYPE_PRIMITIVE; width=1;}
+ CommandPrimitive() {
+ type = TYPE_PRIMITIVE;
+ width = 1;
+ }
};
struct CommandPolygon : public Command {
@@ -693,22 +668,24 @@ public:
RID texture;
int count;
- CommandPolygon() { type = TYPE_POLYGON; count = 0; }
+ CommandPolygon() {
+ type = TYPE_POLYGON;
+ count = 0;
+ }
};
-
struct CommandMesh : public Command {
RID mesh;
RID skeleton;
- CommandMesh() { type = TYPE_MESH; }
+ CommandMesh() { type = TYPE_MESH; }
};
struct CommandMultiMesh : public Command {
RID multimesh;
RID skeleton;
- CommandMultiMesh() { type = TYPE_MULTIMESH; }
+ CommandMultiMesh() { type = TYPE_MULTIMESH; }
};
struct CommandCircle : public Command {
@@ -725,17 +702,18 @@ public:
CommandTransform() { type = TYPE_TRANSFORM; }
};
-
struct CommandClipIgnore : public Command {
bool ignore;
- CommandClipIgnore() { type = TYPE_CLIP_IGNORE; ignore=false; }
+ CommandClipIgnore() {
+ type = TYPE_CLIP_IGNORE;
+ ignore = false;
+ }
};
-
struct ViewportRender {
- VisualServer*owner;
- void* udata;
+ VisualServer *owner;
+ void *udata;
Rect2 rect;
};
@@ -745,12 +723,12 @@ public:
bool behind;
//VS::MaterialBlendMode blend_mode;
int light_mask;
- Vector<Command*> commands;
+ Vector<Command *> commands;
mutable bool custom_rect;
mutable bool rect_dirty;
mutable Rect2 rect;
RID material;
- Item*next;
+ Item *next;
struct CopyBackBuffer {
Rect2 rect;
@@ -759,110 +737,106 @@ public:
};
CopyBackBuffer *copy_back_buffer;
-
Color final_modulate;
Transform2D final_transform;
Rect2 final_clip_rect;
- Item* final_clip_owner;
- Item* material_owner;
+ Item *final_clip_owner;
+ Item *material_owner;
ViewportRender *vp_render;
bool distance_field;
bool light_masked;
Rect2 global_rect_cache;
- const Rect2& get_rect() const {
+ const Rect2 &get_rect() const {
if (custom_rect || !rect_dirty)
return rect;
//must update rect
- int s=commands.size();
- if (s==0) {
+ int s = commands.size();
+ if (s == 0) {
- rect=Rect2();
- rect_dirty=false;
+ rect = Rect2();
+ rect_dirty = false;
return rect;
}
Transform2D xf;
- bool found_xform=false;
- bool first=true;
-
- const Item::Command * const *cmd = &commands[0];
+ bool found_xform = false;
+ bool first = true;
+ const Item::Command *const *cmd = &commands[0];
- for (int i=0;i<s;i++) {
+ for (int i = 0; i < s; i++) {
- const Item::Command *c=cmd[i];
+ const Item::Command *c = cmd[i];
Rect2 r;
- switch(c->type) {
+ switch (c->type) {
case Item::Command::TYPE_LINE: {
- const Item::CommandLine* line = static_cast< const Item::CommandLine*>(c);
- r.pos=line->from;
+ const Item::CommandLine *line = static_cast<const Item::CommandLine *>(c);
+ r.pos = line->from;
r.expand_to(line->to);
} break;
case Item::Command::TYPE_RECT: {
- const Item::CommandRect* crect = static_cast< const Item::CommandRect*>(c);
- r=crect->rect;
+ const Item::CommandRect *crect = static_cast<const Item::CommandRect *>(c);
+ r = crect->rect;
} break;
case Item::Command::TYPE_NINEPATCH: {
- const Item::CommandNinePatch* style = static_cast< const Item::CommandNinePatch*>(c);
- r=style->rect;
+ const Item::CommandNinePatch *style = static_cast<const Item::CommandNinePatch *>(c);
+ r = style->rect;
} break;
case Item::Command::TYPE_PRIMITIVE: {
- const Item::CommandPrimitive* primitive = static_cast< const Item::CommandPrimitive*>(c);
- r.pos=primitive->points[0];
- for(int i=1;i<primitive->points.size();i++) {
+ const Item::CommandPrimitive *primitive = static_cast<const Item::CommandPrimitive *>(c);
+ r.pos = primitive->points[0];
+ for (int i = 1; i < primitive->points.size(); i++) {
r.expand_to(primitive->points[i]);
-
}
} break;
case Item::Command::TYPE_POLYGON: {
- const Item::CommandPolygon* polygon = static_cast< const Item::CommandPolygon*>(c);
+ const Item::CommandPolygon *polygon = static_cast<const Item::CommandPolygon *>(c);
int l = polygon->points.size();
- const Point2*pp=&polygon->points[0];
- r.pos=pp[0];
- for(int i=1;i<l;i++) {
+ const Point2 *pp = &polygon->points[0];
+ r.pos = pp[0];
+ for (int i = 1; i < l; i++) {
r.expand_to(pp[i]);
-
}
} break;
case Item::Command::TYPE_MESH: {
- const Item::CommandMesh* mesh = static_cast< const Item::CommandMesh*>(c);
- Rect3 aabb = RasterizerStorage::base_signleton->mesh_get_aabb(mesh->mesh,mesh->skeleton);
+ const Item::CommandMesh *mesh = static_cast<const Item::CommandMesh *>(c);
+ Rect3 aabb = RasterizerStorage::base_signleton->mesh_get_aabb(mesh->mesh, mesh->skeleton);
- r=Rect2(aabb.pos.x,aabb.pos.y,aabb.size.x,aabb.size.y);
+ r = Rect2(aabb.pos.x, aabb.pos.y, aabb.size.x, aabb.size.y);
} break;
case Item::Command::TYPE_MULTIMESH: {
- const Item::CommandMultiMesh* multimesh = static_cast< const Item::CommandMultiMesh*>(c);
+ const Item::CommandMultiMesh *multimesh = static_cast<const Item::CommandMultiMesh *>(c);
Rect3 aabb = RasterizerStorage::base_signleton->multimesh_get_aabb(multimesh->multimesh);
- r=Rect2(aabb.pos.x,aabb.pos.y,aabb.size.x,aabb.size.y);
+ r = Rect2(aabb.pos.x, aabb.pos.y, aabb.size.x, aabb.size.y);
} break;
case Item::Command::TYPE_CIRCLE: {
- const Item::CommandCircle* circle = static_cast< const Item::CommandCircle*>(c);
- r.pos=Point2(-circle->radius,-circle->radius)+circle->pos;
- r.size=Point2(circle->radius*2.0,circle->radius*2.0);
+ const Item::CommandCircle *circle = static_cast<const Item::CommandCircle *>(c);
+ r.pos = Point2(-circle->radius, -circle->radius) + circle->pos;
+ r.size = Point2(circle->radius * 2.0, circle->radius * 2.0);
} break;
case Item::Command::TYPE_TRANSFORM: {
- const Item::CommandTransform* transform = static_cast<const Item::CommandTransform*>(c);
- xf=transform->xform;
- found_xform=true;
+ const Item::CommandTransform *transform = static_cast<const Item::CommandTransform *>(c);
+ xf = transform->xform;
+ found_xform = true;
continue;
} break;
@@ -873,37 +847,59 @@ public:
if (found_xform) {
r = xf.xform(r);
- found_xform=false;
+ found_xform = false;
}
-
if (first) {
- rect=r;
- first=false;
+ rect = r;
+ first = false;
} else
- rect=rect.merge(r);
+ rect = rect.merge(r);
}
- rect_dirty=false;
+ rect_dirty = false;
return rect;
}
- void clear() { for (int i=0;i<commands.size();i++) memdelete( commands[i] ); commands.clear(); clip=false; rect_dirty=true; final_clip_owner=NULL; material_owner=NULL; light_masked=false; }
- Item() { light_mask=1; vp_render=NULL; next=NULL; final_clip_owner=NULL; clip=false; final_modulate=Color(1,1,1,1); visible=true; rect_dirty=true; custom_rect=false; behind=false; material_owner=NULL; copy_back_buffer=NULL; distance_field=false; light_masked=false; }
- virtual ~Item() { clear(); if (copy_back_buffer) memdelete(copy_back_buffer); }
+ void clear() {
+ for (int i = 0; i < commands.size(); i++)
+ memdelete(commands[i]);
+ commands.clear();
+ clip = false;
+ rect_dirty = true;
+ final_clip_owner = NULL;
+ material_owner = NULL;
+ light_masked = false;
+ }
+ Item() {
+ light_mask = 1;
+ vp_render = NULL;
+ next = NULL;
+ final_clip_owner = NULL;
+ clip = false;
+ final_modulate = Color(1, 1, 1, 1);
+ visible = true;
+ rect_dirty = true;
+ custom_rect = false;
+ behind = false;
+ material_owner = NULL;
+ copy_back_buffer = NULL;
+ distance_field = false;
+ light_masked = false;
+ }
+ virtual ~Item() {
+ clear();
+ if (copy_back_buffer) memdelete(copy_back_buffer);
+ }
};
+ virtual void canvas_begin() = 0;
- virtual void canvas_begin()=0;
-
- virtual void canvas_render_items(Item *p_item_list,int p_z,const Color& p_modulate,Light *p_light)=0;
- virtual void canvas_debug_viewport_shadows(Light* p_lights_with_shadow)=0;
-
-
+ virtual void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light) = 0;
+ virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) = 0;
struct LightOccluderInstance : public RID_Data {
-
bool enabled;
RID canvas;
RID polygon;
@@ -916,52 +912,52 @@ public:
LightOccluderInstance *next;
- LightOccluderInstance() { enabled=true; next=NULL; light_mask=1; cull_cache=VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; }
+ LightOccluderInstance() {
+ enabled = true;
+ next = NULL;
+ light_mask = 1;
+ cull_cache = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
+ }
};
+ virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) = 0;
-
- virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D& p_light_xform, int p_light_mask,float p_near, float p_far, LightOccluderInstance* p_occluders, CameraMatrix *p_xform_cache)=0;
-
-
- virtual void reset_canvas()=0;
+ virtual void reset_canvas() = 0;
virtual ~RasterizerCanvas() {}
};
-
class Rasterizer {
protected:
- static Rasterizer* (*_create_func)();
+ static Rasterizer *(*_create_func)();
+
public:
static Rasterizer *create();
- virtual RasterizerStorage *get_storage()=0;
- virtual RasterizerCanvas *get_canvas()=0;
- virtual RasterizerScene *get_scene()=0;
-
- virtual void initialize()=0;
- virtual void begin_frame()=0;
- virtual void set_current_render_target(RID p_render_target)=0;
- virtual void restore_render_target()=0;
- virtual void clear_render_target(const Color& p_color)=0;
- virtual void blit_render_target_to_screen(RID p_render_target,const Rect2& p_screen_rect,int p_screen=0)=0;
- virtual void end_frame()=0;
- virtual void finalize()=0;
+ virtual RasterizerStorage *get_storage() = 0;
+ virtual RasterizerCanvas *get_canvas() = 0;
+ virtual RasterizerScene *get_scene() = 0;
+ virtual void initialize() = 0;
+ virtual void begin_frame() = 0;
+ virtual void set_current_render_target(RID p_render_target) = 0;
+ virtual void restore_render_target() = 0;
+ virtual void clear_render_target(const Color &p_color) = 0;
+ virtual void blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen = 0) = 0;
+ virtual void end_frame() = 0;
+ virtual void finalize() = 0;
virtual ~Rasterizer() {}
};
-
#if 0
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-#include "servers/visual_server.h"
#include "camera_matrix.h"
#include "map.h"
#include "self_list.h"
+#include "servers/visual_server.h"
class Rasterizer {
protected:
@@ -1975,6 +1971,5 @@ public:
virtual ~Rasterizer() {}
};
-
#endif
#endif
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index c680013efa..3bc495f08e 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -27,69 +27,66 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "shader_language.h"
-#include "print_string.h"
#include "os/os.h"
+#include "print_string.h"
static bool _is_text_char(CharType c) {
- return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_';
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
}
static bool _is_number(CharType c) {
- return (c>='0' && c<='9');
+ return (c >= '0' && c <= '9');
}
static bool _is_hex(CharType c) {
- return (c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F');
+ return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
-
String ShaderLanguage::get_operator_text(Operator p_op) {
- static const char* op_names[OP_MAX]={"==",
- "!=",
- "<",
- "<=",
- ">",
- ">=",
- "&&",
- "||",
- "!",
- "-",
- "+",
- "-",
- "*",
- "/",
- "%",
- "<<",
- ">>",
- "=",
- "+=",
- "-=",
- "*=",
- "/=",
- "%=",
- "<<=",
- ">>=",
- "&=",
- "|=",
- "^=",
- "&",
- "|",
- "^",
- "~",
- "++"
- "--",
- "()",
- "construct"};
+ static const char *op_names[OP_MAX] = { "==",
+ "!=",
+ "<",
+ "<=",
+ ">",
+ ">=",
+ "&&",
+ "||",
+ "!",
+ "-",
+ "+",
+ "-",
+ "*",
+ "/",
+ "%",
+ "<<",
+ ">>",
+ "=",
+ "+=",
+ "-=",
+ "*=",
+ "/=",
+ "%=",
+ "<<=",
+ ">>=",
+ "&=",
+ "|=",
+ "^=",
+ "&",
+ "|",
+ "^",
+ "~",
+ "++"
+ "--",
+ "()",
+ "construct" };
return op_names[p_op];
-
}
-
-const char * ShaderLanguage::token_names[TK_MAX]={
+const char *ShaderLanguage::token_names[TK_MAX] = {
"EMPTY",
"IDENTIFIER",
"TRUE",
@@ -195,94 +192,92 @@ const char * ShaderLanguage::token_names[TK_MAX]={
String ShaderLanguage::get_token_text(Token p_token) {
- String name=token_names[p_token.type];
- if (p_token.type==TK_INT_CONSTANT || p_token.type==TK_REAL_CONSTANT) {
- name+="("+rtos(p_token.constant)+")";
- } else if (p_token.type==TK_IDENTIFIER) {
- name+="("+String(p_token.text)+")";
- } else if (p_token.type==TK_ERROR) {
- name+="("+String(p_token.text)+")";
+ String name = token_names[p_token.type];
+ if (p_token.type == TK_INT_CONSTANT || p_token.type == TK_REAL_CONSTANT) {
+ name += "(" + rtos(p_token.constant) + ")";
+ } else if (p_token.type == TK_IDENTIFIER) {
+ name += "(" + String(p_token.text) + ")";
+ } else if (p_token.type == TK_ERROR) {
+ name += "(" + String(p_token.text) + ")";
}
return name;
}
-ShaderLanguage::Token ShaderLanguage::_make_token(TokenType p_type,const StringName& p_text) {
+ShaderLanguage::Token ShaderLanguage::_make_token(TokenType p_type, const StringName &p_text) {
Token tk;
- tk.type=p_type;
- tk.text=p_text;
- tk.line=tk_line;
- if (tk.type==TK_ERROR) {
+ tk.type = p_type;
+ tk.text = p_text;
+ tk.line = tk_line;
+ if (tk.type == TK_ERROR) {
_set_error(p_text);
}
return tk;
}
-const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[]={
- {TK_TRUE,"true"},
- {TK_FALSE,"false"},
- {TK_TYPE_VOID,"void"},
- {TK_TYPE_BOOL,"bool"},
- {TK_TYPE_BVEC2,"bvec2"},
- {TK_TYPE_BVEC3,"bvec3"},
- {TK_TYPE_BVEC4,"bvec4"},
- {TK_TYPE_INT,"int"},
- {TK_TYPE_IVEC2,"ivec2"},
- {TK_TYPE_IVEC3,"ivec3"},
- {TK_TYPE_IVEC4,"ivec4"},
- {TK_TYPE_UINT,"uint"},
- {TK_TYPE_UVEC2,"uvec2"},
- {TK_TYPE_UVEC3,"uvec3"},
- {TK_TYPE_UVEC4,"uvec4"},
- {TK_TYPE_FLOAT,"float"},
- {TK_TYPE_VEC2,"vec2"},
- {TK_TYPE_VEC3,"vec3"},
- {TK_TYPE_VEC4,"vec4"},
- {TK_TYPE_MAT2,"mat2"},
- {TK_TYPE_MAT3,"mat3"},
- {TK_TYPE_MAT4,"mat4"},
- {TK_TYPE_SAMPLER2D,"sampler2D"},
- {TK_TYPE_ISAMPLER2D,"isampler2D"},
- {TK_TYPE_USAMPLER2D,"usampler2D"},
- {TK_TYPE_SAMPLERCUBE,"samplerCube"},
- {TK_PRECISION_LOW,"lowp"},
- {TK_PRECISION_MID,"mediump"},
- {TK_PRECISION_HIGH,"highp"},
- {TK_CF_IF,"if"},
- {TK_CF_ELSE,"else"},
- {TK_CF_FOR,"for"},
- {TK_CF_WHILE,"while"},
- {TK_CF_DO,"do"},
- {TK_CF_SWITCH,"switch"},
- {TK_CF_CASE,"case"},
- {TK_CF_BREAK,"break"},
- {TK_CF_CONTINUE,"continue"},
- {TK_CF_RETURN,"return"},
- {TK_UNIFORM,"uniform"},
- {TK_VARYING,"varying"},
- {TK_RENDER_MODE,"render_mode"},
- {TK_HINT_WHITE_TEXTURE,"hint_white"},
- {TK_HINT_BLACK_TEXTURE,"hint_black"},
- {TK_HINT_NORMAL_TEXTURE,"hint_normal"},
- {TK_HINT_ANISO_TEXTURE,"hint_aniso"},
- {TK_HINT_ALBEDO_TEXTURE,"hint_albedo"},
- {TK_HINT_BLACK_ALBEDO_TEXTURE,"hint_black_albedo"},
- {TK_HINT_COLOR,"hint_color"},
- {TK_HINT_RANGE,"hint_range"},
-
- {TK_ERROR,NULL}
+const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = {
+ { TK_TRUE, "true" },
+ { TK_FALSE, "false" },
+ { TK_TYPE_VOID, "void" },
+ { TK_TYPE_BOOL, "bool" },
+ { TK_TYPE_BVEC2, "bvec2" },
+ { TK_TYPE_BVEC3, "bvec3" },
+ { TK_TYPE_BVEC4, "bvec4" },
+ { TK_TYPE_INT, "int" },
+ { TK_TYPE_IVEC2, "ivec2" },
+ { TK_TYPE_IVEC3, "ivec3" },
+ { TK_TYPE_IVEC4, "ivec4" },
+ { TK_TYPE_UINT, "uint" },
+ { TK_TYPE_UVEC2, "uvec2" },
+ { TK_TYPE_UVEC3, "uvec3" },
+ { TK_TYPE_UVEC4, "uvec4" },
+ { TK_TYPE_FLOAT, "float" },
+ { TK_TYPE_VEC2, "vec2" },
+ { TK_TYPE_VEC3, "vec3" },
+ { TK_TYPE_VEC4, "vec4" },
+ { TK_TYPE_MAT2, "mat2" },
+ { TK_TYPE_MAT3, "mat3" },
+ { TK_TYPE_MAT4, "mat4" },
+ { TK_TYPE_SAMPLER2D, "sampler2D" },
+ { TK_TYPE_ISAMPLER2D, "isampler2D" },
+ { TK_TYPE_USAMPLER2D, "usampler2D" },
+ { TK_TYPE_SAMPLERCUBE, "samplerCube" },
+ { TK_PRECISION_LOW, "lowp" },
+ { TK_PRECISION_MID, "mediump" },
+ { TK_PRECISION_HIGH, "highp" },
+ { TK_CF_IF, "if" },
+ { TK_CF_ELSE, "else" },
+ { TK_CF_FOR, "for" },
+ { TK_CF_WHILE, "while" },
+ { TK_CF_DO, "do" },
+ { TK_CF_SWITCH, "switch" },
+ { TK_CF_CASE, "case" },
+ { TK_CF_BREAK, "break" },
+ { TK_CF_CONTINUE, "continue" },
+ { TK_CF_RETURN, "return" },
+ { TK_UNIFORM, "uniform" },
+ { TK_VARYING, "varying" },
+ { TK_RENDER_MODE, "render_mode" },
+ { TK_HINT_WHITE_TEXTURE, "hint_white" },
+ { TK_HINT_BLACK_TEXTURE, "hint_black" },
+ { TK_HINT_NORMAL_TEXTURE, "hint_normal" },
+ { TK_HINT_ANISO_TEXTURE, "hint_aniso" },
+ { TK_HINT_ALBEDO_TEXTURE, "hint_albedo" },
+ { TK_HINT_BLACK_ALBEDO_TEXTURE, "hint_black_albedo" },
+ { TK_HINT_COLOR, "hint_color" },
+ { TK_HINT_RANGE, "hint_range" },
+
+ { TK_ERROR, NULL }
};
-
-
ShaderLanguage::Token ShaderLanguage::_get_token() {
-#define GETCHAR(m_idx) (((char_idx+m_idx)<code.length())?code[char_idx+m_idx]:CharType(0))
+#define GETCHAR(m_idx) (((char_idx + m_idx) < code.length()) ? code[char_idx + m_idx] : CharType(0))
- while(true) {
+ while (true) {
char_idx++;
- switch(GETCHAR(-1)) {
+ switch (GETCHAR(-1)) {
case 0:
return _make_token(TK_EOF);
@@ -297,17 +292,18 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
continue;
case '/': {
- switch(GETCHAR(0)) {
+ switch (GETCHAR(0)) {
case '*': { // block comment
char_idx++;
- while(true) {
- if (GETCHAR(0)==0) {
+ while (true) {
+ if (GETCHAR(0) == 0) {
return _make_token(TK_EOF);
- } if (GETCHAR(0)=='*' && GETCHAR(1)=='/') {
- char_idx+=2;
+ }
+ if (GETCHAR(0) == '*' && GETCHAR(1) == '/') {
+ char_idx += 2;
break;
- } else if (GETCHAR(0)=='\n') {
+ } else if (GETCHAR(0) == '\n') {
tk_line++;
}
@@ -317,13 +313,12 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '/': { // line comment skip
-
- while(true) {
- if (GETCHAR(0)=='\n') {
+ while (true) {
+ if (GETCHAR(0) == '\n') {
char_idx++;
break;
}
- if (GETCHAR(0)==0) {
+ if (GETCHAR(0) == 0) {
return _make_token(TK_EOF);
}
char_idx++;
@@ -344,7 +339,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '=': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_EQUAL);
}
@@ -353,12 +348,12 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '<': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_LESS_EQUAL);
- } else if (GETCHAR(0)=='<') {
+ } else if (GETCHAR(0) == '<') {
char_idx++;
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_SHIFT_LEFT);
}
@@ -370,12 +365,12 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '>': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_GREATER_EQUAL);
- } else if (GETCHAR(0)=='<') {
+ } else if (GETCHAR(0) == '<') {
char_idx++;
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_SHIFT_RIGHT);
}
@@ -387,7 +382,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '!': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_NOT_EQUAL);
}
@@ -422,10 +417,10 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
case '~':
return _make_token(TK_OP_BIT_INVERT);
case '&': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_BIT_AND);
- } else if (GETCHAR(0)=='&') {
+ } else if (GETCHAR(0) == '&') {
char_idx++;
return _make_token(TK_OP_AND);
}
@@ -433,10 +428,10 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '|': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_BIT_OR);
- } else if (GETCHAR(0)=='|') {
+ } else if (GETCHAR(0) == '|') {
char_idx++;
return _make_token(TK_OP_OR);
}
@@ -445,7 +440,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '*': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_MUL);
}
@@ -453,10 +448,10 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '+': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_ADD);
- } else if (GETCHAR(0)=='+') {
+ } else if (GETCHAR(0) == '+') {
char_idx++;
return _make_token(TK_OP_INCREMENT);
@@ -466,10 +461,10 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '-': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_SUB);
- }else if (GETCHAR(0)=='-') {
+ } else if (GETCHAR(0) == '-') {
char_idx++;
return _make_token(TK_OP_DECREMENT);
@@ -479,7 +474,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '%': {
- if (GETCHAR(0)=='=') {
+ if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_MOD);
}
@@ -490,69 +485,68 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
char_idx--; //go back one, since we have no idea what this is
- if (_is_number(GETCHAR(0)) || (GETCHAR(0)=='.' && _is_number(GETCHAR(1)))) {
+ if (_is_number(GETCHAR(0)) || (GETCHAR(0) == '.' && _is_number(GETCHAR(1)))) {
// parse number
- bool period_found=false;
- bool exponent_found=false;
- bool hexa_found=false;
- bool sign_found=false;
- bool minus_exponent_found=false;
+ bool period_found = false;
+ bool exponent_found = false;
+ bool hexa_found = false;
+ bool sign_found = false;
+ bool minus_exponent_found = false;
String str;
- int i=0;
+ int i = 0;
- while(true) {
- if (GETCHAR(i)=='.') {
+ while (true) {
+ if (GETCHAR(i) == '.') {
if (period_found || exponent_found)
- return _make_token(TK_ERROR,"Invalid numeric constant");
- period_found=true;
- } else if (GETCHAR(i)=='x') {
- if (hexa_found || str.length()!=1 || str[0]!='0')
- return _make_token(TK_ERROR,"Invalid numeric constant");
- hexa_found=true;
- } else if (GETCHAR(i)=='e') {
+ return _make_token(TK_ERROR, "Invalid numeric constant");
+ period_found = true;
+ } else if (GETCHAR(i) == 'x') {
+ if (hexa_found || str.length() != 1 || str[0] != '0')
+ return _make_token(TK_ERROR, "Invalid numeric constant");
+ hexa_found = true;
+ } else if (GETCHAR(i) == 'e') {
if (hexa_found || exponent_found)
- return _make_token(TK_ERROR,"Invalid numeric constant");
- exponent_found=true;
+ return _make_token(TK_ERROR, "Invalid numeric constant");
+ exponent_found = true;
} else if (_is_number(GETCHAR(i))) {
//all ok
} else if (hexa_found && _is_hex(GETCHAR(i))) {
- } else if ((GETCHAR(i)=='-' || GETCHAR(i)=='+') && exponent_found) {
+ } else if ((GETCHAR(i) == '-' || GETCHAR(i) == '+') && exponent_found) {
if (sign_found)
- return _make_token(TK_ERROR,"Invalid numeric constant");
- sign_found=true;
- if (GETCHAR(i)=='-')
- minus_exponent_found=true;
+ return _make_token(TK_ERROR, "Invalid numeric constant");
+ sign_found = true;
+ if (GETCHAR(i) == '-')
+ minus_exponent_found = true;
} else
break;
- str+=CharType(GETCHAR(i));
+ str += CharType(GETCHAR(i));
i++;
}
- if (!_is_number(str[str.length()-1]))
- return _make_token(TK_ERROR,"Invalid numeric constant");
+ if (!_is_number(str[str.length() - 1]))
+ return _make_token(TK_ERROR, "Invalid numeric constant");
- char_idx+=str.length();
+ char_idx += str.length();
Token tk;
if (period_found || minus_exponent_found)
- tk.type=TK_REAL_CONSTANT;
+ tk.type = TK_REAL_CONSTANT;
else
- tk.type=TK_INT_CONSTANT;
+ tk.type = TK_INT_CONSTANT;
if (!str.is_valid_float()) {
- return _make_token(TK_ERROR,"Invalid numeric constant");
+ return _make_token(TK_ERROR, "Invalid numeric constant");
}
- tk.constant=str.to_double();
- tk.line=tk_line;
+ tk.constant = str.to_double();
+ tk.line = tk_line;
return tk;
-
}
- if (GETCHAR(0)=='.') {
+ if (GETCHAR(0) == '.') {
//parse period
char_idx++;
return _make_token(TK_PERIOD);
@@ -562,33 +556,32 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
// parse identifier
String str;
- while(_is_text_char(GETCHAR(0))) {
+ while (_is_text_char(GETCHAR(0))) {
- str+=CharType(GETCHAR(0));
+ str += CharType(GETCHAR(0));
char_idx++;
}
//see if keyword
//should be converted to a static map
- int idx=0;
+ int idx = 0;
- while(keyword_list[idx].text) {
+ while (keyword_list[idx].text) {
- if (str==keyword_list[idx].text) {
+ if (str == keyword_list[idx].text) {
return _make_token(keyword_list[idx].token);
}
idx++;
}
-
- return _make_token(TK_IDENTIFIER,str);
+ return _make_token(TK_IDENTIFIER, str);
}
- if (GETCHAR(0)>32)
- return _make_token(TK_ERROR,"Tokenizer: Unknown character #"+itos(GETCHAR(0))+": '"+String::chr(GETCHAR(0))+"'");
+ if (GETCHAR(0) > 32)
+ return _make_token(TK_ERROR, "Tokenizer: Unknown character #" + itos(GETCHAR(0)) + ": '" + String::chr(GETCHAR(0)) + "'");
else
- return _make_token(TK_ERROR,"Tokenizer: Unknown character #"+itos(GETCHAR(0)));
+ return _make_token(TK_ERROR, "Tokenizer: Unknown character #" + itos(GETCHAR(0)));
} break;
}
@@ -597,85 +590,79 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
return Token();
}
-
-String ShaderLanguage::token_debug(const String& p_code) {
+String ShaderLanguage::token_debug(const String &p_code) {
clear();
- code=p_code;
+ code = p_code;
String output;
Token tk = _get_token();
- while(tk.type!=TK_EOF && tk.type!=TK_ERROR) {
+ while (tk.type != TK_EOF && tk.type != TK_ERROR) {
- output+=itos(tk_line)+": "+get_token_text(tk)+"\n";
+ output += itos(tk_line) + ": " + get_token_text(tk) + "\n";
tk = _get_token();
}
return output;
-
}
bool ShaderLanguage::is_token_datatype(TokenType p_type) {
return (
- p_type==TK_TYPE_VOID ||
- p_type==TK_TYPE_BOOL ||
- p_type==TK_TYPE_BVEC2 ||
- p_type==TK_TYPE_BVEC3 ||
- p_type==TK_TYPE_BVEC4 ||
- p_type==TK_TYPE_INT ||
- p_type==TK_TYPE_IVEC2 ||
- p_type==TK_TYPE_IVEC3 ||
- p_type==TK_TYPE_IVEC4 ||
- p_type==TK_TYPE_UINT ||
- p_type==TK_TYPE_UVEC2 ||
- p_type==TK_TYPE_UVEC3 ||
- p_type==TK_TYPE_UVEC4 ||
- p_type==TK_TYPE_FLOAT ||
- p_type==TK_TYPE_VEC2 ||
- p_type==TK_TYPE_VEC3 ||
- p_type==TK_TYPE_VEC4 ||
- p_type==TK_TYPE_MAT2 ||
- p_type==TK_TYPE_MAT3 ||
- p_type==TK_TYPE_MAT4 ||
- p_type==TK_TYPE_SAMPLER2D ||
- p_type==TK_TYPE_ISAMPLER2D ||
- p_type==TK_TYPE_USAMPLER2D ||
- p_type==TK_TYPE_SAMPLERCUBE );
-
+ p_type == TK_TYPE_VOID ||
+ p_type == TK_TYPE_BOOL ||
+ p_type == TK_TYPE_BVEC2 ||
+ p_type == TK_TYPE_BVEC3 ||
+ p_type == TK_TYPE_BVEC4 ||
+ p_type == TK_TYPE_INT ||
+ p_type == TK_TYPE_IVEC2 ||
+ p_type == TK_TYPE_IVEC3 ||
+ p_type == TK_TYPE_IVEC4 ||
+ p_type == TK_TYPE_UINT ||
+ p_type == TK_TYPE_UVEC2 ||
+ p_type == TK_TYPE_UVEC3 ||
+ p_type == TK_TYPE_UVEC4 ||
+ p_type == TK_TYPE_FLOAT ||
+ p_type == TK_TYPE_VEC2 ||
+ p_type == TK_TYPE_VEC3 ||
+ p_type == TK_TYPE_VEC4 ||
+ p_type == TK_TYPE_MAT2 ||
+ p_type == TK_TYPE_MAT3 ||
+ p_type == TK_TYPE_MAT4 ||
+ p_type == TK_TYPE_SAMPLER2D ||
+ p_type == TK_TYPE_ISAMPLER2D ||
+ p_type == TK_TYPE_USAMPLER2D ||
+ p_type == TK_TYPE_SAMPLERCUBE);
}
ShaderLanguage::DataType ShaderLanguage::get_token_datatype(TokenType p_type) {
- return DataType(p_type-TK_TYPE_VOID);
+ return DataType(p_type - TK_TYPE_VOID);
}
-
bool ShaderLanguage::is_token_precision(TokenType p_type) {
return (
- p_type==TK_PRECISION_LOW ||
- p_type==TK_PRECISION_MID ||
- p_type==TK_PRECISION_HIGH );
-
+ p_type == TK_PRECISION_LOW ||
+ p_type == TK_PRECISION_MID ||
+ p_type == TK_PRECISION_HIGH);
}
ShaderLanguage::DataPrecision ShaderLanguage::get_token_precision(TokenType p_type) {
- if (p_type==TK_PRECISION_LOW)
+ if (p_type == TK_PRECISION_LOW)
return PRECISION_LOWP;
- else if (p_type==TK_PRECISION_HIGH)
+ else if (p_type == TK_PRECISION_HIGH)
return PRECISION_HIGHP;
else
return PRECISION_MEDIUMP;
}
-
String ShaderLanguage::get_datatype_name(DataType p_type) {
- switch(p_type) {
+ switch (p_type) {
case TYPE_VOID: return "void";
case TYPE_BOOL: return "bool";
@@ -706,83 +693,77 @@ String ShaderLanguage::get_datatype_name(DataType p_type) {
return "";
}
-
bool ShaderLanguage::is_token_nonvoid_datatype(TokenType p_type) {
- return is_token_datatype(p_type) && p_type!=TK_TYPE_VOID;
-
+ return is_token_datatype(p_type) && p_type != TK_TYPE_VOID;
}
-
void ShaderLanguage::clear() {
- current_function=StringName();
+ current_function = StringName();
- completion_type=COMPLETION_NONE;
- completion_block=NULL;
- completion_function=StringName();
+ completion_type = COMPLETION_NONE;
+ completion_block = NULL;
+ completion_function = StringName();
- error_line=0;
- tk_line=1;
- char_idx=0;
- error_set=false;
- error_str="";
- while(nodes) {
+ error_line = 0;
+ tk_line = 1;
+ char_idx = 0;
+ error_set = false;
+ error_str = "";
+ while (nodes) {
Node *n = nodes;
- nodes=nodes->next;
+ nodes = nodes->next;
memdelete(n);
}
-
}
-
-bool ShaderLanguage::_find_identifier(const BlockNode* p_block,const Map<StringName, DataType> &p_builtin_types,const StringName& p_identifier, DataType *r_data_type, IdentifierType *r_type) {
-
+bool ShaderLanguage::_find_identifier(const BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type, IdentifierType *r_type) {
if (p_builtin_types.has(p_identifier)) {
if (r_data_type) {
- *r_data_type=p_builtin_types[p_identifier];
+ *r_data_type = p_builtin_types[p_identifier];
}
if (r_type) {
- *r_type=IDENTIFIER_BUILTIN_VAR;
+ *r_type = IDENTIFIER_BUILTIN_VAR;
}
return true;
}
- FunctionNode *function=NULL;
+ FunctionNode *function = NULL;
- while(p_block) {
+ while (p_block) {
if (p_block->variables.has(p_identifier)) {
if (r_data_type) {
- *r_data_type=p_block->variables[p_identifier].type;
+ *r_data_type = p_block->variables[p_identifier].type;
}
if (r_type) {
- *r_type=IDENTIFIER_LOCAL_VAR;
+ *r_type = IDENTIFIER_LOCAL_VAR;
}
return true;
}
if (p_block->parent_function) {
- function=p_block->parent_function;
+ function = p_block->parent_function;
break;
} else {
- ERR_FAIL_COND_V(!p_block->parent_block,false);
- p_block=p_block->parent_block;
+ ERR_FAIL_COND_V(!p_block->parent_block, false);
+ p_block = p_block->parent_block;
}
}
if (function) {
- for(int i=0;i<function->arguments.size();i++) {
- if (function->arguments[i].name==p_identifier) {
+ for (int i = 0; i < function->arguments.size(); i++) {
+ if (function->arguments[i].name == p_identifier) {
if (r_data_type) {
- *r_data_type=function->arguments[i].type;
+ *r_data_type = function->arguments[i].type;
}
if (r_type) {
- *r_type=IDENTIFIER_FUNCTION_ARGUMENT;
+ *r_type = IDENTIFIER_FUNCTION_ARGUMENT;
}
return true;
@@ -790,59 +771,56 @@ bool ShaderLanguage::_find_identifier(const BlockNode* p_block,const Map<StringN
}
}
-
if (shader->varyings.has(p_identifier)) {
if (r_data_type) {
- *r_data_type=shader->varyings[p_identifier].type;
+ *r_data_type = shader->varyings[p_identifier].type;
}
if (r_type) {
- *r_type=IDENTIFIER_VARYING;
+ *r_type = IDENTIFIER_VARYING;
}
return true;
}
if (shader->uniforms.has(p_identifier)) {
if (r_data_type) {
- *r_data_type=shader->uniforms[p_identifier].type;
+ *r_data_type = shader->uniforms[p_identifier].type;
}
if (r_type) {
- *r_type=IDENTIFIER_UNIFORM;
+ *r_type = IDENTIFIER_UNIFORM;
}
return true;
}
- for(int i=0;i<shader->functions.size();i++) {
+ for (int i = 0; i < shader->functions.size(); i++) {
if (!shader->functions[i].callable)
continue;
- if (shader->functions[i].name==p_identifier) {
+ if (shader->functions[i].name == p_identifier) {
if (r_data_type) {
- *r_data_type=shader->functions[i].function->return_type;
+ *r_data_type = shader->functions[i].function->return_type;
}
if (r_type) {
- *r_type=IDENTIFIER_FUNCTION;
+ *r_type = IDENTIFIER_FUNCTION;
}
}
}
return false;
-
}
+bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type) {
-bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type) {
-
- bool valid=false;
+ bool valid = false;
DataType ret_type;
- switch(p_op->op) {
+ switch (p_op->op) {
case OP_EQUAL:
case OP_NOT_EQUAL: {
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
- valid=na==nb;
- ret_type=TYPE_BOOL;
+ valid = na == nb;
+ ret_type = TYPE_BOOL;
} break;
case OP_LESS:
case OP_LESS_EQUAL:
@@ -851,8 +829,8 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
- valid = na==nb && (na==TYPE_UINT || na==TYPE_INT || na==TYPE_FLOAT);
- ret_type=TYPE_BOOL;
+ valid = na == nb && (na == TYPE_UINT || na == TYPE_INT || na == TYPE_FLOAT);
+ ret_type = TYPE_BOOL;
} break;
case OP_AND:
@@ -860,15 +838,15 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
- valid = na==nb && na==TYPE_BOOL;
- ret_type=TYPE_BOOL;
+ valid = na == nb && na == TYPE_BOOL;
+ ret_type = TYPE_BOOL;
} break;
case OP_NOT: {
DataType na = p_op->arguments[0]->get_datatype();
- valid = na==TYPE_BOOL;
- ret_type=TYPE_BOOL;
+ valid = na == TYPE_BOOL;
+ ret_type = TYPE_BOOL;
} break;
case OP_INCREMENT:
@@ -877,8 +855,8 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
case OP_POST_DECREMENT:
case OP_NEGATE: {
DataType na = p_op->arguments[0]->get_datatype();
- valid = na>TYPE_BOOL && na<TYPE_MAT2;
- ret_type=na;
+ valid = na > TYPE_BOOL && na < TYPE_MAT2;
+ ret_type = na;
} break;
case OP_ADD:
case OP_SUB:
@@ -887,50 +865,50 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
- if (na>nb) {
+ if (na > nb) {
//make things easier;
- SWAP(na,nb);
- }
-
- if (na==nb) {
- valid = (na>TYPE_BOOL && na<TYPE_MAT2) || (p_op->op==OP_MUL && na>=TYPE_MAT2 && na<=TYPE_MAT4);
- ret_type=na;
- } else if (na==TYPE_INT && nb==TYPE_IVEC2) {
- valid=true;
- ret_type=TYPE_IVEC2;
- } else if (na==TYPE_INT && nb==TYPE_IVEC3) {
- valid=true;
- ret_type=TYPE_IVEC3;
- } else if (na==TYPE_INT && nb==TYPE_IVEC4) {
- valid=true;
- ret_type=TYPE_IVEC4;
- } else if (na==TYPE_UINT && nb==TYPE_UVEC2) {
- valid=true;
- ret_type=TYPE_UVEC2;
- } else if (na==TYPE_UINT && nb==TYPE_UVEC3) {
- valid=true;
- ret_type=TYPE_UVEC3;
- } else if (na==TYPE_UINT && nb==TYPE_UVEC4) {
- valid=true;
- ret_type=TYPE_UVEC4;
- } else if (na==TYPE_FLOAT && nb==TYPE_VEC2) {
- valid=true;
- ret_type=TYPE_VEC2;
- } else if (na==TYPE_FLOAT && nb==TYPE_VEC3) {
- valid=true;
- ret_type=TYPE_VEC3;
- } else if (na==TYPE_FLOAT && nb==TYPE_VEC4) {
- valid=true;
- ret_type=TYPE_VEC4;
- } else if (p_op->op==OP_MUL && na==TYPE_VEC2 && nb==TYPE_MAT2) {
- valid=true;
- ret_type=TYPE_MAT2;
- } else if (p_op->op==OP_MUL && na==TYPE_VEC3 && nb==TYPE_MAT3) {
- valid=true;
- ret_type=TYPE_MAT3;
- } else if (p_op->op==OP_MUL && na==TYPE_VEC4 && nb==TYPE_MAT4) {
- valid=true;
- ret_type=TYPE_MAT4;
+ SWAP(na, nb);
+ }
+
+ if (na == nb) {
+ valid = (na > TYPE_BOOL && na < TYPE_MAT2) || (p_op->op == OP_MUL && na >= TYPE_MAT2 && na <= TYPE_MAT4);
+ ret_type = na;
+ } else if (na == TYPE_INT && nb == TYPE_IVEC2) {
+ valid = true;
+ ret_type = TYPE_IVEC2;
+ } else if (na == TYPE_INT && nb == TYPE_IVEC3) {
+ valid = true;
+ ret_type = TYPE_IVEC3;
+ } else if (na == TYPE_INT && nb == TYPE_IVEC4) {
+ valid = true;
+ ret_type = TYPE_IVEC4;
+ } else if (na == TYPE_UINT && nb == TYPE_UVEC2) {
+ valid = true;
+ ret_type = TYPE_UVEC2;
+ } else if (na == TYPE_UINT && nb == TYPE_UVEC3) {
+ valid = true;
+ ret_type = TYPE_UVEC3;
+ } else if (na == TYPE_UINT && nb == TYPE_UVEC4) {
+ valid = true;
+ ret_type = TYPE_UVEC4;
+ } else if (na == TYPE_FLOAT && nb == TYPE_VEC2) {
+ valid = true;
+ ret_type = TYPE_VEC2;
+ } else if (na == TYPE_FLOAT && nb == TYPE_VEC3) {
+ valid = true;
+ ret_type = TYPE_VEC3;
+ } else if (na == TYPE_FLOAT && nb == TYPE_VEC4) {
+ valid = true;
+ ret_type = TYPE_VEC4;
+ } else if (p_op->op == OP_MUL && na == TYPE_VEC2 && nb == TYPE_MAT2) {
+ valid = true;
+ ret_type = TYPE_MAT2;
+ } else if (p_op->op == OP_MUL && na == TYPE_VEC3 && nb == TYPE_MAT3) {
+ valid = true;
+ ret_type = TYPE_MAT3;
+ } else if (p_op->op == OP_MUL && na == TYPE_VEC4 && nb == TYPE_MAT4) {
+ valid = true;
+ ret_type = TYPE_MAT4;
}
} break;
case OP_ASSIGN_MOD:
@@ -946,50 +924,49 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
-
- if (na==TYPE_INT && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_INT;
- } else if (na==TYPE_IVEC2 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC2;
- } else if (na==TYPE_IVEC3 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC3;
- } else if (na==TYPE_IVEC4 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC4;
- } else if (na==TYPE_IVEC2 && nb==TYPE_IVEC2) {
- valid=true;
- ret_type=TYPE_IVEC2;
- } else if (na==TYPE_IVEC3 && nb==TYPE_IVEC3) {
- valid=true;
- ret_type=TYPE_IVEC3;
- } else if (na==TYPE_IVEC4 && nb==TYPE_IVEC4) {
- valid=true;
- ret_type=TYPE_IVEC4;
- /////
- } else if (na==TYPE_UINT && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UINT;
- } else if (na==TYPE_UVEC2 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC2;
- } else if (na==TYPE_UVEC3 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC3;
- } else if (na==TYPE_UVEC4 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC4;
- } else if (na==TYPE_UVEC2 && nb==TYPE_UVEC2) {
- valid=true;
- ret_type=TYPE_UVEC2;
- } else if (na==TYPE_UVEC3 && nb==TYPE_UVEC3) {
- valid=true;
- ret_type=TYPE_UVEC3;
- } else if (na==TYPE_UVEC4 && nb==TYPE_UVEC4) {
- valid=true;
- ret_type=TYPE_UVEC4;
+ if (na == TYPE_INT && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_INT;
+ } else if (na == TYPE_IVEC2 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC2;
+ } else if (na == TYPE_IVEC3 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC3;
+ } else if (na == TYPE_IVEC4 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC4;
+ } else if (na == TYPE_IVEC2 && nb == TYPE_IVEC2) {
+ valid = true;
+ ret_type = TYPE_IVEC2;
+ } else if (na == TYPE_IVEC3 && nb == TYPE_IVEC3) {
+ valid = true;
+ ret_type = TYPE_IVEC3;
+ } else if (na == TYPE_IVEC4 && nb == TYPE_IVEC4) {
+ valid = true;
+ ret_type = TYPE_IVEC4;
+ /////
+ } else if (na == TYPE_UINT && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UINT;
+ } else if (na == TYPE_UVEC2 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC2;
+ } else if (na == TYPE_UVEC3 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC3;
+ } else if (na == TYPE_UVEC4 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC4;
+ } else if (na == TYPE_UVEC2 && nb == TYPE_UVEC2) {
+ valid = true;
+ ret_type = TYPE_UVEC2;
+ } else if (na == TYPE_UVEC3 && nb == TYPE_UVEC3) {
+ valid = true;
+ ret_type = TYPE_UVEC3;
+ } else if (na == TYPE_UVEC4 && nb == TYPE_UVEC4) {
+ valid = true;
+ ret_type = TYPE_UVEC4;
}
} break;
case OP_ASSIGN_SHIFT_LEFT:
@@ -1000,42 +977,42 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
- if (na>=TYPE_UINT && na<=TYPE_UVEC4) {
- na=DataType(na-4);
- }
-
- if (nb>=TYPE_UINT && nb<=TYPE_UVEC4) {
- nb=DataType(nb-4);
- }
-
- if (na==TYPE_INT && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_INT;
- } else if (na==TYPE_IVEC2 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC2;
- } else if (na==TYPE_IVEC3 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC3;
- } else if (na==TYPE_IVEC4 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC4;
- } else if (na==TYPE_IVEC2 && nb==TYPE_IVEC2) {
- valid=true;
- ret_type=TYPE_IVEC2;
- } else if (na==TYPE_IVEC3 && nb==TYPE_IVEC3) {
- valid=true;
- ret_type=TYPE_IVEC3;
- } else if (na==TYPE_IVEC4 && nb==TYPE_IVEC4) {
- valid=true;
- ret_type=TYPE_IVEC4;
+ if (na >= TYPE_UINT && na <= TYPE_UVEC4) {
+ na = DataType(na - 4);
+ }
+
+ if (nb >= TYPE_UINT && nb <= TYPE_UVEC4) {
+ nb = DataType(nb - 4);
+ }
+
+ if (na == TYPE_INT && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_INT;
+ } else if (na == TYPE_IVEC2 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC2;
+ } else if (na == TYPE_IVEC3 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC3;
+ } else if (na == TYPE_IVEC4 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC4;
+ } else if (na == TYPE_IVEC2 && nb == TYPE_IVEC2) {
+ valid = true;
+ ret_type = TYPE_IVEC2;
+ } else if (na == TYPE_IVEC3 && nb == TYPE_IVEC3) {
+ valid = true;
+ ret_type = TYPE_IVEC3;
+ } else if (na == TYPE_IVEC4 && nb == TYPE_IVEC4) {
+ valid = true;
+ ret_type = TYPE_IVEC4;
}
} break;
case OP_ASSIGN: {
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
- valid=na==nb;
- ret_type=na;
+ valid = na == nb;
+ ret_type = na;
} break;
case OP_ASSIGN_ADD:
case OP_ASSIGN_SUB:
@@ -1045,46 +1022,45 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
-
- if (na==nb) {
- valid = (na>TYPE_BOOL && na<TYPE_MAT2) || (p_op->op==OP_ASSIGN_MUL && na>=TYPE_MAT2 && na<=TYPE_MAT4);
- ret_type=na;
- } else if (na==TYPE_IVEC2 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC2;
- } else if (na==TYPE_IVEC3 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC3;
- } else if (na==TYPE_IVEC4 && nb==TYPE_INT ) {
- valid=true;
- ret_type=TYPE_IVEC4;
- } else if (na==TYPE_UVEC2 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC2;
- } else if (na==TYPE_UVEC3 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC3;
- } else if (na==TYPE_UVEC4 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC4;
- } else if (na==TYPE_VEC2 && nb==TYPE_FLOAT ) {
- valid=true;
- ret_type=TYPE_VEC2;
- } else if (na==TYPE_VEC3 && nb==TYPE_FLOAT) {
- valid=true;
- ret_type=TYPE_VEC3;
- } else if (na==TYPE_VEC4 && nb==TYPE_FLOAT) {
- valid=true;
- ret_type=TYPE_VEC4;
- } else if (p_op->op==OP_ASSIGN_MUL && na==TYPE_MAT2 && nb==TYPE_VEC2) {
- valid=true;
- ret_type=TYPE_MAT2;
- } else if (p_op->op==OP_ASSIGN_MUL && na==TYPE_MAT3 && nb==TYPE_VEC3) {
- valid=true;
- ret_type=TYPE_MAT3;
- } else if (p_op->op==OP_ASSIGN_MUL && na==TYPE_MAT4 && nb==TYPE_VEC4) {
- valid=true;
- ret_type=TYPE_MAT4;
+ if (na == nb) {
+ valid = (na > TYPE_BOOL && na < TYPE_MAT2) || (p_op->op == OP_ASSIGN_MUL && na >= TYPE_MAT2 && na <= TYPE_MAT4);
+ ret_type = na;
+ } else if (na == TYPE_IVEC2 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC2;
+ } else if (na == TYPE_IVEC3 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC3;
+ } else if (na == TYPE_IVEC4 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC4;
+ } else if (na == TYPE_UVEC2 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC2;
+ } else if (na == TYPE_UVEC3 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC3;
+ } else if (na == TYPE_UVEC4 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC4;
+ } else if (na == TYPE_VEC2 && nb == TYPE_FLOAT) {
+ valid = true;
+ ret_type = TYPE_VEC2;
+ } else if (na == TYPE_VEC3 && nb == TYPE_FLOAT) {
+ valid = true;
+ ret_type = TYPE_VEC3;
+ } else if (na == TYPE_VEC4 && nb == TYPE_FLOAT) {
+ valid = true;
+ ret_type = TYPE_VEC4;
+ } else if (p_op->op == OP_ASSIGN_MUL && na == TYPE_MAT2 && nb == TYPE_VEC2) {
+ valid = true;
+ ret_type = TYPE_MAT2;
+ } else if (p_op->op == OP_ASSIGN_MUL && na == TYPE_MAT3 && nb == TYPE_VEC3) {
+ valid = true;
+ ret_type = TYPE_MAT3;
+ } else if (p_op->op == OP_ASSIGN_MUL && na == TYPE_MAT4 && nb == TYPE_VEC4) {
+ valid = true;
+ ret_type = TYPE_MAT4;
}
} break;
case OP_ASSIGN_BIT_AND:
@@ -1105,68 +1081,68 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
- if (na>nb && p_op->op>=OP_BIT_AND) {
+ if (na > nb && p_op->op >= OP_BIT_AND) {
//can swap for non assign
- SWAP(na,nb);
- }
-
- if (na==TYPE_INT && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_INT;
- } else if (na==TYPE_IVEC2 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC2;
- } else if (na==TYPE_IVEC3 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC3;
- } else if (na==TYPE_IVEC4 && nb==TYPE_INT) {
- valid=true;
- ret_type=TYPE_IVEC4;
- } else if (na==TYPE_IVEC2 && nb==TYPE_IVEC2) {
- valid=true;
- ret_type=TYPE_IVEC2;
- } else if (na==TYPE_IVEC3 && nb==TYPE_IVEC3) {
- valid=true;
- ret_type=TYPE_IVEC3;
- } else if (na==TYPE_IVEC4 && nb==TYPE_IVEC4) {
- valid=true;
- ret_type=TYPE_IVEC4;
- /////
- } else if (na==TYPE_UINT && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UINT;
- } else if (na==TYPE_UVEC2 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC2;
- } else if (na==TYPE_UVEC3 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC3;
- } else if (na==TYPE_UVEC4 && nb==TYPE_UINT) {
- valid=true;
- ret_type=TYPE_UVEC4;
- } else if (na==TYPE_UVEC2 && nb==TYPE_UVEC2) {
- valid=true;
- ret_type=TYPE_UVEC2;
- } else if (na==TYPE_UVEC3 && nb==TYPE_UVEC3) {
- valid=true;
- ret_type=TYPE_UVEC3;
- } else if (na==TYPE_UVEC4 && nb==TYPE_UVEC4) {
- valid=true;
- ret_type=TYPE_UVEC4;
+ SWAP(na, nb);
+ }
+
+ if (na == TYPE_INT && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_INT;
+ } else if (na == TYPE_IVEC2 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC2;
+ } else if (na == TYPE_IVEC3 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC3;
+ } else if (na == TYPE_IVEC4 && nb == TYPE_INT) {
+ valid = true;
+ ret_type = TYPE_IVEC4;
+ } else if (na == TYPE_IVEC2 && nb == TYPE_IVEC2) {
+ valid = true;
+ ret_type = TYPE_IVEC2;
+ } else if (na == TYPE_IVEC3 && nb == TYPE_IVEC3) {
+ valid = true;
+ ret_type = TYPE_IVEC3;
+ } else if (na == TYPE_IVEC4 && nb == TYPE_IVEC4) {
+ valid = true;
+ ret_type = TYPE_IVEC4;
+ /////
+ } else if (na == TYPE_UINT && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UINT;
+ } else if (na == TYPE_UVEC2 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC2;
+ } else if (na == TYPE_UVEC3 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC3;
+ } else if (na == TYPE_UVEC4 && nb == TYPE_UINT) {
+ valid = true;
+ ret_type = TYPE_UVEC4;
+ } else if (na == TYPE_UVEC2 && nb == TYPE_UVEC2) {
+ valid = true;
+ ret_type = TYPE_UVEC2;
+ } else if (na == TYPE_UVEC3 && nb == TYPE_UVEC3) {
+ valid = true;
+ ret_type = TYPE_UVEC3;
+ } else if (na == TYPE_UVEC4 && nb == TYPE_UVEC4) {
+ valid = true;
+ ret_type = TYPE_UVEC4;
}
} break;
case OP_BIT_INVERT: { //unaries
DataType na = p_op->arguments[0]->get_datatype();
- valid = na>=TYPE_INT && na<TYPE_FLOAT;
- ret_type=na;
+ valid = na >= TYPE_INT && na < TYPE_FLOAT;
+ ret_type = na;
} break;
case OP_SELECT_IF: {
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
DataType nc = p_op->arguments[2]->get_datatype();
- valid = na==TYPE_BOOL && (nb==nc);
- ret_type=nb;
+ valid = na == TYPE_BOOL && (nb == nc);
+ ret_type = nb;
} break;
default: {
ERR_FAIL_V(false);
@@ -1174,653 +1150,640 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op,DataType *r_ret_type)
}
if (r_ret_type)
- *r_ret_type=ret_type;
+ *r_ret_type = ret_type;
return valid;
-
}
-const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[]={
+const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = {
//constructors
- {"bool",TYPE_BOOL,{TYPE_BOOL,TYPE_VOID}},
- {"bvec2",TYPE_BVEC2,{TYPE_BOOL,TYPE_VOID}},
- {"bvec2",TYPE_BVEC2,{TYPE_BOOL,TYPE_BOOL,TYPE_VOID}},
- {"bvec3",TYPE_BVEC3,{TYPE_BOOL,TYPE_VOID}},
- {"bvec3",TYPE_BVEC3,{TYPE_BOOL,TYPE_BOOL,TYPE_BOOL,TYPE_VOID}},
- {"bvec3",TYPE_BVEC3,{TYPE_BVEC2,TYPE_BOOL,TYPE_VOID}},
- {"bvec3",TYPE_BVEC3,{TYPE_BOOL,TYPE_BVEC2,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_BOOL,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_BOOL,TYPE_BOOL,TYPE_BOOL,TYPE_BOOL,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_BOOL,TYPE_BVEC2,TYPE_BOOL,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_BVEC2,TYPE_BOOL,TYPE_BOOL,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_BOOL,TYPE_BOOL,TYPE_BVEC2,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_BOOL,TYPE_BVEC3,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_BVEC3,TYPE_BOOL,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_BVEC2,TYPE_BVEC2,TYPE_VOID}},
-
-
- {"float",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"vec2",TYPE_VEC2,{TYPE_FLOAT,TYPE_VOID}},
- {"vec2",TYPE_VEC2,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"vec3",TYPE_VEC3,{TYPE_FLOAT,TYPE_VOID}},
- {"vec3",TYPE_VEC3,{TYPE_FLOAT,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"vec3",TYPE_VEC3,{TYPE_VEC2,TYPE_FLOAT,TYPE_VOID}},
- {"vec3",TYPE_VEC3,{TYPE_FLOAT,TYPE_VEC2,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_FLOAT,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_FLOAT,TYPE_FLOAT,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_FLOAT,TYPE_VEC2,TYPE_FLOAT,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_VEC2,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VEC2,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_FLOAT,TYPE_VEC3,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
-
- {"int",TYPE_INT,{TYPE_INT,TYPE_VOID}},
- {"ivec2",TYPE_IVEC2,{TYPE_INT,TYPE_VOID}},
- {"ivec2",TYPE_IVEC2,{TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"ivec3",TYPE_IVEC3,{TYPE_INT,TYPE_VOID}},
- {"ivec3",TYPE_IVEC3,{TYPE_INT,TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"ivec3",TYPE_IVEC3,{TYPE_IVEC2,TYPE_INT,TYPE_VOID}},
- {"ivec3",TYPE_IVEC3,{TYPE_INT,TYPE_IVEC2,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_INT,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_INT,TYPE_INT,TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_INT,TYPE_IVEC2,TYPE_INT,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_IVEC2,TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_INT,TYPE_INT,TYPE_IVEC2,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_INT,TYPE_IVEC3,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_IVEC3,TYPE_INT,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
-
- {"uint",TYPE_UINT,{TYPE_UINT,TYPE_VOID}},
- {"uvec2",TYPE_UVEC2,{TYPE_UINT,TYPE_VOID}},
- {"uvec2",TYPE_UVEC2,{TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"uvec3",TYPE_UVEC3,{TYPE_UINT,TYPE_VOID}},
- {"uvec3",TYPE_UVEC3,{TYPE_UINT,TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"uvec3",TYPE_UVEC3,{TYPE_UVEC2,TYPE_UINT,TYPE_VOID}},
- {"uvec3",TYPE_UVEC3,{TYPE_UINT,TYPE_UVEC2,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UINT,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UINT,TYPE_UINT,TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UINT,TYPE_UVEC2,TYPE_UINT,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UVEC2,TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UINT,TYPE_UINT,TYPE_UVEC2,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UINT,TYPE_UVEC3,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UVEC3,TYPE_UINT,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
-
- {"mat2",TYPE_MAT2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"mat3",TYPE_MAT3,{TYPE_VEC3,TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"mat4",TYPE_MAT4,{TYPE_VEC4,TYPE_VEC4,TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"mat2",TYPE_MAT2,{TYPE_FLOAT,TYPE_VOID}},
- {"mat3",TYPE_MAT3,{TYPE_FLOAT,TYPE_VOID}},
- {"mat4",TYPE_MAT4,{TYPE_FLOAT,TYPE_VOID}},
+ { "bool", TYPE_BOOL, { TYPE_BOOL, TYPE_VOID } },
+ { "bvec2", TYPE_BVEC2, { TYPE_BOOL, TYPE_VOID } },
+ { "bvec2", TYPE_BVEC2, { TYPE_BOOL, TYPE_BOOL, TYPE_VOID } },
+ { "bvec3", TYPE_BVEC3, { TYPE_BOOL, TYPE_VOID } },
+ { "bvec3", TYPE_BVEC3, { TYPE_BOOL, TYPE_BOOL, TYPE_BOOL, TYPE_VOID } },
+ { "bvec3", TYPE_BVEC3, { TYPE_BVEC2, TYPE_BOOL, TYPE_VOID } },
+ { "bvec3", TYPE_BVEC3, { TYPE_BOOL, TYPE_BVEC2, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_BOOL, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_BOOL, TYPE_BOOL, TYPE_BOOL, TYPE_BOOL, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_BOOL, TYPE_BVEC2, TYPE_BOOL, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_BVEC2, TYPE_BOOL, TYPE_BOOL, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_BOOL, TYPE_BOOL, TYPE_BVEC2, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_BOOL, TYPE_BVEC3, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_BVEC3, TYPE_BOOL, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_BVEC2, TYPE_BVEC2, TYPE_VOID } },
+
+ { "float", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "vec2", TYPE_VEC2, { TYPE_FLOAT, TYPE_VOID } },
+ { "vec2", TYPE_VEC2, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "vec3", TYPE_VEC3, { TYPE_FLOAT, TYPE_VOID } },
+ { "vec3", TYPE_VEC3, { TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "vec3", TYPE_VEC3, { TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
+ { "vec3", TYPE_VEC3, { TYPE_FLOAT, TYPE_VEC2, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_FLOAT, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_FLOAT, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_VEC2, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VEC2, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_FLOAT, TYPE_VEC3, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+
+ { "int", TYPE_INT, { TYPE_INT, TYPE_VOID } },
+ { "ivec2", TYPE_IVEC2, { TYPE_INT, TYPE_VOID } },
+ { "ivec2", TYPE_IVEC2, { TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "ivec3", TYPE_IVEC3, { TYPE_INT, TYPE_VOID } },
+ { "ivec3", TYPE_IVEC3, { TYPE_INT, TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "ivec3", TYPE_IVEC3, { TYPE_IVEC2, TYPE_INT, TYPE_VOID } },
+ { "ivec3", TYPE_IVEC3, { TYPE_INT, TYPE_IVEC2, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_INT, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_INT, TYPE_IVEC2, TYPE_INT, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_IVEC2, TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_INT, TYPE_INT, TYPE_IVEC2, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_INT, TYPE_IVEC3, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_IVEC3, TYPE_INT, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+
+ { "uint", TYPE_UINT, { TYPE_UINT, TYPE_VOID } },
+ { "uvec2", TYPE_UVEC2, { TYPE_UINT, TYPE_VOID } },
+ { "uvec2", TYPE_UVEC2, { TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "uvec3", TYPE_UVEC3, { TYPE_UINT, TYPE_VOID } },
+ { "uvec3", TYPE_UVEC3, { TYPE_UINT, TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "uvec3", TYPE_UVEC3, { TYPE_UVEC2, TYPE_UINT, TYPE_VOID } },
+ { "uvec3", TYPE_UVEC3, { TYPE_UINT, TYPE_UVEC2, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UINT, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UINT, TYPE_UINT, TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UINT, TYPE_UVEC2, TYPE_UINT, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UVEC2, TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UINT, TYPE_UINT, TYPE_UVEC2, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UINT, TYPE_UVEC3, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UVEC3, TYPE_UINT, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+
+ { "mat2", TYPE_MAT2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "mat3", TYPE_MAT3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "mat4", TYPE_MAT4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "mat2", TYPE_MAT2, { TYPE_FLOAT, TYPE_VOID } },
+ { "mat3", TYPE_MAT3, { TYPE_FLOAT, TYPE_VOID } },
+ { "mat4", TYPE_MAT4, { TYPE_FLOAT, TYPE_VOID } },
//conversion scalars
- {"int",TYPE_INT,{TYPE_BOOL,TYPE_VOID}},
- {"int",TYPE_INT,{TYPE_INT,TYPE_VOID}},
- {"int",TYPE_INT,{TYPE_UINT,TYPE_VOID}},
- {"int",TYPE_INT,{TYPE_FLOAT,TYPE_VOID}},
+ { "int", TYPE_INT, { TYPE_BOOL, TYPE_VOID } },
+ { "int", TYPE_INT, { TYPE_INT, TYPE_VOID } },
+ { "int", TYPE_INT, { TYPE_UINT, TYPE_VOID } },
+ { "int", TYPE_INT, { TYPE_FLOAT, TYPE_VOID } },
- {"float",TYPE_FLOAT,{TYPE_BOOL,TYPE_VOID}},
- {"float",TYPE_FLOAT,{TYPE_INT,TYPE_VOID}},
- {"float",TYPE_FLOAT,{TYPE_UINT,TYPE_VOID}},
- {"float",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
+ { "float", TYPE_FLOAT, { TYPE_BOOL, TYPE_VOID } },
+ { "float", TYPE_FLOAT, { TYPE_INT, TYPE_VOID } },
+ { "float", TYPE_FLOAT, { TYPE_UINT, TYPE_VOID } },
+ { "float", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
- {"uint",TYPE_UINT,{TYPE_BOOL,TYPE_VOID}},
- {"uint",TYPE_UINT,{TYPE_INT,TYPE_VOID}},
- {"uint",TYPE_UINT,{TYPE_UINT,TYPE_VOID}},
- {"uint",TYPE_UINT,{TYPE_FLOAT,TYPE_VOID}},
+ { "uint", TYPE_UINT, { TYPE_BOOL, TYPE_VOID } },
+ { "uint", TYPE_UINT, { TYPE_INT, TYPE_VOID } },
+ { "uint", TYPE_UINT, { TYPE_UINT, TYPE_VOID } },
+ { "uint", TYPE_UINT, { TYPE_FLOAT, TYPE_VOID } },
- {"bool",TYPE_BOOL,{TYPE_BOOL,TYPE_VOID}},
- {"bool",TYPE_BOOL,{TYPE_INT,TYPE_VOID}},
- {"bool",TYPE_BOOL,{TYPE_UINT,TYPE_VOID}},
- {"bool",TYPE_BOOL,{TYPE_FLOAT,TYPE_VOID}},
+ { "bool", TYPE_BOOL, { TYPE_BOOL, TYPE_VOID } },
+ { "bool", TYPE_BOOL, { TYPE_INT, TYPE_VOID } },
+ { "bool", TYPE_BOOL, { TYPE_UINT, TYPE_VOID } },
+ { "bool", TYPE_BOOL, { TYPE_FLOAT, TYPE_VOID } },
//conversion vectors
- {"ivec2",TYPE_IVEC2,{TYPE_BVEC2,TYPE_VOID}},
- {"ivec2",TYPE_IVEC2,{TYPE_IVEC2,TYPE_VOID}},
- {"ivec2",TYPE_IVEC2,{TYPE_UVEC2,TYPE_VOID}},
- {"ivec2",TYPE_IVEC2,{TYPE_VEC2,TYPE_VOID}},
-
- {"vec2",TYPE_VEC2,{TYPE_BVEC2,TYPE_VOID}},
- {"vec2",TYPE_VEC2,{TYPE_IVEC2,TYPE_VOID}},
- {"vec2",TYPE_VEC2,{TYPE_UVEC2,TYPE_VOID}},
- {"vec2",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
-
- {"uvec2",TYPE_UVEC2,{TYPE_BVEC2,TYPE_VOID}},
- {"uvec2",TYPE_UVEC2,{TYPE_IVEC2,TYPE_VOID}},
- {"uvec2",TYPE_UVEC2,{TYPE_UVEC2,TYPE_VOID}},
- {"uvec2",TYPE_UVEC2,{TYPE_VEC2,TYPE_VOID}},
-
- {"bvec2",TYPE_BVEC2,{TYPE_BVEC2,TYPE_VOID}},
- {"bvec2",TYPE_BVEC2,{TYPE_IVEC2,TYPE_VOID}},
- {"bvec2",TYPE_BVEC2,{TYPE_UVEC2,TYPE_VOID}},
- {"bvec2",TYPE_BVEC2,{TYPE_VEC2,TYPE_VOID}},
-
- {"ivec3",TYPE_IVEC3,{TYPE_BVEC3,TYPE_VOID}},
- {"ivec3",TYPE_IVEC3,{TYPE_IVEC3,TYPE_VOID}},
- {"ivec3",TYPE_IVEC3,{TYPE_UVEC3,TYPE_VOID}},
- {"ivec3",TYPE_IVEC3,{TYPE_VEC3,TYPE_VOID}},
-
- {"vec3",TYPE_VEC3,{TYPE_BVEC3,TYPE_VOID}},
- {"vec3",TYPE_VEC3,{TYPE_IVEC3,TYPE_VOID}},
- {"vec3",TYPE_VEC3,{TYPE_UVEC3,TYPE_VOID}},
- {"vec3",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
-
- {"uvec3",TYPE_UVEC3,{TYPE_BVEC3,TYPE_VOID}},
- {"uvec3",TYPE_UVEC3,{TYPE_IVEC3,TYPE_VOID}},
- {"uvec3",TYPE_UVEC3,{TYPE_UVEC3,TYPE_VOID}},
- {"uvec3",TYPE_UVEC3,{TYPE_VEC3,TYPE_VOID}},
-
- {"bvec3",TYPE_BVEC3,{TYPE_BVEC3,TYPE_VOID}},
- {"bvec3",TYPE_BVEC3,{TYPE_IVEC3,TYPE_VOID}},
- {"bvec3",TYPE_BVEC3,{TYPE_UVEC3,TYPE_VOID}},
- {"bvec3",TYPE_BVEC3,{TYPE_VEC3,TYPE_VOID}},
-
- {"ivec4",TYPE_IVEC4,{TYPE_BVEC4,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_IVEC4,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_UVEC4,TYPE_VOID}},
- {"ivec4",TYPE_IVEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"vec4",TYPE_VEC4,{TYPE_BVEC4,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_IVEC4,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_UVEC4,TYPE_VOID}},
- {"vec4",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"uvec4",TYPE_UVEC4,{TYPE_BVEC4,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_IVEC4,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_UVEC4,TYPE_VOID}},
- {"uvec4",TYPE_UVEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"bvec4",TYPE_BVEC4,{TYPE_BVEC4,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_IVEC4,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_UVEC4,TYPE_VOID}},
- {"bvec4",TYPE_BVEC4,{TYPE_VEC4,TYPE_VOID}},
+ { "ivec2", TYPE_IVEC2, { TYPE_BVEC2, TYPE_VOID } },
+ { "ivec2", TYPE_IVEC2, { TYPE_IVEC2, TYPE_VOID } },
+ { "ivec2", TYPE_IVEC2, { TYPE_UVEC2, TYPE_VOID } },
+ { "ivec2", TYPE_IVEC2, { TYPE_VEC2, TYPE_VOID } },
+
+ { "vec2", TYPE_VEC2, { TYPE_BVEC2, TYPE_VOID } },
+ { "vec2", TYPE_VEC2, { TYPE_IVEC2, TYPE_VOID } },
+ { "vec2", TYPE_VEC2, { TYPE_UVEC2, TYPE_VOID } },
+ { "vec2", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+
+ { "uvec2", TYPE_UVEC2, { TYPE_BVEC2, TYPE_VOID } },
+ { "uvec2", TYPE_UVEC2, { TYPE_IVEC2, TYPE_VOID } },
+ { "uvec2", TYPE_UVEC2, { TYPE_UVEC2, TYPE_VOID } },
+ { "uvec2", TYPE_UVEC2, { TYPE_VEC2, TYPE_VOID } },
+
+ { "bvec2", TYPE_BVEC2, { TYPE_BVEC2, TYPE_VOID } },
+ { "bvec2", TYPE_BVEC2, { TYPE_IVEC2, TYPE_VOID } },
+ { "bvec2", TYPE_BVEC2, { TYPE_UVEC2, TYPE_VOID } },
+ { "bvec2", TYPE_BVEC2, { TYPE_VEC2, TYPE_VOID } },
+
+ { "ivec3", TYPE_IVEC3, { TYPE_BVEC3, TYPE_VOID } },
+ { "ivec3", TYPE_IVEC3, { TYPE_IVEC3, TYPE_VOID } },
+ { "ivec3", TYPE_IVEC3, { TYPE_UVEC3, TYPE_VOID } },
+ { "ivec3", TYPE_IVEC3, { TYPE_VEC3, TYPE_VOID } },
+
+ { "vec3", TYPE_VEC3, { TYPE_BVEC3, TYPE_VOID } },
+ { "vec3", TYPE_VEC3, { TYPE_IVEC3, TYPE_VOID } },
+ { "vec3", TYPE_VEC3, { TYPE_UVEC3, TYPE_VOID } },
+ { "vec3", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+
+ { "uvec3", TYPE_UVEC3, { TYPE_BVEC3, TYPE_VOID } },
+ { "uvec3", TYPE_UVEC3, { TYPE_IVEC3, TYPE_VOID } },
+ { "uvec3", TYPE_UVEC3, { TYPE_UVEC3, TYPE_VOID } },
+ { "uvec3", TYPE_UVEC3, { TYPE_VEC3, TYPE_VOID } },
+
+ { "bvec3", TYPE_BVEC3, { TYPE_BVEC3, TYPE_VOID } },
+ { "bvec3", TYPE_BVEC3, { TYPE_IVEC3, TYPE_VOID } },
+ { "bvec3", TYPE_BVEC3, { TYPE_UVEC3, TYPE_VOID } },
+ { "bvec3", TYPE_BVEC3, { TYPE_VEC3, TYPE_VOID } },
+
+ { "ivec4", TYPE_IVEC4, { TYPE_BVEC4, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_IVEC4, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_UVEC4, TYPE_VOID } },
+ { "ivec4", TYPE_IVEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "vec4", TYPE_VEC4, { TYPE_BVEC4, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_IVEC4, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_UVEC4, TYPE_VOID } },
+ { "vec4", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "uvec4", TYPE_UVEC4, { TYPE_BVEC4, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_IVEC4, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_UVEC4, TYPE_VOID } },
+ { "uvec4", TYPE_UVEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "bvec4", TYPE_BVEC4, { TYPE_BVEC4, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_IVEC4, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_UVEC4, TYPE_VOID } },
+ { "bvec4", TYPE_BVEC4, { TYPE_VEC4, TYPE_VOID } },
//builtins - trigonometry
- {"sin",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"cos",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"tan",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"asin",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"acos",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"atan",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"atan2",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"sinh",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"cosh",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"tanh",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
+ { "sin", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "cos", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "tan", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "asin", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "acos", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "atan", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "atan2", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "sinh", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "cosh", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "tanh", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
//builtins - exponential
- {"pow",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"pow",TYPE_VEC2,{TYPE_VEC2,TYPE_FLOAT,TYPE_VOID}},
- {"pow",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"pow",TYPE_VEC3,{TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"pow",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"pow",TYPE_VEC4,{TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
- {"pow",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
- {"exp",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"exp",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"exp",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"exp",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
- {"log",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"log",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"log",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"log",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
- {"sqrt",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"sqrt",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"sqrt",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"sqrt",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
+ { "pow", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "pow", TYPE_VEC2, { TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
+ { "pow", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "pow", TYPE_VEC3, { TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "pow", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "pow", TYPE_VEC4, { TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+ { "pow", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+ { "exp", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "exp", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "exp", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "exp", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+ { "log", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "log", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "log", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "log", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+ { "sqrt", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "sqrt", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "sqrt", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "sqrt", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
//builtins - common
- {"abs",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"abs",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"abs",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"abs",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"abs",TYPE_INT,{TYPE_INT,TYPE_VOID}},
- {"abs",TYPE_IVEC2,{TYPE_IVEC2,TYPE_VOID}},
- {"abs",TYPE_IVEC3,{TYPE_IVEC3,TYPE_VOID}},
- {"abs",TYPE_IVEC4,{TYPE_IVEC4,TYPE_VOID}},
-
- {"abs",TYPE_UINT,{TYPE_UINT,TYPE_VOID}},
- {"abs",TYPE_UVEC2,{TYPE_UVEC2,TYPE_VOID}},
- {"abs",TYPE_UVEC3,{TYPE_UVEC3,TYPE_VOID}},
- {"abs",TYPE_UVEC4,{TYPE_UVEC4,TYPE_VOID}},
-
-
- {"sign",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"sign",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"sign",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"sign",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"sign",TYPE_INT,{TYPE_INT,TYPE_VOID}},
- {"sign",TYPE_IVEC2,{TYPE_IVEC2,TYPE_VOID}},
- {"sign",TYPE_IVEC3,{TYPE_IVEC3,TYPE_VOID}},
- {"sign",TYPE_IVEC4,{TYPE_IVEC4,TYPE_VOID}},
-
-
- {"floor",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"floor",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"floor",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"floor",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
- {"trunc",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"trunc",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"trunc",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"trunc",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
- {"round",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"round",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"round",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"round",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
- {"ceil",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"ceil",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"ceil",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"ceil",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
- {"fract",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"fract",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"fract",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"fract",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"mod",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"mod",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"mod",TYPE_VEC2,{TYPE_VEC2,TYPE_FLOAT,TYPE_VOID}},
- {"mod",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"mod",TYPE_VEC3,{TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"mod",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
- {"mod",TYPE_VEC4,{TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
-
- {"modf",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"modf",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"modf",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"modf",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"min",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"min",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"min",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"min",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"min",TYPE_INT,{TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"min",TYPE_IVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"min",TYPE_IVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"min",TYPE_IVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
-
- {"min",TYPE_UINT,{TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"min",TYPE_UVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"min",TYPE_UVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"min",TYPE_UVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
-
- {"max",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"max",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"max",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"max",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"max",TYPE_INT,{TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"max",TYPE_IVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"max",TYPE_IVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"max",TYPE_IVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
-
- {"max",TYPE_UINT,{TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"max",TYPE_UVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"max",TYPE_UVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"max",TYPE_UVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
-
-
- {"clamp",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"clamp",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"clamp",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"clamp",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
- {"clamp",TYPE_VEC2,{TYPE_VEC2,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"clamp",TYPE_VEC3,{TYPE_VEC3,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"clamp",TYPE_VEC4,{TYPE_VEC4,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
-
-
- {"clamp",TYPE_INT,{TYPE_INT,TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"clamp",TYPE_IVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"clamp",TYPE_IVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"clamp",TYPE_IVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
- {"clamp",TYPE_IVEC2,{TYPE_IVEC2,TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"clamp",TYPE_IVEC3,{TYPE_IVEC3,TYPE_INT,TYPE_INT,TYPE_VOID}},
- {"clamp",TYPE_IVEC4,{TYPE_IVEC4,TYPE_INT,TYPE_INT,TYPE_VOID}},
-
- {"clamp",TYPE_UINT,{TYPE_UINT,TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"clamp",TYPE_UVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"clamp",TYPE_UVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"clamp",TYPE_UVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
- {"clamp",TYPE_UVEC2,{TYPE_UVEC2,TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"clamp",TYPE_UVEC3,{TYPE_UVEC3,TYPE_UINT,TYPE_UINT,TYPE_VOID}},
- {"clamp",TYPE_UVEC4,{TYPE_UVEC4,TYPE_UINT,TYPE_UINT,TYPE_VOID}},
-
- {"mix",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"mix",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_BOOL,TYPE_VOID}},
- {"mix",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_FLOAT,TYPE_VOID}},
- {"mix",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_BOOL,TYPE_VOID}},
- {"mix",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_BVEC2,TYPE_VOID}},
- {"mix",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"mix",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"mix",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_BOOL,TYPE_VOID}},
- {"mix",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_BVEC3,TYPE_VOID}},
- {"mix",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"mix",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
- {"mix",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_BOOL,TYPE_VOID}},
- {"mix",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_BVEC3,TYPE_VOID}},
- {"mix",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"step",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"step",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"step",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"step",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
- {"step",TYPE_VEC2,{TYPE_FLOAT,TYPE_VEC2,TYPE_VOID}},
- {"step",TYPE_VEC3,{TYPE_FLOAT,TYPE_VEC3,TYPE_VOID}},
- {"step",TYPE_VEC4,{TYPE_FLOAT,TYPE_VEC4,TYPE_VOID}},
- {"smoothstep",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
- {"smoothstep",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"smoothstep",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"smoothstep",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
- {"smoothstep",TYPE_VEC2,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VEC2,TYPE_VOID}},
- {"smoothstep",TYPE_VEC3,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VEC3,TYPE_VOID}},
- {"smoothstep",TYPE_VEC4,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VEC4,TYPE_VOID}},
-
- {"isnan",TYPE_BOOL,{TYPE_FLOAT,TYPE_VOID}},
- {"isnan",TYPE_BOOL,{TYPE_VEC2,TYPE_VOID}},
- {"isnan",TYPE_BOOL,{TYPE_VEC3,TYPE_VOID}},
- {"isnan",TYPE_BOOL,{TYPE_VEC4,TYPE_VOID}},
-
- {"isinf",TYPE_BOOL,{TYPE_FLOAT,TYPE_VOID}},
- {"isinf",TYPE_BOOL,{TYPE_VEC2,TYPE_VOID}},
- {"isinf",TYPE_BOOL,{TYPE_VEC3,TYPE_VOID}},
- {"isinf",TYPE_BOOL,{TYPE_VEC4,TYPE_VOID}},
-
- {"floatBitsToInt",TYPE_INT,{TYPE_FLOAT,TYPE_VOID}},
- {"floatBitsToInt",TYPE_IVEC2,{TYPE_VEC2,TYPE_VOID}},
- {"floatBitsToInt",TYPE_IVEC3,{TYPE_VEC3,TYPE_VOID}},
- {"floatBitsToInt",TYPE_IVEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"floatBitsToUInt",TYPE_UINT,{TYPE_FLOAT,TYPE_VOID}},
- {"floatBitsToUInt",TYPE_UVEC2,{TYPE_VEC2,TYPE_VOID}},
- {"floatBitsToUInt",TYPE_UVEC3,{TYPE_VEC3,TYPE_VOID}},
- {"floatBitsToUInt",TYPE_UVEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"intBitsToFloat",TYPE_FLOAT,{TYPE_INT,TYPE_VOID}},
- {"intBitsToFloat",TYPE_VEC2,{TYPE_IVEC2,TYPE_VOID}},
- {"intBitsToFloat",TYPE_VEC3,{TYPE_IVEC3,TYPE_VOID}},
- {"intBitsToFloat",TYPE_VEC4,{TYPE_IVEC4,TYPE_VOID}},
-
- {"uintBitsToFloat",TYPE_FLOAT,{TYPE_UINT,TYPE_VOID}},
- {"uintBitsToFloat",TYPE_VEC2,{TYPE_UVEC2,TYPE_VOID}},
- {"uintBitsToFloat",TYPE_VEC3,{TYPE_UVEC3,TYPE_VOID}},
- {"uintBitsToFloat",TYPE_VEC4,{TYPE_UVEC4,TYPE_VOID}},
+ { "abs", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "abs", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "abs", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "abs", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "abs", TYPE_INT, { TYPE_INT, TYPE_VOID } },
+ { "abs", TYPE_IVEC2, { TYPE_IVEC2, TYPE_VOID } },
+ { "abs", TYPE_IVEC3, { TYPE_IVEC3, TYPE_VOID } },
+ { "abs", TYPE_IVEC4, { TYPE_IVEC4, TYPE_VOID } },
+
+ { "abs", TYPE_UINT, { TYPE_UINT, TYPE_VOID } },
+ { "abs", TYPE_UVEC2, { TYPE_UVEC2, TYPE_VOID } },
+ { "abs", TYPE_UVEC3, { TYPE_UVEC3, TYPE_VOID } },
+ { "abs", TYPE_UVEC4, { TYPE_UVEC4, TYPE_VOID } },
+
+ { "sign", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "sign", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "sign", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "sign", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "sign", TYPE_INT, { TYPE_INT, TYPE_VOID } },
+ { "sign", TYPE_IVEC2, { TYPE_IVEC2, TYPE_VOID } },
+ { "sign", TYPE_IVEC3, { TYPE_IVEC3, TYPE_VOID } },
+ { "sign", TYPE_IVEC4, { TYPE_IVEC4, TYPE_VOID } },
+
+ { "floor", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "floor", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "floor", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "floor", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+ { "trunc", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "trunc", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "trunc", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "trunc", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+ { "round", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "round", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "round", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "round", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+ { "ceil", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "ceil", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "ceil", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "ceil", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+ { "fract", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "fract", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "fract", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "fract", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "mod", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "mod", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "mod", TYPE_VEC2, { TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
+ { "mod", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "mod", TYPE_VEC3, { TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "mod", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+ { "mod", TYPE_VEC4, { TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+
+ { "modf", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "modf", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "modf", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "modf", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "min", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "min", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "min", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "min", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "min", TYPE_INT, { TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "min", TYPE_IVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "min", TYPE_IVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "min", TYPE_IVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
+
+ { "min", TYPE_UINT, { TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "min", TYPE_UVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "min", TYPE_UVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "min", TYPE_UVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
+
+ { "max", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "max", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "max", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "max", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "max", TYPE_INT, { TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "max", TYPE_IVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "max", TYPE_IVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "max", TYPE_IVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
+
+ { "max", TYPE_UINT, { TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "max", TYPE_UVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "max", TYPE_UVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "max", TYPE_UVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
+
+ { "clamp", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "clamp", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "clamp", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "clamp", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+ { "clamp", TYPE_VEC2, { TYPE_VEC2, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "clamp", TYPE_VEC3, { TYPE_VEC3, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "clamp", TYPE_VEC4, { TYPE_VEC4, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+
+ { "clamp", TYPE_INT, { TYPE_INT, TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "clamp", TYPE_IVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "clamp", TYPE_IVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "clamp", TYPE_IVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
+ { "clamp", TYPE_IVEC2, { TYPE_IVEC2, TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "clamp", TYPE_IVEC3, { TYPE_IVEC3, TYPE_INT, TYPE_INT, TYPE_VOID } },
+ { "clamp", TYPE_IVEC4, { TYPE_IVEC4, TYPE_INT, TYPE_INT, TYPE_VOID } },
+
+ { "clamp", TYPE_UINT, { TYPE_UINT, TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "clamp", TYPE_UVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "clamp", TYPE_UVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "clamp", TYPE_UVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
+ { "clamp", TYPE_UVEC2, { TYPE_UVEC2, TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "clamp", TYPE_UVEC3, { TYPE_UVEC3, TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+ { "clamp", TYPE_UVEC4, { TYPE_UVEC4, TYPE_UINT, TYPE_UINT, TYPE_VOID } },
+
+ { "mix", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "mix", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_BOOL, TYPE_VOID } },
+ { "mix", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
+ { "mix", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_BOOL, TYPE_VOID } },
+ { "mix", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_BVEC2, TYPE_VOID } },
+ { "mix", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "mix", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "mix", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_BOOL, TYPE_VOID } },
+ { "mix", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_BVEC3, TYPE_VOID } },
+ { "mix", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "mix", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+ { "mix", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_BOOL, TYPE_VOID } },
+ { "mix", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_BVEC3, TYPE_VOID } },
+ { "mix", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "step", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "step", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "step", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "step", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+ { "step", TYPE_VEC2, { TYPE_FLOAT, TYPE_VEC2, TYPE_VOID } },
+ { "step", TYPE_VEC3, { TYPE_FLOAT, TYPE_VEC3, TYPE_VOID } },
+ { "step", TYPE_VEC4, { TYPE_FLOAT, TYPE_VEC4, TYPE_VOID } },
+ { "smoothstep", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } },
+ { "smoothstep", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "smoothstep", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "smoothstep", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+ { "smoothstep", TYPE_VEC2, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VEC2, TYPE_VOID } },
+ { "smoothstep", TYPE_VEC3, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VEC3, TYPE_VOID } },
+ { "smoothstep", TYPE_VEC4, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VEC4, TYPE_VOID } },
+
+ { "isnan", TYPE_BOOL, { TYPE_FLOAT, TYPE_VOID } },
+ { "isnan", TYPE_BOOL, { TYPE_VEC2, TYPE_VOID } },
+ { "isnan", TYPE_BOOL, { TYPE_VEC3, TYPE_VOID } },
+ { "isnan", TYPE_BOOL, { TYPE_VEC4, TYPE_VOID } },
+
+ { "isinf", TYPE_BOOL, { TYPE_FLOAT, TYPE_VOID } },
+ { "isinf", TYPE_BOOL, { TYPE_VEC2, TYPE_VOID } },
+ { "isinf", TYPE_BOOL, { TYPE_VEC3, TYPE_VOID } },
+ { "isinf", TYPE_BOOL, { TYPE_VEC4, TYPE_VOID } },
+
+ { "floatBitsToInt", TYPE_INT, { TYPE_FLOAT, TYPE_VOID } },
+ { "floatBitsToInt", TYPE_IVEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "floatBitsToInt", TYPE_IVEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "floatBitsToInt", TYPE_IVEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "floatBitsToUInt", TYPE_UINT, { TYPE_FLOAT, TYPE_VOID } },
+ { "floatBitsToUInt", TYPE_UVEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "floatBitsToUInt", TYPE_UVEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "floatBitsToUInt", TYPE_UVEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "intBitsToFloat", TYPE_FLOAT, { TYPE_INT, TYPE_VOID } },
+ { "intBitsToFloat", TYPE_VEC2, { TYPE_IVEC2, TYPE_VOID } },
+ { "intBitsToFloat", TYPE_VEC3, { TYPE_IVEC3, TYPE_VOID } },
+ { "intBitsToFloat", TYPE_VEC4, { TYPE_IVEC4, TYPE_VOID } },
+
+ { "uintBitsToFloat", TYPE_FLOAT, { TYPE_UINT, TYPE_VOID } },
+ { "uintBitsToFloat", TYPE_VEC2, { TYPE_UVEC2, TYPE_VOID } },
+ { "uintBitsToFloat", TYPE_VEC3, { TYPE_UVEC3, TYPE_VOID } },
+ { "uintBitsToFloat", TYPE_VEC4, { TYPE_UVEC4, TYPE_VOID } },
//builtins - geometric
- {"length",TYPE_FLOAT,{TYPE_VEC2,TYPE_VOID}},
- {"length",TYPE_FLOAT,{TYPE_VEC3,TYPE_VOID}},
- {"length",TYPE_FLOAT,{TYPE_VEC4,TYPE_VOID}},
- {"distance",TYPE_FLOAT,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"distance",TYPE_FLOAT,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"distance",TYPE_FLOAT,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
- {"dot",TYPE_FLOAT,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"dot",TYPE_FLOAT,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"dot",TYPE_FLOAT,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
- {"cross",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"normalize",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"normalize",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"normalize",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
- {"reflect",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"refract",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
-
- {"facefordward",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"facefordward",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"facefordward",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"matrixCompMult",TYPE_MAT2,{TYPE_MAT2,TYPE_MAT2,TYPE_VOID}},
- {"matrixCompMult",TYPE_MAT3,{TYPE_MAT3,TYPE_MAT3,TYPE_VOID}},
- {"matrixCompMult",TYPE_MAT4,{TYPE_MAT4,TYPE_MAT4,TYPE_VOID}},
-
- {"outerProduct",TYPE_MAT2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"outerProduct",TYPE_MAT3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"outerProduct",TYPE_MAT4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"transpose",TYPE_MAT2,{TYPE_MAT2,TYPE_VOID}},
- {"transpose",TYPE_MAT3,{TYPE_MAT3,TYPE_VOID}},
- {"transpose",TYPE_MAT4,{TYPE_MAT4,TYPE_VOID}},
-
- {"determinant",TYPE_FLOAT,{TYPE_MAT2,TYPE_VOID}},
- {"determinant",TYPE_FLOAT,{TYPE_MAT3,TYPE_VOID}},
- {"determinant",TYPE_FLOAT,{TYPE_MAT4,TYPE_VOID}},
-
- {"inverse",TYPE_MAT2,{TYPE_MAT2,TYPE_VOID}},
- {"inverse",TYPE_MAT3,{TYPE_MAT3,TYPE_VOID}},
- {"inverse",TYPE_MAT4,{TYPE_MAT4,TYPE_VOID}},
-
-
- {"lessThan",TYPE_BVEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"lessThan",TYPE_BVEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"lessThan",TYPE_BVEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"lessThan",TYPE_BVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"lessThan",TYPE_BVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"lessThan",TYPE_BVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
-
- {"lessThan",TYPE_BVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"lessThan",TYPE_BVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"lessThan",TYPE_BVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
-
- {"greaterThan",TYPE_BVEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"greaterThan",TYPE_BVEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"greaterThan",TYPE_BVEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"greaterThan",TYPE_BVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"greaterThan",TYPE_BVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"greaterThan",TYPE_BVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
-
- {"greaterThan",TYPE_BVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"greaterThan",TYPE_BVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"greaterThan",TYPE_BVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
-
- {"lessThanEqual",TYPE_BVEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"lessThanEqual",TYPE_BVEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"lessThanEqual",TYPE_BVEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"lessThanEqual",TYPE_BVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"lessThanEqual",TYPE_BVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"lessThanEqual",TYPE_BVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
-
- {"lessThanEqual",TYPE_BVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"lessThanEqual",TYPE_BVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"lessThanEqual",TYPE_BVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
-
- {"greaterThanEqual",TYPE_BVEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"greaterThanEqual",TYPE_BVEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"greaterThanEqual",TYPE_BVEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"greaterThanEqual",TYPE_BVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"greaterThanEqual",TYPE_BVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"greaterThanEqual",TYPE_BVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
-
- {"greaterThanEqual",TYPE_BVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"greaterThanEqual",TYPE_BVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"greaterThanEqual",TYPE_BVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
-
- {"equal",TYPE_BVEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"equal",TYPE_BVEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"equal",TYPE_BVEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"equal",TYPE_BVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"equal",TYPE_BVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"equal",TYPE_BVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
-
- {"equal",TYPE_BVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"equal",TYPE_BVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"equal",TYPE_BVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
-
- {"equal",TYPE_BVEC2,{TYPE_BVEC2,TYPE_BVEC2,TYPE_VOID}},
- {"equal",TYPE_BVEC3,{TYPE_BVEC3,TYPE_BVEC3,TYPE_VOID}},
- {"equal",TYPE_BVEC4,{TYPE_BVEC4,TYPE_BVEC4,TYPE_VOID}},
-
- {"notEqual",TYPE_BVEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"notEqual",TYPE_BVEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
- {"notEqual",TYPE_BVEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
-
- {"notEqual",TYPE_BVEC2,{TYPE_IVEC2,TYPE_IVEC2,TYPE_VOID}},
- {"notEqual",TYPE_BVEC3,{TYPE_IVEC3,TYPE_IVEC3,TYPE_VOID}},
- {"notEqual",TYPE_BVEC4,{TYPE_IVEC4,TYPE_IVEC4,TYPE_VOID}},
+ { "length", TYPE_FLOAT, { TYPE_VEC2, TYPE_VOID } },
+ { "length", TYPE_FLOAT, { TYPE_VEC3, TYPE_VOID } },
+ { "length", TYPE_FLOAT, { TYPE_VEC4, TYPE_VOID } },
+ { "distance", TYPE_FLOAT, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "distance", TYPE_FLOAT, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "distance", TYPE_FLOAT, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+ { "dot", TYPE_FLOAT, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "dot", TYPE_FLOAT, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "dot", TYPE_FLOAT, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+ { "cross", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "normalize", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "normalize", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "normalize", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+ { "reflect", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "refract", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+
+ { "facefordward", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "facefordward", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "facefordward", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "matrixCompMult", TYPE_MAT2, { TYPE_MAT2, TYPE_MAT2, TYPE_VOID } },
+ { "matrixCompMult", TYPE_MAT3, { TYPE_MAT3, TYPE_MAT3, TYPE_VOID } },
+ { "matrixCompMult", TYPE_MAT4, { TYPE_MAT4, TYPE_MAT4, TYPE_VOID } },
+
+ { "outerProduct", TYPE_MAT2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "outerProduct", TYPE_MAT3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "outerProduct", TYPE_MAT4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "transpose", TYPE_MAT2, { TYPE_MAT2, TYPE_VOID } },
+ { "transpose", TYPE_MAT3, { TYPE_MAT3, TYPE_VOID } },
+ { "transpose", TYPE_MAT4, { TYPE_MAT4, TYPE_VOID } },
+
+ { "determinant", TYPE_FLOAT, { TYPE_MAT2, TYPE_VOID } },
+ { "determinant", TYPE_FLOAT, { TYPE_MAT3, TYPE_VOID } },
+ { "determinant", TYPE_FLOAT, { TYPE_MAT4, TYPE_VOID } },
+
+ { "inverse", TYPE_MAT2, { TYPE_MAT2, TYPE_VOID } },
+ { "inverse", TYPE_MAT3, { TYPE_MAT3, TYPE_VOID } },
+ { "inverse", TYPE_MAT4, { TYPE_MAT4, TYPE_VOID } },
+
+ { "lessThan", TYPE_BVEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "lessThan", TYPE_BVEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "lessThan", TYPE_BVEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "lessThan", TYPE_BVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "lessThan", TYPE_BVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "lessThan", TYPE_BVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
+
+ { "lessThan", TYPE_BVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "lessThan", TYPE_BVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "lessThan", TYPE_BVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
+
+ { "greaterThan", TYPE_BVEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "greaterThan", TYPE_BVEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "greaterThan", TYPE_BVEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "greaterThan", TYPE_BVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "greaterThan", TYPE_BVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "greaterThan", TYPE_BVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
+
+ { "greaterThan", TYPE_BVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "greaterThan", TYPE_BVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "greaterThan", TYPE_BVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
+
+ { "lessThanEqual", TYPE_BVEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "lessThanEqual", TYPE_BVEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "lessThanEqual", TYPE_BVEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "lessThanEqual", TYPE_BVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "lessThanEqual", TYPE_BVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "lessThanEqual", TYPE_BVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
+
+ { "lessThanEqual", TYPE_BVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "lessThanEqual", TYPE_BVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "lessThanEqual", TYPE_BVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
+
+ { "greaterThanEqual", TYPE_BVEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "greaterThanEqual", TYPE_BVEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "greaterThanEqual", TYPE_BVEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "greaterThanEqual", TYPE_BVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "greaterThanEqual", TYPE_BVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "greaterThanEqual", TYPE_BVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
+
+ { "greaterThanEqual", TYPE_BVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "greaterThanEqual", TYPE_BVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "greaterThanEqual", TYPE_BVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
+
+ { "equal", TYPE_BVEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "equal", TYPE_BVEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "equal", TYPE_BVEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "equal", TYPE_BVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "equal", TYPE_BVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "equal", TYPE_BVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
+
+ { "equal", TYPE_BVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "equal", TYPE_BVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "equal", TYPE_BVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
+
+ { "equal", TYPE_BVEC2, { TYPE_BVEC2, TYPE_BVEC2, TYPE_VOID } },
+ { "equal", TYPE_BVEC3, { TYPE_BVEC3, TYPE_BVEC3, TYPE_VOID } },
+ { "equal", TYPE_BVEC4, { TYPE_BVEC4, TYPE_BVEC4, TYPE_VOID } },
+
+ { "notEqual", TYPE_BVEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "notEqual", TYPE_BVEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+ { "notEqual", TYPE_BVEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } },
+
+ { "notEqual", TYPE_BVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } },
+ { "notEqual", TYPE_BVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } },
+ { "notEqual", TYPE_BVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } },
- {"notEqual",TYPE_BVEC2,{TYPE_UVEC2,TYPE_UVEC2,TYPE_VOID}},
- {"notEqual",TYPE_BVEC3,{TYPE_UVEC3,TYPE_UVEC3,TYPE_VOID}},
- {"notEqual",TYPE_BVEC4,{TYPE_UVEC4,TYPE_UVEC4,TYPE_VOID}},
+ { "notEqual", TYPE_BVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } },
+ { "notEqual", TYPE_BVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } },
+ { "notEqual", TYPE_BVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } },
- {"notEqual",TYPE_BVEC2,{TYPE_BVEC2,TYPE_BVEC2,TYPE_VOID}},
- {"notEqual",TYPE_BVEC3,{TYPE_BVEC3,TYPE_BVEC3,TYPE_VOID}},
- {"notEqual",TYPE_BVEC4,{TYPE_BVEC4,TYPE_BVEC4,TYPE_VOID}},
+ { "notEqual", TYPE_BVEC2, { TYPE_BVEC2, TYPE_BVEC2, TYPE_VOID } },
+ { "notEqual", TYPE_BVEC3, { TYPE_BVEC3, TYPE_BVEC3, TYPE_VOID } },
+ { "notEqual", TYPE_BVEC4, { TYPE_BVEC4, TYPE_BVEC4, TYPE_VOID } },
- {"any",TYPE_BOOL,{TYPE_BVEC2,TYPE_VOID}},
- {"any",TYPE_BOOL,{TYPE_BVEC3,TYPE_VOID}},
- {"any",TYPE_BOOL,{TYPE_BVEC4,TYPE_VOID}},
+ { "any", TYPE_BOOL, { TYPE_BVEC2, TYPE_VOID } },
+ { "any", TYPE_BOOL, { TYPE_BVEC3, TYPE_VOID } },
+ { "any", TYPE_BOOL, { TYPE_BVEC4, TYPE_VOID } },
- {"all",TYPE_BOOL,{TYPE_BVEC2,TYPE_VOID}},
- {"all",TYPE_BOOL,{TYPE_BVEC3,TYPE_VOID}},
- {"all",TYPE_BOOL,{TYPE_BVEC4,TYPE_VOID}},
+ { "all", TYPE_BOOL, { TYPE_BVEC2, TYPE_VOID } },
+ { "all", TYPE_BOOL, { TYPE_BVEC3, TYPE_VOID } },
+ { "all", TYPE_BOOL, { TYPE_BVEC4, TYPE_VOID } },
- {"not",TYPE_BOOL,{TYPE_BVEC2,TYPE_VOID}},
- {"not",TYPE_BOOL,{TYPE_BVEC3,TYPE_VOID}},
- {"not",TYPE_BOOL,{TYPE_BVEC4,TYPE_VOID}},
+ { "not", TYPE_BOOL, { TYPE_BVEC2, TYPE_VOID } },
+ { "not", TYPE_BOOL, { TYPE_BVEC3, TYPE_VOID } },
+ { "not", TYPE_BOOL, { TYPE_BVEC4, TYPE_VOID } },
//builtins - texture
- {"textureSize",TYPE_VEC2,{TYPE_SAMPLER2D,TYPE_INT,TYPE_VOID}},
- {"textureSize",TYPE_VEC2,{TYPE_ISAMPLER2D,TYPE_INT,TYPE_VOID}},
- {"textureSize",TYPE_VEC2,{TYPE_USAMPLER2D,TYPE_INT,TYPE_VOID}},
- {"textureSize",TYPE_VEC2,{TYPE_SAMPLERCUBE,TYPE_INT,TYPE_VOID}},
-
- {"texture",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC2,TYPE_VOID}},
- {"texture",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC3,TYPE_VOID}},
- {"texture",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC2,TYPE_FLOAT,TYPE_VOID}},
- {"texture",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
-
- {"texture",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC2,TYPE_VOID}},
- {"texture",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC3,TYPE_VOID}},
- {"texture",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC2,TYPE_FLOAT,TYPE_VOID}},
- {"texture",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
-
- {"texture",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC2,TYPE_VOID}},
- {"texture",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC3,TYPE_VOID}},
- {"texture",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC2,TYPE_FLOAT,TYPE_VOID}},
- {"texture",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
-
- {"texture",TYPE_VEC4,{TYPE_SAMPLERCUBE,TYPE_VEC3,TYPE_VOID}},
- {"texture",TYPE_VEC4,{TYPE_SAMPLERCUBE,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
-
- {"textureProj",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC3,TYPE_VOID}},
- {"textureProj",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC4,TYPE_VOID}},
- {"textureProj",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureProj",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
-
- {"textureProj",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC3,TYPE_VOID}},
- {"textureProj",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC4,TYPE_VOID}},
- {"textureProj",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureProj",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
-
- {"textureProj",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC3,TYPE_VOID}},
- {"textureProj",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC4,TYPE_VOID}},
- {"textureProj",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureProj",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
-
- {"textureLod",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureLod",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureLod",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureLod",TYPE_VEC4,{TYPE_SAMPLERCUBE,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
-
- {"texelFetch",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_IVEC2,TYPE_INT,TYPE_VOID}},
- {"texelFetch",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_IVEC2,TYPE_INT,TYPE_VOID}},
- {"texelFetch",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_IVEC2,TYPE_INT,TYPE_VOID}},
-
- {"textureProjLod",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureProjLod",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
-
- {"textureProjLod",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureProjLod",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
-
- {"textureProjLod",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC3,TYPE_FLOAT,TYPE_VOID}},
- {"textureProjLod",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
-
- {"textureGrad",TYPE_VEC4,{TYPE_SAMPLER2D,TYPE_VEC2,TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"textureGrad",TYPE_IVEC4,{TYPE_ISAMPLER2D,TYPE_VEC2,TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"textureGrad",TYPE_UVEC4,{TYPE_USAMPLER2D,TYPE_VEC2,TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
- {"textureGrad",TYPE_VEC4,{TYPE_SAMPLERCUBE,TYPE_VEC3,TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
-
- {"textureScreen",TYPE_VEC4,{TYPE_VEC2,TYPE_VOID}},
-
- {"dFdx",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"dFdx",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"dFdx",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"dFdx",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"dFdy",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"dFdy",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"dFdy",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"dFdy",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
-
- {"fwidth",TYPE_FLOAT,{TYPE_FLOAT,TYPE_VOID}},
- {"fwidth",TYPE_VEC2,{TYPE_VEC2,TYPE_VOID}},
- {"fwidth",TYPE_VEC3,{TYPE_VEC3,TYPE_VOID}},
- {"fwidth",TYPE_VEC4,{TYPE_VEC4,TYPE_VOID}},
-
-
- {NULL,TYPE_VOID,{TYPE_VOID}}
+ { "textureSize", TYPE_VEC2, { TYPE_SAMPLER2D, TYPE_INT, TYPE_VOID } },
+ { "textureSize", TYPE_VEC2, { TYPE_ISAMPLER2D, TYPE_INT, TYPE_VOID } },
+ { "textureSize", TYPE_VEC2, { TYPE_USAMPLER2D, TYPE_INT, TYPE_VOID } },
+ { "textureSize", TYPE_VEC2, { TYPE_SAMPLERCUBE, TYPE_INT, TYPE_VOID } },
+
+ { "texture", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC2, TYPE_VOID } },
+ { "texture", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC3, TYPE_VOID } },
+ { "texture", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
+ { "texture", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+
+ { "texture", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC2, TYPE_VOID } },
+ { "texture", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC3, TYPE_VOID } },
+ { "texture", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
+ { "texture", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+
+ { "texture", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC2, TYPE_VOID } },
+ { "texture", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC3, TYPE_VOID } },
+ { "texture", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } },
+ { "texture", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+
+ { "texture", TYPE_VEC4, { TYPE_SAMPLERCUBE, TYPE_VEC3, TYPE_VOID } },
+ { "texture", TYPE_VEC4, { TYPE_SAMPLERCUBE, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+
+ { "textureProj", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC3, TYPE_VOID } },
+ { "textureProj", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC4, TYPE_VOID } },
+ { "textureProj", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureProj", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+
+ { "textureProj", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC3, TYPE_VOID } },
+ { "textureProj", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC4, TYPE_VOID } },
+ { "textureProj", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureProj", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+
+ { "textureProj", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC3, TYPE_VOID } },
+ { "textureProj", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC4, TYPE_VOID } },
+ { "textureProj", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureProj", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+
+ { "textureLod", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureLod", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureLod", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureLod", TYPE_VEC4, { TYPE_SAMPLERCUBE, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+
+ { "texelFetch", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_IVEC2, TYPE_INT, TYPE_VOID } },
+ { "texelFetch", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_IVEC2, TYPE_INT, TYPE_VOID } },
+ { "texelFetch", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_IVEC2, TYPE_INT, TYPE_VOID } },
+
+ { "textureProjLod", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureProjLod", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+
+ { "textureProjLod", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureProjLod", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+
+ { "textureProjLod", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } },
+ { "textureProjLod", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } },
+
+ { "textureGrad", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "textureGrad", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "textureGrad", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } },
+ { "textureGrad", TYPE_VEC4, { TYPE_SAMPLERCUBE, TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } },
+
+ { "textureScreen", TYPE_VEC4, { TYPE_VEC2, TYPE_VOID } },
+
+ { "dFdx", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "dFdx", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "dFdx", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "dFdx", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "dFdy", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "dFdy", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "dFdy", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "dFdy", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { "fwidth", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } },
+ { "fwidth", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } },
+ { "fwidth", TYPE_VEC3, { TYPE_VEC3, TYPE_VOID } },
+ { "fwidth", TYPE_VEC4, { TYPE_VEC4, TYPE_VOID } },
+
+ { NULL, TYPE_VOID, { TYPE_VOID } }
};
+bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p_func, DataType *r_ret_type) {
-
-bool ShaderLanguage::_validate_function_call(BlockNode* p_block, OperatorNode *p_func,DataType *r_ret_type) {
-
- ERR_FAIL_COND_V(p_func->op!=OP_CALL && p_func->op!=OP_CONSTRUCT,NULL);
-
+ ERR_FAIL_COND_V(p_func->op != OP_CALL && p_func->op != OP_CONSTRUCT, NULL);
Vector<DataType> args;
- ERR_FAIL_COND_V( p_func->arguments[0]->type!=Node::TYPE_VARIABLE, NULL );
+ ERR_FAIL_COND_V(p_func->arguments[0]->type != Node::TYPE_VARIABLE, NULL);
- StringName name = static_cast<VariableNode*>(p_func->arguments[0])->name.operator String();
+ StringName name = static_cast<VariableNode *>(p_func->arguments[0])->name.operator String();
- bool all_const=true;
- for(int i=1;i<p_func->arguments.size();i++) {
- if (p_func->arguments[i]->type!=Node::TYPE_CONSTANT)
- all_const=false;
+ bool all_const = true;
+ for (int i = 1; i < p_func->arguments.size(); i++) {
+ if (p_func->arguments[i]->type != Node::TYPE_CONSTANT)
+ all_const = false;
args.push_back(p_func->arguments[i]->get_datatype());
}
- int argcount=args.size();
-
- bool failed_builtin=false;
+ int argcount = args.size();
+ bool failed_builtin = false;
- if (argcount<=4) {
+ if (argcount <= 4) {
// test builtins
- int idx=0;
+ int idx = 0;
while (builtin_func_defs[idx].name) {
- if (name==builtin_func_defs[idx].name) {
+ if (name == builtin_func_defs[idx].name) {
- failed_builtin=true;
- bool fail=false;
- for(int i=0;i<argcount;i++) {
+ failed_builtin = true;
+ bool fail = false;
+ for (int i = 0; i < argcount; i++) {
- if (get_scalar_type(args[i])==args[i] && p_func->arguments[i+1]->type==Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode*>(p_func->arguments[i+1]),builtin_func_defs[idx].args[i])) {
+ if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) {
//all good
- } else if (args[i]!=builtin_func_defs[idx].args[i]) {
- fail=true;
+ } else if (args[i] != builtin_func_defs[idx].args[i]) {
+ fail = true;
break;
}
}
- if (!fail && argcount<4 && builtin_func_defs[idx].args[argcount]!=TYPE_VOID)
- fail=true; //make sure the number of arguments matches
+ if (!fail && argcount < 4 && builtin_func_defs[idx].args[argcount] != TYPE_VOID)
+ fail = true; //make sure the number of arguments matches
if (!fail) {
if (r_ret_type)
- *r_ret_type=builtin_func_defs[idx].rettype;
+ *r_ret_type = builtin_func_defs[idx].rettype;
return true;
}
-
}
idx++;
@@ -1828,17 +1791,17 @@ bool ShaderLanguage::_validate_function_call(BlockNode* p_block, OperatorNode *p
}
if (failed_builtin) {
- String err ="Invalid arguments for built-in function: "+String(name)+"(";
- for(int i=0;i<argcount;i++) {
- if (i>0)
- err+=",";
+ String err = "Invalid arguments for built-in function: " + String(name) + "(";
+ for (int i = 0; i < argcount; i++) {
+ if (i > 0)
+ err += ",";
- if (p_func->arguments[i+1]->type==Node::TYPE_CONSTANT && p_func->arguments[i+1]->get_datatype()==TYPE_INT && static_cast<ConstantNode*>(p_func->arguments[i+1])->values[0].sint<0) {
- err+="-";
+ if (p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && p_func->arguments[i + 1]->get_datatype() == TYPE_INT && static_cast<ConstantNode *>(p_func->arguments[i + 1])->values[0].sint < 0) {
+ err += "-";
}
- err+=get_datatype_name(args[i]);
+ err += get_datatype_name(args[i]);
}
- err+=")";
+ err += ")";
_set_error(err);
return false;
}
@@ -1904,51 +1867,48 @@ bool ShaderLanguage::_validate_function_call(BlockNode* p_block, OperatorNode *p
StringName exclude_function;
BlockNode *block = p_block;
- while(block) {
+ while (block) {
if (block->parent_function) {
- exclude_function=block->parent_function->name;
+ exclude_function = block->parent_function->name;
}
- block=block->parent_block;
+ block = block->parent_block;
}
- if (name==exclude_function) {
+ if (name == exclude_function) {
_set_error("Recursion is not allowed");
return false;
}
- for(int i=0;i<shader->functions.size();i++) {
-
+ for (int i = 0; i < shader->functions.size(); i++) {
if (name != shader->functions[i].name)
continue;
if (!shader->functions[i].callable) {
- _set_error("Function '"+String(name)+" can't be called from source code.");
+ _set_error("Function '" + String(name) + " can't be called from source code.");
return false;
}
FunctionNode *pfunc = shader->functions[i].function;
-
- if (pfunc->arguments.size()!=args.size())
+ if (pfunc->arguments.size() != args.size())
continue;
- bool fail=false;
+ bool fail = false;
+ for (int i = 0; i < args.size(); i++) {
- for(int i=0;i<args.size();i++) {
-
- if (get_scalar_type(args[i])==args[i] && p_func->arguments[i+1]->type==Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode*>(p_func->arguments[i+1]),pfunc->arguments[i].type)) {
+ if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[i + 1]), pfunc->arguments[i].type)) {
//all good
- } else if (args[i]!=pfunc->arguments[i].type) {
- fail=true;
+ } else if (args[i] != pfunc->arguments[i].type) {
+ fail = true;
break;
}
}
if (!fail) {
- p_func->return_cache=pfunc->return_type;
+ p_func->return_cache = pfunc->return_type;
return true;
}
}
@@ -1956,58 +1916,51 @@ bool ShaderLanguage::_validate_function_call(BlockNode* p_block, OperatorNode *p
return false;
}
-
-bool ShaderLanguage::_parse_function_arguments(BlockNode* p_block,const Map<StringName,DataType> &p_builtin_types,OperatorNode* p_func,int *r_complete_arg) {
+bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg) {
TkPos pos = _get_tkpos();
Token tk = _get_token();
- if (tk.type==TK_PARENTHESIS_CLOSE) {
+ if (tk.type == TK_PARENTHESIS_CLOSE) {
return true;
}
_set_tkpos(pos);
-
- while(true) {
-
+ while (true) {
if (r_complete_arg) {
pos = _get_tkpos();
tk = _get_token();
- if (tk.type==TK_CURSOR) {
+ if (tk.type == TK_CURSOR) {
- *r_complete_arg=p_func->arguments.size()-1;
+ *r_complete_arg = p_func->arguments.size() - 1;
} else {
_set_tkpos(pos);
}
}
- Node *arg= _parse_and_reduce_expression(p_block,p_builtin_types);
+ Node *arg = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!arg) {
return false;
}
-
p_func->arguments.push_back(arg);
tk = _get_token();
-
- if (tk.type==TK_PARENTHESIS_CLOSE) {
+ if (tk.type == TK_PARENTHESIS_CLOSE) {
return true;
- } else if (tk.type!=TK_COMMA) {
+ } else if (tk.type != TK_COMMA) {
// something is broken
_set_error("Expected ',' or ')' after argument");
return false;
}
-
-
}
return true;
@@ -2015,112 +1968,108 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode* p_block,const Map<Stri
bool ShaderLanguage::is_token_operator(TokenType p_type) {
-
- return (p_type==TK_OP_EQUAL ||
- p_type==TK_OP_NOT_EQUAL ||
- p_type==TK_OP_LESS ||
- p_type==TK_OP_LESS_EQUAL ||
- p_type==TK_OP_GREATER ||
- p_type==TK_OP_GREATER_EQUAL ||
- p_type==TK_OP_AND ||
- p_type==TK_OP_OR ||
- p_type==TK_OP_NOT ||
- p_type==TK_OP_ADD ||
- p_type==TK_OP_SUB ||
- p_type==TK_OP_MUL ||
- p_type==TK_OP_DIV ||
- p_type==TK_OP_MOD ||
- p_type==TK_OP_SHIFT_LEFT ||
- p_type==TK_OP_SHIFT_RIGHT ||
- p_type==TK_OP_ASSIGN ||
- p_type==TK_OP_ASSIGN_ADD ||
- p_type==TK_OP_ASSIGN_SUB ||
- p_type==TK_OP_ASSIGN_MUL ||
- p_type==TK_OP_ASSIGN_DIV ||
- p_type==TK_OP_ASSIGN_MOD ||
- p_type==TK_OP_ASSIGN_SHIFT_LEFT ||
- p_type==TK_OP_ASSIGN_SHIFT_RIGHT ||
- p_type==TK_OP_ASSIGN_BIT_AND ||
- p_type==TK_OP_ASSIGN_BIT_OR ||
- p_type==TK_OP_ASSIGN_BIT_XOR ||
- p_type==TK_OP_BIT_AND ||
- p_type==TK_OP_BIT_OR ||
- p_type==TK_OP_BIT_XOR ||
- p_type==TK_OP_BIT_INVERT ||
- p_type==TK_OP_INCREMENT ||
- p_type==TK_OP_DECREMENT ||
- p_type==TK_QUESTION ||
- p_type==TK_COLON );
-
+ return (p_type == TK_OP_EQUAL ||
+ p_type == TK_OP_NOT_EQUAL ||
+ p_type == TK_OP_LESS ||
+ p_type == TK_OP_LESS_EQUAL ||
+ p_type == TK_OP_GREATER ||
+ p_type == TK_OP_GREATER_EQUAL ||
+ p_type == TK_OP_AND ||
+ p_type == TK_OP_OR ||
+ p_type == TK_OP_NOT ||
+ p_type == TK_OP_ADD ||
+ p_type == TK_OP_SUB ||
+ p_type == TK_OP_MUL ||
+ p_type == TK_OP_DIV ||
+ p_type == TK_OP_MOD ||
+ p_type == TK_OP_SHIFT_LEFT ||
+ p_type == TK_OP_SHIFT_RIGHT ||
+ p_type == TK_OP_ASSIGN ||
+ p_type == TK_OP_ASSIGN_ADD ||
+ p_type == TK_OP_ASSIGN_SUB ||
+ p_type == TK_OP_ASSIGN_MUL ||
+ p_type == TK_OP_ASSIGN_DIV ||
+ p_type == TK_OP_ASSIGN_MOD ||
+ p_type == TK_OP_ASSIGN_SHIFT_LEFT ||
+ p_type == TK_OP_ASSIGN_SHIFT_RIGHT ||
+ p_type == TK_OP_ASSIGN_BIT_AND ||
+ p_type == TK_OP_ASSIGN_BIT_OR ||
+ p_type == TK_OP_ASSIGN_BIT_XOR ||
+ p_type == TK_OP_BIT_AND ||
+ p_type == TK_OP_BIT_OR ||
+ p_type == TK_OP_BIT_XOR ||
+ p_type == TK_OP_BIT_INVERT ||
+ p_type == TK_OP_INCREMENT ||
+ p_type == TK_OP_DECREMENT ||
+ p_type == TK_QUESTION ||
+ p_type == TK_COLON);
}
-bool ShaderLanguage::convert_constant(ConstantNode* p_constant, DataType p_to_type,ConstantNode::Value *p_value) {
+bool ShaderLanguage::convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value) {
- if (p_constant->datatype==p_to_type) {
+ if (p_constant->datatype == p_to_type) {
if (p_value) {
- for(int i=0;i<p_constant->values.size();i++) {
- p_value[i]=p_constant->values[i];
+ for (int i = 0; i < p_constant->values.size(); i++) {
+ p_value[i] = p_constant->values[i];
}
}
return true;
- } else if (p_constant->datatype==TYPE_INT && p_to_type==TYPE_FLOAT) {
+ } else if (p_constant->datatype == TYPE_INT && p_to_type == TYPE_FLOAT) {
if (p_value) {
- p_value->real=p_constant->values[0].sint;
+ p_value->real = p_constant->values[0].sint;
}
return true;
- } else if (p_constant->datatype==TYPE_UINT && p_to_type==TYPE_FLOAT) {
+ } else if (p_constant->datatype == TYPE_UINT && p_to_type == TYPE_FLOAT) {
if (p_value) {
- p_value->real=p_constant->values[0].uint;
+ p_value->real = p_constant->values[0].uint;
}
return true;
- } else if (p_constant->datatype==TYPE_INT && p_to_type==TYPE_UINT) {
- if (p_constant->values[0].sint<0) {
+ } else if (p_constant->datatype == TYPE_INT && p_to_type == TYPE_UINT) {
+ if (p_constant->values[0].sint < 0) {
return false;
}
if (p_value) {
- p_value->uint=p_constant->values[0].sint;
+ p_value->uint = p_constant->values[0].sint;
}
return true;
- } else if (p_constant->datatype==TYPE_UINT && p_to_type==TYPE_INT) {
+ } else if (p_constant->datatype == TYPE_UINT && p_to_type == TYPE_INT) {
- if (p_constant->values[0].uint>0x7FFFFFFF) {
+ if (p_constant->values[0].uint > 0x7FFFFFFF) {
return false;
}
if (p_value) {
- p_value->sint=p_constant->values[0].uint;
+ p_value->sint = p_constant->values[0].uint;
}
return true;
} else
return false;
-
}
bool ShaderLanguage::is_scalar_type(DataType p_type) {
- return p_type==TYPE_BOOL || p_type==TYPE_INT || p_type==TYPE_UINT || p_type==TYPE_FLOAT;
+ return p_type == TYPE_BOOL || p_type == TYPE_INT || p_type == TYPE_UINT || p_type == TYPE_FLOAT;
}
bool ShaderLanguage::is_sampler_type(DataType p_type) {
- return p_type==TYPE_SAMPLER2D || p_type==TYPE_ISAMPLER2D || p_type==TYPE_USAMPLER2D || p_type==TYPE_SAMPLERCUBE;
-
+ return p_type == TYPE_SAMPLER2D || p_type == TYPE_ISAMPLER2D || p_type == TYPE_USAMPLER2D || p_type == TYPE_SAMPLERCUBE;
}
void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
Set<String> kws;
- int idx=0;
+ int idx = 0;
- while(keyword_list[idx].text) {
+ while (keyword_list[idx].text) {
kws.insert(keyword_list[idx].text);
idx++;
}
- idx=0;
+ idx = 0;
while (builtin_func_defs[idx].name) {
@@ -2129,17 +2078,16 @@ void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
idx++;
}
- for(Set<String>::Element *E=kws.front();E;E=E->next()) {
+ for (Set<String>::Element *E = kws.front(); E; E = E->next()) {
r_keywords->push_back(E->get());
}
}
void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) {
-
Set<String> kws;
- int idx=0;
+ int idx = 0;
while (builtin_func_defs[idx].name) {
@@ -2148,16 +2096,14 @@ void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) {
idx++;
}
- for(Set<String>::Element *E=kws.front();E;E=E->next()) {
+ for (Set<String>::Element *E = kws.front(); E; E = E->next()) {
r_keywords->push_back(E->get());
}
}
-
-
ShaderLanguage::DataType ShaderLanguage::get_scalar_type(DataType p_type) {
- static const DataType scalar_types[]={
+ static const DataType scalar_types[] = {
TYPE_VOID,
TYPE_BOOL,
TYPE_BOOL,
@@ -2187,115 +2133,109 @@ ShaderLanguage::DataType ShaderLanguage::get_scalar_type(DataType p_type) {
return scalar_types[p_type];
}
+bool ShaderLanguage::_get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier) {
-bool ShaderLanguage::_get_completable_identifier(BlockNode *p_block,CompletionType p_type,StringName& identifier) {
-
- identifier=StringName();
+ identifier = StringName();
TkPos pos;
Token tk = _get_token();
- if (tk.type==TK_IDENTIFIER) {
- identifier=tk.text;
- pos = _get_tkpos();
+ if (tk.type == TK_IDENTIFIER) {
+ identifier = tk.text;
+ pos = _get_tkpos();
tk = _get_token();
}
- if (tk.type==TK_CURSOR) {
+ if (tk.type == TK_CURSOR) {
- completion_type=p_type;
- completion_line=tk_line;
- completion_block=p_block;
+ completion_type = p_type;
+ completion_line = tk_line;
+ completion_block = p_block;
pos = _get_tkpos();
tk = _get_token();
- if (tk.type==TK_IDENTIFIER) {
- identifier=identifier.operator String() + tk.text.operator String();
+ if (tk.type == TK_IDENTIFIER) {
+ identifier = identifier.operator String() + tk.text.operator String();
} else {
_set_tkpos(pos);
}
return true;
- } else if (identifier!=StringName()){
+ } else if (identifier != StringName()) {
_set_tkpos(pos);
}
return false;
}
-
-
-ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const Map<StringName,DataType> &p_builtin_types) {
+ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types) {
Vector<Expression> expression;
//Vector<TokenType> operators;
- while(true) {
+ while (true) {
- Node *expr=NULL;
+ Node *expr = NULL;
TkPos prepos = _get_tkpos();
Token tk = _get_token();
- TkPos pos = _get_tkpos();
-
+ TkPos pos = _get_tkpos();
- if (tk.type==TK_PARENTHESIS_OPEN) {
+ if (tk.type == TK_PARENTHESIS_OPEN) {
//handle subexpression
- expr = _parse_and_reduce_expression(p_block,p_builtin_types);
+ expr = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!expr)
return NULL;
tk = _get_token();
- if (tk.type!=TK_PARENTHESIS_CLOSE) {
+ if (tk.type != TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in expression");
return NULL;
}
- } else if (tk.type==TK_REAL_CONSTANT) {
-
+ } else if (tk.type == TK_REAL_CONSTANT) {
ConstantNode *constant = alloc_node<ConstantNode>();
ConstantNode::Value v;
- v.real=tk.constant;
+ v.real = tk.constant;
constant->values.push_back(v);
- constant->datatype=TYPE_FLOAT;
- expr=constant;
-
- } else if (tk.type==TK_INT_CONSTANT) {
+ constant->datatype = TYPE_FLOAT;
+ expr = constant;
+ } else if (tk.type == TK_INT_CONSTANT) {
ConstantNode *constant = alloc_node<ConstantNode>();
ConstantNode::Value v;
- v.sint=tk.constant;
+ v.sint = tk.constant;
constant->values.push_back(v);
- constant->datatype=TYPE_INT;
- expr=constant;
+ constant->datatype = TYPE_INT;
+ expr = constant;
- } else if (tk.type==TK_TRUE) {
+ } else if (tk.type == TK_TRUE) {
//print_line("found true");
//handle true constant
ConstantNode *constant = alloc_node<ConstantNode>();
ConstantNode::Value v;
- v.boolean=true;
+ v.boolean = true;
constant->values.push_back(v);
- constant->datatype=TYPE_BOOL;
- expr=constant;
+ constant->datatype = TYPE_BOOL;
+ expr = constant;
- } else if (tk.type==TK_FALSE) {
+ } else if (tk.type == TK_FALSE) {
//handle false constant
ConstantNode *constant = alloc_node<ConstantNode>();
ConstantNode::Value v;
- v.boolean=false;
+ v.boolean = false;
constant->values.push_back(v);
- constant->datatype=TYPE_BOOL;
- expr=constant;
+ constant->datatype = TYPE_BOOL;
+ expr = constant;
- } else if (tk.type==TK_TYPE_VOID) {
+ } else if (tk.type == TK_TYPE_VOID) {
//make sure void is not used in expression
_set_error("Void value not allowed in Expression");
@@ -2304,98 +2244,93 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
//basic type constructor
OperatorNode *func = alloc_node<OperatorNode>();
- func->op=OP_CONSTRUCT;
-
+ func->op = OP_CONSTRUCT;
if (is_token_precision(tk.type)) {
- func->return_precision_cache=get_token_precision(tk.type);
- tk=_get_token();
+ func->return_precision_cache = get_token_precision(tk.type);
+ tk = _get_token();
}
VariableNode *funcname = alloc_node<VariableNode>();
- funcname->name=get_datatype_name(get_token_datatype(tk.type));
+ funcname->name = get_datatype_name(get_token_datatype(tk.type));
func->arguments.push_back(funcname);
- tk=_get_token();
- if (tk.type!=TK_PARENTHESIS_OPEN) {
+ tk = _get_token();
+ if (tk.type != TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after type name");
return NULL;
}
- int carg=-1;
+ int carg = -1;
- bool ok = _parse_function_arguments(p_block,p_builtin_types,func,&carg);
+ bool ok = _parse_function_arguments(p_block, p_builtin_types, func, &carg);
- if (carg>=0) {
- completion_type=COMPLETION_CALL_ARGUMENTS;
- completion_line=tk_line;
- completion_block=p_block;
- completion_function=funcname->name;
- completion_argument=carg;
+ if (carg >= 0) {
+ completion_type = COMPLETION_CALL_ARGUMENTS;
+ completion_line = tk_line;
+ completion_block = p_block;
+ completion_function = funcname->name;
+ completion_argument = carg;
}
if (!ok)
return NULL;
- if (!_validate_function_call(p_block,func,&func->return_cache)) {
- _set_error("No matching constructor found for: '"+String(funcname->name)+"'");
+ if (!_validate_function_call(p_block, func, &func->return_cache)) {
+ _set_error("No matching constructor found for: '" + String(funcname->name) + "'");
return NULL;
}
//validate_Function_call()
- expr=_reduce_expression(p_block,func);
+ expr = _reduce_expression(p_block, func);
-
- } else if (tk.type==TK_IDENTIFIER) {
+ } else if (tk.type == TK_IDENTIFIER) {
_set_tkpos(prepos);
StringName identifier;
- _get_completable_identifier(p_block,COMPLETION_IDENTIFIER,identifier);
-
+ _get_completable_identifier(p_block, COMPLETION_IDENTIFIER, identifier);
- tk=_get_token();
- if (tk.type==TK_PARENTHESIS_OPEN) {
+ tk = _get_token();
+ if (tk.type == TK_PARENTHESIS_OPEN) {
//a function
StringName name = identifier;
OperatorNode *func = alloc_node<OperatorNode>();
- func->op=OP_CALL;
+ func->op = OP_CALL;
VariableNode *funcname = alloc_node<VariableNode>();
- funcname->name=name;
+ funcname->name = name;
func->arguments.push_back(funcname);
- int carg=-1;
+ int carg = -1;
- bool ok =_parse_function_arguments(p_block,p_builtin_types,func,&carg);
+ bool ok = _parse_function_arguments(p_block, p_builtin_types, func, &carg);
- for(int i=0;i<shader->functions.size();i++) {
- if (shader->functions[i].name==name) {
+ for (int i = 0; i < shader->functions.size(); i++) {
+ if (shader->functions[i].name == name) {
shader->functions[i].uses_function.insert(name);
}
}
-
-
- if (carg>=0) {
- completion_type=COMPLETION_CALL_ARGUMENTS;
- completion_line=tk_line;
- completion_block=p_block;
- completion_function=funcname->name;
- completion_argument=carg;
+ if (carg >= 0) {
+ completion_type = COMPLETION_CALL_ARGUMENTS;
+ completion_line = tk_line;
+ completion_block = p_block;
+ completion_function = funcname->name;
+ completion_argument = carg;
}
if (!ok)
return NULL;
- if (!_validate_function_call(p_block,func,&func->return_cache)) {
- _set_error("No matching function found for: '"+String(funcname->name)+"'");
+ if (!_validate_function_call(p_block, func, &func->return_cache)) {
+ _set_error("No matching function found for: '" + String(funcname->name) + "'");
return NULL;
}
- expr=func;
+ expr = func;
} else {
//an identifier
@@ -2405,71 +2340,65 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
DataType data_type;
IdentifierType ident_type;
- if (!_find_identifier(p_block,p_builtin_types,identifier,&data_type,&ident_type)) {
- _set_error("Unknown identifier in expression: "+String(identifier));
+ if (!_find_identifier(p_block, p_builtin_types, identifier, &data_type, &ident_type)) {
+ _set_error("Unknown identifier in expression: " + String(identifier));
return NULL;
}
- if (ident_type==IDENTIFIER_FUNCTION) {
- _set_error("Can't use function as identifier: "+String(identifier));
+ if (ident_type == IDENTIFIER_FUNCTION) {
+ _set_error("Can't use function as identifier: " + String(identifier));
return NULL;
}
-
VariableNode *varname = alloc_node<VariableNode>();
- varname->name=identifier;
- varname->datatype_cache=data_type;
- expr=varname;
-
+ varname->name = identifier;
+ varname->datatype_cache = data_type;
+ expr = varname;
}
-
- } else if (tk.type==TK_OP_ADD) {
+ } else if (tk.type == TK_OP_ADD) {
continue; //this one does nothing
- } else if (tk.type==TK_OP_SUB || tk.type==TK_OP_NOT || tk.type==TK_OP_BIT_INVERT || tk.type==TK_OP_INCREMENT || tk.type==TK_OP_DECREMENT) {
-
+ } else if (tk.type == TK_OP_SUB || tk.type == TK_OP_NOT || tk.type == TK_OP_BIT_INVERT || tk.type == TK_OP_INCREMENT || tk.type == TK_OP_DECREMENT) {
Expression e;
- e.is_op=true;
-
- switch(tk.type) {
- case TK_OP_SUB: e.op=OP_NEGATE; break;
- case TK_OP_NOT: e.op=OP_NOT; break;
- case TK_OP_BIT_INVERT: e.op=OP_BIT_INVERT; break;
- case TK_OP_INCREMENT: e.op=OP_INCREMENT; break;
- case TK_OP_DECREMENT: e.op=OP_DECREMENT; break;
+ e.is_op = true;
+
+ switch (tk.type) {
+ case TK_OP_SUB: e.op = OP_NEGATE; break;
+ case TK_OP_NOT: e.op = OP_NOT; break;
+ case TK_OP_BIT_INVERT: e.op = OP_BIT_INVERT; break;
+ case TK_OP_INCREMENT: e.op = OP_INCREMENT; break;
+ case TK_OP_DECREMENT: e.op = OP_DECREMENT; break;
default: ERR_FAIL_V(NULL);
}
expression.push_back(e);
continue;
-
} else {
- _set_error("Expected expression, found: "+get_token_text(tk));
+ _set_error("Expected expression, found: " + get_token_text(tk));
return NULL;
//nothing
}
- ERR_FAIL_COND_V(!expr,NULL);
-
+ ERR_FAIL_COND_V(!expr, NULL);
/* OK now see what's NEXT to the operator.. */
/* OK now see what's NEXT to the operator.. */
/* OK now see what's NEXT to the operator.. */
- while(true) {
+ while (true) {
TkPos pos = _get_tkpos();
- tk=_get_token();
+ tk = _get_token();
- if (tk.type==TK_PERIOD) {
+ if (tk.type == TK_PERIOD) {
StringName identifier;
- if (_get_completable_identifier(p_block,COMPLETION_INDEX,identifier)) {
- completion_base=expr->get_datatype();
+ if (_get_completable_identifier(p_block, COMPLETION_INDEX, identifier)) {
+ completion_base = expr->get_datatype();
}
- if (identifier==StringName()) {
+ if (identifier == StringName()) {
_set_error("Expected identifier as member");
return NULL;
}
@@ -2477,35 +2406,35 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
DataType dt = expr->get_datatype();
String ident = identifier;
- bool ok=true;
+ bool ok = true;
DataType member_type;
- switch(dt) {
+ switch (dt) {
case TYPE_BVEC2:
case TYPE_IVEC2:
case TYPE_UVEC2:
case TYPE_VEC2: {
int l = ident.length();
- if (l==1) {
- member_type=DataType(dt-1);
- } else if (l==2) {
- member_type=dt;
+ if (l == 1) {
+ member_type = DataType(dt - 1);
+ } else if (l == 2) {
+ member_type = dt;
} else {
- ok=false;
+ ok = false;
break;
}
- const CharType *c=ident.ptr();
- for(int i=0;i<l;i++) {
+ const CharType *c = ident.ptr();
+ for (int i = 0; i < l; i++) {
- switch(c[i]) {
+ switch (c[i]) {
case 'r':
case 'g':
case 'x':
case 'y':
break;
default:
- ok=false;
+ ok = false;
break;
}
}
@@ -2517,21 +2446,21 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
case TYPE_VEC3: {
int l = ident.length();
- if (l==1) {
- member_type=DataType(dt-2);
- } else if (l==2) {
- member_type=DataType(dt-1);
- } else if (l==3) {
- member_type=dt;
+ if (l == 1) {
+ member_type = DataType(dt - 2);
+ } else if (l == 2) {
+ member_type = DataType(dt - 1);
+ } else if (l == 3) {
+ member_type = dt;
} else {
- ok=false;
+ ok = false;
break;
}
- const CharType *c=ident.ptr();
- for(int i=0;i<l;i++) {
+ const CharType *c = ident.ptr();
+ for (int i = 0; i < l; i++) {
- switch(c[i]) {
+ switch (c[i]) {
case 'r':
case 'g':
case 'b':
@@ -2540,7 +2469,7 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
case 'z':
break;
default:
- ok=false;
+ ok = false;
break;
}
}
@@ -2552,23 +2481,23 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
case TYPE_VEC4: {
int l = ident.length();
- if (l==1) {
- member_type=DataType(dt-3);
- } else if (l==2) {
- member_type=DataType(dt-2);
- } else if (l==3) {
- member_type=DataType(dt-1);
- } else if (l==4) {
- member_type=dt;
+ if (l == 1) {
+ member_type = DataType(dt - 3);
+ } else if (l == 2) {
+ member_type = DataType(dt - 2);
+ } else if (l == 3) {
+ member_type = DataType(dt - 1);
+ } else if (l == 4) {
+ member_type = dt;
} else {
- ok=false;
+ ok = false;
break;
}
- const CharType *c=ident.ptr();
- for(int i=0;i<l;i++) {
+ const CharType *c = ident.ptr();
+ for (int i = 0; i < l; i++) {
- switch(c[i]) {
+ switch (c[i]) {
case 'r':
case 'g':
case 'b':
@@ -2579,55 +2508,62 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
case 'w':
break;
default:
- ok=false;
+ ok = false;
break;
}
}
} break;
- case TYPE_MAT2: ok=(ident=="x" || ident=="y"); member_type=TYPE_VEC2; break;
- case TYPE_MAT3: ok=(ident=="x" || ident=="y" || ident=="z" ); member_type=TYPE_VEC3; break;
- case TYPE_MAT4: ok=(ident=="x" || ident=="y" || ident=="z" || ident=="w"); member_type=TYPE_VEC4; break;
+ case TYPE_MAT2:
+ ok = (ident == "x" || ident == "y");
+ member_type = TYPE_VEC2;
+ break;
+ case TYPE_MAT3:
+ ok = (ident == "x" || ident == "y" || ident == "z");
+ member_type = TYPE_VEC3;
+ break;
+ case TYPE_MAT4:
+ ok = (ident == "x" || ident == "y" || ident == "z" || ident == "w");
+ member_type = TYPE_VEC4;
+ break;
default: {}
}
if (!ok) {
- _set_error("Invalid member for expression: ."+ident);
+ _set_error("Invalid member for expression: ." + ident);
return NULL;
}
MemberNode *mn = alloc_node<MemberNode>();
- mn->basetype=dt;
- mn->datatype=member_type;
- mn->name=ident;
- mn->owner=expr;
- expr=mn;
-
+ mn->basetype = dt;
+ mn->datatype = member_type;
+ mn->name = ident;
+ mn->owner = expr;
+ expr = mn;
//todo
//member (period) has priority over any operator
//creates a subindexing expression in place
-
- /*} else if (tk.type==TK_BRACKET_OPEN) {
+ /*} else if (tk.type==TK_BRACKET_OPEN) {
//todo
//subindexing has priority over any operator
//creates a subindexing expression in place
*/
- } else if (tk.type==TK_OP_INCREMENT || tk.type==TK_OP_DECREMENT) {
+ } else if (tk.type == TK_OP_INCREMENT || tk.type == TK_OP_DECREMENT) {
OperatorNode *op = alloc_node<OperatorNode>();
- op->op=tk.type==TK_OP_DECREMENT ? OP_POST_DECREMENT : OP_POST_INCREMENT;
+ op->op = tk.type == TK_OP_DECREMENT ? OP_POST_DECREMENT : OP_POST_INCREMENT;
op->arguments.push_back(expr);
- if (!_validate_operator(op,&op->return_cache)) {
+ if (!_validate_operator(op, &op->return_cache)) {
_set_error("Invalid base type for increment/decrement operator");
return NULL;
}
- expr=op;
- } else {
+ expr = op;
+ } else {
_set_tkpos(pos);
break;
@@ -2635,8 +2571,8 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
}
Expression e;
- e.is_op=false;
- e.node=expr;
+ e.is_op = false;
+ e.node = expr;
expression.push_back(e);
pos = _get_tkpos();
@@ -2645,9 +2581,9 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
if (is_token_operator(tk.type)) {
Expression o;
- o.is_op=true;
+ o.is_op = true;
- switch(tk.type) {
+ switch (tk.type) {
case TK_OP_EQUAL: o.op = OP_EQUAL; break;
case TK_OP_NOT_EQUAL: o.op = OP_NOT_EQUAL; break;
@@ -2676,12 +2612,12 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
case TK_OP_ASSIGN_BIT_OR: o.op = OP_ASSIGN_BIT_OR; break;
case TK_OP_ASSIGN_BIT_XOR: o.op = OP_ASSIGN_BIT_XOR; break;
case TK_OP_BIT_AND: o.op = OP_BIT_AND; break;
- case TK_OP_BIT_OR: o.op = OP_BIT_OR ; break;
+ case TK_OP_BIT_OR: o.op = OP_BIT_OR; break;
case TK_OP_BIT_XOR: o.op = OP_BIT_XOR; break;
case TK_QUESTION: o.op = OP_SELECT_IF; break;
case TK_COLON: o.op = OP_SELECT_ELSE; break;
default: {
- _set_error("Invalid token for operator: "+get_token_text(tk));
+ _set_error("Invalid token for operator: " + get_token_text(tk));
return NULL;
}
}
@@ -2694,92 +2630,110 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
}
}
-
-
/* Reduce the set set of expressions and place them in an operator tree, respecting precedence */
- while(expression.size()>1) {
+ while (expression.size() > 1) {
- int next_op=-1;
- int min_priority=0xFFFFF;
- bool is_unary=false;
- bool is_ternary=false;
+ int next_op = -1;
+ int min_priority = 0xFFFFF;
+ bool is_unary = false;
+ bool is_ternary = false;
- for(int i=0;i<expression.size();i++) {
+ for (int i = 0; i < expression.size(); i++) {
if (!expression[i].is_op) {
continue;
}
- bool unary=false;
- bool ternary=false;
+ bool unary = false;
+ bool ternary = false;
int priority;
- switch(expression[i].op) {
- case OP_EQUAL: priority=8; break;
- case OP_NOT_EQUAL: priority=8; break;
- case OP_LESS: priority=7; break;
- case OP_LESS_EQUAL: priority=7; break;
- case OP_GREATER: priority=7; break;
- case OP_GREATER_EQUAL: priority=7; break;
- case OP_AND: priority=12; break;
- case OP_OR: priority=14; break;
- case OP_NOT: priority=3; unary=true; break;
- case OP_NEGATE: priority=3; unary=true; break;
- case OP_ADD: priority=5; break;
- case OP_SUB: priority=5; break;
- case OP_MUL: priority=4; break;
- case OP_DIV: priority=4; break;
- case OP_MOD: priority=4; break;
- case OP_SHIFT_LEFT: priority=6; break;
- case OP_SHIFT_RIGHT: priority=6; break;
- case OP_ASSIGN: priority=16; break;
- case OP_ASSIGN_ADD: priority=16; break;
- case OP_ASSIGN_SUB: priority=16; break;
- case OP_ASSIGN_MUL: priority=16; break;
- case OP_ASSIGN_DIV: priority=16; break;
- case OP_ASSIGN_MOD: priority=16; break;
- case OP_ASSIGN_SHIFT_LEFT: priority=16; break;
- case OP_ASSIGN_SHIFT_RIGHT: priority=16; break;
- case OP_ASSIGN_BIT_AND: priority=16; break;
- case OP_ASSIGN_BIT_OR: priority=16; break;
- case OP_ASSIGN_BIT_XOR: priority=16; break;
- case OP_BIT_AND: priority=9; break;
- case OP_BIT_OR: priority=11; break;
- case OP_BIT_XOR: priority=10; break;
- case OP_BIT_INVERT: priority=3; unary=true; break;
- case OP_INCREMENT: priority=3; unary=true; break;
- case OP_DECREMENT: priority=3; unary=true; break;
- case OP_SELECT_IF: priority=15; ternary=true; break;
- case OP_SELECT_ELSE: priority=15; ternary=true; break;
-
- default: ERR_FAIL_V(NULL); //unexpected operator
-
- }
-
- if (priority<min_priority) {
+ switch (expression[i].op) {
+ case OP_EQUAL: priority = 8; break;
+ case OP_NOT_EQUAL: priority = 8; break;
+ case OP_LESS: priority = 7; break;
+ case OP_LESS_EQUAL: priority = 7; break;
+ case OP_GREATER: priority = 7; break;
+ case OP_GREATER_EQUAL: priority = 7; break;
+ case OP_AND: priority = 12; break;
+ case OP_OR: priority = 14; break;
+ case OP_NOT:
+ priority = 3;
+ unary = true;
+ break;
+ case OP_NEGATE:
+ priority = 3;
+ unary = true;
+ break;
+ case OP_ADD: priority = 5; break;
+ case OP_SUB: priority = 5; break;
+ case OP_MUL: priority = 4; break;
+ case OP_DIV: priority = 4; break;
+ case OP_MOD: priority = 4; break;
+ case OP_SHIFT_LEFT: priority = 6; break;
+ case OP_SHIFT_RIGHT: priority = 6; break;
+ case OP_ASSIGN: priority = 16; break;
+ case OP_ASSIGN_ADD: priority = 16; break;
+ case OP_ASSIGN_SUB: priority = 16; break;
+ case OP_ASSIGN_MUL: priority = 16; break;
+ case OP_ASSIGN_DIV: priority = 16; break;
+ case OP_ASSIGN_MOD: priority = 16; break;
+ case OP_ASSIGN_SHIFT_LEFT: priority = 16; break;
+ case OP_ASSIGN_SHIFT_RIGHT: priority = 16; break;
+ case OP_ASSIGN_BIT_AND: priority = 16; break;
+ case OP_ASSIGN_BIT_OR: priority = 16; break;
+ case OP_ASSIGN_BIT_XOR: priority = 16; break;
+ case OP_BIT_AND: priority = 9; break;
+ case OP_BIT_OR: priority = 11; break;
+ case OP_BIT_XOR: priority = 10; break;
+ case OP_BIT_INVERT:
+ priority = 3;
+ unary = true;
+ break;
+ case OP_INCREMENT:
+ priority = 3;
+ unary = true;
+ break;
+ case OP_DECREMENT:
+ priority = 3;
+ unary = true;
+ break;
+ case OP_SELECT_IF:
+ priority = 15;
+ ternary = true;
+ break;
+ case OP_SELECT_ELSE:
+ priority = 15;
+ ternary = true;
+ break;
+
+ default:
+ ERR_FAIL_V(NULL); //unexpected operator
+ }
+
+ if (priority < min_priority) {
// < is used for left to right (default)
// <= is used for right to left
- next_op=i;
- min_priority=priority;
- is_unary=unary;
- is_ternary=ternary;
+ next_op = i;
+ min_priority = priority;
+ is_unary = unary;
+ is_ternary = ternary;
}
-
}
- ERR_FAIL_COND_V(next_op==-1,NULL);
+ ERR_FAIL_COND_V(next_op == -1, NULL);
// OK! create operator..
// OK! create operator..
if (is_unary) {
- int expr_pos=next_op;
- while(expression[expr_pos].is_op) {
+ int expr_pos = next_op;
+ while (expression[expr_pos].is_op) {
expr_pos++;
- if (expr_pos==expression.size()) {
+ if (expr_pos == expression.size()) {
//can happen..
_set_error("Unexpected end of expression..");
return NULL;
@@ -2787,162 +2741,149 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
}
//consecutively do unary opeators
- for(int i=expr_pos-1;i>=next_op;i--) {
+ for (int i = expr_pos - 1; i >= next_op; i--) {
OperatorNode *op = alloc_node<OperatorNode>();
- op->op=expression[i].op;
- op->arguments.push_back(expression[i+1].node);
-
- expression[i].is_op=false;
- expression[i].node=op;
+ op->op = expression[i].op;
+ op->arguments.push_back(expression[i + 1].node);
+ expression[i].is_op = false;
+ expression[i].node = op;
- if (!_validate_operator(op,&op->return_cache)) {
+ if (!_validate_operator(op, &op->return_cache)) {
String at;
- for(int i=0;i<op->arguments.size();i++) {
- if (i>0)
- at+=" and ";
- at+=get_datatype_name(op->arguments[i]->get_datatype());
-
+ for (int i = 0; i < op->arguments.size(); i++) {
+ if (i > 0)
+ at += " and ";
+ at += get_datatype_name(op->arguments[i]->get_datatype());
}
- _set_error("Invalid arguments to unary operator '"+get_operator_text(op->op)+"' :" +at);
+ _set_error("Invalid arguments to unary operator '" + get_operator_text(op->op) + "' :" + at);
return NULL;
}
- expression.remove(i+1);
+ expression.remove(i + 1);
}
} else if (is_ternary) {
- if (next_op <1 || next_op>=(expression.size()-1)) {
+ if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug..");
ERR_FAIL_V(NULL);
}
- if (next_op+2 >= expression.size() || !expression[next_op+2].is_op || expression[next_op+2].op!=OP_SELECT_ELSE) {
+ if (next_op + 2 >= expression.size() || !expression[next_op + 2].is_op || expression[next_op + 2].op != OP_SELECT_ELSE) {
_set_error("Mising matching ':' for select operator");
return NULL;
}
-
-
OperatorNode *op = alloc_node<OperatorNode>();
- op->op=expression[next_op].op;
- op->arguments.push_back(expression[next_op-1].node);
- op->arguments.push_back(expression[next_op+1].node);
- op->arguments.push_back(expression[next_op+3].node);
+ op->op = expression[next_op].op;
+ op->arguments.push_back(expression[next_op - 1].node);
+ op->arguments.push_back(expression[next_op + 1].node);
+ op->arguments.push_back(expression[next_op + 3].node);
- expression[next_op-1].is_op=false;
- expression[next_op-1].node=op;
- if (!_validate_operator(op,&op->return_cache)) {
+ expression[next_op - 1].is_op = false;
+ expression[next_op - 1].node = op;
+ if (!_validate_operator(op, &op->return_cache)) {
String at;
- for(int i=0;i<op->arguments.size();i++) {
- if (i>0)
- at+=" and ";
- at+=get_datatype_name(op->arguments[i]->get_datatype());
-
+ for (int i = 0; i < op->arguments.size(); i++) {
+ if (i > 0)
+ at += " and ";
+ at += get_datatype_name(op->arguments[i]->get_datatype());
}
- _set_error("Invalid argument to ternary ?: operator: "+at);
+ _set_error("Invalid argument to ternary ?: operator: " + at);
return NULL;
}
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
expression.remove(next_op);
}
} else {
- if (next_op <1 || next_op>=(expression.size()-1)) {
+ if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug..");
ERR_FAIL_V(NULL);
}
OperatorNode *op = alloc_node<OperatorNode>();
- op->op=expression[next_op].op;
+ op->op = expression[next_op].op;
- if (expression[next_op-1].is_op) {
+ if (expression[next_op - 1].is_op) {
_set_error("Parser bug..");
ERR_FAIL_V(NULL);
}
- if (expression[next_op+1].is_op) {
+ if (expression[next_op + 1].is_op) {
// this is not invalid and can really appear
// but it becomes invalid anyway because no binary op
// can be followed by an unary op in a valid combination,
// due to how precedence works, unaries will always dissapear first
_set_error("Parser bug..");
-
}
-
- op->arguments.push_back(expression[next_op-1].node); //expression goes as left
- op->arguments.push_back(expression[next_op+1].node); //next expression goes as right
- expression[next_op-1].node=op;
+ op->arguments.push_back(expression[next_op - 1].node); //expression goes as left
+ op->arguments.push_back(expression[next_op + 1].node); //next expression goes as right
+ expression[next_op - 1].node = op;
//replace all 3 nodes by this operator and make it an expression
- if (!_validate_operator(op,&op->return_cache)) {
+ if (!_validate_operator(op, &op->return_cache)) {
String at;
- for(int i=0;i<op->arguments.size();i++) {
- if (i>0)
- at+=" and ";
- at+=get_datatype_name(op->arguments[i]->get_datatype());
-
+ for (int i = 0; i < op->arguments.size(); i++) {
+ if (i > 0)
+ at += " and ";
+ at += get_datatype_name(op->arguments[i]->get_datatype());
}
- _set_error("Invalid arguments to operator '"+get_operator_text(op->op)+"' :" +at);
+ _set_error("Invalid arguments to operator '" + get_operator_text(op->op) + "' :" + at);
return NULL;
}
expression.remove(next_op);
expression.remove(next_op);
}
-
}
return expression[0].node;
}
+ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node) {
-ShaderLanguage::Node* ShaderLanguage::_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node) {
-
- if (p_node->type!=Node::TYPE_OPERATOR)
+ if (p_node->type != Node::TYPE_OPERATOR)
return p_node;
//for now only reduce simple constructors
- OperatorNode *op=static_cast<OperatorNode*>(p_node);
-
- if (op->op==OP_CONSTRUCT) {
+ OperatorNode *op = static_cast<OperatorNode *>(p_node);
+ if (op->op == OP_CONSTRUCT) {
- ERR_FAIL_COND_V(op->arguments[0]->type!=Node::TYPE_VARIABLE,p_node);
- VariableNode *vn = static_cast<VariableNode*>(op->arguments[0]);
+ ERR_FAIL_COND_V(op->arguments[0]->type != Node::TYPE_VARIABLE, p_node);
+ VariableNode *vn = static_cast<VariableNode *>(op->arguments[0]);
//StringName name=vn->name;
- DataType base=get_scalar_type(op->get_datatype());
+ DataType base = get_scalar_type(op->get_datatype());
Vector<ConstantNode::Value> values;
+ for (int i = 1; i < op->arguments.size(); i++) {
- for(int i=1;i<op->arguments.size();i++) {
-
-
- op->arguments[i]=_reduce_expression(p_block,op->arguments[i]);
- if (op->arguments[i]->type==Node::TYPE_CONSTANT) {
- ConstantNode *cn = static_cast<ConstantNode*>(op->arguments[i]);
+ op->arguments[i] = _reduce_expression(p_block, op->arguments[i]);
+ if (op->arguments[i]->type == Node::TYPE_CONSTANT) {
+ ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[i]);
- if (get_scalar_type(cn->datatype)==base) {
+ if (get_scalar_type(cn->datatype) == base) {
- for(int j=0;j<cn->values.size();j++) {
+ for (int j = 0; j < cn->values.size(); j++) {
values.push_back(cn->values[j]);
}
- } else if (get_scalar_type(cn->datatype)==cn->datatype) {
+ } else if (get_scalar_type(cn->datatype) == cn->datatype) {
ConstantNode::Value v;
- if (!convert_constant(cn,base,&v)) {
+ if (!convert_constant(cn, base, &v)) {
return p_node;
}
values.push_back(v);
@@ -2955,37 +2896,36 @@ ShaderLanguage::Node* ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
}
}
-
- ConstantNode *cn=alloc_node<ConstantNode>();
- cn->datatype=op->get_datatype();
- cn->values=values;
+ ConstantNode *cn = alloc_node<ConstantNode>();
+ cn->datatype = op->get_datatype();
+ cn->values = values;
return cn;
- } else if (op->op==OP_NEGATE) {
+ } else if (op->op == OP_NEGATE) {
- op->arguments[0]=_reduce_expression(p_block,op->arguments[0]);
- if (op->arguments[0]->type==Node::TYPE_CONSTANT) {
+ op->arguments[0] = _reduce_expression(p_block, op->arguments[0]);
+ if (op->arguments[0]->type == Node::TYPE_CONSTANT) {
- ConstantNode *cn = static_cast<ConstantNode*>(op->arguments[0]);
+ ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[0]);
- DataType base=get_scalar_type(cn->datatype);
+ DataType base = get_scalar_type(cn->datatype);
Vector<ConstantNode::Value> values;
- for(int i=0;i<cn->values.size();i++) {
+ for (int i = 0; i < cn->values.size(); i++) {
ConstantNode::Value nv;
- switch(base) {
+ switch (base) {
case TYPE_BOOL: {
- nv.boolean=!cn->values[i].boolean;
+ nv.boolean = !cn->values[i].boolean;
} break;
case TYPE_INT: {
- nv.sint=-cn->values[i].sint;
+ nv.sint = -cn->values[i].sint;
} break;
case TYPE_UINT: {
- nv.uint=-cn->values[i].uint;
+ nv.uint = -cn->values[i].uint;
} break;
case TYPE_FLOAT: {
- nv.real=-cn->values[i].real;
+ nv.real = -cn->values[i].real;
} break;
default: {}
}
@@ -2993,41 +2933,33 @@ ShaderLanguage::Node* ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
values.push_back(nv);
}
-
- cn->values=values;
+ cn->values = values;
return cn;
}
}
return p_node;
-
-
}
+ShaderLanguage::Node *ShaderLanguage::_parse_and_reduce_expression(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types) {
-ShaderLanguage::Node* ShaderLanguage::_parse_and_reduce_expression(BlockNode *p_block, const Map<StringName,DataType> &p_builtin_types) {
-
-
- ShaderLanguage::Node* expr = _parse_expression(p_block,p_builtin_types);
+ ShaderLanguage::Node *expr = _parse_expression(p_block, p_builtin_types);
if (!expr) //errored
return NULL;
- expr = _reduce_expression(p_block,expr);
+ expr = _reduce_expression(p_block, expr);
return expr;
}
+Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types, bool p_just_one, bool p_can_break, bool p_can_continue) {
-
-
-Error ShaderLanguage::_parse_block(BlockNode* p_block,const Map<StringName,DataType> &p_builtin_types,bool p_just_one,bool p_can_break,bool p_can_continue) {
-
- while(true) {
+ while (true) {
TkPos pos = _get_tkpos();
Token tk = _get_token();
- if (tk.type==TK_CURLY_BRACKET_CLOSE) { //end of block
+ if (tk.type == TK_CURLY_BRACKET_CLOSE) { //end of block
if (p_just_one) {
_set_error("Unexpected '}'");
return ERR_PARSE_ERROR;
@@ -3036,9 +2968,9 @@ Error ShaderLanguage::_parse_block(BlockNode* p_block,const Map<StringName,DataT
return OK;
} else if (is_token_precision(tk.type) || is_token_nonvoid_datatype(tk.type)) {
- DataPrecision precision=PRECISION_DEFAULT;
+ DataPrecision precision = PRECISION_DEFAULT;
if (is_token_precision(tk.type)) {
- precision=get_token_precision(tk.type);
+ precision = get_token_precision(tk.type);
tk = _get_token();
if (!is_token_nonvoid_datatype(tk.type)) {
_set_error("Expected datatype after precission");
@@ -3050,97 +2982,96 @@ Error ShaderLanguage::_parse_block(BlockNode* p_block,const Map<StringName,DataT
tk = _get_token();
- while(true) {
+ while (true) {
- if (tk.type!=TK_IDENTIFIER) {
+ if (tk.type != TK_IDENTIFIER) {
_set_error("Expected identifier after type");
return ERR_PARSE_ERROR;
}
StringName name = tk.text;
- if (_find_identifier(p_block,p_builtin_types,name)) {
- _set_error("Redefinition of '"+String(name)+"'");
+ if (_find_identifier(p_block, p_builtin_types, name)) {
+ _set_error("Redefinition of '" + String(name) + "'");
return ERR_PARSE_ERROR;
}
BlockNode::Variable var;
- var.type=type;
- var.precision=precision;
- var.line=tk_line;
- p_block->variables[name]=var;
+ var.type = type;
+ var.precision = precision;
+ var.line = tk_line;
+ p_block->variables[name] = var;
tk = _get_token();
- if (tk.type==TK_OP_ASSIGN) {
+ if (tk.type == TK_OP_ASSIGN) {
//variable creted with assignment! must parse an expression
- Node* n = _parse_and_reduce_expression(p_block,p_builtin_types);
+ Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!n)
return ERR_PARSE_ERROR;
OperatorNode *assign = alloc_node<OperatorNode>();
VariableNode *vnode = alloc_node<VariableNode>();
- vnode->name=name;
- vnode->datatype_cache=type;
+ vnode->name = name;
+ vnode->datatype_cache = type;
assign->arguments.push_back(vnode);
assign->arguments.push_back(n);
- assign->op=OP_ASSIGN;
+ assign->op = OP_ASSIGN;
p_block->statements.push_back(assign);
tk = _get_token();
}
- if (tk.type==TK_COMMA) {
+ if (tk.type == TK_COMMA) {
tk = _get_token();
//another variable
- } else if (tk.type==TK_SEMICOLON) {
+ } else if (tk.type == TK_SEMICOLON) {
break;
} else {
_set_error("Expected ',' or ';' after variable");
return ERR_PARSE_ERROR;
}
}
- } else if (tk.type==TK_CURLY_BRACKET_OPEN) {
+ } else if (tk.type == TK_CURLY_BRACKET_OPEN) {
//a sub block, just because..
- BlockNode* block = alloc_node<BlockNode>();
- block->parent_block=p_block;
- _parse_block(block,p_builtin_types,false,p_can_break,p_can_continue);
+ BlockNode *block = alloc_node<BlockNode>();
+ block->parent_block = p_block;
+ _parse_block(block, p_builtin_types, false, p_can_break, p_can_continue);
p_block->statements.push_back(block);
- } else if (tk.type==TK_CF_IF) {
+ } else if (tk.type == TK_CF_IF) {
//if () {}
tk = _get_token();
- if (tk.type!=TK_PARENTHESIS_OPEN) {
+ if (tk.type != TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after if");
return ERR_PARSE_ERROR;
}
ControlFlowNode *cf = alloc_node<ControlFlowNode>();
- cf->flow_op=FLOW_OP_IF;
- Node* n = _parse_and_reduce_expression(p_block,p_builtin_types);
+ cf->flow_op = FLOW_OP_IF;
+ Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!n)
return ERR_PARSE_ERROR;
tk = _get_token();
- if (tk.type!=TK_PARENTHESIS_CLOSE) {
+ if (tk.type != TK_PARENTHESIS_CLOSE) {
_set_error("Expected '(' after expression");
return ERR_PARSE_ERROR;
}
- BlockNode* block = alloc_node<BlockNode>();
- block->parent_block=p_block;
+ BlockNode *block = alloc_node<BlockNode>();
+ block->parent_block = p_block;
cf->expressions.push_back(n);
cf->blocks.push_back(block);
p_block->statements.push_back(cf);
+ Error err = _parse_block(block, p_builtin_types, true, p_can_break, p_can_continue);
- Error err=_parse_block(block,p_builtin_types,true,p_can_break,p_can_continue);
-
- pos=_get_tkpos();
+ pos = _get_tkpos();
tk = _get_token();
- if (tk.type==TK_CF_ELSE) {
+ if (tk.type == TK_CF_ELSE) {
block = alloc_node<BlockNode>();
- block->parent_block=p_block;
+ block->parent_block = p_block;
cf->blocks.push_back(block);
- err=_parse_block(block,p_builtin_types,true,p_can_break,p_can_continue);
+ err = _parse_block(block, p_builtin_types, true, p_can_break, p_can_continue);
} else {
_set_tkpos(pos); //rollback
@@ -3150,13 +3081,13 @@ Error ShaderLanguage::_parse_block(BlockNode* p_block,const Map<StringName,DataT
//nothng else, so expression
_set_tkpos(pos); //rollback
- Node*expr = _parse_and_reduce_expression(p_block,p_builtin_types);
+ Node *expr = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!expr)
return ERR_PARSE_ERROR;
p_block->statements.push_back(expr);
tk = _get_token();
- if (tk.type!=TK_SEMICOLON) {
+ if (tk.type != TK_SEMICOLON) {
_set_error("Expected ';' after statement");
return ERR_PARSE_ERROR;
}
@@ -3169,49 +3100,47 @@ Error ShaderLanguage::_parse_block(BlockNode* p_block,const Map<StringName,DataT
return OK;
}
-
-Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataType> > &p_functions, const Set<String> &p_render_modes) {
-
+Error ShaderLanguage::_parse_shader(const Map<StringName, Map<StringName, DataType> > &p_functions, const Set<String> &p_render_modes) {
Token tk = _get_token();
int texture_uniforms = 0;
- int uniforms =0;
+ int uniforms = 0;
- while(tk.type!=TK_EOF) {
+ while (tk.type != TK_EOF) {
- switch(tk.type) {
+ switch (tk.type) {
case TK_RENDER_MODE: {
- while(true) {
+ while (true) {
StringName mode;
- _get_completable_identifier(NULL,COMPLETION_RENDER_MODE,mode);
+ _get_completable_identifier(NULL, COMPLETION_RENDER_MODE, mode);
- if (mode==StringName()) {
+ if (mode == StringName()) {
_set_error("Expected identifier for render mode");
return ERR_PARSE_ERROR;
}
if (!p_render_modes.has(mode)) {
- _set_error("Invalid render mode: '"+String(mode)+"'");
+ _set_error("Invalid render mode: '" + String(mode) + "'");
return ERR_PARSE_ERROR;
}
- if (shader->render_modes.find(mode)!=-1) {
- _set_error("Duplicate render mode: '"+String(mode)+"'");
+ if (shader->render_modes.find(mode) != -1) {
+ _set_error("Duplicate render mode: '" + String(mode) + "'");
return ERR_PARSE_ERROR;
}
shader->render_modes.push_back(mode);
tk = _get_token();
- if (tk.type==TK_COMMA) {
+ if (tk.type == TK_COMMA) {
//all good, do nothing
- } else if (tk.type==TK_SEMICOLON) {
+ } else if (tk.type == TK_SEMICOLON) {
break; //done
} else {
- _set_error("Unexpected token: "+get_token_text(tk));
+ _set_error("Unexpected token: " + get_token_text(tk));
return ERR_PARSE_ERROR;
}
}
@@ -3219,14 +3148,14 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
case TK_UNIFORM:
case TK_VARYING: {
- bool uniform = tk.type==TK_UNIFORM;
+ bool uniform = tk.type == TK_UNIFORM;
DataPrecision precision = PRECISION_DEFAULT;
DataType type;
StringName name;
tk = _get_token();
if (is_token_precision(tk.type)) {
- precision=get_token_precision(tk.type);
+ precision = get_token_precision(tk.type);
tk = _get_token();
}
@@ -3237,25 +3166,25 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
type = get_token_datatype(tk.type);
- if (type==TYPE_VOID) {
+ if (type == TYPE_VOID) {
_set_error("void datatype not allowed here");
return ERR_PARSE_ERROR;
}
- if (!uniform && type<TYPE_FLOAT && type>TYPE_VEC4) { // FIXME: always false! should it be || instead?
+ if (!uniform && type < TYPE_FLOAT && type > TYPE_VEC4) { // FIXME: always false! should it be || instead?
_set_error("Invalid type for varying, only float,vec2,vec3,vec4 allowed.");
return ERR_PARSE_ERROR;
}
tk = _get_token();
- if (tk.type!=TK_IDENTIFIER) {
+ if (tk.type != TK_IDENTIFIER) {
_set_error("Expected identifier!");
return ERR_PARSE_ERROR;
}
- name=tk.text;
+ name = tk.text;
- if (_find_identifier(NULL,Map<StringName,DataType>(),name)) {
- _set_error("Redefinition of '"+String(name)+"'");
+ if (_find_identifier(NULL, Map<StringName, DataType>(), name)) {
+ _set_error("Redefinition of '" + String(name) + "'");
return ERR_PARSE_ERROR;
}
@@ -3264,179 +3193,173 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
ShaderNode::Uniform uniform;
if (is_sampler_type(type)) {
- uniform.texture_order=texture_uniforms++;
- uniform.order=-1;
+ uniform.texture_order = texture_uniforms++;
+ uniform.order = -1;
} else {
- uniform.texture_order=-1;
- uniform.order=uniforms++;
+ uniform.texture_order = -1;
+ uniform.order = uniforms++;
}
- uniform.type=type;
- uniform.precission=precision;
+ uniform.type = type;
+ uniform.precission = precision;
//todo parse default value
tk = _get_token();
- if (tk.type==TK_OP_ASSIGN) {
+ if (tk.type == TK_OP_ASSIGN) {
- Node* expr = _parse_and_reduce_expression(NULL,Map<StringName,DataType>());
+ Node *expr = _parse_and_reduce_expression(NULL, Map<StringName, DataType>());
if (!expr)
return ERR_PARSE_ERROR;
- if (expr->type!=Node::TYPE_CONSTANT) {
+ if (expr->type != Node::TYPE_CONSTANT) {
_set_error("Expected constant expression after '='");
return ERR_PARSE_ERROR;
}
- ConstantNode* cn = static_cast<ConstantNode*>(expr);
+ ConstantNode *cn = static_cast<ConstantNode *>(expr);
uniform.default_value.resize(cn->values.size());
- if (!convert_constant(cn,uniform.type,uniform.default_value.ptr())) {
- _set_error("Can't convert constant to "+get_datatype_name(uniform.type));
+ if (!convert_constant(cn, uniform.type, uniform.default_value.ptr())) {
+ _set_error("Can't convert constant to " + get_datatype_name(uniform.type));
return ERR_PARSE_ERROR;
}
tk = _get_token();
}
- if (tk.type==TK_COLON) {
+ if (tk.type == TK_COLON) {
//hint
tk = _get_token();
- if (tk.type==TK_HINT_WHITE_TEXTURE) {
- uniform.hint=ShaderNode::Uniform::HINT_WHITE;
- } else if (tk.type==TK_HINT_BLACK_TEXTURE) {
- uniform.hint=ShaderNode::Uniform::HINT_BLACK;
- } else if (tk.type==TK_HINT_NORMAL_TEXTURE) {
- uniform.hint=ShaderNode::Uniform::HINT_NORMAL;
- } else if (tk.type==TK_HINT_ANISO_TEXTURE) {
- uniform.hint=ShaderNode::Uniform::HINT_ANISO;
- } else if (tk.type==TK_HINT_ALBEDO_TEXTURE) {
- uniform.hint=ShaderNode::Uniform::HINT_ALBEDO;
- } else if (tk.type==TK_HINT_BLACK_ALBEDO_TEXTURE) {
- uniform.hint=ShaderNode::Uniform::HINT_BLACK_ALBEDO;
- } else if (tk.type==TK_HINT_COLOR) {
- if (type!=TYPE_VEC4) {
+ if (tk.type == TK_HINT_WHITE_TEXTURE) {
+ uniform.hint = ShaderNode::Uniform::HINT_WHITE;
+ } else if (tk.type == TK_HINT_BLACK_TEXTURE) {
+ uniform.hint = ShaderNode::Uniform::HINT_BLACK;
+ } else if (tk.type == TK_HINT_NORMAL_TEXTURE) {
+ uniform.hint = ShaderNode::Uniform::HINT_NORMAL;
+ } else if (tk.type == TK_HINT_ANISO_TEXTURE) {
+ uniform.hint = ShaderNode::Uniform::HINT_ANISO;
+ } else if (tk.type == TK_HINT_ALBEDO_TEXTURE) {
+ uniform.hint = ShaderNode::Uniform::HINT_ALBEDO;
+ } else if (tk.type == TK_HINT_BLACK_ALBEDO_TEXTURE) {
+ uniform.hint = ShaderNode::Uniform::HINT_BLACK_ALBEDO;
+ } else if (tk.type == TK_HINT_COLOR) {
+ if (type != TYPE_VEC4) {
_set_error("Color hint is for vec4 only");
return ERR_PARSE_ERROR;
}
- uniform.hint=ShaderNode::Uniform::HINT_COLOR;
- } else if (tk.type==TK_HINT_RANGE) {
+ uniform.hint = ShaderNode::Uniform::HINT_COLOR;
+ } else if (tk.type == TK_HINT_RANGE) {
- uniform.hint=ShaderNode::Uniform::HINT_RANGE;
- if (type!=TYPE_FLOAT && type!=TYPE_INT) {
+ uniform.hint = ShaderNode::Uniform::HINT_RANGE;
+ if (type != TYPE_FLOAT && type != TYPE_INT) {
_set_error("Range hint is for float and int only");
return ERR_PARSE_ERROR;
}
tk = _get_token();
- if (tk.type!=TK_PARENTHESIS_OPEN) {
+ if (tk.type != TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after hint_range");
return ERR_PARSE_ERROR;
}
tk = _get_token();
- float sign=1.0;
+ float sign = 1.0;
- if (tk.type==TK_OP_SUB) {
- sign=-1.0;
+ if (tk.type == TK_OP_SUB) {
+ sign = -1.0;
tk = _get_token();
}
- if (tk.type!=TK_REAL_CONSTANT && tk.type!=TK_INT_CONSTANT) {
+ if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) {
_set_error("Expected integer constant");
return ERR_PARSE_ERROR;
}
- uniform.hint_range[0]=tk.constant;
- uniform.hint_range[0]*=sign;
+ uniform.hint_range[0] = tk.constant;
+ uniform.hint_range[0] *= sign;
tk = _get_token();
- if (tk.type!=TK_COMMA) {
+ if (tk.type != TK_COMMA) {
_set_error("Expected ',' after integer constant");
return ERR_PARSE_ERROR;
}
tk = _get_token();
- sign=1.0;
+ sign = 1.0;
- if (tk.type==TK_OP_SUB) {
- sign=-1.0;
+ if (tk.type == TK_OP_SUB) {
+ sign = -1.0;
tk = _get_token();
}
-
- if (tk.type!=TK_REAL_CONSTANT && tk.type!=TK_INT_CONSTANT) {
+ if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) {
_set_error("Expected integer constant after ','");
return ERR_PARSE_ERROR;
}
- uniform.hint_range[1]=tk.constant;
- uniform.hint_range[1]*=sign;
+ uniform.hint_range[1] = tk.constant;
+ uniform.hint_range[1] *= sign;
tk = _get_token();
- if (tk.type==TK_COMMA) {
+ if (tk.type == TK_COMMA) {
tk = _get_token();
- if (tk.type!=TK_REAL_CONSTANT && tk.type!=TK_INT_CONSTANT) {
+ if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) {
_set_error("Expected integer constant after ','");
return ERR_PARSE_ERROR;
}
- uniform.hint_range[2]=tk.constant;
+ uniform.hint_range[2] = tk.constant;
tk = _get_token();
} else {
- if (type==TYPE_INT) {
- uniform.hint_range[2]=1;
+ if (type == TYPE_INT) {
+ uniform.hint_range[2] = 1;
} else {
- uniform.hint_range[2]=0.001;
+ uniform.hint_range[2] = 0.001;
}
}
- if (tk.type!=TK_PARENTHESIS_CLOSE) {
+ if (tk.type != TK_PARENTHESIS_CLOSE) {
_set_error("Expected ','");
return ERR_PARSE_ERROR;
}
-
} else {
_set_error("Expected valid type hint after ':'.");
}
- if (uniform.hint!=ShaderNode::Uniform::HINT_RANGE && uniform.hint!=ShaderNode::Uniform::HINT_NONE && uniform.hint!=ShaderNode::Uniform::HINT_COLOR && type <=TYPE_MAT4) {
+ if (uniform.hint != ShaderNode::Uniform::HINT_RANGE && uniform.hint != ShaderNode::Uniform::HINT_NONE && uniform.hint != ShaderNode::Uniform::HINT_COLOR && type <= TYPE_MAT4) {
_set_error("This hint is only for sampler types");
return ERR_PARSE_ERROR;
-
}
tk = _get_token();
}
- shader->uniforms[name]=uniform;
+ shader->uniforms[name] = uniform;
- if (tk.type!=TK_SEMICOLON) {
+ if (tk.type != TK_SEMICOLON) {
_set_error("Expected ';'");
return ERR_PARSE_ERROR;
}
} else {
ShaderNode::Varying varying;
- varying.type=type;
- varying.precission=precision;
- shader->varyings[name]=varying;
+ varying.type = type;
+ varying.precission = precision;
+ shader->varyings[name] = varying;
tk = _get_token();
- if (tk.type!=TK_SEMICOLON) {
+ if (tk.type != TK_SEMICOLON) {
_set_error("Expected ';'");
return ERR_PARSE_ERROR;
}
-
}
-
-
} break;
default: {
//function
@@ -3446,7 +3369,7 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
StringName name;
if (is_token_precision(tk.type)) {
- precision=get_token_precision(tk.type);
+ precision = get_token_precision(tk.type);
tk = _get_token();
}
@@ -3457,56 +3380,51 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
type = get_token_datatype(tk.type);
- _get_completable_identifier(NULL,COMPLETION_MAIN_FUNCTION,name);
+ _get_completable_identifier(NULL, COMPLETION_MAIN_FUNCTION, name);
- if (name==StringName()) {
+ if (name == StringName()) {
_set_error("Expected function name after datatype");
return ERR_PARSE_ERROR;
-
}
-
- if (_find_identifier(NULL,Map<StringName,DataType>(),name)) {
- _set_error("Redefinition of '"+String(name)+"'");
+ if (_find_identifier(NULL, Map<StringName, DataType>(), name)) {
+ _set_error("Redefinition of '" + String(name) + "'");
return ERR_PARSE_ERROR;
}
tk = _get_token();
- if (tk.type!=TK_PARENTHESIS_OPEN) {
+ if (tk.type != TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after identifier");
return ERR_PARSE_ERROR;
-
}
-
- Map<StringName,DataType> builtin_types;
+ Map<StringName, DataType> builtin_types;
if (p_functions.has(name)) {
- builtin_types=p_functions[name];
+ builtin_types = p_functions[name];
}
ShaderNode::Function function;
- function.callable=!p_functions.has(name);
- function.name=name;
+ function.callable = !p_functions.has(name);
+ function.name = name;
- FunctionNode* func_node=alloc_node<FunctionNode>();
+ FunctionNode *func_node = alloc_node<FunctionNode>();
- function.function=func_node;
+ function.function = func_node;
shader->functions.push_back(function);
- func_node->name=name;
- func_node->return_type=type;
- func_node->return_precision=precision;
+ func_node->name = name;
+ func_node->return_type = type;
+ func_node->return_precision = precision;
func_node->body = alloc_node<BlockNode>();
- func_node->body->parent_function=func_node;
-
+ func_node->body->parent_function = func_node;
tk = _get_token();
- while(true) {
- if (tk.type==TK_PARENTHESIS_CLOSE) {
+ while (true) {
+ if (tk.type == TK_PARENTHESIS_CLOSE) {
break;
}
@@ -3515,7 +3433,7 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
DataPrecision pprecision = PRECISION_DEFAULT;
if (is_token_precision(tk.type)) {
- pprecision=get_token_precision(tk.type);
+ pprecision = get_token_precision(tk.type);
tk = _get_token();
}
@@ -3524,73 +3442,70 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
return ERR_PARSE_ERROR;
}
- ptype=get_token_datatype(tk.type);
+ ptype = get_token_datatype(tk.type);
- if (ptype==TYPE_VOID) {
+ if (ptype == TYPE_VOID) {
_set_error("void not allowed in argument");
return ERR_PARSE_ERROR;
}
tk = _get_token();
- if (tk.type!=TK_IDENTIFIER) {
+ if (tk.type != TK_IDENTIFIER) {
_set_error("Expected identifier for argument name");
return ERR_PARSE_ERROR;
}
pname = tk.text;
- if (_find_identifier(func_node->body,builtin_types,pname)) {
- _set_error("Redefinition of '"+String(pname)+"'");
+ if (_find_identifier(func_node->body, builtin_types, pname)) {
+ _set_error("Redefinition of '" + String(pname) + "'");
return ERR_PARSE_ERROR;
}
FunctionNode::Argument arg;
- arg.type=ptype;
- arg.name=pname;
- arg.precision=pprecision;
+ arg.type = ptype;
+ arg.name = pname;
+ arg.precision = pprecision;
func_node->arguments.push_back(arg);
tk = _get_token();
-
- if (tk.type==TK_COMMA) {
+ if (tk.type == TK_COMMA) {
tk = _get_token();
//do none and go on
- } else if (tk.type!=TK_PARENTHESIS_CLOSE) {
+ } else if (tk.type != TK_PARENTHESIS_CLOSE) {
_set_error("Expected ',' or ')' after identifier");
return ERR_PARSE_ERROR;
}
-
}
if (p_functions.has(name)) {
//if one of the core functions, make sure they are of the correct form
if (func_node->arguments.size() > 0) {
- _set_error("Function '"+String(name)+"' expects no arguments.");
+ _set_error("Function '" + String(name) + "' expects no arguments.");
return ERR_PARSE_ERROR;
}
- if (func_node->return_type!=TYPE_VOID) {
- _set_error("Function '"+String(name)+"' must be of void return type.");
+ if (func_node->return_type != TYPE_VOID) {
+ _set_error("Function '" + String(name) + "' must be of void return type.");
return ERR_PARSE_ERROR;
}
}
-
//all good let's parse inside the fucntion!
tk = _get_token();
- if (tk.type!=TK_CURLY_BRACKET_OPEN) {
+ if (tk.type != TK_CURLY_BRACKET_OPEN) {
_set_error("Expected '{' to begin function");
return ERR_PARSE_ERROR;
}
current_function = name;
- Error err = _parse_block(func_node->body,builtin_types);
+ Error err = _parse_block(func_node->body, builtin_types);
if (err)
return err;
- current_function=StringName();
+ current_function = StringName();
}
}
@@ -3600,42 +3515,42 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
return OK;
}
-Error ShaderLanguage::compile(const String& p_code, const Map< StringName, Map<StringName,DataType> > &p_functions, const Set<String> &p_render_modes) {
+Error ShaderLanguage::compile(const String &p_code, const Map<StringName, Map<StringName, DataType> > &p_functions, const Set<String> &p_render_modes) {
clear();
- code=p_code;
+ code = p_code;
- nodes=NULL;
+ nodes = NULL;
shader = alloc_node<ShaderNode>();
- Error err = _parse_shader(p_functions,p_render_modes);
+ Error err = _parse_shader(p_functions, p_render_modes);
- if (err!=OK) {
+ if (err != OK) {
return err;
}
return OK;
}
-Error ShaderLanguage::complete(const String& p_code,const Map< StringName, Map<StringName,DataType> > &p_functions,const Set<String>& p_render_modes,List<String>* r_options,String& r_call_hint) {
+Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Map<StringName, DataType> > &p_functions, const Set<String> &p_render_modes, List<String> *r_options, String &r_call_hint) {
clear();
- code=p_code;
+ code = p_code;
- nodes=NULL;
+ nodes = NULL;
shader = alloc_node<ShaderNode>();
- Error err = _parse_shader(p_functions,p_render_modes);
+ Error err = _parse_shader(p_functions, p_render_modes);
- switch(completion_type) {
+ switch (completion_type) {
case COMPLETION_NONE: {
//do none
return ERR_PARSE_ERROR;
} break;
case COMPLETION_RENDER_MODE: {
- for(const Set<String>::Element *E=p_render_modes.front();E;E=E->next()) {
+ for (const Set<String>::Element *E = p_render_modes.front(); E; E = E->next()) {
r_options->push_back(E->get());
}
@@ -3644,7 +3559,7 @@ Error ShaderLanguage::complete(const String& p_code,const Map< StringName, Map<S
} break;
case COMPLETION_MAIN_FUNCTION: {
- for(const Map< StringName, Map<StringName,DataType> >::Element *E=p_functions.front();E;E=E->next()) {
+ for (const Map<StringName, Map<StringName, DataType> >::Element *E = p_functions.front(); E; E = E->next()) {
r_options->push_back(E->key());
}
@@ -3654,71 +3569,66 @@ Error ShaderLanguage::complete(const String& p_code,const Map< StringName, Map<S
case COMPLETION_IDENTIFIER:
case COMPLETION_FUNCTION_CALL: {
- bool comp_ident=completion_type==COMPLETION_IDENTIFIER;
+ bool comp_ident = completion_type == COMPLETION_IDENTIFIER;
Set<String> matches;
StringName skip_function;
- BlockNode *block=completion_block;
+ BlockNode *block = completion_block;
-
- while(block) {
+ while (block) {
if (comp_ident) {
- for (const Map<StringName,BlockNode::Variable>::Element *E=block->variables.front();E;E=E->next()) {
+ for (const Map<StringName, BlockNode::Variable>::Element *E = block->variables.front(); E; E = E->next()) {
- if (E->get().line<completion_line) {
+ if (E->get().line < completion_line) {
matches.insert(E->key());
}
}
}
-
if (block->parent_function) {
if (comp_ident) {
- for(int i=0;i<block->parent_function->arguments.size();i++) {
+ for (int i = 0; i < block->parent_function->arguments.size(); i++) {
matches.insert(block->parent_function->arguments[i].name);
}
}
- skip_function=block->parent_function->name;
+ skip_function = block->parent_function->name;
}
- block=block->parent_block;
+ block = block->parent_block;
}
- if (comp_ident && skip_function!=StringName() && p_functions.has(skip_function)) {
+ if (comp_ident && skip_function != StringName() && p_functions.has(skip_function)) {
- for (Map<StringName,DataType>::Element *E=p_functions[skip_function].front();E;E=E->next()) {
+ for (Map<StringName, DataType>::Element *E = p_functions[skip_function].front(); E; E = E->next()) {
matches.insert(E->key());
}
}
if (comp_ident) {
- for (const Map<StringName,ShaderNode::Varying>::Element *E=shader->varyings.front();E;E=E->next()) {
+ for (const Map<StringName, ShaderNode::Varying>::Element *E = shader->varyings.front(); E; E = E->next()) {
matches.insert(E->key());
-
}
- for (const Map<StringName,ShaderNode::Uniform>::Element *E=shader->uniforms.front();E;E=E->next()) {
+ for (const Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) {
matches.insert(E->key());
}
-
-
}
- for(int i=0;i<shader->functions.size();i++) {
- if (!shader->functions[i].callable || shader->functions[i].name==skip_function)
+ for (int i = 0; i < shader->functions.size(); i++) {
+ if (!shader->functions[i].callable || shader->functions[i].name == skip_function)
continue;
- matches.insert(String(shader->functions[i].name)+"(");
+ matches.insert(String(shader->functions[i].name) + "(");
}
- int idx=0;
+ int idx = 0;
while (builtin_func_defs[idx].name) {
- matches.insert(String(builtin_func_defs[idx].name)+"(");
+ matches.insert(String(builtin_func_defs[idx].name) + "(");
idx++;
}
- for(Set<String>::Element *E=matches.front();E;E=E->next()) {
+ for (Set<String>::Element *E = matches.front(); E; E = E->next()) {
r_options->push_back(E->get());
}
@@ -3727,118 +3637,112 @@ Error ShaderLanguage::complete(const String& p_code,const Map< StringName, Map<S
} break;
case COMPLETION_CALL_ARGUMENTS: {
- for(int i=0;i<shader->functions.size();i++) {
+ for (int i = 0; i < shader->functions.size(); i++) {
if (!shader->functions[i].callable)
continue;
- if (shader->functions[i].name==completion_function) {
+ if (shader->functions[i].name == completion_function) {
String calltip;
- calltip+=get_datatype_name( shader->functions[i].function->return_type );
- calltip+=" ";
- calltip+=shader->functions[i].name;
- calltip+="(";
+ calltip += get_datatype_name(shader->functions[i].function->return_type);
+ calltip += " ";
+ calltip += shader->functions[i].name;
+ calltip += "(";
- for(int j=0;j<shader->functions[i].function->arguments.size();j++) {
+ for (int j = 0; j < shader->functions[i].function->arguments.size(); j++) {
- if (j>0)
- calltip+=", ";
+ if (j > 0)
+ calltip += ", ";
else
- calltip+=" ";
+ calltip += " ";
- if (j==completion_argument) {
- calltip+=CharType(0xFFFF);
+ if (j == completion_argument) {
+ calltip += CharType(0xFFFF);
}
- calltip+=get_datatype_name(shader->functions[i].function->arguments[j].type);
- calltip+=" ";
- calltip+=shader->functions[i].function->arguments[j].name;
+ calltip += get_datatype_name(shader->functions[i].function->arguments[j].type);
+ calltip += " ";
+ calltip += shader->functions[i].function->arguments[j].name;
- if (j==completion_argument) {
- calltip+=CharType(0xFFFF);
+ if (j == completion_argument) {
+ calltip += CharType(0xFFFF);
}
-
}
if (shader->functions[i].function->arguments.size())
- calltip+=" ";
- calltip+=")";
+ calltip += " ";
+ calltip += ")";
- r_call_hint=calltip;
+ r_call_hint = calltip;
return OK;
}
-
}
- int idx=0;
+ int idx = 0;
String calltip;
while (builtin_func_defs[idx].name) {
- if (completion_function==builtin_func_defs[idx].name) {
+ if (completion_function == builtin_func_defs[idx].name) {
if (calltip.length())
- calltip+="\n";
+ calltip += "\n";
- calltip+=get_datatype_name( builtin_func_defs[idx].rettype );
- calltip+=" ";
- calltip+=builtin_func_defs[idx].name;
- calltip+="(";
+ calltip += get_datatype_name(builtin_func_defs[idx].rettype);
+ calltip += " ";
+ calltip += builtin_func_defs[idx].name;
+ calltip += "(";
- bool found_arg=false;
- for(int i=0;i<4;i++) {
+ bool found_arg = false;
+ for (int i = 0; i < 4; i++) {
- if (builtin_func_defs[idx].args[i]==TYPE_VOID)
+ if (builtin_func_defs[idx].args[i] == TYPE_VOID)
break;
- if (i>0)
- calltip+=", ";
+ if (i > 0)
+ calltip += ", ";
else
- calltip+=" ";
+ calltip += " ";
- if (i==completion_argument) {
- calltip+=CharType(0xFFFF);
+ if (i == completion_argument) {
+ calltip += CharType(0xFFFF);
}
- calltip+=get_datatype_name(builtin_func_defs[idx].args[i]);
+ calltip += get_datatype_name(builtin_func_defs[idx].args[i]);
- if (i==completion_argument) {
- calltip+=CharType(0xFFFF);
+ if (i == completion_argument) {
+ calltip += CharType(0xFFFF);
}
- found_arg=true;
-
+ found_arg = true;
}
if (found_arg)
- calltip+=" ";
- calltip+=")";
-
-
+ calltip += " ";
+ calltip += ")";
}
idx++;
}
- r_call_hint=calltip;
+ r_call_hint = calltip;
return OK;
} break;
case COMPLETION_INDEX: {
- const char colv[4]={'r','g','b','a'};
- const char coordv[4]={'x','y','z','w'};
+ const char colv[4] = { 'r', 'g', 'b', 'a' };
+ const char coordv[4] = { 'x', 'y', 'z', 'w' };
+ int limit = 0;
- int limit=0;
-
- switch(completion_base) {
+ switch (completion_base) {
case TYPE_BVEC2:
case TYPE_IVEC2:
case TYPE_UVEC2:
case TYPE_VEC2: {
- limit=2;
+ limit = 2;
} break;
case TYPE_BVEC3:
@@ -3846,7 +3750,7 @@ Error ShaderLanguage::complete(const String& p_code,const Map< StringName, Map<S
case TYPE_UVEC3:
case TYPE_VEC3: {
- limit=3;
+ limit = 3;
} break;
case TYPE_BVEC4:
@@ -3854,23 +3758,21 @@ Error ShaderLanguage::complete(const String& p_code,const Map< StringName, Map<S
case TYPE_UVEC4:
case TYPE_VEC4: {
- limit=4;
+ limit = 4;
} break;
- case TYPE_MAT2: limit=2; break;
- case TYPE_MAT3: limit=3; break;
- case TYPE_MAT4: limit=4; break;
+ case TYPE_MAT2: limit = 2; break;
+ case TYPE_MAT3: limit = 3; break;
+ case TYPE_MAT4: limit = 4; break;
default: {}
}
- for(int i=0;i<limit;i++) {
+ for (int i = 0; i < limit; i++) {
r_options->push_back(String::chr(colv[i]));
r_options->push_back(String::chr(coordv[i]));
}
} break;
-
-
}
return ERR_PARSE_ERROR;
@@ -3893,12 +3795,10 @@ ShaderLanguage::ShaderNode *ShaderLanguage::get_shader() {
ShaderLanguage::ShaderLanguage() {
- nodes=NULL;
+ nodes = NULL;
}
ShaderLanguage::~ShaderLanguage() {
clear();
}
-
-
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h
index 4f8717088e..a4757e3419 100644
--- a/servers/visual/shader_language.h
+++ b/servers/visual/shader_language.h
@@ -29,20 +29,16 @@
#ifndef SHADER_LANGUAGE_H
#define SHADER_LANGUAGE_H
-#include "typedefs.h"
-#include "ustring.h"
#include "list.h"
-#include "string_db.h"
#include "map.h"
+#include "string_db.h"
+#include "typedefs.h"
+#include "ustring.h"
#include "variant.h"
-
-class ShaderLanguage {
-
-
+class ShaderLanguage {
public:
-
enum TokenType {
TK_EMPTY,
@@ -149,12 +145,12 @@ public:
TK_MAX
};
- /* COMPILER */
+/* COMPILER */
- // lame work around to Apple defining this as a macro in 10.12 SDK
- #ifdef TYPE_BOOL
- #undef TYPE_BOOL
- #endif
+// lame work around to Apple defining this as a macro in 10.12 SDK
+#ifdef TYPE_BOOL
+#undef TYPE_BOOL
+#endif
enum DataType {
TYPE_VOID,
@@ -268,26 +264,29 @@ public:
virtual ~Node() {}
};
- template<class T>
- T* alloc_node() {
- T* node = memnew(T);
- node->next=nodes;
- nodes=node;
+ template <class T>
+ T *alloc_node() {
+ T *node = memnew(T);
+ node->next = nodes;
+ nodes = node;
return node;
}
Node *nodes;
-
struct OperatorNode : public Node {
DataType return_cache;
DataPrecision return_precision_cache;
Operator op;
- Vector<Node*> arguments;
+ Vector<Node *> arguments;
virtual DataType get_datatype() const { return return_cache; }
- OperatorNode() { type=TYPE_OPERATOR; return_cache=TYPE_VOID; return_precision_cache=PRECISION_DEFAULT; }
+ OperatorNode() {
+ type = TYPE_OPERATOR;
+ return_cache = TYPE_VOID;
+ return_precision_cache = PRECISION_DEFAULT;
+ }
};
struct VariableNode : public Node {
@@ -295,7 +294,10 @@ public:
StringName name;
virtual DataType get_datatype() const { return datatype_cache; }
- VariableNode() { type=TYPE_VARIABLE; datatype_cache=TYPE_VOID; }
+ VariableNode() {
+ type = TYPE_VARIABLE;
+ datatype_cache = TYPE_VOID;
+ }
};
struct ConstantNode : public Node {
@@ -312,7 +314,7 @@ public:
Vector<Value> values;
virtual DataType get_datatype() const { return datatype; }
- ConstantNode() { type=TYPE_CONSTANT; }
+ ConstantNode() { type = TYPE_CONSTANT; }
};
struct FunctionNode;
@@ -327,17 +329,24 @@ public:
int line; //for completion
};
- Map<StringName,Variable> variables;
- List<Node*> statements;
- BlockNode() { type=TYPE_BLOCK; parent_block=NULL; parent_function=NULL; }
+ Map<StringName, Variable> variables;
+ List<Node *> statements;
+ BlockNode() {
+ type = TYPE_BLOCK;
+ parent_block = NULL;
+ parent_function = NULL;
+ }
};
struct ControlFlowNode : public Node {
FlowOperation flow_op;
- Vector<Node*> expressions;
- Vector<BlockNode*> blocks;
- ControlFlowNode() { type=TYPE_CONTROL_FLOW; flow_op=FLOW_OP_IF;}
+ Vector<Node *> expressions;
+ Vector<BlockNode *> blocks;
+ ControlFlowNode() {
+ type = TYPE_CONTROL_FLOW;
+ flow_op = FLOW_OP_IF;
+ }
};
struct MemberNode : public Node {
@@ -345,15 +354,13 @@ public:
DataType basetype;
DataType datatype;
StringName name;
- Node* owner;
+ Node *owner;
virtual DataType get_datatype() const { return datatype; }
- MemberNode() { type=TYPE_MEMBER; }
+ MemberNode() { type = TYPE_MEMBER; }
};
-
struct FunctionNode : public Node {
-
struct Argument {
StringName name;
@@ -367,16 +374,17 @@ public:
Vector<Argument> arguments;
BlockNode *body;
- FunctionNode() { type=TYPE_FUNCTION; return_precision=PRECISION_DEFAULT; }
-
+ FunctionNode() {
+ type = TYPE_FUNCTION;
+ return_precision = PRECISION_DEFAULT;
+ }
};
-
struct ShaderNode : public Node {
struct Function {
StringName name;
- FunctionNode*function;
+ FunctionNode *function;
Set<StringName> uses_function;
bool callable;
};
@@ -408,20 +416,23 @@ public:
Hint hint;
float hint_range[3];
- Uniform() { hint=HINT_NONE; hint_range[0]=0; hint_range[1]=1; hint_range[2]=0.001;}
+ Uniform() {
+ hint = HINT_NONE;
+ hint_range[0] = 0;
+ hint_range[1] = 1;
+ hint_range[2] = 0.001;
+ }
};
-
- Map<StringName,Varying> varyings;
- Map<StringName,Uniform> uniforms;
+ Map<StringName, Varying> varyings;
+ Map<StringName, Uniform> uniforms;
Vector<StringName> render_modes;
Vector<Function> functions;
- ShaderNode() { type=TYPE_SHADER; }
+ ShaderNode() { type = TYPE_SHADER; }
};
-
struct Expression {
bool is_op;
@@ -431,8 +442,6 @@ public:
};
};
-
-
struct VarInfo {
StringName name;
@@ -457,7 +466,6 @@ public:
uint16_t line;
};
-
static String get_operator_text(Operator p_op);
static String get_token_text(Token p_token);
@@ -469,16 +477,19 @@ public:
static bool is_token_nonvoid_datatype(TokenType p_type);
static bool is_token_operator(TokenType p_type);
- static bool convert_constant(ConstantNode* p_constant, DataType p_to_type,ConstantNode::Value *p_value=NULL);
+ static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value = NULL);
static DataType get_scalar_type(DataType p_type);
static bool is_scalar_type(DataType p_type);
static bool is_sampler_type(DataType p_type);
static void get_keyword_list(List<String> *r_keywords);
static void get_builtin_funcs(List<String> *r_keywords);
-private:
- struct KeyWord { TokenType token; const char *text;};
+private:
+ struct KeyWord {
+ TokenType token;
+ const char *text;
+ };
static const KeyWord keyword_list[];
bool error_set;
@@ -498,33 +509,28 @@ private:
TkPos _get_tkpos() {
TkPos tkp;
- tkp.char_idx=char_idx;
- tkp.tk_line=tk_line;
+ tkp.char_idx = char_idx;
+ tkp.tk_line = tk_line;
return tkp;
}
-
void _set_tkpos(TkPos p_pos) {
- char_idx=p_pos.char_idx;
- tk_line=p_pos.tk_line;
+ char_idx = p_pos.char_idx;
+ tk_line = p_pos.tk_line;
}
- void _set_error(const String& p_str) {
+ void _set_error(const String &p_str) {
if (error_set)
return;
- error_line=tk_line;
- error_set=true;
- error_str=p_str;
+ error_line = tk_line;
+ error_set = true;
+ error_str = p_str;
}
+ static const char *token_names[TK_MAX];
- static const char * token_names[TK_MAX];
-
-
-
-
- Token _make_token(TokenType p_type, const StringName& p_text=StringName());
+ Token _make_token(TokenType p_type, const StringName &p_text = StringName());
Token _get_token();
ShaderNode *shader;
@@ -538,18 +544,16 @@ private:
IDENTIFIER_BUILTIN_VAR,
};
- bool _find_identifier(const BlockNode* p_block,const Map<StringName, DataType> &p_builtin_types,const StringName& p_identifier, DataType *r_data_type=NULL, IdentifierType *r_type=NULL);
-
- bool _validate_operator(OperatorNode *p_op,DataType *r_ret_type=NULL);
+ bool _find_identifier(const BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type = NULL, IdentifierType *r_type = NULL);
+ bool _validate_operator(OperatorNode *p_op, DataType *r_ret_type = NULL);
struct BuiltinFuncDef {
- enum { MAX_ARGS=5 };
- const char* name;
+ enum { MAX_ARGS = 5 };
+ const char *name;
DataType rettype;
const DataType args[MAX_ARGS];
-
};
CompletionType completion_type;
@@ -559,44 +563,38 @@ private:
StringName completion_function;
int completion_argument;
-
- bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName& identifier);
+ bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier);
static const BuiltinFuncDef builtin_func_defs[];
- bool _validate_function_call(BlockNode* p_block, OperatorNode *p_func,DataType *r_ret_type);
-
- bool _parse_function_arguments(BlockNode *p_block, const Map<StringName,DataType> &p_builtin_types, OperatorNode* p_func, int *r_complete_arg=NULL);
+ bool _validate_function_call(BlockNode *p_block, OperatorNode *p_func, DataType *r_ret_type);
- Node* _parse_expression(BlockNode *p_block, const Map<StringName,DataType> &p_builtin_types);
+ bool _parse_function_arguments(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg = NULL);
- ShaderLanguage::Node* _reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node);
- Node* _parse_and_reduce_expression(BlockNode *p_block,const Map<StringName,DataType> &p_builtin_types);
+ Node *_parse_expression(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types);
- Error _parse_block(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types, bool p_just_one=false, bool p_can_break=false, bool p_can_continue=false);
+ ShaderLanguage::Node *_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node);
+ Node *_parse_and_reduce_expression(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types);
- Error _parse_shader(const Map< StringName, Map<StringName,DataType> > &p_functions, const Set<String> &p_render_modes);
+ Error _parse_block(BlockNode *p_block, const Map<StringName, DataType> &p_builtin_types, bool p_just_one = false, bool p_can_break = false, bool p_can_continue = false);
+ Error _parse_shader(const Map<StringName, Map<StringName, DataType> > &p_functions, const Set<String> &p_render_modes);
public:
-
//static void get_keyword_list(ShaderType p_type,List<String> *p_keywords);
void clear();
- Error compile(const String& p_code,const Map< StringName, Map<StringName,DataType> > &p_functions,const Set<String>& p_render_modes);
- Error complete(const String& p_code,const Map< StringName, Map<StringName,DataType> > &p_functions,const Set<String>& p_render_modes,List<String>* r_options,String& r_call_hint);
-
-
+ Error compile(const String &p_code, const Map<StringName, Map<StringName, DataType> > &p_functions, const Set<String> &p_render_modes);
+ Error complete(const String &p_code, const Map<StringName, Map<StringName, DataType> > &p_functions, const Set<String> &p_render_modes, List<String> *r_options, String &r_call_hint);
String get_error_text();
int get_error_line();
ShaderNode *get_shader();
- String token_debug(const String& p_code);
+ String token_debug(const String &p_code);
ShaderLanguage();
~ShaderLanguage();
};
-
#endif // SHADER_LANGUAGE_H
diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp
index d119e81a4b..cd9afa7735 100644
--- a/servers/visual/shader_types.cpp
+++ b/servers/visual/shader_types.cpp
@@ -28,85 +28,82 @@
/*************************************************************************/
#include "shader_types.h"
-
-const Map< StringName, Map<StringName,ShaderLanguage::DataType> >& ShaderTypes::get_functions(VS::ShaderMode p_mode) {
+const Map<StringName, Map<StringName, ShaderLanguage::DataType> > &ShaderTypes::get_functions(VS::ShaderMode p_mode) {
return shader_modes[p_mode].functions;
}
-const Set<String>& ShaderTypes::get_modes(VS::ShaderMode p_mode) {
+const Set<String> &ShaderTypes::get_modes(VS::ShaderMode p_mode) {
return shader_modes[p_mode].modes;
}
+ShaderTypes *ShaderTypes::singleton = NULL;
-ShaderTypes *ShaderTypes::singleton=NULL;
-
-ShaderTypes::ShaderTypes()
-{
- singleton=this;
+ShaderTypes::ShaderTypes() {
+ singleton = this;
/*************** SPATIAL ***********************/
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_VERTEX"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_NORMAL"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_TANGENT"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_BONES"]=ShaderLanguage::TYPE_IVEC4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_WEIGHTS"]=ShaderLanguage::TYPE_VEC4;
-
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["POSITION"]=ShaderLanguage::TYPE_VEC4 ;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["VERTEX"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["NORMAL"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["TANGENT"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["BINORMAL"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["UV2"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["COLOR"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["POINT_SIZE"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["INSTANCE_ID"]=ShaderLanguage::TYPE_INT;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_VERTEX"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_TANGENT"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_BONES"] = ShaderLanguage::TYPE_IVEC4;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["SRC_WEIGHTS"] = ShaderLanguage::TYPE_VEC4;
+
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["POSITION"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["VERTEX"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["TANGENT"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["UV2"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["INSTANCE_ID"] = ShaderLanguage::TYPE_INT;
//builtins
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["WORLD_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["INV_CAMERA_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["PROJECTION_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["TIME"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["VIEWPORT_SIZE"]=ShaderLanguage::TYPE_VEC2;
-
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["VERTEX"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["FRAGCOORD"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["FRONT_FACING"]=ShaderLanguage::TYPE_BOOL;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["NORMAL"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["TANGENT"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["BINORMAL"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["NORMALMAP"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["NORMALMAP_DEPTH"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["UV2"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["COLOR"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["NORMAL"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ALBEDO"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ALPHA"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SPECULAR"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ROUGHNESS"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["RIM"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["RIM_TINT"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["CLEARCOAT"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["CLEARCOAT_GLOSS"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ANISOTROPY"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ANISOTROPY_FLOW"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SSS_STRENGTH"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["AO"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["EMISSION"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SPECIAL"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["DISCARD"]=ShaderLanguage::TYPE_BOOL;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SCREEN_UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["POINT_COORD"]=ShaderLanguage::TYPE_VEC2;
-
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["WORLD_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["INV_CAMERA_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["PROJECTION_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["TIME"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["VIEWPORT_SIZE"]=ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["INV_CAMERA_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["vertex"]["VIEWPORT_SIZE"] = ShaderLanguage::TYPE_VEC2;
+
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["VERTEX"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["FRAGCOORD"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["FRONT_FACING"] = ShaderLanguage::TYPE_BOOL;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["TANGENT"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["UV2"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ALBEDO"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SPECULAR"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["RIM"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["RIM_TINT"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["CLEARCOAT"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["CLEARCOAT_GLOSS"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ANISOTROPY"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ANISOTROPY_FLOW"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["AO"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["EMISSION"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SPECIAL"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["DISCARD"] = ShaderLanguage::TYPE_BOOL;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["POINT_COORD"] = ShaderLanguage::TYPE_VEC2;
+
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["INV_CAMERA_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["VIEWPORT_SIZE"] = ShaderLanguage::TYPE_VEC2;
shader_modes[VS::SHADER_SPATIAL].modes.insert("blend_mix");
shader_modes[VS::SHADER_SPATIAL].modes.insert("blend_add");
@@ -129,48 +126,48 @@ ShaderTypes::ShaderTypes()
/************ CANVAS ITEM **************************/
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["SRC_VERTEX"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["VERTEX"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["VERTEX_COLOR"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["POINT_SIZE"]=ShaderLanguage::TYPE_FLOAT;
-
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["WORLD_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["PROJECTION_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["EXTRA_MATRIX"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["TIME"]=ShaderLanguage::TYPE_FLOAT;
-
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SRC_COLOR"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POSITION"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMAL"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMALMAP"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMALMAP_DEPTH"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["COLOR"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TEXTURE"]=ShaderLanguage::TYPE_SAMPLER2D;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TEXTURE_PIXEL_SIZE"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SCREEN_UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POINT_COORD"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TIME"]=ShaderLanguage::TYPE_FLOAT;
-
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POSITION"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["NORMAL"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["COLOR"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["TEXTURE"]=ShaderLanguage::TYPE_SAMPLER2D;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["TEXTURE_PIXEL_SIZE"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["VAR1"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["VAR2"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["SCREEN_UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_VEC"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_HEIGHT"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_COLOR"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_UV"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_SHADOW"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["SHADOW"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POINT_COORD"]=ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["TIME"]=ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["SRC_VERTEX"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["VERTEX"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["VERTEX_COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
+
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["EXTRA_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
+
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SRC_COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POSITION"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TEXTURE_PIXEL_SIZE"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POINT_COORD"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
+
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POSITION"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["TEXTURE_PIXEL_SIZE"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["VAR1"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["VAR2"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_VEC"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_HEIGHT"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT_SHADOW"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["LIGHT"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["SHADOW"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POINT_COORD"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("skip_transform");
@@ -183,28 +180,23 @@ ShaderTypes::ShaderTypes()
shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("unshaded");
shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("light_only");
-
/************ PARTICLES **************************/
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["COLOR"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["VELOCITY"]=ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["MASS"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["ACTIVE"]=ShaderLanguage::TYPE_BOOL;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["RESTART"]=ShaderLanguage::TYPE_BOOL;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["CUSTOM"]=ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["TRANSFORM"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["TIME"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["LIFETIME"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["DELTA"]=ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["SEED"]=ShaderLanguage::TYPE_BOOL;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["ORIGIN"]=ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["INDEX"]=ShaderLanguage::TYPE_INT;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["VELOCITY"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["MASS"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["ACTIVE"] = ShaderLanguage::TYPE_BOOL;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["RESTART"] = ShaderLanguage::TYPE_BOOL;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["CUSTOM"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["TRANSFORM"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["LIFETIME"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["DELTA"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["SEED"] = ShaderLanguage::TYPE_BOOL;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["ORIGIN"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[VS::SHADER_PARTICLES].functions["vertex"]["INDEX"] = ShaderLanguage::TYPE_INT;
shader_modes[VS::SHADER_PARTICLES].modes.insert("billboard");
shader_modes[VS::SHADER_PARTICLES].modes.insert("disable_force");
shader_modes[VS::SHADER_PARTICLES].modes.insert("disable_velocity");
-
-
-
-
}
diff --git a/servers/visual/shader_types.h b/servers/visual/shader_types.h
index b8a96af922..1bddde8c82 100644
--- a/servers/visual/shader_types.h
+++ b/servers/visual/shader_types.h
@@ -29,25 +29,25 @@
#ifndef SHADERTYPES_H
#define SHADERTYPES_H
-#include "shader_language.h"
#include "servers/visual_server.h"
+#include "shader_language.h"
class ShaderTypes {
-
struct Type {
- Map< StringName, Map<StringName,ShaderLanguage::DataType> > functions;
- Set<String> modes;
+ Map<StringName, Map<StringName, ShaderLanguage::DataType> > functions;
+ Set<String> modes;
};
- Map<VS::ShaderMode,Type> shader_modes;
+ Map<VS::ShaderMode, Type> shader_modes;
static ShaderTypes *singleton;
+
public:
static ShaderTypes *get_singleton() { return singleton; }
- const Map< StringName, Map<StringName,ShaderLanguage::DataType> >& get_functions(VS::ShaderMode p_mode);
- const Set<String>& get_modes(VS::ShaderMode p_mode);
+ const Map<StringName, Map<StringName, ShaderLanguage::DataType> > &get_functions(VS::ShaderMode p_mode);
+ const Set<String> &get_modes(VS::ShaderMode p_mode);
ShaderTypes();
};
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index 84cc1a968d..40fa779170 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -30,30 +30,27 @@
#include "visual_server_global.h"
#include "visual_server_viewport.h"
-void VisualServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, const Color& p_modulate, RasterizerCanvas::Light *p_lights) {
+void VisualServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) {
-
- static const int z_range = VS::CANVAS_ITEM_Z_MAX-VS::CANVAS_ITEM_Z_MIN+1;
+ static const int z_range = VS::CANVAS_ITEM_Z_MAX - VS::CANVAS_ITEM_Z_MIN + 1;
RasterizerCanvas::Item *z_list[z_range];
RasterizerCanvas::Item *z_last_list[z_range];
- for(int i=0;i<z_range;i++) {
- z_list[i]=NULL;
- z_last_list[i]=NULL;
+ for (int i = 0; i < z_range; i++) {
+ z_list[i] = NULL;
+ z_last_list[i] = NULL;
}
+ _render_canvas_item(p_canvas_item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL);
- _render_canvas_item(p_canvas_item,p_transform,p_clip_rect,Color(1,1,1,1),0,z_list,z_last_list,NULL,NULL);
-
- for(int i=0;i<z_range;i++) {
+ for (int i = 0; i < z_range; i++) {
if (!z_list[i])
continue;
- VSG::canvas_render->canvas_render_items(z_list[i],VS::CANVAS_ITEM_Z_MIN+i,p_modulate,p_lights);
+ VSG::canvas_render->canvas_render_items(z_list[i], VS::CANVAS_ITEM_Z_MIN + i, p_modulate, p_lights);
}
-
}
-void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item,const Transform2D& p_transform,const Rect2& p_clip_rect, const Color &p_modulate,int p_z,RasterizerCanvas::Item **z_list,RasterizerCanvas::Item **z_last_list,Item *p_canvas_clip,Item *p_material_owner) {
+void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) {
Item *ci = p_canvas_item;
@@ -63,55 +60,52 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item,const Transform
Rect2 rect = ci->get_rect();
Transform2D xform = p_transform * ci->xform;
Rect2 global_rect = xform.xform(rect);
- global_rect.pos+=p_clip_rect.pos;
-
+ global_rect.pos += p_clip_rect.pos;
if (ci->use_parent_material && p_material_owner)
- ci->material_owner=p_material_owner;
+ ci->material_owner = p_material_owner;
else {
- p_material_owner=ci;
- ci->material_owner=NULL;
+ p_material_owner = ci;
+ ci->material_owner = NULL;
}
+ Color modulate(ci->modulate.r * p_modulate.r, ci->modulate.g * p_modulate.g, ci->modulate.b * p_modulate.b, ci->modulate.a * p_modulate.a);
- Color modulate( ci->modulate.r * p_modulate.r, ci->modulate.g * p_modulate.g,ci->modulate.b * p_modulate.b,ci->modulate.a * p_modulate.a);
-
- if (modulate.a<0.007)
+ if (modulate.a < 0.007)
return;
-
- int child_item_count=ci->child_items.size();
- Item **child_items=(Item**)alloca(child_item_count*sizeof(Item*));
- copymem(child_items,ci->child_items.ptr(),child_item_count*sizeof(Item*));
+ int child_item_count = ci->child_items.size();
+ Item **child_items = (Item **)alloca(child_item_count * sizeof(Item *));
+ copymem(child_items, ci->child_items.ptr(), child_item_count * sizeof(Item *));
if (ci->clip) {
if (p_canvas_clip != NULL) {
- ci->final_clip_rect=p_canvas_clip->final_clip_rect.clip(global_rect);
+ ci->final_clip_rect = p_canvas_clip->final_clip_rect.clip(global_rect);
} else {
- ci->final_clip_rect=global_rect;
+ ci->final_clip_rect = global_rect;
}
- ci->final_clip_owner=ci;
+ ci->final_clip_owner = ci;
} else {
- ci->final_clip_owner=p_canvas_clip;
+ ci->final_clip_owner = p_canvas_clip;
}
if (ci->sort_y) {
- SortArray<Item*,ItemPtrSort> sorter;
- sorter.sort(child_items,child_item_count);
+ SortArray<Item *, ItemPtrSort> sorter;
+ sorter.sort(child_items, child_item_count);
}
if (ci->z_relative)
- p_z=CLAMP(p_z+ci->z,VS::CANVAS_ITEM_Z_MIN,VS::CANVAS_ITEM_Z_MAX);
+ p_z = CLAMP(p_z + ci->z, VS::CANVAS_ITEM_Z_MIN, VS::CANVAS_ITEM_Z_MAX);
else
- p_z=ci->z;
+ p_z = ci->z;
- for(int i=0;i<child_item_count;i++) {
+ for (int i = 0; i < child_item_count; i++) {
if (!child_items[i]->behind)
continue;
- _render_canvas_item(child_items[i],xform,p_clip_rect,modulate,p_z,z_list,z_last_list,(Item*)ci->final_clip_owner,p_material_owner);
+ _render_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner);
}
if (ci->copy_back_buffer) {
@@ -121,61 +115,55 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item,const Transform
if ((!ci->commands.empty() && p_clip_rect.intersects(global_rect)) || ci->vp_render || ci->copy_back_buffer) {
//something to draw?
- ci->final_transform=xform;
- ci->final_modulate=Color(modulate.r*ci->self_modulate.r, modulate.g*ci->self_modulate.g, modulate.b*ci->self_modulate.b, modulate.a*ci->self_modulate.a );
- ci->global_rect_cache=global_rect;
- ci->global_rect_cache.pos-=p_clip_rect.pos;
- ci->light_masked=false;
+ ci->final_transform = xform;
+ ci->final_modulate = Color(modulate.r * ci->self_modulate.r, modulate.g * ci->self_modulate.g, modulate.b * ci->self_modulate.b, modulate.a * ci->self_modulate.a);
+ ci->global_rect_cache = global_rect;
+ ci->global_rect_cache.pos -= p_clip_rect.pos;
+ ci->light_masked = false;
- int zidx = p_z-VS::CANVAS_ITEM_Z_MIN;
+ int zidx = p_z - VS::CANVAS_ITEM_Z_MIN;
if (z_last_list[zidx]) {
- z_last_list[zidx]->next=ci;
- z_last_list[zidx]=ci;
+ z_last_list[zidx]->next = ci;
+ z_last_list[zidx] = ci;
} else {
- z_list[zidx]=ci;
- z_last_list[zidx]=ci;
+ z_list[zidx] = ci;
+ z_last_list[zidx] = ci;
}
- ci->next=NULL;
-
+ ci->next = NULL;
}
- for(int i=0;i<child_item_count;i++) {
+ for (int i = 0; i < child_item_count; i++) {
if (child_items[i]->behind)
continue;
- _render_canvas_item(child_items[i],xform,p_clip_rect,modulate,p_z,z_list,z_last_list,(Item*)ci->final_clip_owner,p_material_owner);
+ _render_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner);
}
-
}
-void VisualServerCanvas::_light_mask_canvas_items(int p_z,RasterizerCanvas::Item *p_canvas_item,RasterizerCanvas::Light *p_masked_lights) {
+void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights) {
if (!p_masked_lights)
return;
- RasterizerCanvas::Item *ci=p_canvas_item;
+ RasterizerCanvas::Item *ci = p_canvas_item;
- while(ci) {
+ while (ci) {
- RasterizerCanvas::Light *light=p_masked_lights;
- while(light) {
+ RasterizerCanvas::Light *light = p_masked_lights;
+ while (light) {
- if (ci->light_mask&light->item_mask && p_z>=light->z_min && p_z<=light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache,light->rect_cache)) {
- ci->light_masked=true;
+ if (ci->light_mask & light->item_mask && p_z >= light->z_min && p_z <= light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache)) {
+ ci->light_masked = true;
}
- light=light->mask_next_ptr;
+ light = light->mask_next_ptr;
}
- ci=ci->next;
+ ci = ci->next;
}
-
-
-
-
}
void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) {
@@ -183,112 +171,105 @@ void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_tr
VSG::canvas_render->canvas_begin();
int l = p_canvas->child_items.size();
- Canvas::ChildItem *ci=p_canvas->child_items.ptr();
+ Canvas::ChildItem *ci = p_canvas->child_items.ptr();
- bool has_mirror=false;
- for(int i=0;i<l;i++) {
+ bool has_mirror = false;
+ for (int i = 0; i < l; i++) {
if (ci[i].mirror.x || ci[i].mirror.y) {
- has_mirror=true;
+ has_mirror = true;
break;
}
}
-
if (!has_mirror) {
- static const int z_range = VS::CANVAS_ITEM_Z_MAX-VS::CANVAS_ITEM_Z_MIN+1;
+ static const int z_range = VS::CANVAS_ITEM_Z_MAX - VS::CANVAS_ITEM_Z_MIN + 1;
RasterizerCanvas::Item *z_list[z_range];
RasterizerCanvas::Item *z_last_list[z_range];
- for(int i=0;i<z_range;i++) {
- z_list[i]=NULL;
- z_last_list[i]=NULL;
+ for (int i = 0; i < z_range; i++) {
+ z_list[i] = NULL;
+ z_last_list[i] = NULL;
}
- for(int i=0;i<l;i++) {
- _render_canvas_item(ci[i].item,p_transform,p_clip_rect,Color(1,1,1,1),0,z_list,z_last_list,NULL,NULL);
+ for (int i = 0; i < l; i++) {
+ _render_canvas_item(ci[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL);
}
- for(int i=0;i<z_range;i++) {
+ for (int i = 0; i < z_range; i++) {
if (!z_list[i])
continue;
if (p_masked_lights) {
- _light_mask_canvas_items(VS::CANVAS_ITEM_Z_MIN+i,z_list[i],p_masked_lights);
+ _light_mask_canvas_items(VS::CANVAS_ITEM_Z_MIN + i, z_list[i], p_masked_lights);
}
- VSG::canvas_render->canvas_render_items(z_list[i],VS::CANVAS_ITEM_Z_MIN+i,p_canvas->modulate,p_lights);
+ VSG::canvas_render->canvas_render_items(z_list[i], VS::CANVAS_ITEM_Z_MIN + i, p_canvas->modulate, p_lights);
}
} else {
- for(int i=0;i<l;i++) {
+ for (int i = 0; i < l; i++) {
- Canvas::ChildItem& ci=p_canvas->child_items[i];
- _render_canvas_item_tree(ci.item,p_transform,p_clip_rect,p_canvas->modulate,p_lights);
+ Canvas::ChildItem &ci = p_canvas->child_items[i];
+ _render_canvas_item_tree(ci.item, p_transform, p_clip_rect, p_canvas->modulate, p_lights);
//mirroring (useful for scrolling backgrounds)
- if (ci.mirror.x!=0) {
+ if (ci.mirror.x != 0) {
- Transform2D xform2 = p_transform * Transform2D(0,Vector2(ci.mirror.x,0));
- _render_canvas_item_tree(ci.item,xform2,p_clip_rect,p_canvas->modulate,p_lights);
+ Transform2D xform2 = p_transform * Transform2D(0, Vector2(ci.mirror.x, 0));
+ _render_canvas_item_tree(ci.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
}
- if (ci.mirror.y!=0) {
+ if (ci.mirror.y != 0) {
- Transform2D xform2 = p_transform * Transform2D(0,Vector2(0,ci.mirror.y));
- _render_canvas_item_tree(ci.item,xform2,p_clip_rect,p_canvas->modulate,p_lights);
+ Transform2D xform2 = p_transform * Transform2D(0, Vector2(0, ci.mirror.y));
+ _render_canvas_item_tree(ci.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
}
- if (ci.mirror.y!=0 && ci.mirror.x!=0) {
+ if (ci.mirror.y != 0 && ci.mirror.x != 0) {
- Transform2D xform2 = p_transform * Transform2D(0,ci.mirror);
- _render_canvas_item_tree(ci.item,xform2,p_clip_rect,p_canvas->modulate,p_lights);
+ Transform2D xform2 = p_transform * Transform2D(0, ci.mirror);
+ _render_canvas_item_tree(ci.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
}
-
}
}
-
}
-
RID VisualServerCanvas::canvas_create() {
- Canvas * canvas = memnew( Canvas );
- ERR_FAIL_COND_V(!canvas,RID());
- RID rid = canvas_owner.make_rid( canvas );
+ Canvas *canvas = memnew(Canvas);
+ ERR_FAIL_COND_V(!canvas, RID());
+ RID rid = canvas_owner.make_rid(canvas);
return rid;
}
-void VisualServerCanvas::canvas_set_item_mirroring(RID p_canvas,RID p_item,const Point2& p_mirroring) {
+void VisualServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) {
- Canvas * canvas = canvas_owner.getornull(p_canvas);
+ Canvas *canvas = canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
int idx = canvas->find_item(canvas_item);
- ERR_FAIL_COND(idx==-1);
- canvas->child_items[idx].mirror=p_mirroring;
-
+ ERR_FAIL_COND(idx == -1);
+ canvas->child_items[idx].mirror = p_mirroring;
}
-void VisualServerCanvas::canvas_set_modulate(RID p_canvas,const Color& p_color) {
+void VisualServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) {
- Canvas * canvas = canvas_owner.get(p_canvas);
+ Canvas *canvas = canvas_owner.get(p_canvas);
ERR_FAIL_COND(!canvas);
- canvas->modulate=p_color;
+ canvas->modulate = p_color;
}
-
RID VisualServerCanvas::canvas_item_create() {
- Item *canvas_item = memnew( Item );
- ERR_FAIL_COND_V(!canvas_item,RID());
+ Item *canvas_item = memnew(Item);
+ ERR_FAIL_COND_V(!canvas_item, RID());
- return canvas_item_owner.make_rid( canvas_item );
+ return canvas_item_owner.make_rid(canvas_item);
}
-void VisualServerCanvas::canvas_item_set_parent(RID p_item,RID p_parent) {
-
+void VisualServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
if (canvas_item->parent.is_valid()) {
@@ -303,285 +284,262 @@ void VisualServerCanvas::canvas_item_set_parent(RID p_item,RID p_parent) {
item_owner->child_items.erase(canvas_item);
}
- canvas_item->parent=RID();
+ canvas_item->parent = RID();
}
-
if (p_parent.is_valid()) {
if (canvas_owner.owns(p_parent)) {
Canvas *canvas = canvas_owner.get(p_parent);
Canvas::ChildItem ci;
- ci.item=canvas_item;
+ ci.item = canvas_item;
canvas->child_items.push_back(ci);
- canvas->children_order_dirty=true;
+ canvas->children_order_dirty = true;
} else if (canvas_item_owner.owns(p_parent)) {
Item *item_owner = canvas_item_owner.get(p_parent);
item_owner->child_items.push_back(canvas_item);
- item_owner->children_order_dirty=true;
+ item_owner->children_order_dirty = true;
} else {
ERR_EXPLAIN("Invalid parent");
ERR_FAIL();
}
-
-
}
- canvas_item->parent=p_parent;
-
-
+ canvas_item->parent = p_parent;
}
-void VisualServerCanvas::canvas_item_set_visible(RID p_item,bool p_visible){
+void VisualServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->visible=p_visible;
-
+ canvas_item->visible = p_visible;
}
-void VisualServerCanvas::canvas_item_set_light_mask(RID p_item,int p_mask){
+void VisualServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->light_mask=p_mask;
-
+ canvas_item->light_mask = p_mask;
}
-void VisualServerCanvas::canvas_item_set_transform(RID p_item, const Transform2D& p_transform){
+void VisualServerCanvas::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->xform=p_transform;
-
+ canvas_item->xform = p_transform;
}
-void VisualServerCanvas::canvas_item_set_clip(RID p_item, bool p_clip){
+void VisualServerCanvas::canvas_item_set_clip(RID p_item, bool p_clip) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->clip=p_clip;
-
+ canvas_item->clip = p_clip;
}
-void VisualServerCanvas::canvas_item_set_distance_field_mode(RID p_item, bool p_enable){
+void VisualServerCanvas::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->distance_field=p_enable;
-
-
+ canvas_item->distance_field = p_enable;
}
-void VisualServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect,const Rect2& p_rect){
+void VisualServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->custom_rect=p_custom_rect;
- canvas_item->rect=p_rect;
-
+ canvas_item->custom_rect = p_custom_rect;
+ canvas_item->rect = p_rect;
}
-void VisualServerCanvas::canvas_item_set_modulate(RID p_item, const Color& p_color) {
+void VisualServerCanvas::canvas_item_set_modulate(RID p_item, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->modulate=p_color;
-
+ canvas_item->modulate = p_color;
}
-void VisualServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color& p_color){
+void VisualServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->self_modulate=p_color;
-
+ canvas_item->self_modulate = p_color;
}
-void VisualServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable){
+void VisualServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->behind=p_enable;
-
+ canvas_item->behind = p_enable;
}
+void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width, bool p_antialiased) {
-void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width,bool p_antialiased) {
-
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandLine * line = memnew( Item::CommandLine );
+ Item::CommandLine *line = memnew(Item::CommandLine);
ERR_FAIL_COND(!line);
- line->color=p_color;
- line->from=p_from;
- line->to=p_to;
- line->width=p_width;
- line->antialiased=p_antialiased;
- canvas_item->rect_dirty=true;
-
+ line->color = p_color;
+ line->from = p_from;
+ line->to = p_to;
+ line->width = p_width;
+ line->antialiased = p_antialiased;
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(line);
}
-void VisualServerCanvas::canvas_item_add_rect(RID p_item, const Rect2& p_rect, const Color& p_color) {
+void VisualServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandRect * rect = memnew( Item::CommandRect );
+ Item::CommandRect *rect = memnew(Item::CommandRect);
ERR_FAIL_COND(!rect);
- rect->modulate=p_color;
- rect->rect=p_rect;
- canvas_item->rect_dirty=true;
+ rect->modulate = p_color;
+ rect->rect = p_rect;
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(rect);
}
-void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2& p_pos, float p_radius,const Color& p_color) {
-
+void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandCircle * circle = memnew( Item::CommandCircle );
+ Item::CommandCircle *circle = memnew(Item::CommandCircle);
ERR_FAIL_COND(!circle);
- circle->color=p_color;
- circle->pos=p_pos;
- circle->radius=p_radius;
+ circle->color = p_color;
+ circle->pos = p_pos;
+ circle->radius = p_radius;
canvas_item->commands.push_back(circle);
-
}
-void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile,const Color& p_modulate,bool p_transpose) {
+void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandRect * rect = memnew( Item::CommandRect );
+ Item::CommandRect *rect = memnew(Item::CommandRect);
ERR_FAIL_COND(!rect);
- rect->modulate=p_modulate;
- rect->rect=p_rect;
- rect->flags=0;
+ rect->modulate = p_modulate;
+ rect->rect = p_rect;
+ rect->flags = 0;
if (p_tile) {
- rect->flags|=RasterizerCanvas::CANVAS_RECT_TILE;
- rect->flags|=RasterizerCanvas::CANVAS_RECT_REGION;
- rect->source=Rect2(0,0,p_rect.size.width,p_rect.size.height);
+ rect->flags |= RasterizerCanvas::CANVAS_RECT_TILE;
+ rect->flags |= RasterizerCanvas::CANVAS_RECT_REGION;
+ rect->source = Rect2(0, 0, p_rect.size.width, p_rect.size.height);
}
- if (p_rect.size.x<0) {
+ if (p_rect.size.x < 0) {
- rect->flags|=RasterizerCanvas::CANVAS_RECT_FLIP_H;
+ rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H;
rect->rect.size.x = -rect->rect.size.x;
}
- if (p_rect.size.y<0) {
+ if (p_rect.size.y < 0) {
- rect->flags|=RasterizerCanvas::CANVAS_RECT_FLIP_V;
+ rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V;
rect->rect.size.y = -rect->rect.size.y;
}
if (p_transpose) {
- rect->flags|=RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
+ rect->flags |= RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
SWAP(rect->rect.size.x, rect->rect.size.y);
}
- rect->texture=p_texture;
- canvas_item->rect_dirty=true;
+ rect->texture = p_texture;
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(rect);
}
-void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate,bool p_transpose) {
+void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandRect * rect = memnew( Item::CommandRect );
+ Item::CommandRect *rect = memnew(Item::CommandRect);
ERR_FAIL_COND(!rect);
- rect->modulate=p_modulate;
- rect->rect=p_rect;
- rect->texture=p_texture;
- rect->source=p_src_rect;
- rect->flags=RasterizerCanvas::CANVAS_RECT_REGION;
+ rect->modulate = p_modulate;
+ rect->rect = p_rect;
+ rect->texture = p_texture;
+ rect->source = p_src_rect;
+ rect->flags = RasterizerCanvas::CANVAS_RECT_REGION;
- if (p_rect.size.x<0) {
+ if (p_rect.size.x < 0) {
- rect->flags|=RasterizerCanvas::CANVAS_RECT_FLIP_H;
+ rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H;
rect->rect.size.x = -rect->rect.size.x;
}
- if (p_rect.size.y<0) {
+ if (p_rect.size.y < 0) {
- rect->flags|=RasterizerCanvas::CANVAS_RECT_FLIP_V;
+ rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V;
rect->rect.size.y = -rect->rect.size.y;
}
if (p_transpose) {
- rect->flags|=RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
+ rect->flags |= RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
SWAP(rect->rect.size.x, rect->rect.size.y);
}
- canvas_item->rect_dirty=true;
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(rect);
-
}
-void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2& p_rect, const Rect2& p_source, RID p_texture,const Vector2& p_topleft, const Vector2& p_bottomright,VS::NinePatchAxisMode p_x_axis_mode, VS::NinePatchAxisMode p_y_axis_mode,bool p_draw_center,const Color& p_modulate) {
-
+void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode, VS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate) {
-
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandNinePatch * style = memnew( Item::CommandNinePatch );
+ Item::CommandNinePatch *style = memnew(Item::CommandNinePatch);
ERR_FAIL_COND(!style);
- style->texture=p_texture;
- style->rect=p_rect;
- style->source=p_source;
- style->draw_center=p_draw_center;
- style->color=p_modulate;
- style->margin[MARGIN_LEFT]=p_topleft.x;
- style->margin[MARGIN_TOP]=p_topleft.y;
- style->margin[MARGIN_RIGHT]=p_bottomright.x;
- style->margin[MARGIN_BOTTOM]=p_bottomright.y;
- style->axis_x=p_x_axis_mode;
- style->axis_y=p_y_axis_mode;
- canvas_item->rect_dirty=true;
+ style->texture = p_texture;
+ style->rect = p_rect;
+ style->source = p_source;
+ style->draw_center = p_draw_center;
+ style->color = p_modulate;
+ style->margin[MARGIN_LEFT] = p_topleft.x;
+ style->margin[MARGIN_TOP] = p_topleft.y;
+ style->margin[MARGIN_RIGHT] = p_bottomright.x;
+ style->margin[MARGIN_BOTTOM] = p_bottomright.y;
+ style->axis_x = p_x_axis_mode;
+ style->axis_y = p_y_axis_mode;
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(style);
}
-void VisualServerCanvas::canvas_item_add_primitive(RID p_item,const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width) {
+void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandPrimitive * prim = memnew( Item::CommandPrimitive );
+ Item::CommandPrimitive *prim = memnew(Item::CommandPrimitive);
ERR_FAIL_COND(!prim);
- prim->texture=p_texture;
- prim->points=p_points;
- prim->uvs=p_uvs;
- prim->colors=p_colors;
- prim->width=p_width;
- canvas_item->rect_dirty=true;
+ prim->texture = p_texture;
+ prim->points = p_points;
+ prim->uvs = p_uvs;
+ prim->colors = p_colors;
+ prim->width = p_width;
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(prim);
}
-void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture) {
-
+void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
#ifdef DEBUG_ENABLED
int pointcount = p_points.size();
- ERR_FAIL_COND(pointcount<3);
- int color_size=p_colors.size();
- int uv_size=p_uvs.size();
- ERR_FAIL_COND(color_size!=0 && color_size!=1 && color_size!=pointcount);
- ERR_FAIL_COND(uv_size!=0 && (uv_size!=pointcount || !p_texture.is_valid()));
+ ERR_FAIL_COND(pointcount < 3);
+ int color_size = p_colors.size();
+ int uv_size = p_uvs.size();
+ ERR_FAIL_COND(color_size != 0 && color_size != 1 && color_size != pointcount);
+ ERR_FAIL_COND(uv_size != 0 && (uv_size != pointcount || !p_texture.is_valid()));
#endif
Vector<int> indices = Geometry::triangulate_polygon(p_points);
@@ -591,30 +549,27 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2
ERR_FAIL_V();
}
- Item::CommandPolygon * polygon = memnew( Item::CommandPolygon );
+ Item::CommandPolygon *polygon = memnew(Item::CommandPolygon);
ERR_FAIL_COND(!polygon);
- polygon->texture=p_texture;
- polygon->points=p_points;
- polygon->uvs=p_uvs;
- polygon->colors=p_colors;
- polygon->indices=indices;
- polygon->count=indices.size();
- canvas_item->rect_dirty=true;
+ polygon->texture = p_texture;
+ polygon->points = p_points;
+ polygon->uvs = p_uvs;
+ polygon->colors = p_colors;
+ polygon->indices = indices;
+ polygon->count = indices.size();
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(polygon);
-
}
+void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, int p_count) {
-void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int>& p_indices, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture, int p_count) {
-
-
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
int ps = p_points.size();
- ERR_FAIL_COND(!p_colors.empty() && p_colors.size()!=ps && p_colors.size()!=1);
- ERR_FAIL_COND(!p_uvs.empty() && p_uvs.size()!=ps);
+ ERR_FAIL_COND(!p_colors.empty() && p_colors.size() != ps && p_colors.size() != 1);
+ ERR_FAIL_COND(!p_uvs.empty() && p_uvs.size() != ps);
Vector<int> indices = p_indices;
@@ -622,181 +577,169 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector
if (indices.empty()) {
- ERR_FAIL_COND( ps % 3 != 0 );
+ ERR_FAIL_COND(ps % 3 != 0);
if (p_count == -1)
count = ps;
} else {
- ERR_FAIL_COND( indices.size() % 3 != 0 );
+ ERR_FAIL_COND(indices.size() % 3 != 0);
if (p_count == -1)
count = indices.size();
}
- Item::CommandPolygon * polygon = memnew( Item::CommandPolygon );
+ Item::CommandPolygon *polygon = memnew(Item::CommandPolygon);
ERR_FAIL_COND(!polygon);
- polygon->texture=p_texture;
- polygon->points=p_points;
- polygon->uvs=p_uvs;
- polygon->colors=p_colors;
- polygon->indices=indices;
+ polygon->texture = p_texture;
+ polygon->points = p_points;
+ polygon->uvs = p_uvs;
+ polygon->colors = p_colors;
+ polygon->indices = indices;
polygon->count = count;
- canvas_item->rect_dirty=true;
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(polygon);
}
+void VisualServerCanvas::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) {
-void VisualServerCanvas::canvas_item_add_set_transform(RID p_item,const Transform2D& p_transform) {
-
-
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandTransform * tr = memnew( Item::CommandTransform );
+ Item::CommandTransform *tr = memnew(Item::CommandTransform);
ERR_FAIL_COND(!tr);
- tr->xform=p_transform;
+ tr->xform = p_transform;
canvas_item->commands.push_back(tr);
-
}
-void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID& p_mesh,RID p_skeleton){
+void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandMesh * m = memnew( Item::CommandMesh );
+ Item::CommandMesh *m = memnew(Item::CommandMesh);
ERR_FAIL_COND(!m);
- m->mesh=p_mesh;
- m->skeleton=p_skeleton;
+ m->mesh = p_mesh;
+ m->skeleton = p_skeleton;
canvas_item->commands.push_back(m);
}
-void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh,RID p_skeleton){
+void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandMultiMesh * mm = memnew( Item::CommandMultiMesh );
+ Item::CommandMultiMesh *mm = memnew(Item::CommandMultiMesh);
ERR_FAIL_COND(!mm);
- mm->multimesh=p_mesh;
- mm->skeleton=p_skeleton;
+ mm->multimesh = p_mesh;
+ mm->skeleton = p_skeleton;
canvas_item->commands.push_back(mm);
-
}
-void VisualServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore){
-
+void VisualServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- Item::CommandClipIgnore * ci = memnew( Item::CommandClipIgnore);
+ Item::CommandClipIgnore *ci = memnew(Item::CommandClipIgnore);
ERR_FAIL_COND(!ci);
- ci->ignore=p_ignore;
+ ci->ignore = p_ignore;
canvas_item->commands.push_back(ci);
}
-void VisualServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable){
-
+void VisualServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->sort_y=p_enable;
+ canvas_item->sort_y = p_enable;
}
-void VisualServerCanvas::canvas_item_set_z(RID p_item, int p_z){
+void VisualServerCanvas::canvas_item_set_z(RID p_item, int p_z) {
- ERR_FAIL_COND(p_z<VS::CANVAS_ITEM_Z_MIN || p_z>VS::CANVAS_ITEM_Z_MAX);
+ ERR_FAIL_COND(p_z < VS::CANVAS_ITEM_Z_MIN || p_z > VS::CANVAS_ITEM_Z_MAX);
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->z=p_z;
+ canvas_item->z = p_z;
}
-void VisualServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable){
+void VisualServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->z_relative=p_enable;
-
+ canvas_item->z_relative = p_enable;
}
-void VisualServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable,const Rect2& p_rect){
+void VisualServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) {
-
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- if (bool(canvas_item->copy_back_buffer!=NULL) !=p_enable) {
+ if (bool(canvas_item->copy_back_buffer != NULL) != p_enable) {
if (p_enable) {
- canvas_item->copy_back_buffer = memnew( RasterizerCanvas::Item::CopyBackBuffer );
+ canvas_item->copy_back_buffer = memnew(RasterizerCanvas::Item::CopyBackBuffer);
} else {
memdelete(canvas_item->copy_back_buffer);
- canvas_item->copy_back_buffer=NULL;
+ canvas_item->copy_back_buffer = NULL;
}
}
if (p_enable) {
- canvas_item->copy_back_buffer->rect=p_rect;
- canvas_item->copy_back_buffer->full=p_rect==Rect2();
+ canvas_item->copy_back_buffer->rect = p_rect;
+ canvas_item->copy_back_buffer->full = p_rect == Rect2();
}
-
}
-void VisualServerCanvas::canvas_item_clear(RID p_item){
+void VisualServerCanvas::canvas_item_clear(RID p_item) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clear();
}
-void VisualServerCanvas::canvas_item_set_draw_index(RID p_item,int p_index){
+void VisualServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) {
- Item *canvas_item = canvas_item_owner.getornull( p_item );
+ Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->index=p_index;
+ canvas_item->index = p_index;
- if (canvas_item_owner.owns( canvas_item->parent)) {
- Item *canvas_item_parent = canvas_item_owner.getornull( canvas_item->parent );
- canvas_item_parent->children_order_dirty=true;
+ if (canvas_item_owner.owns(canvas_item->parent)) {
+ Item *canvas_item_parent = canvas_item_owner.getornull(canvas_item->parent);
+ canvas_item_parent->children_order_dirty = true;
return;
}
- Canvas* canvas = canvas_owner.getornull( canvas_item->parent );
+ Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
if (canvas) {
- canvas->children_order_dirty=true;
+ canvas->children_order_dirty = true;
return;
}
-
}
-void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material){
+void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material) {
- Item *canvas_item = canvas_item_owner.get( p_item );
+ Item *canvas_item = canvas_item_owner.get(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->material=p_material;
+ canvas_item->material = p_material;
}
-void VisualServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable){
+void VisualServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.get( p_item );
+ Item *canvas_item = canvas_item_owner.get(p_item);
ERR_FAIL_COND(!canvas_item);
- canvas_item->use_parent_material=p_enable;
-
+ canvas_item->use_parent_material = p_enable;
}
-RID VisualServerCanvas::canvas_light_create(){
+RID VisualServerCanvas::canvas_light_create() {
- RasterizerCanvas::Light *clight = memnew( RasterizerCanvas::Light );
+ RasterizerCanvas::Light *clight = memnew(RasterizerCanvas::Light);
clight->light_internal = VSG::canvas_render->light_internal_create();
return canvas_light_owner.make_rid(clight);
-
}
-void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light,RID p_canvas){
+void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
@@ -808,9 +751,9 @@ void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light,RID p_canvas)
}
if (!canvas_owner.owns(p_canvas))
- p_canvas=RID();
+ p_canvas = RID();
- clight->canvas=p_canvas;
+ clight->canvas = p_canvas;
if (clight->canvas.is_valid()) {
@@ -819,196 +762,164 @@ void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light,RID p_canvas)
}
}
-
-void VisualServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled){
+void VisualServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->enabled=p_enabled;
-
+ clight->enabled = p_enabled;
}
-void VisualServerCanvas::canvas_light_set_scale(RID p_light, float p_scale){
-
+void VisualServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->scale=p_scale;
-
+ clight->scale = p_scale;
}
-void VisualServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D& p_transform){
-
+void VisualServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->xform=p_transform;
-
+ clight->xform = p_transform;
}
-void VisualServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture){
-
+void VisualServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->texture=p_texture;
-
+ clight->texture = p_texture;
}
-void VisualServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset){
-
+void VisualServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->texture_offset=p_offset;
-
+ clight->texture_offset = p_offset;
}
-void VisualServerCanvas::canvas_light_set_color(RID p_light, const Color& p_color){
-
-
+void VisualServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->color=p_color;
+ clight->color = p_color;
}
-void VisualServerCanvas::canvas_light_set_height(RID p_light, float p_height){
-
+void VisualServerCanvas::canvas_light_set_height(RID p_light, float p_height) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->height=p_height;
-
+ clight->height = p_height;
}
-void VisualServerCanvas::canvas_light_set_energy(RID p_light, float p_energy){
-
+void VisualServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->energy=p_energy;
-
+ clight->energy = p_energy;
}
-void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z){
-
+void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->z_min=p_min_z;
- clight->z_max=p_max_z;
-
+ clight->z_min = p_min_z;
+ clight->z_max = p_max_z;
}
-void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer,int p_max_layer){
-
+void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
-
- clight->layer_max=p_max_layer;
- clight->layer_min=p_min_layer;
-
-
+ clight->layer_max = p_max_layer;
+ clight->layer_min = p_min_layer;
}
-void VisualServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask){
-
+void VisualServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->item_mask=p_mask;
-
+ clight->item_mask = p_mask;
}
-void VisualServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask){
+void VisualServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->item_shadow_mask=p_mask;
-
+ clight->item_shadow_mask = p_mask;
}
-void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode){
+void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->mode=p_mode;
-
+ clight->mode = p_mode;
}
-
-void VisualServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled){
+void VisualServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- if (clight->shadow_buffer.is_valid()==p_enabled)
+ if (clight->shadow_buffer.is_valid() == p_enabled)
return;
if (p_enabled) {
- clight->shadow_buffer=VSG::storage->canvas_light_shadow_buffer_create(clight->shadow_buffer_size);
+ clight->shadow_buffer = VSG::storage->canvas_light_shadow_buffer_create(clight->shadow_buffer_size);
} else {
VSG::storage->free(clight->shadow_buffer);
- clight->shadow_buffer=RID();
+ clight->shadow_buffer = RID();
}
-
}
-void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_size){
+void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_size) {
- ERR_FAIL_COND(p_size<32 || p_size>16384);
+ ERR_FAIL_COND(p_size < 32 || p_size > 16384);
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
int new_size = nearest_power_of_2(p_size);
- if (new_size==clight->shadow_buffer_size)
+ if (new_size == clight->shadow_buffer_size)
return;
- clight->shadow_buffer_size=nearest_power_of_2(p_size);
+ clight->shadow_buffer_size = nearest_power_of_2(p_size);
if (clight->shadow_buffer.is_valid()) {
VSG::storage->free(clight->shadow_buffer);
- clight->shadow_buffer=VSG::storage->canvas_light_shadow_buffer_create(clight->shadow_buffer_size);
+ clight->shadow_buffer = VSG::storage->canvas_light_shadow_buffer_create(clight->shadow_buffer_size);
}
}
void VisualServerCanvas::canvas_light_set_shadow_gradient_length(RID p_light, float p_length) {
- ERR_FAIL_COND(p_length<0);
+ ERR_FAIL_COND(p_length < 0);
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->shadow_gradient_length=p_length;
-
+ clight->shadow_gradient_length = p_length;
}
void VisualServerCanvas::canvas_light_set_shadow_filter(RID p_light, VS::CanvasLightShadowFilter p_filter) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->shadow_filter=p_filter;
-
+ clight->shadow_filter = p_filter;
}
-void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color& p_color) {
+void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->shadow_color=p_color;
+ clight->shadow_color = p_color;
}
-
-
RID VisualServerCanvas::canvas_light_occluder_create() {
- RasterizerCanvas::LightOccluderInstance *occluder = memnew( RasterizerCanvas::LightOccluderInstance );
+ RasterizerCanvas::LightOccluderInstance *occluder = memnew(RasterizerCanvas::LightOccluderInstance);
return canvas_light_occluder_owner.make_rid(occluder);
}
-void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder,RID p_canvas){
+void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
ERR_FAIL_COND(!occluder);
@@ -1020,9 +931,9 @@ void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder,R
}
if (!canvas_owner.owns(p_canvas))
- p_canvas=RID();
+ p_canvas = RID();
- occluder->canvas=p_canvas;
+ occluder->canvas = p_canvas;
if (occluder->canvas.is_valid()) {
@@ -1030,14 +941,14 @@ void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder,R
canvas->occluders.insert(occluder);
}
}
-void VisualServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder,bool p_enabled) {
+void VisualServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
ERR_FAIL_COND(!occluder);
- occluder->enabled=p_enabled;
+ occluder->enabled = p_enabled;
}
-void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder,RID p_polygon) {
+void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
ERR_FAIL_COND(!occluder);
@@ -1049,153 +960,147 @@ void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder,RID p_
}
}
- occluder->polygon=p_polygon;
- occluder->polygon_buffer=RID();
+ occluder->polygon = p_polygon;
+ occluder->polygon_buffer = RID();
if (occluder->polygon.is_valid()) {
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_polygon);
if (!occluder_poly)
- occluder->polygon=RID();
+ occluder->polygon = RID();
ERR_FAIL_COND(!occluder_poly);
occluder_poly->owners.insert(occluder);
- occluder->polygon_buffer=occluder_poly->occluder;
- occluder->aabb_cache=occluder_poly->aabb;
- occluder->cull_cache=occluder_poly->cull_mode;
+ occluder->polygon_buffer = occluder_poly->occluder;
+ occluder->aabb_cache = occluder_poly->aabb;
+ occluder->cull_cache = occluder_poly->cull_mode;
}
-
}
-void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder,const Transform2D& p_xform) {
+void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
ERR_FAIL_COND(!occluder);
- occluder->xform=p_xform;
+ occluder->xform = p_xform;
}
-void VisualServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder,int p_mask) {
+void VisualServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
ERR_FAIL_COND(!occluder);
- occluder->light_mask=p_mask;
+ occluder->light_mask = p_mask;
}
RID VisualServerCanvas::canvas_occluder_polygon_create() {
- LightOccluderPolygon * occluder_poly = memnew( LightOccluderPolygon );
- occluder_poly->occluder=VSG::storage->canvas_light_occluder_create();
+ LightOccluderPolygon *occluder_poly = memnew(LightOccluderPolygon);
+ occluder_poly->occluder = VSG::storage->canvas_light_occluder_create();
return canvas_light_occluder_polygon_owner.make_rid(occluder_poly);
-
}
-void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon,const PoolVector<Vector2>& p_shape,bool p_closed) {
+void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape, bool p_closed) {
- if (p_shape.size()<3) {
- canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon,p_shape);
+ if (p_shape.size() < 3) {
+ canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, p_shape);
return;
}
PoolVector<Vector2> lines;
- int lc = p_shape.size()*2;
+ int lc = p_shape.size() * 2;
- lines.resize(lc-(p_closed?0:2));
+ lines.resize(lc - (p_closed ? 0 : 2));
{
PoolVector<Vector2>::Write w = lines.write();
PoolVector<Vector2>::Read r = p_shape.read();
- int max=lc/2;
+ int max = lc / 2;
if (!p_closed) {
max--;
}
- for(int i=0;i<max;i++) {
+ for (int i = 0; i < max; i++) {
Vector2 a = r[i];
- Vector2 b = r[(i+1)%(lc/2)];
- w[i*2+0]=a;
- w[i*2+1]=b;
+ Vector2 b = r[(i + 1) % (lc / 2)];
+ w[i * 2 + 0] = a;
+ w[i * 2 + 1] = b;
}
-
}
- canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon,lines);
+ canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, lines);
}
-void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const PoolVector<Vector2>& p_shape) {
+void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape) {
- LightOccluderPolygon * occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
- ERR_FAIL_COND(p_shape.size()&1);
+ ERR_FAIL_COND(p_shape.size() & 1);
int lc = p_shape.size();
- occluder_poly->aabb=Rect2();
+ occluder_poly->aabb = Rect2();
{
PoolVector<Vector2>::Read r = p_shape.read();
- for(int i=0;i<lc;i++) {
- if (i==0)
- occluder_poly->aabb.pos=r[i];
+ for (int i = 0; i < lc; i++) {
+ if (i == 0)
+ occluder_poly->aabb.pos = r[i];
else
occluder_poly->aabb.expand_to(r[i]);
}
}
- VSG::storage->canvas_light_occluder_set_polylines(occluder_poly->occluder,p_shape);
- for( Set<RasterizerCanvas::LightOccluderInstance*>::Element *E=occluder_poly->owners.front();E;E=E->next()) {
- E->get()->aabb_cache=occluder_poly->aabb;
+ VSG::storage->canvas_light_occluder_set_polylines(occluder_poly->occluder, p_shape);
+ for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) {
+ E->get()->aabb_cache = occluder_poly->aabb;
}
}
+void VisualServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, VS::CanvasOccluderPolygonCullMode p_mode) {
-void VisualServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon,VS::CanvasOccluderPolygonCullMode p_mode) {
-
- LightOccluderPolygon * occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
- occluder_poly->cull_mode=p_mode;
- for( Set<RasterizerCanvas::LightOccluderInstance*>::Element *E=occluder_poly->owners.front();E;E=E->next()) {
- E->get()->cull_cache=p_mode;
+ occluder_poly->cull_mode = p_mode;
+ for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) {
+ E->get()->cull_cache = p_mode;
}
}
-
-
bool VisualServerCanvas::free(RID p_rid) {
if (canvas_owner.owns(p_rid)) {
Canvas *canvas = canvas_owner.get(p_rid);
- ERR_FAIL_COND_V(!canvas,false);
+ ERR_FAIL_COND_V(!canvas, false);
- while(canvas->viewports.size()) {
+ while (canvas->viewports.size()) {
VisualServerViewport::Viewport *vp = VSG::viewport->viewport_owner.get(canvas->viewports.front()->get());
- ERR_FAIL_COND_V(!vp,true);
+ ERR_FAIL_COND_V(!vp, true);
- Map<RID,VisualServerViewport::Viewport::CanvasData>::Element *E=vp->canvas_map.find(p_rid);
- ERR_FAIL_COND_V(!E,true);
+ Map<RID, VisualServerViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid);
+ ERR_FAIL_COND_V(!E, true);
vp->canvas_map.erase(p_rid);
- canvas->viewports.erase( canvas->viewports.front() );
+ canvas->viewports.erase(canvas->viewports.front());
}
- for (int i=0;i<canvas->child_items.size();i++) {
+ for (int i = 0; i < canvas->child_items.size(); i++) {
- canvas->child_items[i].item->parent=RID();
+ canvas->child_items[i].item->parent = RID();
}
- for (Set<RasterizerCanvas::Light*>::Element *E=canvas->lights.front();E;E=E->next()) {
+ for (Set<RasterizerCanvas::Light *>::Element *E = canvas->lights.front(); E; E = E->next()) {
- E->get()->canvas=RID();
+ E->get()->canvas = RID();
}
- for (Set<RasterizerCanvas::LightOccluderInstance*>::Element *E=canvas->occluders.front();E;E=E->next()) {
+ for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = canvas->occluders.front(); E; E = E->next()) {
- E->get()->canvas=RID();
+ E->get()->canvas = RID();
}
- canvas_owner.free( p_rid );
+ canvas_owner.free(p_rid);
- memdelete( canvas );
+ memdelete(canvas);
} else if (canvas_item_owner.owns(p_rid)) {
Item *canvas_item = canvas_item_owner.get(p_rid);
- ERR_FAIL_COND_V(!canvas_item,true);
+ ERR_FAIL_COND_V(!canvas_item, true);
if (canvas_item->parent.is_valid()) {
@@ -1207,13 +1112,12 @@ bool VisualServerCanvas::free(RID p_rid) {
Item *item_owner = canvas_item_owner.get(canvas_item->parent);
item_owner->child_items.erase(canvas_item);
-
}
}
- for (int i=0;i<canvas_item->child_items.size();i++) {
+ for (int i = 0; i < canvas_item->child_items.size(); i++) {
- canvas_item->child_items[i]->parent=RID();
+ canvas_item->child_items[i]->parent = RID();
}
/*
@@ -1222,17 +1126,17 @@ bool VisualServerCanvas::free(RID p_rid) {
}
*/
- canvas_item_owner.free( p_rid );
+ canvas_item_owner.free(p_rid);
- memdelete( canvas_item );
+ memdelete(canvas_item);
} else if (canvas_light_owner.owns(p_rid)) {
RasterizerCanvas::Light *canvas_light = canvas_light_owner.get(p_rid);
- ERR_FAIL_COND_V(!canvas_light,true);
+ ERR_FAIL_COND_V(!canvas_light, true);
if (canvas_light->canvas.is_valid()) {
- Canvas* canvas = canvas_owner.get(canvas_light->canvas);
+ Canvas *canvas = canvas_owner.get(canvas_light->canvas);
if (canvas)
canvas->lights.erase(canvas_light);
}
@@ -1242,13 +1146,13 @@ bool VisualServerCanvas::free(RID p_rid) {
VSG::canvas_render->light_internal_free(canvas_light->light_internal);
- canvas_light_owner.free( p_rid );
- memdelete( canvas_light );
+ canvas_light_owner.free(p_rid);
+ memdelete(canvas_light);
} else if (canvas_light_occluder_owner.owns(p_rid)) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_rid);
- ERR_FAIL_COND_V(!occluder,true);
+ ERR_FAIL_COND_V(!occluder, true);
if (occluder->polygon.is_valid()) {
@@ -1256,32 +1160,30 @@ bool VisualServerCanvas::free(RID p_rid) {
if (occluder_poly) {
occluder_poly->owners.erase(occluder);
}
-
}
if (occluder->canvas.is_valid() && canvas_owner.owns(occluder->canvas)) {
Canvas *canvas = canvas_owner.get(occluder->canvas);
canvas->occluders.erase(occluder);
-
}
- canvas_light_occluder_owner.free( p_rid );
+ canvas_light_occluder_owner.free(p_rid);
memdelete(occluder);
} else if (canvas_light_occluder_polygon_owner.owns(p_rid)) {
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_rid);
- ERR_FAIL_COND_V(!occluder_poly,true);
+ ERR_FAIL_COND_V(!occluder_poly, true);
VSG::storage->free(occluder_poly->occluder);
- while(occluder_poly->owners.size()) {
+ while (occluder_poly->owners.size()) {
- occluder_poly->owners.front()->get()->polygon=RID();
- occluder_poly->owners.erase( occluder_poly->owners.front() );
+ occluder_poly->owners.front()->get()->polygon = RID();
+ occluder_poly->owners.erase(occluder_poly->owners.front());
}
- canvas_light_occluder_polygon_owner.free( p_rid );
+ canvas_light_occluder_polygon_owner.free(p_rid);
memdelete(occluder_poly);
} else {
return false;
@@ -1290,9 +1192,5 @@ bool VisualServerCanvas::free(RID p_rid) {
return true;
}
-
-
-VisualServerCanvas::VisualServerCanvas()
-{
-
+VisualServerCanvas::VisualServerCanvas() {
}
diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h
index b405bc804d..3c2dde17d5 100644
--- a/servers/visual/visual_server_canvas.h
+++ b/servers/visual/visual_server_canvas.h
@@ -34,13 +34,10 @@
class VisualServerCanvas {
public:
-
-
struct Item : public RasterizerCanvas::Item {
-
RID parent; // canvas it belongs to
- List<Item*>::Element *E;
+ List<Item *>::Element *E;
int z;
bool z_relative;
bool sort_y;
@@ -50,29 +47,26 @@ public:
int index;
bool children_order_dirty;
-
- Vector<Item*> child_items;
-
+ Vector<Item *> child_items;
Item() {
- children_order_dirty=true;
- E=NULL;
- z=0;
- modulate=Color(1,1,1,1);
- self_modulate=Color(1,1,1,1);
- sort_y=false;
- use_parent_material=false;
- z_relative=true;
- index=0;
+ children_order_dirty = true;
+ E = NULL;
+ z = 0;
+ modulate = Color(1, 1, 1, 1);
+ self_modulate = Color(1, 1, 1, 1);
+ sort_y = false;
+ use_parent_material = false;
+ z_relative = true;
+ index = 0;
}
};
-
struct ItemPtrSort {
- _FORCE_INLINE_ bool operator()(const Item* p_left,const Item* p_right) const {
+ _FORCE_INLINE_ bool operator()(const Item *p_left, const Item *p_right) const {
- if(Math::abs(p_left->xform.elements[2].y - p_right->xform.elements[2].y) < CMP_EPSILON )
+ if (Math::abs(p_left->xform.elements[2].y - p_right->xform.elements[2].y) < CMP_EPSILON)
return p_left->xform.elements[2].x < p_right->xform.elements[2].x;
else
return p_left->xform.elements[2].y < p_right->xform.elements[2].y;
@@ -85,12 +79,14 @@ public:
Rect2 aabb;
VS::CanvasOccluderPolygonCullMode cull_mode;
RID occluder;
- Set<RasterizerCanvas::LightOccluderInstance*> owners;
+ Set<RasterizerCanvas::LightOccluderInstance *> owners;
- LightOccluderPolygon() { active=false; cull_mode=VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; }
+ LightOccluderPolygon() {
+ active = false;
+ cull_mode = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
+ }
};
-
RID_Owner<LightOccluderPolygon> canvas_light_occluder_polygon_owner;
RID_Owner<RasterizerCanvas::LightOccluderInstance> canvas_light_occluder_owner;
@@ -102,91 +98,86 @@ public:
Point2 mirror;
Item *item;
- bool operator<(const ChildItem& p_item) const {
+ bool operator<(const ChildItem &p_item) const {
return item->index < p_item.item->index;
}
};
+ Set<RasterizerCanvas::Light *> lights;
-
- Set<RasterizerCanvas::Light*> lights;
-
- Set<RasterizerCanvas::LightOccluderInstance*> occluders;
+ Set<RasterizerCanvas::LightOccluderInstance *> occluders;
bool children_order_dirty;
Vector<ChildItem> child_items;
Color modulate;
int find_item(Item *p_item) {
- for(int i=0;i<child_items.size();i++) {
- if (child_items[i].item==p_item)
+ for (int i = 0; i < child_items.size(); i++) {
+ if (child_items[i].item == p_item)
return i;
}
return -1;
}
void erase_item(Item *p_item) {
- int idx=find_item(p_item);
- if (idx>=0)
+ int idx = find_item(p_item);
+ if (idx >= 0)
child_items.remove(idx);
}
-
- Canvas() { modulate=Color(1,1,1,1); children_order_dirty=true; }
-
+ Canvas() {
+ modulate = Color(1, 1, 1, 1);
+ children_order_dirty = true;
+ }
};
-
RID_Owner<Canvas> canvas_owner;
RID_Owner<Item> canvas_item_owner;
RID_Owner<RasterizerCanvas::Light> canvas_light_owner;
private:
+ void _render_canvas_item_tree(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights);
+ void _render_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner);
+ void _light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights);
- void _render_canvas_item_tree(Item *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights);
- void _render_canvas_item(Item *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner);
- void _light_mask_canvas_items(int p_z,RasterizerCanvas::Item *p_canvas_item,RasterizerCanvas::Light *p_masked_lights);
public:
-
- void render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights,const Rect2& p_clip_rect);
+ void render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect);
RID canvas_create();
- void canvas_set_item_mirroring(RID p_canvas,RID p_item,const Point2& p_mirroring);
- void canvas_set_modulate(RID p_canvas,const Color& p_color);
-
+ void canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring);
+ void canvas_set_modulate(RID p_canvas, const Color &p_color);
RID canvas_item_create();
- void canvas_item_set_parent(RID p_item,RID p_parent);
+ void canvas_item_set_parent(RID p_item, RID p_parent);
- void canvas_item_set_visible(RID p_item,bool p_visible);
- void canvas_item_set_light_mask(RID p_item,int p_mask);
+ void canvas_item_set_visible(RID p_item, bool p_visible);
+ void canvas_item_set_light_mask(RID p_item, int p_mask);
- void canvas_item_set_transform(RID p_item, const Transform2D& p_transform);
+ void canvas_item_set_transform(RID p_item, const Transform2D &p_transform);
void canvas_item_set_clip(RID p_item, bool p_clip);
void canvas_item_set_distance_field_mode(RID p_item, bool p_enable);
- void canvas_item_set_custom_rect(RID p_item, bool p_custom_rect,const Rect2& p_rect=Rect2());
- void canvas_item_set_modulate(RID p_item, const Color& p_color);
- void canvas_item_set_self_modulate(RID p_item, const Color& p_color);
+ void canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect = Rect2());
+ void canvas_item_set_modulate(RID p_item, const Color &p_color);
+ void canvas_item_set_self_modulate(RID p_item, const Color &p_color);
void canvas_item_set_draw_behind_parent(RID p_item, bool p_enable);
-
- void canvas_item_add_line(RID p_item, const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width=1.0,bool p_antialiased=false);
- void canvas_item_add_rect(RID p_item, const Rect2& p_rect, const Color& p_color);
- void canvas_item_add_circle(RID p_item, const Point2& p_pos, float p_radius,const Color& p_color);
- void canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile=false,const Color& p_modulate=Color(1,1,1),bool p_transpose=false);
- void canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1),bool p_transpose=false);
- void canvas_item_add_nine_patch(RID p_item, const Rect2& p_rect, const Rect2& p_source, RID p_texture,const Vector2& p_topleft, const Vector2& p_bottomright,VS::NinePatchAxisMode p_x_axis_mode=VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode=VS::NINE_PATCH_STRETCH,bool p_draw_center=true,const Color& p_modulate=Color(1,1,1));
- void canvas_item_add_primitive(RID p_item, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width=1.0);
- void canvas_item_add_polygon(RID p_item, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs=Vector<Point2>(), RID p_texture=RID());
- void canvas_item_add_triangle_array(RID p_item, const Vector<int>& p_indices, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs=Vector<Point2>(), RID p_texture=RID(), int p_count=-1);
- void canvas_item_add_mesh(RID p_item, const RID& p_mesh,RID p_skeleton=RID());
- void canvas_item_add_multimesh(RID p_item, RID p_mesh,RID p_skeleton=RID());
- void canvas_item_add_set_transform(RID p_item,const Transform2D& p_transform);
+ void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false);
+ void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color);
+ void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color);
+ void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false);
+ void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false);
+ void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1));
+ void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0);
+ void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID());
+ void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), int p_count = -1);
+ void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton = RID());
+ void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = RID());
+ void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform);
void canvas_item_add_clip_ignore(RID p_item, bool p_ignore);
void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable);
void canvas_item_set_z(RID p_item, int p_z);
void canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable);
- void canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable,const Rect2& p_rect);
+ void canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect);
void canvas_item_clear(RID p_item);
void canvas_item_set_draw_index(RID p_item, int p_index);
@@ -196,50 +187,43 @@ public:
void canvas_item_set_use_parent_material(RID p_item, bool p_enable);
RID canvas_light_create();
- void canvas_light_attach_to_canvas(RID p_light,RID p_canvas);
+ void canvas_light_attach_to_canvas(RID p_light, RID p_canvas);
void canvas_light_set_enabled(RID p_light, bool p_enabled);
void canvas_light_set_scale(RID p_light, float p_scale);
- void canvas_light_set_transform(RID p_light, const Transform2D& p_transform);
+ void canvas_light_set_transform(RID p_light, const Transform2D &p_transform);
void canvas_light_set_texture(RID p_light, RID p_texture);
- void canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset);
- void canvas_light_set_color(RID p_light, const Color& p_color);
+ void canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset);
+ void canvas_light_set_color(RID p_light, const Color &p_color);
void canvas_light_set_height(RID p_light, float p_height);
void canvas_light_set_energy(RID p_light, float p_energy);
- void canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z);
- void canvas_light_set_layer_range(RID p_light, int p_min_layer,int p_max_layer);
+ void canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z);
+ void canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer);
void canvas_light_set_item_cull_mask(RID p_light, int p_mask);
void canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask);
void canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode);
-
void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled);
void canvas_light_set_shadow_buffer_size(RID p_light, int p_size);
void canvas_light_set_shadow_gradient_length(RID p_light, float p_length);
void canvas_light_set_shadow_filter(RID p_light, VS::CanvasLightShadowFilter p_filter);
- void canvas_light_set_shadow_color(RID p_light, const Color& p_color);
-
-
+ void canvas_light_set_shadow_color(RID p_light, const Color &p_color);
RID canvas_light_occluder_create();
- void canvas_light_occluder_attach_to_canvas(RID p_occluder,RID p_canvas);
- void canvas_light_occluder_set_enabled(RID p_occluder,bool p_enabled);
- void canvas_light_occluder_set_polygon(RID p_occluder,RID p_polygon);
- void canvas_light_occluder_set_transform(RID p_occluder,const Transform2D& p_xform);
- void canvas_light_occluder_set_light_mask(RID p_occluder,int p_mask);
+ void canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas);
+ void canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled);
+ void canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon);
+ void canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform);
+ void canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask);
RID canvas_occluder_polygon_create();
- void canvas_occluder_polygon_set_shape(RID p_occluder_polygon,const PoolVector<Vector2>& p_shape,bool p_closed);
- void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const PoolVector<Vector2>& p_shape);
-
-
- void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon,VS::CanvasOccluderPolygonCullMode p_mode);
+ void canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape, bool p_closed);
+ void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape);
+ void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, VS::CanvasOccluderPolygonCullMode p_mode);
bool free(RID p_rid);
VisualServerCanvas();
-
-
};
#endif // VISUALSERVERCANVAS_H
diff --git a/servers/visual/visual_server_global.cpp b/servers/visual/visual_server_global.cpp
index 3704192c7e..75506f7add 100644
--- a/servers/visual/visual_server_global.cpp
+++ b/servers/visual/visual_server_global.cpp
@@ -28,11 +28,11 @@
/*************************************************************************/
#include "visual_server_global.h"
-RasterizerStorage *VisualServerGlobals::storage=NULL;
-RasterizerCanvas *VisualServerGlobals::canvas_render=NULL;
-RasterizerScene *VisualServerGlobals::scene_render=NULL;
-Rasterizer *VisualServerGlobals::rasterizer=NULL;
+RasterizerStorage *VisualServerGlobals::storage = NULL;
+RasterizerCanvas *VisualServerGlobals::canvas_render = NULL;
+RasterizerScene *VisualServerGlobals::scene_render = NULL;
+Rasterizer *VisualServerGlobals::rasterizer = NULL;
-VisualServerCanvas *VisualServerGlobals::canvas=NULL;
-VisualServerViewport *VisualServerGlobals::viewport=NULL;
-VisualServerScene *VisualServerGlobals::scene=NULL;
+VisualServerCanvas *VisualServerGlobals::canvas = NULL;
+VisualServerViewport *VisualServerGlobals::viewport = NULL;
+VisualServerScene *VisualServerGlobals::scene = NULL;
diff --git a/servers/visual/visual_server_global.h b/servers/visual/visual_server_global.h
index f95aed3ffb..d55059cd55 100644
--- a/servers/visual/visual_server_global.h
+++ b/servers/visual/visual_server_global.h
@@ -35,10 +35,8 @@ class VisualServerCanvas;
class VisualServerViewport;
class VisualServerScene;
-class VisualServerGlobals
-{
+class VisualServerGlobals {
public:
-
static RasterizerStorage *storage;
static RasterizerCanvas *canvas_render;
static RasterizerScene *scene_render;
diff --git a/servers/visual/visual_server_light_baker.cpp b/servers/visual/visual_server_light_baker.cpp
index bdf20df618..493eeb49ca 100644
--- a/servers/visual/visual_server_light_baker.cpp
+++ b/servers/visual/visual_server_light_baker.cpp
@@ -28,7 +28,5 @@
/*************************************************************************/
#include "visual_server_light_baker.h"
-VisualServerLightBaker::VisualServerLightBaker()
-{
-
+VisualServerLightBaker::VisualServerLightBaker() {
}
diff --git a/servers/visual/visual_server_light_baker.h b/servers/visual/visual_server_light_baker.h
index 416c16ed3a..82909bb082 100644
--- a/servers/visual/visual_server_light_baker.h
+++ b/servers/visual/visual_server_light_baker.h
@@ -33,7 +33,6 @@
class VisualServerLightBaker {
public:
-
struct BakeCell {
uint32_t cells[8];
@@ -43,14 +42,8 @@ public:
uint32_t light[4]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast)
float alpha; //used for upsampling
uint32_t directional_pass; //used for baking directional
-
};
-
-
-
-
-
VisualServerLightBaker();
};
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 3a5ffda8f5..2666a95595 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -27,48 +27,37 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_server_raster.h"
-#include "os/os.h"
-#include "global_config.h"
#include "default_mouse_cursor.xpm"
-#include "sort.h"
+#include "global_config.h"
#include "io/marshalls.h"
+#include "os/os.h"
+#include "sort.h"
#include "visual_server_canvas.h"
#include "visual_server_global.h"
#include "visual_server_scene.h"
// careful, these may run in different threads than the visual server
-
-
-
/* CURSOR */
-void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor ){
-
+void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor) {
}
-void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor, const Rect2 &p_region){
-
+void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor, const Rect2 &p_region) {
}
-void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor ){
-
+void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) {
}
-void VisualServerRaster::cursor_set_pos(const Point2& p_pos, int p_cursor ){
-
+void VisualServerRaster::cursor_set_pos(const Point2 &p_pos, int p_cursor) {
}
/* BLACK BARS */
-
-void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom){
-
+void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
}
-void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom){
-
+void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
}
-
/* FREE */
-void VisualServerRaster::free( RID p_rid ){
+void VisualServerRaster::free(RID p_rid) {
if (VSG::storage->free(p_rid))
return;
@@ -78,19 +67,18 @@ void VisualServerRaster::free( RID p_rid ){
return;
if (VSG::scene->free(p_rid))
return;
-
}
/* EVENT QUEUING */
-void VisualServerRaster::draw(){
+void VisualServerRaster::draw() {
/*
if (changes)
print_line("changes: "+itos(changes));
*/
- changes=0;
+ changes = 0;
VSG::rasterizer->begin_frame();
@@ -102,19 +90,17 @@ void VisualServerRaster::draw(){
VSG::rasterizer->end_frame();
//draw_extra_frame=VS:rasterizer->needs_to_draw_next_frame();
}
-void VisualServerRaster::sync(){
-
+void VisualServerRaster::sync() {
}
-bool VisualServerRaster::has_changed() const{
+bool VisualServerRaster::has_changed() const {
- return changes>0;
+ return changes > 0;
}
-void VisualServerRaster::init(){
+void VisualServerRaster::init() {
VSG::rasterizer->initialize();
-
}
-void VisualServerRaster::finish(){
+void VisualServerRaster::finish() {
if (test_cube.is_valid()) {
free(test_cube);
@@ -123,26 +109,18 @@ void VisualServerRaster::finish(){
VSG::rasterizer->finalize();
}
-
/* STATUS INFORMATION */
-
-int VisualServerRaster::get_render_info(RenderInfo p_info){
+int VisualServerRaster::get_render_info(RenderInfo p_info) {
return 0;
}
-
-
/* TESTING */
-
-
-void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color,bool p_scale){
-
+void VisualServerRaster::set_boot_image(const Image &p_image, const Color &p_color, bool p_scale) {
}
-void VisualServerRaster::set_default_clear_color(const Color& p_color){
-
+void VisualServerRaster::set_default_clear_color(const Color &p_color) {
}
bool VisualServerRaster::has_feature(Features p_feature) const {
@@ -152,27 +130,25 @@ bool VisualServerRaster::has_feature(Features p_feature) const {
RID VisualServerRaster::get_test_cube() {
if (!test_cube.is_valid()) {
- test_cube=_make_test_cube();
+ test_cube = _make_test_cube();
}
return test_cube;
}
-
-bool VisualServerRaster::has_os_feature(const String& p_feature) const {
+bool VisualServerRaster::has_os_feature(const String &p_feature) const {
return VSG::storage->has_os_feature(p_feature);
}
VisualServerRaster::VisualServerRaster() {
- VSG::canvas = memnew( VisualServerCanvas);
- VSG::viewport = memnew( VisualServerViewport);
- VSG::scene = memnew( VisualServerScene );
+ VSG::canvas = memnew(VisualServerCanvas);
+ VSG::viewport = memnew(VisualServerViewport);
+ VSG::scene = memnew(VisualServerScene);
VSG::rasterizer = Rasterizer::create();
- VSG::storage=VSG::rasterizer->get_storage();
- VSG::canvas_render=VSG::rasterizer->get_canvas();
- VSG::scene_render=VSG::rasterizer->get_scene();
-
+ VSG::storage = VSG::rasterizer->get_storage();
+ VSG::canvas_render = VSG::rasterizer->get_canvas();
+ VSG::scene_render = VSG::rasterizer->get_scene();
}
VisualServerRaster::~VisualServerRaster() {
@@ -182,12 +158,11 @@ VisualServerRaster::~VisualServerRaster() {
memdelete(VSG::rasterizer);
}
-
#if 0
BalloonAllocator<> *VisualServerRaster::OctreeAllocator::allocator=NULL;
-#define VS_CHANGED\
+#define VS_CHANGED \
changes++;\
//print_line(__FUNCTION__);
@@ -5371,8 +5346,6 @@ CameraMatrix _lispm_look( const Vector3 pos, const Vector3 dir, const Vector3 up
return cmout;
}
-
-
#if 1
void VisualServerRaster::_light_instance_update_lispsm_shadow(Instance *p_light,Scenario *p_scenario,Camera *p_camera,const CullRange& p_cull_range) {
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 7d547e1862..58e07057f2 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -29,36 +29,30 @@
#ifndef VISUAL_SERVER_RASTER_H
#define VISUAL_SERVER_RASTER_H
-
-#include "servers/visual_server.h"
-#include "servers/visual/rasterizer.h"
#include "allocators.h"
#include "octree.h"
-#include "visual_server_global.h"
-#include "visual_server_viewport.h"
+#include "servers/visual/rasterizer.h"
+#include "servers/visual_server.h"
#include "visual_server_canvas.h"
+#include "visual_server_global.h"
#include "visual_server_scene.h"
+#include "visual_server_viewport.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
-
-
class VisualServerRaster : public VisualServer {
-
enum {
- MAX_INSTANCE_CULL=8192,
- MAX_INSTANCE_LIGHTS=4,
- LIGHT_CACHE_DIRTY=-1,
- MAX_LIGHTS_CULLED=256,
- MAX_ROOM_CULL=32,
- MAX_EXTERIOR_PORTALS=128,
- MAX_LIGHT_SAMPLERS=256,
- INSTANCE_ROOMLESS_MASK=(1<<20)
-
+ MAX_INSTANCE_CULL = 8192,
+ MAX_INSTANCE_LIGHTS = 4,
+ LIGHT_CACHE_DIRTY = -1,
+ MAX_LIGHTS_CULLED = 256,
+ MAX_ROOM_CULL = 32,
+ MAX_EXTERIOR_PORTALS = 128,
+ MAX_LIGHT_SAMPLERS = 256,
+ INSTANCE_ROOMLESS_MASK = (1 << 20)
};
@@ -66,8 +60,7 @@ class VisualServerRaster : public VisualServer {
bool draw_extra_frame;
RID test_cube;
-
- #if 0
+#if 0
struct Room {
bool occlude_exterior;
@@ -582,293 +575,299 @@ class VisualServerRaster : public VisualServer {
#endif
public:
-
#define DISPLAY_CHANGED changes++;
-#define BIND0R(m_r,m_name) m_r m_name() { return BINDBASE->m_name(); }
-#define BIND1R(m_r,m_name,m_type1) m_r m_name(m_type1 arg1) { return BINDBASE->m_name(arg1); }
-#define BIND1RC(m_r,m_name,m_type1) m_r m_name(m_type1 arg1) const { return BINDBASE->m_name(arg1); }
-#define BIND2RC(m_r,m_name,m_type1,m_type2) m_r m_name(m_type1 arg1,m_type2 arg2) const { return BINDBASE->m_name(arg1,arg2); }
-#define BIND3RC(m_r,m_name,m_type1,m_type2,m_type3) m_r m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3) const { return BINDBASE->m_name(arg1,arg2,arg3); }
-#define BIND4RC(m_r,m_name,m_type1,m_type2,m_type3,m_type4) m_r m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3,m_type4 arg4) const { return BINDBASE->m_name(arg1,arg2,arg3,arg4); }
-
-#define BIND1(m_name,m_type1) void m_name(m_type1 arg1) { DISPLAY_CHANGED BINDBASE->m_name(arg1); }
-#define BIND2(m_name,m_type1,m_type2) void m_name(m_type1 arg1,m_type2 arg2) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2); }
-#define BIND2C(m_name,m_type1,m_type2) void m_name(m_type1 arg1,m_type2 arg2) const { BINDBASE->m_name(arg1,arg2); }
-#define BIND3(m_name,m_type1,m_type2,m_type3) void m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2,arg3); }
-#define BIND4(m_name,m_type1,m_type2,m_type3,m_type4) void m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3,m_type4 arg4) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2,arg3,arg4); }
-#define BIND5(m_name,m_type1,m_type2,m_type3,m_type4,m_type5) void m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3,m_type4 arg4,m_type5 arg5) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2,arg3,arg4,arg5); }
-#define BIND6(m_name,m_type1,m_type2,m_type3,m_type4,m_type5,m_type6) void m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3,m_type4 arg4,m_type5 arg5,m_type6 arg6) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2,arg3,arg4,arg5,arg6); }
-#define BIND7(m_name,m_type1,m_type2,m_type3,m_type4,m_type5,m_type6,m_type7) void m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3,m_type4 arg4,m_type5 arg5,m_type6 arg6,m_type7 arg7) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2,arg3,arg4,arg5,arg6,arg7); }
-#define BIND8(m_name,m_type1,m_type2,m_type3,m_type4,m_type5,m_type6,m_type7,m_type8) void m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3,m_type4 arg4,m_type5 arg5,m_type6 arg6,m_type7 arg7,m_type8 arg8) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); }
-#define BIND9(m_name,m_type1,m_type2,m_type3,m_type4,m_type5,m_type6,m_type7,m_type8,m_type9) void m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3,m_type4 arg4,m_type5 arg5,m_type6 arg6,m_type7 arg7,m_type8 arg8,m_type9 arg9) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); }
-#define BIND10(m_name,m_type1,m_type2,m_type3,m_type4,m_type5,m_type6,m_type7,m_type8,m_type9,m_type10) void m_name(m_type1 arg1,m_type2 arg2,m_type3 arg3,m_type4 arg4,m_type5 arg5,m_type6 arg6,m_type7 arg7,m_type8 arg8,m_type9 arg9,m_type10 arg10) { DISPLAY_CHANGED BINDBASE->m_name(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); }
+#define BIND0R(m_r, m_name) \
+ m_r m_name() { return BINDBASE->m_name(); }
+#define BIND1R(m_r, m_name, m_type1) \
+ m_r m_name(m_type1 arg1) { return BINDBASE->m_name(arg1); }
+#define BIND1RC(m_r, m_name, m_type1) \
+ m_r m_name(m_type1 arg1) const { return BINDBASE->m_name(arg1); }
+#define BIND2RC(m_r, m_name, m_type1, m_type2) \
+ m_r m_name(m_type1 arg1, m_type2 arg2) const { return BINDBASE->m_name(arg1, arg2); }
+#define BIND3RC(m_r, m_name, m_type1, m_type2, m_type3) \
+ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) const { return BINDBASE->m_name(arg1, arg2, arg3); }
+#define BIND4RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \
+ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) const { return BINDBASE->m_name(arg1, arg2, arg3, arg4); }
+
+#define BIND1(m_name, m_type1) \
+ void m_name(m_type1 arg1) { DISPLAY_CHANGED BINDBASE->m_name(arg1); }
+#define BIND2(m_name, m_type1, m_type2) \
+ void m_name(m_type1 arg1, m_type2 arg2) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2); }
+#define BIND2C(m_name, m_type1, m_type2) \
+ void m_name(m_type1 arg1, m_type2 arg2) const { BINDBASE->m_name(arg1, arg2); }
+#define BIND3(m_name, m_type1, m_type2, m_type3) \
+ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3); }
+#define BIND4(m_name, m_type1, m_type2, m_type3, m_type4) \
+ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4); }
+#define BIND5(m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \
+ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5); }
+#define BIND6(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
+ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); }
+#define BIND7(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7) \
+ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7); }
+#define BIND8(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8) \
+ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); }
+#define BIND9(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9) \
+ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); }
+#define BIND10(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10) \
+ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); }
//from now on, calls forwarded to this singleton
#define BINDBASE VSG::storage
/* TEXTURE API */
+ BIND0R(RID, texture_create)
+ BIND5(texture_allocate, RID, int, int, Image::Format, uint32_t)
+ BIND3(texture_set_data, RID, const Image &, CubeMapSide)
+ BIND2RC(Image, texture_get_data, RID, CubeMapSide)
+ BIND2(texture_set_flags, RID, uint32_t)
+ BIND1RC(uint32_t, texture_get_flags, RID)
+ BIND1RC(Image::Format, texture_get_format, RID)
+ BIND1RC(uint32_t, texture_get_width, RID)
+ BIND1RC(uint32_t, texture_get_height, RID)
+ BIND3(texture_set_size_override, RID, int, int)
+ BIND2RC(RID, texture_create_radiance_cubemap, RID, int)
- BIND0R(RID,texture_create)
- BIND5(texture_allocate,RID,int,int,Image::Format,uint32_t)
- BIND3(texture_set_data,RID,const Image&,CubeMapSide)
- BIND2RC(Image,texture_get_data,RID,CubeMapSide)
- BIND2(texture_set_flags,RID,uint32_t)
- BIND1RC(uint32_t,texture_get_flags,RID)
- BIND1RC(Image::Format,texture_get_format,RID)
- BIND1RC(uint32_t,texture_get_width,RID)
- BIND1RC(uint32_t,texture_get_height,RID)
- BIND3(texture_set_size_override,RID,int,int)
- BIND2RC(RID,texture_create_radiance_cubemap,RID,int)
-
- BIND3(texture_set_detect_3d_callback,RID,TextureDetectCallback,void*)
- BIND3(texture_set_detect_srgb_callback,RID,TextureDetectCallback,void*)
+ BIND3(texture_set_detect_3d_callback, RID, TextureDetectCallback, void *)
+ BIND3(texture_set_detect_srgb_callback, RID, TextureDetectCallback, void *)
- BIND2(texture_set_path,RID,const String&)
- BIND1RC(String,texture_get_path,RID)
- BIND1(texture_set_shrink_all_x2_on_set_data,bool)
- BIND1(texture_debug_usage,List<TextureInfo>*)
+ BIND2(texture_set_path, RID, const String &)
+ BIND1RC(String, texture_get_path, RID)
+ BIND1(texture_set_shrink_all_x2_on_set_data, bool)
+ BIND1(texture_debug_usage, List<TextureInfo> *)
- BIND1(textures_keep_original,bool)
+ BIND1(textures_keep_original, bool)
/* SKYBOX API */
- BIND0R(RID,skybox_create)
- BIND3(skybox_set_texture,RID,RID,int)
+ BIND0R(RID, skybox_create)
+ BIND3(skybox_set_texture, RID, RID, int)
/* SHADER API */
- BIND1R(RID,shader_create,ShaderMode)
+ BIND1R(RID, shader_create, ShaderMode)
+ BIND2(shader_set_mode, RID, ShaderMode)
+ BIND1RC(ShaderMode, shader_get_mode, RID)
- BIND2(shader_set_mode,RID,ShaderMode)
- BIND1RC(ShaderMode,shader_get_mode,RID)
+ BIND2(shader_set_code, RID, const String &)
+ BIND1RC(String, shader_get_code, RID)
- BIND2(shader_set_code,RID,const String&)
- BIND1RC(String,shader_get_code,RID)
-
- BIND2C(shader_get_param_list,RID, List<PropertyInfo> *)
-
- BIND3(shader_set_default_texture_param,RID,const StringName&,RID)
- BIND2RC(RID,shader_get_default_texture_param,RID,const StringName&)
+ BIND2C(shader_get_param_list, RID, List<PropertyInfo> *)
+ BIND3(shader_set_default_texture_param, RID, const StringName &, RID)
+ BIND2RC(RID, shader_get_default_texture_param, RID, const StringName &)
/* COMMON MATERIAL API */
- BIND0R(RID,material_create)
-
- BIND2(material_set_shader,RID,RID)
- BIND1RC(RID,material_get_shader,RID)
-
- BIND3(material_set_param,RID, const StringName&, const Variant& )
- BIND2RC(Variant,material_get_param,RID, const StringName& )
+ BIND0R(RID, material_create)
- BIND2(material_set_line_width,RID, float )
+ BIND2(material_set_shader, RID, RID)
+ BIND1RC(RID, material_get_shader, RID)
+ BIND3(material_set_param, RID, const StringName &, const Variant &)
+ BIND2RC(Variant, material_get_param, RID, const StringName &)
+ BIND2(material_set_line_width, RID, float)
/* MESH API */
- BIND0R(RID,mesh_create)
+ BIND0R(RID, mesh_create)
- BIND10(mesh_add_surface,RID,uint32_t,PrimitiveType,const PoolVector<uint8_t>&,int ,const PoolVector<uint8_t>& ,int ,const Rect3&,const Vector<PoolVector<uint8_t> >&,const Vector<Rect3>& )
+ BIND10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &)
- BIND2(mesh_set_blend_shape_count,RID,int)
- BIND1RC(int,mesh_get_blend_shape_count,RID)
+ BIND2(mesh_set_blend_shape_count, RID, int)
+ BIND1RC(int, mesh_get_blend_shape_count, RID)
+ BIND2(mesh_set_blend_shape_mode, RID, BlendShapeMode)
+ BIND1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID)
- BIND2(mesh_set_blend_shape_mode,RID,BlendShapeMode)
- BIND1RC(BlendShapeMode, mesh_get_blend_shape_mode,RID )
+ BIND3(mesh_surface_set_material, RID, int, RID)
+ BIND2RC(RID, mesh_surface_get_material, RID, int)
- BIND3(mesh_surface_set_material,RID, int , RID )
- BIND2RC(RID,mesh_surface_get_material,RID, int )
+ BIND2RC(int, mesh_surface_get_array_len, RID, int)
+ BIND2RC(int, mesh_surface_get_array_index_len, RID, int)
- BIND2RC(int,mesh_surface_get_array_len,RID,int)
- BIND2RC(int,mesh_surface_get_array_index_len,RID,int)
+ BIND2RC(PoolVector<uint8_t>, mesh_surface_get_array, RID, int)
+ BIND2RC(PoolVector<uint8_t>, mesh_surface_get_index_array, RID, int)
- BIND2RC(PoolVector<uint8_t>,mesh_surface_get_array,RID,int)
- BIND2RC(PoolVector<uint8_t>,mesh_surface_get_index_array,RID, int)
+ BIND2RC(uint32_t, mesh_surface_get_format, RID, int)
+ BIND2RC(PrimitiveType, mesh_surface_get_primitive_type, RID, int)
- BIND2RC(uint32_t,mesh_surface_get_format,RID,int)
- BIND2RC(PrimitiveType,mesh_surface_get_primitive_type,RID,int)
+ BIND2RC(Rect3, mesh_surface_get_aabb, RID, int)
+ BIND2RC(Vector<PoolVector<uint8_t> >, mesh_surface_get_blend_shapes, RID, int)
+ BIND2RC(Vector<Rect3>, mesh_surface_get_skeleton_aabb, RID, int)
- BIND2RC(Rect3,mesh_surface_get_aabb,RID,int)
- BIND2RC(Vector<PoolVector<uint8_t> >,mesh_surface_get_blend_shapes,RID,int)
- BIND2RC(Vector<Rect3>,mesh_surface_get_skeleton_aabb,RID,int)
+ BIND2(mesh_remove_surface, RID, int)
+ BIND1RC(int, mesh_get_surface_count, RID)
- BIND2(mesh_remove_surface,RID,int)
- BIND1RC(int,mesh_get_surface_count,RID)
+ BIND2(mesh_set_custom_aabb, RID, const Rect3 &)
+ BIND1RC(Rect3, mesh_get_custom_aabb, RID)
- BIND2(mesh_set_custom_aabb,RID,const Rect3&)
- BIND1RC(Rect3,mesh_get_custom_aabb,RID)
-
- BIND1(mesh_clear,RID)
+ BIND1(mesh_clear, RID)
/* MULTIMESH API */
+ BIND0R(RID, multimesh_create)
- BIND0R(RID,multimesh_create)
-
- BIND4(multimesh_allocate,RID,int,MultimeshTransformFormat,MultimeshColorFormat)
- BIND1RC(int,multimesh_get_instance_count,RID)
+ BIND4(multimesh_allocate, RID, int, MultimeshTransformFormat, MultimeshColorFormat)
+ BIND1RC(int, multimesh_get_instance_count, RID)
- BIND2(multimesh_set_mesh,RID,RID)
- BIND3(multimesh_instance_set_transform,RID,int,const Transform&)
- BIND3(multimesh_instance_set_transform_2d,RID,int,const Transform2D& )
- BIND3(multimesh_instance_set_color,RID,int,const Color&)
+ BIND2(multimesh_set_mesh, RID, RID)
+ BIND3(multimesh_instance_set_transform, RID, int, const Transform &)
+ BIND3(multimesh_instance_set_transform_2d, RID, int, const Transform2D &)
+ BIND3(multimesh_instance_set_color, RID, int, const Color &)
- BIND1RC(RID,multimesh_get_mesh,RID)
- BIND1RC(Rect3,multimesh_get_aabb,RID)
+ BIND1RC(RID, multimesh_get_mesh, RID)
+ BIND1RC(Rect3, multimesh_get_aabb, RID)
- BIND2RC(Transform,multimesh_instance_get_transform,RID,int )
- BIND2RC(Transform2D,multimesh_instance_get_transform_2d,RID,int)
- BIND2RC(Color,multimesh_instance_get_color,RID,int)
-
- BIND2(multimesh_set_visible_instances,RID,int)
- BIND1RC(int,multimesh_get_visible_instances,RID)
+ BIND2RC(Transform, multimesh_instance_get_transform, RID, int)
+ BIND2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int)
+ BIND2RC(Color, multimesh_instance_get_color, RID, int)
+ BIND2(multimesh_set_visible_instances, RID, int)
+ BIND1RC(int, multimesh_get_visible_instances, RID)
/* IMMEDIATE API */
- BIND0R(RID,immediate_create)
- BIND3(immediate_begin,RID,PrimitiveType,RID)
- BIND2(immediate_vertex,RID,const Vector3&)
- BIND2(immediate_normal,RID,const Vector3&)
- BIND2(immediate_tangent,RID,const Plane&)
- BIND2(immediate_color,RID,const Color&)
- BIND2(immediate_uv,RID,const Vector2& )
- BIND2(immediate_uv2,RID,const Vector2&)
- BIND1(immediate_end,RID)
- BIND1(immediate_clear,RID)
- BIND2(immediate_set_material,RID ,RID )
- BIND1RC(RID,immediate_get_material,RID)
+ BIND0R(RID, immediate_create)
+ BIND3(immediate_begin, RID, PrimitiveType, RID)
+ BIND2(immediate_vertex, RID, const Vector3 &)
+ BIND2(immediate_normal, RID, const Vector3 &)
+ BIND2(immediate_tangent, RID, const Plane &)
+ BIND2(immediate_color, RID, const Color &)
+ BIND2(immediate_uv, RID, const Vector2 &)
+ BIND2(immediate_uv2, RID, const Vector2 &)
+ BIND1(immediate_end, RID)
+ BIND1(immediate_clear, RID)
+ BIND2(immediate_set_material, RID, RID)
+ BIND1RC(RID, immediate_get_material, RID)
/* SKELETON API */
- BIND0R(RID,skeleton_create)
- BIND3(skeleton_allocate,RID,int,bool)
- BIND1RC(int,skeleton_get_bone_count,RID)
- BIND3(skeleton_bone_set_transform,RID,int,const Transform&)
- BIND2RC(Transform,skeleton_bone_get_transform,RID,int)
- BIND3(skeleton_bone_set_transform_2d,RID,int, const Transform2D& )
- BIND2RC(Transform2D,skeleton_bone_get_transform_2d,RID,int)
+ BIND0R(RID, skeleton_create)
+ BIND3(skeleton_allocate, RID, int, bool)
+ BIND1RC(int, skeleton_get_bone_count, RID)
+ BIND3(skeleton_bone_set_transform, RID, int, const Transform &)
+ BIND2RC(Transform, skeleton_bone_get_transform, RID, int)
+ BIND3(skeleton_bone_set_transform_2d, RID, int, const Transform2D &)
+ BIND2RC(Transform2D, skeleton_bone_get_transform_2d, RID, int)
/* Light API */
- BIND1R(RID,light_create,LightType)
+ BIND1R(RID, light_create, LightType)
- BIND2(light_set_color,RID,const Color&)
- BIND3(light_set_param,RID ,LightParam ,float )
- BIND2(light_set_shadow,RID ,bool )
- BIND2(light_set_shadow_color,RID ,const Color& )
- BIND2(light_set_projector,RID,RID )
- BIND2(light_set_negative,RID,bool )
- BIND2(light_set_cull_mask,RID ,uint32_t )
+ BIND2(light_set_color, RID, const Color &)
+ BIND3(light_set_param, RID, LightParam, float)
+ BIND2(light_set_shadow, RID, bool)
+ BIND2(light_set_shadow_color, RID, const Color &)
+ BIND2(light_set_projector, RID, RID)
+ BIND2(light_set_negative, RID, bool)
+ BIND2(light_set_cull_mask, RID, uint32_t)
- BIND2(light_omni_set_shadow_mode,RID,LightOmniShadowMode)
- BIND2(light_omni_set_shadow_detail,RID,LightOmniShadowDetail)
+ BIND2(light_omni_set_shadow_mode, RID, LightOmniShadowMode)
+ BIND2(light_omni_set_shadow_detail, RID, LightOmniShadowDetail)
- BIND2(light_directional_set_shadow_mode,RID,LightDirectionalShadowMode)
- BIND2(light_directional_set_blend_splits,RID,bool)
+ BIND2(light_directional_set_shadow_mode, RID, LightDirectionalShadowMode)
+ BIND2(light_directional_set_blend_splits, RID, bool)
/* PROBE API */
- BIND0R(RID,reflection_probe_create)
-
- BIND2(reflection_probe_set_update_mode,RID, ReflectionProbeUpdateMode )
- BIND2(reflection_probe_set_intensity,RID, float )
- BIND2(reflection_probe_set_interior_ambient,RID, const Color& )
- BIND2(reflection_probe_set_interior_ambient_energy,RID, float )
- BIND2(reflection_probe_set_interior_ambient_probe_contribution,RID, float )
- BIND2(reflection_probe_set_max_distance,RID, float )
- BIND2(reflection_probe_set_extents,RID, const Vector3& )
- BIND2(reflection_probe_set_origin_offset,RID, const Vector3& )
- BIND2(reflection_probe_set_as_interior,RID, bool )
- BIND2(reflection_probe_set_enable_box_projection,RID, bool )
- BIND2(reflection_probe_set_enable_shadows,RID, bool )
- BIND2(reflection_probe_set_cull_mask,RID, uint32_t )
+ BIND0R(RID, reflection_probe_create)
+
+ BIND2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode)
+ BIND2(reflection_probe_set_intensity, RID, float)
+ BIND2(reflection_probe_set_interior_ambient, RID, const Color &)
+ BIND2(reflection_probe_set_interior_ambient_energy, RID, float)
+ BIND2(reflection_probe_set_interior_ambient_probe_contribution, RID, float)
+ BIND2(reflection_probe_set_max_distance, RID, float)
+ BIND2(reflection_probe_set_extents, RID, const Vector3 &)
+ BIND2(reflection_probe_set_origin_offset, RID, const Vector3 &)
+ BIND2(reflection_probe_set_as_interior, RID, bool)
+ BIND2(reflection_probe_set_enable_box_projection, RID, bool)
+ BIND2(reflection_probe_set_enable_shadows, RID, bool)
+ BIND2(reflection_probe_set_cull_mask, RID, uint32_t)
/* ROOM API */
- BIND0R(RID,room_create)
- BIND4(room_add_bounds,RID, const PoolVector<Vector2>& ,float ,const Transform& )
- BIND1(room_clear_bounds,RID)
+ BIND0R(RID, room_create)
+ BIND4(room_add_bounds, RID, const PoolVector<Vector2> &, float, const Transform &)
+ BIND1(room_clear_bounds, RID)
/* PORTAL API */
// portals are only (x/y) points, forming a convex shape, which its clockwise
// order points outside. (z is 0);
- BIND0R(RID,portal_create)
- BIND2(portal_set_shape,RID , const Vector<Point2>& )
- BIND2(portal_set_enabled,RID , bool )
- BIND2(portal_set_disable_distance,RID , float )
- BIND2(portal_set_disabled_color,RID , const Color& )
+ BIND0R(RID, portal_create)
+ BIND2(portal_set_shape, RID, const Vector<Point2> &)
+ BIND2(portal_set_enabled, RID, bool)
+ BIND2(portal_set_disable_distance, RID, float)
+ BIND2(portal_set_disabled_color, RID, const Color &)
/* BAKED LIGHT API */
BIND0R(RID, gi_probe_create)
- BIND2(gi_probe_set_bounds,RID,const Rect3&)
- BIND1RC(Rect3,gi_probe_get_bounds,RID)
+ BIND2(gi_probe_set_bounds, RID, const Rect3 &)
+ BIND1RC(Rect3, gi_probe_get_bounds, RID)
- BIND2(gi_probe_set_cell_size,RID,float)
- BIND1RC(float,gi_probe_get_cell_size,RID)
+ BIND2(gi_probe_set_cell_size, RID, float)
+ BIND1RC(float, gi_probe_get_cell_size, RID)
- BIND2(gi_probe_set_to_cell_xform,RID,const Transform&)
- BIND1RC(Transform,gi_probe_get_to_cell_xform,RID)
+ BIND2(gi_probe_set_to_cell_xform, RID, const Transform &)
+ BIND1RC(Transform, gi_probe_get_to_cell_xform, RID)
- BIND2(gi_probe_set_dynamic_range,RID,int)
- BIND1RC(int,gi_probe_get_dynamic_range,RID)
+ BIND2(gi_probe_set_dynamic_range, RID, int)
+ BIND1RC(int, gi_probe_get_dynamic_range, RID)
- BIND2(gi_probe_set_energy,RID,float)
- BIND1RC(float,gi_probe_get_energy,RID)
+ BIND2(gi_probe_set_energy, RID, float)
+ BIND1RC(float, gi_probe_get_energy, RID)
- BIND2(gi_probe_set_bias,RID,float)
- BIND1RC(float,gi_probe_get_bias,RID)
+ BIND2(gi_probe_set_bias, RID, float)
+ BIND1RC(float, gi_probe_get_bias, RID)
- BIND2(gi_probe_set_propagation,RID,float)
- BIND1RC(float,gi_probe_get_propagation,RID)
+ BIND2(gi_probe_set_propagation, RID, float)
+ BIND1RC(float, gi_probe_get_propagation, RID)
- BIND2(gi_probe_set_interior,RID,bool)
- BIND1RC(bool,gi_probe_is_interior,RID)
+ BIND2(gi_probe_set_interior, RID, bool)
+ BIND1RC(bool, gi_probe_is_interior, RID)
- BIND2(gi_probe_set_compress,RID,bool)
- BIND1RC(bool,gi_probe_is_compressed,RID)
+ BIND2(gi_probe_set_compress, RID, bool)
+ BIND1RC(bool, gi_probe_is_compressed, RID)
- BIND2(gi_probe_set_dynamic_data,RID,const PoolVector<int>& )
- BIND1RC( PoolVector<int>,gi_probe_get_dynamic_data,RID)
+ BIND2(gi_probe_set_dynamic_data, RID, const PoolVector<int> &)
+ BIND1RC(PoolVector<int>, gi_probe_get_dynamic_data, RID)
/* PARTICLES */
BIND0R(RID, particles_create)
- BIND2(particles_set_emitting,RID,bool)
- BIND2(particles_set_amount,RID,int )
- BIND2(particles_set_lifetime,RID,float )
- BIND2(particles_set_pre_process_time,RID,float )
- BIND2(particles_set_explosiveness_ratio,RID,float )
- BIND2(particles_set_randomness_ratio,RID,float )
- BIND2(particles_set_custom_aabb,RID,const Rect3& )
- BIND2(particles_set_gravity,RID,const Vector3& )
- BIND2(particles_set_use_local_coordinates,RID,bool )
- BIND2(particles_set_process_material,RID,RID )
-
- BIND2(particles_set_emission_shape,RID,VS::ParticlesEmissionShape )
- BIND2(particles_set_emission_sphere_radius,RID,float )
- BIND2(particles_set_emission_box_extents,RID,const Vector3& )
- BIND2(particles_set_emission_points,RID,const PoolVector<Vector3>& )
+ BIND2(particles_set_emitting, RID, bool)
+ BIND2(particles_set_amount, RID, int)
+ BIND2(particles_set_lifetime, RID, float)
+ BIND2(particles_set_pre_process_time, RID, float)
+ BIND2(particles_set_explosiveness_ratio, RID, float)
+ BIND2(particles_set_randomness_ratio, RID, float)
+ BIND2(particles_set_custom_aabb, RID, const Rect3 &)
+ BIND2(particles_set_gravity, RID, const Vector3 &)
+ BIND2(particles_set_use_local_coordinates, RID, bool)
+ BIND2(particles_set_process_material, RID, RID)
+ BIND2(particles_set_emission_shape, RID, VS::ParticlesEmissionShape)
+ BIND2(particles_set_emission_sphere_radius, RID, float)
+ BIND2(particles_set_emission_box_extents, RID, const Vector3 &)
+ BIND2(particles_set_emission_points, RID, const PoolVector<Vector3> &)
- BIND2(particles_set_draw_order,RID,VS::ParticlesDrawOrder )
+ BIND2(particles_set_draw_order, RID, VS::ParticlesDrawOrder)
- BIND2(particles_set_draw_passes,RID,int )
- BIND3(particles_set_draw_pass_material,RID,int , RID )
- BIND3(particles_set_draw_pass_mesh,RID,int , RID )
-
- BIND1R(Rect3,particles_get_current_aabb,RID);
+ BIND2(particles_set_draw_passes, RID, int)
+ BIND3(particles_set_draw_pass_material, RID, int, RID)
+ BIND3(particles_set_draw_pass_mesh, RID, int, RID)
+ BIND1R(Rect3, particles_get_current_aabb, RID);
#undef BINDBASE
//from now on, calls forwarded to this singleton
@@ -876,14 +875,13 @@ public:
/* CAMERA API */
-
BIND0R(RID, camera_create)
- BIND4(camera_set_perspective,RID,float, float , float )
- BIND4(camera_set_orthogonal,RID,float , float , float )
- BIND2(camera_set_transform,RID,const Transform&)
- BIND2(camera_set_cull_mask,RID,uint32_t )
- BIND2(camera_set_environment,RID ,RID )
- BIND2(camera_set_use_vertical_aspect,RID,bool)
+ BIND4(camera_set_perspective, RID, float, float, float)
+ BIND4(camera_set_orthogonal, RID, float, float, float)
+ BIND2(camera_set_transform, RID, const Transform &)
+ BIND2(camera_set_cull_mask, RID, uint32_t)
+ BIND2(camera_set_environment, RID, RID)
+ BIND2(camera_set_use_vertical_aspect, RID, bool)
#undef BINDBASE
//from now on, calls forwarded to this singleton
@@ -891,122 +889,112 @@ public:
/* VIEWPORT TARGET API */
- BIND0R(RID,viewport_create)
-
- BIND3(viewport_set_size,RID,int ,int )
-
- BIND2(viewport_set_active,RID ,bool )
- BIND2(viewport_set_parent_viewport,RID,RID)
+ BIND0R(RID, viewport_create)
- BIND2(viewport_set_clear_mode,RID,ViewportClearMode )
+ BIND3(viewport_set_size, RID, int, int)
- BIND3(viewport_attach_to_screen,RID ,const Rect2& ,int )
- BIND1(viewport_detach,RID)
+ BIND2(viewport_set_active, RID, bool)
+ BIND2(viewport_set_parent_viewport, RID, RID)
- BIND2(viewport_set_update_mode,RID,ViewportUpdateMode )
- BIND2(viewport_set_vflip,RID,bool)
+ BIND2(viewport_set_clear_mode, RID, ViewportClearMode)
+ BIND3(viewport_attach_to_screen, RID, const Rect2 &, int)
+ BIND1(viewport_detach, RID)
- BIND1RC(RID,viewport_get_texture,RID )
+ BIND2(viewport_set_update_mode, RID, ViewportUpdateMode)
+ BIND2(viewport_set_vflip, RID, bool)
- BIND2(viewport_set_hide_scenario,RID,bool )
- BIND2(viewport_set_hide_canvas,RID,bool )
- BIND2(viewport_set_disable_environment,RID,bool )
- BIND2(viewport_set_disable_3d,RID,bool )
+ BIND1RC(RID, viewport_get_texture, RID)
- BIND2(viewport_attach_camera,RID,RID )
- BIND2(viewport_set_scenario,RID,RID )
- BIND2(viewport_attach_canvas,RID,RID )
+ BIND2(viewport_set_hide_scenario, RID, bool)
+ BIND2(viewport_set_hide_canvas, RID, bool)
+ BIND2(viewport_set_disable_environment, RID, bool)
+ BIND2(viewport_set_disable_3d, RID, bool)
- BIND2(viewport_remove_canvas,RID,RID )
- BIND3(viewport_set_canvas_transform,RID ,RID ,const Transform2D& )
- BIND2(viewport_set_transparent_background,RID ,bool )
+ BIND2(viewport_attach_camera, RID, RID)
+ BIND2(viewport_set_scenario, RID, RID)
+ BIND2(viewport_attach_canvas, RID, RID)
- BIND2(viewport_set_global_canvas_transform,RID,const Transform2D& )
- BIND3(viewport_set_canvas_layer,RID ,RID ,int )
- BIND2(viewport_set_shadow_atlas_size,RID ,int )
- BIND3(viewport_set_shadow_atlas_quadrant_subdivision,RID ,int, int )
- BIND2(viewport_set_msaa,RID ,ViewportMSAA )
- BIND2(viewport_set_hdr,RID ,bool )
+ BIND2(viewport_remove_canvas, RID, RID)
+ BIND3(viewport_set_canvas_transform, RID, RID, const Transform2D &)
+ BIND2(viewport_set_transparent_background, RID, bool)
+ BIND2(viewport_set_global_canvas_transform, RID, const Transform2D &)
+ BIND3(viewport_set_canvas_layer, RID, RID, int)
+ BIND2(viewport_set_shadow_atlas_size, RID, int)
+ BIND3(viewport_set_shadow_atlas_quadrant_subdivision, RID, int, int)
+ BIND2(viewport_set_msaa, RID, ViewportMSAA)
+ BIND2(viewport_set_hdr, RID, bool)
- /* ENVIRONMENT API */
+/* ENVIRONMENT API */
#undef BINDBASE
//from now on, calls forwarded to this singleton
#define BINDBASE VSG::scene_render
- BIND0R(RID,environment_create)
-
- BIND2(environment_set_background,RID ,EnvironmentBG )
- BIND2(environment_set_skybox,RID,RID )
- BIND2(environment_set_skybox_scale,RID,float)
- BIND2(environment_set_bg_color,RID,const Color& )
- BIND2(environment_set_bg_energy,RID,float )
- BIND2(environment_set_canvas_max_layer,RID,int )
- BIND4(environment_set_ambient_light,RID,const Color& ,float,float )
- BIND8(environment_set_ssr,RID,bool,int,float,float,float,bool,bool )
- BIND10(environment_set_ssao,RID ,bool , float , float , float,float,float , float ,const Color &,bool )
-
-
-
- BIND6(environment_set_dof_blur_near,RID,bool ,float,float,float,EnvironmentDOFBlurQuality)
- BIND6(environment_set_dof_blur_far,RID,bool ,float,float,float,EnvironmentDOFBlurQuality)
- BIND10(environment_set_glow,RID,bool ,int ,float ,float ,float ,EnvironmentGlowBlendMode,float,float,bool )
- BIND5(environment_set_fog,RID,bool ,float ,float ,RID )
+ BIND0R(RID, environment_create)
- BIND9(environment_set_tonemap,RID,EnvironmentToneMapper, float ,float ,bool, float ,float ,float,float )
+ BIND2(environment_set_background, RID, EnvironmentBG)
+ BIND2(environment_set_skybox, RID, RID)
+ BIND2(environment_set_skybox_scale, RID, float)
+ BIND2(environment_set_bg_color, RID, const Color &)
+ BIND2(environment_set_bg_energy, RID, float)
+ BIND2(environment_set_canvas_max_layer, RID, int)
+ BIND4(environment_set_ambient_light, RID, const Color &, float, float)
+ BIND8(environment_set_ssr, RID, bool, int, float, float, float, bool, bool)
+ BIND10(environment_set_ssao, RID, bool, float, float, float, float, float, float, const Color &, bool)
- BIND6(environment_set_adjustment,RID,bool ,float ,float ,float ,RID )
+ BIND6(environment_set_dof_blur_near, RID, bool, float, float, float, EnvironmentDOFBlurQuality)
+ BIND6(environment_set_dof_blur_far, RID, bool, float, float, float, EnvironmentDOFBlurQuality)
+ BIND10(environment_set_glow, RID, bool, int, float, float, float, EnvironmentGlowBlendMode, float, float, bool)
+ BIND5(environment_set_fog, RID, bool, float, float, RID)
+ BIND9(environment_set_tonemap, RID, EnvironmentToneMapper, float, float, bool, float, float, float, float)
- /* SCENARIO API */
+ BIND6(environment_set_adjustment, RID, bool, float, float, float, RID)
+/* SCENARIO API */
#undef BINDBASE
#define BINDBASE VSG::scene
- BIND0R(RID,scenario_create)
-
- BIND2(scenario_set_debug,RID,ScenarioDebugMode )
- BIND2(scenario_set_environment,RID, RID )
- BIND3(scenario_set_reflection_atlas_size,RID, int,int )
- BIND2(scenario_set_fallback_environment,RID, RID )
+ BIND0R(RID, scenario_create)
+ BIND2(scenario_set_debug, RID, ScenarioDebugMode)
+ BIND2(scenario_set_environment, RID, RID)
+ BIND3(scenario_set_reflection_atlas_size, RID, int, int)
+ BIND2(scenario_set_fallback_environment, RID, RID)
/* INSTANCING API */
- // from can be mesh, light, area and portal so far.
- BIND0R(RID,instance_create)
-
- BIND2(instance_set_base,RID, RID ) // from can be mesh, light, poly, area and portal so far.
- BIND2(instance_set_scenario,RID, RID ) // from can be mesh, light, poly, area and portal so far.
- BIND2(instance_set_layer_mask,RID, uint32_t )
- BIND2(instance_set_transform,RID, const Transform& )
- BIND2(instance_attach_object_instance_ID,RID,ObjectID )
- BIND3(instance_set_blend_shape_weight,RID,int , float )
- BIND3(instance_set_surface_material,RID,int , RID )
- BIND2(instance_set_visible,RID ,bool)
+ // from can be mesh, light, area and portal so far.
+ BIND0R(RID, instance_create)
+ BIND2(instance_set_base, RID, RID) // from can be mesh, light, poly, area and portal so far.
+ BIND2(instance_set_scenario, RID, RID) // from can be mesh, light, poly, area and portal so far.
+ BIND2(instance_set_layer_mask, RID, uint32_t)
+ BIND2(instance_set_transform, RID, const Transform &)
+ BIND2(instance_attach_object_instance_ID, RID, ObjectID)
+ BIND3(instance_set_blend_shape_weight, RID, int, float)
+ BIND3(instance_set_surface_material, RID, int, RID)
+ BIND2(instance_set_visible, RID, bool)
- BIND2(instance_attach_skeleton,RID,RID )
- BIND2(instance_set_exterior, RID, bool )
- BIND2(instance_set_room, RID, RID )
+ BIND2(instance_attach_skeleton, RID, RID)
+ BIND2(instance_set_exterior, RID, bool)
+ BIND2(instance_set_room, RID, RID)
- BIND2(instance_set_extra_visibility_margin, RID, real_t )
+ BIND2(instance_set_extra_visibility_margin, RID, real_t)
// don't use these in a game!
- BIND2RC(Vector<ObjectID>,instances_cull_aabb,const Rect3& , RID)
- BIND3RC(Vector<ObjectID>,instances_cull_ray,const Vector3& , const Vector3& , RID )
- BIND2RC(Vector<ObjectID>,instances_cull_convex,const Vector<Plane>& , RID)
-
-
- BIND3(instance_geometry_set_flag,RID,InstanceFlags ,bool )
- BIND2(instance_geometry_set_cast_shadows_setting,RID, ShadowCastingSetting )
- BIND2(instance_geometry_set_material_override,RID, RID )
+ BIND2RC(Vector<ObjectID>, instances_cull_aabb, const Rect3 &, RID)
+ BIND3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID)
+ BIND2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID)
+ BIND3(instance_geometry_set_flag, RID, InstanceFlags, bool)
+ BIND2(instance_geometry_set_cast_shadows_setting, RID, ShadowCastingSetting)
+ BIND2(instance_geometry_set_material_override, RID, RID)
- BIND5(instance_geometry_set_draw_range,RID,float ,float ,float ,float )
- BIND2(instance_geometry_set_as_instance_lod,RID,RID )
+ BIND5(instance_geometry_set_draw_range, RID, float, float, float, float)
+ BIND2(instance_geometry_set_as_instance_lod, RID, RID)
#undef BINDBASE
//from now on, calls forwarded to this singleton
@@ -1014,110 +1002,100 @@ public:
/* CANVAS (2D) */
- BIND0R(RID,canvas_create)
- BIND3(canvas_set_item_mirroring,RID ,RID ,const Point2& )
- BIND2(canvas_set_modulate,RID,const Color&)
-
-
- BIND0R(RID,canvas_item_create)
- BIND2(canvas_item_set_parent,RID ,RID)
-
- BIND2(canvas_item_set_visible,RID,bool )
- BIND2(canvas_item_set_light_mask,RID,int )
-
- BIND2(canvas_item_set_transform,RID, const Transform2D& )
- BIND2(canvas_item_set_clip,RID, bool )
- BIND2(canvas_item_set_distance_field_mode,RID, bool )
- BIND3(canvas_item_set_custom_rect,RID, bool ,const Rect2& )
- BIND2(canvas_item_set_modulate,RID, const Color& )
- BIND2(canvas_item_set_self_modulate,RID, const Color& )
-
- BIND2(canvas_item_set_draw_behind_parent,RID, bool )
-
-
- BIND6(canvas_item_add_line,RID, const Point2& , const Point2& ,const Color& ,float ,bool )
- BIND3(canvas_item_add_rect,RID, const Rect2& , const Color& )
- BIND4(canvas_item_add_circle,RID, const Point2& , float ,const Color& )
- BIND6(canvas_item_add_texture_rect,RID, const Rect2& , RID ,bool ,const Color& ,bool )
- BIND6(canvas_item_add_texture_rect_region,RID, const Rect2& , RID ,const Rect2& ,const Color& ,bool )
- BIND10(canvas_item_add_nine_patch,RID, const Rect2& , const Rect2& , RID ,const Vector2& , const Vector2& ,NinePatchAxisMode , NinePatchAxisMode,bool ,const Color& )
- BIND6(canvas_item_add_primitive,RID, const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID ,float )
- BIND5(canvas_item_add_polygon,RID, const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID )
- BIND7(canvas_item_add_triangle_array,RID, const Vector<int>& , const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID , int)
- BIND3(canvas_item_add_mesh,RID, const RID& ,RID )
- BIND3(canvas_item_add_multimesh,RID, RID ,RID )
- BIND2(canvas_item_add_set_transform,RID,const Transform2D& )
- BIND2(canvas_item_add_clip_ignore,RID, bool )
- BIND2(canvas_item_set_sort_children_by_y,RID, bool )
- BIND2(canvas_item_set_z,RID, int )
- BIND2(canvas_item_set_z_as_relative_to_parent,RID, bool )
- BIND3(canvas_item_set_copy_to_backbuffer,RID, bool ,const Rect2& )
-
- BIND1(canvas_item_clear,RID )
- BIND2(canvas_item_set_draw_index,RID,int)
-
- BIND2(canvas_item_set_material,RID, RID )
-
- BIND2(canvas_item_set_use_parent_material,RID, bool )
-
-
- BIND0R(RID,canvas_light_create)
- BIND2(canvas_light_attach_to_canvas,RID,RID )
- BIND2(canvas_light_set_enabled,RID, bool )
- BIND2(canvas_light_set_scale,RID, float )
- BIND2(canvas_light_set_transform,RID, const Transform2D& )
- BIND2(canvas_light_set_texture,RID, RID )
- BIND2(canvas_light_set_texture_offset,RID, const Vector2& )
- BIND2(canvas_light_set_color,RID, const Color& )
- BIND2(canvas_light_set_height,RID, float )
- BIND2(canvas_light_set_energy,RID, float )
- BIND3(canvas_light_set_z_range,RID, int ,int )
- BIND3(canvas_light_set_layer_range,RID, int ,int )
- BIND2(canvas_light_set_item_cull_mask,RID, int )
- BIND2(canvas_light_set_item_shadow_cull_mask,RID, int )
-
- BIND2(canvas_light_set_mode,RID, CanvasLightMode )
-
- BIND2(canvas_light_set_shadow_enabled,RID, bool )
- BIND2(canvas_light_set_shadow_buffer_size,RID, int )
- BIND2(canvas_light_set_shadow_gradient_length,RID, float )
- BIND2(canvas_light_set_shadow_filter,RID, CanvasLightShadowFilter )
- BIND2(canvas_light_set_shadow_color,RID, const Color& )
-
-
-
- BIND0R(RID,canvas_light_occluder_create)
- BIND2(canvas_light_occluder_attach_to_canvas,RID,RID )
- BIND2(canvas_light_occluder_set_enabled,RID,bool )
- BIND2(canvas_light_occluder_set_polygon,RID,RID )
- BIND2(canvas_light_occluder_set_transform,RID,const Transform2D& )
- BIND2(canvas_light_occluder_set_light_mask,RID,int )
-
-
- BIND0R(RID,canvas_occluder_polygon_create)
- BIND3(canvas_occluder_polygon_set_shape,RID,const PoolVector<Vector2>& ,bool)
- BIND2(canvas_occluder_polygon_set_shape_as_lines,RID ,const PoolVector<Vector2>&)
-
-
- BIND2(canvas_occluder_polygon_set_cull_mode,RID,CanvasOccluderPolygonCullMode)
-
+ BIND0R(RID, canvas_create)
+ BIND3(canvas_set_item_mirroring, RID, RID, const Point2 &)
+ BIND2(canvas_set_modulate, RID, const Color &)
+
+ BIND0R(RID, canvas_item_create)
+ BIND2(canvas_item_set_parent, RID, RID)
+
+ BIND2(canvas_item_set_visible, RID, bool)
+ BIND2(canvas_item_set_light_mask, RID, int)
+
+ BIND2(canvas_item_set_transform, RID, const Transform2D &)
+ BIND2(canvas_item_set_clip, RID, bool)
+ BIND2(canvas_item_set_distance_field_mode, RID, bool)
+ BIND3(canvas_item_set_custom_rect, RID, bool, const Rect2 &)
+ BIND2(canvas_item_set_modulate, RID, const Color &)
+ BIND2(canvas_item_set_self_modulate, RID, const Color &)
+
+ BIND2(canvas_item_set_draw_behind_parent, RID, bool)
+
+ BIND6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
+ BIND3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
+ BIND4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
+ BIND6(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool)
+ BIND6(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool)
+ BIND10(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &)
+ BIND6(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float)
+ BIND5(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID)
+ BIND7(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int)
+ BIND3(canvas_item_add_mesh, RID, const RID &, RID)
+ BIND3(canvas_item_add_multimesh, RID, RID, RID)
+ BIND2(canvas_item_add_set_transform, RID, const Transform2D &)
+ BIND2(canvas_item_add_clip_ignore, RID, bool)
+ BIND2(canvas_item_set_sort_children_by_y, RID, bool)
+ BIND2(canvas_item_set_z, RID, int)
+ BIND2(canvas_item_set_z_as_relative_to_parent, RID, bool)
+ BIND3(canvas_item_set_copy_to_backbuffer, RID, bool, const Rect2 &)
+
+ BIND1(canvas_item_clear, RID)
+ BIND2(canvas_item_set_draw_index, RID, int)
+
+ BIND2(canvas_item_set_material, RID, RID)
+
+ BIND2(canvas_item_set_use_parent_material, RID, bool)
+
+ BIND0R(RID, canvas_light_create)
+ BIND2(canvas_light_attach_to_canvas, RID, RID)
+ BIND2(canvas_light_set_enabled, RID, bool)
+ BIND2(canvas_light_set_scale, RID, float)
+ BIND2(canvas_light_set_transform, RID, const Transform2D &)
+ BIND2(canvas_light_set_texture, RID, RID)
+ BIND2(canvas_light_set_texture_offset, RID, const Vector2 &)
+ BIND2(canvas_light_set_color, RID, const Color &)
+ BIND2(canvas_light_set_height, RID, float)
+ BIND2(canvas_light_set_energy, RID, float)
+ BIND3(canvas_light_set_z_range, RID, int, int)
+ BIND3(canvas_light_set_layer_range, RID, int, int)
+ BIND2(canvas_light_set_item_cull_mask, RID, int)
+ BIND2(canvas_light_set_item_shadow_cull_mask, RID, int)
+
+ BIND2(canvas_light_set_mode, RID, CanvasLightMode)
+
+ BIND2(canvas_light_set_shadow_enabled, RID, bool)
+ BIND2(canvas_light_set_shadow_buffer_size, RID, int)
+ BIND2(canvas_light_set_shadow_gradient_length, RID, float)
+ BIND2(canvas_light_set_shadow_filter, RID, CanvasLightShadowFilter)
+ BIND2(canvas_light_set_shadow_color, RID, const Color &)
+
+ BIND0R(RID, canvas_light_occluder_create)
+ BIND2(canvas_light_occluder_attach_to_canvas, RID, RID)
+ BIND2(canvas_light_occluder_set_enabled, RID, bool)
+ BIND2(canvas_light_occluder_set_polygon, RID, RID)
+ BIND2(canvas_light_occluder_set_transform, RID, const Transform2D &)
+ BIND2(canvas_light_occluder_set_light_mask, RID, int)
+
+ BIND0R(RID, canvas_occluder_polygon_create)
+ BIND3(canvas_occluder_polygon_set_shape, RID, const PoolVector<Vector2> &, bool)
+ BIND2(canvas_occluder_polygon_set_shape_as_lines, RID, const PoolVector<Vector2> &)
+
+ BIND2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
/* CURSOR */
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0); // radians
- virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor=0, const Rect2 &p_region=Rect2());
+ virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor = 0, const Rect2 &p_region = Rect2());
virtual void cursor_set_visible(bool p_visible, int p_cursor = 0);
- virtual void cursor_set_pos(const Point2& p_pos, int p_cursor = 0);
+ virtual void cursor_set_pos(const Point2 &p_pos, int p_cursor = 0);
/* BLACK BARS */
-
virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom);
virtual void black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom);
-
/* FREE */
- virtual void free( RID p_rid ); ///< free RIDs associated with the visual server
+ virtual void free(RID p_rid); ///< free RIDs associated with the visual server
/* EVENT QUEUING */
@@ -1129,21 +1107,18 @@ public:
/* STATUS INFORMATION */
-
virtual int get_render_info(RenderInfo p_info);
virtual RID get_test_cube();
-
/* TESTING */
- virtual void set_boot_image(const Image& p_image, const Color& p_color,bool p_scale);
- virtual void set_default_clear_color(const Color& p_color);
+ virtual void set_boot_image(const Image &p_image, const Color &p_color, bool p_scale);
+ virtual void set_default_clear_color(const Color &p_color);
virtual bool has_feature(Features p_feature) const;
- virtual bool has_os_feature(const String& p_feature) const;
-
+ virtual bool has_os_feature(const String &p_feature) const;
VisualServerRaster();
~VisualServerRaster();
@@ -1166,7 +1141,6 @@ public:
#undef BIND8
#undef BIND9
#undef BIND10
-
};
#endif
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index e004103508..46c7fa6791 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -27,84 +27,68 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_server_scene.h"
-#include "visual_server_global.h"
#include "os/os.h"
+#include "visual_server_global.h"
/* CAMERA API */
-
-
-
-
RID VisualServerScene::camera_create() {
- Camera * camera = memnew( Camera );
- return camera_owner.make_rid( camera );
-
+ Camera *camera = memnew(Camera);
+ return camera_owner.make_rid(camera);
}
-void VisualServerScene::camera_set_perspective(RID p_camera,float p_fovy_degrees, float p_z_near, float p_z_far) {
+void VisualServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
- Camera *camera = camera_owner.get( p_camera );
+ Camera *camera = camera_owner.get(p_camera);
ERR_FAIL_COND(!camera);
- camera->type=Camera::PERSPECTIVE;
- camera->fov=p_fovy_degrees;
- camera->znear=p_z_near;
- camera->zfar=p_z_far;
-
+ camera->type = Camera::PERSPECTIVE;
+ camera->fov = p_fovy_degrees;
+ camera->znear = p_z_near;
+ camera->zfar = p_z_far;
}
-void VisualServerScene::camera_set_orthogonal(RID p_camera,float p_size, float p_z_near, float p_z_far) {
+void VisualServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
- Camera *camera = camera_owner.get( p_camera );
+ Camera *camera = camera_owner.get(p_camera);
ERR_FAIL_COND(!camera);
- camera->type=Camera::ORTHOGONAL;
- camera->size=p_size;
- camera->znear=p_z_near;
- camera->zfar=p_z_far;
+ camera->type = Camera::ORTHOGONAL;
+ camera->size = p_size;
+ camera->znear = p_z_near;
+ camera->zfar = p_z_far;
}
-void VisualServerScene::camera_set_transform(RID p_camera,const Transform& p_transform) {
+void VisualServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) {
- Camera *camera = camera_owner.get( p_camera );
+ Camera *camera = camera_owner.get(p_camera);
ERR_FAIL_COND(!camera);
- camera->transform=p_transform.orthonormalized();
-
-
+ camera->transform = p_transform.orthonormalized();
}
-void VisualServerScene::camera_set_cull_mask(RID p_camera,uint32_t p_layers) {
-
+void VisualServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
- Camera *camera = camera_owner.get( p_camera );
+ Camera *camera = camera_owner.get(p_camera);
ERR_FAIL_COND(!camera);
- camera->visible_layers=p_layers;
-
+ camera->visible_layers = p_layers;
}
-void VisualServerScene::camera_set_environment(RID p_camera,RID p_env) {
+void VisualServerScene::camera_set_environment(RID p_camera, RID p_env) {
- Camera *camera = camera_owner.get( p_camera );
+ Camera *camera = camera_owner.get(p_camera);
ERR_FAIL_COND(!camera);
- camera->env=p_env;
-
+ camera->env = p_env;
}
+void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
-void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera,bool p_enable) {
-
- Camera *camera = camera_owner.get( p_camera );
+ Camera *camera = camera_owner.get(p_camera);
ERR_FAIL_COND(!camera);
- camera->vaspect=p_enable;
-
+ camera->vaspect = p_enable;
}
-
/* SCENARIO API */
-
-
-void* VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int) {
+void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int) {
//VisualServerScene *self = (VisualServerScene*)p_self;
Instance *A = p_A;
@@ -112,69 +96,64 @@ void* VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
//instance indices are designed so greater always contains lesser
if (A->base_type > B->base_type) {
- SWAP(A,B); //lesser always first
+ SWAP(A, B); //lesser always first
}
- if (B->base_type==VS::INSTANCE_LIGHT && (1<<A->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
-
- InstanceLightData * light = static_cast<InstanceLightData*>(B->base_data);
- InstanceGeometryData * geom = static_cast<InstanceGeometryData*>(A->base_data);
+ if (B->base_type == VS::INSTANCE_LIGHT && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
InstanceLightData::PairInfo pinfo;
- pinfo.geometry=A;
+ pinfo.geometry = A;
pinfo.L = geom->lighting.push_back(B);
List<InstanceLightData::PairInfo>::Element *E = light->geometries.push_back(pinfo);
if (geom->can_cast_shadows) {
- light->shadow_dirty=true;
+ light->shadow_dirty = true;
}
- geom->lighting_dirty=true;
+ geom->lighting_dirty = true;
return E; //this element should make freeing faster
- } else if (B->base_type==VS::INSTANCE_REFLECTION_PROBE && (1<<A->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
-
- InstanceReflectionProbeData * reflection_probe = static_cast<InstanceReflectionProbeData*>(B->base_data);
- InstanceGeometryData * geom = static_cast<InstanceGeometryData*>(A->base_data);
+ } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
InstanceReflectionProbeData::PairInfo pinfo;
- pinfo.geometry=A;
+ pinfo.geometry = A;
pinfo.L = geom->reflection_probes.push_back(B);
List<InstanceReflectionProbeData::PairInfo>::Element *E = reflection_probe->geometries.push_back(pinfo);
- geom->reflection_dirty=true;
+ geom->reflection_dirty = true;
return E; //this element should make freeing faster
- } else if (B->base_type==VS::INSTANCE_GI_PROBE && (1<<A->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
-
- InstanceGIProbeData * gi_probe = static_cast<InstanceGIProbeData*>(B->base_data);
- InstanceGeometryData * geom = static_cast<InstanceGeometryData*>(A->base_data);
+ } else if (B->base_type == VS::INSTANCE_GI_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
InstanceGIProbeData::PairInfo pinfo;
- pinfo.geometry=A;
+ pinfo.geometry = A;
pinfo.L = geom->gi_probes.push_back(B);
List<InstanceGIProbeData::PairInfo>::Element *E = gi_probe->geometries.push_back(pinfo);
- geom->gi_probes_dirty=true;
+ geom->gi_probes_dirty = true;
return E; //this element should make freeing faster
- } else if (B->base_type==VS::INSTANCE_GI_PROBE && A->base_type==VS::INSTANCE_LIGHT) {
+ } else if (B->base_type == VS::INSTANCE_GI_PROBE && A->base_type == VS::INSTANCE_LIGHT) {
- InstanceGIProbeData * gi_probe = static_cast<InstanceGIProbeData*>(B->base_data);
- InstanceLightData * light = static_cast<InstanceLightData*>(A->base_data);
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
+ InstanceLightData *light = static_cast<InstanceLightData *>(A->base_data);
return gi_probe->lights.insert(A);
}
-
-
#if 0
if (A->base_type==INSTANCE_PORTAL) {
@@ -228,9 +207,8 @@ void* VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
#endif
return NULL;
-
}
-void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int,void* udata) {
+void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) {
//VisualServerScene *self = (VisualServerScene*)p_self;
Instance *A = p_A;
@@ -238,59 +216,54 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
//instance indices are designed so greater always contains lesser
if (A->base_type > B->base_type) {
- SWAP(A,B); //lesser always first
+ SWAP(A, B); //lesser always first
}
+ if (B->base_type == VS::INSTANCE_LIGHT && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
- if (B->base_type==VS::INSTANCE_LIGHT && (1<<A->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
-
- InstanceLightData * light = static_cast<InstanceLightData*>(B->base_data);
- InstanceGeometryData * geom = static_cast<InstanceGeometryData*>(A->base_data);
-
- List<InstanceLightData::PairInfo>::Element *E = reinterpret_cast<List<InstanceLightData::PairInfo>::Element*>(udata);
+ List<InstanceLightData::PairInfo>::Element *E = reinterpret_cast<List<InstanceLightData::PairInfo>::Element *>(udata);
geom->lighting.erase(E->get().L);
light->geometries.erase(E);
if (geom->can_cast_shadows) {
- light->shadow_dirty=true;
+ light->shadow_dirty = true;
}
- geom->lighting_dirty=true;
-
+ geom->lighting_dirty = true;
- } else if (B->base_type==VS::INSTANCE_REFLECTION_PROBE && (1<<A->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
+ } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
- InstanceReflectionProbeData * reflection_probe = static_cast<InstanceReflectionProbeData*>(B->base_data);
- InstanceGeometryData * geom = static_cast<InstanceGeometryData*>(A->base_data);
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
- List<InstanceReflectionProbeData::PairInfo>::Element *E = reinterpret_cast<List<InstanceReflectionProbeData::PairInfo>::Element*>(udata);
+ List<InstanceReflectionProbeData::PairInfo>::Element *E = reinterpret_cast<List<InstanceReflectionProbeData::PairInfo>::Element *>(udata);
geom->reflection_probes.erase(E->get().L);
reflection_probe->geometries.erase(E);
- geom->reflection_dirty=true;
+ geom->reflection_dirty = true;
- } else if (B->base_type==VS::INSTANCE_GI_PROBE && (1<<A->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
+ } else if (B->base_type == VS::INSTANCE_GI_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
- InstanceGIProbeData * gi_probe = static_cast<InstanceGIProbeData*>(B->base_data);
- InstanceGeometryData * geom = static_cast<InstanceGeometryData*>(A->base_data);
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
- List<InstanceGIProbeData::PairInfo>::Element *E = reinterpret_cast<List<InstanceGIProbeData::PairInfo>::Element*>(udata);
+ List<InstanceGIProbeData::PairInfo>::Element *E = reinterpret_cast<List<InstanceGIProbeData::PairInfo>::Element *>(udata);
geom->gi_probes.erase(E->get().L);
gi_probe->geometries.erase(E);
- geom->gi_probes_dirty=true;
-
-
- } else if (B->base_type==VS::INSTANCE_GI_PROBE && A->base_type==VS::INSTANCE_LIGHT) {
+ geom->gi_probes_dirty = true;
- InstanceGIProbeData * gi_probe = static_cast<InstanceGIProbeData*>(B->base_data);
- InstanceLightData * light = static_cast<InstanceLightData*>(A->base_data);
+ } else if (B->base_type == VS::INSTANCE_GI_PROBE && A->base_type == VS::INSTANCE_LIGHT) {
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
+ InstanceLightData *light = static_cast<InstanceLightData *>(A->base_data);
- Set<Instance*>::Element *E = reinterpret_cast<Set<Instance*>::Element*>(udata);
+ Set<Instance *>::Element *E = reinterpret_cast<Set<Instance *>::Element *>(udata);
gi_probe->lights.erase(E);
}
@@ -349,124 +322,111 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
RID VisualServerScene::scenario_create() {
- Scenario *scenario = memnew( Scenario );
- ERR_FAIL_COND_V(!scenario,RID());
- RID scenario_rid = scenario_owner.make_rid( scenario );
- scenario->self=scenario_rid;
-
- scenario->octree.set_pair_callback(_instance_pair,this);
- scenario->octree.set_unpair_callback(_instance_unpair,this);
- scenario->reflection_probe_shadow_atlas=VSG::scene_render->shadow_atlas_create();
- VSG::scene_render->shadow_atlas_set_size(scenario->reflection_probe_shadow_atlas,1024); //make enough shadows for close distance, don't bother with rest
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas,0,4);
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas,1,4);
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas,2,4);
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas,3,8);
- scenario->reflection_atlas=VSG::scene_render->reflection_atlas_create();
+ Scenario *scenario = memnew(Scenario);
+ ERR_FAIL_COND_V(!scenario, RID());
+ RID scenario_rid = scenario_owner.make_rid(scenario);
+ scenario->self = scenario_rid;
+
+ scenario->octree.set_pair_callback(_instance_pair, this);
+ scenario->octree.set_unpair_callback(_instance_unpair, this);
+ scenario->reflection_probe_shadow_atlas = VSG::scene_render->shadow_atlas_create();
+ VSG::scene_render->shadow_atlas_set_size(scenario->reflection_probe_shadow_atlas, 1024); //make enough shadows for close distance, don't bother with rest
+ VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 0, 4);
+ VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 1, 4);
+ VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 2, 4);
+ VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 3, 8);
+ scenario->reflection_atlas = VSG::scene_render->reflection_atlas_create();
return scenario_rid;
}
-void VisualServerScene::scenario_set_debug(RID p_scenario,VS::ScenarioDebugMode p_debug_mode) {
+void VisualServerScene::scenario_set_debug(RID p_scenario, VS::ScenarioDebugMode p_debug_mode) {
Scenario *scenario = scenario_owner.get(p_scenario);
ERR_FAIL_COND(!scenario);
- scenario->debug=p_debug_mode;
+ scenario->debug = p_debug_mode;
}
void VisualServerScene::scenario_set_environment(RID p_scenario, RID p_environment) {
Scenario *scenario = scenario_owner.get(p_scenario);
ERR_FAIL_COND(!scenario);
- scenario->environment=p_environment;
-
+ scenario->environment = p_environment;
}
void VisualServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
-
Scenario *scenario = scenario_owner.get(p_scenario);
ERR_FAIL_COND(!scenario);
- scenario->fallback_environment=p_environment;
-
-
+ scenario->fallback_environment = p_environment;
}
-void VisualServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_size,int p_subdiv) {
+void VisualServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_size, int p_subdiv) {
Scenario *scenario = scenario_owner.get(p_scenario);
ERR_FAIL_COND(!scenario);
- VSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas,p_size);
- VSG::scene_render->reflection_atlas_set_subdivision(scenario->reflection_atlas,p_subdiv);
-
-
+ VSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_size);
+ VSG::scene_render->reflection_atlas_set_subdivision(scenario->reflection_atlas, p_subdiv);
}
-
-
/* INSTANCING API */
-void VisualServerScene::_instance_queue_update(Instance *p_instance,bool p_update_aabb,bool p_update_materials) {
+void VisualServerScene::_instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_materials) {
if (p_update_aabb)
- p_instance->update_aabb=true;
+ p_instance->update_aabb = true;
if (p_update_materials)
- p_instance->update_materials=true;
+ p_instance->update_materials = true;
if (p_instance->update_item.in_list())
return;
_instance_update_list.add(&p_instance->update_item);
-
-
}
// from can be mesh, light, area and portal so far.
-RID VisualServerScene::instance_create(){
+RID VisualServerScene::instance_create() {
- Instance *instance = memnew( Instance );
- ERR_FAIL_COND_V(!instance,RID());
+ Instance *instance = memnew(Instance);
+ ERR_FAIL_COND_V(!instance, RID());
RID instance_rid = instance_owner.make_rid(instance);
- instance->self=instance_rid;
-
+ instance->self = instance_rid;
return instance_rid;
-
-
}
-void VisualServerScene::instance_set_base(RID p_instance, RID p_base){
+void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
Scenario *scenario = instance->scenario;
- if (instance->base_type!=VS::INSTANCE_NONE) {
+ if (instance->base_type != VS::INSTANCE_NONE) {
//free anything related to that base
- VSG::storage->instance_remove_dependency(instance->base,instance);
+ VSG::storage->instance_remove_dependency(instance->base, instance);
if (scenario && instance->octree_id) {
scenario->octree.erase(instance->octree_id); //make dependencies generated by the octree go away
- instance->octree_id=0;
+ instance->octree_id = 0;
}
- switch(instance->base_type) {
+ switch (instance->base_type) {
case VS::INSTANCE_LIGHT: {
- InstanceLightData *light = static_cast<InstanceLightData*>(instance->base_data);
+ InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
if (instance->scenario && light->D) {
- instance->scenario->directional_lights.erase( light->D );
- light->D=NULL;
+ instance->scenario->directional_lights.erase(light->D);
+ light->D = NULL;
}
VSG::scene_render->free(light->instance);
} break;
case VS::INSTANCE_REFLECTION_PROBE: {
- InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData*>(instance->base_data);
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data);
VSG::scene_render->free(reflection_probe->instance);
if (reflection_probe->update_list.in_list()) {
reflection_probe_render_list.remove(&reflection_probe->update_list);
@@ -474,9 +434,9 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base){
} break;
case VS::INSTANCE_GI_PROBE: {
- InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData*>(instance->base_data);
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
- while(gi_probe->dynamic.updating_stage==GI_UPDATE_STAGE_LIGHTING) {
+ while (gi_probe->dynamic.updating_stage == GI_UPDATE_STAGE_LIGHTING) {
//wait until bake is done if it's baking
OS::get_singleton()->delay_usec(1);
}
@@ -490,19 +450,18 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base){
VSG::scene_render->free(gi_probe->probe_instance);
} break;
-
}
if (instance->base_data) {
- memdelete( instance->base_data );
- instance->base_data=NULL;
+ memdelete(instance->base_data);
+ instance->base_data = NULL;
}
instance->blend_values.clear();
- for(int i=0;i<instance->materials.size();i++) {
+ for (int i = 0; i < instance->materials.size(); i++) {
if (instance->materials[i].is_valid()) {
- VSG::storage->material_remove_instance_owner(instance->materials[i],instance);
+ VSG::storage->material_remove_instance_owner(instance->materials[i], instance);
}
}
instance->materials.clear();
@@ -625,70 +584,65 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base){
instance->gi_probe_sampler_info=NULL;
}
#endif
-
}
-
- instance->base_type=VS::INSTANCE_NONE;
- instance->base=RID();
-
+ instance->base_type = VS::INSTANCE_NONE;
+ instance->base = RID();
if (p_base.is_valid()) {
- instance->base_type=VSG::storage->get_base_type(p_base);
- ERR_FAIL_COND(instance->base_type==VS::INSTANCE_NONE);
+ instance->base_type = VSG::storage->get_base_type(p_base);
+ ERR_FAIL_COND(instance->base_type == VS::INSTANCE_NONE);
- switch(instance->base_type) {
+ switch (instance->base_type) {
case VS::INSTANCE_LIGHT: {
- InstanceLightData *light = memnew( InstanceLightData );
+ InstanceLightData *light = memnew(InstanceLightData);
- if (scenario && VSG::storage->light_get_type(p_base)==VS::LIGHT_DIRECTIONAL) {
+ if (scenario && VSG::storage->light_get_type(p_base) == VS::LIGHT_DIRECTIONAL) {
light->D = scenario->directional_lights.push_back(instance);
}
light->instance = VSG::scene_render->light_instance_create(p_base);
- instance->base_data=light;
+ instance->base_data = light;
} break;
case VS::INSTANCE_MESH:
case VS::INSTANCE_MULTIMESH:
case VS::INSTANCE_IMMEDIATE: {
- InstanceGeometryData *geom = memnew( InstanceGeometryData );
- instance->base_data=geom;
+ InstanceGeometryData *geom = memnew(InstanceGeometryData);
+ instance->base_data = geom;
} break;
case VS::INSTANCE_REFLECTION_PROBE: {
- InstanceReflectionProbeData *reflection_probe = memnew( InstanceReflectionProbeData );
- reflection_probe->owner=instance;
- instance->base_data=reflection_probe;
+ InstanceReflectionProbeData *reflection_probe = memnew(InstanceReflectionProbeData);
+ reflection_probe->owner = instance;
+ instance->base_data = reflection_probe;
- reflection_probe->instance=VSG::scene_render->reflection_probe_instance_create(p_base);
+ reflection_probe->instance = VSG::scene_render->reflection_probe_instance_create(p_base);
} break;
case VS::INSTANCE_GI_PROBE: {
- InstanceGIProbeData *gi_probe = memnew( InstanceGIProbeData );
- instance->base_data=gi_probe;
- gi_probe->owner=instance;
+ InstanceGIProbeData *gi_probe = memnew(InstanceGIProbeData);
+ instance->base_data = gi_probe;
+ gi_probe->owner = instance;
if (scenario && !gi_probe->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element);
}
- gi_probe->probe_instance=VSG::scene_render->gi_probe_instance_create();
+ gi_probe->probe_instance = VSG::scene_render->gi_probe_instance_create();
} break;
-
}
- VSG::storage->instance_add_dependency(p_base,instance);
+ VSG::storage->instance_add_dependency(p_base, instance);
- instance->base=p_base;
+ instance->base = p_base;
if (scenario)
- _instance_queue_update(instance,true,true);
-
+ _instance_queue_update(instance, true, true);
#if 0
if (rasterizer->is_mesh(p_base)) {
@@ -747,238 +701,219 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base){
instance_dependency_map[ p_base ].insert( instance->self );
#endif
-
-
}
}
-void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario){
+void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
if (instance->scenario) {
- instance->scenario->instances.remove( &instance->scenario_item );
+ instance->scenario->instances.remove(&instance->scenario_item);
if (instance->octree_id) {
instance->scenario->octree.erase(instance->octree_id); //make dependencies generated by the octree go away
- instance->octree_id=0;
+ instance->octree_id = 0;
}
-
- switch(instance->base_type) {
+ switch (instance->base_type) {
case VS::INSTANCE_LIGHT: {
-
- InstanceLightData *light = static_cast<InstanceLightData*>(instance->base_data);
+ InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
if (light->D) {
- instance->scenario->directional_lights.erase( light->D );
- light->D=NULL;
+ instance->scenario->directional_lights.erase(light->D);
+ light->D = NULL;
}
} break;
case VS::INSTANCE_REFLECTION_PROBE: {
- InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData*>(instance->base_data);
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data);
VSG::scene_render->reflection_probe_release_atlas_index(reflection_probe->instance);
} break;
case VS::INSTANCE_GI_PROBE: {
- InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData*>(instance->base_data);
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
if (gi_probe->update_element.in_list()) {
gi_probe_update_list.remove(&gi_probe->update_element);
}
} break;
-
}
- instance->scenario=NULL;
+ instance->scenario = NULL;
}
-
if (p_scenario.is_valid()) {
- Scenario *scenario = scenario_owner.get( p_scenario );
+ Scenario *scenario = scenario_owner.get(p_scenario);
ERR_FAIL_COND(!scenario);
- instance->scenario=scenario;
-
- scenario->instances.add( &instance->scenario_item );
+ instance->scenario = scenario;
+ scenario->instances.add(&instance->scenario_item);
- switch(instance->base_type) {
+ switch (instance->base_type) {
case VS::INSTANCE_LIGHT: {
+ InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
- InstanceLightData *light = static_cast<InstanceLightData*>(instance->base_data);
-
- if (VSG::storage->light_get_type(instance->base)==VS::LIGHT_DIRECTIONAL) {
+ if (VSG::storage->light_get_type(instance->base) == VS::LIGHT_DIRECTIONAL) {
light->D = scenario->directional_lights.push_back(instance);
}
} break;
case VS::INSTANCE_GI_PROBE: {
- InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData*>(instance->base_data);
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
if (!gi_probe->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element);
}
} break;
}
- _instance_queue_update(instance,true,true);
+ _instance_queue_update(instance, true, true);
}
}
-void VisualServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask){
-
+void VisualServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
- instance->layer_mask=p_mask;
+ instance->layer_mask = p_mask;
}
-void VisualServerScene::instance_set_transform(RID p_instance, const Transform& p_transform){
+void VisualServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
- if (instance->transform==p_transform)
+ if (instance->transform == p_transform)
return; //must be checked to avoid worst evil
- instance->transform=p_transform;
- _instance_queue_update(instance,true);
+ instance->transform = p_transform;
+ _instance_queue_update(instance, true);
}
-void VisualServerScene::instance_attach_object_instance_ID(RID p_instance,ObjectID p_ID){
+void VisualServerScene::instance_attach_object_instance_ID(RID p_instance, ObjectID p_ID) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
-
- instance->object_ID=p_ID;
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
+ instance->object_ID = p_ID;
}
-void VisualServerScene::instance_set_blend_shape_weight(RID p_instance,int p_shape, float p_weight){
+void VisualServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
if (instance->update_item.in_list()) {
_update_dirty_instance(instance);
}
- ERR_FAIL_INDEX(p_shape,instance->blend_values.size());
- instance->blend_values[p_shape]=p_weight;
+ ERR_FAIL_INDEX(p_shape, instance->blend_values.size());
+ instance->blend_values[p_shape] = p_weight;
}
-void VisualServerScene::instance_set_surface_material(RID p_instance,int p_surface, RID p_material){
+void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
if (instance->update_item.in_list()) {
_update_dirty_instance(instance);
}
- ERR_FAIL_INDEX(p_surface,instance->materials.size());
+ ERR_FAIL_INDEX(p_surface, instance->materials.size());
if (instance->materials[p_surface].is_valid()) {
- VSG::storage->material_remove_instance_owner(instance->materials[p_surface],instance);
+ VSG::storage->material_remove_instance_owner(instance->materials[p_surface], instance);
}
- instance->materials[p_surface]=p_material;
+ instance->materials[p_surface] = p_material;
instance->base_material_changed();
if (instance->materials[p_surface].is_valid()) {
- VSG::storage->material_add_instance_owner(instance->materials[p_surface],instance);
+ VSG::storage->material_add_instance_owner(instance->materials[p_surface], instance);
}
-
-
}
-void VisualServerScene::instance_set_visible(RID p_instance,bool p_visible) {
+void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
- if (instance->visible==p_visible)
+ if (instance->visible == p_visible)
return;
- instance->visible=p_visible;
-
+ instance->visible = p_visible;
- switch(instance->base_type) {
+ switch (instance->base_type) {
case VS::INSTANCE_LIGHT: {
- if (VSG::storage->light_get_type(instance->base)!=VS::LIGHT_DIRECTIONAL && instance->octree_id && instance->scenario) {
- instance->scenario->octree.set_pairable(instance->octree_id,p_visible,1<<VS::INSTANCE_LIGHT,p_visible?VS::INSTANCE_GEOMETRY_MASK:0);
+ if (VSG::storage->light_get_type(instance->base) != VS::LIGHT_DIRECTIONAL && instance->octree_id && instance->scenario) {
+ instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_LIGHT, p_visible ? VS::INSTANCE_GEOMETRY_MASK : 0);
}
} break;
case VS::INSTANCE_REFLECTION_PROBE: {
if (instance->octree_id && instance->scenario) {
- instance->scenario->octree.set_pairable(instance->octree_id,p_visible,1<<VS::INSTANCE_REFLECTION_PROBE,p_visible?VS::INSTANCE_GEOMETRY_MASK:0);
+ instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_REFLECTION_PROBE, p_visible ? VS::INSTANCE_GEOMETRY_MASK : 0);
}
} break;
case VS::INSTANCE_GI_PROBE: {
if (instance->octree_id && instance->scenario) {
- instance->scenario->octree.set_pairable(instance->octree_id,p_visible,1<<VS::INSTANCE_GI_PROBE,p_visible?(VS::INSTANCE_GEOMETRY_MASK|(1<<VS::INSTANCE_LIGHT)):0);
+ instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_GI_PROBE, p_visible ? (VS::INSTANCE_GEOMETRY_MASK | (1 << VS::INSTANCE_LIGHT)) : 0);
}
} break;
-
}
-
}
-void VisualServerScene::instance_attach_skeleton(RID p_instance,RID p_skeleton){
+void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
- if (instance->skeleton==p_skeleton)
+ if (instance->skeleton == p_skeleton)
return;
if (instance->skeleton.is_valid()) {
- VSG::storage->instance_remove_skeleton(p_skeleton,instance);
+ VSG::storage->instance_remove_skeleton(p_skeleton, instance);
}
- instance->skeleton=p_skeleton;
+ instance->skeleton = p_skeleton;
if (instance->skeleton.is_valid()) {
- VSG::storage->instance_add_skeleton(p_skeleton,instance);
+ VSG::storage->instance_add_skeleton(p_skeleton, instance);
}
- _instance_queue_update(instance,true);
+ _instance_queue_update(instance, true);
}
-void VisualServerScene::instance_set_exterior( RID p_instance, bool p_enabled ){
-
+void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) {
}
-void VisualServerScene::instance_set_room( RID p_instance, RID p_room ){
-
+void VisualServerScene::instance_set_room(RID p_instance, RID p_room) {
}
-void VisualServerScene::instance_set_extra_visibility_margin( RID p_instance, real_t p_margin ){
-
+void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
}
-Vector<ObjectID> VisualServerScene::instances_cull_aabb(const Rect3& p_aabb, RID p_scenario) const {
-
+Vector<ObjectID> VisualServerScene::instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario) const {
Vector<ObjectID> instances;
- Scenario *scenario=scenario_owner.get(p_scenario);
- ERR_FAIL_COND_V(!scenario,instances);
+ Scenario *scenario = scenario_owner.get(p_scenario);
+ ERR_FAIL_COND_V(!scenario, instances);
- const_cast<VisualServerScene*>(this)->update_dirty_instances(); // check dirty instances before culling
+ const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
- int culled=0;
+ int culled = 0;
Instance *cull[1024];
- culled=scenario->octree.cull_AABB(p_aabb,cull,1024);
+ culled = scenario->octree.cull_AABB(p_aabb, cull, 1024);
- for (int i=0;i<culled;i++) {
+ for (int i = 0; i < culled; i++) {
- Instance *instance=cull[i];
+ Instance *instance = cull[i];
ERR_CONTINUE(!instance);
- if (instance->object_ID==0)
+ if (instance->object_ID == 0)
continue;
instances.push_back(instance->object_ID);
@@ -986,79 +921,74 @@ Vector<ObjectID> VisualServerScene::instances_cull_aabb(const Rect3& p_aabb, RID
return instances;
}
-Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3& p_from, const Vector3& p_to, RID p_scenario) const{
+Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
Vector<ObjectID> instances;
- Scenario *scenario=scenario_owner.get(p_scenario);
- ERR_FAIL_COND_V(!scenario,instances);
- const_cast<VisualServerScene*>(this)->update_dirty_instances(); // check dirty instances before culling
+ Scenario *scenario = scenario_owner.get(p_scenario);
+ ERR_FAIL_COND_V(!scenario, instances);
+ const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
- int culled=0;
+ int culled = 0;
Instance *cull[1024];
- culled=scenario->octree.cull_segment(p_from,p_to*10000,cull,1024);
-
+ culled = scenario->octree.cull_segment(p_from, p_to * 10000, cull, 1024);
- for (int i=0;i<culled;i++) {
- Instance *instance=cull[i];
+ for (int i = 0; i < culled; i++) {
+ Instance *instance = cull[i];
ERR_CONTINUE(!instance);
- if (instance->object_ID==0)
+ if (instance->object_ID == 0)
continue;
instances.push_back(instance->object_ID);
}
return instances;
-
}
-Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane>& p_convex, RID p_scenario) const{
+Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
Vector<ObjectID> instances;
- Scenario *scenario=scenario_owner.get(p_scenario);
- ERR_FAIL_COND_V(!scenario,instances);
- const_cast<VisualServerScene*>(this)->update_dirty_instances(); // check dirty instances before culling
+ Scenario *scenario = scenario_owner.get(p_scenario);
+ ERR_FAIL_COND_V(!scenario, instances);
+ const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
- int culled=0;
+ int culled = 0;
Instance *cull[1024];
+ culled = scenario->octree.cull_convex(p_convex, cull, 1024);
- culled=scenario->octree.cull_convex(p_convex,cull,1024);
+ for (int i = 0; i < culled; i++) {
- for (int i=0;i<culled;i++) {
-
- Instance *instance=cull[i];
+ Instance *instance = cull[i];
ERR_CONTINUE(!instance);
- if (instance->object_ID==0)
+ if (instance->object_ID == 0)
continue;
instances.push_back(instance->object_ID);
}
return instances;
-
}
-void VisualServerScene::instance_geometry_set_flag(RID p_instance,VS::InstanceFlags p_flags,bool p_enabled){
+void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceFlags p_flags, bool p_enabled) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
- switch(p_flags) {
+ switch (p_flags) {
case VS::INSTANCE_FLAG_BILLBOARD: {
- instance->billboard=p_enabled;
+ instance->billboard = p_enabled;
} break;
case VS::INSTANCE_FLAG_BILLBOARD_FIX_Y: {
- instance->billboard_y=p_enabled;
+ instance->billboard_y = p_enabled;
} break;
case VS::INSTANCE_FLAG_CAST_SHADOW: {
if (p_enabled == true) {
instance->cast_shadows = VS::SHADOW_CASTING_SETTING_ON;
- }
- else {
+ } else {
instance->cast_shadows = VS::SHADOW_CASTING_SETTING_OFF;
}
@@ -1067,69 +997,59 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance,VS::InstanceFl
} break;
case VS::INSTANCE_FLAG_DEPH_SCALE: {
- instance->depth_scale=p_enabled;
+ instance->depth_scale = p_enabled;
} break;
case VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS: {
- instance->visible_in_all_rooms=p_enabled;
+ instance->visible_in_all_rooms = p_enabled;
} break;
-
}
}
void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) {
-
}
-void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material){
+void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
- Instance *instance = instance_owner.get( p_instance );
- ERR_FAIL_COND( !instance );
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
if (instance->material_override.is_valid()) {
- VSG::storage->material_remove_instance_owner(instance->material_override,instance);
+ VSG::storage->material_remove_instance_owner(instance->material_override, instance);
}
- instance->material_override=p_material;
+ instance->material_override = p_material;
instance->base_material_changed();
if (instance->material_override.is_valid()) {
- VSG::storage->material_add_instance_owner(instance->material_override,instance);
+ VSG::storage->material_add_instance_owner(instance->material_override, instance);
}
-
}
-
-void VisualServerScene::instance_geometry_set_draw_range(RID p_instance,float p_min,float p_max,float p_min_margin,float p_max_margin){
-
+void VisualServerScene::instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) {
}
-void VisualServerScene::instance_geometry_set_as_instance_lod(RID p_instance,RID p_as_lod_of_instance){
-
+void VisualServerScene::instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance) {
}
-
void VisualServerScene::_update_instance(Instance *p_instance) {
p_instance->version++;
if (p_instance->base_type == VS::INSTANCE_LIGHT) {
- InstanceLightData *light = static_cast<InstanceLightData*>(p_instance->base_data);
-
- VSG::scene_render->light_instance_set_transform( light->instance, p_instance->transform );
- light->shadow_dirty=true;
+ InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
+ VSG::scene_render->light_instance_set_transform(light->instance, p_instance->transform);
+ light->shadow_dirty = true;
}
if (p_instance->base_type == VS::INSTANCE_REFLECTION_PROBE) {
- InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData*>(p_instance->base_data);
-
- VSG::scene_render->reflection_probe_instance_set_transform( reflection_probe->instance, p_instance->transform );
- reflection_probe->reflection_dirty=true;
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
+ VSG::scene_render->reflection_probe_instance_set_transform(reflection_probe->instance, p_instance->transform);
+ reflection_probe->reflection_dirty = true;
}
-
if (p_instance->aabb.has_no_surface())
return;
@@ -1140,18 +1060,17 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
}
#endif
- if ((1<<p_instance->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
+ if ((1 << p_instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
- InstanceGeometryData *geom = static_cast<InstanceGeometryData*>(p_instance->base_data);
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
//make sure lights are updated if it casts shadow
if (geom->can_cast_shadows) {
- for (List<Instance*>::Element *E=geom->lighting.front();E;E=E->next()) {
- InstanceLightData *light = static_cast<InstanceLightData*>(E->get()->base_data);
- light->shadow_dirty=true;
+ for (List<Instance *>::Element *E = geom->lighting.front(); E; E = E->next()) {
+ InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
+ light->shadow_dirty = true;
}
}
-
}
#if 0
else if (p_instance->base_type == INSTANCE_ROOM) {
@@ -1166,7 +1085,6 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
p_instance->gi_probe_info->affine_inverse=(p_instance->data.transform*scale).affine_inverse();
}
-
#endif
p_instance->mirror = p_instance->transform.basis.determinant() < 0.0;
@@ -1202,37 +1120,34 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
} else {
#endif
- new_aabb = p_instance->transform.xform(p_instance->aabb);
+ new_aabb = p_instance->transform.xform(p_instance->aabb);
#if 0
}
#endif
-
- p_instance->transformed_aabb=new_aabb;
+ p_instance->transformed_aabb = new_aabb;
if (!p_instance->scenario) {
return;
}
+ if (p_instance->octree_id == 0) {
+ uint32_t base_type = 1 << p_instance->base_type;
+ uint32_t pairable_mask = 0;
+ bool pairable = false;
- if (p_instance->octree_id==0) {
-
- uint32_t base_type = 1<<p_instance->base_type;
- uint32_t pairable_mask=0;
- bool pairable=false;
+ if (p_instance->base_type == VS::INSTANCE_LIGHT || p_instance->base_type == VS::INSTANCE_REFLECTION_PROBE) {
- if (p_instance->base_type == VS::INSTANCE_LIGHT || p_instance->base_type==VS::INSTANCE_REFLECTION_PROBE) {
-
- pairable_mask=p_instance->visible?VS::INSTANCE_GEOMETRY_MASK:0;
- pairable=true;
+ pairable_mask = p_instance->visible ? VS::INSTANCE_GEOMETRY_MASK : 0;
+ pairable = true;
}
if (p_instance->base_type == VS::INSTANCE_GI_PROBE) {
//lights and geometries
- pairable_mask=p_instance->visible?VS::INSTANCE_GEOMETRY_MASK|(1<<VS::INSTANCE_LIGHT):0;
- pairable=true;
+ pairable_mask = p_instance->visible ? VS::INSTANCE_GEOMETRY_MASK | (1 << VS::INSTANCE_LIGHT) : 0;
+ pairable = true;
}
#if 0
@@ -1263,7 +1178,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
#endif
// not inside octree
- p_instance->octree_id = p_instance->scenario->octree.create(p_instance,new_aabb,0,pairable,base_type,pairable_mask);
+ p_instance->octree_id = p_instance->scenario->octree.create(p_instance, new_aabb, 0, pairable, base_type, pairable_mask);
} else {
@@ -1272,7 +1187,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
return;
*/
- p_instance->scenario->octree.move(p_instance->octree_id,new_aabb);
+ p_instance->scenario->octree.move(p_instance->octree_id, new_aabb);
}
#if 0
if (p_instance->base_type==INSTANCE_PORTAL) {
@@ -1291,23 +1206,22 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
_instance_validate_autorooms(E->get());
}
#endif
-
}
void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
Rect3 new_aabb;
- ERR_FAIL_COND(p_instance->base_type!=VS::INSTANCE_NONE && !p_instance->base.is_valid());
+ ERR_FAIL_COND(p_instance->base_type != VS::INSTANCE_NONE && !p_instance->base.is_valid());
- switch(p_instance->base_type) {
+ switch (p_instance->base_type) {
case VisualServer::INSTANCE_NONE: {
// do nothing
} break;
case VisualServer::INSTANCE_MESH: {
- new_aabb = VSG::storage->mesh_get_aabb(p_instance->base,p_instance->skeleton);
+ new_aabb = VSG::storage->mesh_get_aabb(p_instance->base, p_instance->skeleton);
} break;
@@ -1320,7 +1234,6 @@ void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
new_aabb = VSG::storage->immediate_get_aabb(p_instance->base);
-
} break;
#if 0
@@ -1396,164 +1309,147 @@ void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
if (p_instance->extra_margin)
new_aabb.grow_by(p_instance->extra_margin);
- p_instance->aabb=new_aabb;
-
+ p_instance->aabb = new_aabb;
}
+void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario) {
+ InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
-
-
-void VisualServerScene::_light_instance_update_shadow(Instance *p_instance,const Transform p_cam_transform,const CameraMatrix& p_cam_projection,bool p_cam_orthogonal,RID p_shadow_atlas,Scenario* p_scenario) {
-
-
- InstanceLightData * light = static_cast<InstanceLightData*>(p_instance->base_data);
-
- switch(VSG::storage->light_get_type(p_instance->base)) {
+ switch (VSG::storage->light_get_type(p_instance->base)) {
case VS::LIGHT_DIRECTIONAL: {
- float max_distance =p_cam_projection.get_z_far();
- float shadow_max = VSG::storage->light_get_param(p_instance->base,VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE);
- if (shadow_max>0) {
- max_distance=MIN(shadow_max,max_distance);
+ float max_distance = p_cam_projection.get_z_far();
+ float shadow_max = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE);
+ if (shadow_max > 0) {
+ max_distance = MIN(shadow_max, max_distance);
}
- max_distance=MAX(max_distance,p_cam_projection.get_z_near()+0.001);
+ max_distance = MAX(max_distance, p_cam_projection.get_z_near() + 0.001);
- float range = max_distance-p_cam_projection.get_z_near();
+ float range = max_distance - p_cam_projection.get_z_near();
- int splits=0;
- switch(VSG::storage->light_directional_get_shadow_mode(p_instance->base)) {
- case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: splits=1; break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: splits=2; break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: splits=4; break;
+ int splits = 0;
+ switch (VSG::storage->light_directional_get_shadow_mode(p_instance->base)) {
+ case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: splits = 1; break;
+ case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: splits = 2; break;
+ case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: splits = 4; break;
}
float distances[5];
- distances[0]=p_cam_projection.get_z_near();
- for(int i=0;i<splits;i++) {
- distances[i+1]=p_cam_projection.get_z_near()+VSG::storage->light_get_param(p_instance->base,VS::LightParam(VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET+i))*range;
+ distances[0] = p_cam_projection.get_z_near();
+ for (int i = 0; i < splits; i++) {
+ distances[i + 1] = p_cam_projection.get_z_near() + VSG::storage->light_get_param(p_instance->base, VS::LightParam(VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET + i)) * range;
};
- distances[splits]=max_distance;
+ distances[splits] = max_distance;
- float texture_size=VSG::scene_render->get_directional_light_shadow_size(light->instance);
+ float texture_size = VSG::scene_render->get_directional_light_shadow_size(light->instance);
bool overlap = VSG::storage->light_directional_get_blend_splits(p_instance->base);
- for (int i=0;i<splits;i++) {
+ for (int i = 0; i < splits; i++) {
// setup a camera matrix for that range!
CameraMatrix camera_matrix;
float aspect = p_cam_projection.get_aspect();
-
if (p_cam_orthogonal) {
- float w,h;
- p_cam_projection.get_viewport_size(w,h);
- camera_matrix.set_orthogonal(w,aspect,distances[(i==0 || !overlap )?i:i-1],distances[i+1],false);
+ float w, h;
+ p_cam_projection.get_viewport_size(w, h);
+ camera_matrix.set_orthogonal(w, aspect, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], false);
} else {
float fov = p_cam_projection.get_fov();
- camera_matrix.set_perspective(fov,aspect,distances[(i==0 || !overlap )?i:i-1],distances[i+1],false);
+ camera_matrix.set_perspective(fov, aspect, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], false);
}
//obtain the frustum endpoints
Vector3 endpoints[8]; // frustum plane endpoints
- bool res = camera_matrix.get_endpoints(p_cam_transform,endpoints);
+ bool res = camera_matrix.get_endpoints(p_cam_transform, endpoints);
ERR_CONTINUE(!res);
// obtain the light frustm ranges (given endpoints)
- Vector3 x_vec=p_instance->transform.basis.get_axis( Vector3::AXIS_X ).normalized();
- Vector3 y_vec=p_instance->transform.basis.get_axis( Vector3::AXIS_Y ).normalized();
- Vector3 z_vec=p_instance->transform.basis.get_axis( Vector3::AXIS_Z ).normalized();
+ Vector3 x_vec = p_instance->transform.basis.get_axis(Vector3::AXIS_X).normalized();
+ Vector3 y_vec = p_instance->transform.basis.get_axis(Vector3::AXIS_Y).normalized();
+ Vector3 z_vec = p_instance->transform.basis.get_axis(Vector3::AXIS_Z).normalized();
//z_vec points agsint the camera, like in default opengl
- float x_min,x_max;
- float y_min,y_max;
- float z_min,z_max;
-
- float x_min_cam,x_max_cam;
- float y_min_cam,y_max_cam;
- float z_min_cam,z_max_cam;
+ float x_min, x_max;
+ float y_min, y_max;
+ float z_min, z_max;
+ float x_min_cam, x_max_cam;
+ float y_min_cam, y_max_cam;
+ float z_min_cam, z_max_cam;
//used for culling
- for(int j=0;j<8;j++) {
-
- float d_x=x_vec.dot(endpoints[j]);
- float d_y=y_vec.dot(endpoints[j]);
- float d_z=z_vec.dot(endpoints[j]);
-
- if (j==0 || d_x<x_min)
- x_min=d_x;
- if (j==0 || d_x>x_max)
- x_max=d_x;
-
- if (j==0 || d_y<y_min)
- y_min=d_y;
- if (j==0 || d_y>y_max)
- y_max=d_y;
-
- if (j==0 || d_z<z_min)
- z_min=d_z;
- if (j==0 || d_z>z_max)
- z_max=d_z;
-
-
+ for (int j = 0; j < 8; j++) {
+
+ float d_x = x_vec.dot(endpoints[j]);
+ float d_y = y_vec.dot(endpoints[j]);
+ float d_z = z_vec.dot(endpoints[j]);
+
+ if (j == 0 || d_x < x_min)
+ x_min = d_x;
+ if (j == 0 || d_x > x_max)
+ x_max = d_x;
+
+ if (j == 0 || d_y < y_min)
+ y_min = d_y;
+ if (j == 0 || d_y > y_max)
+ y_max = d_y;
+
+ if (j == 0 || d_z < z_min)
+ z_min = d_z;
+ if (j == 0 || d_z > z_max)
+ z_max = d_z;
}
-
-
-
-
{
//camera viewport stuff
//this trick here is what stabilizes the shadow (make potential jaggies to not move)
//at the cost of some wasted resolution. Still the quality increase is very well worth it
-
Vector3 center;
- for(int j=0;j<8;j++) {
+ for (int j = 0; j < 8; j++) {
- center+=endpoints[j];
+ center += endpoints[j];
}
- center/=8.0;
+ center /= 8.0;
//center=x_vec*(x_max-x_min)*0.5 + y_vec*(y_max-y_min)*0.5 + z_vec*(z_max-z_min)*0.5;
- float radius=0;
+ float radius = 0;
- for(int j=0;j<8;j++) {
+ for (int j = 0; j < 8; j++) {
float d = center.distance_to(endpoints[j]);
- if (d>radius)
- radius=d;
+ if (d > radius)
+ radius = d;
}
+ radius *= texture_size / (texture_size - 2.0); //add a texel by each side, so stepified texture will always fit
- radius *= texture_size/(texture_size-2.0); //add a texel by each side, so stepified texture will always fit
-
- x_max_cam=x_vec.dot(center)+radius;
- x_min_cam=x_vec.dot(center)-radius;
- y_max_cam=y_vec.dot(center)+radius;
- y_min_cam=y_vec.dot(center)-radius;
- z_max_cam=z_vec.dot(center)+radius;
- z_min_cam=z_vec.dot(center)-radius;
-
- float unit = radius*2.0/texture_size;
+ x_max_cam = x_vec.dot(center) + radius;
+ x_min_cam = x_vec.dot(center) - radius;
+ y_max_cam = y_vec.dot(center) + radius;
+ y_min_cam = y_vec.dot(center) - radius;
+ z_max_cam = z_vec.dot(center) + radius;
+ z_min_cam = z_vec.dot(center) - radius;
- x_max_cam=Math::stepify(x_max_cam,unit);
- x_min_cam=Math::stepify(x_min_cam,unit);
- y_max_cam=Math::stepify(y_max_cam,unit);
- y_min_cam=Math::stepify(y_min_cam,unit);
+ float unit = radius * 2.0 / texture_size;
+ x_max_cam = Math::stepify(x_max_cam, unit);
+ x_min_cam = Math::stepify(x_min_cam, unit);
+ y_max_cam = Math::stepify(y_max_cam, unit);
+ y_min_cam = Math::stepify(y_min_cam, unit);
}
//now that we now all ranges, we can proceed to make the light frustum planes, for culling octree
@@ -1562,57 +1458,50 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance,const
light_frustum_planes.resize(6);
//right/left
- light_frustum_planes[0]=Plane( x_vec, x_max );
- light_frustum_planes[1]=Plane( -x_vec, -x_min );
+ light_frustum_planes[0] = Plane(x_vec, x_max);
+ light_frustum_planes[1] = Plane(-x_vec, -x_min);
//top/bottom
- light_frustum_planes[2]=Plane( y_vec, y_max );
- light_frustum_planes[3]=Plane( -y_vec, -y_min );
+ light_frustum_planes[2] = Plane(y_vec, y_max);
+ light_frustum_planes[3] = Plane(-y_vec, -y_min);
//near/far
- light_frustum_planes[4]=Plane( z_vec, z_max+1e6 );
- light_frustum_planes[5]=Plane( -z_vec, -z_min ); // z_min is ok, since casters further than far-light plane are not needed
+ light_frustum_planes[4] = Plane(z_vec, z_max + 1e6);
+ light_frustum_planes[5] = Plane(-z_vec, -z_min); // z_min is ok, since casters further than far-light plane are not needed
- int cull_count = p_scenario->octree.cull_convex(light_frustum_planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(light_frustum_planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
// a pre pass will need to be needed to determine the actual z-near to be used
+ for (int j = 0; j < cull_count; j++) {
- for (int j=0;j<cull_count;j++) {
-
- float min,max;
+ float min, max;
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !((1<<instance->base_type)&VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData*>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
- SWAP(instance_shadow_cull_result[j],instance_shadow_cull_result[cull_count]);
+ SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
continue;
-
}
-
- instance->transformed_aabb.project_range_in_plane(Plane(z_vec,0),min,max);
- if (max>z_max)
- z_max=max;
+ instance->transformed_aabb.project_range_in_plane(Plane(z_vec, 0), min, max);
+ if (max > z_max)
+ z_max = max;
}
{
CameraMatrix ortho_camera;
- real_t half_x = (x_max_cam-x_min_cam) * 0.5;
- real_t half_y = (y_max_cam-y_min_cam) * 0.5;
-
+ real_t half_x = (x_max_cam - x_min_cam) * 0.5;
+ real_t half_y = (y_max_cam - y_min_cam) * 0.5;
- ortho_camera.set_orthogonal( -half_x, half_x,-half_y,half_y, 0, (z_max-z_min_cam) );
+ ortho_camera.set_orthogonal(-half_x, half_x, -half_y, half_y, 0, (z_max - z_min_cam));
Transform ortho_transform;
- ortho_transform.basis=p_instance->transform.basis;
- ortho_transform.origin=x_vec*(x_min_cam+half_x)+y_vec*(y_min_cam+half_y)+z_vec*z_max;
+ ortho_transform.basis = p_instance->transform.basis;
+ ortho_transform.origin = x_vec * (x_min_cam + half_x) + y_vec * (y_min_cam + half_y) + z_vec * z_max;
- VSG::scene_render->light_instance_set_shadow_transform(light->instance,ortho_camera,ortho_transform,0,distances[i+1],i);
+ VSG::scene_render->light_instance_set_shadow_transform(light->instance, ortho_camera, ortho_transform, 0, distances[i + 1], i);
}
-
-
- VSG::scene_render->render_shadow(light->instance,p_shadow_atlas,i,(RasterizerScene::InstanceBase**)instance_shadow_cull_result,cull_count);
-
+ VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
}
} break;
@@ -1620,205 +1509,185 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance,const
VS::LightOmniShadowMode shadow_mode = VSG::storage->light_omni_get_shadow_mode(p_instance->base);
- switch(shadow_mode) {
+ switch (shadow_mode) {
case VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID: {
- for(int i=0;i<2;i++) {
+ for (int i = 0; i < 2; i++) {
//using this one ensures that raster deferred will have it
- float radius = VSG::storage->light_get_param( p_instance->base, VS::LIGHT_PARAM_RANGE);
+ float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE);
- float z =i==0?-1:1;
+ float z = i == 0 ? -1 : 1;
Vector<Plane> planes;
planes.resize(5);
- planes[0]=p_instance->transform.xform(Plane(Vector3(0,0,z),radius));
- planes[1]=p_instance->transform.xform(Plane(Vector3(1,0,z).normalized(),radius));
- planes[2]=p_instance->transform.xform(Plane(Vector3(-1,0,z).normalized(),radius));
- planes[3]=p_instance->transform.xform(Plane(Vector3(0,1,z).normalized(),radius));
- planes[4]=p_instance->transform.xform(Plane(Vector3(0,-1,z).normalized(),radius));
-
+ planes[0] = p_instance->transform.xform(Plane(Vector3(0, 0, z), radius));
+ planes[1] = p_instance->transform.xform(Plane(Vector3(1, 0, z).normalized(), radius));
+ planes[2] = p_instance->transform.xform(Plane(Vector3(-1, 0, z).normalized(), radius));
+ planes[3] = p_instance->transform.xform(Plane(Vector3(0, 1, z).normalized(), radius));
+ planes[4] = p_instance->transform.xform(Plane(Vector3(0, -1, z).normalized(), radius));
- int cull_count = p_scenario->octree.cull_convex(planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
- for (int j=0;j<cull_count;j++) {
+ for (int j = 0; j < cull_count; j++) {
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !((1<<instance->base_type)&VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData*>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
- SWAP(instance_shadow_cull_result[j],instance_shadow_cull_result[cull_count]);
+ SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
-
}
}
- VSG::scene_render->light_instance_set_shadow_transform(light->instance,CameraMatrix(),p_instance->transform,radius,0,i);
- VSG::scene_render->render_shadow(light->instance,p_shadow_atlas,i,(RasterizerScene::InstanceBase**)instance_shadow_cull_result,cull_count);
+ VSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), p_instance->transform, radius, 0, i);
+ VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
}
} break;
case VS::LIGHT_OMNI_SHADOW_CUBE: {
- float radius = VSG::storage->light_get_param( p_instance->base, VS::LIGHT_PARAM_RANGE);
+ float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE);
CameraMatrix cm;
- cm.set_perspective(90,1,0.01,radius);
+ cm.set_perspective(90, 1, 0.01, radius);
- for(int i=0;i<6;i++) {
+ for (int i = 0; i < 6; i++) {
//using this one ensures that raster deferred will have it
-
-
- static const Vector3 view_normals[6]={
+ static const Vector3 view_normals[6] = {
Vector3(-1, 0, 0),
Vector3(+1, 0, 0),
- Vector3( 0,-1, 0),
- Vector3( 0,+1, 0),
- Vector3( 0, 0,-1),
- Vector3( 0, 0,+1)
+ Vector3(0, -1, 0),
+ Vector3(0, +1, 0),
+ Vector3(0, 0, -1),
+ Vector3(0, 0, +1)
};
- static const Vector3 view_up[6]={
- Vector3( 0,-1, 0),
- Vector3( 0,-1, 0),
- Vector3( 0, 0,-1),
- Vector3( 0, 0,+1),
- Vector3( 0,-1, 0),
- Vector3( 0,-1, 0)
+ static const Vector3 view_up[6] = {
+ Vector3(0, -1, 0),
+ Vector3(0, -1, 0),
+ Vector3(0, 0, -1),
+ Vector3(0, 0, +1),
+ Vector3(0, -1, 0),
+ Vector3(0, -1, 0)
};
- Transform xform = p_instance->transform * Transform().looking_at(view_normals[i],view_up[i]);
-
+ Transform xform = p_instance->transform * Transform().looking_at(view_normals[i], view_up[i]);
Vector<Plane> planes = cm.get_projection_planes(xform);
- int cull_count = p_scenario->octree.cull_convex(planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
- for (int j=0;j<cull_count;j++) {
+ for (int j = 0; j < cull_count; j++) {
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !((1<<instance->base_type)&VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData*>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
- SWAP(instance_shadow_cull_result[j],instance_shadow_cull_result[cull_count]);
+ SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
-
}
}
-
- VSG::scene_render->light_instance_set_shadow_transform(light->instance,cm,xform,radius,0,i);
- VSG::scene_render->render_shadow(light->instance,p_shadow_atlas,i,(RasterizerScene::InstanceBase**)instance_shadow_cull_result,cull_count);
+ VSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, xform, radius, 0, i);
+ VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
}
//restore the regular DP matrix
- VSG::scene_render->light_instance_set_shadow_transform(light->instance,CameraMatrix(),p_instance->transform,radius,0,0);
+ VSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), p_instance->transform, radius, 0, 0);
} break;
}
-
} break;
case VS::LIGHT_SPOT: {
-
- float radius = VSG::storage->light_get_param( p_instance->base, VS::LIGHT_PARAM_RANGE);
- float angle = VSG::storage->light_get_param( p_instance->base, VS::LIGHT_PARAM_SPOT_ANGLE);
+ float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE);
+ float angle = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_SPOT_ANGLE);
CameraMatrix cm;
- cm.set_perspective( angle*2.0, 1.0, 0.01, radius );
-
+ cm.set_perspective(angle * 2.0, 1.0, 0.01, radius);
Vector<Plane> planes = cm.get_projection_planes(p_instance->transform);
- int cull_count = p_scenario->octree.cull_convex(planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
- for (int j=0;j<cull_count;j++) {
+ for (int j = 0; j < cull_count; j++) {
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !((1<<instance->base_type)&VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData*>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
- SWAP(instance_shadow_cull_result[j],instance_shadow_cull_result[cull_count]);
+ SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
-
}
}
-
- VSG::scene_render->light_instance_set_shadow_transform(light->instance,cm,p_instance->transform,radius,0,0);
- VSG::scene_render->render_shadow(light->instance,p_shadow_atlas,0,(RasterizerScene::InstanceBase**)instance_shadow_cull_result,cull_count);
+ VSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, p_instance->transform, radius, 0, 0);
+ VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, 0, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
} break;
}
-
}
-
-void VisualServerScene::render_camera(RID p_camera, RID p_scenario,Size2 p_viewport_size,RID p_shadow_atlas) {
+void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
/* STEP 1 - SETUP CAMERA */
CameraMatrix camera_matrix;
- bool ortho=false;
+ bool ortho = false;
-
- switch(camera->type) {
+ switch (camera->type) {
case Camera::ORTHOGONAL: {
camera_matrix.set_orthogonal(
- camera->size,
- p_viewport_size.width / (float)p_viewport_size.height,
- camera->znear,
- camera->zfar,
- camera->vaspect
-
- );
- ortho=true;
+ camera->size,
+ p_viewport_size.width / (float)p_viewport_size.height,
+ camera->znear,
+ camera->zfar,
+ camera->vaspect
+
+ );
+ ortho = true;
} break;
case Camera::PERSPECTIVE: {
camera_matrix.set_perspective(
- camera->fov,
- p_viewport_size.width / (float)p_viewport_size.height,
- camera->znear,
- camera->zfar,
- camera->vaspect
+ camera->fov,
+ p_viewport_size.width / (float)p_viewport_size.height,
+ camera->znear,
+ camera->zfar,
+ camera->vaspect
- );
- ortho=false;
+ );
+ ortho = false;
} break;
}
- _render_scene(camera->transform,camera_matrix,ortho,camera->env,camera->visible_layers,p_scenario,p_shadow_atlas,RID(),-1);
-
+ _render_scene(camera->transform, camera_matrix, ortho, camera->env, camera->visible_layers, p_scenario, p_shadow_atlas, RID(), -1);
}
-
-void VisualServerScene::_render_scene(const Transform p_cam_transform,const CameraMatrix& p_cam_projection,bool p_cam_orthogonal,RID p_force_environment,uint32_t p_visible_layers, RID p_scenario,RID p_shadow_atlas,RID p_reflection_probe,int p_reflection_probe_pass) {
-
-
+void VisualServerScene::_render_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
Scenario *scenario = scenario_owner.getornull(p_scenario);
render_pass++;
- uint32_t camera_layer_mask=p_visible_layers;
+ uint32_t camera_layer_mask = p_visible_layers;
VSG::scene_render->set_scene_pass(render_pass);
-
//rasterizer->set_camera(camera->transform, camera_matrix,ortho);
Vector<Plane> planes = p_cam_projection.get_projection_planes(p_cam_transform);
- Plane near_plane(p_cam_transform.origin,-p_cam_transform.basis.get_axis(2).normalized());
+ Plane near_plane(p_cam_transform.origin, -p_cam_transform.basis.get_axis(2).normalized());
float z_far = p_cam_projection.get_z_far();
/* STEP 2 - CULL */
- int cull_count = scenario->octree.cull_convex(planes,instance_cull_result,MAX_INSTANCE_CULL);
- light_cull_count=0;
+ int cull_count = scenario->octree.cull_convex(planes, instance_cull_result, MAX_INSTANCE_CULL);
+ light_cull_count = 0;
- reflection_probe_cull_count=0;
+ reflection_probe_cull_count = 0;
- //light_samplers_culled=0;
+//light_samplers_culled=0;
/* print_line("OT: "+rtos( (OS::get_singleton()->get_ticks_usec()-t)/1000.0));
print_line("OTO: "+itos(p_scenario->octree.get_octant_count()));
@@ -1826,10 +1695,9 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
print_line("OTP: "+itos(p_scenario->octree.get_pair_count()));
*/
- /* STEP 3 - PROCESS PORTALS, VALIDATE ROOMS */
+/* STEP 3 - PROCESS PORTALS, VALIDATE ROOMS */
-
- // compute portals
+// compute portals
#if 0
exterior_visited=false;
exterior_portal_cull_count=0;
@@ -1913,43 +1781,39 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
#endif
/* STEP 4 - REMOVE FURTHER CULLED OBJECTS, ADD LIGHTS */
- for(int i=0;i<cull_count;i++) {
+ for (int i = 0; i < cull_count; i++) {
Instance *ins = instance_cull_result[i];
- bool keep=false;
+ bool keep = false;
- if ((camera_layer_mask&ins->layer_mask)==0) {
+ if ((camera_layer_mask & ins->layer_mask) == 0) {
//failure
- } else if (ins->base_type==VS::INSTANCE_LIGHT && ins->visible) {
-
+ } else if (ins->base_type == VS::INSTANCE_LIGHT && ins->visible) {
- if (ins->visible && light_cull_count<MAX_LIGHTS_CULLED) {
+ if (ins->visible && light_cull_count < MAX_LIGHTS_CULLED) {
- InstanceLightData * light = static_cast<InstanceLightData*>(ins->base_data);
+ InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
if (!light->geometries.empty()) {
//do not add this light if no geometry is affected by it..
- light_cull_result[light_cull_count]=ins;
- light_instance_cull_result[light_cull_count]=light->instance;
+ light_cull_result[light_cull_count] = ins;
+ light_instance_cull_result[light_cull_count] = light->instance;
if (p_shadow_atlas.is_valid() && VSG::storage->light_has_shadow(ins->base)) {
VSG::scene_render->light_instance_mark_visible(light->instance); //mark it visible for shadow allocation later
}
light_cull_count++;
}
-
-
}
- } else if (ins->base_type==VS::INSTANCE_REFLECTION_PROBE && ins->visible) {
+ } else if (ins->base_type == VS::INSTANCE_REFLECTION_PROBE && ins->visible) {
+ if (ins->visible && reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {
- if (ins->visible && reflection_probe_cull_count<MAX_REFLECTION_PROBES_CULLED) {
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(ins->base_data);
- InstanceReflectionProbeData * reflection_probe = static_cast<InstanceReflectionProbeData*>(ins->base_data);
-
- if (p_reflection_probe!=reflection_probe->instance) {
+ if (p_reflection_probe != reflection_probe->instance) {
//avoid entering The Matrix
if (!reflection_probe->geometries.empty()) {
@@ -1957,32 +1821,31 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
if (reflection_probe->reflection_dirty || VSG::scene_render->reflection_probe_instance_needs_redraw(reflection_probe->instance)) {
if (!reflection_probe->update_list.in_list()) {
- reflection_probe->render_step=0;
+ reflection_probe->render_step = 0;
reflection_probe_render_list.add(&reflection_probe->update_list);
}
- reflection_probe->reflection_dirty=false;
+ reflection_probe->reflection_dirty = false;
}
if (VSG::scene_render->reflection_probe_instance_has_reflection(reflection_probe->instance)) {
- reflection_probe_instance_cull_result[reflection_probe_cull_count]=reflection_probe->instance;
+ reflection_probe_instance_cull_result[reflection_probe_cull_count] = reflection_probe->instance;
reflection_probe_cull_count++;
}
-
}
}
}
- } else if (ins->base_type==VS::INSTANCE_GI_PROBE && ins->visible) {
+ } else if (ins->base_type == VS::INSTANCE_GI_PROBE && ins->visible) {
- InstanceGIProbeData * gi_probe = static_cast<InstanceGIProbeData*>(ins->base_data);
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(ins->base_data);
if (!gi_probe->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element);
}
- } else if ((1<<ins->base_type)&VS::INSTANCE_GEOMETRY_MASK && ins->visible && ins->cast_shadows!=VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
+ } else if ((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
- keep=true;
+ keep = true;
#if 0
bool discarded=false;
@@ -2049,230 +1912,207 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
}
#endif
-
- InstanceGeometryData * geom = static_cast<InstanceGeometryData*>(ins->base_data);
-
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data);
if (geom->lighting_dirty) {
- int l=0;
+ int l = 0;
//only called when lights AABB enter/exit this geometry
ins->light_instances.resize(geom->lighting.size());
- for (List<Instance*>::Element *E=geom->lighting.front();E;E=E->next()) {
+ for (List<Instance *>::Element *E = geom->lighting.front(); E; E = E->next()) {
- InstanceLightData * light = static_cast<InstanceLightData*>(E->get()->base_data);
+ InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
- ins->light_instances[l++]=light->instance;
+ ins->light_instances[l++] = light->instance;
}
- geom->lighting_dirty=false;
+ geom->lighting_dirty = false;
}
if (geom->reflection_dirty) {
- int l=0;
+ int l = 0;
//only called when reflection probe AABB enter/exit this geometry
ins->reflection_probe_instances.resize(geom->reflection_probes.size());
- for (List<Instance*>::Element *E=geom->reflection_probes.front();E;E=E->next()) {
+ for (List<Instance *>::Element *E = geom->reflection_probes.front(); E; E = E->next()) {
- InstanceReflectionProbeData * reflection_probe = static_cast<InstanceReflectionProbeData*>(E->get()->base_data);
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(E->get()->base_data);
- ins->reflection_probe_instances[l++]=reflection_probe->instance;
+ ins->reflection_probe_instances[l++] = reflection_probe->instance;
}
- geom->reflection_dirty=false;
+ geom->reflection_dirty = false;
}
if (geom->gi_probes_dirty) {
- int l=0;
+ int l = 0;
//only called when reflection probe AABB enter/exit this geometry
ins->gi_probe_instances.resize(geom->gi_probes.size());
- for (List<Instance*>::Element *E=geom->gi_probes.front();E;E=E->next()) {
+ for (List<Instance *>::Element *E = geom->gi_probes.front(); E; E = E->next()) {
- InstanceGIProbeData * gi_probe = static_cast<InstanceGIProbeData*>(E->get()->base_data);
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(E->get()->base_data);
- ins->gi_probe_instances[l++]=gi_probe->probe_instance;
+ ins->gi_probe_instances[l++] = gi_probe->probe_instance;
}
- geom->gi_probes_dirty=false;
+ geom->gi_probes_dirty = false;
}
ins->depth = near_plane.distance_to(ins->transform.origin);
- ins->depth_layer=CLAMP(int(ins->depth*8/z_far),0,7);
-
+ ins->depth_layer = CLAMP(int(ins->depth * 8 / z_far), 0, 7);
}
if (!keep) {
// remove, no reason to keep
cull_count--;
- SWAP( instance_cull_result[i], instance_cull_result[ cull_count ] );
+ SWAP(instance_cull_result[i], instance_cull_result[cull_count]);
i--;
- ins->last_render_pass=0; // make invalid
+ ins->last_render_pass = 0; // make invalid
} else {
- ins->last_render_pass=render_pass;
+ ins->last_render_pass = render_pass;
}
}
/* STEP 5 - PROCESS LIGHTS */
- RID *directional_light_ptr=&light_instance_cull_result[light_cull_count];
- int directional_light_count=0;
+ RID *directional_light_ptr = &light_instance_cull_result[light_cull_count];
+ int directional_light_count = 0;
// directional lights
{
- Instance** lights_with_shadow = (Instance**)alloca(sizeof(Instance*)*scenario->directional_lights.size());
- int directional_shadow_count=0;
+ Instance **lights_with_shadow = (Instance **)alloca(sizeof(Instance *) * scenario->directional_lights.size());
+ int directional_shadow_count = 0;
- for (List<Instance*>::Element *E=scenario->directional_lights.front();E;E=E->next()) {
+ for (List<Instance *>::Element *E = scenario->directional_lights.front(); E; E = E->next()) {
- if (light_cull_count+directional_light_count>=MAX_LIGHTS_CULLED) {
+ if (light_cull_count + directional_light_count >= MAX_LIGHTS_CULLED) {
break;
}
if (!E->get()->visible)
continue;
- InstanceLightData * light = static_cast<InstanceLightData*>(E->get()->base_data);
-
+ InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
//check shadow..
-
if (light && p_shadow_atlas.is_valid() && VSG::storage->light_has_shadow(E->get()->base)) {
- lights_with_shadow[directional_shadow_count++]=E->get();
-
+ lights_with_shadow[directional_shadow_count++] = E->get();
}
//add to list
- directional_light_ptr[directional_light_count++]=light->instance;
+ directional_light_ptr[directional_light_count++] = light->instance;
}
VSG::scene_render->set_directional_shadow_count(directional_shadow_count);
- for(int i=0;i<directional_shadow_count;i++) {
-
- _light_instance_update_shadow(lights_with_shadow[i],p_cam_transform,p_cam_projection,p_cam_orthogonal,p_shadow_atlas,scenario);
+ for (int i = 0; i < directional_shadow_count; i++) {
+ _light_instance_update_shadow(lights_with_shadow[i], p_cam_transform, p_cam_projection, p_cam_orthogonal, p_shadow_atlas, scenario);
}
}
-
{ //setup shadow maps
//SortArray<Instance*,_InstanceLightsort> sorter;
//sorter.sort(light_cull_result,light_cull_count);
- for (int i=0;i<light_cull_count;i++) {
+ for (int i = 0; i < light_cull_count; i++) {
Instance *ins = light_cull_result[i];
if (!p_shadow_atlas.is_valid() || !VSG::storage->light_has_shadow(ins->base))
continue;
- InstanceLightData * light = static_cast<InstanceLightData*>(ins->base_data);
+ InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
float coverage;
- { //compute coverage
-
+ { //compute coverage
Transform cam_xf = p_cam_transform;
float zn = p_cam_projection.get_z_near();
- Plane p (cam_xf.origin + cam_xf.basis.get_axis(2) * -zn, -cam_xf.basis.get_axis(2) ); //camera near plane
+ Plane p(cam_xf.origin + cam_xf.basis.get_axis(2) * -zn, -cam_xf.basis.get_axis(2)); //camera near plane
- float vp_w,vp_h; //near plane size in screen coordinates
- p_cam_projection.get_viewport_size(vp_w,vp_h);
+ float vp_w, vp_h; //near plane size in screen coordinates
+ p_cam_projection.get_viewport_size(vp_w, vp_h);
-
- switch(VSG::storage->light_get_type(ins->base)) {
+ switch (VSG::storage->light_get_type(ins->base)) {
case VS::LIGHT_OMNI: {
- float radius = VSG::storage->light_get_param(ins->base,VS::LIGHT_PARAM_RANGE);
+ float radius = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_RANGE);
//get two points parallel to near plane
- Vector3 points[2]={
+ Vector3 points[2] = {
ins->transform.origin,
- ins->transform.origin+cam_xf.basis.get_axis(0)*radius
+ ins->transform.origin + cam_xf.basis.get_axis(0) * radius
};
if (!p_cam_orthogonal) {
//if using perspetive, map them to near plane
- for(int j=0;j<2;j++) {
- if (p.distance_to(points[j]) < 0 ) {
- points[j].z=-zn; //small hack to keep size constant when hitting the screen
-
+ for (int j = 0; j < 2; j++) {
+ if (p.distance_to(points[j]) < 0) {
+ points[j].z = -zn; //small hack to keep size constant when hitting the screen
}
- p.intersects_segment(cam_xf.origin,points[j],&points[j]); //map to plane
+ p.intersects_segment(cam_xf.origin, points[j], &points[j]); //map to plane
}
-
-
}
- float screen_diameter = points[0].distance_to(points[1])*2;
- coverage = screen_diameter / (vp_w+vp_h);
+ float screen_diameter = points[0].distance_to(points[1]) * 2;
+ coverage = screen_diameter / (vp_w + vp_h);
} break;
case VS::LIGHT_SPOT: {
- float radius = VSG::storage->light_get_param(ins->base,VS::LIGHT_PARAM_RANGE);
- float angle = VSG::storage->light_get_param(ins->base,VS::LIGHT_PARAM_SPOT_ANGLE);
-
-
- float w = radius*Math::sin(Math::deg2rad(angle));
- float d = radius*Math::cos(Math::deg2rad(angle));
+ float radius = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_RANGE);
+ float angle = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_SPOT_ANGLE);
+ float w = radius * Math::sin(Math::deg2rad(angle));
+ float d = radius * Math::cos(Math::deg2rad(angle));
- Vector3 base = ins->transform.origin-ins->transform.basis.get_axis(2).normalized()*d;
+ Vector3 base = ins->transform.origin - ins->transform.basis.get_axis(2).normalized() * d;
- Vector3 points[2]={
+ Vector3 points[2] = {
base,
- base+cam_xf.basis.get_axis(0)*w
+ base + cam_xf.basis.get_axis(0) * w
};
if (!p_cam_orthogonal) {
//if using perspetive, map them to near plane
- for(int j=0;j<2;j++) {
- if (p.distance_to(points[j]) < 0 ) {
- points[j].z=-zn; //small hack to keep size constant when hitting the screen
-
+ for (int j = 0; j < 2; j++) {
+ if (p.distance_to(points[j]) < 0) {
+ points[j].z = -zn; //small hack to keep size constant when hitting the screen
}
- p.intersects_segment(cam_xf.origin,points[j],&points[j]); //map to plane
+ p.intersects_segment(cam_xf.origin, points[j], &points[j]); //map to plane
}
-
-
}
- float screen_diameter = points[0].distance_to(points[1])*2;
- coverage = screen_diameter / (vp_w+vp_h);
-
+ float screen_diameter = points[0].distance_to(points[1]) * 2;
+ coverage = screen_diameter / (vp_w + vp_h);
} break;
default: {
ERR_PRINT("Invalid Light Type");
}
}
-
}
-
if (light->shadow_dirty) {
light->last_version++;
- light->shadow_dirty=false;
+ light->shadow_dirty = false;
}
-
- bool redraw = VSG::scene_render->shadow_atlas_update_light(p_shadow_atlas,light->instance,coverage,light->last_version);
+ bool redraw = VSG::scene_render->shadow_atlas_update_light(p_shadow_atlas, light->instance, coverage, light->last_version);
if (redraw) {
//must redraw!
- _light_instance_update_shadow(ins,p_cam_transform,p_cam_projection,p_cam_orthogonal,p_shadow_atlas,scenario);
+ _light_instance_update_shadow(ins, p_cam_transform, p_cam_projection, p_cam_orthogonal, p_shadow_atlas, scenario);
}
-
}
}
@@ -2280,11 +2120,11 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
RID environment;
if (p_force_environment.is_valid()) //camera has more environment priority
- environment=p_force_environment;
+ environment = p_force_environment;
else if (scenario->environment.is_valid())
- environment=scenario->environment;
+ environment = scenario->environment;
else
- environment=scenario->fallback_environment;
+ environment = scenario->fallback_environment;
#if 0
/* STEP 6 - SAMPLE BAKED LIGHT */
@@ -2301,62 +2141,57 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
#endif
/* STEP 7 - PROCESS GEOMETRY AND DRAW SCENE*/
- VSG::scene_render->render_scene(p_cam_transform, p_cam_projection,p_cam_orthogonal,(RasterizerScene::InstanceBase**)instance_cull_result,cull_count,light_instance_cull_result,light_cull_count+directional_light_count,reflection_probe_instance_cull_result,reflection_probe_cull_count,environment,p_shadow_atlas,scenario->reflection_atlas,p_reflection_probe,p_reflection_probe_pass);
-
-
+ VSG::scene_render->render_scene(p_cam_transform, p_cam_projection, p_cam_orthogonal, (RasterizerScene::InstanceBase **)instance_cull_result, cull_count, light_instance_cull_result, light_cull_count + directional_light_count, reflection_probe_instance_cull_result, reflection_probe_cull_count, environment, p_shadow_atlas, scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass);
}
-bool VisualServerScene::_render_reflection_probe_step(Instance* p_instance,int p_step) {
+bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int p_step) {
- InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData*>(p_instance->base_data);
+ InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
Scenario *scenario = p_instance->scenario;
- ERR_FAIL_COND_V(!scenario,true);
+ ERR_FAIL_COND_V(!scenario, true);
- if (p_step==0) {
+ if (p_step == 0) {
- if (!VSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance,scenario->reflection_atlas)) {
+ if (!VSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance, scenario->reflection_atlas)) {
return true; //sorry, all full :(
}
}
- if (p_step>=0 && p_step<6) {
+ if (p_step >= 0 && p_step < 6) {
- static const Vector3 view_normals[6]={
+ static const Vector3 view_normals[6] = {
Vector3(-1, 0, 0),
Vector3(+1, 0, 0),
- Vector3( 0,-1, 0),
- Vector3( 0,+1, 0),
- Vector3( 0, 0,-1),
- Vector3( 0, 0,+1)
+ Vector3(0, -1, 0),
+ Vector3(0, +1, 0),
+ Vector3(0, 0, -1),
+ Vector3(0, 0, +1)
};
Vector3 extents = VSG::storage->reflection_probe_get_extents(p_instance->base);
Vector3 origin_offset = VSG::storage->reflection_probe_get_origin_offset(p_instance->base);
float max_distance = VSG::storage->reflection_probe_get_origin_max_distance(p_instance->base);
+ Vector3 edge = view_normals[p_step] * extents;
+ float distance = ABS(view_normals[p_step].dot(edge) - view_normals[p_step].dot(origin_offset)); //distance from origin offset to actual view distance limit
- Vector3 edge = view_normals[p_step]*extents;
- float distance = ABS(view_normals[p_step].dot(edge)-view_normals[p_step].dot(origin_offset)); //distance from origin offset to actual view distance limit
-
- max_distance = MAX(max_distance,distance);
-
+ max_distance = MAX(max_distance, distance);
//render cubemap side
CameraMatrix cm;
- cm.set_perspective(90,1,0.01,max_distance);
-
-
- static const Vector3 view_up[6]={
- Vector3( 0,-1, 0),
- Vector3( 0,-1, 0),
- Vector3( 0, 0,-1),
- Vector3( 0, 0,+1),
- Vector3( 0,-1, 0),
- Vector3( 0,-1, 0)
+ cm.set_perspective(90, 1, 0.01, max_distance);
+
+ static const Vector3 view_up[6] = {
+ Vector3(0, -1, 0),
+ Vector3(0, -1, 0),
+ Vector3(0, 0, -1),
+ Vector3(0, 0, +1),
+ Vector3(0, -1, 0),
+ Vector3(0, -1, 0)
};
Transform local_view;
- local_view.set_look_at(origin_offset,origin_offset+view_normals[p_step],view_up[p_step]);
+ local_view.set_look_at(origin_offset, origin_offset + view_normals[p_step], view_up[p_step]);
Transform xform = p_instance->transform * local_view;
@@ -2364,10 +2199,10 @@ bool VisualServerScene::_render_reflection_probe_step(Instance* p_instance,int p
if (VSG::storage->reflection_probe_renders_shadows(p_instance->base)) {
- shadow_atlas=scenario->reflection_probe_shadow_atlas;
+ shadow_atlas = scenario->reflection_probe_shadow_atlas;
}
- _render_scene(xform,cm,false,RID(),VSG::storage->reflection_probe_get_cull_mask(p_instance->base),p_instance->scenario->self,shadow_atlas,reflection_probe->instance,p_step);
+ _render_scene(xform, cm, false, RID(), VSG::storage->reflection_probe_get_cull_mask(p_instance->base), p_instance->scenario->self, shadow_atlas, reflection_probe->instance, p_step);
} else {
//do roughness postprocess step until it belives it's done
@@ -2377,84 +2212,81 @@ bool VisualServerScene::_render_reflection_probe_step(Instance* p_instance,int p
return false;
}
-void VisualServerScene::_gi_probe_fill_local_data(int p_idx, int p_level, int p_x, int p_y, int p_z, const GIProbeDataCell* p_cell, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, Vector<uint32_t> *prev_cell) {
+void VisualServerScene::_gi_probe_fill_local_data(int p_idx, int p_level, int p_x, int p_y, int p_z, const GIProbeDataCell *p_cell, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, Vector<uint32_t> *prev_cell) {
- if (p_level==p_header->cell_subdiv-1) {
+ if (p_level == p_header->cell_subdiv - 1) {
Vector3 emission;
- emission.x=(p_cell[p_idx].emission>>24)/255.0;
- emission.y=((p_cell[p_idx].emission>>16)&0xFF)/255.0;
- emission.z=((p_cell[p_idx].emission>>8)&0xFF)/255.0;
- float l = (p_cell[p_idx].emission&0xFF)/255.0;
- l*=8.0;
+ emission.x = (p_cell[p_idx].emission >> 24) / 255.0;
+ emission.y = ((p_cell[p_idx].emission >> 16) & 0xFF) / 255.0;
+ emission.z = ((p_cell[p_idx].emission >> 8) & 0xFF) / 255.0;
+ float l = (p_cell[p_idx].emission & 0xFF) / 255.0;
+ l *= 8.0;
- emission*=l;
+ emission *= l;
- p_local_data[p_idx].energy[0]=uint16_t(emission.x*1024); //go from 0 to 1024 for light
- p_local_data[p_idx].energy[1]=uint16_t(emission.y*1024); //go from 0 to 1024 for light
- p_local_data[p_idx].energy[2]=uint16_t(emission.z*1024); //go from 0 to 1024 for light
+ p_local_data[p_idx].energy[0] = uint16_t(emission.x * 1024); //go from 0 to 1024 for light
+ p_local_data[p_idx].energy[1] = uint16_t(emission.y * 1024); //go from 0 to 1024 for light
+ p_local_data[p_idx].energy[2] = uint16_t(emission.z * 1024); //go from 0 to 1024 for light
} else {
- p_local_data[p_idx].energy[0]=0;
- p_local_data[p_idx].energy[1]=0;
- p_local_data[p_idx].energy[2]=0;
+ p_local_data[p_idx].energy[0] = 0;
+ p_local_data[p_idx].energy[1] = 0;
+ p_local_data[p_idx].energy[2] = 0;
- int half=(1<<(p_header->cell_subdiv-1))>>(p_level+1);
+ int half = (1 << (p_header->cell_subdiv - 1)) >> (p_level + 1);
- for(int i=0;i<8;i++) {
+ for (int i = 0; i < 8; i++) {
uint32_t child = p_cell[p_idx].children[i];
- if (child==0xFFFFFFFF)
+ if (child == 0xFFFFFFFF)
continue;
int x = p_x;
int y = p_y;
int z = p_z;
- if (i&1)
- x+=half;
- if (i&2)
- y+=half;
- if (i&4)
- z+=half;
+ if (i & 1)
+ x += half;
+ if (i & 2)
+ y += half;
+ if (i & 4)
+ z += half;
- _gi_probe_fill_local_data(child,p_level+1,x,y,z,p_cell,p_header,p_local_data,prev_cell);
+ _gi_probe_fill_local_data(child, p_level + 1, x, y, z, p_cell, p_header, p_local_data, prev_cell);
}
}
//position for each part of the mipmaped texture
- p_local_data[p_idx].pos[0]=p_x>>(p_header->cell_subdiv-p_level-1);
- p_local_data[p_idx].pos[1]=p_y>>(p_header->cell_subdiv-p_level-1);
- p_local_data[p_idx].pos[2]=p_z>>(p_header->cell_subdiv-p_level-1);
+ p_local_data[p_idx].pos[0] = p_x >> (p_header->cell_subdiv - p_level - 1);
+ p_local_data[p_idx].pos[1] = p_y >> (p_header->cell_subdiv - p_level - 1);
+ p_local_data[p_idx].pos[2] = p_z >> (p_header->cell_subdiv - p_level - 1);
prev_cell[p_level].push_back(p_idx);
-
}
+void VisualServerScene::_gi_probe_bake_threads(void *self) {
-void VisualServerScene::_gi_probe_bake_threads(void* self) {
-
- VisualServerScene* vss = (VisualServerScene*)self;
+ VisualServerScene *vss = (VisualServerScene *)self;
vss->_gi_probe_bake_thread();
}
void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
-
- InstanceGIProbeData *probe = static_cast<InstanceGIProbeData*>(p_instance->base_data);
+ InstanceGIProbeData *probe = static_cast<InstanceGIProbeData *>(p_instance->base_data);
if (probe->dynamic.probe_data.is_valid()) {
VSG::storage->free(probe->dynamic.probe_data);
- probe->dynamic.probe_data=RID();
+ probe->dynamic.probe_data = RID();
}
- probe->dynamic.light_data=VSG::storage->gi_probe_get_dynamic_data(p_instance->base);
+ probe->dynamic.light_data = VSG::storage->gi_probe_get_dynamic_data(p_instance->base);
- if (probe->dynamic.light_data.size()==0)
+ if (probe->dynamic.light_data.size() == 0)
return;
//using dynamic data
- PoolVector<int>::Read r=probe->dynamic.light_data.read();
+ PoolVector<int>::Read r = probe->dynamic.light_data.read();
const GIProbeDataHeader *header = (GIProbeDataHeader *)r.ptr();
@@ -2462,36 +2294,36 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
int cell_count = probe->dynamic.local_data.size();
PoolVector<InstanceGIProbeData::LocalData>::Write ldw = probe->dynamic.local_data.write();
- const GIProbeDataCell *cells = (GIProbeDataCell*)&r[16];
+ const GIProbeDataCell *cells = (GIProbeDataCell *)&r[16];
probe->dynamic.level_cell_lists.resize(header->cell_subdiv);
- _gi_probe_fill_local_data(0,0,0,0,0,cells,header,ldw.ptr(),probe->dynamic.level_cell_lists.ptr());
+ _gi_probe_fill_local_data(0, 0, 0, 0, 0, cells, header, ldw.ptr(), probe->dynamic.level_cell_lists.ptr());
bool compress = VSG::storage->gi_probe_is_compressed(p_instance->base);
probe->dynamic.compression = compress ? VSG::storage->gi_probe_get_dynamic_data_get_preferred_compression() : RasterizerStorage::GI_PROBE_UNCOMPRESSED;
- probe->dynamic.probe_data=VSG::storage->gi_probe_dynamic_data_create(header->width,header->height,header->depth,probe->dynamic.compression);
+ probe->dynamic.probe_data = VSG::storage->gi_probe_dynamic_data_create(header->width, header->height, header->depth, probe->dynamic.compression);
- probe->dynamic.bake_dynamic_range=VSG::storage->gi_probe_get_dynamic_range(p_instance->base);
+ probe->dynamic.bake_dynamic_range = VSG::storage->gi_probe_get_dynamic_range(p_instance->base);
probe->dynamic.mipmaps_3d.clear();
- probe->dynamic.propagate=VSG::storage->gi_probe_get_propagation(p_instance->base);
+ probe->dynamic.propagate = VSG::storage->gi_probe_get_propagation(p_instance->base);
- probe->dynamic.grid_size[0]=header->width;
- probe->dynamic.grid_size[1]=header->height;
- probe->dynamic.grid_size[2]=header->depth;
+ probe->dynamic.grid_size[0] = header->width;
+ probe->dynamic.grid_size[1] = header->height;
+ probe->dynamic.grid_size[2] = header->depth;
int size_limit = 1;
int size_divisor = 1;
- if (probe->dynamic.compression==RasterizerStorage::GI_PROBE_S3TC) {
+ if (probe->dynamic.compression == RasterizerStorage::GI_PROBE_S3TC) {
print_line("S3TC");
- size_limit=4;
- size_divisor=4;
+ size_limit = 4;
+ size_divisor = 4;
}
- for(int i=0;i<(int)header->cell_subdiv;i++) {
+ for (int i = 0; i < (int)header->cell_subdiv; i++) {
uint32_t x = header->width >> i;
uint32_t y = header->height >> i;
@@ -2499,56 +2331,55 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
//create and clear mipmap
PoolVector<uint8_t> mipmap;
- int size = x*y*z*4;
- size/=size_divisor;
+ int size = x * y * z * 4;
+ size /= size_divisor;
mipmap.resize(size);
PoolVector<uint8_t>::Write w = mipmap.write();
- zeromem(w.ptr(),size);
+ zeromem(w.ptr(), size);
w = PoolVector<uint8_t>::Write();
probe->dynamic.mipmaps_3d.push_back(mipmap);
- if (x<=size_limit || y<=size_limit || z<=size_limit)
+ if (x <= size_limit || y <= size_limit || z <= size_limit)
break;
}
- probe->dynamic.updating_stage=GI_UPDATE_STAGE_CHECK;
- probe->invalid=false;
- probe->dynamic.enabled=true;
+ probe->dynamic.updating_stage = GI_UPDATE_STAGE_CHECK;
+ probe->invalid = false;
+ probe->dynamic.enabled = true;
Transform cell_to_xform = VSG::storage->gi_probe_get_to_cell_xform(p_instance->base);
Rect3 bounds = VSG::storage->gi_probe_get_bounds(p_instance->base);
float cell_size = VSG::storage->gi_probe_get_cell_size(p_instance->base);
- probe->dynamic.light_to_cell_xform=cell_to_xform * p_instance->transform.affine_inverse();
+ probe->dynamic.light_to_cell_xform = cell_to_xform * p_instance->transform.affine_inverse();
- VSG::scene_render->gi_probe_instance_set_light_data(probe->probe_instance,p_instance->base,probe->dynamic.probe_data);
- VSG::scene_render->gi_probe_instance_set_transform_to_data(probe->probe_instance,probe->dynamic.light_to_cell_xform);
+ VSG::scene_render->gi_probe_instance_set_light_data(probe->probe_instance, p_instance->base, probe->dynamic.probe_data);
+ VSG::scene_render->gi_probe_instance_set_transform_to_data(probe->probe_instance, probe->dynamic.light_to_cell_xform);
- VSG::scene_render->gi_probe_instance_set_bounds(probe->probe_instance,bounds.size/cell_size);
+ VSG::scene_render->gi_probe_instance_set_bounds(probe->probe_instance, bounds.size / cell_size);
- probe->base_version=VSG::storage->gi_probe_get_version(p_instance->base);
+ probe->base_version = VSG::storage->gi_probe_get_version(p_instance->base);
//if compression is S3TC, fill it up
- if (probe->dynamic.compression==RasterizerStorage::GI_PROBE_S3TC) {
+ if (probe->dynamic.compression == RasterizerStorage::GI_PROBE_S3TC) {
//create all blocks
- Vector<Map<uint32_t,InstanceGIProbeData::CompBlockS3TC> > comp_blocks;
+ Vector<Map<uint32_t, InstanceGIProbeData::CompBlockS3TC> > comp_blocks;
int mipmap_count = probe->dynamic.mipmaps_3d.size();
comp_blocks.resize(mipmap_count);
- for(int i=0;i<cell_count;i++) {
+ for (int i = 0; i < cell_count; i++) {
const GIProbeDataCell &c = cells[i];
const InstanceGIProbeData::LocalData &ld = ldw[i];
- int level = c.level_alpha>>16;
- int mipmap = header->cell_subdiv - level -1;
+ int level = c.level_alpha >> 16;
+ int mipmap = header->cell_subdiv - level - 1;
if (mipmap >= mipmap_count)
- continue;//uninteresting
-
+ continue; //uninteresting
- int blockx = (ld.pos[0]>>2);
- int blocky = (ld.pos[1]>>2);
+ int blockx = (ld.pos[0] >> 2);
+ int blocky = (ld.pos[1] >> 2);
int blockz = (ld.pos[2]); //compression is x/y only
int blockw = (header->width >> mipmap) >> 2;
@@ -2556,120 +2387,115 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
//print_line("cell "+itos(i)+" level "+itos(level)+"mipmap: "+itos(mipmap)+" pos: "+Vector3(blockx,blocky,blockz)+" size "+Vector2(blockw,blockh));
- uint32_t key = blockz * blockw*blockh + blocky * blockw + blockx;
+ uint32_t key = blockz * blockw * blockh + blocky * blockw + blockx;
- Map<uint32_t,InstanceGIProbeData::CompBlockS3TC> & cmap = comp_blocks[mipmap];
+ Map<uint32_t, InstanceGIProbeData::CompBlockS3TC> &cmap = comp_blocks[mipmap];
if (!cmap.has(key)) {
InstanceGIProbeData::CompBlockS3TC k;
- k.offset=key; //use offset as counter first
- k.source_count=0;
- cmap[key]=k;
+ k.offset = key; //use offset as counter first
+ k.source_count = 0;
+ cmap[key] = k;
}
- InstanceGIProbeData::CompBlockS3TC &k=cmap[key];
- ERR_CONTINUE(k.source_count==16);
- k.sources[k.source_count++]=i;
+ InstanceGIProbeData::CompBlockS3TC &k = cmap[key];
+ ERR_CONTINUE(k.source_count == 16);
+ k.sources[k.source_count++] = i;
}
//fix the blocks, precomputing what is needed
probe->dynamic.mipmaps_s3tc.resize(mipmap_count);
- for(int i=0;i<mipmap_count;i++) {
- print_line("S3TC level: "+itos(i)+" blocks: "+itos(comp_blocks[i].size()));
+ for (int i = 0; i < mipmap_count; i++) {
+ print_line("S3TC level: " + itos(i) + " blocks: " + itos(comp_blocks[i].size()));
probe->dynamic.mipmaps_s3tc[i].resize(comp_blocks[i].size());
PoolVector<InstanceGIProbeData::CompBlockS3TC>::Write w = probe->dynamic.mipmaps_s3tc[i].write();
- int block_idx=0;
+ int block_idx = 0;
- for (Map<uint32_t,InstanceGIProbeData::CompBlockS3TC>::Element *E=comp_blocks[i].front();E;E=E->next()) {
+ for (Map<uint32_t, InstanceGIProbeData::CompBlockS3TC>::Element *E = comp_blocks[i].front(); E; E = E->next()) {
InstanceGIProbeData::CompBlockS3TC k = E->get();
//PRECOMPUTE ALPHA
- int max_alpha=-100000;
- int min_alpha=k.source_count==16 ?100000 :0; //if the block is not completely full, minimum is always 0, (and those blocks will map to 1, which will be zero)
+ int max_alpha = -100000;
+ int min_alpha = k.source_count == 16 ? 100000 : 0; //if the block is not completely full, minimum is always 0, (and those blocks will map to 1, which will be zero)
- uint8_t alpha_block[4][4]={ {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0} };
+ uint8_t alpha_block[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
- for(int j=0;j<k.source_count;j++) {
+ for (int j = 0; j < k.source_count; j++) {
- int alpha = (cells[k.sources[j]].level_alpha>>8)&0xFF;
- if (alpha<min_alpha)
- min_alpha=alpha;
- if (alpha>max_alpha)
- max_alpha=alpha;
+ int alpha = (cells[k.sources[j]].level_alpha >> 8) & 0xFF;
+ if (alpha < min_alpha)
+ min_alpha = alpha;
+ if (alpha > max_alpha)
+ max_alpha = alpha;
//fill up alpha block
- alpha_block[ldw[k.sources[j]].pos[0]%4][ldw[k.sources[j]].pos[1]%4]=alpha;
-
+ alpha_block[ldw[k.sources[j]].pos[0] % 4][ldw[k.sources[j]].pos[1] % 4] = alpha;
}
//use the first mode (8 adjustable levels)
- k.alpha[0]=max_alpha;
- k.alpha[1]=min_alpha;
+ k.alpha[0] = max_alpha;
+ k.alpha[1] = min_alpha;
- uint64_t alpha_bits=0;
+ uint64_t alpha_bits = 0;
- if (max_alpha!=min_alpha) {
+ if (max_alpha != min_alpha) {
- int idx=0;
+ int idx = 0;
- for(int y=0;y<4;y++) {
- for(int x=0;x<4;x++) {
+ for (int y = 0; y < 4; y++) {
+ for (int x = 0; x < 4; x++) {
//substract minimum
- uint32_t a = uint32_t(alpha_block[x][y])-min_alpha;
+ uint32_t a = uint32_t(alpha_block[x][y]) - min_alpha;
//convert range to 3 bits
- a =int((a * 7.0 / (max_alpha-min_alpha))+0.5);
- a = CLAMP(a,0,7); //just to be sure
- a = 7-a; //because range is inverted in this mode
- if (a==0) {
+ a = int((a * 7.0 / (max_alpha - min_alpha)) + 0.5);
+ a = CLAMP(a, 0, 7); //just to be sure
+ a = 7 - a; //because range is inverted in this mode
+ if (a == 0) {
//do none, remain
- } else if (a==7) {
- a=1;
+ } else if (a == 7) {
+ a = 1;
} else {
- a=a+1;
+ a = a + 1;
}
- alpha_bits|=uint64_t(a)<<(idx*3);
+ alpha_bits |= uint64_t(a) << (idx * 3);
idx++;
}
}
}
- k.alpha[2]=(alpha_bits >> 0)&0xFF;
- k.alpha[3]=(alpha_bits >> 8)&0xFF;
- k.alpha[4]=(alpha_bits >> 16)&0xFF;
- k.alpha[5]=(alpha_bits >> 24)&0xFF;
- k.alpha[6]=(alpha_bits >> 32)&0xFF;
- k.alpha[7]=(alpha_bits >> 40)&0xFF;
-
- w[block_idx++]=k;
+ k.alpha[2] = (alpha_bits >> 0) & 0xFF;
+ k.alpha[3] = (alpha_bits >> 8) & 0xFF;
+ k.alpha[4] = (alpha_bits >> 16) & 0xFF;
+ k.alpha[5] = (alpha_bits >> 24) & 0xFF;
+ k.alpha[6] = (alpha_bits >> 32) & 0xFF;
+ k.alpha[7] = (alpha_bits >> 40) & 0xFF;
+ w[block_idx++] = k;
}
-
}
}
-
}
void VisualServerScene::_gi_probe_bake_thread() {
- while(true) {
+ while (true) {
probe_bake_sem->wait();
if (probe_bake_thread_exit) {
break;
}
- Instance* to_bake=NULL;
+ Instance *to_bake = NULL;
probe_bake_mutex->lock();
if (!probe_bake_list.empty()) {
- to_bake=probe_bake_list.front()->get();
+ to_bake = probe_bake_list.front()->get();
probe_bake_list.pop_front();
-
}
probe_bake_mutex->unlock();
@@ -2680,111 +2506,103 @@ void VisualServerScene::_gi_probe_bake_thread() {
}
}
+uint32_t VisualServerScene::_gi_bake_find_cell(const GIProbeDataCell *cells, int x, int y, int z, int p_cell_subdiv) {
+ uint32_t cell = 0;
-uint32_t VisualServerScene::_gi_bake_find_cell(const GIProbeDataCell *cells,int x,int y, int z,int p_cell_subdiv) {
-
+ int ofs_x = 0;
+ int ofs_y = 0;
+ int ofs_z = 0;
+ int size = 1 << (p_cell_subdiv - 1);
+ int half = size / 2;
- uint32_t cell=0;
-
- int ofs_x=0;
- int ofs_y=0;
- int ofs_z=0;
- int size = 1<<(p_cell_subdiv-1);
- int half=size/2;
-
- if (x<0 || x>=size)
+ if (x < 0 || x >= size)
return -1;
- if (y<0 || y>=size)
+ if (y < 0 || y >= size)
return -1;
- if (z<0 || z>=size)
+ if (z < 0 || z >= size)
return -1;
- for(int i=0;i<p_cell_subdiv-1;i++) {
+ for (int i = 0; i < p_cell_subdiv - 1; i++) {
const GIProbeDataCell *bc = &cells[cell];
int child = 0;
if (x >= ofs_x + half) {
- child|=1;
- ofs_x+=half;
+ child |= 1;
+ ofs_x += half;
}
if (y >= ofs_y + half) {
- child|=2;
- ofs_y+=half;
+ child |= 2;
+ ofs_y += half;
}
if (z >= ofs_z + half) {
- child|=4;
- ofs_z+=half;
+ child |= 4;
+ ofs_z += half;
}
cell = bc->children[child];
- if (cell==0xFFFFFFFF)
+ if (cell == 0xFFFFFFFF)
return 0xFFFFFFFF;
- half>>=1;
+ half >>= 1;
}
return cell;
-
}
-static float _get_normal_advance(const Vector3& p_normal ) {
+static float _get_normal_advance(const Vector3 &p_normal) {
Vector3 normal = p_normal;
Vector3 unorm = normal.abs();
- if ( (unorm.x >= unorm.y) && (unorm.x >= unorm.z) ) {
- // x code
- unorm = normal.x > 0.0 ? Vector3( 1.0, 0.0, 0.0 ) : Vector3( -1.0, 0.0, 0.0 ) ;
- } else if ( (unorm.y > unorm.x) && (unorm.y >= unorm.z) ) {
- // y code
- unorm = normal.y > 0.0 ? Vector3( 0.0, 1.0, 0.0 ) : Vector3( 0.0, -1.0, 0.0 ) ;
- } else if ( (unorm.z > unorm.x) && (unorm.z > unorm.y) ) {
- // z code
- unorm = normal.z > 0.0 ? Vector3( 0.0, 0.0, 1.0 ) : Vector3( 0.0, 0.0, -1.0 ) ;
+ if ((unorm.x >= unorm.y) && (unorm.x >= unorm.z)) {
+ // x code
+ unorm = normal.x > 0.0 ? Vector3(1.0, 0.0, 0.0) : Vector3(-1.0, 0.0, 0.0);
+ } else if ((unorm.y > unorm.x) && (unorm.y >= unorm.z)) {
+ // y code
+ unorm = normal.y > 0.0 ? Vector3(0.0, 1.0, 0.0) : Vector3(0.0, -1.0, 0.0);
+ } else if ((unorm.z > unorm.x) && (unorm.z > unorm.y)) {
+ // z code
+ unorm = normal.z > 0.0 ? Vector3(0.0, 0.0, 1.0) : Vector3(0.0, 0.0, -1.0);
} else {
- // oh-no we messed up code
- // has to be
- unorm = Vector3( 1.0, 0.0, 0.0 );
+ // oh-no we messed up code
+ // has to be
+ unorm = Vector3(1.0, 0.0, 0.0);
}
- return 1.0/normal.dot(unorm);
-
+ return 1.0 / normal.dot(unorm);
}
-void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header,const GIProbeDataCell *cells,InstanceGIProbeData::LocalData *local_data,const uint32_t *leaves,int leaf_count, const InstanceGIProbeData::LightCache& light_cache,int sign) {
+void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, const GIProbeDataCell *cells, InstanceGIProbeData::LocalData *local_data, const uint32_t *leaves, int leaf_count, const InstanceGIProbeData::LightCache &light_cache, int sign) {
+ int light_r = int(light_cache.color.r * light_cache.energy * 1024.0) * sign;
+ int light_g = int(light_cache.color.g * light_cache.energy * 1024.0) * sign;
+ int light_b = int(light_cache.color.b * light_cache.energy * 1024.0) * sign;
- int light_r = int(light_cache.color.r * light_cache.energy * 1024.0)*sign;
- int light_g = int(light_cache.color.g * light_cache.energy * 1024.0)*sign;
- int light_b = int(light_cache.color.b * light_cache.energy * 1024.0)*sign;
-
- float limits[3]={float(header->width),float(header->height),float(header->depth)};
+ float limits[3] = { float(header->width), float(header->height), float(header->depth) };
Plane clip[3];
- int clip_planes=0;
-
-
+ int clip_planes = 0;
- switch(light_cache.type) {
+ switch (light_cache.type) {
case VS::LIGHT_DIRECTIONAL: {
- float max_len = Vector3(limits[0],limits[1],limits[2]).length()*1.1;
+ float max_len = Vector3(limits[0], limits[1], limits[2]).length() * 1.1;
Vector3 light_axis = -light_cache.transform.basis.get_axis(2).normalized();
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
- if (ABS(light_axis[i])<CMP_EPSILON)
+ if (ABS(light_axis[i]) < CMP_EPSILON)
continue;
- clip[clip_planes].normal[i]=1.0;
+ clip[clip_planes].normal[i] = 1.0;
- if (light_axis[i]<0) {
+ if (light_axis[i] < 0) {
- clip[clip_planes].d=limits[i]+1;
+ clip[clip_planes].d = limits[i] + 1;
} else {
- clip[clip_planes].d-=1.0;
+ clip[clip_planes].d -= 1.0;
}
clip_planes++;
@@ -2792,137 +2610,129 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header,con
float distance_adv = _get_normal_advance(light_axis);
- int success_count=0;
+ int success_count = 0;
uint64_t us = OS::get_singleton()->get_ticks_usec();
- for(int i=0;i<leaf_count;i++) {
+ for (int i = 0; i < leaf_count; i++) {
uint32_t idx = leaves[i];
const GIProbeDataCell *cell = &cells[idx];
InstanceGIProbeData::LocalData *light = &local_data[idx];
- Vector3 to(light->pos[0]+0.5,light->pos[1]+0.5,light->pos[2]+0.5);
- Vector3 norm (
- (((cells[idx].normal>>16)&0xFF)/255.0)*2.0-1.0,
- (((cells[idx].normal>>8)&0xFF)/255.0)*2.0-1.0,
- (((cells[idx].normal>>0)&0xFF)/255.0)*2.0-1.0
- );
-
+ Vector3 to(light->pos[0] + 0.5, light->pos[1] + 0.5, light->pos[2] + 0.5);
+ Vector3 norm(
+ (((cells[idx].normal >> 16) & 0xFF) / 255.0) * 2.0 - 1.0,
+ (((cells[idx].normal >> 8) & 0xFF) / 255.0) * 2.0 - 1.0,
+ (((cells[idx].normal >> 0) & 0xFF) / 255.0) * 2.0 - 1.0);
float att = norm.dot(-light_axis);
- if (att<0.001) {
+ if (att < 0.001) {
//not lighting towards this
continue;
}
Vector3 from = to - max_len * light_axis;
- for(int j=0;j<clip_planes;j++) {
+ for (int j = 0; j < clip_planes; j++) {
- clip[j].intersects_segment(from,to,&from);
+ clip[j].intersects_segment(from, to, &from);
}
float distance = (to - from).length();
- distance+=distance_adv-Math::fmod(distance,distance_adv); //make it reach the center of the box always
+ distance += distance_adv - Math::fmod(distance, distance_adv); //make it reach the center of the box always
from = to - light_axis * distance;
- uint32_t result=0xFFFFFFFF;
+ uint32_t result = 0xFFFFFFFF;
- while(distance>-distance_adv) { //use this to avoid precision errors
+ while (distance > -distance_adv) { //use this to avoid precision errors
- result = _gi_bake_find_cell(cells,int(floor(from.x)),int(floor(from.y)),int(floor(from.z)),header->cell_subdiv);
- if (result!=0xFFFFFFFF) {
+ result = _gi_bake_find_cell(cells, int(floor(from.x)), int(floor(from.y)), int(floor(from.z)), header->cell_subdiv);
+ if (result != 0xFFFFFFFF) {
break;
}
- from+=light_axis*distance_adv;
- distance-=distance_adv;
+ from += light_axis * distance_adv;
+ distance -= distance_adv;
}
- if (result==idx) {
+ if (result == idx) {
//cell hit itself! hooray!
- light->energy[0]+=int32_t(light_r*att*((cell->albedo>>16)&0xFF)/255.0);
- light->energy[1]+=int32_t(light_g*att*((cell->albedo>>8)&0xFF)/255.0);
- light->energy[2]+=int32_t(light_b*att*((cell->albedo)&0xFF)/255.0);
- success_count++;
+ light->energy[0] += int32_t(light_r * att * ((cell->albedo >> 16) & 0xFF) / 255.0);
+ light->energy[1] += int32_t(light_g * att * ((cell->albedo >> 8) & 0xFF) / 255.0);
+ light->energy[2] += int32_t(light_b * att * ((cell->albedo) & 0xFF) / 255.0);
+ success_count++;
}
}
- print_line("BAKE TIME: "+rtos((OS::get_singleton()->get_ticks_usec()-us)/1000000.0));
- print_line("valid cells: "+itos(success_count));
-
+ print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0));
+ print_line("valid cells: " + itos(success_count));
} break;
case VS::LIGHT_OMNI:
case VS::LIGHT_SPOT: {
-
uint64_t us = OS::get_singleton()->get_ticks_usec();
Vector3 light_pos = light_cache.transform.origin;
Vector3 spot_axis = -light_cache.transform.basis.get_axis(2).normalized();
-
float local_radius = light_cache.radius * light_cache.transform.basis.get_axis(2).length();
- for(int i=0;i<leaf_count;i++) {
+ for (int i = 0; i < leaf_count; i++) {
uint32_t idx = leaves[i];
const GIProbeDataCell *cell = &cells[idx];
InstanceGIProbeData::LocalData *light = &local_data[idx];
- Vector3 to(light->pos[0]+0.5,light->pos[1]+0.5,light->pos[2]+0.5);
- Vector3 norm (
- (((cells[idx].normal>>16)&0xFF)/255.0)*2.0-1.0,
- (((cells[idx].normal>>8)&0xFF)/255.0)*2.0-1.0,
- (((cells[idx].normal>>0)&0xFF)/255.0)*2.0-1.0
- );
+ Vector3 to(light->pos[0] + 0.5, light->pos[1] + 0.5, light->pos[2] + 0.5);
+ Vector3 norm(
+ (((cells[idx].normal >> 16) & 0xFF) / 255.0) * 2.0 - 1.0,
+ (((cells[idx].normal >> 8) & 0xFF) / 255.0) * 2.0 - 1.0,
+ (((cells[idx].normal >> 0) & 0xFF) / 255.0) * 2.0 - 1.0);
Vector3 light_axis = (to - light_pos).normalized();
float distance_adv = _get_normal_advance(light_axis);
float att = norm.dot(-light_axis);
- if (att<0.001) {
+ if (att < 0.001) {
//not lighting towards this
continue;
}
{
float d = light_pos.distance_to(to);
- if (d+distance_adv > local_radius)
+ if (d + distance_adv > local_radius)
continue; // too far away
- float dt = CLAMP((d+distance_adv)/local_radius,0,1);
- att*= powf(1.0-dt,light_cache.attenuation);
+ float dt = CLAMP((d + distance_adv) / local_radius, 0, 1);
+ att *= powf(1.0 - dt, light_cache.attenuation);
}
-
- if (light_cache.type==VS::LIGHT_SPOT) {
+ if (light_cache.type == VS::LIGHT_SPOT) {
float angle = Math::rad2deg(acos(light_axis.dot(spot_axis)));
if (angle > light_cache.spot_angle)
continue;
- float d = CLAMP(angle/light_cache.spot_angle,1,0);
- att*= powf(1.0-d,light_cache.spot_attenuation);
-
+ float d = CLAMP(angle / light_cache.spot_angle, 1, 0);
+ att *= powf(1.0 - d, light_cache.spot_attenuation);
}
- clip_planes=0;
+ clip_planes = 0;
- for(int c=0;c<3;c++) {
+ for (int c = 0; c < 3; c++) {
- if (ABS(light_axis[c])<CMP_EPSILON)
+ if (ABS(light_axis[c]) < CMP_EPSILON)
continue;
- clip[clip_planes].normal[c]=1.0;
+ clip[clip_planes].normal[c] = 1.0;
- if (light_axis[c]<0) {
+ if (light_axis[c] < 0) {
- clip[clip_planes].d=limits[c]+1;
+ clip[clip_planes].d = limits[c] + 1;
} else {
- clip[clip_planes].d-=1.0;
+ clip[clip_planes].d -= 1.0;
}
clip_planes++;
@@ -2930,216 +2740,203 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header,con
Vector3 from = light_pos;
- for(int j=0;j<clip_planes;j++) {
+ for (int j = 0; j < clip_planes; j++) {
- clip[j].intersects_segment(from,to,&from);
+ clip[j].intersects_segment(from, to, &from);
}
float distance = (to - from).length();
-
-
- distance-=Math::fmod(distance,distance_adv); //make it reach the center of the box always, but this tame make it closer
+ distance -= Math::fmod(distance, distance_adv); //make it reach the center of the box always, but this tame make it closer
from = to - light_axis * distance;
- uint32_t result=0xFFFFFFFF;
+ uint32_t result = 0xFFFFFFFF;
- while(distance>-distance_adv) { //use this to avoid precision errors
+ while (distance > -distance_adv) { //use this to avoid precision errors
- result = _gi_bake_find_cell(cells,int(floor(from.x)),int(floor(from.y)),int(floor(from.z)),header->cell_subdiv);
- if (result!=0xFFFFFFFF) {
+ result = _gi_bake_find_cell(cells, int(floor(from.x)), int(floor(from.y)), int(floor(from.z)), header->cell_subdiv);
+ if (result != 0xFFFFFFFF) {
break;
}
- from+=light_axis*distance_adv;
- distance-=distance_adv;
+ from += light_axis * distance_adv;
+ distance -= distance_adv;
}
- if (result==idx) {
+ if (result == idx) {
//cell hit itself! hooray!
- light->energy[0]+=int32_t(light_r*att*((cell->albedo>>16)&0xFF)/255.0);
- light->energy[1]+=int32_t(light_g*att*((cell->albedo>>8)&0xFF)/255.0);
- light->energy[2]+=int32_t(light_b*att*((cell->albedo)&0xFF)/255.0);
-
+ light->energy[0] += int32_t(light_r * att * ((cell->albedo >> 16) & 0xFF) / 255.0);
+ light->energy[1] += int32_t(light_g * att * ((cell->albedo >> 8) & 0xFF) / 255.0);
+ light->energy[2] += int32_t(light_b * att * ((cell->albedo) & 0xFF) / 255.0);
}
}
- print_line("BAKE TIME: "+rtos((OS::get_singleton()->get_ticks_usec()-us)/1000000.0));
-
+ print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0));
} break;
}
}
-
-void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data,float p_propagate) {
+void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell *p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, float p_propagate) {
//average light to upper level
- float divisor=0;
- float sum[3]={0.0,0.0,0.0};
+ float divisor = 0;
+ float sum[3] = { 0.0, 0.0, 0.0 };
- for(int i=0;i<8;i++) {
+ for (int i = 0; i < 8; i++) {
uint32_t child = p_cells[p_idx].children[i];
- if (child==0xFFFFFFFF)
+ if (child == 0xFFFFFFFF)
continue;
- if (p_level+1 < (int)p_header->cell_subdiv-1) {
- _bake_gi_downscale_light(child,p_level+1,p_cells,p_header,p_local_data,p_propagate);
+ if (p_level + 1 < (int)p_header->cell_subdiv - 1) {
+ _bake_gi_downscale_light(child, p_level + 1, p_cells, p_header, p_local_data, p_propagate);
}
- sum[0]+=p_local_data[child].energy[0];
- sum[1]+=p_local_data[child].energy[1];
- sum[2]+=p_local_data[child].energy[2];
- divisor+=1.0;
-
+ sum[0] += p_local_data[child].energy[0];
+ sum[1] += p_local_data[child].energy[1];
+ sum[2] += p_local_data[child].energy[2];
+ divisor += 1.0;
}
- divisor=Math::lerp((float)8.0,divisor,p_propagate);
- sum[0]/=divisor;
- sum[1]/=divisor;
- sum[2]/=divisor;
+ divisor = Math::lerp((float)8.0, divisor, p_propagate);
+ sum[0] /= divisor;
+ sum[1] /= divisor;
+ sum[2] /= divisor;
//divide by eight for average
- p_local_data[p_idx].energy[0]=Math::fast_ftoi(sum[0]);
- p_local_data[p_idx].energy[1]=Math::fast_ftoi(sum[1]);
- p_local_data[p_idx].energy[2]=Math::fast_ftoi(sum[2]);
-
+ p_local_data[p_idx].energy[0] = Math::fast_ftoi(sum[0]);
+ p_local_data[p_idx].energy[1] = Math::fast_ftoi(sum[1]);
+ p_local_data[p_idx].energy[2] = Math::fast_ftoi(sum[2]);
}
-
void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
- InstanceGIProbeData * probe_data = static_cast<InstanceGIProbeData*>(p_gi_probe->base_data);
+ InstanceGIProbeData *probe_data = static_cast<InstanceGIProbeData *>(p_gi_probe->base_data);
- PoolVector<int>::Read r=probe_data->dynamic.light_data.read();
+ PoolVector<int>::Read r = probe_data->dynamic.light_data.read();
const GIProbeDataHeader *header = (const GIProbeDataHeader *)r.ptr();
- const GIProbeDataCell *cells = (const GIProbeDataCell*)&r[16];
+ const GIProbeDataCell *cells = (const GIProbeDataCell *)&r[16];
- int leaf_count = probe_data->dynamic.level_cell_lists[ header->cell_subdiv -1 ].size();
- const uint32_t *leaves = probe_data->dynamic.level_cell_lists[ header->cell_subdiv -1 ].ptr();
+ int leaf_count = probe_data->dynamic.level_cell_lists[header->cell_subdiv - 1].size();
+ const uint32_t *leaves = probe_data->dynamic.level_cell_lists[header->cell_subdiv - 1].ptr();
PoolVector<InstanceGIProbeData::LocalData>::Write ldw = probe_data->dynamic.local_data.write();
InstanceGIProbeData::LocalData *local_data = ldw.ptr();
-
//remove what must be removed
- for (Map<RID,InstanceGIProbeData::LightCache>::Element *E=probe_data->dynamic.light_cache.front();E;E=E->next()) {
+ for (Map<RID, InstanceGIProbeData::LightCache>::Element *E = probe_data->dynamic.light_cache.front(); E; E = E->next()) {
RID rid = E->key();
- const InstanceGIProbeData::LightCache& lc = E->get();
+ const InstanceGIProbeData::LightCache &lc = E->get();
- if (!probe_data->dynamic.light_cache_changes.has(rid) || !(probe_data->dynamic.light_cache_changes[rid]==lc)) {
+ if (!probe_data->dynamic.light_cache_changes.has(rid) || !(probe_data->dynamic.light_cache_changes[rid] == lc)) {
//erase light data
- _bake_gi_probe_light(header,cells,local_data,leaves,leaf_count,lc,-1);
+ _bake_gi_probe_light(header, cells, local_data, leaves, leaf_count, lc, -1);
}
-
}
//add what must be added
- for (Map<RID,InstanceGIProbeData::LightCache>::Element *E=probe_data->dynamic.light_cache_changes.front();E;E=E->next()) {
+ for (Map<RID, InstanceGIProbeData::LightCache>::Element *E = probe_data->dynamic.light_cache_changes.front(); E; E = E->next()) {
RID rid = E->key();
- const InstanceGIProbeData::LightCache& lc = E->get();
+ const InstanceGIProbeData::LightCache &lc = E->get();
- if (!probe_data->dynamic.light_cache.has(rid) || !(probe_data->dynamic.light_cache[rid]==lc)) {
+ if (!probe_data->dynamic.light_cache.has(rid) || !(probe_data->dynamic.light_cache[rid] == lc)) {
//add light data
- _bake_gi_probe_light(header,cells,local_data,leaves,leaf_count,lc,1);
+ _bake_gi_probe_light(header, cells, local_data, leaves, leaf_count, lc, 1);
}
}
- SWAP(probe_data->dynamic.light_cache_changes,probe_data->dynamic.light_cache);
+ SWAP(probe_data->dynamic.light_cache_changes, probe_data->dynamic.light_cache);
//downscale to lower res levels
- _bake_gi_downscale_light(0,0,cells,header,local_data,probe_data->dynamic.propagate);
+ _bake_gi_downscale_light(0, 0, cells, header, local_data, probe_data->dynamic.propagate);
//plot result to 3D texture!
- if (probe_data->dynamic.compression==RasterizerStorage::GI_PROBE_UNCOMPRESSED) {
+ if (probe_data->dynamic.compression == RasterizerStorage::GI_PROBE_UNCOMPRESSED) {
- for(int i=0;i<(int)header->cell_subdiv;i++) {
+ for (int i = 0; i < (int)header->cell_subdiv; i++) {
- int stage = header->cell_subdiv - i -1;
+ int stage = header->cell_subdiv - i - 1;
if (stage >= probe_data->dynamic.mipmaps_3d.size())
continue; //no mipmap for this one
- print_line("generating mipmap stage: "+itos(stage));
- int level_cell_count = probe_data->dynamic.level_cell_lists[ i ].size();
- const uint32_t *level_cells = probe_data->dynamic.level_cell_lists[ i ].ptr();
+ print_line("generating mipmap stage: " + itos(stage));
+ int level_cell_count = probe_data->dynamic.level_cell_lists[i].size();
+ const uint32_t *level_cells = probe_data->dynamic.level_cell_lists[i].ptr();
PoolVector<uint8_t>::Write lw = probe_data->dynamic.mipmaps_3d[stage].write();
uint8_t *mipmapw = lw.ptr();
- uint32_t sizes[3]={header->width>>stage,header->height>>stage,header->depth>>stage};
+ uint32_t sizes[3] = { header->width >> stage, header->height >> stage, header->depth >> stage };
- for(int j=0;j<level_cell_count;j++) {
+ for (int j = 0; j < level_cell_count; j++) {
uint32_t idx = level_cells[j];
- uint32_t r = (uint32_t(local_data[idx].energy[0])/probe_data->dynamic.bake_dynamic_range)>>2;
- uint32_t g = (uint32_t(local_data[idx].energy[1])/probe_data->dynamic.bake_dynamic_range)>>2;
- uint32_t b = (uint32_t(local_data[idx].energy[2])/probe_data->dynamic.bake_dynamic_range)>>2;
- uint32_t a = (cells[idx].level_alpha>>8)&0xFF;
-
- uint32_t mm_ofs = sizes[0]*sizes[1]*(local_data[idx].pos[2]) + sizes[0]*(local_data[idx].pos[1]) + (local_data[idx].pos[0]);
- mm_ofs*=4; //for RGBA (4 bytes)
-
- mipmapw[mm_ofs+0]=uint8_t(CLAMP(r,0,255));
- mipmapw[mm_ofs+1]=uint8_t(CLAMP(g,0,255));
- mipmapw[mm_ofs+2]=uint8_t(CLAMP(b,0,255));
- mipmapw[mm_ofs+3]=uint8_t(CLAMP(a,0,255));
+ uint32_t r = (uint32_t(local_data[idx].energy[0]) / probe_data->dynamic.bake_dynamic_range) >> 2;
+ uint32_t g = (uint32_t(local_data[idx].energy[1]) / probe_data->dynamic.bake_dynamic_range) >> 2;
+ uint32_t b = (uint32_t(local_data[idx].energy[2]) / probe_data->dynamic.bake_dynamic_range) >> 2;
+ uint32_t a = (cells[idx].level_alpha >> 8) & 0xFF;
+ uint32_t mm_ofs = sizes[0] * sizes[1] * (local_data[idx].pos[2]) + sizes[0] * (local_data[idx].pos[1]) + (local_data[idx].pos[0]);
+ mm_ofs *= 4; //for RGBA (4 bytes)
+ mipmapw[mm_ofs + 0] = uint8_t(CLAMP(r, 0, 255));
+ mipmapw[mm_ofs + 1] = uint8_t(CLAMP(g, 0, 255));
+ mipmapw[mm_ofs + 2] = uint8_t(CLAMP(b, 0, 255));
+ mipmapw[mm_ofs + 3] = uint8_t(CLAMP(a, 0, 255));
}
}
- } else if (probe_data->dynamic.compression==RasterizerStorage::GI_PROBE_S3TC) {
-
+ } else if (probe_data->dynamic.compression == RasterizerStorage::GI_PROBE_S3TC) {
int mipmap_count = probe_data->dynamic.mipmaps_3d.size();
- for(int mmi=0;mmi<mipmap_count;mmi++) {
+ for (int mmi = 0; mmi < mipmap_count; mmi++) {
PoolVector<uint8_t>::Write mmw = probe_data->dynamic.mipmaps_3d[mmi].write();
int block_count = probe_data->dynamic.mipmaps_s3tc[mmi].size();
PoolVector<InstanceGIProbeData::CompBlockS3TC>::Read mmr = probe_data->dynamic.mipmaps_s3tc[mmi].read();
- for(int i=0;i<block_count;i++) {
+ for (int i = 0; i < block_count; i++) {
- const InstanceGIProbeData::CompBlockS3TC& b = mmr[i];
+ const InstanceGIProbeData::CompBlockS3TC &b = mmr[i];
- uint8_t *blockptr = &mmw[b.offset*16];
- copymem(blockptr,b.alpha,8); //copy alpha part, which is precomputed
+ uint8_t *blockptr = &mmw[b.offset * 16];
+ copymem(blockptr, b.alpha, 8); //copy alpha part, which is precomputed
Vector3 colors[16];
- for(int j=0;j<b.source_count;j++) {
+ for (int j = 0; j < b.source_count; j++) {
- colors[j].x=(local_data[b.sources[j]].energy[0]/float(probe_data->dynamic.bake_dynamic_range))/1024.0;
- colors[j].y=(local_data[b.sources[j]].energy[1]/float(probe_data->dynamic.bake_dynamic_range))/1024.0;
- colors[j].z=(local_data[b.sources[j]].energy[2]/float(probe_data->dynamic.bake_dynamic_range))/1024.0;
+ colors[j].x = (local_data[b.sources[j]].energy[0] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
+ colors[j].y = (local_data[b.sources[j]].energy[1] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
+ colors[j].z = (local_data[b.sources[j]].energy[2] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
}
//super quick and dirty compression
//find 2 most futher apart
- float distance=0;
- Vector3 from,to;
+ float distance = 0;
+ Vector3 from, to;
- if (b.source_count==16) {
+ if (b.source_count == 16) {
//all cells are used so, find minmax between them
- int further_apart[2]={0,0};
- for(int j=0;j<b.source_count;j++) {
- for(int k=j+1;k<b.source_count;k++) {
+ int further_apart[2] = { 0, 0 };
+ for (int j = 0; j < b.source_count; j++) {
+ for (int k = j + 1; k < b.source_count; k++) {
float d = colors[j].distance_squared_to(colors[k]);
- if (d>distance) {
- distance=d;
- further_apart[0]=j;
- further_apart[1]=k;
+ if (d > distance) {
+ distance = d;
+ further_apart[0] = j;
+ further_apart[1] = k;
}
}
}
@@ -3154,154 +2951,138 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
//average all colors first
Vector3 average;
- for(int j=0;j<b.source_count;j++) {
- average+=colors[j];
+ for (int j = 0; j < b.source_count; j++) {
+ average += colors[j];
}
average.normalize();
//find max distance in normal from average
- for(int j=0;j<b.source_count;j++) {
+ for (int j = 0; j < b.source_count; j++) {
float d = average.dot(colors[j]);
- distance=MAX(d,distance);
+ distance = MAX(d, distance);
}
from = Vector3(); //from black
to = average * distance;
//find max distance
-
}
-
int indices[16];
- uint16_t color_0=0;
- color_0 = CLAMP(int(from.x*31),0,31)<<11;
- color_0 |= CLAMP(int(from.y*63),0,63)<<5;
- color_0 |= CLAMP(int(from.z*31),0,31);
+ uint16_t color_0 = 0;
+ color_0 = CLAMP(int(from.x * 31), 0, 31) << 11;
+ color_0 |= CLAMP(int(from.y * 63), 0, 63) << 5;
+ color_0 |= CLAMP(int(from.z * 31), 0, 31);
- uint16_t color_1=0;
- color_1 = CLAMP(int(to.x*31),0,31)<<11;
- color_1 |= CLAMP(int(to.y*63),0,63)<<5;
- color_1 |= CLAMP(int(to.z*31),0,31);
+ uint16_t color_1 = 0;
+ color_1 = CLAMP(int(to.x * 31), 0, 31) << 11;
+ color_1 |= CLAMP(int(to.y * 63), 0, 63) << 5;
+ color_1 |= CLAMP(int(to.z * 31), 0, 31);
if (color_1 > color_0) {
- SWAP(color_1,color_0);
- SWAP(from,to);
+ SWAP(color_1, color_0);
+ SWAP(from, to);
}
+ if (distance > 0) {
- if (distance>0) {
-
- Vector3 dir = (to-from).normalized();
+ Vector3 dir = (to - from).normalized();
+ for (int j = 0; j < b.source_count; j++) {
- for(int j=0;j<b.source_count;j++) {
-
- float d = (colors[j]-from).dot(dir) / distance;
- indices[j]=int(d*3+0.5);
-
- static const int index_swap[4]={0,3,1,2};
-
- indices[j]=index_swap[CLAMP(indices[j],0,3)];
+ float d = (colors[j] - from).dot(dir) / distance;
+ indices[j] = int(d * 3 + 0.5);
+ static const int index_swap[4] = { 0, 3, 1, 2 };
+ indices[j] = index_swap[CLAMP(indices[j], 0, 3)];
}
} else {
- for(int j=0;j<b.source_count;j++) {
- indices[j]=0;
+ for (int j = 0; j < b.source_count; j++) {
+ indices[j] = 0;
}
}
//by default, 1 is black, otherwise it will be overriden by source
- uint32_t index_block[16]={1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1 };
+ uint32_t index_block[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
- for(int j=0;j<b.source_count;j++) {
+ for (int j = 0; j < b.source_count; j++) {
- int x=local_data[b.sources[j]].pos[0]%4;
- int y=local_data[b.sources[j]].pos[1]%4;
+ int x = local_data[b.sources[j]].pos[0] % 4;
+ int y = local_data[b.sources[j]].pos[1] % 4;
- index_block[y*4+x]=indices[j];
+ index_block[y * 4 + x] = indices[j];
}
- uint32_t encode=0;
+ uint32_t encode = 0;
- for(int j=0;j<16;j++) {
- encode|=index_block[j]<<(j*2);
+ for (int j = 0; j < 16; j++) {
+ encode |= index_block[j] << (j * 2);
}
- blockptr[8]=color_0&0xFF;
- blockptr[9]=(color_0>>8)&0xFF;
- blockptr[10]=color_1&0xFF;
- blockptr[11]=(color_1>>8)&0xFF;
- blockptr[12]=encode&0xFF;
- blockptr[13]=(encode>>8)&0xFF;
- blockptr[14]=(encode>>16)&0xFF;
- blockptr[15]=(encode>>24)&0xFF;
-
+ blockptr[8] = color_0 & 0xFF;
+ blockptr[9] = (color_0 >> 8) & 0xFF;
+ blockptr[10] = color_1 & 0xFF;
+ blockptr[11] = (color_1 >> 8) & 0xFF;
+ blockptr[12] = encode & 0xFF;
+ blockptr[13] = (encode >> 8) & 0xFF;
+ blockptr[14] = (encode >> 16) & 0xFF;
+ blockptr[15] = (encode >> 24) & 0xFF;
}
-
-
}
-
}
-
//send back to main thread to update un little chunks
- probe_data->dynamic.updating_stage=GI_UPDATE_STAGE_UPLOADING;
-
+ probe_data->dynamic.updating_stage = GI_UPDATE_STAGE_UPLOADING;
}
bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) {
- InstanceGIProbeData * probe_data = static_cast<InstanceGIProbeData*>(p_gi_probe->base_data);
+ InstanceGIProbeData *probe_data = static_cast<InstanceGIProbeData *>(p_gi_probe->base_data);
probe_data->dynamic.light_cache_changes.clear();
- bool all_equal=true;
-
+ bool all_equal = true;
- for (List<Instance*>::Element *E=p_gi_probe->scenario->directional_lights.front();E;E=E->next()) {
+ for (List<Instance *>::Element *E = p_gi_probe->scenario->directional_lights.front(); E; E = E->next()) {
InstanceGIProbeData::LightCache lc;
- lc.type=VSG::storage->light_get_type(E->get()->base);
- lc.color=VSG::storage->light_get_color(E->get()->base);
- lc.energy=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_ENERGY);
- lc.radius=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_RANGE);
- lc.attenuation=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_ATTENUATION);
- lc.spot_angle=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_SPOT_ANGLE);
- lc.spot_attenuation=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_SPOT_ATTENUATION);
+ lc.type = VSG::storage->light_get_type(E->get()->base);
+ lc.color = VSG::storage->light_get_color(E->get()->base);
+ lc.energy = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ENERGY);
+ lc.radius = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_RANGE);
+ lc.attenuation = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ATTENUATION);
+ lc.spot_angle = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ANGLE);
+ lc.spot_attenuation = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ATTENUATION);
lc.transform = probe_data->dynamic.light_to_cell_xform * E->get()->transform;
- if (!probe_data->dynamic.light_cache.has(E->get()->self) || !(probe_data->dynamic.light_cache[E->get()->self]==lc)) {
- all_equal=false;
+ if (!probe_data->dynamic.light_cache.has(E->get()->self) || !(probe_data->dynamic.light_cache[E->get()->self] == lc)) {
+ all_equal = false;
}
- probe_data->dynamic.light_cache_changes[E->get()->self]=lc;
-
+ probe_data->dynamic.light_cache_changes[E->get()->self] = lc;
}
-
- for (Set<Instance*>::Element *E=probe_data->lights.front();E;E=E->next()) {
+ for (Set<Instance *>::Element *E = probe_data->lights.front(); E; E = E->next()) {
InstanceGIProbeData::LightCache lc;
- lc.type=VSG::storage->light_get_type(E->get()->base);
- lc.color=VSG::storage->light_get_color(E->get()->base);
- lc.energy=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_ENERGY);
- lc.radius=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_RANGE);
- lc.attenuation=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_ATTENUATION);
- lc.spot_angle=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_SPOT_ANGLE);
- lc.spot_attenuation=VSG::storage->light_get_param(E->get()->base,VS::LIGHT_PARAM_SPOT_ATTENUATION);
+ lc.type = VSG::storage->light_get_type(E->get()->base);
+ lc.color = VSG::storage->light_get_color(E->get()->base);
+ lc.energy = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ENERGY);
+ lc.radius = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_RANGE);
+ lc.attenuation = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ATTENUATION);
+ lc.spot_angle = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ANGLE);
+ lc.spot_attenuation = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ATTENUATION);
lc.transform = probe_data->dynamic.light_to_cell_xform * E->get()->transform;
- if (!probe_data->dynamic.light_cache.has(E->get()->self) || !(probe_data->dynamic.light_cache[E->get()->self]==lc)) {
- all_equal=false;
+ if (!probe_data->dynamic.light_cache.has(E->get()->self) || !(probe_data->dynamic.light_cache[E->get()->self] == lc)) {
+ all_equal = false;
}
- probe_data->dynamic.light_cache_changes[E->get()->self]=lc;
+ probe_data->dynamic.light_cache_changes[E->get()->self] = lc;
}
//lighting changed from after to before, must do some updating
- return !all_equal || probe_data->dynamic.light_cache_changes.size()!=probe_data->dynamic.light_cache.size();
-
+ return !all_equal || probe_data->dynamic.light_cache_changes.size() != probe_data->dynamic.light_cache.size();
}
void VisualServerScene::render_probes() {
@@ -3310,82 +3091,80 @@ void VisualServerScene::render_probes() {
SelfList<InstanceReflectionProbeData> *ref_probe = reflection_probe_render_list.first();
- bool busy=false;
+ bool busy = false;
- while(ref_probe) {
+ while (ref_probe) {
- SelfList<InstanceReflectionProbeData> *next=ref_probe->next();
+ SelfList<InstanceReflectionProbeData> *next = ref_probe->next();
RID base = ref_probe->self()->owner->base;
- switch(VSG::storage->reflection_probe_get_update_mode(base)) {
+ switch (VSG::storage->reflection_probe_get_update_mode(base)) {
case VS::REFLECTION_PROBE_UPDATE_ONCE: {
if (busy) //already rendering something
break;
- bool done = _render_reflection_probe_step(ref_probe->self()->owner,ref_probe->self()->render_step);
+ bool done = _render_reflection_probe_step(ref_probe->self()->owner, ref_probe->self()->render_step);
if (done) {
reflection_probe_render_list.remove(ref_probe);
} else {
ref_probe->self()->render_step++;
}
- busy=true; //do not render another one of this kind
+ busy = true; //do not render another one of this kind
} break;
case VS::REFLECTION_PROBE_UPDATE_ALWAYS: {
- int step=0;
- bool done=false;
- while(!done) {
- done = _render_reflection_probe_step(ref_probe->self()->owner,step);
+ int step = 0;
+ bool done = false;
+ while (!done) {
+ done = _render_reflection_probe_step(ref_probe->self()->owner, step);
step++;
}
reflection_probe_render_list.remove(ref_probe);
} break;
-
}
- ref_probe=next;
+ ref_probe = next;
}
/* GI PROBES */
SelfList<InstanceGIProbeData> *gi_probe = gi_probe_update_list.first();
- while(gi_probe) {
+ while (gi_probe) {
- SelfList<InstanceGIProbeData> *next=gi_probe->next();
+ SelfList<InstanceGIProbeData> *next = gi_probe->next();
InstanceGIProbeData *probe = gi_probe->self();
Instance *instance_probe = probe->owner;
//check if probe must be setup, but don't do if on the lighting thread
- bool force_lighting=false;
+ bool force_lighting = false;
- if (probe->invalid || (probe->dynamic.updating_stage==GI_UPDATE_STAGE_CHECK && probe->base_version!=VSG::storage->gi_probe_get_version(instance_probe->base))) {
+ if (probe->invalid || (probe->dynamic.updating_stage == GI_UPDATE_STAGE_CHECK && probe->base_version != VSG::storage->gi_probe_get_version(instance_probe->base))) {
_setup_gi_probe(instance_probe);
- force_lighting=true;
+ force_lighting = true;
}
float propagate = VSG::storage->gi_probe_get_propagation(instance_probe->base);
- if (probe->dynamic.propagate!=propagate) {
- probe->dynamic.propagate=propagate;
- force_lighting=true;
+ if (probe->dynamic.propagate != propagate) {
+ probe->dynamic.propagate = propagate;
+ force_lighting = true;
}
+ if (probe->invalid == false && probe->dynamic.enabled) {
- if (probe->invalid==false && probe->dynamic.enabled) {
-
- switch(probe->dynamic.updating_stage) {
+ switch (probe->dynamic.updating_stage) {
case GI_UPDATE_STAGE_CHECK: {
if (_check_gi_probe(instance_probe) || force_lighting) {
//send to lighting thread
- probe->dynamic.updating_stage=GI_UPDATE_STAGE_LIGHTING;
+ probe->dynamic.updating_stage = GI_UPDATE_STAGE_LIGHTING;
#ifndef NO_THREADS
probe_bake_mutex->lock();
@@ -3397,7 +3176,6 @@ void VisualServerScene::render_probes() {
_bake_gi_probe(instance_probe);
#endif
-
}
} break;
case GI_UPDATE_STAGE_LIGHTING: {
@@ -3408,29 +3186,23 @@ void VisualServerScene::render_probes() {
uint64_t us = OS::get_singleton()->get_ticks_usec();
- for(int i=0;i<(int)probe->dynamic.mipmaps_3d.size();i++) {
+ for (int i = 0; i < (int)probe->dynamic.mipmaps_3d.size(); i++) {
int mmsize = probe->dynamic.mipmaps_3d[i].size();
PoolVector<uint8_t>::Read r = probe->dynamic.mipmaps_3d[i].read();
- VSG::storage->gi_probe_dynamic_data_update(probe->dynamic.probe_data,0,probe->dynamic.grid_size[2]>>i,i,r.ptr());
+ VSG::storage->gi_probe_dynamic_data_update(probe->dynamic.probe_data, 0, probe->dynamic.grid_size[2] >> i, i, r.ptr());
}
-
- probe->dynamic.updating_stage=GI_UPDATE_STAGE_CHECK;
+ probe->dynamic.updating_stage = GI_UPDATE_STAGE_CHECK;
//print_line("UPLOAD TIME: "+rtos((OS::get_singleton()->get_ticks_usec()-us)/1000000.0));
} break;
-
}
}
//_update_gi_probe(gi_probe->self()->owner);
-
- gi_probe=next;
+ gi_probe = next;
}
-
-
-
}
void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
@@ -3438,143 +3210,131 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
if (p_instance->update_aabb)
_update_instance_aabb(p_instance);
-
if (p_instance->update_materials) {
- if (p_instance->base_type==VS::INSTANCE_MESH) {
+ if (p_instance->base_type == VS::INSTANCE_MESH) {
//remove materials no longer used and un-own them
int new_mat_count = VSG::storage->mesh_get_surface_count(p_instance->base);
- for(int i=p_instance->materials.size()-1;i>=new_mat_count;i--) {
+ for (int i = p_instance->materials.size() - 1; i >= new_mat_count; i--) {
if (p_instance->materials[i].is_valid()) {
- VSG::storage->material_remove_instance_owner(p_instance->materials[i],p_instance);
+ VSG::storage->material_remove_instance_owner(p_instance->materials[i], p_instance);
}
}
p_instance->materials.resize(new_mat_count);
int new_blend_shape_count = VSG::storage->mesh_get_blend_shape_count(p_instance->base);
- if (new_blend_shape_count!=p_instance->blend_values.size()) {
+ if (new_blend_shape_count != p_instance->blend_values.size()) {
p_instance->blend_values.resize(new_blend_shape_count);
- for(int i=0;i<new_blend_shape_count;i++) {
- p_instance->blend_values[i]=0;
+ for (int i = 0; i < new_blend_shape_count; i++) {
+ p_instance->blend_values[i] = 0;
}
}
}
- if ((1<<p_instance->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
+ if ((1 << p_instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
- InstanceGeometryData *geom = static_cast<InstanceGeometryData*>(p_instance->base_data);
+ InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
- bool can_cast_shadows=true;
+ bool can_cast_shadows = true;
- if (p_instance->cast_shadows==VS::SHADOW_CASTING_SETTING_OFF) {
- can_cast_shadows=false;
+ if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) {
+ can_cast_shadows = false;
} else if (p_instance->material_override.is_valid()) {
- can_cast_shadows=VSG::storage->material_casts_shadows(p_instance->material_override);
+ can_cast_shadows = VSG::storage->material_casts_shadows(p_instance->material_override);
} else {
-
-
- if (p_instance->base_type==VS::INSTANCE_MESH) {
- RID mesh=p_instance->base;
+ if (p_instance->base_type == VS::INSTANCE_MESH) {
+ RID mesh = p_instance->base;
if (mesh.is_valid()) {
- bool cast_shadows=false;
-
- for(int i=0;i<p_instance->materials.size();i++) {
+ bool cast_shadows = false;
+ for (int i = 0; i < p_instance->materials.size(); i++) {
- RID mat = p_instance->materials[i].is_valid()?p_instance->materials[i]:VSG::storage->mesh_surface_get_material(mesh,i);
+ RID mat = p_instance->materials[i].is_valid() ? p_instance->materials[i] : VSG::storage->mesh_surface_get_material(mesh, i);
if (!mat.is_valid()) {
- cast_shadows=true;
+ cast_shadows = true;
break;
}
if (VSG::storage->material_casts_shadows(mat)) {
- cast_shadows=true;
+ cast_shadows = true;
break;
}
}
if (!cast_shadows) {
- can_cast_shadows=false;
+ can_cast_shadows = false;
}
}
- } else if (p_instance->base_type==VS::INSTANCE_MULTIMESH) {
+ } else if (p_instance->base_type == VS::INSTANCE_MULTIMESH) {
RID mesh = VSG::storage->multimesh_get_mesh(p_instance->base);
if (mesh.is_valid()) {
- bool cast_shadows=false;
+ bool cast_shadows = false;
int sc = VSG::storage->mesh_get_surface_count(mesh);
- for(int i=0;i<sc;i++) {
+ for (int i = 0; i < sc; i++) {
- RID mat =VSG::storage->mesh_surface_get_material(mesh,i);
+ RID mat = VSG::storage->mesh_surface_get_material(mesh, i);
if (!mat.is_valid()) {
- cast_shadows=true;
+ cast_shadows = true;
break;
}
if (VSG::storage->material_casts_shadows(mat)) {
- cast_shadows=true;
+ cast_shadows = true;
break;
}
-
}
if (!cast_shadows) {
- can_cast_shadows=false;
+ can_cast_shadows = false;
}
}
- } else if (p_instance->base_type==VS::INSTANCE_IMMEDIATE) {
+ } else if (p_instance->base_type == VS::INSTANCE_IMMEDIATE) {
RID mat = VSG::storage->immediate_get_material(p_instance->base);
if (!mat.is_valid() || VSG::storage->material_casts_shadows(mat)) {
- can_cast_shadows=true;
+ can_cast_shadows = true;
} else {
- can_cast_shadows=false;
+ can_cast_shadows = false;
}
-
-
}
-
-
-
}
- if (can_cast_shadows!=geom->can_cast_shadows) {
+ if (can_cast_shadows != geom->can_cast_shadows) {
//ability to cast shadows change, let lights now
- for (List<Instance*>::Element *E=geom->lighting.front();E;E=E->next()) {
- InstanceLightData *light = static_cast<InstanceLightData*>(E->get()->base_data);
- light->shadow_dirty=true;
+ for (List<Instance *>::Element *E = geom->lighting.front(); E; E = E->next()) {
+ InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
+ light->shadow_dirty = true;
}
- geom->can_cast_shadows=can_cast_shadows;
+ geom->can_cast_shadows = can_cast_shadows;
}
}
-
}
_update_instance(p_instance);
- p_instance->update_aabb=false;
- p_instance->update_materials=false;
+ p_instance->update_aabb = false;
+ p_instance->update_materials = false;
- _instance_update_list.remove( &p_instance->update_item );
+ _instance_update_list.remove(&p_instance->update_item);
}
-
void VisualServerScene::update_dirty_instances() {
VSG::storage->update_dirty_resources();
- while(_instance_update_list.first()) {
+ while (_instance_update_list.first()) {
- _update_dirty_instance( _instance_update_list.first()->self() );
+ _update_dirty_instance(_instance_update_list.first()->self());
}
}
@@ -3582,17 +3342,17 @@ bool VisualServerScene::free(RID p_rid) {
if (camera_owner.owns(p_rid)) {
- Camera *camera = camera_owner.get( p_rid );
+ Camera *camera = camera_owner.get(p_rid);
camera_owner.free(p_rid);
memdelete(camera);
} else if (scenario_owner.owns(p_rid)) {
- Scenario *scenario = scenario_owner.get( p_rid );
+ Scenario *scenario = scenario_owner.get(p_rid);
- while(scenario->instances.first()) {
- instance_set_scenario(scenario->instances.first()->self()->self,RID());
+ while (scenario->instances.first()) {
+ instance_set_scenario(scenario->instances.first()->self()->self, RID());
}
VSG::scene_render->free(scenario->reflection_probe_shadow_atlas);
VSG::scene_render->free(scenario->reflection_atlas);
@@ -3606,11 +3366,11 @@ bool VisualServerScene::free(RID p_rid) {
Instance *instance = instance_owner.get(p_rid);
- instance_set_room(p_rid,RID());
- instance_set_scenario(p_rid,RID());
- instance_set_base(p_rid,RID());
- instance_geometry_set_material_override(p_rid,RID());
- instance_attach_skeleton(p_rid,RID());
+ instance_set_room(p_rid, RID());
+ instance_set_scenario(p_rid, RID());
+ instance_set_base(p_rid, RID());
+ instance_geometry_set_material_override(p_rid, RID());
+ instance_attach_skeleton(p_rid, RID());
update_dirty_instances(); //in case something changed this
@@ -3620,38 +3380,32 @@ bool VisualServerScene::free(RID p_rid) {
return false;
}
-
return true;
}
-VisualServerScene *VisualServerScene::singleton=NULL;
-
+VisualServerScene *VisualServerScene::singleton = NULL;
VisualServerScene::VisualServerScene() {
#ifndef NO_THREADS
probe_bake_sem = Semaphore::create();
probe_bake_mutex = Mutex::create();
- probe_bake_thread = Thread::create(_gi_probe_bake_threads,this);
- probe_bake_thread_exit=false;
+ probe_bake_thread = Thread::create(_gi_probe_bake_threads, this);
+ probe_bake_thread_exit = false;
#endif
-
- render_pass=1;
- singleton=this;
-
+ render_pass = 1;
+ singleton = this;
}
VisualServerScene::~VisualServerScene() {
#ifndef NO_THREADS
- probe_bake_thread_exit=true;
+ probe_bake_thread_exit = true;
Thread::wait_to_finish(probe_bake_thread);
memdelete(probe_bake_thread);
memdelete(probe_bake_sem);
memdelete(probe_bake_mutex);
#endif
-
-
}
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index 01ad400b80..b02e6c820b 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -31,30 +31,27 @@
#include "servers/visual/rasterizer.h"
-#include "geometry.h"
#include "allocators.h"
+#include "geometry.h"
#include "octree.h"
-#include "self_list.h"
-#include "os/thread.h"
#include "os/semaphore.h"
#include "os/semaphore.h"
+#include "os/thread.h"
+#include "self_list.h"
class VisualServerScene {
public:
-
-
enum {
- MAX_INSTANCE_CULL=65536,
- MAX_LIGHTS_CULLED=4096,
- MAX_REFLECTION_PROBES_CULLED=4096,
- MAX_ROOM_CULL=32,
- MAX_EXTERIOR_PORTALS=128,
+ MAX_INSTANCE_CULL = 65536,
+ MAX_LIGHTS_CULLED = 4096,
+ MAX_REFLECTION_PROBES_CULLED = 4096,
+ MAX_ROOM_CULL = 32,
+ MAX_EXTERIOR_PORTALS = 128,
};
uint64_t render_pass;
-
static VisualServerScene *singleton;
#if 0
struct Portal {
@@ -99,10 +96,9 @@ public:
#endif
-
/* CAMERA API */
- struct Camera : public RID_Data {
+ struct Camera : public RID_Data {
enum Type {
PERSPECTIVE,
@@ -110,7 +106,7 @@ public:
};
Type type;
float fov;
- float znear,zfar;
+ float znear, zfar;
float size;
uint32_t visible_layers;
bool vaspect;
@@ -120,26 +116,25 @@ public:
Camera() {
- visible_layers=0xFFFFFFFF;
- fov=60;
- type=PERSPECTIVE;
- znear=0.1; zfar=100;
- size=1.0;
- vaspect=false;
-
+ visible_layers = 0xFFFFFFFF;
+ fov = 60;
+ type = PERSPECTIVE;
+ znear = 0.1;
+ zfar = 100;
+ size = 1.0;
+ vaspect = false;
}
};
mutable RID_Owner<Camera> camera_owner;
virtual RID camera_create();
- virtual void camera_set_perspective(RID p_camera,float p_fovy_degrees, float p_z_near, float p_z_far);
- virtual void camera_set_orthogonal(RID p_camera,float p_size, float p_z_near, float p_z_far);
- virtual void camera_set_transform(RID p_camera,const Transform& p_transform);
- virtual void camera_set_cull_mask(RID p_camera,uint32_t p_layers);
- virtual void camera_set_environment(RID p_camera,RID p_env);
- virtual void camera_set_use_vertical_aspect(RID p_camera,bool p_enable);
-
+ virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far);
+ virtual void camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far);
+ virtual void camera_set_transform(RID p_camera, const Transform &p_transform);
+ virtual void camera_set_cull_mask(RID p_camera, uint32_t p_layers);
+ virtual void camera_set_environment(RID p_camera, RID p_env);
+ virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable);
/*
@@ -173,56 +168,48 @@ public:
};
*/
-
-
/* SCENARIO API */
struct Instance;
- struct Scenario : RID_Data {
-
+ struct Scenario : RID_Data {
VS::ScenarioDebugMode debug;
RID self;
// well wtf, balloon allocator is slower?
- Octree<Instance,true> octree;
+ Octree<Instance, true> octree;
- List<Instance*> directional_lights;
+ List<Instance *> directional_lights;
RID environment;
RID fallback_environment;
RID reflection_probe_shadow_atlas;
RID reflection_atlas;
-
SelfList<Instance>::List instances;
- Scenario() { debug=VS::SCENARIO_DEBUG_DISABLED; }
+ Scenario() { debug = VS::SCENARIO_DEBUG_DISABLED; }
};
mutable RID_Owner<Scenario> scenario_owner;
- static void* _instance_pair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int);
- static void _instance_unpair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int,void*);
+ static void *_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int);
+ static void _instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *);
virtual RID scenario_create();
- virtual void scenario_set_debug(RID p_scenario,VS::ScenarioDebugMode p_debug_mode);
+ virtual void scenario_set_debug(RID p_scenario, VS::ScenarioDebugMode p_debug_mode);
virtual void scenario_set_environment(RID p_scenario, RID p_environment);
virtual void scenario_set_fallback_environment(RID p_scenario, RID p_environment);
- virtual void scenario_set_reflection_atlas_size(RID p_scenario, int p_size,int p_subdiv);
-
+ virtual void scenario_set_reflection_atlas_size(RID p_scenario, int p_size, int p_subdiv);
/* INSTANCING API */
struct InstanceBaseData {
-
virtual ~InstanceBaseData() {}
};
-
-
struct Instance : RasterizerScene::InstanceBase {
RID self;
@@ -237,7 +224,6 @@ public:
SelfList<Instance> update_item;
-
Rect3 aabb;
Rect3 transformed_aabb;
float extra_margin;
@@ -262,107 +248,99 @@ public:
virtual void base_removed() {
- singleton->instance_set_base(self,RID());
+ singleton->instance_set_base(self, RID());
}
virtual void base_changed() {
- singleton->_instance_queue_update(this,true,true);
+ singleton->_instance_queue_update(this, true, true);
}
virtual void base_material_changed() {
- singleton->_instance_queue_update(this,false,true);
+ singleton->_instance_queue_update(this, false, true);
}
+ Instance()
+ : scenario_item(this), update_item(this), room_item(this) {
- Instance() : scenario_item(this), update_item(this), room_item(this) {
-
- octree_id=0;
- scenario=NULL;
-
-
- update_aabb=false;
- update_materials=false;
+ octree_id = 0;
+ scenario = NULL;
- extra_margin=0;
+ update_aabb = false;
+ update_materials = false;
+ extra_margin = 0;
- object_ID=0;
- visible=true;
+ object_ID = 0;
+ visible = true;
- lod_begin=0;
- lod_end=0;
- lod_begin_hysteresis=0;
- lod_end_hysteresis=0;
+ lod_begin = 0;
+ lod_end = 0;
+ lod_begin_hysteresis = 0;
+ lod_end_hysteresis = 0;
- room=NULL;
- visible_in_all_rooms=false;
-
-
-
- last_render_pass=0;
- last_frame_pass=0;
- version=1;
- base_data=NULL;
+ room = NULL;
+ visible_in_all_rooms = false;
+ last_render_pass = 0;
+ last_frame_pass = 0;
+ version = 1;
+ base_data = NULL;
}
~Instance() {
if (base_data)
memdelete(base_data);
-
}
};
SelfList<Instance>::List _instance_update_list;
- void _instance_queue_update(Instance *p_instance,bool p_update_aabb,bool p_update_materials=false);
-
+ void _instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_materials = false);
struct InstanceGeometryData : public InstanceBaseData {
- List<Instance*> lighting;
+ List<Instance *> lighting;
bool lighting_dirty;
bool can_cast_shadows;
- List<Instance*> reflection_probes;
+ List<Instance *> reflection_probes;
bool reflection_dirty;
- List<Instance*> gi_probes;
+ List<Instance *> gi_probes;
bool gi_probes_dirty;
InstanceGeometryData() {
- lighting_dirty=false;
- reflection_dirty=true;
- can_cast_shadows=true;
- gi_probes_dirty=true;
+ lighting_dirty = false;
+ reflection_dirty = true;
+ can_cast_shadows = true;
+ gi_probes_dirty = true;
}
};
struct InstanceReflectionProbeData : public InstanceBaseData {
-
Instance *owner;
struct PairInfo {
- List<Instance*>::Element *L; //reflection iterator in geometry
+ List<Instance *>::Element *L; //reflection iterator in geometry
Instance *geometry;
};
List<PairInfo> geometries;
-
RID instance;
bool reflection_dirty;
SelfList<InstanceReflectionProbeData> update_list;
int render_step;
- InstanceReflectionProbeData() : update_list(this) {
+ InstanceReflectionProbeData()
+ : update_list(this) {
- reflection_dirty=true;
- render_step=-1;
+ reflection_dirty = true;
+ render_step = -1;
}
};
@@ -371,13 +349,13 @@ public:
struct InstanceLightData : public InstanceBaseData {
struct PairInfo {
- List<Instance*>::Element *L; //light iterator in geometry
+ List<Instance *>::Element *L; //light iterator in geometry
Instance *geometry;
};
RID instance;
uint64_t last_version;
- List<Instance*>::Element *D; // directional light in scenario
+ List<Instance *>::Element *D; // directional light in scenario
bool shadow_dirty;
@@ -387,26 +365,25 @@ public:
InstanceLightData() {
- shadow_dirty=true;
- D=NULL;
- last_version=0;
- baked_light=NULL;
+ shadow_dirty = true;
+ D = NULL;
+ last_version = 0;
+ baked_light = NULL;
}
};
struct InstanceGIProbeData : public InstanceBaseData {
-
Instance *owner;
struct PairInfo {
- List<Instance*>::Element *L; //gi probe iterator in geometry
+ List<Instance *>::Element *L; //gi probe iterator in geometry
Instance *geometry;
};
List<PairInfo> geometries;
- Set<Instance*> lights;
+ Set<Instance *> lights;
struct LightCache {
@@ -419,29 +396,27 @@ public:
float spot_angle;
float spot_attenuation;
- bool operator==(const LightCache& p_cache) {
+ bool operator==(const LightCache &p_cache) {
- return (type==p_cache.type &&
- transform==p_cache.transform &&
- color==p_cache.color &&
- energy==p_cache.energy &&
- radius==p_cache.radius &&
- attenuation==p_cache.attenuation &&
- spot_angle==p_cache.spot_angle &&
- spot_attenuation==p_cache.spot_attenuation);
+ return (type == p_cache.type &&
+ transform == p_cache.transform &&
+ color == p_cache.color &&
+ energy == p_cache.energy &&
+ radius == p_cache.radius &&
+ attenuation == p_cache.attenuation &&
+ spot_angle == p_cache.spot_angle &&
+ spot_attenuation == p_cache.spot_attenuation);
}
LightCache() {
- type=VS::LIGHT_DIRECTIONAL;
- energy=1.0;
- radius=1.0;
- attenuation=1.0;
- spot_angle=1.0;
- spot_attenuation=1.0;
-
+ type = VS::LIGHT_DIRECTIONAL;
+ energy = 1.0;
+ radius = 1.0;
+ attenuation = 1.0;
+ spot_angle = 1.0;
+ spot_attenuation = 1.0;
}
-
};
struct LocalData {
@@ -456,11 +431,10 @@ public:
uint8_t alpha[8]; //alpha block is pre-computed
};
-
struct Dynamic {
- Map<RID,LightCache> light_cache;
- Map<RID,LightCache> light_cache_changes;
+ Map<RID, LightCache> light_cache;
+ Map<RID, LightCache> light_cache_changes;
PoolVector<int> light_data;
PoolVector<LocalData> local_data;
Vector<Vector<uint32_t> > level_cell_lists;
@@ -469,8 +443,8 @@ public:
int bake_dynamic_range;
RasterizerStorage::GIProbeCompression compression;
- Vector< PoolVector<uint8_t> > mipmaps_3d;
- Vector< PoolVector<CompBlockS3TC> > mipmaps_s3tc; //for s3tc
+ Vector<PoolVector<uint8_t> > mipmaps_3d;
+ Vector<PoolVector<CompBlockS3TC> > mipmaps_s3tc; //for s3tc
int updating_stage;
float propagate;
@@ -481,26 +455,22 @@ public:
} dynamic;
-
RID probe_instance;
-
bool invalid;
uint32_t base_version;
SelfList<InstanceGIProbeData> update_element;
- InstanceGIProbeData() : update_element(this) {
- invalid=true;
- base_version=0;
+ InstanceGIProbeData()
+ : update_element(this) {
+ invalid = true;
+ base_version = 0;
}
-
};
-
SelfList<InstanceGIProbeData>::List gi_probe_update_list;
-
Instance *instance_cull_result[MAX_INSTANCE_CULL];
Instance *instance_shadow_cull_result[MAX_INSTANCE_CULL]; //used for generating shadowmaps
Instance *light_cull_result[MAX_LIGHTS_CULLED];
@@ -509,53 +479,47 @@ public:
RID reflection_probe_instance_cull_result[MAX_REFLECTION_PROBES_CULLED];
int reflection_probe_cull_count;
-
RID_Owner<Instance> instance_owner;
- // from can be mesh, light, area and portal so far.
+ // from can be mesh, light, area and portal so far.
virtual RID instance_create(); // from can be mesh, light, poly, area and portal so far.
virtual void instance_set_base(RID p_instance, RID p_base); // from can be mesh, light, poly, area and portal so far.
virtual void instance_set_scenario(RID p_instance, RID p_scenario); // from can be mesh, light, poly, area and portal so far.
virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask);
- virtual void instance_set_transform(RID p_instance, const Transform& p_transform);
- virtual void instance_attach_object_instance_ID(RID p_instance,ObjectID p_ID);
- virtual void instance_set_blend_shape_weight(RID p_instance,int p_shape, float p_weight);
- virtual void instance_set_surface_material(RID p_instance,int p_surface, RID p_material);
- virtual void instance_set_visible(RID p_instance,bool p_visible);
-
+ virtual void instance_set_transform(RID p_instance, const Transform &p_transform);
+ virtual void instance_attach_object_instance_ID(RID p_instance, ObjectID p_ID);
+ virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight);
+ virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material);
+ virtual void instance_set_visible(RID p_instance, bool p_visible);
- virtual void instance_attach_skeleton(RID p_instance,RID p_skeleton);
- virtual void instance_set_exterior( RID p_instance, bool p_enabled );
- virtual void instance_set_room( RID p_instance, RID p_room );
-
- virtual void instance_set_extra_visibility_margin( RID p_instance, real_t p_margin );
+ virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton);
+ virtual void instance_set_exterior(RID p_instance, bool p_enabled);
+ virtual void instance_set_room(RID p_instance, RID p_room);
+ virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin);
// don't use these in a game!
- virtual Vector<ObjectID> instances_cull_aabb(const Rect3& p_aabb, RID p_scenario=RID()) const;
- virtual Vector<ObjectID> instances_cull_ray(const Vector3& p_from, const Vector3& p_to, RID p_scenario=RID()) const;
- virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane>& p_convex, RID p_scenario=RID()) const;
-
+ virtual Vector<ObjectID> instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario = RID()) const;
+ virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const;
+ virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const;
- virtual void instance_geometry_set_flag(RID p_instance,VS::InstanceFlags p_flags,bool p_enabled);
+ virtual void instance_geometry_set_flag(RID p_instance, VS::InstanceFlags p_flags, bool p_enabled);
virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting);
virtual void instance_geometry_set_material_override(RID p_instance, RID p_material);
-
- virtual void instance_geometry_set_draw_range(RID p_instance,float p_min,float p_max,float p_min_margin,float p_max_margin);
- virtual void instance_geometry_set_as_instance_lod(RID p_instance,RID p_as_lod_of_instance);
-
+ virtual void instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin);
+ virtual void instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance);
_FORCE_INLINE_ void _update_instance(Instance *p_instance);
_FORCE_INLINE_ void _update_instance_aabb(Instance *p_instance);
_FORCE_INLINE_ void _update_dirty_instance(Instance *p_instance);
- _FORCE_INLINE_ void _light_instance_update_shadow(Instance *p_instance,const Transform p_cam_transform,const CameraMatrix& p_cam_projection,bool p_cam_orthogonal,RID p_shadow_atlas,Scenario* p_scenario);
+ _FORCE_INLINE_ void _light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario);
- void _render_scene(const Transform p_cam_transform, const CameraMatrix& p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
+ void _render_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
- void render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
+ void render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
void update_dirty_instances();
//probes
@@ -570,7 +534,6 @@ public:
uint32_t leaf_cell_count;
};
-
struct GIProbeDataCell {
uint32_t children[8];
@@ -587,27 +550,26 @@ public:
};
void _gi_probe_bake_thread();
- static void _gi_probe_bake_threads(void*);
+ static void _gi_probe_bake_threads(void *);
volatile bool probe_bake_thread_exit;
Thread *probe_bake_thread;
Semaphore *probe_bake_sem;
Mutex *probe_bake_mutex;
- List<Instance*> probe_bake_list;
+ List<Instance *> probe_bake_list;
- bool _render_reflection_probe_step(Instance* p_instance,int p_step);
- void _gi_probe_fill_local_data(int p_idx,int p_level,int p_x,int p_y,int p_z,const GIProbeDataCell* p_cell,const GIProbeDataHeader *p_header,InstanceGIProbeData::LocalData *p_local_data,Vector<uint32_t> *prev_cell);
+ bool _render_reflection_probe_step(Instance *p_instance, int p_step);
+ void _gi_probe_fill_local_data(int p_idx, int p_level, int p_x, int p_y, int p_z, const GIProbeDataCell *p_cell, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, Vector<uint32_t> *prev_cell);
- _FORCE_INLINE_ uint32_t _gi_bake_find_cell(const GIProbeDataCell *cells,int x,int y, int z,int p_cell_subdiv);
- void _bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, float p_propagate);
- void _bake_gi_probe_light(const GIProbeDataHeader *header,const GIProbeDataCell *cells,InstanceGIProbeData::LocalData *local_data,const uint32_t *leaves,int p_leaf_count, const InstanceGIProbeData::LightCache& light_cache,int p_sign);
+ _FORCE_INLINE_ uint32_t _gi_bake_find_cell(const GIProbeDataCell *cells, int x, int y, int z, int p_cell_subdiv);
+ void _bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell *p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, float p_propagate);
+ void _bake_gi_probe_light(const GIProbeDataHeader *header, const GIProbeDataCell *cells, InstanceGIProbeData::LocalData *local_data, const uint32_t *leaves, int p_leaf_count, const InstanceGIProbeData::LightCache &light_cache, int p_sign);
void _bake_gi_probe(Instance *p_probe);
bool _check_gi_probe(Instance *p_gi_probe);
void _setup_gi_probe(Instance *p_instance);
void render_probes();
-
bool free(RID p_rid);
VisualServerScene();
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp
index a88fb69e93..7b8a725c5a 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/visual/visual_server_viewport.cpp
@@ -27,16 +27,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_server_viewport.h"
-#include "visual_server_global.h"
+#include "global_config.h"
#include "visual_server_canvas.h"
+#include "visual_server_global.h"
#include "visual_server_scene.h"
-#include "global_config.h"
-
-
void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
- /* Camera should always be BEFORE any other 3D */
+/* Camera should always be BEFORE any other 3D */
#if 0
bool scenario_draw_canvas_bg=false;
int scenario_canvas_max_layer=0;
@@ -82,126 +80,117 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
}
#endif
- if (p_viewport->clear_mode!=VS::VIEWPORT_CLEAR_NEVER) {
+ if (p_viewport->clear_mode != VS::VIEWPORT_CLEAR_NEVER) {
VSG::rasterizer->clear_render_target(clear_color);
- if (p_viewport->clear_mode==VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
- p_viewport->clear_mode=VS::VIEWPORT_CLEAR_NEVER;
+ if (p_viewport->clear_mode == VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
+ p_viewport->clear_mode = VS::VIEWPORT_CLEAR_NEVER;
}
}
-
if (!p_viewport->disable_3d && p_viewport->camera.is_valid()) {
- VSG::scene->render_camera(p_viewport->camera,p_viewport->scenario,p_viewport->size,p_viewport->shadow_atlas);
+ VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
}
if (!p_viewport->hide_canvas) {
- int i=0;
+ int i = 0;
- Map<Viewport::CanvasKey,Viewport::CanvasData*> canvas_map;
+ Map<Viewport::CanvasKey, Viewport::CanvasData *> canvas_map;
- Rect2 clip_rect(0,0,p_viewport->size.x,p_viewport->size.y);
- RasterizerCanvas::Light *lights=NULL;
- RasterizerCanvas::Light *lights_with_shadow=NULL;
- RasterizerCanvas::Light *lights_with_mask=NULL;
+ Rect2 clip_rect(0, 0, p_viewport->size.x, p_viewport->size.y);
+ RasterizerCanvas::Light *lights = NULL;
+ RasterizerCanvas::Light *lights_with_shadow = NULL;
+ RasterizerCanvas::Light *lights_with_mask = NULL;
Rect2 shadow_rect;
- int light_count=0;
+ int light_count = 0;
- for (Map<RID,Viewport::CanvasData>::Element *E=p_viewport->canvas_map.front();E;E=E->next()) {
+ for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
Transform2D xf = p_viewport->global_transform * E->get().transform;
- VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas*>(E->get().canvas);
+ VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get().canvas);
//find lights in canvas
+ for (Set<RasterizerCanvas::Light *>::Element *F = canvas->lights.front(); F; F = F->next()) {
- for(Set<RasterizerCanvas::Light*>::Element *F=canvas->lights.front();F;F=F->next()) {
-
-
- RasterizerCanvas::Light* cl=F->get();
+ RasterizerCanvas::Light *cl = F->get();
if (cl->enabled && cl->texture.is_valid()) {
//not super efficient..
- Size2 tsize(VSG::storage->texture_get_width(cl->texture),VSG::storage->texture_get_height(cl->texture));
- tsize*=cl->scale;
+ Size2 tsize(VSG::storage->texture_get_width(cl->texture), VSG::storage->texture_get_height(cl->texture));
+ tsize *= cl->scale;
- Vector2 offset=tsize/2.0;
- cl->rect_cache=Rect2(-offset+cl->texture_offset,tsize);
- cl->xform_cache=xf * cl->xform;
+ Vector2 offset = tsize / 2.0;
+ cl->rect_cache = Rect2(-offset + cl->texture_offset, tsize);
+ cl->xform_cache = xf * cl->xform;
+ if (clip_rect.intersects_transformed(cl->xform_cache, cl->rect_cache)) {
- if (clip_rect.intersects_transformed(cl->xform_cache,cl->rect_cache)) {
-
- cl->filter_next_ptr=lights;
- lights=cl;
- cl->texture_cache=NULL;
+ cl->filter_next_ptr = lights;
+ lights = cl;
+ cl->texture_cache = NULL;
Transform2D scale;
scale.scale(cl->rect_cache.size);
- scale.elements[2]=cl->rect_cache.pos;
+ scale.elements[2] = cl->rect_cache.pos;
cl->light_shader_xform = (cl->xform_cache * scale).affine_inverse();
- cl->light_shader_pos=cl->xform_cache[2];
+ cl->light_shader_pos = cl->xform_cache[2];
if (cl->shadow_buffer.is_valid()) {
- cl->shadows_next_ptr=lights_with_shadow;
- if (lights_with_shadow==NULL) {
+ cl->shadows_next_ptr = lights_with_shadow;
+ if (lights_with_shadow == NULL) {
shadow_rect = cl->xform_cache.xform(cl->rect_cache);
} else {
- shadow_rect=shadow_rect.merge( cl->xform_cache.xform(cl->rect_cache) );
+ shadow_rect = shadow_rect.merge(cl->xform_cache.xform(cl->rect_cache));
}
- lights_with_shadow=cl;
- cl->radius_cache=cl->rect_cache.size.length();
-
+ lights_with_shadow = cl;
+ cl->radius_cache = cl->rect_cache.size.length();
}
- if (cl->mode==VS::CANVAS_LIGHT_MODE_MASK) {
- cl->mask_next_ptr=lights_with_mask;
- lights_with_mask=cl;
+ if (cl->mode == VS::CANVAS_LIGHT_MODE_MASK) {
+ cl->mask_next_ptr = lights_with_mask;
+ lights_with_mask = cl;
}
light_count++;
}
- VSG::canvas_render->light_internal_update(cl->light_internal,cl);
-
+ VSG::canvas_render->light_internal_update(cl->light_internal, cl);
}
}
//print_line("lights: "+itos(light_count));
- canvas_map[ Viewport::CanvasKey( E->key(), E->get().layer) ]=&E->get();
-
+ canvas_map[Viewport::CanvasKey(E->key(), E->get().layer)] = &E->get();
}
if (lights_with_shadow) {
//update shadows if any
- RasterizerCanvas::LightOccluderInstance * occluders=NULL;
+ RasterizerCanvas::LightOccluderInstance *occluders = NULL;
//make list of occluders
- for (Map<RID,Viewport::CanvasData>::Element *E=p_viewport->canvas_map.front();E;E=E->next()) {
+ for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
- VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas*>(E->get().canvas);
+ VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get().canvas);
Transform2D xf = p_viewport->global_transform * E->get().transform;
-
- for(Set<RasterizerCanvas::LightOccluderInstance*>::Element *F=canvas->occluders.front();F;F=F->next()) {
+ for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
if (!F->get()->enabled)
continue;
F->get()->xform_cache = xf * F->get()->xform;
- if (shadow_rect.intersects_transformed(F->get()->xform_cache,F->get()->aabb_cache)) {
-
- F->get()->next=occluders;
- occluders=F->get();
+ if (shadow_rect.intersects_transformed(F->get()->xform_cache, F->get()->aabb_cache)) {
+ F->get()->next = occluders;
+ occluders = F->get();
}
}
}
//update the light shadowmaps with them
- RasterizerCanvas::Light *light=lights_with_shadow;
- while(light) {
+ RasterizerCanvas::Light *light = lights_with_shadow;
+ while (light) {
- VSG::canvas_render->canvas_light_shadow_buffer_update(light->shadow_buffer,light->xform_cache.affine_inverse(),light->item_mask,light->radius_cache/1000.0,light->radius_cache*1.1,occluders,&light->shadow_matrix_cache);
- light=light->shadows_next_ptr;
+ VSG::canvas_render->canvas_light_shadow_buffer_update(light->shadow_buffer, light->xform_cache.affine_inverse(), light->item_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders, &light->shadow_matrix_cache);
+ light = light->shadows_next_ptr;
}
//VSG::canvas_render->reset_canvas();
@@ -209,7 +198,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
VSG::rasterizer->restore_render_target();
-
#if 0
if (scenario_draw_canvas_bg && canvas_map.front() && canvas_map.front()->key().layer>scenario_canvas_max_layer) {
@@ -219,27 +207,26 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
}
#endif
+ for (Map<Viewport::CanvasKey, Viewport::CanvasData *>::Element *E = canvas_map.front(); E; E = E->next()) {
- for (Map<Viewport::CanvasKey,Viewport::CanvasData*>::Element *E=canvas_map.front();E;E=E->next()) {
-
- VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas*>(E->get()->canvas);
+ VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get()->canvas);
//print_line("canvas "+itos(i)+" size: "+itos(I->get()->canvas->child_items.size()));
//print_line("GT "+p_viewport->global_transform+". CT: "+E->get()->transform);
Transform2D xform = p_viewport->global_transform * E->get()->transform;
- RasterizerCanvas::Light *canvas_lights=NULL;
+ RasterizerCanvas::Light *canvas_lights = NULL;
- RasterizerCanvas::Light *ptr=lights;
- while(ptr) {
- if (E->get()->layer>=ptr->layer_min && E->get()->layer<=ptr->layer_max) {
- ptr->next_ptr=canvas_lights;
- canvas_lights=ptr;
+ RasterizerCanvas::Light *ptr = lights;
+ while (ptr) {
+ if (E->get()->layer >= ptr->layer_min && E->get()->layer <= ptr->layer_max) {
+ ptr->next_ptr = canvas_lights;
+ canvas_lights = ptr;
}
- ptr=ptr->filter_next_ptr;
+ ptr = ptr->filter_next_ptr;
}
- VSG::canvas->render_canvas( canvas,xform,canvas_lights,lights_with_mask,clip_rect );
+ VSG::canvas->render_canvas(canvas, xform, canvas_lights, lights_with_mask, clip_rect);
i++;
#if 0
if (scenario_draw_canvas_bg && E->key().layer>=scenario_canvas_max_layer) {
@@ -247,8 +234,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
scenario_draw_canvas_bg=false;
}
#endif
-
-
}
#if 0
if (scenario_draw_canvas_bg) {
@@ -259,33 +244,28 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
//VSG::canvas_render->canvas_debug_viewport_shadows(lights_with_shadow);
}
-
-
-
}
void VisualServerViewport::draw_viewports() {
//sort viewports
-
//draw viewports
- clear_color=GLOBAL_GET("rendering/viewport/default_clear_color");
-
+ clear_color = GLOBAL_GET("rendering/viewport/default_clear_color");
active_viewports.sort_custom<ViewportSort>();
- for(int i=0;i<active_viewports.size();i++) {
+ for (int i = 0; i < active_viewports.size(); i++) {
Viewport *vp = active_viewports[i];
- if (vp->update_mode==VS::VIEWPORT_UPDATE_DISABLED)
+ if (vp->update_mode == VS::VIEWPORT_UPDATE_DISABLED)
continue;
- ERR_CONTINUE( !vp->render_target.is_valid() );
+ ERR_CONTINUE(!vp->render_target.is_valid());
- bool visible = vp->viewport_to_screen_rect!=Rect2() || vp->update_mode==VS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode==VS::VIEWPORT_UPDATE_ONCE;
+ bool visible = vp->viewport_to_screen_rect != Rect2() || vp->update_mode == VS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == VS::VIEWPORT_UPDATE_ONCE;
if (!visible)
continue;
@@ -293,177 +273,161 @@ void VisualServerViewport::draw_viewports() {
VSG::rasterizer->set_current_render_target(vp->render_target);
_draw_viewport(vp);
- if (vp->viewport_to_screen_rect!=Rect2()) {
+ if (vp->viewport_to_screen_rect != Rect2()) {
//copy to screen if set as such
VSG::rasterizer->set_current_render_target(RID());
- VSG::rasterizer->blit_render_target_to_screen(vp->render_target,vp->viewport_to_screen_rect,vp->viewport_to_screen);
+ VSG::rasterizer->blit_render_target_to_screen(vp->render_target, vp->viewport_to_screen_rect, vp->viewport_to_screen);
}
- if (vp->update_mode==VS::VIEWPORT_UPDATE_ONCE) {
- vp->update_mode=VS::VIEWPORT_UPDATE_DISABLED;
+ if (vp->update_mode == VS::VIEWPORT_UPDATE_ONCE) {
+ vp->update_mode = VS::VIEWPORT_UPDATE_DISABLED;
}
}
}
-
RID VisualServerViewport::viewport_create() {
- Viewport * viewport = memnew( Viewport );
+ Viewport *viewport = memnew(Viewport);
RID rid = viewport_owner.make_rid(viewport);
- viewport->self=rid;
- viewport->hide_scenario=false;
- viewport->hide_canvas=false;
- viewport->render_target=VSG::storage->render_target_create();
- viewport->shadow_atlas=VSG::scene_render->shadow_atlas_create();
+ viewport->self = rid;
+ viewport->hide_scenario = false;
+ viewport->hide_canvas = false;
+ viewport->render_target = VSG::storage->render_target_create();
+ viewport->shadow_atlas = VSG::scene_render->shadow_atlas_create();
return rid;
-
}
-void VisualServerViewport::viewport_set_size(RID p_viewport,int p_width,int p_height){
+void VisualServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
- ERR_FAIL_COND(p_width<0 && p_height<0);
+ ERR_FAIL_COND(p_width < 0 && p_height < 0);
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
-
-
- viewport->size=Size2(p_width,p_height);
- VSG::storage->render_target_set_size(viewport->render_target,p_width,p_height);
-
-
+ viewport->size = Size2(p_width, p_height);
+ VSG::storage->render_target_set_size(viewport->render_target, p_width, p_height);
}
-void VisualServerViewport::viewport_set_active(RID p_viewport,bool p_active) {
+void VisualServerViewport::viewport_set_active(RID p_viewport, bool p_active) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
if (p_active) {
- ERR_FAIL_COND(active_viewports.find(viewport)!=-1);//already active
+ ERR_FAIL_COND(active_viewports.find(viewport) != -1); //already active
active_viewports.push_back(viewport);
} else {
active_viewports.erase(viewport);
}
-
-
}
-void VisualServerViewport::viewport_set_parent_viewport(RID p_viewport,RID p_parent_viewport) {
+void VisualServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->parent=p_parent_viewport;
+ viewport->parent = p_parent_viewport;
}
-void VisualServerViewport::viewport_set_clear_mode(RID p_viewport,VS::ViewportClearMode p_clear_mode) {
+void VisualServerViewport::viewport_set_clear_mode(RID p_viewport, VS::ViewportClearMode p_clear_mode) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->clear_mode=p_clear_mode;
-
+ viewport->clear_mode = p_clear_mode;
}
+void VisualServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, int p_screen) {
-void VisualServerViewport::viewport_attach_to_screen(RID p_viewport,const Rect2& p_rect,int p_screen){
-
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->viewport_to_screen_rect=p_rect;
- viewport->viewport_to_screen=p_screen;
+ viewport->viewport_to_screen_rect = p_rect;
+ viewport->viewport_to_screen = p_screen;
}
-void VisualServerViewport::viewport_detach(RID p_viewport){
+void VisualServerViewport::viewport_detach(RID p_viewport) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->viewport_to_screen_rect=Rect2();
- viewport->viewport_to_screen=0;
-
+ viewport->viewport_to_screen_rect = Rect2();
+ viewport->viewport_to_screen = 0;
}
-void VisualServerViewport::viewport_set_update_mode(RID p_viewport,VS::ViewportUpdateMode p_mode){
+void VisualServerViewport::viewport_set_update_mode(RID p_viewport, VS::ViewportUpdateMode p_mode) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->update_mode=p_mode;
-
+ viewport->update_mode = p_mode;
}
-void VisualServerViewport::viewport_set_vflip(RID p_viewport,bool p_enable){
+void VisualServerViewport::viewport_set_vflip(RID p_viewport, bool p_enable) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- VSG::storage->render_target_set_flag(viewport->render_target,RasterizerStorage::RENDER_TARGET_VFLIP,p_enable);
-
+ VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_VFLIP, p_enable);
}
-RID VisualServerViewport::viewport_get_texture(RID p_viewport) const{
+RID VisualServerViewport::viewport_get_texture(RID p_viewport) const {
- const Viewport * viewport = viewport_owner.getornull(p_viewport);
- ERR_FAIL_COND_V(!viewport,RID());
+ const Viewport *viewport = viewport_owner.getornull(p_viewport);
+ ERR_FAIL_COND_V(!viewport, RID());
return VSG::storage->render_target_get_texture(viewport->render_target);
-
}
-void VisualServerViewport::viewport_set_hide_scenario(RID p_viewport,bool p_hide){
+void VisualServerViewport::viewport_set_hide_scenario(RID p_viewport, bool p_hide) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->hide_scenario=p_hide;
+ viewport->hide_scenario = p_hide;
}
-void VisualServerViewport::viewport_set_hide_canvas(RID p_viewport,bool p_hide){
+void VisualServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->hide_canvas=p_hide;
+ viewport->hide_canvas = p_hide;
}
-void VisualServerViewport::viewport_set_disable_environment(RID p_viewport,bool p_disable){
+void VisualServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
-
- viewport->disable_environment=p_disable;
+ viewport->disable_environment = p_disable;
}
-void VisualServerViewport::viewport_set_disable_3d(RID p_viewport,bool p_disable){
+void VisualServerViewport::viewport_set_disable_3d(RID p_viewport, bool p_disable) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
-
- viewport->disable_3d=p_disable;
- VSG::storage->render_target_set_flag(viewport->render_target,RasterizerStorage::RENDER_TARGET_NO_3D,p_disable);
+ viewport->disable_3d = p_disable;
+ VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D, p_disable);
}
-void VisualServerViewport::viewport_attach_camera(RID p_viewport,RID p_camera){
+void VisualServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->camera=p_camera;
+ viewport->camera = p_camera;
}
-void VisualServerViewport::viewport_set_scenario(RID p_viewport,RID p_scenario){
+void VisualServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->scenario=p_scenario;
+ viewport->scenario = p_scenario;
}
-void VisualServerViewport::viewport_attach_canvas(RID p_viewport,RID p_canvas){
+void VisualServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(viewport->canvas_map.has(p_canvas));
@@ -471,15 +435,14 @@ void VisualServerViewport::viewport_attach_canvas(RID p_viewport,RID p_canvas){
ERR_FAIL_COND(!canvas);
canvas->viewports.insert(p_viewport);
- viewport->canvas_map[p_canvas]=Viewport::CanvasData();
- viewport->canvas_map[p_canvas].layer=0;
- viewport->canvas_map[p_canvas].canvas=canvas;
-
+ viewport->canvas_map[p_canvas] = Viewport::CanvasData();
+ viewport->canvas_map[p_canvas].layer = 0;
+ viewport->canvas_map[p_canvas].canvas = canvas;
}
-void VisualServerViewport::viewport_remove_canvas(RID p_viewport,RID p_canvas){
+void VisualServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
VisualServerCanvas::Canvas *canvas = VSG::canvas->canvas_owner.getornull(p_canvas);
@@ -487,110 +450,97 @@ void VisualServerViewport::viewport_remove_canvas(RID p_viewport,RID p_canvas){
viewport->canvas_map.erase(p_canvas);
canvas->viewports.erase(p_viewport);
-
}
-void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Transform2D& p_offset){
+void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
- viewport->canvas_map[p_canvas].transform=p_offset;
-
+ viewport->canvas_map[p_canvas].transform = p_offset;
}
-void VisualServerViewport::viewport_set_transparent_background(RID p_viewport,bool p_enabled){
+void VisualServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- VSG::storage->render_target_set_flag(viewport->render_target,RasterizerStorage::RENDER_TARGET_TRANSPARENT,p_enabled);
-
+ VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_TRANSPARENT, p_enabled);
}
-void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport,const Transform2D& p_transform){
+void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->global_transform=p_transform;
-
+ viewport->global_transform = p_transform;
}
-void VisualServerViewport::viewport_set_canvas_layer(RID p_viewport,RID p_canvas,int p_layer){
+void VisualServerViewport::viewport_set_canvas_layer(RID p_viewport, RID p_canvas, int p_layer) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
- viewport->canvas_map[p_canvas].layer=p_layer;
-
+ viewport->canvas_map[p_canvas].layer = p_layer;
}
-void VisualServerViewport::viewport_set_shadow_atlas_size(RID p_viewport,int p_size) {
+void VisualServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- viewport->shadow_atlas_size=p_size;
-
- VSG::scene_render->shadow_atlas_set_size( viewport->shadow_atlas, viewport->shadow_atlas_size);
+ viewport->shadow_atlas_size = p_size;
+ VSG::scene_render->shadow_atlas_set_size(viewport->shadow_atlas, viewport->shadow_atlas_size);
}
-void VisualServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport,int p_quadrant,int p_subdiv) {
+void VisualServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision( viewport->shadow_atlas, p_quadrant, p_subdiv);
-
+ VSG::scene_render->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
}
-void VisualServerViewport::viewport_set_msaa(RID p_viewport,VS::ViewportMSAA p_msaa) {
+void VisualServerViewport::viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_msaa) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- VSG::storage->render_target_set_msaa(viewport->render_target,p_msaa);
+ VSG::storage->render_target_set_msaa(viewport->render_target, p_msaa);
}
-void VisualServerViewport::viewport_set_hdr(RID p_viewport,bool p_enabled) {
+void VisualServerViewport::viewport_set_hdr(RID p_viewport, bool p_enabled) {
- Viewport * viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- VSG::storage->render_target_set_flag(viewport->render_target,RasterizerStorage::RENDER_TARGET_HDR,p_enabled);
-
+ VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_HDR, p_enabled);
}
bool VisualServerViewport::free(RID p_rid) {
if (viewport_owner.owns(p_rid)) {
- Viewport * viewport = viewport_owner.getornull(p_rid);
-
+ Viewport *viewport = viewport_owner.getornull(p_rid);
- VSG::storage->free( viewport->render_target );
- VSG::scene_render->free( viewport->shadow_atlas );
+ VSG::storage->free(viewport->render_target);
+ VSG::scene_render->free(viewport->shadow_atlas);
- while(viewport->canvas_map.front()) {
- viewport_remove_canvas(p_rid,viewport->canvas_map.front()->key());
+ while (viewport->canvas_map.front()) {
+ viewport_remove_canvas(p_rid, viewport->canvas_map.front()->key());
}
- viewport_set_scenario(p_rid,RID());
+ viewport_set_scenario(p_rid, RID());
active_viewports.erase(viewport);
viewport_owner.free(p_rid);
memdelete(viewport);
-
return true;
}
return false;
-
}
-VisualServerViewport::VisualServerViewport()
-{
-
+VisualServerViewport::VisualServerViewport() {
}
diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h
index 1cee90b803..53ad6bde2b 100644
--- a/servers/visual/visual_server_viewport.h
+++ b/servers/visual/visual_server_viewport.h
@@ -29,20 +29,15 @@
#ifndef VISUALSERVERVIEWPORT_H
#define VISUALSERVERVIEWPORT_H
-#include "servers/visual_server.h"
#include "rasterizer.h"
#include "self_list.h"
+#include "servers/visual_server.h"
-class VisualServerViewport {
+class VisualServerViewport {
public:
-
struct CanvasBase : public RID_Data {
-
-
};
-
-
struct Viewport : public RID_Data {
RID self;
@@ -67,7 +62,6 @@ public:
RID shadow_atlas;
int shadow_atlas_size;
-
VS::ViewportClearMode clear_mode;
bool rendered_in_prev_frame;
@@ -76,9 +70,15 @@ public:
int layer;
RID canvas;
- bool operator<(const CanvasKey& p_canvas) const { if (layer==p_canvas.layer) return canvas < p_canvas.canvas; return layer<p_canvas.layer; }
- CanvasKey() { layer=0; }
- CanvasKey(const RID& p_canvas, int p_layer) { canvas=p_canvas; layer=p_layer; }
+ bool operator<(const CanvasKey &p_canvas) const {
+ if (layer == p_canvas.layer) return canvas < p_canvas.canvas;
+ return layer < p_canvas.layer;
+ }
+ CanvasKey() { layer = 0; }
+ CanvasKey(const RID &p_canvas, int p_layer) {
+ canvas = p_canvas;
+ layer = p_layer;
+ }
};
struct CanvasData {
@@ -90,83 +90,79 @@ public:
Transform2D global_transform;
- Map<RID,CanvasData> canvas_map;
+ Map<RID, CanvasData> canvas_map;
Viewport() {
- update_mode=VS::VIEWPORT_UPDATE_WHEN_VISIBLE;
- clear_mode=VS::VIEWPORT_CLEAR_ALWAYS;
- rendered_in_prev_frame=false;
- disable_environment=false;
- viewport_to_screen=0;
- shadow_atlas_size=0;
- disable_3d=false;
-
+ update_mode = VS::VIEWPORT_UPDATE_WHEN_VISIBLE;
+ clear_mode = VS::VIEWPORT_CLEAR_ALWAYS;
+ rendered_in_prev_frame = false;
+ disable_environment = false;
+ viewport_to_screen = 0;
+ shadow_atlas_size = 0;
+ disable_3d = false;
}
};
mutable RID_Owner<Viewport> viewport_owner;
-
struct ViewportSort {
- _FORCE_INLINE_ bool operator()(const Viewport*p_left,const Viewport* p_right) const {
+ _FORCE_INLINE_ bool operator()(const Viewport *p_left, const Viewport *p_right) const {
- bool left_to_screen = p_left->viewport_to_screen_rect.size!=Size2();
- bool right_to_screen = p_right->viewport_to_screen_rect.size!=Size2();
+ bool left_to_screen = p_left->viewport_to_screen_rect.size != Size2();
+ bool right_to_screen = p_right->viewport_to_screen_rect.size != Size2();
- if (left_to_screen==right_to_screen) {
+ if (left_to_screen == right_to_screen) {
- return p_left->parent==p_right->self;
+ return p_left->parent == p_right->self;
} else {
return right_to_screen;
}
}
};
+ Vector<Viewport *> active_viewports;
- Vector<Viewport*> active_viewports;
private:
Color clear_color;
void _draw_viewport(Viewport *p_viewport);
-public:
-
+public:
RID viewport_create();
- void viewport_set_size(RID p_viewport,int p_width,int p_height);
+ void viewport_set_size(RID p_viewport, int p_width, int p_height);
- void viewport_attach_to_screen(RID p_viewport,const Rect2& p_rect=Rect2(),int p_screen=0);
+ void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), int p_screen = 0);
void viewport_detach(RID p_viewport);
- void viewport_set_active(RID p_viewport,bool p_active);
- void viewport_set_parent_viewport(RID p_viewport,RID p_parent_viewport);
- void viewport_set_update_mode(RID p_viewport,VS::ViewportUpdateMode p_mode);
- void viewport_set_vflip(RID p_viewport,bool p_enable);
-
+ void viewport_set_active(RID p_viewport, bool p_active);
+ void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport);
+ void viewport_set_update_mode(RID p_viewport, VS::ViewportUpdateMode p_mode);
+ void viewport_set_vflip(RID p_viewport, bool p_enable);
- void viewport_set_clear_mode(RID p_viewport,VS::ViewportClearMode p_clear_mode);
+ void viewport_set_clear_mode(RID p_viewport, VS::ViewportClearMode p_clear_mode);
RID viewport_get_texture(RID p_viewport) const;
- void viewport_set_hide_scenario(RID p_viewport,bool p_hide);
- void viewport_set_hide_canvas(RID p_viewport,bool p_hide);
- void viewport_set_disable_environment(RID p_viewport,bool p_disable);
- void viewport_set_disable_3d(RID p_viewport,bool p_disable);
+ void viewport_set_hide_scenario(RID p_viewport, bool p_hide);
+ void viewport_set_hide_canvas(RID p_viewport, bool p_hide);
+ void viewport_set_disable_environment(RID p_viewport, bool p_disable);
+ void viewport_set_disable_3d(RID p_viewport, bool p_disable);
- void viewport_attach_camera(RID p_viewport,RID p_camera);
- void viewport_set_scenario(RID p_viewport,RID p_scenario);
- void viewport_attach_canvas(RID p_viewport,RID p_canvas);
- void viewport_remove_canvas(RID p_viewport,RID p_canvas);
- void viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Transform2D& p_offset);
- void viewport_set_transparent_background(RID p_viewport,bool p_enabled);
+ void viewport_attach_camera(RID p_viewport, RID p_camera);
+ void viewport_set_scenario(RID p_viewport, RID p_scenario);
+ void viewport_attach_canvas(RID p_viewport, RID p_canvas);
+ void viewport_remove_canvas(RID p_viewport, RID p_canvas);
+ void viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset);
+ void viewport_set_transparent_background(RID p_viewport, bool p_enabled);
- void viewport_set_global_canvas_transform(RID p_viewport,const Transform2D& p_transform);
- void viewport_set_canvas_layer(RID p_viewport,RID p_canvas,int p_layer);
+ void viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform);
+ void viewport_set_canvas_layer(RID p_viewport, RID p_canvas, int p_layer);
- void viewport_set_shadow_atlas_size(RID p_viewport,int p_size);
- void viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport,int p_quadrant,int p_subdiv);
+ void viewport_set_shadow_atlas_size(RID p_viewport, int p_size);
+ void viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv);
- void viewport_set_msaa(RID p_viewport,VS::ViewportMSAA p_msaa);
- void viewport_set_hdr(RID p_viewport,bool p_enabled);
+ void viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_msaa);
+ void viewport_set_hdr(RID p_viewport, bool p_enabled);
void draw_viewports();