2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2020-03-26 22:49:16 +01:00
|
|
|
/* visual_instance_3d.cpp */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2020-01-01 11:16:22 +01:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* 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
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
#include "visual_instance_3d.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
#include "scene/scene_string_names.h"
|
2020-03-27 19:21:27 +01:00
|
|
|
#include "servers/rendering_server.h"
|
2020-03-26 22:49:16 +01:00
|
|
|
#include "skeleton_3d.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
AABB VisualInstance3D::get_transformed_aabb() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return get_global_transform().xform(get_aabb());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void VisualInstance3D::_update_visibility() {
|
2017-01-04 05:16:14 +01:00
|
|
|
|
|
|
|
if (!is_inside_tree())
|
|
|
|
return;
|
|
|
|
|
|
|
|
_change_notify("visible");
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree());
|
2017-01-04 05:16:14 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void VisualInstance3D::_notification(int p_what) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (p_what) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
case NOTIFICATION_ENTER_WORLD: {
|
|
|
|
|
2014-05-13 07:24:26 +02:00
|
|
|
// CHECK SKELETON => moving skeleton attaching logic to MeshInstance
|
|
|
|
/*
|
2017-08-24 22:58:51 +02:00
|
|
|
Skeleton *skeleton=Object::cast_to<Skeleton>(get_parent());
|
2014-02-10 02:10:30 +01:00
|
|
|
if (skeleton)
|
2020-03-27 19:21:27 +01:00
|
|
|
RenderingServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() );
|
2014-05-13 07:24:26 +02:00
|
|
|
*/
|
2019-06-22 14:52:51 +02:00
|
|
|
ERR_FAIL_COND(get_world().is_null());
|
2020-03-27 19:21:27 +01:00
|
|
|
RenderingServer::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
|
2017-01-04 05:16:14 +01:00
|
|
|
_update_visibility();
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_TRANSFORM_CHANGED: {
|
|
|
|
|
|
|
|
Transform gt = get_global_transform();
|
2020-03-27 19:21:27 +01:00
|
|
|
RenderingServer::get_singleton()->instance_set_transform(instance, gt);
|
2014-02-10 02:10:30 +01:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_EXIT_WORLD: {
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
RenderingServer::get_singleton()->instance_set_scenario(instance, RID());
|
|
|
|
RenderingServer::get_singleton()->instance_attach_skeleton(instance, RID());
|
|
|
|
//RS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-01-04 05:16:14 +01:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-01-04 05:16:14 +01:00
|
|
|
_update_visibility();
|
2014-02-10 02:10:30 +01:00
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
RID VisualInstance3D::get_instance() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
RID VisualInstance3D::_get_visual_instance_rid() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void VisualInstance3D::set_layer_mask(uint32_t p_mask) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
layers = p_mask;
|
2020-03-27 19:21:27 +01:00
|
|
|
RenderingServer::get_singleton()->instance_set_layer_mask(instance, p_mask);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
uint32_t VisualInstance3D::get_layer_mask() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return layers;
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void VisualInstance3D::set_layer_mask_bit(int p_layer, bool p_enable) {
|
2018-07-30 01:05:16 +02:00
|
|
|
ERR_FAIL_INDEX(p_layer, 32);
|
|
|
|
if (p_enable) {
|
|
|
|
set_layer_mask(layers | (1 << p_layer));
|
|
|
|
} else {
|
|
|
|
set_layer_mask(layers & (~(1 << p_layer)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
bool VisualInstance3D::get_layer_mask_bit(int p_layer) const {
|
2018-07-30 01:05:16 +02:00
|
|
|
ERR_FAIL_INDEX_V(p_layer, 32, false);
|
|
|
|
return (layers & (1 << p_layer));
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void VisualInstance3D::_bind_methods() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"), &VisualInstance3D::_get_visual_instance_rid);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_base", "base"), &VisualInstance3D::set_base);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_base"), &VisualInstance3D::get_base);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_instance"), &VisualInstance3D::get_instance);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_layer_mask", "mask"), &VisualInstance3D::set_layer_mask);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_layer_mask"), &VisualInstance3D::get_layer_mask);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_layer_mask_bit", "layer", "enabled"), &VisualInstance3D::set_layer_mask_bit);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_layer_mask_bit", "layer"), &VisualInstance3D::get_layer_mask_bit);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("get_transformed_aabb"), &VisualInstance3D::get_transformed_aabb);
|
2016-09-22 23:01:44 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_LAYERS_3D_RENDER), "set_layer_mask", "get_layer_mask");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void VisualInstance3D::set_base(const RID &p_base) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
RenderingServer::get_singleton()->instance_set_base(instance, p_base);
|
2019-04-23 00:27:30 +02:00
|
|
|
base = p_base;
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
RID VisualInstance3D::get_base() const {
|
2019-04-23 00:27:30 +02:00
|
|
|
|
|
|
|
return base;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
VisualInstance3D::VisualInstance3D() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
instance = RenderingServer::get_singleton()->instance_create();
|
|
|
|
RenderingServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id());
|
2017-03-05 16:44:50 +01:00
|
|
|
layers = 1;
|
2017-01-13 00:35:46 +01:00
|
|
|
set_notify_transform(true);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
VisualInstance3D::~VisualInstance3D() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
RenderingServer::get_singleton()->free(instance);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_material_override(const Ref<Material> &p_material) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
material_override = p_material;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_geometry_set_material_override(get_instance(), p_material.is_valid() ? p_material->get_rid() : RID());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
Ref<Material> GeometryInstance3D::get_material_override() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return material_override;
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_lod_min_distance(float p_dist) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
lod_min_distance = p_dist;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
float GeometryInstance3D::get_lod_min_distance() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
return lod_min_distance;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_lod_max_distance(float p_dist) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
lod_max_distance = p_dist;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
float GeometryInstance3D::get_lod_max_distance() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
return lod_max_distance;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_lod_min_hysteresis(float p_dist) {
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
lod_min_hysteresis = p_dist;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
|
2016-10-03 21:33:42 +02:00
|
|
|
}
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
float GeometryInstance3D::get_lod_min_hysteresis() const {
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
return lod_min_hysteresis;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_lod_max_hysteresis(float p_dist) {
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
lod_max_hysteresis = p_dist;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
float GeometryInstance3D::get_lod_max_hysteresis() const {
|
2014-08-14 15:31:38 +02:00
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
return lod_max_hysteresis;
|
|
|
|
}
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::_notification(int p_what) {
|
2014-08-14 15:31:38 +02:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_flag(Flags p_flag, bool p_value) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
|
|
|
if (flags[p_flag] == p_value)
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
flags[p_flag] = p_value;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_geometry_set_flag(get_instance(), (RS::InstanceFlags)p_flag, p_value);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
bool GeometryInstance3D::get_flag(Flags p_flag) const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
|
2016-03-08 00:00:55 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return flags[p_flag];
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting) {
|
2016-03-08 00:00:55 +01:00
|
|
|
|
|
|
|
shadow_casting_setting = p_shadow_casting_setting;
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (RS::ShadowCastingSetting)p_shadow_casting_setting);
|
2016-03-08 00:00:55 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
GeometryInstance3D::ShadowCastingSetting GeometryInstance3D::get_cast_shadows_setting() const {
|
2016-03-08 00:00:55 +01:00
|
|
|
|
|
|
|
return shadow_casting_setting;
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_extra_cull_margin(float p_margin) {
|
2015-03-02 04:54:10 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND(p_margin < 0);
|
|
|
|
extra_cull_margin = p_margin;
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin);
|
2015-03-02 04:54:10 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
float GeometryInstance3D::get_extra_cull_margin() const {
|
2015-03-02 04:54:10 +01:00
|
|
|
|
|
|
|
return extra_cull_margin;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::set_custom_aabb(AABB aabb) {
|
2019-01-31 17:54:00 +01:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
RS::get_singleton()->instance_set_custom_aabb(get_instance(), aabb);
|
2019-01-31 17:54:00 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
void GeometryInstance3D::_bind_methods() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_material_override", "material"), &GeometryInstance3D::set_material_override);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance3D::get_material_override);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_flag", "flag", "value"), &GeometryInstance3D::set_flag);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_flag", "flag"), &GeometryInstance3D::get_flag);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance3D::set_cast_shadows_setting);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_cast_shadows_setting"), &GeometryInstance3D::get_cast_shadows_setting);
|
2016-03-08 00:00:55 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_lod_max_hysteresis", "mode"), &GeometryInstance3D::set_lod_max_hysteresis);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_lod_max_hysteresis"), &GeometryInstance3D::get_lod_max_hysteresis);
|
2016-10-03 21:33:42 +02:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_lod_max_distance", "mode"), &GeometryInstance3D::set_lod_max_distance);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_lod_max_distance"), &GeometryInstance3D::get_lod_max_distance);
|
2016-10-03 21:33:42 +02:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_lod_min_hysteresis", "mode"), &GeometryInstance3D::set_lod_min_hysteresis);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_lod_min_hysteresis"), &GeometryInstance3D::get_lod_min_hysteresis);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_lod_min_distance", "mode"), &GeometryInstance3D::set_lod_min_distance);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_lod_min_distance"), &GeometryInstance3D::get_lod_min_distance);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_extra_cull_margin", "margin"), &GeometryInstance3D::set_extra_cull_margin);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_extra_cull_margin"), &GeometryInstance3D::get_extra_cull_margin);
|
2015-03-02 04:54:10 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_custom_aabb", "aabb"), &GeometryInstance3D::set_custom_aabb);
|
2019-01-31 17:54:00 +01:00
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("get_aabb"), &GeometryInstance3D::get_aabb);
|
2016-09-22 23:01:44 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ADD_GROUP("Geometry", "");
|
2020-02-28 12:27:04 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DEFERRED_SET_RESOURCE), "set_material_override", "get_material_override");
|
2017-02-12 01:11:37 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), "set_cast_shadows_setting", "get_cast_shadows_setting");
|
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, "extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0.01"), "set_extra_cull_margin", "get_extra_cull_margin");
|
2017-03-05 16:44:50 +01:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "use_in_baked_light"), "set_flag", "get_flag", FLAG_USE_BAKED_LIGHT);
|
2019-10-11 04:14:56 +02:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "use_dynamic_gi"), "set_flag", "get_flag", FLAG_USE_DYNAMIC_GI);
|
2017-03-05 16:44:50 +01:00
|
|
|
|
|
|
|
ADD_GROUP("LOD", "lod_");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_min_distance", PROPERTY_HINT_RANGE, "0,32768,0.01"), "set_lod_min_distance", "get_lod_min_distance");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_min_hysteresis", PROPERTY_HINT_RANGE, "0,32768,0.01"), "set_lod_min_hysteresis", "get_lod_min_hysteresis");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_max_distance", PROPERTY_HINT_RANGE, "0,32768,0.01"), "set_lod_max_distance", "get_lod_max_distance");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_max_hysteresis", PROPERTY_HINT_RANGE, "0,32768,0.01"), "set_lod_max_hysteresis", "get_lod_max_hysteresis");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-01-14 12:26:56 +01:00
|
|
|
//ADD_SIGNAL( MethodInfo("visibility_changed"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-09-12 21:09:06 +02:00
|
|
|
BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_OFF);
|
|
|
|
BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_ON);
|
|
|
|
BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);
|
|
|
|
BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-09-12 21:09:06 +02:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_USE_BAKED_LIGHT);
|
2019-10-11 04:14:56 +02:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_USE_DYNAMIC_GI);
|
2019-06-27 11:10:53 +02:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_DRAW_NEXT_FRAME_IF_VISIBLE);
|
2017-09-12 21:09:06 +02:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_MAX);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 22:49:16 +01:00
|
|
|
GeometryInstance3D::GeometryInstance3D() {
|
2017-03-05 16:44:50 +01:00
|
|
|
lod_min_distance = 0;
|
|
|
|
lod_max_distance = 0;
|
|
|
|
lod_min_hysteresis = 0;
|
|
|
|
lod_max_hysteresis = 0;
|
2016-10-03 21:33:42 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < FLAG_MAX; i++) {
|
|
|
|
flags[i] = false;
|
2014-12-07 06:04:20 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
shadow_casting_setting = SHADOW_CASTING_SETTING_ON;
|
|
|
|
extra_cull_margin = 0;
|
2020-03-27 19:21:27 +01:00
|
|
|
//RS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|