More cleanups.

This commit is contained in:
Relintai 2023-12-15 11:09:40 +01:00
parent 88b9952ce0
commit 2703102a81
18 changed files with 0 additions and 8049 deletions

View File

@ -34,9 +34,7 @@
#include "core/os/os.h"
#include "core/containers/fixed_array.h"
#include "core/math/transform_interpolator.h"
#include "scene/main/canvas_item.h"
#include "scene/resources/material/particles_material.h"
#include "scene/resources/texture.h"
#include "servers/rendering_server.h"

View File

@ -47,7 +47,6 @@
#include "scene/main/control.h"
#include "scene/resources/font/dynamic_font.h"
#include "scene/resources/material/material.h"
#include "scene/resources/material/spatial_material.h"
#include "scene/resources/material/shader_material.h"
#include "scene/resources/mesh/mesh.h"
#include "scene/resources/packed_scene.h"
@ -988,15 +987,6 @@ Ref<Material> SceneTree::get_debug_paths_material() {
return debug_paths_material;
}
Ref<SpatialMaterial> _debug_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
_debug_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
_debug_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
_debug_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
_debug_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
_debug_material->set_albedo(get_debug_paths_color());
debug_paths_material = _debug_material;
return debug_paths_material;
}
@ -1007,15 +997,6 @@ Ref<Material> SceneTree::get_debug_collision_material() {
return collision_material;
}
Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
line_material->set_albedo(get_debug_collisions_color());
collision_material = line_material;
return collision_material;
}
@ -1028,13 +1009,6 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
debug_contact_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
Ref<SpatialMaterial> mat = Ref<SpatialMaterial>(memnew(SpatialMaterial));
mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
mat->set_albedo(get_debug_collision_contact_color());
Vector3 diamond[6] = {
Vector3(-1, 0, 0),
Vector3(1, 0, 0),
@ -1073,7 +1047,6 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
arr[Mesh::ARRAY_INDEX] = indices;
debug_contact_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arr);
debug_contact_mesh->surface_set_material(0, mat);
return debug_contact_mesh;
}

View File

