2017-03-05 15:47:28 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* reflection_probe.cpp */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2016-11-19 17:23:37 +01:00
|
|
|
#include "reflection_probe.h"
|
|
|
|
|
|
|
|
void ReflectionProbe::set_intensity(float p_intensity) {
|
|
|
|
intensity = p_intensity;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
float ReflectionProbe::get_intensity() const {
|
|
|
|
return intensity;
|
|
|
|
}
|
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
void ReflectionProbe::set_ambient_mode(AmbientMode p_mode) {
|
|
|
|
ambient_mode = p_mode;
|
|
|
|
RS::get_singleton()->reflection_probe_set_ambient_mode(probe, RS::ReflectionProbeAmbientMode(p_mode));
|
2021-02-10 21:18:45 +01:00
|
|
|
notify_property_list_changed();
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
ReflectionProbe::AmbientMode ReflectionProbe::get_ambient_mode() const {
|
|
|
|
return ambient_mode;
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
void ReflectionProbe::set_ambient_color(Color p_ambient) {
|
|
|
|
ambient_color = p_ambient;
|
|
|
|
RS::get_singleton()->reflection_probe_set_ambient_color(probe, p_ambient);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
void ReflectionProbe::set_ambient_color_energy(float p_energy) {
|
|
|
|
ambient_color_energy = p_energy;
|
|
|
|
RS::get_singleton()->reflection_probe_set_ambient_energy(probe, p_energy);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
float ReflectionProbe::get_ambient_color_energy() const {
|
|
|
|
return ambient_color_energy;
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
Color ReflectionProbe::get_ambient_color() const {
|
|
|
|
return ambient_color;
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReflectionProbe::set_max_distance(float p_distance) {
|
2023-09-27 02:19:59 +02:00
|
|
|
max_distance = CLAMP(p_distance, 0.0, 262'144.0);
|
|
|
|
// Reflection rendering breaks if distance exceeds 262,144 units (due to floating-point precision with the near plane being 0.01).
|
|
|
|
RS::get_singleton()->reflection_probe_set_max_distance(probe, max_distance);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
2020-05-14 14:29:06 +02:00
|
|
|
|
2016-11-19 17:23:37 +01:00
|
|
|
float ReflectionProbe::get_max_distance() const {
|
|
|
|
return max_distance;
|
|
|
|
}
|
|
|
|
|
2021-12-29 00:10:41 +01:00
|
|
|
void ReflectionProbe::set_mesh_lod_threshold(float p_pixels) {
|
|
|
|
mesh_lod_threshold = p_pixels;
|
|
|
|
RS::get_singleton()->reflection_probe_set_mesh_lod_threshold(probe, p_pixels);
|
2020-12-17 19:56:59 +01:00
|
|
|
}
|
|
|
|
|
2021-12-29 00:10:41 +01:00
|
|
|
float ReflectionProbe::get_mesh_lod_threshold() const {
|
|
|
|
return mesh_lod_threshold;
|
2020-12-17 19:56:59 +01:00
|
|
|
}
|
|
|
|
|
2022-07-12 09:43:01 +02:00
|
|
|
void ReflectionProbe::set_size(const Vector3 &p_size) {
|
|
|
|
size = p_size;
|
2016-11-19 17:23:37 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
2022-07-12 09:43:01 +02:00
|
|
|
float half_size = size[i] / 2;
|
|
|
|
if (half_size < 0.01) {
|
|
|
|
half_size = 0.01;
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
2022-07-12 09:43:01 +02:00
|
|
|
if (half_size - 0.01 < ABS(origin_offset[i])) {
|
|
|
|
origin_offset[i] = SIGN(origin_offset[i]) * (half_size - 0.01);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 09:43:01 +02:00
|
|
|
RS::get_singleton()->reflection_probe_set_size(probe, size);
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
|
2021-02-10 21:18:45 +01:00
|
|
|
|
2021-06-23 16:49:50 +02:00
|
|
|
update_gizmos();
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
2020-05-14 14:29:06 +02:00
|
|
|
|
2022-07-12 09:43:01 +02:00
|
|
|
Vector3 ReflectionProbe::get_size() const {
|
|
|
|
return size;
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
2022-07-12 09:43:01 +02:00
|
|
|
void ReflectionProbe::set_origin_offset(const Vector3 &p_offset) {
|
|
|
|
origin_offset = p_offset;
|
2016-11-19 17:23:37 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
2022-07-12 09:43:01 +02:00
|
|
|
float half_size = size[i] / 2;
|
|
|
|
if (half_size - 0.01 < ABS(origin_offset[i])) {
|
|
|
|
origin_offset[i] = SIGN(origin_offset[i]) * (half_size - 0.01);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
}
|
2022-07-12 09:43:01 +02:00
|
|
|
RS::get_singleton()->reflection_probe_set_size(probe, size);
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2021-06-23 16:49:50 +02:00
|
|
|
update_gizmos();
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
2020-05-14 14:29:06 +02:00
|
|
|
|
2016-11-19 17:23:37 +01:00
|
|
|
Vector3 ReflectionProbe::get_origin_offset() const {
|
|
|
|
return origin_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReflectionProbe::set_enable_box_projection(bool p_enable) {
|
|
|
|
box_projection = p_enable;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->reflection_probe_set_enable_box_projection(probe, p_enable);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
2020-05-14 14:29:06 +02:00
|
|
|
|
2016-11-19 17:23:37 +01:00
|
|
|
bool ReflectionProbe::is_box_projection_enabled() const {
|
|
|
|
return box_projection;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReflectionProbe::set_as_interior(bool p_enable) {
|
|
|
|
interior = p_enable;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->reflection_probe_set_as_interior(probe, interior);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ReflectionProbe::is_set_as_interior() const {
|
|
|
|
return interior;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReflectionProbe::set_enable_shadows(bool p_enable) {
|
|
|
|
enable_shadows = p_enable;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
2020-05-14 14:29:06 +02:00
|
|
|
|
2016-11-19 17:23:37 +01:00
|
|
|
bool ReflectionProbe::are_shadows_enabled() const {
|
|
|
|
return enable_shadows;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReflectionProbe::set_cull_mask(uint32_t p_layers) {
|
|
|
|
cull_mask = p_layers;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
2020-05-14 14:29:06 +02:00
|
|
|
|
2016-11-19 17:23:37 +01:00
|
|
|
uint32_t ReflectionProbe::get_cull_mask() const {
|
|
|
|
return cull_mask;
|
|
|
|
}
|
|
|
|
|
2023-12-12 13:20:41 +01:00
|
|
|
void ReflectionProbe::set_reflection_mask(uint32_t p_layers) {
|
|
|
|
reflection_mask = p_layers;
|
|
|
|
RS::get_singleton()->reflection_probe_set_reflection_mask(probe, p_layers);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t ReflectionProbe::get_reflection_mask() const {
|
|
|
|
return reflection_mask;
|
|
|
|
}
|
|
|
|
|
2016-11-19 17:23:37 +01:00
|
|
|
void ReflectionProbe::set_update_mode(UpdateMode p_mode) {
|
|
|
|
update_mode = p_mode;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->reflection_probe_set_update_mode(probe, RS::ReflectionProbeUpdateMode(p_mode));
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
|
|
|
|
return update_mode;
|
|
|
|
}
|
|
|
|
|
2017-11-17 03:09:00 +01:00
|
|
|
AABB ReflectionProbe::get_aabb() const {
|
|
|
|
AABB aabb;
|
2017-06-06 20:33:51 +02:00
|
|
|
aabb.position = -origin_offset;
|
2022-07-12 09:43:01 +02:00
|
|
|
aabb.size = origin_offset + size / 2;
|
2016-11-19 17:23:37 +01:00
|
|
|
return aabb;
|
|
|
|
}
|
2020-05-14 14:29:06 +02:00
|
|
|
|
2024-02-17 19:03:21 +01:00
|
|
|
PackedStringArray ReflectionProbe::get_configuration_warnings() const {
|
|
|
|
PackedStringArray warnings = Node::get_configuration_warnings();
|
2023-02-26 01:24:41 +01:00
|
|
|
|
|
|
|
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
|
|
|
|
warnings.push_back(RTR("ReflectionProbes are not supported when using the GL Compatibility backend yet. Support will be added in a future release."));
|
|
|
|
return warnings;
|
|
|
|
}
|
|
|
|
|
|
|
|
return warnings;
|
|
|
|
}
|
|
|
|
|
2022-08-12 22:57:11 +02:00
|
|
|
void ReflectionProbe::_validate_property(PropertyInfo &p_property) const {
|
|
|
|
if (p_property.name == "ambient_color" || p_property.name == "ambient_color_energy") {
|
2020-06-25 15:33:28 +02:00
|
|
|
if (ambient_mode != AMBIENT_COLOR) {
|
2022-08-12 22:57:11 +02:00
|
|
|
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReflectionProbe::_bind_methods() {
|
2017-02-13 12:47:24 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_intensity", "intensity"), &ReflectionProbe::set_intensity);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_intensity"), &ReflectionProbe::get_intensity);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("set_ambient_mode", "ambient"), &ReflectionProbe::set_ambient_mode);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_ambient_mode"), &ReflectionProbe::get_ambient_mode);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("set_ambient_color", "ambient"), &ReflectionProbe::set_ambient_color);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_ambient_color"), &ReflectionProbe::get_ambient_color);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("set_ambient_color_energy", "ambient_energy"), &ReflectionProbe::set_ambient_color_energy);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_ambient_color_energy"), &ReflectionProbe::get_ambient_color_energy);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2017-02-13 12:47:24 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_max_distance", "max_distance"), &ReflectionProbe::set_max_distance);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_max_distance"), &ReflectionProbe::get_max_distance);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2021-12-29 00:10:41 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_mesh_lod_threshold", "ratio"), &ReflectionProbe::set_mesh_lod_threshold);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_mesh_lod_threshold"), &ReflectionProbe::get_mesh_lod_threshold);
|
2020-12-17 19:56:59 +01:00
|
|
|
|
2022-07-12 09:43:01 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("set_size", "size"), &ReflectionProbe::set_size);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_size"), &ReflectionProbe::get_size);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2017-02-13 12:47:24 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_origin_offset", "origin_offset"), &ReflectionProbe::set_origin_offset);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_origin_offset"), &ReflectionProbe::get_origin_offset);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2017-02-13 12:47:24 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_as_interior", "enable"), &ReflectionProbe::set_as_interior);
|
|
|
|
ClassDB::bind_method(D_METHOD("is_set_as_interior"), &ReflectionProbe::is_set_as_interior);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2017-02-13 12:47:24 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_enable_box_projection", "enable"), &ReflectionProbe::set_enable_box_projection);
|
|
|
|
ClassDB::bind_method(D_METHOD("is_box_projection_enabled"), &ReflectionProbe::is_box_projection_enabled);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2017-02-13 12:47:24 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_enable_shadows", "enable"), &ReflectionProbe::set_enable_shadows);
|
|
|
|
ClassDB::bind_method(D_METHOD("are_shadows_enabled"), &ReflectionProbe::are_shadows_enabled);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2017-02-12 01:11:37 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_cull_mask", "layers"), &ReflectionProbe::set_cull_mask);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_cull_mask"), &ReflectionProbe::get_cull_mask);
|
2017-01-04 05:16:14 +01:00
|
|
|
|
2023-12-12 13:20:41 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_reflection_mask", "layers"), &ReflectionProbe::set_reflection_mask);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_reflection_mask"), &ReflectionProbe::get_reflection_mask);
|
|
|
|
|
2017-02-12 01:11:37 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_update_mode", "mode"), &ReflectionProbe::set_update_mode);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_update_mode"), &ReflectionProbe::get_update_mode);
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2021-05-22 04:30:58 +02:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "update_mode", PROPERTY_HINT_ENUM, "Once (Fast),Always (Slow)"), "set_update_mode", "get_update_mode");
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 19:20:53 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "intensity", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_intensity", "get_intensity");
|
2021-12-03 01:09:19 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_distance", PROPERTY_HINT_RANGE, "0,16384,0.1,or_greater,exp,suffix:m"), "set_max_distance", "get_max_distance");
|
2022-07-12 09:43:01 +02:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size", PROPERTY_HINT_NONE, "suffix:m"), "set_size", "get_size");
|
2021-12-03 01:09:19 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "origin_offset", PROPERTY_HINT_NONE, "suffix:m"), "set_origin_offset", "get_origin_offset");
|
2017-02-12 01:11:37 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "box_projection"), "set_enable_box_projection", "is_box_projection_enabled");
|
2020-06-25 15:33:28 +02:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_as_interior", "is_set_as_interior");
|
2017-02-12 01:11:37 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enable_shadows"), "set_enable_shadows", "are_shadows_enabled");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask");
|
2023-12-12 13:20:41 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "reflection_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_reflection_mask", "get_reflection_mask");
|
2021-12-29 00:10:41 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mesh_lod_threshold", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_mesh_lod_threshold", "get_mesh_lod_threshold");
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2020-06-25 15:33:28 +02:00
|
|
|
ADD_GROUP("Ambient", "ambient_");
|
2021-05-22 04:30:58 +02:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "ambient_mode", PROPERTY_HINT_ENUM, "Disabled,Environment,Constant Color"), "set_ambient_mode", "get_ambient_mode");
|
2020-06-25 15:33:28 +02:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ambient_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ambient_color", "get_ambient_color");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ambient_color_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_ambient_color_energy", "get_ambient_color_energy");
|
2016-11-19 17:23:37 +01:00
|
|
|
|
2017-08-20 17:45:01 +02:00
|
|
|
BIND_ENUM_CONSTANT(UPDATE_ONCE);
|
|
|
|
BIND_ENUM_CONSTANT(UPDATE_ALWAYS);
|
2020-06-25 15:33:28 +02:00
|
|
|
|
|
|
|
BIND_ENUM_CONSTANT(AMBIENT_DISABLED);
|
|
|
|
BIND_ENUM_CONSTANT(AMBIENT_ENVIRONMENT);
|
|
|
|
BIND_ENUM_CONSTANT(AMBIENT_COLOR);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
2022-07-12 09:43:01 +02:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
bool ReflectionProbe::_set(const StringName &p_name, const Variant &p_value) {
|
|
|
|
if (p_name == "extents") { // Compatibility with Godot 3.x.
|
|
|
|
set_size((Vector3)p_value * 2);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReflectionProbe::_get(const StringName &p_name, Variant &r_property) const {
|
|
|
|
if (p_name == "extents") { // Compatibility with Godot 3.x.
|
|
|
|
r_property = size / 2;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif // DISABLE_DEPRECATED
|
|
|
|
|
2016-11-19 17:23:37 +01:00
|
|
|
ReflectionProbe::ReflectionProbe() {
|
2020-03-27 19:21:27 +01:00
|
|
|
probe = RenderingServer::get_singleton()->reflection_probe_create();
|
|
|
|
RS::get_singleton()->instance_set_base(get_instance(), probe);
|
2018-07-18 18:47:42 +02:00
|
|
|
set_disable_scale(true);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReflectionProbe::~ReflectionProbe() {
|
2022-12-12 18:42:37 +01:00
|
|
|
ERR_FAIL_NULL(RenderingServer::get_singleton());
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->free(probe);
|
2016-11-19 17:23:37 +01:00
|
|
|
}
|