diff options
Diffstat (limited to 'servers')
52 files changed, 1326 insertions, 342 deletions
diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp index b83b41a571..b87cdd6d9f 100644 --- a/servers/camera_server.cpp +++ b/servers/camera_server.cpp @@ -105,10 +105,7 @@ void CameraServer::add_feed(const Ref<CameraFeed> &p_feed) { // add our feed feeds.push_back(p_feed); -// record for debugging -#ifdef DEBUG_ENABLED - print_line("Registered camera " + p_feed->get_name() + " with id " + itos(p_feed->get_id()) + " position " + itos(p_feed->get_position()) + " at index " + itos(feeds.size() - 1)); -#endif + print_verbose("CameraServer: Registered camera " + p_feed->get_name() + " with ID " + itos(p_feed->get_id()) + " and position " + itos(p_feed->get_position()) + " at index " + itos(feeds.size() - 1)); // let whomever is interested know emit_signal(SNAME("camera_feed_added"), p_feed->get_id()); @@ -119,10 +116,7 @@ void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) { if (feeds[i] == p_feed) { int feed_id = p_feed->get_id(); -// record for debugging -#ifdef DEBUG_ENABLED - print_line("Removed camera " + p_feed->get_name() + " with id " + itos(feed_id) + " position " + itos(p_feed->get_position())); -#endif + print_verbose("CameraServer: Removed camera " + p_feed->get_name() + " with ID " + itos(feed_id) + " and position " + itos(p_feed->get_position())); // remove it from our array, if this results in our feed being unreferenced it will be destroyed feeds.remove_at(i); diff --git a/servers/display_server.cpp b/servers/display_server.cpp index 6f14e73f34..dda8e29b6a 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -597,6 +597,10 @@ void DisplayServer::_bind_methods() { ClassDB::bind_method(D_METHOD("tts_set_utterance_callback", "event", "callable"), &DisplayServer::tts_set_utterance_callback); ClassDB::bind_method(D_METHOD("_tts_post_utterance_event", "event", "id", "char_pos"), &DisplayServer::tts_post_utterance_event); + ClassDB::bind_method(D_METHOD("is_dark_mode_supported"), &DisplayServer::is_dark_mode_supported); + ClassDB::bind_method(D_METHOD("is_dark_mode"), &DisplayServer::is_dark_mode); + ClassDB::bind_method(D_METHOD("get_accent_color"), &DisplayServer::get_accent_color); + ClassDB::bind_method(D_METHOD("mouse_set_mode", "mouse_mode"), &DisplayServer::mouse_set_mode); ClassDB::bind_method(D_METHOD("mouse_get_mode"), &DisplayServer::mouse_get_mode); diff --git a/servers/display_server.h b/servers/display_server.h index 7cb880cbcb..ab4f9fc499 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -212,6 +212,10 @@ public: virtual void tts_set_utterance_callback(TTSUtteranceEvent p_event, const Callable &p_callable); virtual void tts_post_utterance_event(TTSUtteranceEvent p_event, int p_id, int p_pos = 0); + virtual bool is_dark_mode_supported() const { return false; }; + virtual bool is_dark_mode() const { return false; }; + virtual Color get_accent_color() const { return Color(0, 0, 0, 0); }; + enum MouseMode { MOUSE_MODE_VISIBLE, MOUSE_MODE_HIDDEN, diff --git a/servers/extensions/physics_server_2d_extension.cpp b/servers/extensions/physics_server_2d_extension.cpp new file mode 100644 index 0000000000..36f3be2468 --- /dev/null +++ b/servers/extensions/physics_server_2d_extension.cpp @@ -0,0 +1,338 @@ +/*************************************************************************/ +/* physics_server_2d_extension.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 "physics_server_2d_extension.h" + +bool PhysicsDirectSpaceState2DExtension::is_body_excluded_from_query(const RID &p_body) const { + return exclude && exclude->has(p_body); +} + +thread_local const HashSet<RID> *PhysicsDirectSpaceState2DExtension::exclude = nullptr; + +void PhysicsDirectSpaceState2DExtension::_bind_methods() { + GDVIRTUAL_BIND(_intersect_ray, "from", "to", "collision_mask", "collide_with_bodies", "collide_with_areas", "hit_from_inside", "result"); + GDVIRTUAL_BIND(_intersect_point, "position", "canvas_instance_id", "collision_mask", "collide_with_bodies", "collide_with_areas", "results", "max_results"); + GDVIRTUAL_BIND(_intersect_shape, "shape_rid", "transform", "motion", "margin", "collision_mask", "collide_with_bodies", "collide_with_areas", "result", "max_results"); + GDVIRTUAL_BIND(_cast_motion, "shape_rid", "transform", "motion", "margin", "collision_mask", "collide_with_bodies", "collide_with_areas", "closest_safe", "closest_unsafe"); + GDVIRTUAL_BIND(_collide_shape, "shape_rid", "transform", "motion", "margin", "collision_mask", "collide_with_bodies", "collide_with_areas", "results", "max_results", "result_count"); + GDVIRTUAL_BIND(_rest_info, "shape_rid", "transform", "motion", "margin", "collision_mask", "collide_with_bodies", "collide_with_areas", "rest_info"); +} + +PhysicsDirectSpaceState2DExtension::PhysicsDirectSpaceState2DExtension() { +} + +void PhysicsDirectBodyState2DExtension::_bind_methods() { + GDVIRTUAL_BIND(_get_total_gravity); + GDVIRTUAL_BIND(_get_total_linear_damp); + GDVIRTUAL_BIND(_get_total_angular_damp); + + GDVIRTUAL_BIND(_get_center_of_mass); + GDVIRTUAL_BIND(_get_center_of_mass_local); + GDVIRTUAL_BIND(_get_inverse_mass); + GDVIRTUAL_BIND(_get_inverse_inertia); + + GDVIRTUAL_BIND(_set_linear_velocity, "velocity"); + GDVIRTUAL_BIND(_get_linear_velocity); + + GDVIRTUAL_BIND(_set_angular_velocity, "velocity"); + GDVIRTUAL_BIND(_get_angular_velocity); + + GDVIRTUAL_BIND(_set_transform, "transform"); + GDVIRTUAL_BIND(_get_transform); + + GDVIRTUAL_BIND(_get_velocity_at_local_position, "local_position"); + + GDVIRTUAL_BIND(_apply_central_impulse, "impulse"); + GDVIRTUAL_BIND(_apply_impulse, "impulse", "position"); + GDVIRTUAL_BIND(_apply_torque_impulse, "impulse"); + + GDVIRTUAL_BIND(_apply_central_force, "force"); + GDVIRTUAL_BIND(_apply_force, "force", "position"); + GDVIRTUAL_BIND(_apply_torque, "torque"); + + GDVIRTUAL_BIND(_add_constant_central_force, "force"); + GDVIRTUAL_BIND(_add_constant_force, "force", "position"); + GDVIRTUAL_BIND(_add_constant_torque, "torque"); + + GDVIRTUAL_BIND(_set_constant_force, "force"); + GDVIRTUAL_BIND(_get_constant_force); + + GDVIRTUAL_BIND(_set_constant_torque, "torque"); + GDVIRTUAL_BIND(_get_constant_torque); + + GDVIRTUAL_BIND(_set_sleep_state, "enabled"); + GDVIRTUAL_BIND(_is_sleeping); + + GDVIRTUAL_BIND(_get_contact_count); + + GDVIRTUAL_BIND(_get_contact_local_position, "contact_idx"); + GDVIRTUAL_BIND(_get_contact_local_normal, "contact_idx"); + GDVIRTUAL_BIND(_get_contact_local_shape, "contact_idx"); + GDVIRTUAL_BIND(_get_contact_collider, "contact_idx"); + GDVIRTUAL_BIND(_get_contact_collider_position, "contact_idx"); + GDVIRTUAL_BIND(_get_contact_collider_id, "contact_idx"); + GDVIRTUAL_BIND(_get_contact_collider_object, "contact_idx"); + GDVIRTUAL_BIND(_get_contact_collider_shape, "contact_idx"); + GDVIRTUAL_BIND(_get_contact_collider_velocity_at_position, "contact_idx"); + + GDVIRTUAL_BIND(_get_step); + GDVIRTUAL_BIND(_integrate_forces); + + GDVIRTUAL_BIND(_get_space_state); +} + +PhysicsDirectBodyState2DExtension::PhysicsDirectBodyState2DExtension() { +} + +thread_local const HashSet<RID> *PhysicsServer2DExtension::exclude_bodies = nullptr; +thread_local const HashSet<ObjectID> *PhysicsServer2DExtension::exclude_objects = nullptr; + +bool PhysicsServer2DExtension::body_test_motion_is_excluding_body(RID p_body) const { + return exclude_bodies && exclude_bodies->has(p_body); +} + +bool PhysicsServer2DExtension::body_test_motion_is_excluding_object(ObjectID p_object) const { + return exclude_objects && exclude_objects->has(p_object); +} + +void PhysicsServer2DExtension::_bind_methods() { + /* SHAPE API */ + + GDVIRTUAL_BIND(_world_boundary_shape_create); + GDVIRTUAL_BIND(_separation_ray_shape_create); + GDVIRTUAL_BIND(_segment_shape_create); + GDVIRTUAL_BIND(_circle_shape_create); + GDVIRTUAL_BIND(_rectangle_shape_create); + GDVIRTUAL_BIND(_capsule_shape_create); + GDVIRTUAL_BIND(_convex_polygon_shape_create); + GDVIRTUAL_BIND(_concave_polygon_shape_create); + + GDVIRTUAL_BIND(_shape_set_data, "shape", "data"); + GDVIRTUAL_BIND(_shape_set_custom_solver_bias, "shape", "bias"); + + GDVIRTUAL_BIND(_shape_get_type, "shape"); + GDVIRTUAL_BIND(_shape_get_data, "shape"); + GDVIRTUAL_BIND(_shape_get_custom_solver_bias, "shape"); + GDVIRTUAL_BIND(_shape_collide, "shape_A", "xform_A", "motion_A", "shape_B", "xform_B", "motion_B", "results", "result_max", "result_count"); + + /* SPACE API */ + + GDVIRTUAL_BIND(_space_create); + GDVIRTUAL_BIND(_space_set_active, "space", "active"); + GDVIRTUAL_BIND(_space_is_active, "space"); + + GDVIRTUAL_BIND(_space_set_param, "space", "param", "value"); + GDVIRTUAL_BIND(_space_get_param, "space", "param"); + + GDVIRTUAL_BIND(_space_get_direct_state, "space"); + + GDVIRTUAL_BIND(_space_set_debug_contacts, "space", "max_contacts"); + GDVIRTUAL_BIND(_space_get_contacts, "space"); + GDVIRTUAL_BIND(_space_get_contact_count, "space"); + + /* AREA API */ + + GDVIRTUAL_BIND(_area_create); + + GDVIRTUAL_BIND(_area_set_space, "area", "space"); + GDVIRTUAL_BIND(_area_get_space, "area"); + + GDVIRTUAL_BIND(_area_add_shape, "area", "shape", "transform", "disabled"); + GDVIRTUAL_BIND(_area_set_shape, "area", "shape_idx", "shape"); + GDVIRTUAL_BIND(_area_set_shape_transform, "area", "shape_idx", "transform"); + GDVIRTUAL_BIND(_area_set_shape_disabled, "area", "shape_idx", "disabled"); + + GDVIRTUAL_BIND(_area_get_shape_count, "area"); + GDVIRTUAL_BIND(_area_get_shape, "area", "shape_idx"); + GDVIRTUAL_BIND(_area_get_shape_transform, "area", "shape_idx"); + + GDVIRTUAL_BIND(_area_remove_shape, "area", "shape_idx"); + GDVIRTUAL_BIND(_area_clear_shapes, "area"); + + GDVIRTUAL_BIND(_area_attach_object_instance_id, "area", "id"); + GDVIRTUAL_BIND(_area_get_object_instance_id, "area"); + + GDVIRTUAL_BIND(_area_attach_canvas_instance_id, "area", "id"); + GDVIRTUAL_BIND(_area_get_canvas_instance_id, "area"); + + GDVIRTUAL_BIND(_area_set_param, "area", "param", "value"); + GDVIRTUAL_BIND(_area_set_transform, "area", "transform"); + + GDVIRTUAL_BIND(_area_get_param, "area", "param"); + GDVIRTUAL_BIND(_area_get_transform, "area"); + + GDVIRTUAL_BIND(_area_set_collision_layer, "area", "layer"); + GDVIRTUAL_BIND(_area_set_collision_mask, "area", "mask"); + + GDVIRTUAL_BIND(_area_set_monitorable, "area", "monitorable"); + GDVIRTUAL_BIND(_area_set_pickable, "area", "pickable"); + + GDVIRTUAL_BIND(_area_set_monitor_callback, "area", "callback"); + GDVIRTUAL_BIND(_area_set_area_monitor_callback, "area", "callback"); + + /* BODY API */ + + GDVIRTUAL_BIND(_body_create); + + GDVIRTUAL_BIND(_body_set_space, "body", "space"); + GDVIRTUAL_BIND(_body_get_space, "body"); + + GDVIRTUAL_BIND(_body_set_mode, "body", "mode"); + GDVIRTUAL_BIND(_body_get_mode, "body"); + + GDVIRTUAL_BIND(_body_add_shape, "body", "shape", "transform", "disabled"); + GDVIRTUAL_BIND(_body_set_shape, "body", "shape_idx", "shape"); + GDVIRTUAL_BIND(_body_set_shape_transform, "body", "shape_idx", "transform"); + + GDVIRTUAL_BIND(_body_get_shape_count, "body"); + GDVIRTUAL_BIND(_body_get_shape, "body", "shape_idx"); + GDVIRTUAL_BIND(_body_get_shape_transform, "body", "shape_idx"); + + GDVIRTUAL_BIND(_body_set_shape_disabled, "body", "shape_idx", "disabled"); + GDVIRTUAL_BIND(_body_set_shape_as_one_way_collision, "body", "shape_idx", "enable", "margin"); + + GDVIRTUAL_BIND(_body_remove_shape, "body", "shape_idx"); + GDVIRTUAL_BIND(_body_clear_shapes, "body"); + + GDVIRTUAL_BIND(_body_attach_object_instance_id, "body", "id"); + GDVIRTUAL_BIND(_body_get_object_instance_id, "body"); + + GDVIRTUAL_BIND(_body_attach_canvas_instance_id, "body", "id"); + GDVIRTUAL_BIND(_body_get_canvas_instance_id, "body"); + + GDVIRTUAL_BIND(_body_set_continuous_collision_detection_mode, "body", "mode"); + GDVIRTUAL_BIND(_body_get_continuous_collision_detection_mode, "body"); + + GDVIRTUAL_BIND(_body_set_collision_layer, "body", "layer"); + GDVIRTUAL_BIND(_body_get_collision_layer, "body"); + + GDVIRTUAL_BIND(_body_set_collision_mask, "body", "mask"); + GDVIRTUAL_BIND(_body_get_collision_mask, "body"); + + GDVIRTUAL_BIND(_body_set_collision_priority, "body", "priority"); + GDVIRTUAL_BIND(_body_get_collision_priority, "body"); + + GDVIRTUAL_BIND(_body_set_param, "body", "param", "value"); + GDVIRTUAL_BIND(_body_get_param, "body", "param"); + + GDVIRTUAL_BIND(_body_reset_mass_properties, "body"); + + GDVIRTUAL_BIND(_body_set_state, "body", "state", "value"); + GDVIRTUAL_BIND(_body_get_state, "body", "state"); + + GDVIRTUAL_BIND(_body_apply_central_impulse, "body", "impulse"); + GDVIRTUAL_BIND(_body_apply_torque_impulse, "body", "impulse"); + GDVIRTUAL_BIND(_body_apply_impulse, "body", "impulse", "position"); + + GDVIRTUAL_BIND(_body_apply_central_force, "body", "force"); + GDVIRTUAL_BIND(_body_apply_force, "body", "force", "position"); + GDVIRTUAL_BIND(_body_apply_torque, "body", "torque"); + + GDVIRTUAL_BIND(_body_add_constant_central_force, "body", "force"); + GDVIRTUAL_BIND(_body_add_constant_force, "body", "force", "position"); + GDVIRTUAL_BIND(_body_add_constant_torque, "body", "torque"); + + GDVIRTUAL_BIND(_body_set_constant_force, "body", "force"); + GDVIRTUAL_BIND(_body_get_constant_force, "body"); + + GDVIRTUAL_BIND(_body_set_constant_torque, "body", "torque"); + GDVIRTUAL_BIND(_body_get_constant_torque, "body"); + + GDVIRTUAL_BIND(_body_set_axis_velocity, "body", "axis_velocity"); + + GDVIRTUAL_BIND(_body_add_collision_exception, "body", "excepted_body"); + GDVIRTUAL_BIND(_body_remove_collision_exception, "body", "excepted_body"); + GDVIRTUAL_BIND(_body_get_collision_exceptions, "body"); + + GDVIRTUAL_BIND(_body_set_max_contacts_reported, "body", "amount"); + GDVIRTUAL_BIND(_body_get_max_contacts_reported, "body"); + + GDVIRTUAL_BIND(_body_set_contacts_reported_depth_threshold, "body", "threshold"); + GDVIRTUAL_BIND(_body_get_contacts_reported_depth_threshold, "body"); + + GDVIRTUAL_BIND(_body_set_omit_force_integration, "body", "enable"); + GDVIRTUAL_BIND(_body_is_omitting_force_integration, "body"); + + GDVIRTUAL_BIND(_body_set_state_sync_callback, "body", "callback"); + GDVIRTUAL_BIND(_body_set_force_integration_callback, "body", "callable", "userdata"); + + GDVIRTUAL_BIND(_body_collide_shape, "body", "body_shape", "shape", "shape_xform", "motion", "results", "result_max", "result_count"); + + GDVIRTUAL_BIND(_body_set_pickable, "body", "pickable"); + + GDVIRTUAL_BIND(_body_get_direct_state, "body"); + + GDVIRTUAL_BIND(_body_test_motion, "body", "from", "motion", "margin", "collide_separation_ray", "recovery_as_collision", "result"); + + /* JOINT API */ + + GDVIRTUAL_BIND(_joint_create); + GDVIRTUAL_BIND(_joint_clear, "joint"); + + GDVIRTUAL_BIND(_joint_set_param, "joint", "param", "value"); + GDVIRTUAL_BIND(_joint_get_param, "joint", "param"); + + GDVIRTUAL_BIND(_joint_disable_collisions_between_bodies, "joint", "disable"); + GDVIRTUAL_BIND(_joint_is_disabled_collisions_between_bodies, "joint"); + + GDVIRTUAL_BIND(_joint_make_pin, "joint", "anchor", "body_a", "body_b"); + GDVIRTUAL_BIND(_joint_make_groove, "joint", "a_groove1", "a_groove2", "b_anchor", "body_a", "body_b"); + GDVIRTUAL_BIND(_joint_make_damped_spring, "joint", "anchor_a", "anchor_b", "body_a", "body_b"); + + GDVIRTUAL_BIND(_pin_joint_set_param, "joint", "param", "value"); + GDVIRTUAL_BIND(_pin_joint_get_param, "joint", "param"); + + GDVIRTUAL_BIND(_damped_spring_joint_set_param, "joint", "param", "value"); + GDVIRTUAL_BIND(_damped_spring_joint_get_param, "joint", "param"); + + GDVIRTUAL_BIND(_joint_get_type, "joint"); + + /* MISC */ + + GDVIRTUAL_BIND(_free_rid, "rid"); + + GDVIRTUAL_BIND(_set_active, "active"); + + GDVIRTUAL_BIND(_init); + GDVIRTUAL_BIND(_step, "step"); + GDVIRTUAL_BIND(_sync); + GDVIRTUAL_BIND(_flush_queries); + GDVIRTUAL_BIND(_end_sync); + GDVIRTUAL_BIND(_finish); + + GDVIRTUAL_BIND(_is_flushing_queries); + GDVIRTUAL_BIND(_get_process_info, "process_info"); +} + +PhysicsServer2DExtension::PhysicsServer2DExtension() { +} + +PhysicsServer2DExtension::~PhysicsServer2DExtension() { +} diff --git a/servers/extensions/physics_server_2d_extension.h b/servers/extensions/physics_server_2d_extension.h new file mode 100644 index 0000000000..3bd3d642c8 --- /dev/null +++ b/servers/extensions/physics_server_2d_extension.h @@ -0,0 +1,462 @@ +/*************************************************************************/ +/* physics_server_2d_extension.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. */ +/*************************************************************************/ + +#ifndef PHYSICS_SERVER_2D_EXTENSION_H +#define PHYSICS_SERVER_2D_EXTENSION_H + +#include "core/extension/ext_wrappers.gen.inc" +#include "core/object/gdvirtual.gen.inc" +#include "core/object/script_language.h" +#include "core/variant/native_ptr.h" +#include "core/variant/type_info.h" +#include "core/variant/typed_array.h" +#include "servers/physics_server_2d.h" + +class PhysicsDirectBodyState2DExtension : public PhysicsDirectBodyState2D { + GDCLASS(PhysicsDirectBodyState2DExtension, PhysicsDirectBodyState2D); + +protected: + static void _bind_methods(); + +public: + // The warning is valid, but unavoidable. If the function is not overridden it will error anyway. + + EXBIND0RC(Vector2, get_total_gravity) + EXBIND0RC(real_t, get_total_angular_damp) + EXBIND0RC(real_t, get_total_linear_damp) + + EXBIND0RC(Vector2, get_center_of_mass) + EXBIND0RC(Vector2, get_center_of_mass_local) + EXBIND0RC(real_t, get_inverse_mass) + EXBIND0RC(real_t, get_inverse_inertia) + + EXBIND1(set_linear_velocity, const Vector2 &) + EXBIND0RC(Vector2, get_linear_velocity) + + EXBIND1(set_angular_velocity, real_t) + EXBIND0RC(real_t, get_angular_velocity) + + EXBIND1(set_transform, const Transform2D &) + EXBIND0RC(Transform2D, get_transform) + + EXBIND1RC(Vector2, get_velocity_at_local_position, const Vector2 &) + + EXBIND1(apply_central_impulse, const Vector2 &) + EXBIND1(apply_torque_impulse, real_t) + EXBIND2(apply_impulse, const Vector2 &, const Vector2 &) + + EXBIND1(apply_central_force, const Vector2 &) + EXBIND2(apply_force, const Vector2 &, const Vector2 &) + EXBIND1(apply_torque, real_t) + + EXBIND1(add_constant_central_force, const Vector2 &) + EXBIND2(add_constant_force, const Vector2 &, const Vector2 &) + EXBIND1(add_constant_torque, real_t) + + EXBIND1(set_constant_force, const Vector2 &) + EXBIND0RC(Vector2, get_constant_force) + + EXBIND1(set_constant_torque, real_t) + EXBIND0RC(real_t, get_constant_torque) + + EXBIND1(set_sleep_state, bool) + EXBIND0RC(bool, is_sleeping) + + EXBIND0RC(int, get_contact_count) + + EXBIND1RC(Vector2, get_contact_local_position, int) + EXBIND1RC(Vector2, get_contact_local_normal, int) + EXBIND1RC(int, get_contact_local_shape, int) + + EXBIND1RC(RID, get_contact_collider, int) + EXBIND1RC(Vector2, get_contact_collider_position, int) + EXBIND1RC(ObjectID, get_contact_collider_id, int) + EXBIND1RC(Object *, get_contact_collider_object, int) + EXBIND1RC(int, get_contact_collider_shape, int) + EXBIND1RC(Vector2, get_contact_collider_velocity_at_position, int) + + EXBIND0RC(real_t, get_step) + EXBIND0(integrate_forces) + + EXBIND0R(PhysicsDirectSpaceState2D *, get_space_state) + + PhysicsDirectBodyState2DExtension(); +}; + +typedef PhysicsDirectSpaceState2D::RayResult PhysicsServer2DExtensionRayResult; +typedef PhysicsDirectSpaceState2D::ShapeResult PhysicsServer2DExtensionShapeResult; +typedef PhysicsDirectSpaceState2D::ShapeRestInfo PhysicsServer2DExtensionShapeRestInfo; + +GDVIRTUAL_NATIVE_PTR(PhysicsServer2DExtensionRayResult) +GDVIRTUAL_NATIVE_PTR(PhysicsServer2DExtensionShapeResult) +GDVIRTUAL_NATIVE_PTR(PhysicsServer2DExtensionShapeRestInfo) + +class PhysicsDirectSpaceState2DExtension : public PhysicsDirectSpaceState2D { + GDCLASS(PhysicsDirectSpaceState2DExtension, PhysicsDirectSpaceState2D); + + thread_local static const HashSet<RID> *exclude; + +protected: + static void _bind_methods(); + bool is_body_excluded_from_query(const RID &p_body) const; + + GDVIRTUAL7R(bool, _intersect_ray, const Vector2 &, const Vector2 &, uint32_t, bool, bool, bool, GDNativePtr<PhysicsServer2DExtensionRayResult>) + GDVIRTUAL7R(int, _intersect_point, const Vector2 &, ObjectID, uint32_t, bool, bool, GDNativePtr<PhysicsServer2DExtensionShapeResult>, int) + GDVIRTUAL9R(int, _intersect_shape, RID, const Transform2D &, const Vector2 &, real_t, uint32_t, bool, bool, GDNativePtr<PhysicsServer2DExtensionShapeResult>, int) + GDVIRTUAL9R(bool, _cast_motion, RID, const Transform2D &, const Vector2 &, real_t, uint32_t, bool, bool, GDNativePtr<real_t>, GDNativePtr<real_t>) + GDVIRTUAL10R(bool, _collide_shape, RID, const Transform2D &, const Vector2 &, real_t, uint32_t, bool, bool, GDNativePtr<Vector2>, int, GDNativePtr<int>) + GDVIRTUAL8R(bool, _rest_info, RID, const Transform2D &, const Vector2 &, real_t, uint32_t, bool, bool, GDNativePtr<PhysicsServer2DExtensionShapeRestInfo>) + +public: + virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override { + exclude = &p_parameters.exclude; + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_intersect_ray, p_parameters.from, p_parameters.to, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, p_parameters.hit_from_inside, &r_result, ret); + exclude = nullptr; + return ret; + } + virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override { + exclude = &p_parameters.exclude; + int ret = false; + GDVIRTUAL_REQUIRED_CALL(_intersect_point, p_parameters.position, p_parameters.canvas_instance_id, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, ret); + exclude = nullptr; + return ret; + } + virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override { + exclude = &p_parameters.exclude; + int ret = 0; + GDVIRTUAL_REQUIRED_CALL(_intersect_shape, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, ret); + exclude = nullptr; + return ret; + } + virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) override { + exclude = &p_parameters.exclude; + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_cast_motion, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, &p_closest_safe, &p_closest_unsafe, ret); + exclude = nullptr; + return ret; + } + virtual bool collide_shape(const ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) override { + exclude = &p_parameters.exclude; + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_collide_shape, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, &r_result_count, ret); + exclude = nullptr; + return ret; + } + virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override { + exclude = &p_parameters.exclude; + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_rest_info, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_info, ret); + exclude = nullptr; + return ret; + } + + PhysicsDirectSpaceState2DExtension(); +}; + +typedef PhysicsServer2D::MotionResult PhysicsServer2DExtensionMotionResult; + +struct PhysicsServer2DExtensionStateCallback { + void *instance = nullptr; + void (*callback)(void *p_instance, PhysicsDirectBodyState2D *p_state); +}; + +GDVIRTUAL_NATIVE_PTR(PhysicsServer2DExtensionMotionResult) +GDVIRTUAL_NATIVE_PTR(PhysicsServer2DExtensionStateCallback) + +class PhysicsServer2DExtension : public PhysicsServer2D { + GDCLASS(PhysicsServer2DExtension, PhysicsServer2D); + +protected: + static void _bind_methods(); + + GDVIRTUAL9R(bool, _shape_collide, RID, const Transform2D &, const Vector2 &, RID, const Transform2D &, const Vector2 &, GDNativePtr<Vector2>, int, GDNativePtr<int>) + + GDVIRTUAL8R(bool, _body_collide_shape, RID, int, RID, const Transform2D &, const Vector2 &, GDNativePtr<Vector2>, int, GDNativePtr<int>) + +public: + // The warning is valid, but unavoidable. If the function is not overridden it will error anyway. + + /* SHAPE API */ + + EXBIND0R(RID, world_boundary_shape_create) + EXBIND0R(RID, separation_ray_shape_create) + EXBIND0R(RID, segment_shape_create) + EXBIND0R(RID, circle_shape_create) + EXBIND0R(RID, rectangle_shape_create) + EXBIND0R(RID, capsule_shape_create) + EXBIND0R(RID, convex_polygon_shape_create) + EXBIND0R(RID, concave_polygon_shape_create) + + EXBIND2(shape_set_data, RID, const Variant &) + EXBIND2(shape_set_custom_solver_bias, RID, real_t) + + EXBIND1RC(ShapeType, shape_get_type, RID) + EXBIND1RC(Variant, shape_get_data, RID) + EXBIND1RC(real_t, shape_get_custom_solver_bias, RID) + + virtual bool shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) override { + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_shape_collide, p_shape_A, p_xform_A, p_motion_A, p_shape_B, p_xform_B, p_motion_B, r_results, p_result_max, &r_result_count, ret); + return ret; + } + + /* SPACE API */ + + EXBIND0R(RID, space_create) + EXBIND2(space_set_active, RID, bool) + EXBIND1RC(bool, space_is_active, RID) + + EXBIND3(space_set_param, RID, SpaceParameter, real_t) + EXBIND2RC(real_t, space_get_param, RID, SpaceParameter) + + EXBIND1R(PhysicsDirectSpaceState2D *, space_get_direct_state, RID) + + EXBIND2(space_set_debug_contacts, RID, int) + EXBIND1RC(Vector<Vector2>, space_get_contacts, RID) + EXBIND1RC(int, space_get_contact_count, RID) + + /* AREA API */ + + //EXBIND0RID(area); + EXBIND0R(RID, area_create) + + EXBIND2(area_set_space, RID, RID) + EXBIND1RC(RID, area_get_space, RID) + + EXBIND4(area_add_shape, RID, RID, const Transform2D &, bool) + EXBIND3(area_set_shape, RID, int, RID) + EXBIND3(area_set_shape_transform, RID, int, const Transform2D &) + EXBIND3(area_set_shape_disabled, RID, int, bool) + + EXBIND1RC(int, area_get_shape_count, RID) + EXBIND2RC(RID, area_get_shape, RID, int) + EXBIND2RC(Transform2D, area_get_shape_transform, RID, int) + + EXBIND2(area_remove_shape, RID, int) + EXBIND1(area_clear_shapes, RID) + + EXBIND2(area_attach_object_instance_id, RID, ObjectID) + EXBIND1RC(ObjectID, area_get_object_instance_id, RID) + + EXBIND2(area_attach_canvas_instance_id, RID, ObjectID) + EXBIND1RC(ObjectID, area_get_canvas_instance_id, RID) + + EXBIND3(area_set_param, RID, AreaParameter, const Variant &) + EXBIND2(area_set_transform, RID, const Transform2D &) + + EXBIND2RC(Variant, area_get_param, RID, AreaParameter) + EXBIND1RC(Transform2D, area_get_transform, RID) + + EXBIND2(area_set_collision_mask, RID, uint32_t) + EXBIND2(area_set_collision_layer, RID, uint32_t) + + EXBIND2(area_set_monitorable, RID, bool) + EXBIND2(area_set_pickable, RID, bool) + + EXBIND2(area_set_monitor_callback, RID, const Callable &) + EXBIND2(area_set_area_monitor_callback, RID, const Callable &) + + /* BODY API */ + + //EXBIND2RID(body,BodyMode,bool); + EXBIND0R(RID, body_create) + + EXBIND2(body_set_space, RID, RID) + EXBIND1RC(RID, body_get_space, RID) + + EXBIND2(body_set_mode, RID, BodyMode) + EXBIND1RC(BodyMode, body_get_mode, RID) + + EXBIND4(body_add_shape, RID, RID, const Transform2D &, bool) + EXBIND3(body_set_shape, RID, int, RID) + EXBIND3(body_set_shape_transform, RID, int, const Transform2D &) + + EXBIND1RC(int, body_get_shape_count, RID) + EXBIND2RC(RID, body_get_shape, RID, int) + EXBIND2RC(Transform2D, body_get_shape_transform, RID, int) + + EXBIND3(body_set_shape_disabled, RID, int, bool) + EXBIND4(body_set_shape_as_one_way_collision, RID, int, bool, real_t) + + EXBIND2(body_remove_shape, RID, int) + EXBIND1(body_clear_shapes, RID) + + EXBIND2(body_attach_object_instance_id, RID, ObjectID) + EXBIND1RC(ObjectID, body_get_object_instance_id, RID) + + EXBIND2(body_attach_canvas_instance_id, RID, ObjectID) + EXBIND1RC(ObjectID, body_get_canvas_instance_id, RID) + + EXBIND2(body_set_continuous_collision_detection_mode, RID, CCDMode) + EXBIND1RC(CCDMode, body_get_continuous_collision_detection_mode, RID) + + EXBIND2(body_set_collision_layer, RID, uint32_t) + EXBIND1RC(uint32_t, body_get_collision_layer, RID) + + EXBIND2(body_set_collision_mask, RID, uint32_t) + EXBIND1RC(uint32_t, body_get_collision_mask, RID) + + EXBIND2(body_set_collision_priority, RID, real_t) + EXBIND1RC(real_t, body_get_collision_priority, RID) + + EXBIND3(body_set_param, RID, BodyParameter, const Variant &) + EXBIND2RC(Variant, body_get_param, RID, BodyParameter) + + EXBIND1(body_reset_mass_properties, RID) + + EXBIND3(body_set_state, RID, BodyState, const Variant &) + EXBIND2RC(Variant, body_get_state, RID, BodyState) + + EXBIND2(body_apply_central_impulse, RID, const Vector2 &) + EXBIND2(body_apply_torque_impulse, RID, real_t) + EXBIND3(body_apply_impulse, RID, const Vector2 &, const Vector2 &) + + EXBIND2(body_apply_central_force, RID, const Vector2 &) + EXBIND3(body_apply_force, RID, const Vector2 &, const Vector2 &) + EXBIND2(body_apply_torque, RID, real_t) + + EXBIND2(body_add_constant_central_force, RID, const Vector2 &) + EXBIND3(body_add_constant_force, RID, const Vector2 &, const Vector2 &) + EXBIND2(body_add_constant_torque, RID, real_t) + + EXBIND2(body_set_constant_force, RID, const Vector2 &) + EXBIND1RC(Vector2, body_get_constant_force, RID) + + EXBIND2(body_set_constant_torque, RID, real_t) + EXBIND1RC(real_t, body_get_constant_torque, RID) + + EXBIND2(body_set_axis_velocity, RID, const Vector2 &) + + EXBIND2(body_add_collision_exception, RID, RID) + EXBIND2(body_remove_collision_exception, RID, RID) + GDVIRTUAL1RC(TypedArray<RID>, _body_get_collision_exceptions, RID) + + void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) override { + TypedArray<RID> ret; + GDVIRTUAL_REQUIRED_CALL(_body_get_collision_exceptions, p_body, ret); + for (int i = 0; i < ret.size(); i++) { + p_exceptions->push_back(ret[i]); + } + } + + EXBIND2(body_set_max_contacts_reported, RID, int) + EXBIND1RC(int, body_get_max_contacts_reported, RID) + + EXBIND2(body_set_contacts_reported_depth_threshold, RID, real_t) + EXBIND1RC(real_t, body_get_contacts_reported_depth_threshold, RID) + + EXBIND2(body_set_omit_force_integration, RID, bool) + EXBIND1RC(bool, body_is_omitting_force_integration, RID) + + GDVIRTUAL2(_body_set_state_sync_callback, RID, GDNativePtr<PhysicsServer2DExtensionStateCallback>) + void body_set_state_sync_callback(RID p_body, void *p_instance, BodyStateCallback p_callback) override { + PhysicsServer2DExtensionStateCallback callback; + callback.callback = p_callback; + callback.instance = p_instance; + GDVIRTUAL_REQUIRED_CALL(_body_set_state_sync_callback, p_body, &callback); + } + EXBIND3(body_set_force_integration_callback, RID, const Callable &, const Variant &) + + virtual bool body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) override { + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_body_collide_shape, p_body, p_body_shape, p_shape, p_shape_xform, p_motion, r_results, p_result_max, &r_result_count, ret); + return ret; + } + + EXBIND2(body_set_pickable, RID, bool) + + EXBIND1R(PhysicsDirectBodyState2D *, body_get_direct_state, RID) + + GDVIRTUAL7RC(bool, _body_test_motion, RID, const Transform2D &, const Vector2 &, real_t, bool, bool, GDNativePtr<PhysicsServer2DExtensionMotionResult>) + + thread_local static const HashSet<RID> *exclude_bodies; + thread_local static const HashSet<ObjectID> *exclude_objects; + + bool body_test_motion_is_excluding_body(RID p_body) const; + bool body_test_motion_is_excluding_object(ObjectID p_object) const; + + bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override { + bool ret = false; + exclude_bodies = &p_parameters.exclude_bodies; + exclude_objects = &p_parameters.exclude_objects; + GDVIRTUAL_REQUIRED_CALL(_body_test_motion, p_body, p_parameters.from, p_parameters.motion, p_parameters.margin, p_parameters.collide_separation_ray, p_parameters.recovery_as_collision, r_result, ret); + exclude_bodies = nullptr; + exclude_objects = nullptr; + return ret; + } + + /* JOINT API */ + + EXBIND0R(RID, joint_create) + EXBIND1(joint_clear, RID) + + EXBIND3(joint_set_param, RID, JointParam, real_t) + EXBIND2RC(real_t, joint_get_param, RID, JointParam) + + EXBIND2(joint_disable_collisions_between_bodies, RID, bool) + EXBIND1RC(bool, joint_is_disabled_collisions_between_bodies, RID) + + EXBIND4(joint_make_pin, RID, const Vector2 &, RID, RID) + EXBIND6(joint_make_groove, RID, const Vector2 &, const Vector2 &, const Vector2 &, RID, RID) + EXBIND5(joint_make_damped_spring, RID, const Vector2 &, const Vector2 &, RID, RID) + + EXBIND3(pin_joint_set_param, RID, PinJointParam, real_t) + EXBIND2RC(real_t, pin_joint_get_param, RID, PinJointParam) + + EXBIND3(damped_spring_joint_set_param, RID, DampedSpringParam, real_t) + EXBIND2RC(real_t, damped_spring_joint_get_param, RID, DampedSpringParam) + + EXBIND1RC(JointType, joint_get_type, RID) + + /* MISC */ + + GDVIRTUAL1(_free_rid, RID) + virtual void free(RID p_rid) override { + GDVIRTUAL_REQUIRED_CALL(_free_rid, p_rid); + } + + EXBIND1(set_active, bool) + + EXBIND0(init) + EXBIND1(step, real_t) + EXBIND0(sync) + EXBIND0(flush_queries) + EXBIND0(end_sync) + EXBIND0(finish) + + EXBIND0RC(bool, is_flushing_queries) + EXBIND1R(int, get_process_info, ProcessInfo) + + PhysicsServer2DExtension(); + ~PhysicsServer2DExtension(); +}; + +#endif // PHYSICS_SERVER_2D_EXTENSION_H diff --git a/servers/extensions/physics_server_3d_extension.cpp b/servers/extensions/physics_server_3d_extension.cpp index 7d797bf611..800284dc60 100644 --- a/servers/extensions/physics_server_3d_extension.cpp +++ b/servers/extensions/physics_server_3d_extension.cpp @@ -125,6 +125,8 @@ bool PhysicsServer3DExtension::body_test_motion_is_excluding_object(ObjectID p_o } void PhysicsServer3DExtension::_bind_methods() { + /* SHAPE API */ + GDVIRTUAL_BIND(_world_boundary_shape_create); GDVIRTUAL_BIND(_separation_ray_shape_create); GDVIRTUAL_BIND(_sphere_shape_create); @@ -137,18 +139,34 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_custom_shape_create); GDVIRTUAL_BIND(_shape_set_data, "shape", "data"); + GDVIRTUAL_BIND(_shape_set_custom_solver_bias, "shape", "bias"); + + GDVIRTUAL_BIND(_shape_set_margin, "shape", "margin"); + GDVIRTUAL_BIND(_shape_get_margin, "shape"); GDVIRTUAL_BIND(_shape_get_type, "shape"); GDVIRTUAL_BIND(_shape_get_data, "shape"); + GDVIRTUAL_BIND(_shape_get_custom_solver_bias, "shape"); + + /* SPACE API */ GDVIRTUAL_BIND(_space_create); GDVIRTUAL_BIND(_space_set_active, "space", "active"); GDVIRTUAL_BIND(_space_is_active, "space"); + GDVIRTUAL_BIND(_space_set_param, "space", "param", "value"); GDVIRTUAL_BIND(_space_get_param, "space", "param"); + GDVIRTUAL_BIND(_space_get_direct_state, "space"); + GDVIRTUAL_BIND(_space_set_debug_contacts, "space", "max_contacts"); + GDVIRTUAL_BIND(_space_get_contacts, "space"); + GDVIRTUAL_BIND(_space_get_contact_count, "space"); + + /* AREA API */ + GDVIRTUAL_BIND(_area_create); + GDVIRTUAL_BIND(_area_set_space, "area", "space"); GDVIRTUAL_BIND(_area_get_space, "area"); @@ -164,8 +182,8 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_area_remove_shape, "area", "shape_idx"); GDVIRTUAL_BIND(_area_clear_shapes, "area"); - GDVIRTUAL_BIND(_area_set_collision_layer, "area", "layer"); - GDVIRTUAL_BIND(_area_set_collision_mask, "area", "mask"); + GDVIRTUAL_BIND(_area_attach_object_instance_id, "area", "id"); + GDVIRTUAL_BIND(_area_get_object_instance_id, "area"); GDVIRTUAL_BIND(_area_set_param, "area", "param", "value"); GDVIRTUAL_BIND(_area_set_transform, "area", "transform"); @@ -173,14 +191,16 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_area_get_param, "area", "param"); GDVIRTUAL_BIND(_area_get_transform, "area"); - GDVIRTUAL_BIND(_area_attach_object_instance_id, "area", "id"); - GDVIRTUAL_BIND(_area_get_object_instance_id, "area"); + GDVIRTUAL_BIND(_area_set_collision_layer, "area", "layer"); + GDVIRTUAL_BIND(_area_set_collision_mask, "area", "mask"); + + GDVIRTUAL_BIND(_area_set_monitorable, "area", "monitorable"); + GDVIRTUAL_BIND(_area_set_ray_pickable, "area", "enable"); GDVIRTUAL_BIND(_area_set_monitor_callback, "area", "callback"); GDVIRTUAL_BIND(_area_set_area_monitor_callback, "area", "callback"); - GDVIRTUAL_BIND(_area_set_monitorable, "area", "monitorable"); - GDVIRTUAL_BIND(_area_set_ray_pickable, "area", "enable"); + /* BODY API */ GDVIRTUAL_BIND(_body_create); @@ -190,15 +210,6 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_set_mode, "body", "mode"); GDVIRTUAL_BIND(_body_get_mode, "body"); - GDVIRTUAL_BIND(_body_set_collision_layer, "body", "layer"); - GDVIRTUAL_BIND(_body_get_collision_layer, "body"); - - GDVIRTUAL_BIND(_body_set_collision_mask, "body", "mask"); - GDVIRTUAL_BIND(_body_get_collision_mask, "body"); - - GDVIRTUAL_BIND(_body_set_collision_priority, "body", "priority"); - GDVIRTUAL_BIND(_body_get_collision_priority, "body"); - GDVIRTUAL_BIND(_body_add_shape, "body", "shape", "transform", "disabled"); GDVIRTUAL_BIND(_body_set_shape, "body", "shape_idx", "shape"); GDVIRTUAL_BIND(_body_set_shape_transform, "body", "shape_idx", "transform"); @@ -217,6 +228,18 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_set_enable_continuous_collision_detection, "body", "enable"); GDVIRTUAL_BIND(_body_is_continuous_collision_detection_enabled, "body"); + GDVIRTUAL_BIND(_body_set_collision_layer, "body", "layer"); + GDVIRTUAL_BIND(_body_get_collision_layer, "body"); + + GDVIRTUAL_BIND(_body_set_collision_mask, "body", "mask"); + GDVIRTUAL_BIND(_body_get_collision_mask, "body"); + + GDVIRTUAL_BIND(_body_set_collision_priority, "body", "priority"); + GDVIRTUAL_BIND(_body_get_collision_priority, "body"); + + GDVIRTUAL_BIND(_body_set_user_flags, "body", "flags"); + GDVIRTUAL_BIND(_body_get_user_flags, "body"); + GDVIRTUAL_BIND(_body_set_param, "body", "param", "value"); GDVIRTUAL_BIND(_body_get_param, "body", "param"); @@ -250,13 +273,18 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_add_collision_exception, "body", "excepted_body"); GDVIRTUAL_BIND(_body_remove_collision_exception, "body", "excepted_body"); + GDVIRTUAL_BIND(_body_get_collision_exceptions, "body"); GDVIRTUAL_BIND(_body_set_max_contacts_reported, "body", "amount"); GDVIRTUAL_BIND(_body_get_max_contacts_reported, "body"); + GDVIRTUAL_BIND(_body_set_contacts_reported_depth_threshold, "body", "threshold"); + GDVIRTUAL_BIND(_body_get_contacts_reported_depth_threshold, "body"); + GDVIRTUAL_BIND(_body_set_omit_force_integration, "body", "enable"); GDVIRTUAL_BIND(_body_is_omitting_force_integration, "body"); + GDVIRTUAL_BIND(_body_set_state_sync_callback, "body", "callback"); GDVIRTUAL_BIND(_body_set_force_integration_callback, "body", "callable", "userdata"); GDVIRTUAL_BIND(_body_set_ray_pickable, "body", "enable"); @@ -265,12 +293,68 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_get_direct_state, "body"); + /* SOFT BODY API */ + + GDVIRTUAL_BIND(_soft_body_create); + + GDVIRTUAL_BIND(_soft_body_update_rendering_server, "body", "rendering_server_handler"); + + GDVIRTUAL_BIND(_soft_body_set_space, "body", "space"); + GDVIRTUAL_BIND(_soft_body_get_space, "body"); + + GDVIRTUAL_BIND(_soft_body_set_ray_pickable, "body", "enable"); + + GDVIRTUAL_BIND(_soft_body_set_collision_layer, "body", "layer"); + GDVIRTUAL_BIND(_soft_body_get_collision_layer, "body"); + + GDVIRTUAL_BIND(_soft_body_set_collision_mask, "body", "mask"); + GDVIRTUAL_BIND(_soft_body_get_collision_mask, "body"); + + GDVIRTUAL_BIND(_soft_body_add_collision_exception, "body", "body_b"); + GDVIRTUAL_BIND(_soft_body_remove_collision_exception, "body", "body_b"); + GDVIRTUAL_BIND(_soft_body_get_collision_exceptions, "body"); + + GDVIRTUAL_BIND(_soft_body_set_state, "body", "state", "variant"); + GDVIRTUAL_BIND(_soft_body_get_state, "body", "state"); + + GDVIRTUAL_BIND(_soft_body_set_transform, "body", "transform"); + + GDVIRTUAL_BIND(_soft_body_set_simulation_precision, "body", "simulation_precision"); + GDVIRTUAL_BIND(_soft_body_get_simulation_precision, "body"); + + GDVIRTUAL_BIND(_soft_body_set_total_mass, "body", "total_mass"); + GDVIRTUAL_BIND(_soft_body_get_total_mass, "body"); + + GDVIRTUAL_BIND(_soft_body_set_linear_stiffness, "body", "linear_stiffness"); + GDVIRTUAL_BIND(_soft_body_get_linear_stiffness, "body"); + + GDVIRTUAL_BIND(_soft_body_set_pressure_coefficient, "body", "pressure_coefficient"); + GDVIRTUAL_BIND(_soft_body_get_pressure_coefficient, "body"); + + GDVIRTUAL_BIND(_soft_body_set_damping_coefficient, "body", "damping_coefficient"); + GDVIRTUAL_BIND(_soft_body_get_damping_coefficient, "body"); + + GDVIRTUAL_BIND(_soft_body_set_drag_coefficient, "body", "drag_coefficient"); + GDVIRTUAL_BIND(_soft_body_get_drag_coefficient, "body"); + + GDVIRTUAL_BIND(_soft_body_set_mesh, "body", "mesh"); + GDVIRTUAL_BIND(_soft_body_get_bounds, "body"); + GDVIRTUAL_BIND(_soft_body_move_point, "body", "point_index", "global_position"); + GDVIRTUAL_BIND(_soft_body_get_point_global_position, "body", "point_index"); + + GDVIRTUAL_BIND(_soft_body_remove_all_pinned_points, "body"); + GDVIRTUAL_BIND(_soft_body_pin_point, "body", "point_index", "pin"); + GDVIRTUAL_BIND(_soft_body_is_point_pinned, "body", "point_index"); + + /* JOINT API */ + GDVIRTUAL_BIND(_joint_create); GDVIRTUAL_BIND(_joint_clear, "joint"); GDVIRTUAL_BIND(_joint_make_pin, "joint", "body_A", "local_A", "body_B", "local_B"); + GDVIRTUAL_BIND(_pin_joint_set_param, "joint", "param", "value"); GDVIRTUAL_BIND(_pin_joint_get_param, "joint", "param"); @@ -281,6 +365,7 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_pin_joint_get_local_b, "joint"); GDVIRTUAL_BIND(_joint_make_hinge, "joint", "body_A", "hinge_A", "body_B", "hinge_B"); + GDVIRTUAL_BIND(_joint_make_hinge_simple, "joint", "body_A", "pivot_A", "axis_A", "body_B", "pivot_B", "axis_B"); GDVIRTUAL_BIND(_hinge_joint_set_param, "joint", "param", "value"); GDVIRTUAL_BIND(_hinge_joint_get_param, "joint", "param"); @@ -298,11 +383,6 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_cone_twist_joint_set_param, "joint", "param", "value"); GDVIRTUAL_BIND(_cone_twist_joint_get_param, "joint", "param"); - GDVIRTUAL_BIND(_joint_get_type, "joint"); - - GDVIRTUAL_BIND(_joint_set_solver_priority, "joint", "priority"); - GDVIRTUAL_BIND(_joint_get_solver_priority, "joint"); - GDVIRTUAL_BIND(_joint_make_generic_6dof, "joint", "body_A", "local_ref_A", "body_B", "local_ref_B"); GDVIRTUAL_BIND(_generic_6dof_joint_set_param, "joint", "axis", "param", "value"); @@ -311,10 +391,23 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_generic_6dof_joint_set_flag, "joint", "axis", "flag", "enable"); GDVIRTUAL_BIND(_generic_6dof_joint_get_flag, "joint", "axis", "flag"); + GDVIRTUAL_BIND(_joint_get_type, "joint"); + + GDVIRTUAL_BIND(_joint_set_solver_priority, "joint", "priority"); + GDVIRTUAL_BIND(_joint_get_solver_priority, "joint"); + GDVIRTUAL_BIND(_free_rid, "rid"); GDVIRTUAL_BIND(_set_active, "active"); + GDVIRTUAL_BIND(_init); + GDVIRTUAL_BIND(_step, "step"); + GDVIRTUAL_BIND(_sync); + GDVIRTUAL_BIND(_flush_queries); + GDVIRTUAL_BIND(_end_sync); + GDVIRTUAL_BIND(_finish); + + GDVIRTUAL_BIND(_is_flushing_queries); GDVIRTUAL_BIND(_get_process_info, "process_info"); } diff --git a/servers/extensions/physics_server_3d_extension.h b/servers/extensions/physics_server_3d_extension.h index 3200438253..b6ed346a3d 100644 --- a/servers/extensions/physics_server_3d_extension.h +++ b/servers/extensions/physics_server_3d_extension.h @@ -210,6 +210,8 @@ protected: public: // The warning is valid, but unavoidable. If the function is not overridden it will error anyway. + /* SHAPE API */ + EXBIND0R(RID, world_boundary_shape_create) EXBIND0R(RID, separation_ray_shape_create) EXBIND0R(RID, sphere_shape_create) @@ -262,6 +264,7 @@ public: EXBIND1RC(int, area_get_shape_count, RID) EXBIND2RC(RID, area_get_shape, RID, int) EXBIND2RC(Transform3D, area_get_shape_transform, RID, int) + EXBIND2(area_remove_shape, RID, int) EXBIND1(area_clear_shapes, RID) @@ -297,12 +300,11 @@ public: EXBIND4(body_add_shape, RID, RID, const Transform3D &, bool) EXBIND3(body_set_shape, RID, int, RID) EXBIND3(body_set_shape_transform, RID, int, const Transform3D &) + EXBIND3(body_set_shape_disabled, RID, int, bool) EXBIND1RC(int, body_get_shape_count, RID) - EXBIND2RC(Transform3D, body_get_shape_transform, RID, int) EXBIND2RC(RID, body_get_shape, RID, int) - - EXBIND3(body_set_shape_disabled, RID, int, bool) + EXBIND2RC(Transform3D, body_get_shape_transform, RID, int) EXBIND2(body_remove_shape, RID, int) EXBIND1(body_clear_shapes, RID) @@ -333,9 +335,9 @@ public: EXBIND3(body_set_state, RID, BodyState, const Variant &) EXBIND2RC(Variant, body_get_state, RID, BodyState) - EXBIND2(body_apply_torque_impulse, RID, const Vector3 &) EXBIND2(body_apply_central_impulse, RID, const Vector3 &) EXBIND3(body_apply_impulse, RID, const Vector3 &, const Vector3 &) + EXBIND2(body_apply_torque_impulse, RID, const Vector3 &) EXBIND2(body_apply_central_force, RID, const Vector3 &) EXBIND3(body_apply_force, RID, const Vector3 &, const Vector3 &) @@ -476,7 +478,6 @@ public: /* JOINT API */ EXBIND0R(RID, joint_create) - EXBIND1(joint_clear, RID) EXBIND5(joint_make_pin, RID, RID, const Vector3 &, RID, const Vector3 &) @@ -537,8 +538,8 @@ public: EXBIND0(init) EXBIND1(step, real_t) EXBIND0(sync) - EXBIND0(end_sync) EXBIND0(flush_queries) + EXBIND0(end_sync) EXBIND0(finish) EXBIND0RC(bool, is_flushing_queries) diff --git a/servers/physics_2d/godot_body_direct_state_2d.cpp b/servers/physics_2d/godot_body_direct_state_2d.cpp index cde6e8c991..d413e03be6 100644 --- a/servers/physics_2d/godot_body_direct_state_2d.cpp +++ b/servers/physics_2d/godot_body_direct_state_2d.cpp @@ -138,7 +138,7 @@ void GodotPhysicsDirectBodyState2D::add_constant_torque(real_t p_torque) { } void GodotPhysicsDirectBodyState2D::set_constant_force(const Vector2 &p_force) { - if (!p_force.is_equal_approx(Vector2())) { + if (!p_force.is_zero_approx()) { body->wakeup(); } body->set_constant_force(p_force); diff --git a/servers/physics_2d/godot_physics_server_2d.cpp b/servers/physics_2d/godot_physics_server_2d.cpp index c728dccd4f..cec31bdc31 100644 --- a/servers/physics_2d/godot_physics_server_2d.cpp +++ b/servers/physics_2d/godot_physics_server_2d.cpp @@ -848,7 +848,7 @@ void GodotPhysicsServer2D::body_set_constant_force(RID p_body, const Vector2 &p_ ERR_FAIL_COND(!body); body->set_constant_force(p_force); - if (!p_force.is_equal_approx(Vector2())) { + if (!p_force.is_zero_approx()) { body->wakeup(); } } diff --git a/servers/physics_3d/godot_body_direct_state_3d.cpp b/servers/physics_3d/godot_body_direct_state_3d.cpp index a8c6086e1c..25088d33f3 100644 --- a/servers/physics_3d/godot_body_direct_state_3d.cpp +++ b/servers/physics_3d/godot_body_direct_state_3d.cpp @@ -145,7 +145,7 @@ void GodotPhysicsDirectBodyState3D::add_constant_torque(const Vector3 &p_torque) } void GodotPhysicsDirectBodyState3D::set_constant_force(const Vector3 &p_force) { - if (!p_force.is_equal_approx(Vector3())) { + if (!p_force.is_zero_approx()) { body->wakeup(); } body->set_constant_force(p_force); @@ -156,7 +156,7 @@ Vector3 GodotPhysicsDirectBodyState3D::get_constant_force() const { } void GodotPhysicsDirectBodyState3D::set_constant_torque(const Vector3 &p_torque) { - if (!p_torque.is_equal_approx(Vector3())) { + if (!p_torque.is_zero_approx()) { body->wakeup(); } body->set_constant_torque(p_torque); diff --git a/servers/physics_3d/godot_collision_solver_3d_sat.cpp b/servers/physics_3d/godot_collision_solver_3d_sat.cpp index 20e9300778..56e644b57b 100644 --- a/servers/physics_3d/godot_collision_solver_3d_sat.cpp +++ b/servers/physics_3d/godot_collision_solver_3d_sat.cpp @@ -629,7 +629,7 @@ public: _FORCE_INLINE_ bool test_axis(const Vector3 &p_axis) { Vector3 axis = p_axis; - if (axis.is_equal_approx(Vector3())) { + if (axis.is_zero_approx()) { // strange case, try an upwards separator axis = Vector3(0.0, 1.0, 0.0); } diff --git a/servers/physics_3d/godot_physics_server_3d.cpp b/servers/physics_3d/godot_physics_server_3d.cpp index 9c1535f561..b028c00a31 100644 --- a/servers/physics_3d/godot_physics_server_3d.cpp +++ b/servers/physics_3d/godot_physics_server_3d.cpp @@ -760,7 +760,7 @@ void GodotPhysicsServer3D::body_set_constant_force(RID p_body, const Vector3 &p_ ERR_FAIL_COND(!body); body->set_constant_force(p_force); - if (!p_force.is_equal_approx(Vector3())) { + if (!p_force.is_zero_approx()) { body->wakeup(); } } @@ -776,7 +776,7 @@ void GodotPhysicsServer3D::body_set_constant_torque(RID p_body, const Vector3 &p ERR_FAIL_COND(!body); body->set_constant_torque(p_torque); - if (!p_torque.is_equal_approx(Vector3())) { + if (!p_torque.is_zero_approx()) { body->wakeup(); } } diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp index ca9c9c8fc4..abaa473017 100644 --- a/servers/physics_server_2d.cpp +++ b/servers/physics_server_2d.cpp @@ -148,7 +148,7 @@ PhysicsDirectBodyState2D::PhysicsDirectBodyState2D() {} /////////////////////////////////////////////////////// -Ref<PhysicsRayQueryParameters2D> PhysicsRayQueryParameters2D::create(Vector2 p_from, Vector2 p_to, uint32_t p_mask, const Vector<RID> &p_exclude) { +Ref<PhysicsRayQueryParameters2D> PhysicsRayQueryParameters2D::create(Vector2 p_from, Vector2 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude) { Ref<PhysicsRayQueryParameters2D> params; params.instantiate(); params->set_from(p_from); @@ -158,25 +158,25 @@ Ref<PhysicsRayQueryParameters2D> PhysicsRayQueryParameters2D::create(Vector2 p_f return params; } -void PhysicsRayQueryParameters2D::set_exclude(const Vector<RID> &p_exclude) { +void PhysicsRayQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) { parameters.exclude.clear(); for (int i = 0; i < p_exclude.size(); i++) { parameters.exclude.insert(p_exclude[i]); } } -Vector<RID> PhysicsRayQueryParameters2D::get_exclude() const { - Vector<RID> ret; +TypedArray<RID> PhysicsRayQueryParameters2D::get_exclude() const { + TypedArray<RID> ret; ret.resize(parameters.exclude.size()); int idx = 0; for (const RID &E : parameters.exclude) { - ret.write[idx++] = E; + ret[idx++] = E; } return ret; } void PhysicsRayQueryParameters2D::_bind_methods() { - ClassDB::bind_static_method("PhysicsRayQueryParameters2D", D_METHOD("create", "from", "to", "collision_mask", "exclude"), &PhysicsRayQueryParameters2D::create, DEFVAL(UINT32_MAX), DEFVAL(Vector<RID>())); + ClassDB::bind_static_method("PhysicsRayQueryParameters2D", D_METHOD("create", "from", "to", "collision_mask", "exclude"), &PhysicsRayQueryParameters2D::create, DEFVAL(UINT32_MAX), DEFVAL(TypedArray<RID>())); ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsRayQueryParameters2D::set_from); ClassDB::bind_method(D_METHOD("get_from"), &PhysicsRayQueryParameters2D::get_from); @@ -210,19 +210,19 @@ void PhysicsRayQueryParameters2D::_bind_methods() { /////////////////////////////////////////////////////// -void PhysicsPointQueryParameters2D::set_exclude(const Vector<RID> &p_exclude) { +void PhysicsPointQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) { parameters.exclude.clear(); for (int i = 0; i < p_exclude.size(); i++) { parameters.exclude.insert(p_exclude[i]); } } -Vector<RID> PhysicsPointQueryParameters2D::get_exclude() const { - Vector<RID> ret; +TypedArray<RID> PhysicsPointQueryParameters2D::get_exclude() const { + TypedArray<RID> ret; ret.resize(parameters.exclude.size()); int idx = 0; for (const RID &E : parameters.exclude) { - ret.write[idx++] = E; + ret[idx++] = E; } return ret; } @@ -269,19 +269,19 @@ void PhysicsShapeQueryParameters2D::set_shape_rid(const RID &p_shape) { } } -void PhysicsShapeQueryParameters2D::set_exclude(const Vector<RID> &p_exclude) { +void PhysicsShapeQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) { parameters.exclude.clear(); for (int i = 0; i < p_exclude.size(); i++) { parameters.exclude.insert(p_exclude[i]); } } -Vector<RID> PhysicsShapeQueryParameters2D::get_exclude() const { - Vector<RID> ret; +TypedArray<RID> PhysicsShapeQueryParameters2D::get_exclude() const { + TypedArray<RID> ret; ret.resize(parameters.exclude.size()); int idx = 0; for (const RID &E : parameters.exclude) { - ret.write[idx++] = E; + ret[idx++] = E; } return ret; } @@ -461,21 +461,21 @@ void PhysicsDirectSpaceState2D::_bind_methods() { /////////////////////////////// -Vector<RID> PhysicsTestMotionParameters2D::get_exclude_bodies() const { - Vector<RID> exclude; +TypedArray<RID> PhysicsTestMotionParameters2D::get_exclude_bodies() const { + TypedArray<RID> exclude; exclude.resize(parameters.exclude_bodies.size()); int body_index = 0; for (RID body : parameters.exclude_bodies) { - exclude.write[body_index++] = body; + exclude[body_index++] = body; } return exclude; } -void PhysicsTestMotionParameters2D::set_exclude_bodies(const Vector<RID> &p_exclude) { - for (RID body : p_exclude) { - parameters.exclude_bodies.insert(body); +void PhysicsTestMotionParameters2D::set_exclude_bodies(const TypedArray<RID> &p_exclude) { + for (int i = 0; i < p_exclude.size(); i++) { + parameters.exclude_bodies.insert(p_exclude[i]); } } @@ -850,6 +850,8 @@ void PhysicsServer2D::_bind_methods() { BIND_ENUM_CONSTANT(JOINT_PARAM_MAX_BIAS); BIND_ENUM_CONSTANT(JOINT_PARAM_MAX_FORCE); + BIND_ENUM_CONSTANT(PIN_JOINT_SOFTNESS); + BIND_ENUM_CONSTANT(DAMPED_SPRING_REST_LENGTH); BIND_ENUM_CONSTANT(DAMPED_SPRING_STIFFNESS); BIND_ENUM_CONSTANT(DAMPED_SPRING_DAMPING); @@ -874,9 +876,7 @@ PhysicsServer2D::~PhysicsServer2D() { singleton = nullptr; } -Vector<PhysicsServer2DManager::ClassInfo> PhysicsServer2DManager::physics_2d_servers; -int PhysicsServer2DManager::default_server_id = -1; -int PhysicsServer2DManager::default_server_priority = -1; +PhysicsServer2DManager *PhysicsServer2DManager::singleton = nullptr; const String PhysicsServer2DManager::setting_property_name(PNAME("physics/2d/physics_engine")); void PhysicsServer2DManager::on_servers_changed() { @@ -887,10 +887,19 @@ void PhysicsServer2DManager::on_servers_changed() { ProjectSettings::get_singleton()->set_custom_property_info(setting_property_name, PropertyInfo(Variant::STRING, setting_property_name, PROPERTY_HINT_ENUM, physics_servers)); } -void PhysicsServer2DManager::register_server(const String &p_name, CreatePhysicsServer2DCallback p_creat_callback) { - ERR_FAIL_COND(!p_creat_callback); +void PhysicsServer2DManager::_bind_methods() { + ClassDB::bind_method(D_METHOD("register_server", "name", "create_callback"), &PhysicsServer2DManager::register_server); + ClassDB::bind_method(D_METHOD("set_default_server", "name", "priority"), &PhysicsServer2DManager::set_default_server); +} + +PhysicsServer2DManager *PhysicsServer2DManager::get_singleton() { + return singleton; +} + +void PhysicsServer2DManager::register_server(const String &p_name, const Callable &p_create_callback) { + //ERR_FAIL_COND(!p_create_callback.is_valid()); ERR_FAIL_COND(find_server_id(p_name) != -1); - physics_2d_servers.push_back(ClassInfo(p_name, p_creat_callback)); + physics_2d_servers.push_back(ClassInfo(p_name, p_create_callback)); on_servers_changed(); } @@ -923,7 +932,11 @@ String PhysicsServer2DManager::get_server_name(int p_id) { PhysicsServer2D *PhysicsServer2DManager::new_default_server() { ERR_FAIL_COND_V(default_server_id == -1, nullptr); - return physics_2d_servers[default_server_id].create_callback(); + Variant ret; + Callable::CallError ce; + physics_2d_servers[default_server_id].create_callback.callp(nullptr, 0, ret, ce); + ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, nullptr); + return Object::cast_to<PhysicsServer2D>(ret.get_validated_object()); } PhysicsServer2D *PhysicsServer2DManager::new_server(const String &p_name) { @@ -931,6 +944,18 @@ PhysicsServer2D *PhysicsServer2DManager::new_server(const String &p_name) { if (id == -1) { return nullptr; } else { - return physics_2d_servers[id].create_callback(); + Variant ret; + Callable::CallError ce; + physics_2d_servers[id].create_callback.callp(nullptr, 0, ret, ce); + ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, nullptr); + return Object::cast_to<PhysicsServer2D>(ret.get_validated_object()); } } + +PhysicsServer2DManager::PhysicsServer2DManager() { + singleton = this; +} + +PhysicsServer2DManager::~PhysicsServer2DManager() { + singleton = nullptr; +} diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h index 071ff5ffe9..d5b4dc05e6 100644 --- a/servers/physics_server_2d.h +++ b/servers/physics_server_2d.h @@ -610,7 +610,7 @@ protected: static void _bind_methods(); public: - static Ref<PhysicsRayQueryParameters2D> create(Vector2 p_from, Vector2 p_to, uint32_t p_mask, const Vector<RID> &p_exclude); + static Ref<PhysicsRayQueryParameters2D> create(Vector2 p_from, Vector2 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude); const PhysicsDirectSpaceState2D::RayParameters &get_parameters() const { return parameters; } void set_from(const Vector2 &p_from) { parameters.from = p_from; } @@ -631,8 +631,8 @@ public: void set_hit_from_inside(bool p_enable) { parameters.hit_from_inside = p_enable; } bool is_hit_from_inside_enabled() const { return parameters.hit_from_inside; } - void set_exclude(const Vector<RID> &p_exclude); - Vector<RID> get_exclude() const; + void set_exclude(const TypedArray<RID> &p_exclude); + TypedArray<RID> get_exclude() const; }; class PhysicsPointQueryParameters2D : public RefCounted { @@ -661,8 +661,8 @@ public: void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; } bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; } - void set_exclude(const Vector<RID> &p_exclude); - Vector<RID> get_exclude() const; + void set_exclude(const TypedArray<RID> &p_exclude); + TypedArray<RID> get_exclude() const; }; class PhysicsShapeQueryParameters2D : public RefCounted { @@ -702,8 +702,8 @@ public: void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; } bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; } - void set_exclude(const Vector<RID> &p_exclude); - Vector<RID> get_exclude() const; + void set_exclude(const TypedArray<RID> &p_exclude); + TypedArray<RID> get_exclude() const; }; class PhysicsTestMotionParameters2D : public RefCounted { @@ -729,8 +729,8 @@ public: bool is_collide_separation_ray_enabled() const { return parameters.collide_separation_ray; } void set_collide_separation_ray_enabled(bool p_enabled) { parameters.collide_separation_ray = p_enabled; } - Vector<RID> get_exclude_bodies() const; - void set_exclude_bodies(const Vector<RID> &p_exclude); + TypedArray<RID> get_exclude_bodies() const; + void set_exclude_bodies(const TypedArray<RID> &p_exclude); Array get_exclude_objects() const; void set_exclude_objects(const Array &p_exclude); @@ -766,16 +766,18 @@ public: real_t get_collision_unsafe_fraction() const; }; -typedef PhysicsServer2D *(*CreatePhysicsServer2DCallback)(); +class PhysicsServer2DManager : public Object { + GDCLASS(PhysicsServer2DManager, Object); + + static PhysicsServer2DManager *singleton; -class PhysicsServer2DManager { struct ClassInfo { String name; - CreatePhysicsServer2DCallback create_callback = nullptr; + Callable create_callback; ClassInfo() {} - ClassInfo(String p_name, CreatePhysicsServer2DCallback p_create_callback) : + ClassInfo(String p_name, Callable p_create_callback) : name(p_name), create_callback(p_create_callback) {} @@ -789,24 +791,30 @@ class PhysicsServer2DManager { } }; - static Vector<ClassInfo> physics_2d_servers; - static int default_server_id; - static int default_server_priority; + Vector<ClassInfo> physics_2d_servers; + int default_server_id = -1; + int default_server_priority = -1; + + void on_servers_changed(); + +protected: + static void _bind_methods(); public: static const String setting_property_name; -private: - static void on_servers_changed(); + static PhysicsServer2DManager *get_singleton(); -public: - static void register_server(const String &p_name, CreatePhysicsServer2DCallback p_creat_callback); - static void set_default_server(const String &p_name, int p_priority = 0); - static int find_server_id(const String &p_name); - static int get_servers_count(); - static String get_server_name(int p_id); - static PhysicsServer2D *new_default_server(); - static PhysicsServer2D *new_server(const String &p_name); + void register_server(const String &p_name, const Callable &p_create_callback); + void set_default_server(const String &p_name, int p_priority = 0); + int find_server_id(const String &p_name); + int get_servers_count(); + String get_server_name(int p_id); + PhysicsServer2D *new_default_server(); + PhysicsServer2D *new_server(const String &p_name); + + PhysicsServer2DManager(); + ~PhysicsServer2DManager(); }; VARIANT_ENUM_CAST(PhysicsServer2D::ShapeType); @@ -820,6 +828,7 @@ VARIANT_ENUM_CAST(PhysicsServer2D::BodyState); VARIANT_ENUM_CAST(PhysicsServer2D::CCDMode); VARIANT_ENUM_CAST(PhysicsServer2D::JointParam); VARIANT_ENUM_CAST(PhysicsServer2D::JointType); +VARIANT_ENUM_CAST(PhysicsServer2D::PinJointParam); VARIANT_ENUM_CAST(PhysicsServer2D::DampedSpringParam); VARIANT_ENUM_CAST(PhysicsServer2D::AreaBodyStatus); VARIANT_ENUM_CAST(PhysicsServer2D::ProcessInfo); diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp index fc32e1f665..b4f30d7649 100644 --- a/servers/physics_server_3d.cpp +++ b/servers/physics_server_3d.cpp @@ -1046,9 +1046,7 @@ PhysicsServer3D::~PhysicsServer3D() { singleton = nullptr; } -Vector<PhysicsServer3DManager::ClassInfo> PhysicsServer3DManager::physics_servers; -int PhysicsServer3DManager::default_server_id = -1; -int PhysicsServer3DManager::default_server_priority = -1; +PhysicsServer3DManager *PhysicsServer3DManager::singleton = nullptr; const String PhysicsServer3DManager::setting_property_name(PNAME("physics/3d/physics_engine")); void PhysicsServer3DManager::on_servers_changed() { @@ -1059,10 +1057,19 @@ void PhysicsServer3DManager::on_servers_changed() { ProjectSettings::get_singleton()->set_custom_property_info(setting_property_name, PropertyInfo(Variant::STRING, setting_property_name, PROPERTY_HINT_ENUM, physics_servers2)); } -void PhysicsServer3DManager::register_server(const String &p_name, CreatePhysicsServer3DCallback p_creat_callback) { - ERR_FAIL_COND(!p_creat_callback); +void PhysicsServer3DManager::_bind_methods() { + ClassDB::bind_method(D_METHOD("register_server", "name", "create_callback"), &PhysicsServer3DManager::register_server); + ClassDB::bind_method(D_METHOD("set_default_server", "name", "priority"), &PhysicsServer3DManager::set_default_server); +} + +PhysicsServer3DManager *PhysicsServer3DManager::get_singleton() { + return singleton; +} + +void PhysicsServer3DManager::register_server(const String &p_name, const Callable &p_create_callback) { + //ERR_FAIL_COND(!p_create_callback.is_valid()); ERR_FAIL_COND(find_server_id(p_name) != -1); - physics_servers.push_back(ClassInfo(p_name, p_creat_callback)); + physics_servers.push_back(ClassInfo(p_name, p_create_callback)); on_servers_changed(); } @@ -1095,7 +1102,11 @@ String PhysicsServer3DManager::get_server_name(int p_id) { PhysicsServer3D *PhysicsServer3DManager::new_default_server() { ERR_FAIL_COND_V(default_server_id == -1, nullptr); - return physics_servers[default_server_id].create_callback(); + Variant ret; + Callable::CallError ce; + physics_servers[default_server_id].create_callback.callp(nullptr, 0, ret, ce); + ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, nullptr); + return Object::cast_to<PhysicsServer3D>(ret.get_validated_object()); } PhysicsServer3D *PhysicsServer3DManager::new_server(const String &p_name) { @@ -1103,6 +1114,18 @@ PhysicsServer3D *PhysicsServer3DManager::new_server(const String &p_name) { if (id == -1) { return nullptr; } else { - return physics_servers[id].create_callback(); + Variant ret; + Callable::CallError ce; + physics_servers[id].create_callback.callp(nullptr, 0, ret, ce); + ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, nullptr); + return Object::cast_to<PhysicsServer3D>(ret.get_validated_object()); } } + +PhysicsServer3DManager::PhysicsServer3DManager() { + singleton = this; +} + +PhysicsServer3DManager::~PhysicsServer3DManager() { + singleton = nullptr; +} diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h index 6237ed67aa..1308e4cd36 100644 --- a/servers/physics_server_3d.h +++ b/servers/physics_server_3d.h @@ -983,16 +983,18 @@ public: real_t get_collision_depth(int p_collision_index = 0) const; }; -typedef PhysicsServer3D *(*CreatePhysicsServer3DCallback)(); +class PhysicsServer3DManager : public Object { + GDCLASS(PhysicsServer3DManager, Object); + + static PhysicsServer3DManager *singleton; -class PhysicsServer3DManager { struct ClassInfo { String name; - CreatePhysicsServer3DCallback create_callback = nullptr; + Callable create_callback; ClassInfo() {} - ClassInfo(String p_name, CreatePhysicsServer3DCallback p_create_callback) : + ClassInfo(String p_name, Callable p_create_callback) : name(p_name), create_callback(p_create_callback) {} @@ -1006,24 +1008,30 @@ class PhysicsServer3DManager { } }; - static Vector<ClassInfo> physics_servers; - static int default_server_id; - static int default_server_priority; + Vector<ClassInfo> physics_servers; + int default_server_id = -1; + int default_server_priority = -1; + + void on_servers_changed(); + +protected: + static void _bind_methods(); public: static const String setting_property_name; -private: - static void on_servers_changed(); + static PhysicsServer3DManager *get_singleton(); -public: - static void register_server(const String &p_name, CreatePhysicsServer3DCallback p_creat_callback); - static void set_default_server(const String &p_name, int p_priority = 0); - static int find_server_id(const String &p_name); - static int get_servers_count(); - static String get_server_name(int p_id); - static PhysicsServer3D *new_default_server(); - static PhysicsServer3D *new_server(const String &p_name); + void register_server(const String &p_name, const Callable &p_create_callback); + void set_default_server(const String &p_name, int p_priority = 0); + int find_server_id(const String &p_name); + int get_servers_count(); + String get_server_name(int p_id); + PhysicsServer3D *new_default_server(); + PhysicsServer3D *new_server(const String &p_name); + + PhysicsServer3DManager(); + ~PhysicsServer3DManager(); }; VARIANT_ENUM_CAST(PhysicsServer3D::ShapeType); diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index db473f6296..b9667f338c 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -72,6 +72,7 @@ #include "rendering/rendering_device.h" #include "rendering/rendering_device_binds.h" #include "rendering_server.h" +#include "servers/extensions/physics_server_2d_extension.h" #include "servers/extensions/physics_server_3d_extension.h" #include "servers/rendering/shader_types.h" #include "text/text_server_dummy.h" @@ -84,7 +85,7 @@ ShaderTypes *shader_types = nullptr; -PhysicsServer3D *_createGodotPhysics3DCallback() { +static PhysicsServer3D *_createGodotPhysics3DCallback() { bool using_threads = GLOBAL_GET("physics/3d/run_on_separate_thread"); PhysicsServer3D *physics_server_3d = memnew(GodotPhysicsServer3D(using_threads)); @@ -92,7 +93,7 @@ PhysicsServer3D *_createGodotPhysics3DCallback() { return memnew(PhysicsServer3DWrapMT(physics_server_3d, using_threads)); } -PhysicsServer2D *_createGodotPhysics2DCallback() { +static PhysicsServer2D *_createGodotPhysics2DCallback() { bool using_threads = GLOBAL_GET("physics/2d/run_on_separate_thread"); PhysicsServer2D *physics_server_2d = memnew(GodotPhysicsServer2D(using_threads)); @@ -132,7 +133,23 @@ void register_server_types() { GDREGISTER_ABSTRACT_CLASS(RenderingServer); GDREGISTER_CLASS(AudioServer); + GDREGISTER_CLASS(PhysicsServer2DManager); + Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2DManager", PhysicsServer2DManager::get_singleton(), "PhysicsServer2DManager")); + GDREGISTER_ABSTRACT_CLASS(PhysicsServer2D); + GDREGISTER_VIRTUAL_CLASS(PhysicsServer2DExtension); + GDREGISTER_VIRTUAL_CLASS(PhysicsDirectBodyState2DExtension); + GDREGISTER_VIRTUAL_CLASS(PhysicsDirectSpaceState2DExtension); + + GDREGISTER_NATIVE_STRUCT(PhysicsServer2DExtensionRayResult, "Vector2 position;Vector2 normal;RID rid;ObjectID collider_id;Object *collider;int shape"); + GDREGISTER_NATIVE_STRUCT(PhysicsServer2DExtensionShapeResult, "RID rid;ObjectID collider_id;Object *collider;int shape"); + GDREGISTER_NATIVE_STRUCT(PhysicsServer2DExtensionShapeRestInfo, "Vector2 point;Vector2 normal;RID rid;ObjectID collider_id;int shape;Vector2 linear_velocity"); + GDREGISTER_NATIVE_STRUCT(PhysicsServer2DExtensionMotionResult, "Vector2 travel;Vector2 remainder;Vector2 collision_point;Vector2 collision_normal;Vector2 collider_velocity;real_t collision_depth;real_t collision_safe_fraction;real_t collision_unsafe_fraction;int collision_local_shape;ObjectID collider_id;RID collider;int collider_shape"); + GDREGISTER_NATIVE_STRUCT(PhysicsServer2DExtensionStateCallback, "void *instance;void (*callback)(void *p_instance, PhysicsDirectBodyState2D *p_state)"); + + GDREGISTER_CLASS(PhysicsServer3DManager); + Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3DManager", PhysicsServer3DManager::get_singleton(), "PhysicsServer3DManager")); + GDREGISTER_ABSTRACT_CLASS(PhysicsServer3D); GDREGISTER_VIRTUAL_CLASS(PhysicsServer3DExtension); GDREGISTER_VIRTUAL_CLASS(PhysicsDirectBodyState3DExtension); @@ -253,15 +270,15 @@ void register_server_types() { GLOBAL_DEF(PhysicsServer2DManager::setting_property_name, "DEFAULT"); ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServer2DManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServer2DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT")); - PhysicsServer2DManager::register_server("GodotPhysics2D", &_createGodotPhysics2DCallback); - PhysicsServer2DManager::set_default_server("GodotPhysics2D"); + PhysicsServer2DManager::get_singleton()->register_server("GodotPhysics2D", callable_mp_static(_createGodotPhysics2DCallback)); + PhysicsServer2DManager::get_singleton()->set_default_server("GodotPhysics2D"); // Physics 3D GLOBAL_DEF(PhysicsServer3DManager::setting_property_name, "DEFAULT"); ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServer3DManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServer3DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT")); - PhysicsServer3DManager::register_server("GodotPhysics3D", &_createGodotPhysics3DCallback); - PhysicsServer3DManager::set_default_server("GodotPhysics3D"); + PhysicsServer3DManager::get_singleton()->register_server("GodotPhysics3D", callable_mp_static(_createGodotPhysics3DCallback)); + PhysicsServer3DManager::get_singleton()->set_default_server("GodotPhysics3D"); writer_mjpeg = memnew(MovieWriterMJPEG); MovieWriter::add_writer(writer_mjpeg); diff --git a/servers/rendering/dummy/rasterizer_scene_dummy.h b/servers/rendering/dummy/rasterizer_scene_dummy.h index 7dac1f5966..4a2a947b94 100644 --- a/servers/rendering/dummy/rasterizer_scene_dummy.h +++ b/servers/rendering/dummy/rasterizer_scene_dummy.h @@ -197,7 +197,7 @@ public: void sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) override {} void sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) override {} - TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) override { return TypedArray<Image>(); } + TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) override { return TypedArray<Image>(); } bool free(RID p_rid) override { if (is_environment(p_rid)) { diff --git a/servers/rendering/dummy/storage/material_storage.h b/servers/rendering/dummy/storage/material_storage.h index e25a2ac3a9..ed8fefc558 100644 --- a/servers/rendering/dummy/storage/material_storage.h +++ b/servers/rendering/dummy/storage/material_storage.h @@ -40,21 +40,21 @@ class MaterialStorage : public RendererMaterialStorage { public: /* GLOBAL SHADER UNIFORM API */ - virtual void global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) override {} - virtual void global_shader_uniform_remove(const StringName &p_name) override {} - virtual Vector<StringName> global_shader_uniform_get_list() const override { return Vector<StringName>(); } + virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) override {} + virtual void global_shader_parameter_remove(const StringName &p_name) override {} + virtual Vector<StringName> global_shader_parameter_get_list() const override { return Vector<StringName>(); } - virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) override {} - virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) override {} - virtual Variant global_shader_uniform_get(const StringName &p_name) const override { return Variant(); } - virtual RS::GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const override { return RS::GLOBAL_VAR_TYPE_MAX; } + virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) override {} + virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) override {} + virtual Variant global_shader_parameter_get(const StringName &p_name) const override { return Variant(); } + virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const override { return RS::GLOBAL_VAR_TYPE_MAX; } - virtual void global_shader_uniforms_load_settings(bool p_load_textures = true) override {} - virtual void global_shader_uniforms_clear() override {} + virtual void global_shader_parameters_load_settings(bool p_load_textures = true) override {} + virtual void global_shader_parameters_clear() override {} - virtual int32_t global_shader_uniforms_instance_allocate(RID p_instance) override { return 0; } - virtual void global_shader_uniforms_instance_free(RID p_instance) override {} - virtual void global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) override {} + virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) override { return 0; } + virtual void global_shader_parameters_instance_free(RID p_instance) override {} + virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) override {} /* SHADER API */ @@ -66,11 +66,11 @@ public: virtual void shader_set_path_hint(RID p_shader, const String &p_code) override {} virtual String shader_get_code(RID p_shader) const override { return ""; } - virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const override {} + virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const override {} - virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override {} - virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const override { return RID(); } - virtual Variant shader_get_param_default(RID p_material, const StringName &p_param) const override { return Variant(); } + virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override {} + virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const override { return RID(); } + virtual Variant shader_get_parameter_default(RID p_material, const StringName &p_param) const override { return Variant(); } virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override { return RS::ShaderNativeSourceCode(); }; @@ -89,7 +89,7 @@ public: virtual bool material_is_animated(RID p_material) override { return false; } virtual bool material_casts_shadows(RID p_material) override { return false; } - virtual void material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) override {} + virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) override {} virtual void material_update_dependency(RID p_material, DependencyTracker *p_instance) override {} }; diff --git a/servers/rendering/dummy/storage/mesh_storage.h b/servers/rendering/dummy/storage/mesh_storage.h index 1eb4fd854f..b0914e70e4 100644 --- a/servers/rendering/dummy/storage/mesh_storage.h +++ b/servers/rendering/dummy/storage/mesh_storage.h @@ -81,6 +81,7 @@ public: s->vertex_count = p_surface.vertex_count; s->index_data = p_surface.index_data; s->index_count = p_surface.index_count; + s->skin_data = p_surface.skin_data; } virtual int mesh_get_blend_shape_count(RID p_mesh) const override { return 0; } @@ -98,6 +99,7 @@ public: virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override { DummyMesh *m = mesh_owner.get_or_null(p_mesh); ERR_FAIL_COND_V(!m, RS::SurfaceData()); + ERR_FAIL_INDEX_V(p_surface, m->surfaces.size(), RS::SurfaceData()); RS::SurfaceData s = m->surfaces[p_surface]; return s; } diff --git a/servers/rendering/renderer_rd/environment/fog.cpp b/servers/rendering/renderer_rd/environment/fog.cpp index 91ffa053c9..a41552cd5c 100644 --- a/servers/rendering/renderer_rd/environment/fog.cpp +++ b/servers/rendering/renderer_rd/environment/fog.cpp @@ -361,7 +361,7 @@ void Fog::FogShaderData::set_code(const String &p_code) { valid = true; } -void Fog::FogShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) { +void Fog::FogShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) { if (!p_texture.is_valid()) { if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) { default_texture_params[p_name].erase(p_index); @@ -430,7 +430,7 @@ void Fog::FogShaderData::get_instance_param_list(List<RendererMaterialStorage::I } } -bool Fog::FogShaderData::is_param_texture(const StringName &p_param) const { +bool Fog::FogShaderData::is_parameter_texture(const StringName &p_param) const { if (!uniforms.has(p_param)) { return false; } diff --git a/servers/rendering/renderer_rd/environment/fog.h b/servers/rendering/renderer_rd/environment/fog.h index 30c8a3f382..9ecd5699dc 100644 --- a/servers/rendering/renderer_rd/environment/fog.h +++ b/servers/rendering/renderer_rd/environment/fog.h @@ -202,10 +202,10 @@ private: virtual void set_path_hint(const String &p_hint); virtual void set_code(const String &p_Code); - virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index); + virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index); virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const; virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const; - virtual bool is_param_texture(const StringName &p_param) const; + virtual bool is_parameter_texture(const StringName &p_param) const; virtual bool is_animated() const; virtual bool casts_shadows() const; virtual Variant get_default_parameter(const StringName &p_parameter) const; diff --git a/servers/rendering/renderer_rd/environment/sky.cpp b/servers/rendering/renderer_rd/environment/sky.cpp index 1f7a5c8da3..65d1d9e705 100644 --- a/servers/rendering/renderer_rd/environment/sky.cpp +++ b/servers/rendering/renderer_rd/environment/sky.cpp @@ -152,7 +152,7 @@ void SkyRD::SkyShaderData::set_code(const String &p_code) { valid = true; } -void SkyRD::SkyShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) { +void SkyRD::SkyShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) { if (!p_texture.is_valid()) { if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) { default_texture_params[p_name].erase(p_index); @@ -220,7 +220,7 @@ void SkyRD::SkyShaderData::get_instance_param_list(List<RendererMaterialStorage: } } -bool SkyRD::SkyShaderData::is_param_texture(const StringName &p_param) const { +bool SkyRD::SkyShaderData::is_parameter_texture(const StringName &p_param) const { if (!uniforms.has(p_param)) { return false; } diff --git a/servers/rendering/renderer_rd/environment/sky.h b/servers/rendering/renderer_rd/environment/sky.h index fbd43889a0..45c4f9bda7 100644 --- a/servers/rendering/renderer_rd/environment/sky.h +++ b/servers/rendering/renderer_rd/environment/sky.h @@ -130,10 +130,10 @@ private: virtual void set_code(const String &p_Code); virtual void set_path_hint(const String &p_hint); - virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index); + virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index); virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const; virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const; - virtual bool is_param_texture(const StringName &p_param) const; + virtual bool is_parameter_texture(const StringName &p_param) const; virtual bool is_animated() const; virtual bool casts_shadows() const; virtual Variant get_default_parameter(const StringName &p_parameter) const; diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index 0911ee595f..75ccf1add5 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -375,7 +375,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) { valid = true; } -void SceneShaderForwardClustered::ShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) { +void SceneShaderForwardClustered::ShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) { if (!p_texture.is_valid()) { if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) { default_texture_params[p_name].erase(p_index); @@ -448,7 +448,7 @@ void SceneShaderForwardClustered::ShaderData::get_instance_param_list(List<Rende } } -bool SceneShaderForwardClustered::ShaderData::is_param_texture(const StringName &p_param) const { +bool SceneShaderForwardClustered::ShaderData::is_parameter_texture(const StringName &p_param) const { if (!uniforms.has(p_param)) { return false; } diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h index d6b526fa4a..c2f56eb164 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h @@ -182,11 +182,11 @@ public: virtual void set_code(const String &p_Code); virtual void set_path_hint(const String &p_path); - virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index); + virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index); virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const; void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const; - virtual bool is_param_texture(const StringName &p_param) const; + virtual bool is_parameter_texture(const StringName &p_param) const; virtual bool is_animated() const; virtual bool casts_shadows() const; virtual Variant get_default_parameter(const StringName &p_parameter) const; diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index 85c9e1db2a..383ed9247d 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -331,7 +331,7 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) { valid = true; } -void SceneShaderForwardMobile::ShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) { +void SceneShaderForwardMobile::ShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) { if (!p_texture.is_valid()) { if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) { default_texture_params[p_name].erase(p_index); @@ -403,7 +403,7 @@ void SceneShaderForwardMobile::ShaderData::get_instance_param_list(List<Renderer } } -bool SceneShaderForwardMobile::ShaderData::is_param_texture(const StringName &p_param) const { +bool SceneShaderForwardMobile::ShaderData::is_parameter_texture(const StringName &p_param) const { if (!uniforms.has(p_param)) { return false; } diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h index e208334547..21270d7c62 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h @@ -141,11 +141,11 @@ public: virtual void set_code(const String &p_Code); virtual void set_path_hint(const String &p_path); - virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index); + virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index); virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const; void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const; - virtual bool is_param_texture(const StringName &p_param) const; + virtual bool is_parameter_texture(const StringName &p_param) const; virtual bool is_animated() const; virtual bool casts_shadows() const; virtual Variant get_default_parameter(const StringName &p_parameter) const; diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 7102f1f0ff..ab3e3ebe51 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -2192,7 +2192,7 @@ void RendererCanvasRenderRD::CanvasShaderData::set_code(const String &p_code) { valid = true; } -void RendererCanvasRenderRD::CanvasShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) { +void RendererCanvasRenderRD::CanvasShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) { if (!p_texture.is_valid()) { if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) { default_texture_params[p_name].erase(p_index); @@ -2264,7 +2264,7 @@ void RendererCanvasRenderRD::CanvasShaderData::get_instance_param_list(List<Rend } } -bool RendererCanvasRenderRD::CanvasShaderData::is_param_texture(const StringName &p_param) const { +bool RendererCanvasRenderRD::CanvasShaderData::is_parameter_texture(const StringName &p_param) const { if (!uniforms.has(p_param)) { return false; } diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.h b/servers/rendering/renderer_rd/renderer_canvas_render_rd.h index 54077a5b9a..67db56d913 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.h @@ -182,11 +182,11 @@ class RendererCanvasRenderRD : public RendererCanvasRender { virtual void set_code(const String &p_Code); virtual void set_path_hint(const String &p_path); - virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index); + virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index); virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const; virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const; - virtual bool is_param_texture(const StringName &p_param) const; + virtual bool is_parameter_texture(const StringName &p_param) const; virtual bool is_animated() const; virtual bool casts_shadows() const; virtual Variant get_default_parameter(const StringName &p_parameter) const; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index cb7c643dfb..78c83d1fb4 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -3570,7 +3570,7 @@ float RendererSceneRenderRD::screen_space_roughness_limiter_get_limit() const { return screen_space_roughness_limiter_limit; } -TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) { +TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) { RD::TextureFormat tf; tf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; tf.width = p_image_size.width; // Always 64x64 diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index 396faf8108..76d2bc68fe 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -1046,7 +1046,7 @@ public: int get_roughness_layers() const; bool is_using_radiance_cubemap_array() const; - virtual TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) override; + virtual TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) override; virtual bool free(RID p_rid) override; diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp index fa8406e7a1..b36a028f04 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp @@ -954,7 +954,7 @@ void MaterialStorage::MaterialData::update_uniform_buffer(const HashMap<StringNa if (gv) { index = gv->buffer_index; } else { - WARN_PRINT("Shader uses global uniform '" + E.key + "', but it was removed at some point. Material will not display correctly."); + WARN_PRINT("Shader uses global parameter '" + E.key + "', but it was removed at some point. Material will not display correctly."); } uint32_t offset = p_uniform_offsets[E.value.order]; @@ -1070,7 +1070,7 @@ void MaterialStorage::MaterialData::update_textures(const HashMap<StringName, Va GlobalShaderUniforms::Variable *v = material_storage->global_shader_uniforms.variables.getptr(uniform_name); if (v) { if (v->buffer_index >= 0) { - WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it changed type and is no longer a texture!."); + WARN_PRINT("Shader uses global parameter texture '" + String(uniform_name) + "', but it changed type and is no longer a texture!."); } else { HashMap<StringName, uint64_t>::Iterator E = used_global_textures.find(uniform_name); @@ -1085,7 +1085,7 @@ void MaterialStorage::MaterialData::update_textures(const HashMap<StringName, Va } } else { - WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it was removed at some point. Material will not display correctly."); + WARN_PRINT("Shader uses global parameter texture '" + String(uniform_name) + "', but it was removed at some point. Material will not display correctly."); } } else { HashMap<StringName, Variant>::ConstIterator V = p_parameters.find(uniform_name); @@ -1652,7 +1652,7 @@ int32_t MaterialStorage::_global_shader_uniform_allocate(uint32_t p_elements) { return -1; } -void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderUniformType p_type, const Variant &p_value) { +void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderParameterType p_type, const Variant &p_value) { switch (p_type) { case RS::GLOBAL_VAR_TYPE_BOOL: { GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index]; @@ -1945,7 +1945,7 @@ void MaterialStorage::_global_shader_uniform_mark_buffer_dirty(int32_t p_index, } } -void MaterialStorage::global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) { +void MaterialStorage::global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) { ERR_FAIL_COND(global_shader_uniforms.variables.has(p_name)); GlobalShaderUniforms::Variable gv; gv.type = p_type; @@ -1983,7 +1983,7 @@ void MaterialStorage::global_shader_uniform_add(const StringName &p_name, RS::Gl global_shader_uniforms.variables[p_name] = gv; } -void MaterialStorage::global_shader_uniform_remove(const StringName &p_name) { +void MaterialStorage::global_shader_parameter_remove(const StringName &p_name) { if (!global_shader_uniforms.variables.has(p_name)) { return; } @@ -1999,7 +1999,7 @@ void MaterialStorage::global_shader_uniform_remove(const StringName &p_name) { global_shader_uniforms.variables.erase(p_name); } -Vector<StringName> MaterialStorage::global_shader_uniform_get_list() const { +Vector<StringName> MaterialStorage::global_shader_parameter_get_list() const { if (!Engine::get_singleton()->is_editor_hint()) { ERR_FAIL_V_MSG(Vector<StringName>(), "This function should never be used outside the editor, it can severely damage performance."); } @@ -2012,7 +2012,7 @@ Vector<StringName> MaterialStorage::global_shader_uniform_get_list() const { return names; } -void MaterialStorage::global_shader_uniform_set(const StringName &p_name, const Variant &p_value) { +void MaterialStorage::global_shader_parameter_set(const StringName &p_name, const Variant &p_value) { ERR_FAIL_COND(!global_shader_uniforms.variables.has(p_name)); GlobalShaderUniforms::Variable &gv = global_shader_uniforms.variables[p_name]; gv.value = p_value; @@ -2033,7 +2033,7 @@ void MaterialStorage::global_shader_uniform_set(const StringName &p_name, const } } -void MaterialStorage::global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) { +void MaterialStorage::global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) { if (!global_shader_uniforms.variables.has(p_name)) { return; //variable may not exist } @@ -2064,7 +2064,7 @@ void MaterialStorage::global_shader_uniform_set_override(const StringName &p_nam } } -Variant MaterialStorage::global_shader_uniform_get(const StringName &p_name) const { +Variant MaterialStorage::global_shader_parameter_get(const StringName &p_name) const { if (!Engine::get_singleton()->is_editor_hint()) { ERR_FAIL_V_MSG(Variant(), "This function should never be used outside the editor, it can severely damage performance."); } @@ -2076,7 +2076,7 @@ Variant MaterialStorage::global_shader_uniform_get(const StringName &p_name) con return global_shader_uniforms.variables[p_name].value; } -RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type_internal(const StringName &p_name) const { +RS::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type_internal(const StringName &p_name) const { if (!global_shader_uniforms.variables.has(p_name)) { return RS::GLOBAL_VAR_TYPE_MAX; } @@ -2084,15 +2084,15 @@ RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type_inte return global_shader_uniforms.variables[p_name].type; } -RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type(const StringName &p_name) const { +RS::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type(const StringName &p_name) const { if (!Engine::get_singleton()->is_editor_hint()) { ERR_FAIL_V_MSG(RS::GLOBAL_VAR_TYPE_MAX, "This function should never be used outside the editor, it can severely damage performance."); } - return global_shader_uniform_get_type_internal(p_name); + return global_shader_parameter_get_type_internal(p_name); } -void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures) { +void MaterialStorage::global_shader_parameters_load_settings(bool p_load_textures) { List<PropertyInfo> settings; ProjectSettings::get_singleton()->get_property_list(&settings); @@ -2137,11 +2137,11 @@ void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures) "samplerCube", }; - RS::GlobalShaderUniformType gvtype = RS::GLOBAL_VAR_TYPE_MAX; + RS::GlobalShaderParameterType gvtype = RS::GLOBAL_VAR_TYPE_MAX; for (int i = 0; i < RS::GLOBAL_VAR_TYPE_MAX; i++) { if (global_var_type_names[i] == type) { - gvtype = RS::GlobalShaderUniformType(i); + gvtype = RS::GlobalShaderParameterType(i); break; } } @@ -2165,15 +2165,15 @@ void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures) if (global_shader_uniforms.variables.has(name)) { //has it, update it - global_shader_uniform_set(name, value); + global_shader_parameter_set(name, value); } else { - global_shader_uniform_add(name, gvtype, value); + global_shader_parameter_add(name, gvtype, value); } } } } -void MaterialStorage::global_shader_uniforms_clear() { +void MaterialStorage::global_shader_parameters_clear() { global_shader_uniforms.variables.clear(); //not right but for now enough } @@ -2181,7 +2181,7 @@ RID MaterialStorage::global_shader_uniforms_get_storage_buffer() const { return global_shader_uniforms.buffer; } -int32_t MaterialStorage::global_shader_uniforms_instance_allocate(RID p_instance) { +int32_t MaterialStorage::global_shader_parameters_instance_allocate(RID p_instance) { ERR_FAIL_COND_V(global_shader_uniforms.instance_buffer_pos.has(p_instance), -1); int32_t pos = _global_shader_uniform_allocate(ShaderLanguage::MAX_INSTANCE_UNIFORM_INDICES); global_shader_uniforms.instance_buffer_pos[p_instance] = pos; //save anyway @@ -2190,7 +2190,7 @@ int32_t MaterialStorage::global_shader_uniforms_instance_allocate(RID p_instance return pos; } -void MaterialStorage::global_shader_uniforms_instance_free(RID p_instance) { +void MaterialStorage::global_shader_parameters_instance_free(RID p_instance) { ERR_FAIL_COND(!global_shader_uniforms.instance_buffer_pos.has(p_instance)); int32_t pos = global_shader_uniforms.instance_buffer_pos[p_instance]; if (pos >= 0) { @@ -2199,7 +2199,7 @@ void MaterialStorage::global_shader_uniforms_instance_free(RID p_instance) { global_shader_uniforms.instance_buffer_pos.erase(p_instance); } -void MaterialStorage::global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) { +void MaterialStorage::global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) { if (!global_shader_uniforms.instance_buffer_pos.has(p_instance)) { return; //just not allocated, ignore } @@ -2384,7 +2384,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { if (shader->data) { for (const KeyValue<StringName, HashMap<int, RID>> &E : shader->default_texture_parameter) { for (const KeyValue<int, RID> &E2 : E.value) { - shader->data->set_default_texture_param(E.key, E2.value, E2.key); + shader->data->set_default_texture_parameter(E.key, E2.value, E2.key); } } } @@ -2418,7 +2418,7 @@ String MaterialStorage::shader_get_code(RID p_shader) const { return shader->code; } -void MaterialStorage::shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const { +void MaterialStorage::get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND(!shader); if (shader->data) { @@ -2426,7 +2426,7 @@ void MaterialStorage::shader_get_shader_uniform_list(RID p_shader, List<Property } } -void MaterialStorage::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) { +void MaterialStorage::shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND(!shader); @@ -2445,7 +2445,7 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin } } if (shader->data) { - shader->data->set_default_texture_param(p_name, p_texture, p_index); + shader->data->set_default_texture_parameter(p_name, p_texture, p_index); } for (Material *E : shader->owners) { Material *material = E; @@ -2453,7 +2453,7 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin } } -RID MaterialStorage::shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const { +RID MaterialStorage::shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND_V(!shader, RID()); if (shader->default_texture_parameter.has(p_name) && shader->default_texture_parameter[p_name].has(p_index)) { @@ -2463,7 +2463,7 @@ RID MaterialStorage::shader_get_default_texture_param(RID p_shader, const String return RID(); } -Variant MaterialStorage::shader_get_param_default(RID p_shader, const StringName &p_param) const { +Variant MaterialStorage::shader_get_parameter_default(RID p_shader, const StringName &p_param) const { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND_V(!shader, Variant()); if (shader->data) { @@ -2616,7 +2616,7 @@ void MaterialStorage::material_set_param(RID p_material, const StringName &p_par } if (material->shader && material->shader->data) { //shader is valid - bool is_texture = material->shader->data->is_param_texture(p_param); + bool is_texture = material->shader->data->is_parameter_texture(p_param); _material_queue_update(material, !is_texture, is_texture); } else { _material_queue_update(material, true, true); @@ -2684,14 +2684,14 @@ bool MaterialStorage::material_casts_shadows(RID p_material) { return true; //by default everything casts shadows } -void MaterialStorage::material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) { +void MaterialStorage::material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); if (material->shader && material->shader->data) { material->shader->data->get_instance_param_list(r_parameters); if (material->next_pass.is_valid()) { - material_get_instance_shader_uniforms(material->next_pass, r_parameters); + material_get_instance_shader_parameters(material->next_pass, r_parameters); } } } diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.h b/servers/rendering/renderer_rd/storage_rd/material_storage.h index dbf7a92e23..db2e4cfa2a 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.h @@ -56,11 +56,11 @@ public: struct ShaderData { virtual void set_code(const String &p_Code) = 0; virtual void set_path_hint(const String &p_hint) = 0; - virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) = 0; + virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) = 0; virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const = 0; virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const = 0; - virtual bool is_param_texture(const StringName &p_param) const = 0; + virtual bool is_parameter_texture(const StringName &p_param) const = 0; virtual bool is_animated() const = 0; virtual bool casts_shadows() const = 0; virtual Variant get_default_parameter(const StringName &p_parameter) const = 0; @@ -119,7 +119,7 @@ private: struct Variable { HashSet<RID> texture_materials; // materials using this - RS::GlobalShaderUniformType type; + RS::GlobalShaderParameterType type; Variant value; Variant override; int32_t buffer_index; //for vectors @@ -171,7 +171,7 @@ private: } global_shader_uniforms; int32_t _global_shader_uniform_allocate(uint32_t p_elements); - void _global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderUniformType p_type, const Variant &p_value); + void _global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderParameterType p_type, const Variant &p_value); void _global_shader_uniform_mark_buffer_dirty(int32_t p_index, int32_t p_elements); /* SHADER API */ @@ -332,22 +332,22 @@ public: void _update_global_shader_uniforms(); - virtual void global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) override; - virtual void global_shader_uniform_remove(const StringName &p_name) override; - virtual Vector<StringName> global_shader_uniform_get_list() const override; + virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) override; + virtual void global_shader_parameter_remove(const StringName &p_name) override; + virtual Vector<StringName> global_shader_parameter_get_list() const override; - virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) override; - virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) override; - virtual Variant global_shader_uniform_get(const StringName &p_name) const override; - virtual RS::GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const override; - RS::GlobalShaderUniformType global_shader_uniform_get_type_internal(const StringName &p_name) const; + virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) override; + virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) override; + virtual Variant global_shader_parameter_get(const StringName &p_name) const override; + virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const override; + RS::GlobalShaderParameterType global_shader_parameter_get_type_internal(const StringName &p_name) const; - virtual void global_shader_uniforms_load_settings(bool p_load_textures = true) override; - virtual void global_shader_uniforms_clear() override; + virtual void global_shader_parameters_load_settings(bool p_load_textures = true) override; + virtual void global_shader_parameters_clear() override; - virtual int32_t global_shader_uniforms_instance_allocate(RID p_instance) override; - virtual void global_shader_uniforms_instance_free(RID p_instance) override; - virtual void global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) override; + virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) override; + virtual void global_shader_parameters_instance_free(RID p_instance) override; + virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) override; RID global_shader_uniforms_get_storage_buffer() const; @@ -362,11 +362,11 @@ public: virtual void shader_set_code(RID p_shader, const String &p_code) override; virtual void shader_set_path_hint(RID p_shader, const String &p_path) override; virtual String shader_get_code(RID p_shader) const override; - virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const override; + virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const override; - virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override; - virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const override; - virtual Variant shader_get_param_default(RID p_shader, const StringName &p_param) const override; + virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override; + virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const override; + virtual Variant shader_get_parameter_default(RID p_shader, const StringName &p_param) const override; void shader_set_data_request_function(ShaderType p_shader_type, ShaderDataRequestFunction p_function); virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override; @@ -394,7 +394,7 @@ public: virtual bool material_is_animated(RID p_material) override; virtual bool material_casts_shadows(RID p_material) override; - virtual void material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) override; + virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) override; virtual void material_update_dependency(RID p_material, DependencyTracker *p_instance) override; diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 49d7198ec2..49e3543ba5 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -425,7 +425,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) } for (int i = 0; i < p_surface.bone_aabbs.size(); i++) { const AABB &bone = p_surface.bone_aabbs[i]; - if (!bone.has_no_volume()) { + if (bone.has_volume()) { mesh->bone_aabbs.write[i].merge_with(bone); } } diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 022b027644..424d2d3c7a 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -1586,7 +1586,7 @@ void ParticlesStorage::ParticlesShaderData::set_code(const String &p_code) { valid = true; } -void ParticlesStorage::ParticlesShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) { +void ParticlesStorage::ParticlesShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) { if (!p_texture.is_valid()) { if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) { default_texture_params[p_name].erase(p_index); @@ -1655,7 +1655,7 @@ void ParticlesStorage::ParticlesShaderData::get_instance_param_list(List<Rendere } } -bool ParticlesStorage::ParticlesShaderData::is_param_texture(const StringName &p_param) const { +bool ParticlesStorage::ParticlesShaderData::is_parameter_texture(const StringName &p_param) const { if (!uniforms.has(p_param)) { return false; } diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.h b/servers/rendering/renderer_rd/storage_rd/particles_storage.h index 299fdc6ec8..af29f5022b 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.h @@ -336,10 +336,10 @@ private: virtual void set_code(const String &p_Code); virtual void set_path_hint(const String &p_hint); - virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index); + virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index); virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const; virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const; - virtual bool is_param_texture(const StringName &p_param) const; + virtual bool is_parameter_texture(const StringName &p_param) const; virtual bool is_animated() const; virtual bool casts_shadows() const; virtual Variant get_default_parameter(const StringName &p_parameter) const; diff --git a/servers/rendering/renderer_scene.h b/servers/rendering/renderer_scene.h index b6404f946e..29c65fcffb 100644 --- a/servers/rendering/renderer_scene.h +++ b/servers/rendering/renderer_scene.h @@ -101,10 +101,10 @@ public: virtual void instance_geometry_set_visibility_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin, RS::VisibilityRangeFadeMode p_fade_mode) = 0; virtual void instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index) = 0; virtual void instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias) = 0; - virtual void instance_geometry_set_shader_uniform(RID p_instance, const StringName &p_parameter, const Variant &p_value) = 0; - virtual void instance_geometry_get_shader_uniform_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0; - virtual Variant instance_geometry_get_shader_uniform(RID p_instance, const StringName &p_parameter) const = 0; - virtual Variant instance_geometry_get_shader_uniform_default_value(RID p_instance, const StringName &p_parameter) const = 0; + virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) = 0; + virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0; + virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const = 0; + virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const = 0; virtual void directional_shadow_atlas_set_size(int p_size, bool p_16_bits = true) = 0; @@ -296,7 +296,7 @@ public: virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) = 0; - virtual TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) = 0; + virtual TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) = 0; virtual void voxel_gi_set_quality(RS::VoxelGIQuality) = 0; virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) = 0; diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index c7df8ebadb..04dedc0646 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -1436,7 +1436,7 @@ void RendererSceneCull::instance_geometry_set_lod_bias(RID p_instance, float p_l } } -void RendererSceneCull::instance_geometry_set_shader_uniform(RID p_instance, const StringName &p_parameter, const Variant &p_value) { +void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) { Instance *instance = instance_owner.get_or_null(p_instance); ERR_FAIL_COND(!instance); @@ -1454,12 +1454,12 @@ void RendererSceneCull::instance_geometry_set_shader_uniform(RID p_instance, con E->value.value = p_value; if (E->value.index >= 0 && instance->instance_allocated_shader_uniforms) { //update directly - RSG::material_storage->global_shader_uniforms_instance_update(p_instance, E->value.index, p_value); + RSG::material_storage->global_shader_parameters_instance_update(p_instance, E->value.index, p_value); } } } -Variant RendererSceneCull::instance_geometry_get_shader_uniform(RID p_instance, const StringName &p_parameter) const { +Variant RendererSceneCull::instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const { const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance); ERR_FAIL_COND_V(!instance, Variant()); @@ -1469,7 +1469,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_uniform(RID p_instance, return Variant(); } -Variant RendererSceneCull::instance_geometry_get_shader_uniform_default_value(RID p_instance, const StringName &p_parameter) const { +Variant RendererSceneCull::instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const { const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance); ERR_FAIL_COND_V(!instance, Variant()); @@ -1479,7 +1479,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_uniform_default_value(RI return Variant(); } -void RendererSceneCull::instance_geometry_get_shader_uniform_list(RID p_instance, List<PropertyInfo> *p_parameters) const { +void RendererSceneCull::instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const { const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance); ERR_FAIL_COND(!instance); @@ -1563,7 +1563,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) { } } - if (p_instance->aabb.has_no_surface()) { + if (!p_instance->aabb.has_surface()) { return; } @@ -3676,7 +3676,7 @@ void RendererSceneCull::render_particle_colliders() { void RendererSceneCull::_update_instance_shader_uniforms_from_material(HashMap<StringName, Instance::InstanceShaderParameter> &isparams, const HashMap<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material) { List<RendererMaterialStorage::InstanceShaderParam> plist; - RSG::material_storage->material_get_instance_shader_uniforms(p_material, &plist); + RSG::material_storage->material_get_instance_shader_parameters(p_material, &plist); for (const RendererMaterialStorage::InstanceShaderParam &E : plist) { StringName name = E.info.name; if (isparams.has(name)) { @@ -3882,17 +3882,17 @@ void RendererSceneCull::_update_dirty_instance(Instance *p_instance) { if (p_instance->instance_allocated_shader_uniforms != (p_instance->instance_shader_uniforms.size() > 0)) { p_instance->instance_allocated_shader_uniforms = (p_instance->instance_shader_uniforms.size() > 0); if (p_instance->instance_allocated_shader_uniforms) { - p_instance->instance_allocated_shader_uniforms_offset = RSG::material_storage->global_shader_uniforms_instance_allocate(p_instance->self); + p_instance->instance_allocated_shader_uniforms_offset = RSG::material_storage->global_shader_parameters_instance_allocate(p_instance->self); ERR_FAIL_NULL(geom->geometry_instance); geom->geometry_instance->set_instance_shader_uniforms_offset(p_instance->instance_allocated_shader_uniforms_offset); for (const KeyValue<StringName, Instance::InstanceShaderParameter> &E : p_instance->instance_shader_uniforms) { if (E.value.value.get_type() != Variant::NIL) { - RSG::material_storage->global_shader_uniforms_instance_update(p_instance->self, E.value.index, E.value.value); + RSG::material_storage->global_shader_parameters_instance_update(p_instance->self, E.value.index, E.value.value); } } } else { - RSG::material_storage->global_shader_uniforms_instance_free(p_instance->self); + RSG::material_storage->global_shader_parameters_instance_free(p_instance->self); p_instance->instance_allocated_shader_uniforms_offset = -1; ERR_FAIL_NULL(geom->geometry_instance); geom->geometry_instance->set_instance_shader_uniforms_offset(-1); @@ -3990,7 +3990,7 @@ bool RendererSceneCull::free(RID p_rid) { if (instance->instance_allocated_shader_uniforms) { //free the used shader parameters - RSG::material_storage->global_shader_uniforms_instance_free(instance->self); + RSG::material_storage->global_shader_parameters_instance_free(instance->self); } update_dirty_instances(); //in case something changed this @@ -4002,7 +4002,7 @@ bool RendererSceneCull::free(RID p_rid) { return true; } -TypedArray<Image> RendererSceneCull::bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) { +TypedArray<Image> RendererSceneCull::bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) { return scene_render->bake_render_uv2(p_base, p_material_overrides, p_image_size); } diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h index cc8d6bf5c6..c799553f87 100644 --- a/servers/rendering/renderer_scene_cull.h +++ b/servers/rendering/renderer_scene_cull.h @@ -970,10 +970,10 @@ public: void _update_instance_shader_uniforms_from_material(HashMap<StringName, Instance::InstanceShaderParameter> &isparams, const HashMap<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material); - virtual void instance_geometry_set_shader_uniform(RID p_instance, const StringName &p_parameter, const Variant &p_value); - virtual void instance_geometry_get_shader_uniform_list(RID p_instance, List<PropertyInfo> *p_parameters) const; - virtual Variant instance_geometry_get_shader_uniform(RID p_instance, const StringName &p_parameter) const; - virtual Variant instance_geometry_get_shader_uniform_default_value(RID p_instance, const StringName &p_parameter) const; + virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value); + virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const; + virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const; + virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const; _FORCE_INLINE_ void _update_instance(Instance *p_instance); _FORCE_INLINE_ void _update_instance_aabb(Instance *p_instance); @@ -1064,7 +1064,7 @@ public: void render_particle_colliders(); virtual void render_probes(); - TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size); + TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size); //pass to scene render diff --git a/servers/rendering/renderer_scene_render.h b/servers/rendering/renderer_scene_render.h index 2b18621fff..9aa4108412 100644 --- a/servers/rendering/renderer_scene_render.h +++ b/servers/rendering/renderer_scene_render.h @@ -338,7 +338,7 @@ public: virtual void sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) = 0; virtual void sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) = 0; - virtual TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) = 0; + virtual TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) = 0; virtual bool free(RID p_rid) = 0; diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 2fefdbff52..dd190437a3 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -235,7 +235,7 @@ RID RenderingDevice::_shader_create_from_spirv(const Ref<RDShaderSPIRV> &p_spirv return shader_create_from_spirv(stage_data); } -RID RenderingDevice::_uniform_set_create(const Array &p_uniforms, RID p_shader, uint32_t p_shader_set) { +RID RenderingDevice::_uniform_set_create(const TypedArray<RDUniform> &p_uniforms, RID p_shader, uint32_t p_shader_set) { Vector<Uniform> uniforms; uniforms.resize(p_uniforms.size()); for (int i = 0; i < p_uniforms.size(); i++) { diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index ed88f57a94..29e5c9cd77 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -42,7 +42,7 @@ class RDSamplerState; class RDVertexAttribute; class RDShaderSource; class RDShaderSPIRV; -class RDUniforms; +class RDUniform; class RDPipelineRasterizationState; class RDPipelineMultisampleState; class RDPipelineDepthStencilState; @@ -1314,7 +1314,7 @@ protected: Vector<uint8_t> _shader_compile_binary_from_spirv(const Ref<RDShaderSPIRV> &p_bytecode, const String &p_shader_name = ""); RID _shader_create_from_spirv(const Ref<RDShaderSPIRV> &p_spirv, const String &p_shader_name = ""); - RID _uniform_set_create(const Array &p_uniforms, RID p_shader, uint32_t p_shader_set); + RID _uniform_set_create(const TypedArray<RDUniform> &p_uniforms, RID p_shader, uint32_t p_shader_set); Error _buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const Vector<uint8_t> &p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL); diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index 4a5f9abed1..dfe16431bd 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -227,11 +227,11 @@ public: FUNC2(shader_set_path_hint, RID, const String &) FUNC1RC(String, shader_get_code, RID) - FUNC2SC(shader_get_shader_uniform_list, RID, List<PropertyInfo> *) + FUNC2SC(get_shader_parameter_list, RID, List<PropertyInfo> *) - FUNC4(shader_set_default_texture_param, RID, const StringName &, RID, int) - FUNC3RC(RID, shader_get_default_texture_param, RID, const StringName &, int) - FUNC2RC(Variant, shader_get_param_default, RID, const StringName &) + FUNC4(shader_set_default_texture_parameter, RID, const StringName &, RID, int) + FUNC3RC(RID, shader_get_default_texture_parameter, RID, const StringName &, int) + FUNC2RC(Variant, shader_get_parameter_default, RID, const StringName &) FUNC1RC(ShaderNativeSourceCode, shader_get_native_source_code, RID) @@ -783,12 +783,12 @@ public: FUNC4(instance_geometry_set_lightmap, RID, RID, const Rect2 &, int) FUNC2(instance_geometry_set_lod_bias, RID, float) FUNC2(instance_geometry_set_transparency, RID, float) - FUNC3(instance_geometry_set_shader_uniform, RID, const StringName &, const Variant &) - FUNC2RC(Variant, instance_geometry_get_shader_uniform, RID, const StringName &) - FUNC2RC(Variant, instance_geometry_get_shader_uniform_default_value, RID, const StringName &) - FUNC2C(instance_geometry_get_shader_uniform_list, RID, List<PropertyInfo> *) + FUNC3(instance_geometry_set_shader_parameter, RID, const StringName &, const Variant &) + FUNC2RC(Variant, instance_geometry_get_shader_parameter, RID, const StringName &) + FUNC2RC(Variant, instance_geometry_get_shader_parameter_default_value, RID, const StringName &) + FUNC2C(instance_geometry_get_shader_parameter_list, RID, List<PropertyInfo> *) - FUNC3R(TypedArray<Image>, bake_render_uv2, RID, const Vector<RID> &, const Size2i &) + FUNC3R(TypedArray<Image>, bake_render_uv2, RID, const TypedArray<RID> &, const Size2i &) FUNC1(gi_set_use_half_resolution, bool) @@ -919,16 +919,16 @@ public: #define ServerName RendererMaterialStorage #define server_name RSG::material_storage - FUNC3(global_shader_uniform_add, const StringName &, GlobalShaderUniformType, const Variant &) - FUNC1(global_shader_uniform_remove, const StringName &) - FUNC0RC(Vector<StringName>, global_shader_uniform_get_list) - FUNC2(global_shader_uniform_set, const StringName &, const Variant &) - FUNC2(global_shader_uniform_set_override, const StringName &, const Variant &) - FUNC1RC(GlobalShaderUniformType, global_shader_uniform_get_type, const StringName &) - FUNC1RC(Variant, global_shader_uniform_get, const StringName &) + FUNC3(global_shader_parameter_add, const StringName &, GlobalShaderParameterType, const Variant &) + FUNC1(global_shader_parameter_remove, const StringName &) + FUNC0RC(Vector<StringName>, global_shader_parameter_get_list) + FUNC2(global_shader_parameter_set, const StringName &, const Variant &) + FUNC2(global_shader_parameter_set_override, const StringName &, const Variant &) + FUNC1RC(GlobalShaderParameterType, global_shader_parameter_get_type, const StringName &) + FUNC1RC(Variant, global_shader_parameter_get, const StringName &) - FUNC1(global_shader_uniforms_load_settings, bool) - FUNC0(global_shader_uniforms_clear) + FUNC1(global_shader_parameters_load_settings, bool) + FUNC0(global_shader_parameters_clear) #undef server_name #undef ServerName diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index 7b33a13ec3..ab5b8af794 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -1349,7 +1349,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } ShaderLanguage::DataType ShaderCompiler::_get_variable_type(const StringName &p_type) { - RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(p_type); + RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_type); return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt); } diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 2bbc5e4dfb..e2519ba8d1 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -257,6 +257,7 @@ enum ContextFlag : uint32_t { CF_UNIFORM_KEYWORD = 2048U, // "uniform" CF_CONST_KEYWORD = 4096U, // "const" CF_UNIFORM_QUALIFIER = 8192U, // "<x> uniform float t;" + CF_SHADER_TYPE = 16384U, // "shader_type" }; const uint32_t KCF_DATATYPE = CF_BLOCK | CF_GLOBAL_SPACE | CF_DATATYPE | CF_FUNC_DECL_PARAM_TYPE | CF_UNIFORM_TYPE; @@ -318,7 +319,7 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = { { TK_VARYING, "varying", CF_GLOBAL_SPACE, { "particles", "sky", "fog" }, {} }, { TK_CONST, "const", CF_BLOCK | CF_GLOBAL_SPACE | CF_CONST_KEYWORD, {}, {} }, { TK_STRUCT, "struct", CF_GLOBAL_SPACE, {}, {} }, - { TK_SHADER_TYPE, "shader_type", CF_GLOBAL_SPACE, {}, {} }, + { TK_SHADER_TYPE, "shader_type", CF_SHADER_TYPE, {}, {} }, { TK_RENDER_MODE, "render_mode", CF_GLOBAL_SPACE, {}, {} }, // uniform qualifiers @@ -1183,7 +1184,7 @@ void ShaderLanguage::clear() { include_positions.push_back(FilePosition()); #ifdef DEBUG_ENABLED - keyword_completion_context = CF_GLOBAL_SPACE; + keyword_completion_context = CF_UNSPECIFIED; used_constants.clear(); used_varyings.clear(); used_uniforms.clear(); @@ -7821,6 +7822,9 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f Token next; if (!is_shader_inc) { +#ifdef DEBUG_ENABLED + keyword_completion_context = CF_SHADER_TYPE; +#endif // DEBUG_ENABLED tk = _get_token(); if (tk.type != TK_SHADER_TYPE) { diff --git a/servers/rendering/storage/material_storage.h b/servers/rendering/storage/material_storage.h index ad8e3e79bf..396668c9ed 100644 --- a/servers/rendering/storage/material_storage.h +++ b/servers/rendering/storage/material_storage.h @@ -39,21 +39,21 @@ public: virtual ~RendererMaterialStorage(){}; /* GLOBAL SHADER UNIFORM API */ - virtual void global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) = 0; - virtual void global_shader_uniform_remove(const StringName &p_name) = 0; - virtual Vector<StringName> global_shader_uniform_get_list() const = 0; + virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) = 0; + virtual void global_shader_parameter_remove(const StringName &p_name) = 0; + virtual Vector<StringName> global_shader_parameter_get_list() const = 0; - virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) = 0; - virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) = 0; - virtual Variant global_shader_uniform_get(const StringName &p_name) const = 0; - virtual RS::GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const = 0; + virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) = 0; + virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) = 0; + virtual Variant global_shader_parameter_get(const StringName &p_name) const = 0; + virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const = 0; - virtual void global_shader_uniforms_load_settings(bool p_load_textures = true) = 0; - virtual void global_shader_uniforms_clear() = 0; + virtual void global_shader_parameters_load_settings(bool p_load_textures = true) = 0; + virtual void global_shader_parameters_clear() = 0; - virtual int32_t global_shader_uniforms_instance_allocate(RID p_instance) = 0; - virtual void global_shader_uniforms_instance_free(RID p_instance) = 0; - virtual void global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) = 0; + virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) = 0; + virtual void global_shader_parameters_instance_free(RID p_instance) = 0; + virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) = 0; /* SHADER API */ virtual RID shader_allocate() = 0; @@ -63,11 +63,11 @@ public: virtual void shader_set_code(RID p_shader, const String &p_code) = 0; virtual void shader_set_path_hint(RID p_shader, const String &p_path) = 0; virtual String shader_get_code(RID p_shader) const = 0; - virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0; + virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0; - virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) = 0; - virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const = 0; - virtual Variant shader_get_param_default(RID p_material, const StringName &p_param) const = 0; + virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) = 0; + virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const = 0; + virtual Variant shader_get_parameter_default(RID p_material, const StringName &p_param) const = 0; virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const = 0; @@ -94,7 +94,7 @@ public: Variant default_value; }; - virtual void material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) = 0; + virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) = 0; virtual void material_update_dependency(RID p_material, DependencyTracker *p_instance) = 0; }; diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 53ce4af988..aa3351c815 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -95,7 +95,7 @@ PackedInt64Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from return to_int_array(ids); } -PackedInt64Array RenderingServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const { +PackedInt64Array RenderingServer::_instances_cull_convex_bind(const TypedArray<Plane> &p_convex, RID p_scenario) const { if (RSG::threaded) { WARN_PRINT_ONCE("Using this function with a threaded renderer hurts performance, as it causes a server stall."); } @@ -1400,7 +1400,7 @@ Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_su } #endif -int RenderingServer::global_shader_uniform_type_get_shader_datatype(GlobalShaderUniformType p_type) { +int RenderingServer::global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type) { switch (p_type) { case RS::GLOBAL_VAR_TYPE_BOOL: return ShaderLanguage::TYPE_BOOL; @@ -1501,9 +1501,9 @@ TypedArray<Image> RenderingServer::_texture_3d_get(RID p_texture) const { return ret; } -TypedArray<Dictionary> RenderingServer::_shader_get_shader_uniform_list(RID p_shader) const { +TypedArray<Dictionary> RenderingServer::_shader_get_shader_parameter_list(RID p_shader) const { List<PropertyInfo> l; - shader_get_shader_uniform_list(p_shader, &l); + get_shader_parameter_list(p_shader, &l); return convert_property_list(&l); } @@ -1626,14 +1626,14 @@ Dictionary RenderingServer::_mesh_get_surface(RID p_mesh, int p_idx) { return d; } -TypedArray<Dictionary> RenderingServer::_instance_geometry_get_shader_uniform_list(RID p_instance) const { +TypedArray<Dictionary> RenderingServer::_instance_geometry_get_shader_parameter_list(RID p_instance) const { List<PropertyInfo> params; - instance_geometry_get_shader_uniform_list(p_instance, ¶ms); + instance_geometry_get_shader_parameter_list(p_instance, ¶ms); return convert_property_list(¶ms); } TypedArray<Image> RenderingServer::_bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) { - Vector<RID> mat_overrides; + TypedArray<RID> mat_overrides; for (int i = 0; i < p_material_overrides.size(); i++) { mat_overrides.push_back(p_material_overrides[i]); } @@ -1702,11 +1702,11 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &RenderingServer::shader_set_code); ClassDB::bind_method(D_METHOD("shader_set_path_hint", "shader", "path"), &RenderingServer::shader_set_path_hint); ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &RenderingServer::shader_get_code); - ClassDB::bind_method(D_METHOD("shader_get_shader_uniform_list", "shader"), &RenderingServer::_shader_get_shader_uniform_list); - ClassDB::bind_method(D_METHOD("shader_get_param_default", "shader", "param"), &RenderingServer::shader_get_param_default); + ClassDB::bind_method(D_METHOD("get_shader_parameter_list", "shader"), &RenderingServer::_shader_get_shader_parameter_list); + ClassDB::bind_method(D_METHOD("shader_get_parameter_default", "shader", "name"), &RenderingServer::shader_get_parameter_default); - ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "param", "texture", "index"), &RenderingServer::shader_set_default_texture_param, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "param", "index"), &RenderingServer::shader_get_default_texture_param, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("shader_set_default_texture_parameter", "shader", "name", "texture", "index"), &RenderingServer::shader_set_default_texture_parameter, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("shader_get_default_texture_parameter", "shader", "name", "index"), &RenderingServer::shader_get_default_texture_parameter, DEFVAL(0)); BIND_ENUM_CONSTANT(SHADER_SPATIAL); BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM); @@ -2490,10 +2490,10 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("instance_geometry_set_lightmap", "instance", "lightmap", "lightmap_uv_scale", "lightmap_slice"), &RenderingServer::instance_geometry_set_lightmap); ClassDB::bind_method(D_METHOD("instance_geometry_set_lod_bias", "instance", "lod_bias"), &RenderingServer::instance_geometry_set_lod_bias); - ClassDB::bind_method(D_METHOD("instance_geometry_set_shader_uniform", "instance", "parameter", "value"), &RenderingServer::instance_geometry_set_shader_uniform); - ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_uniform", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_uniform); - ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_uniform_default_value", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_uniform_default_value); - ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_uniform_list", "instance"), &RenderingServer::_instance_geometry_get_shader_uniform_list); + ClassDB::bind_method(D_METHOD("instance_geometry_set_shader_parameter", "instance", "parameter", "value"), &RenderingServer::instance_geometry_set_shader_parameter); + ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter); + ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_default_value", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter_default_value); + ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_list", "instance"), &RenderingServer::_instance_geometry_get_shader_parameter_list); ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &RenderingServer::_instances_cull_aabb_bind, DEFVAL(RID())); ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &RenderingServer::_instances_cull_ray_bind, DEFVAL(RID())); @@ -2690,13 +2690,13 @@ void RenderingServer::_bind_methods() { /* GLOBAL SHADER UNIFORMS */ - ClassDB::bind_method(D_METHOD("global_shader_uniform_add", "name", "type", "default_value"), &RenderingServer::global_shader_uniform_add); - ClassDB::bind_method(D_METHOD("global_shader_uniform_remove", "name"), &RenderingServer::global_shader_uniform_remove); - ClassDB::bind_method(D_METHOD("global_shader_uniform_get_list"), &RenderingServer::global_shader_uniform_get_list); - ClassDB::bind_method(D_METHOD("global_shader_uniform_set", "name", "value"), &RenderingServer::global_shader_uniform_set); - ClassDB::bind_method(D_METHOD("global_shader_uniform_set_override", "name", "value"), &RenderingServer::global_shader_uniform_set_override); - ClassDB::bind_method(D_METHOD("global_shader_uniform_get", "name"), &RenderingServer::global_shader_uniform_get); - ClassDB::bind_method(D_METHOD("global_shader_uniform_get_type", "name"), &RenderingServer::global_shader_uniform_get_type); + ClassDB::bind_method(D_METHOD("global_shader_parameter_add", "name", "type", "default_value"), &RenderingServer::global_shader_parameter_add); + ClassDB::bind_method(D_METHOD("global_shader_parameter_remove", "name"), &RenderingServer::global_shader_parameter_remove); + ClassDB::bind_method(D_METHOD("global_shader_parameter_get_list"), &RenderingServer::global_shader_parameter_get_list); + ClassDB::bind_method(D_METHOD("global_shader_parameter_set", "name", "value"), &RenderingServer::global_shader_parameter_set); + ClassDB::bind_method(D_METHOD("global_shader_parameter_set_override", "name", "value"), &RenderingServer::global_shader_parameter_set_override); + ClassDB::bind_method(D_METHOD("global_shader_parameter_get", "name"), &RenderingServer::global_shader_parameter_get); + ClassDB::bind_method(D_METHOD("global_shader_parameter_get_type", "name"), &RenderingServer::global_shader_parameter_get_type); BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BOOL); BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC2); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 7bbc6aa069..67ba407775 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -173,11 +173,11 @@ public: virtual void shader_set_code(RID p_shader, const String &p_code) = 0; virtual void shader_set_path_hint(RID p_shader, const String &p_path) = 0; virtual String shader_get_code(RID p_shader) const = 0; - virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0; - virtual Variant shader_get_param_default(RID p_shader, const StringName &p_param) const = 0; + virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0; + virtual Variant shader_get_parameter_default(RID p_shader, const StringName &p_param) const = 0; - virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index = 0) = 0; - virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index = 0) const = 0; + virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index = 0) = 0; + virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index = 0) const = 0; struct ShaderNativeSourceCode { struct Version { @@ -1223,7 +1223,7 @@ public: PackedInt64Array _instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario = RID()) const; PackedInt64Array _instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const; - PackedInt64Array _instances_cull_convex_bind(const Array &p_convex, RID p_scenario = RID()) const; + PackedInt64Array _instances_cull_convex_bind(const TypedArray<Plane> &p_convex, RID p_scenario = RID()) const; enum InstanceFlags { INSTANCE_FLAG_USE_BAKED_LIGHT, @@ -1255,10 +1255,10 @@ public: virtual void instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias) = 0; virtual void instance_geometry_set_transparency(RID p_instance, float p_transparency) = 0; - virtual void instance_geometry_set_shader_uniform(RID p_instance, const StringName &, const Variant &p_value) = 0; - virtual Variant instance_geometry_get_shader_uniform(RID p_instance, const StringName &) const = 0; - virtual Variant instance_geometry_get_shader_uniform_default_value(RID p_instance, const StringName &) const = 0; - virtual void instance_geometry_get_shader_uniform_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0; + virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &, const Variant &p_value) = 0; + virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &) const = 0; + virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &) const = 0; + virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0; /* Bake 3D objects */ @@ -1269,7 +1269,7 @@ public: BAKE_CHANNEL_EMISSION }; - virtual TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) = 0; + virtual TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) = 0; /* CANVAS (2D) */ @@ -1441,7 +1441,7 @@ public: /* GLOBAL SHADER UNIFORMS */ - enum GlobalShaderUniformType { + enum GlobalShaderParameterType { GLOBAL_VAR_TYPE_BOOL, GLOBAL_VAR_TYPE_BVEC2, GLOBAL_VAR_TYPE_BVEC3, @@ -1473,20 +1473,20 @@ public: GLOBAL_VAR_TYPE_MAX }; - virtual void global_shader_uniform_add(const StringName &p_name, GlobalShaderUniformType p_type, const Variant &p_value) = 0; - virtual void global_shader_uniform_remove(const StringName &p_name) = 0; - virtual Vector<StringName> global_shader_uniform_get_list() const = 0; + virtual void global_shader_parameter_add(const StringName &p_name, GlobalShaderParameterType p_type, const Variant &p_value) = 0; + virtual void global_shader_parameter_remove(const StringName &p_name) = 0; + virtual Vector<StringName> global_shader_parameter_get_list() const = 0; - virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) = 0; - virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) = 0; + virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) = 0; + virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) = 0; - virtual Variant global_shader_uniform_get(const StringName &p_name) const = 0; - virtual GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const = 0; + virtual Variant global_shader_parameter_get(const StringName &p_name) const = 0; + virtual GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const = 0; - virtual void global_shader_uniforms_load_settings(bool p_load_textures) = 0; - virtual void global_shader_uniforms_clear() = 0; + virtual void global_shader_parameters_load_settings(bool p_load_textures) = 0; + virtual void global_shader_parameters_clear() = 0; - static int global_shader_uniform_type_get_shader_datatype(GlobalShaderUniformType p_type); + static int global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type); /* FREE */ @@ -1583,11 +1583,11 @@ private: RID _texture_3d_create(Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const TypedArray<Image> &p_data); void _texture_3d_update(RID p_texture, const TypedArray<Image> &p_data); TypedArray<Image> _texture_3d_get(RID p_texture) const; - TypedArray<Dictionary> _shader_get_shader_uniform_list(RID p_shader) const; + TypedArray<Dictionary> _shader_get_shader_parameter_list(RID p_shader) const; RID _mesh_create_from_surfaces(const TypedArray<Dictionary> &p_surfaces, int p_blend_shape_count); void _mesh_add_surface(RID p_mesh, const Dictionary &p_surface); Dictionary _mesh_get_surface(RID p_mesh, int p_idx); - TypedArray<Dictionary> _instance_geometry_get_shader_uniform_list(RID p_instance) const; + TypedArray<Dictionary> _instance_geometry_get_shader_parameter_list(RID p_instance) const; TypedArray<Image> _bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size); void _particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses); }; @@ -1662,7 +1662,7 @@ VARIANT_ENUM_CAST(RenderingServer::CanvasLightMode); VARIANT_ENUM_CAST(RenderingServer::CanvasLightBlendMode); VARIANT_ENUM_CAST(RenderingServer::CanvasLightShadowFilter); VARIANT_ENUM_CAST(RenderingServer::CanvasOccluderPolygonCullMode); -VARIANT_ENUM_CAST(RenderingServer::GlobalShaderUniformType); +VARIANT_ENUM_CAST(RenderingServer::GlobalShaderParameterType); VARIANT_ENUM_CAST(RenderingServer::RenderingInfo); VARIANT_ENUM_CAST(RenderingServer::Features); VARIANT_ENUM_CAST(RenderingServer::CanvasTextureChannel); diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp index 74ae2bfff0..ebd35b0f75 100644 --- a/servers/text/text_server_extension.cpp +++ b/servers/text/text_server_extension.cpp @@ -1136,7 +1136,7 @@ int64_t TextServerExtension::shaped_text_get_spacing(const RID &p_shaped, TextSe return 0; } -bool TextServerExtension::shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { +bool TextServerExtension::shaped_text_add_string(const RID &p_shaped, const String &p_text, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { bool ret; if (GDVIRTUAL_CALL(shaped_text_add_string, p_shaped, p_text, p_fonts, p_size, p_opentype_features, p_language, p_meta, ret)) { return ret; @@ -1176,7 +1176,7 @@ Variant TextServerExtension::shaped_get_span_meta(const RID &p_shaped, int64_t p return false; } -void TextServerExtension::shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features) { +void TextServerExtension::shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features) { GDVIRTUAL_CALL(shaped_set_span_update_font, p_shaped, p_index, p_fonts, p_size, p_opentype_features); } diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h index 6a2c199898..700d08f7d7 100644 --- a/servers/text/text_server_extension.h +++ b/servers/text/text_server_extension.h @@ -378,19 +378,19 @@ public: GDVIRTUAL3(shaped_text_set_spacing, RID, SpacingType, int64_t); GDVIRTUAL2RC(int64_t, shaped_text_get_spacing, RID, SpacingType); - virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override; + virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override; virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1) override; virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) override; - GDVIRTUAL7R(bool, shaped_text_add_string, RID, const String &, const Array &, int64_t, const Dictionary &, const String &, const Variant &); + GDVIRTUAL7R(bool, shaped_text_add_string, RID, const String &, const TypedArray<RID> &, int64_t, const Dictionary &, const String &, const Variant &); GDVIRTUAL5R(bool, shaped_text_add_object, RID, const Variant &, const Size2 &, InlineAlignment, int64_t); GDVIRTUAL4R(bool, shaped_text_resize_object, RID, const Variant &, const Size2 &, InlineAlignment); virtual int64_t shaped_get_span_count(const RID &p_shaped) const override; virtual Variant shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const override; - virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) override; + virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) override; GDVIRTUAL1RC(int64_t, shaped_get_span_count, RID); GDVIRTUAL2RC(Variant, shaped_get_span_meta, RID, int64_t); - GDVIRTUAL5(shaped_set_span_update_font, RID, int64_t, const Array &, int64_t, const Dictionary &); + GDVIRTUAL5(shaped_set_span_update_font, RID, int64_t, const TypedArray<RID> &, int64_t, const Dictionary &); virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const override; virtual RID shaped_text_get_parent(const RID &p_shaped) const override; diff --git a/servers/text_server.h b/servers/text_server.h index e8945dd807..b62d418fc8 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -409,13 +409,13 @@ public: virtual void shaped_text_set_spacing(const RID &p_shaped, SpacingType p_spacing, int64_t p_value) = 0; virtual int64_t shaped_text_get_spacing(const RID &p_shaped, SpacingType p_spacing) const = 0; - virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) = 0; + virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) = 0; virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1) = 0; virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) = 0; virtual int64_t shaped_get_span_count(const RID &p_shaped) const = 0; virtual Variant shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const = 0; - virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) = 0; + virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) = 0; virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const = 0; // Copy shaped substring (e.g. line break) without reshaping, but correctly reordered, preservers range. virtual RID shaped_text_get_parent(const RID &p_shaped) const = 0; |