@ -146,7 +146,6 @@
#include "scene/resources/mesh/immediate_mesh.h"
#include "scene/resources/shapes_2d/line_shape_2d.h"
#include "scene/resources/material/material.h"
#include "scene/resources/material/spatial_material.h"
#include "scene/resources/material/shader_material.h"
#include "scene/resources/mesh/mesh.h"
#include "scene/resources/mesh/mesh_data_tool.h"
@ -155,16 +154,12 @@
#include "scene/resources/navigation_2d/navigation_mesh_source_geometry_data_2d.h"
#include "scene/resources/navigation_2d/navigation_polygon.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/material/particles_material.h"
#include "scene/resources/mesh/polygon_path_finder.h"
#include "scene/resources/mesh/primitive_meshes.h"
#include "scene/resources/shapes_2d/rectangle_shape_2d.h"
#include "scene/resources/resource_format_text.h"
#include "scene/resources/shapes_2d/segment_shape_2d.h"
#include "scene/resources/physics_material.h"
#include "scene/resources/sky.h"
#include "scene/resources/mesh/surface_tool.h"
#include "scene/gui/resources/syntax_highlighter.h"
#include "scene/resources/text_file.h"
@ -442,9 +437,6 @@ void register_scene_types() {
/* REGISTER RESOURCES */
ClassDB::register_virtual_class<Shader>();
ClassDB::register_class<ParticlesMaterial>();
SceneTree::add_idle_callback(ParticlesMaterial::flush_changes);
ParticlesMaterial::init_shaders();
ClassDB::register_virtual_class<Mesh>();
ClassDB::register_class<ArrayMesh>();
@ -465,9 +457,6 @@ void register_scene_types() {
ClassDB::register_class<TextMesh>();
ClassDB::register_class<PointMesh>();
ClassDB::register_virtual_class<Material>();
ClassDB::register_class<SpatialMaterial>();
SceneTree::add_idle_callback(SpatialMaterial::flush_changes);
SpatialMaterial::init_shaders();
OS::get_singleton()->yield(); //may take time to init
@ -475,9 +464,6 @@ void register_scene_types() {
ClassDB::register_class<PhysicsMaterial>();
ClassDB::register_class<World2D>();
ClassDB::register_virtual_class<Texture>();
ClassDB::register_virtual_class<Sky>();
ClassDB::register_class<PanoramaSky>();
ClassDB::register_class<ProceduralSky>();
ClassDB::register_class<StreamTexture>();
ClassDB::register_class<ImageTexture>();
ClassDB::register_class<AtlasTexture>();
@ -647,12 +633,6 @@ void unregister_scene_types() {
ResourceLoader::remove_resource_format_loader(resource_loader_bmfont);
resource_loader_bmfont.unref();
//SpatialMaterial is not initialised when 3D is disabled, so it shouldn't be cleaned up either
#ifndef _3D_DISABLED
SpatialMaterial::finish_shaders();
#endif // _3D_DISABLED
ParticlesMaterial::finish_shaders();
CanvasItemMaterial::finish_shaders();
SceneStringNames::free();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,422 +0,0 @@
#ifndef ENVIRONMENT_3D_H
#define ENVIRONMENT_3D_H
/*************************************************************************/
/* environment.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/object/resource.h"
class Sky;
class Texture;
class Environment3D : public Resource {
GDCLASS(Environment3D, Resource);
public:
enum BGMode {
BG_CLEAR_COLOR,
BG_COLOR,
BG_SKY,
BG_COLOR_SKY,
BG_CANVAS,
BG_KEEP,
BG_CAMERA_FEED,
BG_MAX
};
enum ToneMapper {
TONE_MAPPER_LINEAR,
TONE_MAPPER_REINHARDT,
TONE_MAPPER_FILMIC,
TONE_MAPPER_ACES,
TONE_MAPPER_ACES_FITTED
};
enum GlowBlendMode {
GLOW_BLEND_MODE_ADDITIVE,
GLOW_BLEND_MODE_SCREEN,
GLOW_BLEND_MODE_SOFTLIGHT,
GLOW_BLEND_MODE_REPLACE,
};
enum DOFBlurQuality {
DOF_BLUR_QUALITY_LOW,
DOF_BLUR_QUALITY_MEDIUM,
DOF_BLUR_QUALITY_HIGH,
};
enum SSAOBlur {
SSAO_BLUR_DISABLED,
SSAO_BLUR_1x1,
SSAO_BLUR_2x2,
SSAO_BLUR_3x3
};
enum SSAOQuality {
SSAO_QUALITY_LOW,
SSAO_QUALITY_MEDIUM,
SSAO_QUALITY_HIGH
};
private:
RID environment;
BGMode bg_mode;
Ref<Sky> bg_sky;
float bg_sky_custom_fov;
Basis bg_sky_orientation;
Color bg_color;
float bg_energy;
int bg_canvas_max_layer;
Color ambient_color;
float ambient_energy;
float ambient_sky_contribution;
ToneMapper tone_mapper;
float tonemap_exposure;
float tonemap_white;
bool tonemap_auto_exposure;
float tonemap_auto_exposure_max;
float tonemap_auto_exposure_min;
float tonemap_auto_exposure_speed;
float tonemap_auto_exposure_grey;
bool adjustment_enabled;
float adjustment_contrast;
float adjustment_saturation;
float adjustment_brightness;
Ref<Texture> adjustment_color_correction;
bool ssr_enabled;
int ssr_max_steps;
float ssr_fade_in;
float ssr_fade_out;
float ssr_depth_tolerance;
bool ssr_roughness;
bool ssao_enabled;
float ssao_radius;
float ssao_intensity;
float ssao_radius2;
float ssao_intensity2;
float ssao_bias;
float ssao_direct_light_affect;
float ssao_ao_channel_affect;
Color ssao_color;
SSAOBlur ssao_blur;
float ssao_edge_sharpness;
SSAOQuality ssao_quality;
bool glow_enabled;
int glow_levels;
float glow_intensity;
float glow_strength;
float glow_bloom;
GlowBlendMode glow_blend_mode;
float glow_hdr_bleed_threshold;
float glow_hdr_bleed_scale;
float glow_hdr_luminance_cap;
bool glow_bicubic_upscale;
bool glow_high_quality;
bool dof_blur_far_enabled;
float dof_blur_far_distance;
float dof_blur_far_transition;
float dof_blur_far_amount;
DOFBlurQuality dof_blur_far_quality;
bool dof_blur_near_enabled;
float dof_blur_near_distance;
float dof_blur_near_transition;
float dof_blur_near_amount;
DOFBlurQuality dof_blur_near_quality;
bool fog_enabled;
Color fog_color;
Color fog_sun_color;
float fog_sun_amount;
bool fog_depth_enabled;
float fog_depth_begin;
float fog_depth_end;
float fog_depth_curve;
bool fog_transmit_enabled;
float fog_transmit_curve;
bool fog_height_enabled;
float fog_height_min;
float fog_height_max;
float fog_height_curve;
protected:
static void _bind_methods();
virtual void _validate_property(PropertyInfo &property) const;
public:
void set_background(BGMode p_bg);
void set_sky(const Ref<Sky> &p_sky);
void set_sky_custom_fov(float p_scale);
void set_sky_orientation(const Basis &p_orientation);
void set_sky_rotation(const Vector3 &p_euler_rad);
void set_sky_rotation_degrees(const Vector3 &p_euler_deg);
void set_bg_color(const Color &p_color);
void set_bg_energy(float p_energy);
void set_canvas_max_layer(int p_max_layer);
void set_ambient_light_color(const Color &p_color);
void set_ambient_light_energy(float p_energy);
void set_ambient_light_sky_contribution(float p_energy);
BGMode get_background() const;
Ref<Sky> get_sky() const;
float get_sky_custom_fov() const;
Basis get_sky_orientation() const;
Vector3 get_sky_rotation() const;
Vector3 get_sky_rotation_degrees() const;
Color get_bg_color() const;
float get_bg_energy() const;
int get_canvas_max_layer() const;
Color get_ambient_light_color() const;
float get_ambient_light_energy() const;
float get_ambient_light_sky_contribution() const;
void set_tonemapper(ToneMapper p_tone_mapper);
ToneMapper get_tonemapper() const;
void set_tonemap_exposure(float p_exposure);
float get_tonemap_exposure() const;
void set_tonemap_white(float p_white);
float get_tonemap_white() const;
void set_tonemap_auto_exposure(bool p_enabled);
bool get_tonemap_auto_exposure() const;
void set_tonemap_auto_exposure_max(float p_auto_exposure_max);
float get_tonemap_auto_exposure_max() const;
void set_tonemap_auto_exposure_min(float p_auto_exposure_min);
float get_tonemap_auto_exposure_min() const;
void set_tonemap_auto_exposure_speed(float p_auto_exposure_speed);
float get_tonemap_auto_exposure_speed() const;
void set_tonemap_auto_exposure_grey(float p_auto_exposure_grey);
float get_tonemap_auto_exposure_grey() const;
void set_adjustment_enable(bool p_enable);
bool is_adjustment_enabled() const;
void set_adjustment_brightness(float p_brightness);
float get_adjustment_brightness() const;
void set_adjustment_contrast(float p_contrast);
float get_adjustment_contrast() const;
void set_adjustment_saturation(float p_saturation);
float get_adjustment_saturation() const;
void set_adjustment_color_correction(const Ref<Texture> &p_ramp);
Ref<Texture> get_adjustment_color_correction() const;
void set_ssr_enabled(bool p_enable);
bool is_ssr_enabled() const;
void set_ssr_max_steps(int p_steps);
int get_ssr_max_steps() const;
void set_ssr_fade_in(float p_fade_in);
float get_ssr_fade_in() const;
void set_ssr_fade_out(float p_fade_out);
float get_ssr_fade_out() const;
void set_ssr_depth_tolerance(float p_depth_tolerance);
float get_ssr_depth_tolerance() const;
void set_ssr_rough(bool p_enable);
bool is_ssr_rough() const;
void set_ssao_enabled(bool p_enable);
bool is_ssao_enabled() const;
void set_ssao_radius(float p_radius);
float get_ssao_radius() const;
void set_ssao_intensity(float p_intensity);
float get_ssao_intensity() const;
void set_ssao_radius2(float p_radius);
float get_ssao_radius2() const;
void set_ssao_intensity2(float p_intensity);
float get_ssao_intensity2() const;
void set_ssao_bias(float p_bias);
float get_ssao_bias() const;
void set_ssao_direct_light_affect(float p_direct_light_affect);
float get_ssao_direct_light_affect() const;
void set_ssao_ao_channel_affect(float p_ao_channel_affect);
float get_ssao_ao_channel_affect() const;
void set_ssao_color(const Color &p_color);
Color get_ssao_color() const;
void set_ssao_blur(SSAOBlur p_blur);
SSAOBlur get_ssao_blur() const;
void set_ssao_quality(SSAOQuality p_quality);
SSAOQuality get_ssao_quality() const;
void set_ssao_edge_sharpness(float p_edge_sharpness);
float get_ssao_edge_sharpness() const;
void set_glow_enabled(bool p_enabled);
bool is_glow_enabled() const;
void set_glow_level(int p_level, bool p_enabled);
bool is_glow_level_enabled(int p_level) const;
void set_glow_intensity(float p_intensity);
float get_glow_intensity() const;
void set_glow_strength(float p_strength);
float get_glow_strength() const;
void set_glow_bloom(float p_threshold);
float get_glow_bloom() const;
void set_glow_blend_mode(GlowBlendMode p_mode);
GlowBlendMode get_glow_blend_mode() const;
void set_glow_hdr_bleed_threshold(float p_threshold);
float get_glow_hdr_bleed_threshold() const;
void set_glow_hdr_luminance_cap(float p_amount);
float get_glow_hdr_luminance_cap() const;
void set_glow_hdr_bleed_scale(float p_scale);
float get_glow_hdr_bleed_scale() const;
void set_glow_bicubic_upscale(bool p_enable);
bool is_glow_bicubic_upscale_enabled() const;
void set_glow_high_quality(bool p_enable);
bool is_glow_high_quality_enabled() const;
void set_dof_blur_far_enabled(bool p_enable);
bool is_dof_blur_far_enabled() const;
void set_dof_blur_far_distance(float p_distance);
float get_dof_blur_far_distance() const;
void set_dof_blur_far_transition(float p_distance);
float get_dof_blur_far_transition() const;
void set_dof_blur_far_amount(float p_amount);
float get_dof_blur_far_amount() const;
void set_dof_blur_far_quality(DOFBlurQuality p_quality);
DOFBlurQuality get_dof_blur_far_quality() const;
void set_dof_blur_near_enabled(bool p_enable);
bool is_dof_blur_near_enabled() const;
void set_dof_blur_near_distance(float p_distance);
float get_dof_blur_near_distance() const;
void set_dof_blur_near_transition(float p_distance);
float get_dof_blur_near_transition() const;
void set_dof_blur_near_amount(float p_amount);
float get_dof_blur_near_amount() const;
void set_dof_blur_near_quality(DOFBlurQuality p_quality);
DOFBlurQuality get_dof_blur_near_quality() const;
void set_fog_enabled(bool p_enabled);
bool is_fog_enabled() const;
void set_fog_color(const Color &p_color);
Color get_fog_color() const;
void set_fog_sun_color(const Color &p_color);
Color get_fog_sun_color() const;
void set_fog_sun_amount(float p_amount);
float get_fog_sun_amount() const;
void set_fog_depth_enabled(bool p_enabled);
bool is_fog_depth_enabled() const;
void set_fog_depth_begin(float p_distance);
float get_fog_depth_begin() const;
void set_fog_depth_end(float p_distance);
float get_fog_depth_end() const;
void set_fog_depth_curve(float p_curve);
float get_fog_depth_curve() const;
void set_fog_transmit_enabled(bool p_enabled);
bool is_fog_transmit_enabled() const;
void set_fog_transmit_curve(float p_curve);
float get_fog_transmit_curve() const;
void set_fog_height_enabled(bool p_enabled);
bool is_fog_height_enabled() const;
void set_fog_height_min(float p_distance);
float get_fog_height_min() const;
void set_fog_height_max(float p_distance);
float get_fog_height_max() const;
void set_fog_height_curve(float p_distance);
float get_fog_height_curve() const;
virtual RID get_rid() const;
Environment3D();
~Environment3D();
};
VARIANT_ENUM_CAST(Environment3D::BGMode)
VARIANT_ENUM_CAST(Environment3D::ToneMapper)
VARIANT_ENUM_CAST(Environment3D::GlowBlendMode)
VARIANT_ENUM_CAST(Environment3D::DOFBlurQuality)
VARIANT_ENUM_CAST(Environment3D::SSAOQuality)
VARIANT_ENUM_CAST(Environment3D::SSAOBlur)
#endif // ENVIRONMENT_3D_H

File diff suppressed because it is too large Load Diff

View File

@ -1,338 +0,0 @@
#ifndef PARTICLES_MATERIAL_H
#define PARTICLES_MATERIAL_H
/*************************************************************************/
/* particles_material.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/containers/rid.h"
#include "scene/resources/material/material.h"
class ParticlesMaterial : public Material {
GDCLASS(ParticlesMaterial, Material);
public:
enum Parameter {
PARAM_INITIAL_LINEAR_VELOCITY,
PARAM_ANGULAR_VELOCITY,
PARAM_ORBIT_VELOCITY,
PARAM_LINEAR_ACCEL,
PARAM_RADIAL_ACCEL,
PARAM_TANGENTIAL_ACCEL,
PARAM_DAMPING,
PARAM_ANGLE,
PARAM_SCALE,
PARAM_HUE_VARIATION,
PARAM_ANIM_SPEED,
PARAM_ANIM_OFFSET,
PARAM_MAX
};
// When extending, make sure not to overflow the size of the MaterialKey below.
enum Flags {
FLAG_ALIGN_Y_TO_VELOCITY,
FLAG_ROTATE_Y,
FLAG_DISABLE_Z,
FLAG_MAX
};
// When extending, make sure not to overflow the size of the MaterialKey below.
enum EmissionShape {
EMISSION_SHAPE_POINT,
EMISSION_SHAPE_SPHERE,
EMISSION_SHAPE_BOX,
EMISSION_SHAPE_POINTS,
EMISSION_SHAPE_DIRECTED_POINTS,
EMISSION_SHAPE_RING,
EMISSION_SHAPE_MAX
};
private:
union MaterialKey {
// The bit size of the struct must be kept below or equal to 32 bits.
// Consider this when extending Flags, or EmissionShape.
struct {
uint32_t texture_mask : 16;
uint32_t texture_color : 1;
uint32_t texture_initial_color : 1;
uint32_t flags : 4;
uint32_t emission_shape : 3;
uint32_t trail_size_texture : 1;
uint32_t trail_color_texture : 1;
uint32_t invalid_key : 1;
uint32_t has_emission_color : 1;
};
uint32_t key;
bool operator<(const MaterialKey &p_key) const {
return key < p_key.key;
}
};
struct ShaderData {
RID shader;
int users;
};
static RBMap<MaterialKey, ShaderData> shader_map;
MaterialKey current_key;
_FORCE_INLINE_ MaterialKey _compute_key() const {
MaterialKey mk;
mk.key = 0;
for (int i = 0; i < PARAM_MAX; i++) {
if (tex_parameters[i].is_valid()) {
mk.texture_mask |= (1 << i);
}
}
for (int i = 0; i < FLAG_MAX; i++) {
if (flags[i]) {
mk.flags |= (1 << i);
}
}
mk.texture_color = color_ramp.is_valid() ? 1 : 0;
mk.texture_initial_color = color_initial_ramp.is_valid() ? 1 : 0;
mk.emission_shape = emission_shape;
mk.trail_color_texture = trail_color_modifier.is_valid() ? 1 : 0;
mk.trail_size_texture = trail_size_modifier.is_valid() ? 1 : 0;
mk.has_emission_color = emission_shape >= EMISSION_SHAPE_POINTS && emission_color_texture.is_valid();
return mk;
}
static Mutex material_mutex;
static SelfList<ParticlesMaterial>::List *dirty_materials;
struct ShaderNames {
StringName direction;
StringName spread;
StringName flatness;
StringName initial_linear_velocity;
StringName initial_angle;
StringName angular_velocity;
StringName orbit_velocity;
StringName linear_accel;
StringName radial_accel;
StringName tangent_accel;
StringName damping;
StringName scale;
StringName hue_variation;
StringName anim_speed;
StringName anim_offset;
StringName initial_linear_velocity_random;
StringName initial_angle_random;
StringName angular_velocity_random;
StringName orbit_velocity_random;
StringName linear_accel_random;
StringName radial_accel_random;
StringName tangent_accel_random;
StringName damping_random;
StringName scale_random;
StringName hue_variation_random;
StringName anim_speed_random;
StringName anim_offset_random;
StringName angle_texture;
StringName angular_velocity_texture;
StringName orbit_velocity_texture;
StringName linear_accel_texture;
StringName radial_accel_texture;
StringName tangent_accel_texture;
StringName damping_texture;
StringName scale_texture;
StringName hue_variation_texture;
StringName anim_speed_texture;
StringName anim_offset_texture;
StringName color;
StringName color_ramp;
StringName color_initial_ramp;
StringName emission_sphere_radius;
StringName emission_box_extents;
StringName emission_texture_point_count;
StringName emission_texture_points;
StringName emission_texture_normal;
StringName emission_texture_color;
StringName emission_ring_radius;
StringName emission_ring_inner_radius;
StringName emission_ring_height;
StringName emission_ring_axis;
StringName trail_divisor;
StringName trail_size_modifier;
StringName trail_color_modifier;
StringName gravity;
StringName lifetime_randomness;
};
static ShaderNames *shader_names;
SelfList<ParticlesMaterial> element;
void _update_shader();
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;
bool is_initialized = false;
Vector3 direction;
float spread;
float flatness;
float parameters[PARAM_MAX];
float randomness[PARAM_MAX];
Ref<Texture> tex_parameters[PARAM_MAX];
Color color;
Ref<Texture> color_ramp;
Ref<Texture> color_initial_ramp;
bool flags[FLAG_MAX];
EmissionShape emission_shape;
float emission_sphere_radius;
Vector3 emission_box_extents;
Ref<Texture> emission_point_texture;
Ref<Texture> emission_normal_texture;
Ref<Texture> emission_color_texture;
int emission_point_count;
float emission_ring_height;
float emission_ring_radius;
float emission_ring_inner_radius;
Vector3 emission_ring_axis;
bool anim_loop;
int trail_divisor;
Ref<CurveTexture> trail_size_modifier;
Ref<GradientTexture> trail_color_modifier;
Vector3 gravity;
float lifetime_randomness;
//do not save emission points here
protected:
static void _bind_methods();
virtual void _validate_property(PropertyInfo &property) const;
public:
void set_direction(Vector3 p_direction);
Vector3 get_direction() const;
void set_spread(float p_spread);
float get_spread() const;
void set_flatness(float p_flatness);
float get_flatness() const;
void set_param(Parameter p_param, float p_value);
float get_param(Parameter p_param) const;
void set_param_randomness(Parameter p_param, float p_value);
float get_param_randomness(Parameter p_param) const;
void set_param_texture(Parameter p_param, const Ref<Texture> &p_texture);
Ref<Texture> get_param_texture(Parameter p_param) const;
void set_color(const Color &p_color);
Color get_color() const;
void set_color_ramp(const Ref<Texture> &p_texture);
Ref<Texture> get_color_ramp() const;
void set_color_initial_ramp(const Ref<Texture> &p_texture);
Ref<Texture> get_color_initial_ramp() const;
void set_flag(Flags p_flag, bool p_enable);
bool get_flag(Flags p_flag) const;
void set_emission_shape(EmissionShape p_shape);
void set_emission_sphere_radius(float p_radius);
void set_emission_box_extents(Vector3 p_extents);
void set_emission_point_texture(const Ref<Texture> &p_points);
void set_emission_normal_texture(const Ref<Texture> &p_normals);
void set_emission_color_texture(const Ref<Texture> &p_colors);
void set_emission_point_count(int p_count);
void set_emission_ring_radius(float p_radius);
void set_emission_ring_inner_radius(float p_offset);
void set_emission_ring_height(float p_height);
void set_emission_ring_axis(Vector3 p_axis);
EmissionShape get_emission_shape() const;
float get_emission_sphere_radius() const;
Vector3 get_emission_box_extents() const;
Ref<Texture> get_emission_point_texture() const;
Ref<Texture> get_emission_normal_texture() const;
Ref<Texture> get_emission_color_texture() const;
int get_emission_point_count() const;
float get_emission_ring_radius() const;
float get_emission_ring_inner_radius() const;
float get_emission_ring_height() const;
Vector3 get_emission_ring_axis() const;
void set_trail_divisor(int p_divisor);
int get_trail_divisor() const;
void set_trail_size_modifier(const Ref<CurveTexture> &p_trail_size_modifier);
Ref<CurveTexture> get_trail_size_modifier() const;
void set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier);
Ref<GradientTexture> get_trail_color_modifier() const;
void set_gravity(const Vector3 &p_gravity);
Vector3 get_gravity() const;
void set_lifetime_randomness(float p_lifetime);
float get_lifetime_randomness() const;
static void init_shaders();
static void finish_shaders();
static void flush_changes();
RID get_shader_rid() const;
virtual Shader::Mode get_shader_mode() const;
ParticlesMaterial();
~ParticlesMaterial();
};
VARIANT_ENUM_CAST(ParticlesMaterial::Parameter)
VARIANT_ENUM_CAST(ParticlesMaterial::Flags)
VARIANT_ENUM_CAST(ParticlesMaterial::EmissionShape)
#endif // PARTICLES_MATERIAL_H

File diff suppressed because it is too large Load Diff

View File

@ -1,601 +0,0 @@
#ifndef SPATIAL_MATERIAL_H
#define SPATIAL_MATERIAL_H
/*************************************************************************/
/* material.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/containers/self_list.h"
#include "scene/resources/material/material.h"
#include "scene/resources/shader.h"
#include "servers/rendering_server.h"
class Texture;
class SpatialMaterial : public Material {
GDCLASS(SpatialMaterial, Material);
public:
enum TextureParam {
TEXTURE_ALBEDO,
TEXTURE_METALLIC,
TEXTURE_ROUGHNESS,
TEXTURE_EMISSION,
TEXTURE_NORMAL,
TEXTURE_RIM,
TEXTURE_CLEARCOAT,
TEXTURE_FLOWMAP,
TEXTURE_AMBIENT_OCCLUSION,
TEXTURE_DEPTH,
TEXTURE_SUBSURFACE_SCATTERING,
TEXTURE_TRANSMISSION,
TEXTURE_REFRACTION,
TEXTURE_DETAIL_MASK,
TEXTURE_DETAIL_ALBEDO,
TEXTURE_DETAIL_NORMAL,
TEXTURE_MAX
};
enum DetailUV {
DETAIL_UV_1,
DETAIL_UV_2
};
enum Feature {
FEATURE_TRANSPARENT,
FEATURE_EMISSION,
FEATURE_NORMAL_MAPPING,
FEATURE_RIM,
FEATURE_CLEARCOAT,
FEATURE_ANISOTROPY,
FEATURE_AMBIENT_OCCLUSION,
FEATURE_DEPTH_MAPPING,
FEATURE_SUBSURACE_SCATTERING,
FEATURE_TRANSMISSION,
FEATURE_REFRACTION,
FEATURE_DETAIL,
FEATURE_MAX
};
enum BlendMode {
BLEND_MODE_MIX,
BLEND_MODE_ADD,
BLEND_MODE_SUB,
BLEND_MODE_MUL,
};
enum DepthDrawMode {
DEPTH_DRAW_OPAQUE_ONLY,
DEPTH_DRAW_ALWAYS,
DEPTH_DRAW_DISABLED,
DEPTH_DRAW_ALPHA_OPAQUE_PREPASS
};
enum CullMode {
CULL_BACK,
CULL_FRONT,
CULL_DISABLED
};
enum Flags {
FLAG_UNSHADED,
FLAG_USE_VERTEX_LIGHTING,
FLAG_DISABLE_DEPTH_TEST,
FLAG_ALBEDO_FROM_VERTEX_COLOR,
FLAG_SRGB_VERTEX_COLOR,
FLAG_USE_POINT_SIZE,
FLAG_FIXED_SIZE,
FLAG_BILLBOARD_KEEP_SCALE,
FLAG_UV1_USE_TRIPLANAR,
FLAG_UV2_USE_TRIPLANAR,
FLAG_TRIPLANAR_USE_WORLD,
FLAG_AO_ON_UV2,
FLAG_EMISSION_ON_UV2,
FLAG_USE_ALPHA_SCISSOR,
FLAG_ALBEDO_TEXTURE_FORCE_SRGB,
FLAG_DONT_RECEIVE_SHADOWS,
FLAG_ENSURE_CORRECT_NORMALS,
FLAG_DISABLE_AMBIENT_LIGHT,
FLAG_USE_SHADOW_TO_OPACITY,
FLAG_ALBEDO_TEXTURE_SDF,
FLAG_MAX
};
enum DiffuseMode {
DIFFUSE_BURLEY,
DIFFUSE_LAMBERT,
DIFFUSE_LAMBERT_WRAP,
DIFFUSE_OREN_NAYAR,
DIFFUSE_TOON,
};
enum SpecularMode {
SPECULAR_SCHLICK_GGX,
SPECULAR_BLINN,
SPECULAR_PHONG,
SPECULAR_TOON,
SPECULAR_DISABLED,
};
enum BillboardMode {
BILLBOARD_DISABLED,
BILLBOARD_ENABLED,
BILLBOARD_FIXED_Y,
BILLBOARD_PARTICLES,
};
enum TextureChannel {
TEXTURE_CHANNEL_RED,
TEXTURE_CHANNEL_GREEN,
TEXTURE_CHANNEL_BLUE,
TEXTURE_CHANNEL_ALPHA,
TEXTURE_CHANNEL_GRAYSCALE
};
enum EmissionOperator {
EMISSION_OP_ADD,
EMISSION_OP_MULTIPLY
};
enum DistanceFadeMode {
DISTANCE_FADE_DISABLED,
DISTANCE_FADE_PIXEL_ALPHA,
DISTANCE_FADE_PIXEL_DITHER,
DISTANCE_FADE_OBJECT_DITHER,
};
enum AsyncMode {
ASYNC_MODE_VISIBLE,
ASYNC_MODE_HIDDEN,
};
private:
union MaterialKey {
struct {
uint64_t feature_mask : 12;
uint64_t detail_uv : 1;
uint64_t blend_mode : 2;
uint64_t depth_draw_mode : 2;
uint64_t cull_mode : 2;
uint64_t flags : 20;
uint64_t detail_blend_mode : 2;
uint64_t diffuse_mode : 3;
uint64_t specular_mode : 3;
uint64_t invalid_key : 1;
uint64_t deep_parallax : 1;
uint64_t billboard_mode : 2;
uint64_t grow : 1;
uint64_t proximity_fade : 1;
uint64_t distance_fade : 2;
uint64_t emission_op : 1;
uint64_t texture_metallic : 1;
uint64_t texture_roughness : 1;
//uint64_t reserved : 6;
};
uint64_t key;
bool operator<(const MaterialKey &p_key) const {
return key < p_key.key;
}
};
struct ShaderData {
RID shader;
int users;
};
static RBMap<MaterialKey, ShaderData> shader_map;
MaterialKey current_key;
_FORCE_INLINE_ MaterialKey _compute_key() const {
MaterialKey mk;
mk.key = 0;
for (int i = 0; i < FEATURE_MAX; i++) {
if (features[i]) {
mk.feature_mask |= ((uint64_t)1 << i);
}
}
mk.detail_uv = detail_uv;
mk.blend_mode = blend_mode;
mk.depth_draw_mode = depth_draw_mode;
mk.cull_mode = cull_mode;
for (int i = 0; i < FLAG_MAX; i++) {
if (flags[i]) {
mk.flags |= ((uint64_t)1 << i);
}
}
mk.detail_blend_mode = detail_blend_mode;
mk.diffuse_mode = diffuse_mode;
mk.specular_mode = specular_mode;
mk.billboard_mode = billboard_mode;
mk.deep_parallax = deep_parallax ? 1 : 0;
mk.grow = grow_enabled;
mk.proximity_fade = proximity_fade_enabled;
mk.distance_fade = distance_fade;
mk.emission_op = emission_op;
mk.texture_metallic = textures[TEXTURE_METALLIC].is_valid() ? 1 : 0;
mk.texture_roughness = textures[TEXTURE_ROUGHNESS].is_valid() ? 1 : 0;
return mk;
}
struct ShaderNames {
StringName albedo;
StringName specular;
StringName metallic;
StringName roughness;
StringName emission;
StringName emission_energy;
StringName normal_scale;
StringName rim;
StringName rim_tint;
StringName clearcoat;
StringName clearcoat_gloss;
StringName anisotropy;
StringName depth_scale;
StringName subsurface_scattering_strength;
StringName transmission;
StringName refraction;
StringName point_size;
StringName uv1_scale;
StringName uv1_offset;
StringName uv2_scale;
StringName uv2_offset;
StringName particles_anim_h_frames;
StringName particles_anim_v_frames;
StringName particles_anim_loop;
StringName depth_min_layers;
StringName depth_max_layers;
StringName depth_flip;
StringName uv1_blend_sharpness;
StringName uv2_blend_sharpness;
StringName grow;
StringName proximity_fade_distance;
StringName distance_fade_min;
StringName distance_fade_max;
StringName ao_light_affect;
StringName metallic_texture_channel;
StringName roughness_texture_channel;
StringName ao_texture_channel;
StringName clearcoat_texture_channel;
StringName rim_texture_channel;
StringName depth_texture_channel;
StringName refraction_texture_channel;
StringName alpha_scissor_threshold;
StringName texture_names[TEXTURE_MAX];
};
static Mutex material_mutex;
static SelfList<SpatialMaterial>::List *dirty_materials;
static ShaderNames *shader_names;
SelfList<SpatialMaterial> element;
void _update_shader();
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;
bool is_initialized = false;
Color albedo;
float specular;
float metallic;
float roughness;
Color emission;
float emission_energy;
float normal_scale;
float rim;
float rim_tint;
float clearcoat;
float clearcoat_gloss;
float anisotropy;
float depth_scale;
float subsurface_scattering_strength;
Color transmission;
float refraction;
float line_width;
float point_size;
float alpha_scissor_threshold;
bool grow_enabled;
float ao_light_affect;
float grow;
int particles_anim_h_frames;
int particles_anim_v_frames;
bool particles_anim_loop;
Vector3 uv1_scale;
Vector3 uv1_offset;
float uv1_triplanar_sharpness;
Vector3 uv2_scale;
Vector3 uv2_offset;
float uv2_triplanar_sharpness;
DetailUV detail_uv;
bool deep_parallax;
int deep_parallax_min_layers;
int deep_parallax_max_layers;
bool depth_parallax_flip_tangent;
bool depth_parallax_flip_binormal;
bool proximity_fade_enabled;
float proximity_fade_distance;
DistanceFadeMode distance_fade;
float distance_fade_max_distance;
float distance_fade_min_distance;
BlendMode blend_mode;
BlendMode detail_blend_mode;
DepthDrawMode depth_draw_mode;
CullMode cull_mode;
bool flags[FLAG_MAX];
SpecularMode specular_mode;
DiffuseMode diffuse_mode;
BillboardMode billboard_mode;
EmissionOperator emission_op;
AsyncMode async_mode;
TextureChannel metallic_texture_channel;
TextureChannel roughness_texture_channel;
TextureChannel ao_texture_channel;
TextureChannel refraction_texture_channel;
bool features[FEATURE_MAX];
Ref<Texture> textures[TEXTURE_MAX];
bool force_vertex_shading = false;
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
static HashMap<uint64_t, Ref<SpatialMaterial>> materials_for_2d; //used by Sprite3D and other stuff
void _validate_high_end(const String &text, PropertyInfo &property) const;
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &property) const;
virtual bool _can_do_next_pass() const { return true; }
public:
void set_albedo(const Color &p_albedo);
Color get_albedo() const;
void set_specular(float p_specular);
float get_specular() const;
void set_metallic(float p_metallic);
float get_metallic() const;
void set_roughness(float p_roughness);
float get_roughness() const;
void set_emission(const Color &p_emission);
Color get_emission() const;
void set_emission_energy(float p_emission_energy);
float get_emission_energy() const;
void set_normal_scale(float p_normal_scale);
float get_normal_scale() const;
void set_rim(float p_rim);
float get_rim() const;
void set_rim_tint(float p_rim_tint);
float get_rim_tint() const;
void set_ao_light_affect(float p_ao_light_affect);
float get_ao_light_affect() const;
void set_clearcoat(float p_clearcoat);
float get_clearcoat() const;
void set_clearcoat_gloss(float p_clearcoat_gloss);
float get_clearcoat_gloss() const;
void set_anisotropy(float p_anisotropy);
float get_anisotropy() const;
void set_depth_scale(float p_depth_scale);
float get_depth_scale() const;
void set_depth_deep_parallax(bool p_enable);
bool is_depth_deep_parallax_enabled() const;
void set_depth_deep_parallax_min_layers(int p_layer);
int get_depth_deep_parallax_min_layers() const;
void set_depth_deep_parallax_max_layers(int p_layer);
int get_depth_deep_parallax_max_layers() const;
void set_depth_deep_parallax_flip_tangent(bool p_flip);
bool get_depth_deep_parallax_flip_tangent() const;
void set_depth_deep_parallax_flip_binormal(bool p_flip);
bool get_depth_deep_parallax_flip_binormal() const;
void set_subsurface_scattering_strength(float p_subsurface_scattering_strength);
float get_subsurface_scattering_strength() const;
void set_transmission(const Color &p_transmission);
Color get_transmission() const;
void set_refraction(float p_refraction);
float get_refraction() const;
void set_line_width(float p_line_width);
float get_line_width() const;
void set_point_size(float p_point_size);
float get_point_size() const;
void set_detail_uv(DetailUV p_detail_uv);
DetailUV get_detail_uv() const;
void set_blend_mode(BlendMode p_mode);
BlendMode get_blend_mode() const;
void set_detail_blend_mode(BlendMode p_mode);
BlendMode get_detail_blend_mode() const;
void set_depth_draw_mode(DepthDrawMode p_mode);
DepthDrawMode get_depth_draw_mode() const;
void set_cull_mode(CullMode p_mode);
CullMode get_cull_mode() const;
void set_diffuse_mode(DiffuseMode p_mode);
DiffuseMode get_diffuse_mode() const;
void set_specular_mode(SpecularMode p_mode);
SpecularMode get_specular_mode() const;
void set_flag(Flags p_flag, bool p_enabled);
bool get_flag(Flags p_flag) const;
void set_texture(TextureParam p_param, const Ref<Texture> &p_texture);
Ref<Texture> get_texture(TextureParam p_param) const;
// Used only for shader material conversion
Ref<Texture> get_texture_by_name(StringName p_name) const;
void set_feature(Feature p_feature, bool p_enabled);
bool get_feature(Feature p_feature) const;
void set_uv1_scale(const Vector3 &p_scale);
Vector3 get_uv1_scale() const;
void set_uv1_offset(const Vector3 &p_offset);
Vector3 get_uv1_offset() const;
void set_uv1_triplanar_blend_sharpness(float p_sharpness);
float get_uv1_triplanar_blend_sharpness() const;
void set_uv2_scale(const Vector3 &p_scale);
Vector3 get_uv2_scale() const;
void set_uv2_offset(const Vector3 &p_offset);
Vector3 get_uv2_offset() const;
void set_uv2_triplanar_blend_sharpness(float p_sharpness);
float get_uv2_triplanar_blend_sharpness() const;
void set_billboard_mode(BillboardMode p_mode);
BillboardMode get_billboard_mode() const;
void set_particles_anim_h_frames(int p_frames);
int get_particles_anim_h_frames() const;
void set_particles_anim_v_frames(int p_frames);
int get_particles_anim_v_frames() const;
void set_particles_anim_loop(bool p_loop);
bool get_particles_anim_loop() const;
void set_grow_enabled(bool p_enable);
bool is_grow_enabled() const;
void set_grow(float p_grow);
float get_grow() const;
void set_alpha_scissor_threshold(float p_threshold);
float get_alpha_scissor_threshold() const;
void set_on_top_of_alpha();
void set_proximity_fade(bool p_enable);
bool is_proximity_fade_enabled() const;
void set_proximity_fade_distance(float p_distance);
float get_proximity_fade_distance() const;
void set_distance_fade(DistanceFadeMode p_mode);
DistanceFadeMode get_distance_fade() const;
void set_distance_fade_max_distance(float p_distance);
float get_distance_fade_max_distance() const;
void set_distance_fade_min_distance(float p_distance);
float get_distance_fade_min_distance() const;
void set_emission_operator(EmissionOperator p_op);
EmissionOperator get_emission_operator() const;
void set_metallic_texture_channel(TextureChannel p_channel);
TextureChannel get_metallic_texture_channel() const;
void set_roughness_texture_channel(TextureChannel p_channel);
TextureChannel get_roughness_texture_channel() const;
void set_ao_texture_channel(TextureChannel p_channel);
TextureChannel get_ao_texture_channel() const;
void set_refraction_texture_channel(TextureChannel p_channel);
TextureChannel get_refraction_texture_channel() const;
void set_async_mode(AsyncMode p_mode);
AsyncMode get_async_mode() const;
static void init_shaders();
static void finish_shaders();
static void flush_changes();
static RID get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard = false, bool p_billboard_y = false, bool p_no_depth_test = false, bool p_fixed_size = false, bool p_sdf = false);
RID get_shader_rid() const;
virtual Shader::Mode get_shader_mode() const;
SpatialMaterial();
virtual ~SpatialMaterial();
};
VARIANT_ENUM_CAST(SpatialMaterial::TextureParam)
VARIANT_ENUM_CAST(SpatialMaterial::DetailUV)
VARIANT_ENUM_CAST(SpatialMaterial::Feature)
VARIANT_ENUM_CAST(SpatialMaterial::BlendMode)
VARIANT_ENUM_CAST(SpatialMaterial::DepthDrawMode)
VARIANT_ENUM_CAST(SpatialMaterial::CullMode)
VARIANT_ENUM_CAST(SpatialMaterial::Flags)
VARIANT_ENUM_CAST(SpatialMaterial::DiffuseMode)
VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode)
VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode)
VARIANT_ENUM_CAST(SpatialMaterial::TextureChannel)
VARIANT_ENUM_CAST(SpatialMaterial::EmissionOperator)
VARIANT_ENUM_CAST(SpatialMaterial::DistanceFadeMode)
VARIANT_ENUM_CAST(SpatialMaterial::AsyncMode)
//////////////////////
#endif

View File

@ -31,7 +31,6 @@
#include "navigation_mesh.h"
#include "servers/navigation_server.h"
#include "scene/resources/material/spatial_material.h"
void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
ERR_FAIL_COND(p_mesh.is_null());
@ -445,8 +444,6 @@ Ref<ArrayMesh> NavigationMesh::get_debug_mesh() {
}
debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, face_mesh_array);
Ref<SpatialMaterial> debug_geometry_face_material = NavigationServer::get_singleton()->get_debug_navigation_geometry_face_material();
debug_mesh->surface_set_material(debug_mesh->get_surface_count(), debug_geometry_face_material);
// if enabled build geometry edge line surface
bool enabled_edge_lines = NavigationServer::get_singleton()->get_debug_navigation_enable_edge_lines();
@ -470,8 +467,6 @@ Ref<ArrayMesh> NavigationMesh::get_debug_mesh() {
line_mesh_array.resize(Mesh::ARRAY_MAX);
line_mesh_array[Mesh::ARRAY_VERTEX] = line_vertex_array;
debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, line_mesh_array);
Ref<SpatialMaterial> debug_geometry_edge_material = NavigationServer::get_singleton()->get_debug_navigation_geometry_edge_material();
debug_mesh->surface_set_material(debug_mesh->get_surface_count() - 1, debug_geometry_edge_material);
}
return debug_mesh;

View File

@ -1,242 +0,0 @@
/*************************************************************************/
/* occluder_shape.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "occluder_shape.h"
#include "core/config/engine.h"
#include "core/math/transform.h"
#include "servers/rendering_server.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
#endif
void OccluderShape::_bind_methods() {
}
OccluderShape::OccluderShape() {
}
OccluderShape::~OccluderShape() {
if (_shape.is_valid()) {
RenderingServer::get_singleton()->free(_shape);
}
}
#ifdef TOOLS_ENABLED
AABB OccluderShape::get_fallback_gizmo_aabb() const {
return AABB(Vector3(-0.5, -0.5, -0.5), Vector3(1, 1, 1));
}
#endif
//////////////////////////////////////////////
void OccluderShapeSphere::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_spheres", "spheres"), &OccluderShapeSphere::set_spheres);
ClassDB::bind_method(D_METHOD("get_spheres"), &OccluderShapeSphere::get_spheres);
ClassDB::bind_method(D_METHOD("set_sphere_position", "index", "position"), &OccluderShapeSphere::set_sphere_position);
ClassDB::bind_method(D_METHOD("set_sphere_radius", "index", "radius"), &OccluderShapeSphere::set_sphere_radius);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "spheres", PROPERTY_HINT_NONE, itos(Variant::PLANE) + ":"), "set_spheres", "get_spheres");
}
#ifdef TOOLS_ENABLED
void OccluderShapeSphere::_update_aabb() {
_aabb_local = AABB();
if (!_spheres.size()) {
return;
}
_aabb_local.position = _spheres[0].normal;
for (int n = 0; n < _spheres.size(); n++) {
AABB bb(_spheres[n].normal, Vector3(0, 0, 0));
bb.grow_by(_spheres[n].d);
_aabb_local.merge_with(bb);
}
}
AABB OccluderShapeSphere::get_fallback_gizmo_aabb() const {
return _aabb_local;
}
#endif
void OccluderShapeSphere::update_shape_to_rendering_server() {
}
Transform OccluderShapeSphere::center_node(const Transform &p_global_xform, const Transform &p_parent_xform, real_t p_snap) {
if (!_spheres.size()) {
return Transform();
}
// make sure world spheres correct
Vector<Plane> spheres_world_space;
if (spheres_world_space.size() != _spheres.size()) {
spheres_world_space.resize(_spheres.size());
}
Vector3 scale3 = p_global_xform.basis.get_scale_abs();
real_t scale = (scale3.x + scale3.y + scale3.z) / 3.0;
for (int n = 0; n < _spheres.size(); n++) {
Plane p;
p.normal = p_global_xform.xform(_spheres[n].normal);
p.d = _spheres[n].d * scale;
spheres_world_space.set(n, p);
}
// first find the center
AABB bb;
bb.set_position(spheres_world_space[0].normal);
// new positions
for (int n = 0; n < spheres_world_space.size(); n++) {
const Plane &sphere = spheres_world_space[n];
// update aabb
AABB sphere_bb(sphere.normal, Vector3());
sphere_bb.grow_by(sphere.d);
bb.merge_with(sphere_bb);
}
Vector3 center = bb.get_center();
// snapping
if (p_snap > 0.0001) {
center.snap(Vector3(p_snap, p_snap, p_snap));
}
// new transform with no rotate or scale, centered
Transform new_local_xform = Transform();
new_local_xform.translate_local(center.x, center.y, center.z);
Transform inv_xform = new_local_xform.affine_inverse();
// back calculate the new spheres
for (int n = 0; n < spheres_world_space.size(); n++) {
Plane p = spheres_world_space[n];
p.normal = inv_xform.xform(p.normal);
// assuming uniform scale, otherwise this will go wrong
Vector3 inv_scale = inv_xform.basis.get_scale_abs();
p.d *= inv_scale.x;
spheres_world_space.set(n, p);
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
UndoRedo *undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("OccluderShapeSphere Set Spheres"));
undo_redo->add_do_method(this, "set_spheres", spheres_world_space);
undo_redo->add_undo_method(this, "set_spheres", _spheres);
undo_redo->commit_action();
} else {
set_spheres(spheres_world_space);
}
#else
set_spheres(spheres_world_space);
#endif
notify_change_to_owners();
return new_local_xform;
}
void OccluderShapeSphere::set_spheres(const Vector<Plane> &p_spheres) {
#ifdef TOOLS_ENABLED
// try and detect special circumstance of adding a new sphere in the editor
bool adding_in_editor = false;
if ((p_spheres.size() == _spheres.size() + 1) && (p_spheres[p_spheres.size() - 1] == Plane())) {
adding_in_editor = true;
}
#endif
_spheres = p_spheres;
// sanitize radii
for (int n = 0; n < _spheres.size(); n++) {
if (_spheres[n].d < _min_radius) {
Plane p = _spheres[n];
p.d = _min_radius;
_spheres.set(n, p);
}
}
#ifdef TOOLS_ENABLED
if (adding_in_editor) {
_spheres.set(_spheres.size() - 1, Plane(Vector3(), 1.0));
}
_update_aabb();
#endif
update_shape_to_rendering_server();
notify_change_to_owners();
}
void OccluderShapeSphere::set_sphere_position(int p_idx, const Vector3 &p_position) {
ERR_FAIL_INDEX(p_idx, _spheres.size());
Plane p = _spheres[p_idx];
p.normal = p_position;
_spheres.set(p_idx, p);
#ifdef TOOLS_ENABLED
_update_aabb();
#endif
update_shape_to_rendering_server();
notify_change_to_owners();
}
void OccluderShapeSphere::set_sphere_radius(int p_idx, real_t p_radius) {
ERR_FAIL_INDEX(p_idx, _spheres.size());
Plane p = _spheres[p_idx];
p.d = MAX(p_radius, _min_radius);
_spheres.set(p_idx, p);
#ifdef TOOLS_ENABLED
_update_aabb();
#endif
update_shape_to_rendering_server();
notify_change_to_owners();
}
OccluderShapeSphere::OccluderShapeSphere() {
// Create a default sphere
Vector<Plane> planes;
planes.push_back(Plane(Vector3(0, 0, 0), 1));
set_spheres(planes);
}

View File

@ -1,95 +0,0 @@
#ifndef OCCLUDER_SHAPE_H
#define OCCLUDER_SHAPE_H
/*************************************************************************/
/* occluder_shape.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/math/plane.h"
#include "core/object/resource.h"
#include "core/containers/vector.h"
class OccluderShape : public Resource {
GDCLASS(OccluderShape, Resource);
OBJ_SAVE_TYPE(OccluderShape);
RES_BASE_EXTENSION("occ");
RID _shape;
protected:
static void _bind_methods();
RID get_shape() const { return _shape; }
OccluderShape();
public:
virtual RID get_rid() const { return _shape; }
~OccluderShape();
virtual Transform center_node(const Transform &p_global_xform, const Transform &p_parent_xform, real_t p_snap) = 0;
#ifdef TOOLS_ENABLED
// for editor gizmo
virtual AABB get_fallback_gizmo_aabb() const;
virtual bool requires_uniform_scale() const { return false; }
#endif
};
class OccluderShapeSphere : public OccluderShape {
GDCLASS(OccluderShapeSphere, OccluderShape);
// We bandit a plane to store position / radius
Vector<Plane> _spheres;
const real_t _min_radius = 0.1;
#ifdef TOOLS_ENABLED
AABB _aabb_local;
void _update_aabb();
#endif
protected:
static void _bind_methods();
public:
void set_spheres(const Vector<Plane> &p_spheres);
Vector<Plane> get_spheres() const { return _spheres; }
void set_sphere_position(int p_idx, const Vector3 &p_position);
void set_sphere_radius(int p_idx, real_t p_radius);
void update_shape_to_rendering_server();
virtual Transform center_node(const Transform &p_global_xform, const Transform &p_parent_xform, real_t p_snap);
#ifdef TOOLS_ENABLED
virtual AABB get_fallback_gizmo_aabb() const;
virtual bool requires_uniform_scale() const { return false; }
#endif
OccluderShapeSphere();
};
#endif // OCCLUDER_SHAPE_H

View File

@ -1,231 +0,0 @@
/*************************************************************************/
/* occluder_shape_polygon.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "occluder_shape_polygon.h"
#include "servers/rendering_server.h"
#ifdef TOOLS_ENABLED
void OccluderShapePolygon::_update_aabb() {
_aabb_local = AABB();
if (_poly_pts_local.size()) {
Vector3 begin = _vec2to3(_poly_pts_local[0]);
Vector3 end = begin;
for (int n = 1; n < _poly_pts_local.size(); n++) {
Vector3 pt = _vec2to3(_poly_pts_local[n]);
begin.x = MIN(begin.x, pt.x);
begin.y = MIN(begin.y, pt.y);
begin.z = MIN(begin.z, pt.z);
end.x = MAX(end.x, pt.x);
end.y = MAX(end.y, pt.y);
end.z = MAX(end.z, pt.z);
}
for (int n = 0; n < _hole_pts_local.size(); n++) {
Vector3 pt = _vec2to3(_hole_pts_local[n]);
begin.x = MIN(begin.x, pt.x);
begin.y = MIN(begin.y, pt.y);
begin.z = MIN(begin.z, pt.z);
end.x = MAX(end.x, pt.x);
end.y = MAX(end.y, pt.y);
end.z = MAX(end.z, pt.z);
}
_aabb_local.position = begin;
_aabb_local.size = end - begin;
}
}
AABB OccluderShapePolygon::get_fallback_gizmo_aabb() const {
return _aabb_local;
}
#endif
void OccluderShapePolygon::_sanitize_points_internal(const PoolVector<Vector2> &p_from, Vector<Vector2> &r_to) {
// remove duplicates? NYI maybe not necessary
Vector<Vector2> raw;
raw.resize(p_from.size());
for (int n = 0; n < p_from.size(); n++) {
raw.set(n, p_from[n]);
}
// this function may get rid of some concave points due to user editing ..
// may not be necessary, no idea how fast it is
r_to = Geometry::convex_hull_2d(raw);
// some peculiarity of convex_hull_2d function, it duplicates the last point for some reason
if (r_to.size() > 1) {
r_to.resize(r_to.size() - 1);
}
// sort winding, the system expects counter clockwise polys
Geometry::sort_polygon_winding(r_to, false);
}
void OccluderShapePolygon::_sanitize_points() {
_sanitize_points_internal(_poly_pts_local_raw, _poly_pts_local);
_sanitize_points_internal(_hole_pts_local_raw, _hole_pts_local);
#ifdef TOOLS_ENABLED
_update_aabb();
#endif
}
void OccluderShapePolygon::set_polygon_point(int p_idx, const Vector2 &p_point) {
ERR_FAIL_INDEX_MSG(p_idx, _poly_pts_local_raw.size(), "Index out of bounds. Call set_polygon_points() to set the size of the array.");
_poly_pts_local_raw.set(p_idx, p_point);
_sanitize_points();
update_shape_to_rendering_server();
notify_change_to_owners();
}
void OccluderShapePolygon::set_hole_point(int p_idx, const Vector2 &p_point) {
ERR_FAIL_INDEX_MSG(p_idx, _hole_pts_local_raw.size(), "Index out of bounds. Call set_hole_points() to set the size of the array.");
_hole_pts_local_raw.set(p_idx, p_point);
_sanitize_points();
update_shape_to_rendering_server();
notify_change_to_owners();
}
void OccluderShapePolygon::set_polygon_points(const PoolVector<Vector2> &p_points) {
_poly_pts_local_raw = p_points;
_sanitize_points();
update_shape_to_rendering_server();
notify_change_to_owners();
}
void OccluderShapePolygon::set_hole_points(const PoolVector<Vector2> &p_points) {
_hole_pts_local_raw = p_points;
_sanitize_points();
update_shape_to_rendering_server();
notify_change_to_owners();
}
PoolVector<Vector2> OccluderShapePolygon::get_polygon_points() const {
return _poly_pts_local_raw;
}
PoolVector<Vector2> OccluderShapePolygon::get_hole_points() const {
return _hole_pts_local_raw;
}
void OccluderShapePolygon::update_shape_to_rendering_server() {
if (_poly_pts_local.size() < 3)
return;
Geometry::OccluderMeshData md;
md.faces.resize(1);
Geometry::OccluderMeshData::Face &face = md.faces[0];
face.two_way = is_two_way();
md.vertices.resize(_poly_pts_local.size() + _hole_pts_local.size());
face.indices.resize(_poly_pts_local.size());
for (int n = 0; n < _poly_pts_local.size(); n++) {
md.vertices[n] = _vec2to3(_poly_pts_local[n]);
face.indices[n] = n;
}
// hole points
if (_hole_pts_local.size()) {
face.holes.resize(1);
Geometry::OccluderMeshData::Hole &hole = face.holes[0];
hole.indices.resize(_hole_pts_local.size());
for (int n = 0; n < _hole_pts_local.size(); n++) {
int dest_idx = n + _poly_pts_local.size();
hole.indices[n] = dest_idx;
md.vertices[dest_idx] = _vec2to3(_hole_pts_local[n]);
}
}
face.plane = Plane(Vector3(0, 0, 0), Vector3(0, 0, -1));
}
void OccluderShapePolygon::set_two_way(bool p_two_way) {
_settings_two_way = p_two_way;
update_shape_to_rendering_server();
notify_change_to_owners();
}
Transform OccluderShapePolygon::center_node(const Transform &p_global_xform, const Transform &p_parent_xform, real_t p_snap) {
return Transform();
}
void OccluderShapePolygon::clear() {
_poly_pts_local.clear();
_poly_pts_local_raw.resize(0);
_hole_pts_local.clear();
_hole_pts_local_raw.resize(0);
#ifdef TOOLS_ENABLED
_aabb_local = AABB();
#endif
}
void OccluderShapePolygon::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_two_way", "two_way"), &OccluderShapePolygon::set_two_way);
ClassDB::bind_method(D_METHOD("is_two_way"), &OccluderShapePolygon::is_two_way);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "two_way"), "set_two_way", "is_two_way");
ClassDB::bind_method(D_METHOD("set_polygon_points", "points"), &OccluderShapePolygon::set_polygon_points);
ClassDB::bind_method(D_METHOD("get_polygon_points"), &OccluderShapePolygon::get_polygon_points);
ClassDB::bind_method(D_METHOD("set_polygon_point", "index", "position"), &OccluderShapePolygon::set_polygon_point);
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "polygon_points"), "set_polygon_points", "get_polygon_points");
ClassDB::bind_method(D_METHOD("set_hole_points", "points"), &OccluderShapePolygon::set_hole_points);
ClassDB::bind_method(D_METHOD("get_hole_points"), &OccluderShapePolygon::get_hole_points);
ClassDB::bind_method(D_METHOD("set_hole_point", "index", "position"), &OccluderShapePolygon::set_hole_point);
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "hole_points"), "set_hole_points", "get_hole_points");
}
OccluderShapePolygon::OccluderShapePolygon() {
clear();
PoolVector<Vector2> points;
points.resize(4);
points.set(0, Vector2(1, -1));
points.set(1, Vector2(1, 1));
points.set(2, Vector2(-1, 1));
points.set(3, Vector2(-1, -1));
set_polygon_points(points); // default shape
}

View File

@ -1,93 +0,0 @@
#ifndef OCCLUDER_SHAPE_POLYGON_H
#define OCCLUDER_SHAPE_POLYGON_H
/*************************************************************************/
/* occluder_shape_polygon.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "occluder_shape.h"
class OccluderShapePolygon : public OccluderShape {
GDCLASS(OccluderShapePolygon, OccluderShape);
OBJ_SAVE_TYPE(OccluderShapePolygon);
friend class OccluderSpatialGizmo;
// points in local space of the plane,
// not necessary in correct winding order
// (as they can be edited by the user)
// Note: these are saved by the IDE
PoolVector<Vector2> _poly_pts_local_raw;
PoolVector<Vector2> _hole_pts_local_raw;
// sanitized
Vector<Vector2> _poly_pts_local;
Vector<Vector2> _hole_pts_local;
bool _settings_two_way = true;
#ifdef TOOLS_ENABLED
AABB _aabb_local;
void _update_aabb();
#endif
// mem funcs
void _sanitize_points();
void _sanitize_points_internal(const PoolVector<Vector2> &p_from, Vector<Vector2> &r_to);
static Vector3 _vec2to3(const Vector2 &p_pt) { return Vector3(p_pt.x, p_pt.y, 0.0); }
protected:
static void _bind_methods();
public:
// the raw points are used for the IDE Inspector, and also to allow the user
// to edit the geometry of the poly at runtime (they can also just change the node transform)
void set_polygon_points(const PoolVector<Vector2> &p_points);
PoolVector<Vector2> get_polygon_points() const;
void set_hole_points(const PoolVector<Vector2> &p_points);
PoolVector<Vector2> get_hole_points() const;
// primarily for the gizmo
void set_polygon_point(int p_idx, const Vector2 &p_point);
void set_hole_point(int p_idx, const Vector2 &p_point);
void set_two_way(bool p_two_way);
bool is_two_way() const { return _settings_two_way; }
void clear();
void update_shape_to_rendering_server();
virtual Transform center_node(const Transform &p_global_xform, const Transform &p_parent_xform, real_t p_snap);
#ifdef TOOLS_ENABLED
virtual AABB get_fallback_gizmo_aabb() const;
#endif
OccluderShapePolygon();
};
#endif // OCCLUDER_SHAPE_POLYGON_H

View File

@ -1,540 +0,0 @@
/*************************************************************************/
/* sky.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "sky.h"
#include "core/io/image_loader.h"
void Sky::set_radiance_size(RadianceSize p_size) {
ERR_FAIL_INDEX(p_size, RADIANCE_SIZE_MAX);
radiance_size = p_size;
_radiance_changed();
}
Sky::RadianceSize Sky::get_radiance_size() const {
return radiance_size;
}
void Sky::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_radiance_size", "size"), &Sky::set_radiance_size);
ClassDB::bind_method(D_METHOD("get_radiance_size"), &Sky::get_radiance_size);
// Don't expose 1024 and 2048 in the property hint as these sizes will cause GPU hangs on many systems.
ADD_PROPERTY(PropertyInfo(Variant::INT, "radiance_size", PROPERTY_HINT_ENUM, "32,64,128,256,512"), "set_radiance_size", "get_radiance_size");
BIND_ENUM_CONSTANT(RADIANCE_SIZE_32);
BIND_ENUM_CONSTANT(RADIANCE_SIZE_64);
BIND_ENUM_CONSTANT(RADIANCE_SIZE_128);
BIND_ENUM_CONSTANT(RADIANCE_SIZE_256);
BIND_ENUM_CONSTANT(RADIANCE_SIZE_512);
BIND_ENUM_CONSTANT(RADIANCE_SIZE_1024);
BIND_ENUM_CONSTANT(RADIANCE_SIZE_2048);
BIND_ENUM_CONSTANT(RADIANCE_SIZE_MAX);
}
Sky::Sky() {
radiance_size = RADIANCE_SIZE_128;
}
/////////////////////////////////////////
void PanoramaSky::_radiance_changed() {
if (panorama.is_valid()) {
static const int size[RADIANCE_SIZE_MAX] = {
32, 64, 128, 256, 512, 1024, 2048
};
RS::get_singleton()->sky_set_texture(sky, panorama->get_rid(), size[get_radiance_size()]);
}
}
void PanoramaSky::set_panorama(const Ref<Texture> &p_panorama) {
panorama = p_panorama;
if (panorama.is_valid()) {
_radiance_changed();
} else {
RS::get_singleton()->sky_set_texture(sky, RID(), 0);
}
}
Ref<Texture> PanoramaSky::get_panorama() const {
return panorama;
}
RID PanoramaSky::get_rid() const {
return sky;
}
void PanoramaSky::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_panorama", "texture"), &PanoramaSky::set_panorama);
ClassDB::bind_method(D_METHOD("get_panorama"), &PanoramaSky::get_panorama);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "panorama", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_panorama", "get_panorama");
}
PanoramaSky::PanoramaSky() {
sky = RS::get_singleton()->sky_create();
}
PanoramaSky::~PanoramaSky() {
RS::get_singleton()->free(sky);
}
//////////////////////////////////
void ProceduralSky::_radiance_changed() {
if (update_queued) {
return; //do nothing yet
}
static const int size[RADIANCE_SIZE_MAX] = {
32, 64, 128, 256, 512, 1024, 2048
};
RS::get_singleton()->sky_set_texture(sky, texture, size[get_radiance_size()]);
}
Ref<Image> ProceduralSky::_generate_sky() {
update_queued = false;
PoolVector<uint8_t> imgdata;
static const int size[TEXTURE_SIZE_MAX] = {
256, 512, 1024, 2048, 4096
};
int w = size[texture_size];
int h = w / 2;
imgdata.resize(w * h * 4); //RGBE
{
PoolVector<uint8_t>::Write dataw = imgdata.write();
uint32_t *ptr = (uint32_t *)dataw.ptr();
Color sky_top_linear = sky_top_color.to_linear();
Color sky_horizon_linear = sky_horizon_color.to_linear();
Color ground_bottom_linear = ground_bottom_color.to_linear();
Color ground_horizon_linear = ground_horizon_color.to_linear();
Color sun_linear;
sun_linear.r = sun_color.r * sun_energy;
sun_linear.g = sun_color.g * sun_energy;
sun_linear.b = sun_color.b * sun_energy;
Vector3 sun(0, 0, -1);
sun = Basis(Vector3(1, 0, 0), Math::deg2rad(sun_latitude)).xform(sun);
sun = Basis(Vector3(0, 1, 0), Math::deg2rad(sun_longitude)).xform(sun);
sun.normalize();
for (int i = 0; i < w; i++) {
float u = float(i) / (w - 1);
float phi = u * 2.0 * Math_PI;
for (int j = 0; j < h; j++) {
float v = float(j) / (h - 1);
float theta = v * Math_PI;
Vector3 normal(
Math::sin(phi) * Math::sin(theta) * -1.0,
Math::cos(theta),
Math::cos(phi) * Math::sin(theta) * -1.0);
normal.normalize();
// acos does clamping.
float v_angle = Math::acos(normal.y);
Color color;
if (normal.y < 0) {
//ground
float c = (v_angle - (Math_PI * 0.5)) / (Math_PI * 0.5);
color = ground_horizon_linear.linear_interpolate(ground_bottom_linear, Math::ease(c, ground_curve));
color.r *= ground_energy;
color.g *= ground_energy;
color.b *= ground_energy;
} else {
float c = v_angle / (Math_PI * 0.5);
color = sky_horizon_linear.linear_interpolate(sky_top_linear, Math::ease(1.0 - c, sky_curve));
color.r *= sky_energy;
color.g *= sky_energy;
color.b *= sky_energy;
// acos does clamping.
float sun_angle = Math::rad2deg(Math::acos(sun.dot(normal)));
if (sun_angle < sun_angle_min) {
color = color.blend(sun_linear);
} else if (sun_angle < sun_angle_max) {
float c2 = (sun_angle - sun_angle_min) / (sun_angle_max - sun_angle_min);
c2 = Math::ease(c2, sun_curve);
color = color.blend(sun_linear).linear_interpolate(color, c2);
}
}
ptr[j * w + i] = color.to_rgbe9995();
}
}
}
Ref<Image> image;
image.instance();
image->create(w, h, false, Image::FORMAT_RGBE9995, imgdata);
return image;
}
void ProceduralSky::set_sky_top_color(const Color &p_sky_top) {
sky_top_color = p_sky_top;
_queue_update();
}
Color ProceduralSky::get_sky_top_color() const {
return sky_top_color;
}
void ProceduralSky::set_sky_horizon_color(const Color &p_sky_horizon) {
sky_horizon_color = p_sky_horizon;
_queue_update();
}
Color ProceduralSky::get_sky_horizon_color() const {
return sky_horizon_color;
}
void ProceduralSky::set_sky_curve(float p_curve) {
sky_curve = p_curve;
_queue_update();
}
float ProceduralSky::get_sky_curve() const {
return sky_curve;
}
void ProceduralSky::set_sky_energy(float p_energy) {
sky_energy = p_energy;
_queue_update();
}
float ProceduralSky::get_sky_energy() const {
return sky_energy;
}
void ProceduralSky::set_ground_bottom_color(const Color &p_ground_bottom) {
ground_bottom_color = p_ground_bottom;
_queue_update();
}
Color ProceduralSky::get_ground_bottom_color() const {
return ground_bottom_color;
}
void ProceduralSky::set_ground_horizon_color(const Color &p_ground_horizon) {
ground_horizon_color = p_ground_horizon;
_queue_update();
}
Color ProceduralSky::get_ground_horizon_color() const {
return ground_horizon_color;
}
void ProceduralSky::set_ground_curve(float p_curve) {
ground_curve = p_curve;
_queue_update();
}
float ProceduralSky::get_ground_curve() const {
return ground_curve;
}
void ProceduralSky::set_ground_energy(float p_energy) {
ground_energy = p_energy;
_queue_update();
}
float ProceduralSky::get_ground_energy() const {
return ground_energy;
}
void ProceduralSky::set_sun_color(const Color &p_sun) {
sun_color = p_sun;
_queue_update();
}
Color ProceduralSky::get_sun_color() const {
return sun_color;
}
void ProceduralSky::set_sun_latitude(float p_angle) {
sun_latitude = p_angle;
_queue_update();
}
float ProceduralSky::get_sun_latitude() const {
return sun_latitude;
}
void ProceduralSky::set_sun_longitude(float p_angle) {
sun_longitude = p_angle;
_queue_update();
}
float ProceduralSky::get_sun_longitude() const {
return sun_longitude;
}
void ProceduralSky::set_sun_angle_min(float p_angle) {
sun_angle_min = p_angle;
_queue_update();
}
float ProceduralSky::get_sun_angle_min() const {
return sun_angle_min;
}
void ProceduralSky::set_sun_angle_max(float p_angle) {
sun_angle_max = p_angle;
_queue_update();
}
float ProceduralSky::get_sun_angle_max() const {
return sun_angle_max;
}
void ProceduralSky::set_sun_curve(float p_curve) {
sun_curve = p_curve;
_queue_update();
}
float ProceduralSky::get_sun_curve() const {
return sun_curve;
}
void ProceduralSky::set_sun_energy(float p_energy) {
sun_energy = p_energy;
_queue_update();
}
float ProceduralSky::get_sun_energy() const {
return sun_energy;
}
void ProceduralSky::set_texture_size(TextureSize p_size) {
ERR_FAIL_INDEX(p_size, TEXTURE_SIZE_MAX);
texture_size = p_size;
_queue_update();
}
ProceduralSky::TextureSize ProceduralSky::get_texture_size() const {
return texture_size;
}
Ref<Image> ProceduralSky::get_data() const {
return panorama->duplicate();
}
RID ProceduralSky::get_rid() const {
return sky;
}
void ProceduralSky::_update_sky() {
bool use_thread = true;
if (first_time) {
use_thread = false;
first_time = false;
}
#ifdef NO_THREADS
use_thread = false;
#endif
if (use_thread) {
if (!sky_thread.is_started()) {
sky_thread.start(_thread_function, this);
regen_queued = false;
} else {
regen_queued = true;
}
} else {
panorama = _generate_sky();
RS::get_singleton()->texture_allocate(texture, panorama->get_width(), panorama->get_height(), 0, Image::FORMAT_RGBE9995, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAG_FILTER | RS::TEXTURE_FLAG_REPEAT);
RS::get_singleton()->texture_set_data(texture, panorama);
_radiance_changed();
}
}
void ProceduralSky::_queue_update() {
if (update_queued) {
return;
}
update_queued = true;
call_deferred("_update_sky");
}
void ProceduralSky::_thread_done(const Ref<Image> &p_image) {
ERR_FAIL_COND(p_image.is_null());
panorama = p_image;
RS::get_singleton()->texture_allocate(texture, panorama->get_width(), panorama->get_height(), 0, Image::FORMAT_RGBE9995, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAG_FILTER | RS::TEXTURE_FLAG_REPEAT);
RS::get_singleton()->texture_set_data(texture, panorama);
_radiance_changed();
sky_thread.wait_to_finish();
if (regen_queued) {
sky_thread.start(_thread_function, this);
regen_queued = false;
}
}
void ProceduralSky::_thread_function(void *p_ud) {
ProceduralSky *psky = (ProceduralSky *)p_ud;
psky->call_deferred("_thread_done", psky->_generate_sky());
}
void ProceduralSky::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_sky"), &ProceduralSky::_update_sky);
ClassDB::bind_method(D_METHOD("set_sky_top_color", "color"), &ProceduralSky::set_sky_top_color);
ClassDB::bind_method(D_METHOD("get_sky_top_color"), &ProceduralSky::get_sky_top_color);
ClassDB::bind_method(D_METHOD("set_sky_horizon_color", "color"), &ProceduralSky::set_sky_horizon_color);
ClassDB::bind_method(D_METHOD("get_sky_horizon_color"), &ProceduralSky::get_sky_horizon_color);
ClassDB::bind_method(D_METHOD("set_sky_curve", "curve"), &ProceduralSky::set_sky_curve);
ClassDB::bind_method(D_METHOD("get_sky_curve"), &ProceduralSky::get_sky_curve);
ClassDB::bind_method(D_METHOD("set_sky_energy", "energy"), &ProceduralSky::set_sky_energy);
ClassDB::bind_method(D_METHOD("get_sky_energy"), &ProceduralSky::get_sky_energy);
ClassDB::bind_method(D_METHOD("set_ground_bottom_color", "color"), &ProceduralSky::set_ground_bottom_color);
ClassDB::bind_method(D_METHOD("get_ground_bottom_color"), &ProceduralSky::get_ground_bottom_color);
ClassDB::bind_method(D_METHOD("set_ground_horizon_color", "color"), &ProceduralSky::set_ground_horizon_color);
ClassDB::bind_method(D_METHOD("get_ground_horizon_color"), &ProceduralSky::get_ground_horizon_color);
ClassDB::bind_method(D_METHOD("set_ground_curve", "curve"), &ProceduralSky::set_ground_curve);
ClassDB::bind_method(D_METHOD("get_ground_curve"), &ProceduralSky::get_ground_curve);
ClassDB::bind_method(D_METHOD("set_ground_energy", "energy"), &ProceduralSky::set_ground_energy);
ClassDB::bind_method(D_METHOD("get_ground_energy"), &ProceduralSky::get_ground_energy);
ClassDB::bind_method(D_METHOD("set_sun_color", "color"), &ProceduralSky::set_sun_color);
ClassDB::bind_method(D_METHOD("get_sun_color"), &ProceduralSky::get_sun_color);
ClassDB::bind_method(D_METHOD("set_sun_latitude", "degrees"), &ProceduralSky::set_sun_latitude);
ClassDB::bind_method(D_METHOD("get_sun_latitude"), &ProceduralSky::get_sun_latitude);
ClassDB::bind_method(D_METHOD("set_sun_longitude", "degrees"), &ProceduralSky::set_sun_longitude);
ClassDB::bind_method(D_METHOD("get_sun_longitude"), &ProceduralSky::get_sun_longitude);
ClassDB::bind_method(D_METHOD("set_sun_angle_min", "degrees"), &ProceduralSky::set_sun_angle_min);
ClassDB::bind_method(D_METHOD("get_sun_angle_min"), &ProceduralSky::get_sun_angle_min);
ClassDB::bind_method(D_METHOD("set_sun_angle_max", "degrees"), &ProceduralSky::set_sun_angle_max);
ClassDB::bind_method(D_METHOD("get_sun_angle_max"), &ProceduralSky::get_sun_angle_max);
ClassDB::bind_method(D_METHOD("set_sun_curve", "curve"), &ProceduralSky::set_sun_curve);
ClassDB::bind_method(D_METHOD("get_sun_curve"), &ProceduralSky::get_sun_curve);
ClassDB::bind_method(D_METHOD("set_sun_energy", "energy"), &ProceduralSky::set_sun_energy);
ClassDB::bind_method(D_METHOD("get_sun_energy"), &ProceduralSky::get_sun_energy);
ClassDB::bind_method(D_METHOD("set_texture_size", "size"), &ProceduralSky::set_texture_size);
ClassDB::bind_method(D_METHOD("get_texture_size"), &ProceduralSky::get_texture_size);
ClassDB::bind_method(D_METHOD("_thread_done", "image"), &ProceduralSky::_thread_done);
ADD_GROUP("Sky", "sky_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_top_color"), "set_sky_top_color", "get_sky_top_color");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_horizon_color"), "set_sky_horizon_color", "get_sky_horizon_color");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sky_curve", PROPERTY_HINT_EXP_EASING), "set_sky_curve", "get_sky_curve");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sky_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_sky_energy", "get_sky_energy");
ADD_GROUP("Ground", "ground_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_bottom_color"), "set_ground_bottom_color", "get_ground_bottom_color");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_horizon_color"), "set_ground_horizon_color", "get_ground_horizon_color");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ground_curve", PROPERTY_HINT_EXP_EASING), "set_ground_curve", "get_ground_curve");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ground_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_ground_energy", "get_ground_energy");
ADD_GROUP("Sun", "sun_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sun_color"), "set_sun_color", "get_sun_color");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_latitude", PROPERTY_HINT_RANGE, "-180,180,0.01"), "set_sun_latitude", "get_sun_latitude");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_longitude", PROPERTY_HINT_RANGE, "-180,180,0.01"), "set_sun_longitude", "get_sun_longitude");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_angle_min", PROPERTY_HINT_RANGE, "0,360,0.01"), "set_sun_angle_min", "get_sun_angle_min");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_angle_max", PROPERTY_HINT_RANGE, "0,360,0.01"), "set_sun_angle_max", "get_sun_angle_max");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_curve", PROPERTY_HINT_EXP_EASING), "set_sun_curve", "get_sun_curve");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_sun_energy", "get_sun_energy");
ADD_GROUP("Texture", "texture_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_texture_size", "get_texture_size");
BIND_ENUM_CONSTANT(TEXTURE_SIZE_256);
BIND_ENUM_CONSTANT(TEXTURE_SIZE_512);
BIND_ENUM_CONSTANT(TEXTURE_SIZE_1024);
BIND_ENUM_CONSTANT(TEXTURE_SIZE_2048);
BIND_ENUM_CONSTANT(TEXTURE_SIZE_4096);
BIND_ENUM_CONSTANT(TEXTURE_SIZE_MAX);
}
ProceduralSky::ProceduralSky(bool p_desaturate) {
sky = RS::get_singleton()->sky_create();
texture = RID_PRIME(RS::get_singleton()->texture_create());
update_queued = false;
sky_top_color = Color::hex(0xa5d6f1ff);
sky_horizon_color = Color::hex(0xd6eafaff);
sky_curve = 0.09;
sky_energy = 1;
ground_bottom_color = Color::hex(0x282f36ff);
ground_horizon_color = Color::hex(0x6c655fff);
ground_curve = 0.02;
ground_energy = 1;
if (p_desaturate) {
sky_top_color.set_hsv(sky_top_color.get_h(), 0, sky_top_color.get_v());
sky_horizon_color.set_hsv(sky_horizon_color.get_h(), 0, sky_horizon_color.get_v());
ground_bottom_color.set_hsv(ground_bottom_color.get_h(), 0, ground_bottom_color.get_v());
ground_horizon_color.set_hsv(ground_horizon_color.get_h(), 0, ground_horizon_color.get_v());
}
sun_color = Color(1, 1, 1);
sun_latitude = 35;
sun_longitude = 0;
sun_angle_min = 1;
sun_angle_max = 100;
sun_curve = 0.05;
sun_energy = 1;
texture_size = TEXTURE_SIZE_1024;
regen_queued = false;
first_time = true;
_queue_update();
}
ProceduralSky::~ProceduralSky() {
if (sky_thread.is_started()) {
sky_thread.wait_to_finish();
}
RS::get_singleton()->free(sky);
RS::get_singleton()->free(texture);
}

View File

@ -1,202 +0,0 @@
#ifndef SKY_H
#define SKY_H
/*************************************************************************/
/* sky.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/os/thread.h"
#include "scene/resources/texture.h"
class Sky : public Resource {
GDCLASS(Sky, Resource);
public:
enum RadianceSize {
RADIANCE_SIZE_32,
RADIANCE_SIZE_64,
RADIANCE_SIZE_128,
RADIANCE_SIZE_256,
RADIANCE_SIZE_512,
RADIANCE_SIZE_1024,
RADIANCE_SIZE_2048,
RADIANCE_SIZE_MAX
};
private:
RadianceSize radiance_size;
protected:
static void _bind_methods();
virtual void _radiance_changed() = 0;
public:
void set_radiance_size(RadianceSize p_size);
RadianceSize get_radiance_size() const;
Sky();
};
VARIANT_ENUM_CAST(Sky::RadianceSize)
class PanoramaSky : public Sky {
GDCLASS(PanoramaSky, Sky);
private:
RID sky;
Ref<Texture> panorama;
protected:
static void _bind_methods();
virtual void _radiance_changed();
public:
void set_panorama(const Ref<Texture> &p_panorama);
Ref<Texture> get_panorama() const;
virtual RID get_rid() const;
PanoramaSky();
~PanoramaSky();
};
class ProceduralSky : public Sky {
GDCLASS(ProceduralSky, Sky);
public:
enum TextureSize {
TEXTURE_SIZE_256,
TEXTURE_SIZE_512,
TEXTURE_SIZE_1024,
TEXTURE_SIZE_2048,
TEXTURE_SIZE_4096,
TEXTURE_SIZE_MAX
};
private:
Thread sky_thread;
Color sky_top_color;
Color sky_horizon_color;
float sky_curve;
float sky_energy;
Color ground_bottom_color;
Color ground_horizon_color;
float ground_curve;
float ground_energy;
Color sun_color;
float sun_latitude;
float sun_longitude;
float sun_angle_min;
float sun_angle_max;
float sun_curve;
float sun_energy;
TextureSize texture_size;
RID sky;
RID texture;
Ref<Image> panorama;
bool update_queued;
bool regen_queued;
bool first_time;
void _thread_done(const Ref<Image> &p_image);
static void _thread_function(void *p_ud);
protected:
static void _bind_methods();
virtual void _radiance_changed();
Ref<Image> _generate_sky();
void _update_sky();
void _queue_update();
public:
void set_sky_top_color(const Color &p_sky_top);
Color get_sky_top_color() const;
void set_sky_horizon_color(const Color &p_sky_horizon);
Color get_sky_horizon_color() const;
void set_sky_curve(float p_curve);
float get_sky_curve() const;
void set_sky_energy(float p_energy);
float get_sky_energy() const;
void set_ground_bottom_color(const Color &p_ground_bottom);
Color get_ground_bottom_color() const;
void set_ground_horizon_color(const Color &p_ground_horizon);
Color get_ground_horizon_color() const;
void set_ground_curve(float p_curve);
float get_ground_curve() const;
void set_ground_energy(float p_energy);
float get_ground_energy() const;
void set_sun_color(const Color &p_sun);
Color get_sun_color() const;
void set_sun_latitude(float p_angle);
float get_sun_latitude() const;
void set_sun_longitude(float p_angle);
float get_sun_longitude() const;
void set_sun_angle_min(float p_angle);
float get_sun_angle_min() const;
void set_sun_angle_max(float p_angle);
float get_sun_angle_max() const;
void set_sun_curve(float p_curve);
float get_sun_curve() const;
void set_sun_energy(float p_energy);
float get_sun_energy() const;
void set_texture_size(TextureSize p_size);
TextureSize get_texture_size() const;
Ref<Image> get_data() const;
virtual RID get_rid() const;
ProceduralSky(bool p_desaturate = false);
~ProceduralSky();
};
VARIANT_ENUM_CAST(ProceduralSky::TextureSize)
#endif // SKY_H

View File

@ -39,7 +39,6 @@
#include "core/config/engine.h"
#include "core/config/project_settings.h"
#include "scene/resources/material/material.h"
#include "scene/resources/material/spatial_material.h"
#endif
NavigationServer *NavigationServer::singleton = nullptr;
@ -307,285 +306,8 @@ void NavigationServer::_emit_avoidance_debug_changed_signal() {
#endif // DEBUG_ENABLED
#ifdef DEBUG_ENABLED
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_geometry_face_material() {
if (_debug_navigation_geometry_face_material.is_valid()) {
return _debug_navigation_geometry_face_material;
}
bool enabled_geometry_face_random_color = get_debug_navigation_enable_geometry_face_random_color();
Color debug_navigation_geometry_face_color = get_debug_navigation_geometry_face_color();
Ref<SpatialMaterial> face_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
face_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
face_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
face_material->set_albedo(debug_navigation_geometry_face_color);
face_material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
if (enabled_geometry_face_random_color) {
face_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
face_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
}
_debug_navigation_geometry_face_material = face_material;
return _debug_navigation_geometry_face_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_geometry_edge_material() {
if (_debug_navigation_geometry_edge_material.is_valid()) {
return _debug_navigation_geometry_edge_material;
}
bool enabled_edge_lines_xray = get_debug_navigation_enable_edge_lines_xray();
Color debug_navigation_geometry_edge_color = get_debug_navigation_geometry_edge_color();
Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
line_material->set_albedo(debug_navigation_geometry_edge_color);
if (enabled_edge_lines_xray) {
line_material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
}
_debug_navigation_geometry_edge_material = line_material;
return _debug_navigation_geometry_edge_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_geometry_face_disabled_material() {
if (_debug_navigation_geometry_face_disabled_material.is_valid()) {
return _debug_navigation_geometry_face_disabled_material;
}
Color debug_navigation_geometry_face_disabled_color = get_debug_navigation_geometry_face_disabled_color();
Ref<SpatialMaterial> face_disabled_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
face_disabled_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
face_disabled_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
face_disabled_material->set_albedo(debug_navigation_geometry_face_disabled_color);
_debug_navigation_geometry_face_disabled_material = face_disabled_material;
return _debug_navigation_geometry_face_disabled_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_geometry_edge_disabled_material() {
if (_debug_navigation_geometry_edge_disabled_material.is_valid()) {
return _debug_navigation_geometry_edge_disabled_material;
}
bool enabled_edge_lines_xray = get_debug_navigation_enable_edge_lines_xray();
Color debug_navigation_geometry_edge_disabled_color = get_debug_navigation_geometry_edge_disabled_color();
Ref<SpatialMaterial> line_disabled_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
line_disabled_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
line_disabled_material->set_albedo(debug_navigation_geometry_edge_disabled_color);
if (enabled_edge_lines_xray) {
line_disabled_material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
}
_debug_navigation_geometry_edge_disabled_material = line_disabled_material;
return _debug_navigation_geometry_edge_disabled_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_edge_connections_material() {
if (_debug_navigation_edge_connections_material.is_valid()) {
return _debug_navigation_edge_connections_material;
}
bool enabled_edge_connections_xray = get_debug_navigation_enable_edge_connections_xray();
Color debug_navigation_edge_connection_color = get_debug_navigation_edge_connection_color();
Ref<SpatialMaterial> edge_connections_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
edge_connections_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
edge_connections_material->set_albedo(debug_navigation_edge_connection_color);
if (enabled_edge_connections_xray) {
edge_connections_material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
}
edge_connections_material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MAX - 2);
_debug_navigation_edge_connections_material = edge_connections_material;
return _debug_navigation_edge_connections_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_link_connections_material() {
if (_debug_navigation_link_connections_material.is_valid()) {
return _debug_navigation_link_connections_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
material->set_albedo(_debug_navigation_link_connection_color);
if (_debug_navigation_enable_link_connections_xray) {
material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
}
material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MAX - 2);
_debug_navigation_link_connections_material = material;
return _debug_navigation_link_connections_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_link_connections_disabled_material() {
if (_debug_navigation_link_connections_disabled_material.is_valid()) {
return _debug_navigation_link_connections_disabled_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
material->set_albedo(_debug_navigation_link_connection_disabled_color);
if (_debug_navigation_enable_link_connections_xray) {
material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
}
material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MAX - 2);
_debug_navigation_link_connections_disabled_material = material;
return _debug_navigation_link_connections_disabled_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_agent_path_line_material() {
if (_debug_navigation_agent_path_line_material.is_valid()) {
return _debug_navigation_agent_path_line_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
material->set_albedo(_debug_navigation_agent_path_color);
if (_debug_navigation_enable_agent_paths_xray) {
material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
}
material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MAX - 2);
_debug_navigation_agent_path_line_material = material;
return _debug_navigation_agent_path_line_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_agent_path_point_material() {
if (_debug_navigation_agent_path_point_material.is_valid()) {
return _debug_navigation_agent_path_point_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
//material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
material->set_albedo(_debug_navigation_agent_path_color);
material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
material->set_point_size(_debug_navigation_agent_path_point_size);
if (_debug_navigation_enable_agent_paths_xray) {
material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
}
material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MAX - 2);
_debug_navigation_agent_path_point_material = material;
return _debug_navigation_agent_path_point_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_avoidance_agents_radius_material() {
if (_debug_navigation_avoidance_agents_radius_material.is_valid()) {
return _debug_navigation_avoidance_agents_radius_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
material->set_albedo(_debug_navigation_avoidance_agents_radius_color);
material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 2);
_debug_navigation_avoidance_agents_radius_material = material;
return _debug_navigation_avoidance_agents_radius_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_avoidance_obstacles_radius_material() {
if (_debug_navigation_avoidance_obstacles_radius_material.is_valid()) {
return _debug_navigation_avoidance_obstacles_radius_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
material->set_albedo(_debug_navigation_avoidance_obstacles_radius_color);
material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 2);
_debug_navigation_avoidance_obstacles_radius_material = material;
return _debug_navigation_avoidance_obstacles_radius_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushin_face_material() {
if (_debug_navigation_avoidance_static_obstacle_pushin_face_material.is_valid()) {
return _debug_navigation_avoidance_static_obstacle_pushin_face_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
material->set_albedo(_debug_navigation_avoidance_static_obstacle_pushin_face_color);
material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 2);
_debug_navigation_avoidance_static_obstacle_pushin_face_material = material;
return _debug_navigation_avoidance_static_obstacle_pushin_face_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushout_face_material() {
if (_debug_navigation_avoidance_static_obstacle_pushout_face_material.is_valid()) {
return _debug_navigation_avoidance_static_obstacle_pushout_face_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
material->set_albedo(_debug_navigation_avoidance_static_obstacle_pushout_face_color);
material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 2);
_debug_navigation_avoidance_static_obstacle_pushout_face_material = material;
return _debug_navigation_avoidance_static_obstacle_pushout_face_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushin_edge_material() {
if (_debug_navigation_avoidance_static_obstacle_pushin_edge_material.is_valid()) {
return _debug_navigation_avoidance_static_obstacle_pushin_edge_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
//material->set_transparency(SpatialMaterial::TRANSPARENCY_ALPHA);
//material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
material->set_albedo(_debug_navigation_avoidance_static_obstacle_pushin_edge_color);
//material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 2);
material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
_debug_navigation_avoidance_static_obstacle_pushin_edge_material = material;
return _debug_navigation_avoidance_static_obstacle_pushin_edge_material;
}
Ref<SpatialMaterial> NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushout_edge_material() {
if (_debug_navigation_avoidance_static_obstacle_pushout_edge_material.is_valid()) {
return _debug_navigation_avoidance_static_obstacle_pushout_edge_material;
}
Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
///material->set_transparency(SpatialMaterial::TRANSPARENCY_ALPHA);
//material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
material->set_albedo(_debug_navigation_avoidance_static_obstacle_pushout_edge_color);
//material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 2);
material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
_debug_navigation_avoidance_static_obstacle_pushout_edge_material = material;
return _debug_navigation_avoidance_static_obstacle_pushout_edge_material;
}
void NavigationServer::set_debug_navigation_edge_connection_color(const Color &p_color) {
_debug_navigation_edge_connection_color = p_color;
if (_debug_navigation_edge_connections_material.is_valid()) {
_debug_navigation_edge_connections_material->set_albedo(_debug_navigation_edge_connection_color);
}
}
Color NavigationServer::get_debug_navigation_edge_connection_color() const {
@ -594,9 +316,6 @@ Color NavigationServer::get_debug_navigation_edge_connection_color() const {
void NavigationServer::set_debug_navigation_geometry_edge_color(const Color &p_color) {
_debug_navigation_geometry_edge_color = p_color;
if (_debug_navigation_geometry_edge_material.is_valid()) {
_debug_navigation_geometry_edge_material->set_albedo(_debug_navigation_geometry_edge_color);
}
}
Color NavigationServer::get_debug_navigation_geometry_edge_color() const {
@ -605,9 +324,6 @@ Color NavigationServer::get_debug_navigation_geometry_edge_color() const {
void NavigationServer::set_debug_navigation_geometry_face_color(const Color &p_color) {
_debug_navigation_geometry_face_color = p_color;
if (_debug_navigation_geometry_face_material.is_valid()) {
_debug_navigation_geometry_face_material->set_albedo(_debug_navigation_geometry_face_color);
}
}
Color NavigationServer::get_debug_navigation_geometry_face_color() const {
@ -616,9 +332,6 @@ Color NavigationServer::get_debug_navigation_geometry_face_color() const {
void NavigationServer::set_debug_navigation_geometry_edge_disabled_color(const Color &p_color) {
_debug_navigation_geometry_edge_disabled_color = p_color;
if (_debug_navigation_geometry_edge_disabled_material.is_valid()) {
_debug_navigation_geometry_edge_disabled_material->set_albedo(_debug_navigation_geometry_edge_disabled_color);
}
}
Color NavigationServer::get_debug_navigation_geometry_edge_disabled_color() const {
@ -627,9 +340,6 @@ Color NavigationServer::get_debug_navigation_geometry_edge_disabled_color() cons
void NavigationServer::set_debug_navigation_geometry_face_disabled_color(const Color &p_color) {
_debug_navigation_geometry_face_disabled_color = p_color;
if (_debug_navigation_geometry_face_disabled_material.is_valid()) {
_debug_navigation_geometry_face_disabled_material->set_albedo(_debug_navigation_geometry_face_disabled_color);
}
}
Color NavigationServer::get_debug_navigation_geometry_face_disabled_color() const {
@ -638,9 +348,6 @@ Color NavigationServer::get_debug_navigation_geometry_face_disabled_color() cons
void NavigationServer::set_debug_navigation_link_connection_color(const Color &p_color) {
_debug_navigation_link_connection_color = p_color;
if (_debug_navigation_link_connections_material.is_valid()) {
_debug_navigation_link_connections_material->set_albedo(_debug_navigation_link_connection_color);
}
}
Color NavigationServer::get_debug_navigation_link_connection_color() const {
@ -649,9 +356,6 @@ Color NavigationServer::get_debug_navigation_link_connection_color() const {
void NavigationServer::set_debug_navigation_link_connection_disabled_color(const Color &p_color) {
_debug_navigation_link_connection_disabled_color = p_color;
if (_debug_navigation_link_connections_disabled_material.is_valid()) {
_debug_navigation_link_connections_disabled_material->set_albedo(_debug_navigation_link_connection_disabled_color);
}
}
Color NavigationServer::get_debug_navigation_link_connection_disabled_color() const {
@ -660,9 +364,6 @@ Color NavigationServer::get_debug_navigation_link_connection_disabled_color() co
void NavigationServer::set_debug_navigation_agent_path_point_size(float p_point_size) {
_debug_navigation_agent_path_point_size = MAX(0.1, p_point_size);
if (_debug_navigation_agent_path_point_material.is_valid()) {
_debug_navigation_agent_path_point_material->set_point_size(_debug_navigation_agent_path_point_size);
}
}
float NavigationServer::get_debug_navigation_agent_path_point_size() const {
@ -671,12 +372,6 @@ float NavigationServer::get_debug_navigation_agent_path_point_size() const {
void NavigationServer::set_debug_navigation_agent_path_color(const Color &p_color) {
_debug_navigation_agent_path_color = p_color;
if (_debug_navigation_agent_path_line_material.is_valid()) {
_debug_navigation_agent_path_line_material->set_albedo(_debug_navigation_agent_path_color);
}
if (_debug_navigation_agent_path_point_material.is_valid()) {
_debug_navigation_agent_path_point_material->set_albedo(_debug_navigation_agent_path_color);
}
}
Color NavigationServer::get_debug_navigation_agent_path_color() const {
@ -695,9 +390,6 @@ bool NavigationServer::get_debug_navigation_enable_edge_connections() const {
void NavigationServer::set_debug_navigation_enable_edge_connections_xray(const bool p_value) {
_debug_navigation_enable_edge_connections_xray = p_value;
if (_debug_navigation_edge_connections_material.is_valid()) {
_debug_navigation_edge_connections_material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, _debug_navigation_enable_edge_connections_xray);
}
}
bool NavigationServer::get_debug_navigation_enable_edge_connections_xray() const {
@ -716,9 +408,6 @@ bool NavigationServer::get_debug_navigation_enable_edge_lines() const {
void NavigationServer::set_debug_navigation_enable_edge_lines_xray(const bool p_value) {
_debug_navigation_enable_edge_lines_xray = p_value;
if (_debug_navigation_geometry_edge_material.is_valid()) {
_debug_navigation_geometry_edge_material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, _debug_navigation_enable_edge_lines_xray);
}
}
bool NavigationServer::get_debug_navigation_enable_edge_lines_xray() const {
@ -747,9 +436,6 @@ bool NavigationServer::get_debug_navigation_enable_link_connections() const {
void NavigationServer::set_debug_navigation_enable_link_connections_xray(const bool p_value) {
_debug_navigation_enable_link_connections_xray = p_value;
if (_debug_navigation_link_connections_material.is_valid()) {
_debug_navigation_link_connections_material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, _debug_navigation_enable_link_connections_xray);
}
}
bool NavigationServer::get_debug_navigation_enable_link_connections_xray() const {
@ -788,9 +474,6 @@ bool NavigationServer::get_debug_navigation_avoidance_enable_obstacles_static()
void NavigationServer::set_debug_navigation_avoidance_agents_radius_color(const Color &p_color) {
_debug_navigation_avoidance_agents_radius_color = p_color;
if (_debug_navigation_avoidance_agents_radius_material.is_valid()) {
_debug_navigation_avoidance_agents_radius_material->set_albedo(_debug_navigation_avoidance_agents_radius_color);
}
}
Color NavigationServer::get_debug_navigation_avoidance_agents_radius_color() const {
@ -799,9 +482,6 @@ Color NavigationServer::get_debug_navigation_avoidance_agents_radius_color() con
void NavigationServer::set_debug_navigation_avoidance_obstacles_radius_color(const Color &p_color) {
_debug_navigation_avoidance_obstacles_radius_color = p_color;
if (_debug_navigation_avoidance_obstacles_radius_material.is_valid()) {
_debug_navigation_avoidance_obstacles_radius_material->set_albedo(_debug_navigation_avoidance_obstacles_radius_color);
}
}
Color NavigationServer::get_debug_navigation_avoidance_obstacles_radius_color() const {
@ -810,9 +490,6 @@ Color NavigationServer::get_debug_navigation_avoidance_obstacles_radius_color()
void NavigationServer::set_debug_navigation_avoidance_static_obstacle_pushin_face_color(const Color &p_color) {
_debug_navigation_avoidance_static_obstacle_pushin_face_color = p_color;
if (_debug_navigation_avoidance_static_obstacle_pushin_face_material.is_valid()) {
_debug_navigation_avoidance_static_obstacle_pushin_face_material->set_albedo(_debug_navigation_avoidance_static_obstacle_pushin_face_color);
}
}
Color NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushin_face_color() const {
@ -821,9 +498,6 @@ Color NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushin_fa
void NavigationServer::set_debug_navigation_avoidance_static_obstacle_pushout_face_color(const Color &p_color) {
_debug_navigation_avoidance_static_obstacle_pushout_face_color = p_color;
if (_debug_navigation_avoidance_static_obstacle_pushout_face_material.is_valid()) {
_debug_navigation_avoidance_static_obstacle_pushout_face_material->set_albedo(_debug_navigation_avoidance_static_obstacle_pushout_face_color);
}
}
Color NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushout_face_color() const {
@ -832,9 +506,6 @@ Color NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushout_f
void NavigationServer::set_debug_navigation_avoidance_static_obstacle_pushin_edge_color(const Color &p_color) {
_debug_navigation_avoidance_static_obstacle_pushin_edge_color = p_color;
if (_debug_navigation_avoidance_static_obstacle_pushin_edge_material.is_valid()) {
_debug_navigation_avoidance_static_obstacle_pushin_edge_material->set_albedo(_debug_navigation_avoidance_static_obstacle_pushin_edge_color);
}
}
Color NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushin_edge_color() const {
@ -843,9 +514,6 @@ Color NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushin_ed
void NavigationServer::set_debug_navigation_avoidance_static_obstacle_pushout_edge_color(const Color &p_color) {
_debug_navigation_avoidance_static_obstacle_pushout_edge_color = p_color;
if (_debug_navigation_avoidance_static_obstacle_pushout_edge_material.is_valid()) {
_debug_navigation_avoidance_static_obstacle_pushout_edge_material->set_albedo(_debug_navigation_avoidance_static_obstacle_pushout_edge_color);
}
}
Color NavigationServer::get_debug_navigation_avoidance_static_obstacle_pushout_edge_color() const {
@ -870,12 +538,6 @@ bool NavigationServer::get_debug_navigation_enable_agent_paths() const {
void NavigationServer::set_debug_navigation_enable_agent_paths_xray(const bool p_value) {
_debug_navigation_enable_agent_paths_xray = p_value;
if (_debug_navigation_agent_path_line_material.is_valid()) {
_debug_navigation_agent_path_line_material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, _debug_navigation_enable_agent_paths_xray);
}
if (_debug_navigation_agent_path_point_material.is_valid()) {
_debug_navigation_agent_path_point_material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, _debug_navigation_enable_agent_paths_xray);
}
}
bool NavigationServer::get_debug_navigation_enable_agent_paths_xray() const {

View File

@ -38,7 +38,6 @@
#include "core/object/reference.h"
class NavigationMesh;
class SpatialMaterial;
class NavigationPathQueryParameters3D;
class NavigationPathQueryResult3D;
@ -415,25 +414,6 @@ public:
void set_debug_navigation_avoidance_enable_obstacles_static(const bool p_value);
bool get_debug_navigation_avoidance_enable_obstacles_static() const;
Ref<SpatialMaterial> get_debug_navigation_geometry_face_material();
Ref<SpatialMaterial> get_debug_navigation_geometry_edge_material();
Ref<SpatialMaterial> get_debug_navigation_geometry_face_disabled_material();
Ref<SpatialMaterial> get_debug_navigation_geometry_edge_disabled_material();
Ref<SpatialMaterial> get_debug_navigation_edge_connections_material();
Ref<SpatialMaterial> get_debug_navigation_link_connections_material();
Ref<SpatialMaterial> get_debug_navigation_link_connections_disabled_material();
Ref<SpatialMaterial> get_debug_navigation_agent_path_line_material();
Ref<SpatialMaterial> get_debug_navigation_agent_path_point_material();
Ref<SpatialMaterial> get_debug_navigation_avoidance_agents_radius_material();
Ref<SpatialMaterial> get_debug_navigation_avoidance_obstacles_radius_material();
Ref<SpatialMaterial> get_debug_navigation_avoidance_static_obstacle_pushin_face_material();
Ref<SpatialMaterial> get_debug_navigation_avoidance_static_obstacle_pushout_face_material();
Ref<SpatialMaterial> get_debug_navigation_avoidance_static_obstacle_pushin_edge_material();
Ref<SpatialMaterial> get_debug_navigation_avoidance_static_obstacle_pushout_edge_material();
protected:
bool _debug_enabled;
bool _debug_dirty;
@ -479,24 +459,6 @@ protected:
bool _debug_navigation_avoidance_enable_obstacles_radius;
bool _debug_navigation_avoidance_enable_obstacles_static;
Ref<SpatialMaterial> _debug_navigation_geometry_edge_material;
Ref<SpatialMaterial> _debug_navigation_geometry_face_material;
Ref<SpatialMaterial> _debug_navigation_geometry_edge_disabled_material;
Ref<SpatialMaterial> _debug_navigation_geometry_face_disabled_material;
Ref<SpatialMaterial> _debug_navigation_edge_connections_material;
Ref<SpatialMaterial> _debug_navigation_link_connections_material;
Ref<SpatialMaterial> _debug_navigation_link_connections_disabled_material;
Ref<SpatialMaterial> _debug_navigation_avoidance_agents_radius_material;
Ref<SpatialMaterial> _debug_navigation_avoidance_obstacles_radius_material;
Ref<SpatialMaterial> _debug_navigation_avoidance_static_obstacle_pushin_face_material;
Ref<SpatialMaterial> _debug_navigation_avoidance_static_obstacle_pushout_face_material;
Ref<SpatialMaterial> _debug_navigation_avoidance_static_obstacle_pushin_edge_material;
Ref<SpatialMaterial> _debug_navigation_avoidance_static_obstacle_pushout_edge_material;
Ref<SpatialMaterial> _debug_navigation_agent_path_line_material;
Ref<SpatialMaterial> _debug_navigation_agent_path_point_material;
#endif // DEBUG_ENABLED
};