mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 06:03:09 +00:00
Merge pull request #82313 from AThousandShips/null_check_servers
[Servers] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable
This commit is contained in:
commit
2c8c7b95aa
@ -659,7 +659,7 @@ bool EditorInspectorPluginGradient::can_handle(Object *p_object) {
|
||||
|
||||
void EditorInspectorPluginGradient::parse_begin(Object *p_object) {
|
||||
Gradient *gradient = Object::cast_to<Gradient>(p_object);
|
||||
ERR_FAIL_COND(!gradient);
|
||||
ERR_FAIL_NULL(gradient);
|
||||
Ref<Gradient> g(gradient);
|
||||
|
||||
GradientEditor *editor = memnew(GradientEditor);
|
||||
|
@ -389,7 +389,7 @@ void AudioServer::_mix_step() {
|
||||
}
|
||||
|
||||
AudioStreamPlaybackBusDetails *ptr = playback->bus_details.load();
|
||||
ERR_FAIL_COND(ptr == nullptr);
|
||||
ERR_FAIL_NULL(ptr);
|
||||
// By putting null into the bus details pointers, we're taking ownership of their memory for the duration of this mix.
|
||||
AudioStreamPlaybackBusDetails bus_details = *ptr;
|
||||
|
||||
@ -620,8 +620,8 @@ void AudioServer::_mix_step_for_channel(AudioFrame *p_out_buf, AudioFrame *p_sou
|
||||
filter.set_stages(1);
|
||||
filter.set_gain(p_highshelf_gain);
|
||||
|
||||
ERR_FAIL_COND(p_processor_l == nullptr);
|
||||
ERR_FAIL_COND(p_processor_r == nullptr);
|
||||
ERR_FAIL_NULL(p_processor_l);
|
||||
ERR_FAIL_NULL(p_processor_r);
|
||||
|
||||
bool is_just_started = p_vol_start.l == 0 && p_vol_start.r == 0;
|
||||
p_processor_l->set_filter(&filter, /* clear_history= */ is_just_started);
|
||||
|
@ -396,7 +396,7 @@ void ServersDebugger::deinitialize() {
|
||||
}
|
||||
|
||||
Error ServersDebugger::_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured) {
|
||||
ERR_FAIL_COND_V(!singleton, ERR_BUG);
|
||||
ERR_FAIL_NULL_V(singleton, ERR_BUG);
|
||||
r_captured = true;
|
||||
if (p_cmd == "memory") {
|
||||
singleton->_send_resource_usage();
|
||||
|
@ -510,7 +510,7 @@ void GodotBody2D::integrate_forces(real_t p_step) {
|
||||
// Add default gravity and damping from space area.
|
||||
if (!stopped) {
|
||||
GodotArea2D *default_area = get_space()->get_default_area();
|
||||
ERR_FAIL_COND(!default_area);
|
||||
ERR_FAIL_NULL(default_area);
|
||||
|
||||
if (!gravity_done) {
|
||||
Vector2 default_gravity;
|
||||
|
@ -58,7 +58,7 @@ void GodotBroadPhase2DBVH::remove(ID p_id) {
|
||||
GodotCollisionObject2D *GodotBroadPhase2DBVH::get_object(ID p_id) const {
|
||||
ERR_FAIL_COND_V(!p_id, nullptr);
|
||||
GodotCollisionObject2D *it = bvh.get(p_id - 1);
|
||||
ERR_FAIL_COND_V(!it, nullptr);
|
||||
ERR_FAIL_NULL_V(it, nullptr);
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_po
|
||||
int version_B = (pointcount_B > 2 ? 2 : pointcount_B) - 1;
|
||||
|
||||
GenerateContactsFunc contacts_func = generate_contacts_func_table[version_A][version_B];
|
||||
ERR_FAIL_COND(!contacts_func);
|
||||
ERR_FAIL_NULL(contacts_func);
|
||||
contacts_func(points_A, pointcount_A, points_B, pointcount_B, p_collector);
|
||||
}
|
||||
|
||||
@ -1396,7 +1396,7 @@ bool sat_2d_calculate_penetration(const GodotShape2D *p_shape_A, const Transform
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!collision_func, false);
|
||||
ERR_FAIL_NULL_V(collision_func, false);
|
||||
|
||||
collision_func(A, *transform_A, B, *transform_B, &callback, *motion_A, *motion_B, margin_A, margin_B);
|
||||
|
||||
|
@ -105,7 +105,7 @@ bool GodotPinJoint2D::setup(real_t p_step) {
|
||||
}
|
||||
|
||||
GodotSpace2D *space = A->get_space();
|
||||
ERR_FAIL_COND_V(!space, false);
|
||||
ERR_FAIL_NULL_V(space, false);
|
||||
|
||||
rA = A->get_transform().basis_xform(anchor_A);
|
||||
rB = B ? B->get_transform().basis_xform(anchor_B) : anchor_B;
|
||||
@ -391,7 +391,7 @@ bool GodotGrooveJoint2D::setup(real_t p_step) {
|
||||
}
|
||||
|
||||
GodotSpace2D *space = A->get_space();
|
||||
ERR_FAIL_COND_V(!space, false);
|
||||
ERR_FAIL_NULL_V(space, false);
|
||||
|
||||
// calculate endpoints in worldspace
|
||||
Vector2 ta = A->get_transform().xform(A_groove_1);
|
||||
|
@ -114,32 +114,32 @@ RID GodotPhysicsServer2D::concave_polygon_shape_create() {
|
||||
|
||||
void GodotPhysicsServer2D::shape_set_data(RID p_shape, const Variant &p_data) {
|
||||
GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND(!shape);
|
||||
ERR_FAIL_NULL(shape);
|
||||
shape->set_data(p_data);
|
||||
};
|
||||
|
||||
void GodotPhysicsServer2D::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
|
||||
GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND(!shape);
|
||||
ERR_FAIL_NULL(shape);
|
||||
shape->set_custom_bias(p_bias);
|
||||
}
|
||||
|
||||
PhysicsServer2D::ShapeType GodotPhysicsServer2D::shape_get_type(RID p_shape) const {
|
||||
const GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
|
||||
ERR_FAIL_NULL_V(shape, SHAPE_CUSTOM);
|
||||
return shape->get_type();
|
||||
};
|
||||
|
||||
Variant GodotPhysicsServer2D::shape_get_data(RID p_shape) const {
|
||||
const GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND_V(!shape, Variant());
|
||||
ERR_FAIL_NULL_V(shape, Variant());
|
||||
ERR_FAIL_COND_V(!shape->is_configured(), Variant());
|
||||
return shape->get_data();
|
||||
};
|
||||
|
||||
real_t GodotPhysicsServer2D::shape_get_custom_solver_bias(RID p_shape) const {
|
||||
const GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
ERR_FAIL_NULL_V(shape, 0);
|
||||
return shape->get_custom_bias();
|
||||
}
|
||||
|
||||
@ -195,9 +195,9 @@ void GodotPhysicsServer2D::_shape_col_cbk(const Vector2 &p_point_A, const Vector
|
||||
|
||||
bool GodotPhysicsServer2D::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) {
|
||||
GodotShape2D *shape_A = shape_owner.get_or_null(p_shape_A);
|
||||
ERR_FAIL_COND_V(!shape_A, false);
|
||||
ERR_FAIL_NULL_V(shape_A, false);
|
||||
GodotShape2D *shape_B = shape_owner.get_or_null(p_shape_B);
|
||||
ERR_FAIL_COND_V(!shape_B, false);
|
||||
ERR_FAIL_NULL_V(shape_B, false);
|
||||
|
||||
if (p_result_max == 0) {
|
||||
return GodotCollisionSolver2D::solve(shape_A, p_xform_A, p_motion_A, shape_B, p_xform_B, p_motion_B, nullptr, nullptr);
|
||||
@ -220,7 +220,7 @@ RID GodotPhysicsServer2D::space_create() {
|
||||
space->set_self(id);
|
||||
RID area_id = area_create();
|
||||
GodotArea2D *area = area_owner.get_or_null(area_id);
|
||||
ERR_FAIL_COND_V(!area, RID());
|
||||
ERR_FAIL_NULL_V(area, RID());
|
||||
space->set_default_area(area);
|
||||
area->set_space(space);
|
||||
area->set_priority(-1);
|
||||
@ -230,7 +230,7 @@ RID GodotPhysicsServer2D::space_create() {
|
||||
|
||||
void GodotPhysicsServer2D::space_set_active(RID p_space, bool p_active) {
|
||||
GodotSpace2D *space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND(!space);
|
||||
ERR_FAIL_NULL(space);
|
||||
if (p_active) {
|
||||
active_spaces.insert(space);
|
||||
} else {
|
||||
@ -240,45 +240,45 @@ void GodotPhysicsServer2D::space_set_active(RID p_space, bool p_active) {
|
||||
|
||||
bool GodotPhysicsServer2D::space_is_active(RID p_space) const {
|
||||
const GodotSpace2D *space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND_V(!space, false);
|
||||
ERR_FAIL_NULL_V(space, false);
|
||||
|
||||
return active_spaces.has(space);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
|
||||
GodotSpace2D *space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND(!space);
|
||||
ERR_FAIL_NULL(space);
|
||||
|
||||
space->set_param(p_param, p_value);
|
||||
}
|
||||
|
||||
real_t GodotPhysicsServer2D::space_get_param(RID p_space, SpaceParameter p_param) const {
|
||||
const GodotSpace2D *space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND_V(!space, 0);
|
||||
ERR_FAIL_NULL_V(space, 0);
|
||||
return space->get_param(p_param);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::space_set_debug_contacts(RID p_space, int p_max_contacts) {
|
||||
GodotSpace2D *space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND(!space);
|
||||
ERR_FAIL_NULL(space);
|
||||
space->set_debug_contacts(p_max_contacts);
|
||||
}
|
||||
|
||||
Vector<Vector2> GodotPhysicsServer2D::space_get_contacts(RID p_space) const {
|
||||
GodotSpace2D *space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND_V(!space, Vector<Vector2>());
|
||||
ERR_FAIL_NULL_V(space, Vector<Vector2>());
|
||||
return space->get_debug_contacts();
|
||||
}
|
||||
|
||||
int GodotPhysicsServer2D::space_get_contact_count(RID p_space) const {
|
||||
GodotSpace2D *space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND_V(!space, 0);
|
||||
ERR_FAIL_NULL_V(space, 0);
|
||||
return space->get_debug_contact_count();
|
||||
}
|
||||
|
||||
PhysicsDirectSpaceState2D *GodotPhysicsServer2D::space_get_direct_state(RID p_space) {
|
||||
GodotSpace2D *space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND_V(!space, nullptr);
|
||||
ERR_FAIL_NULL_V(space, nullptr);
|
||||
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");
|
||||
|
||||
return space->get_direct_state();
|
||||
@ -293,12 +293,12 @@ RID GodotPhysicsServer2D::area_create() {
|
||||
|
||||
void GodotPhysicsServer2D::area_set_space(RID p_area, RID p_space) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
GodotSpace2D *space = nullptr;
|
||||
if (p_space.is_valid()) {
|
||||
space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND(!space);
|
||||
ERR_FAIL_NULL(space);
|
||||
}
|
||||
|
||||
if (area->get_space() == space) {
|
||||
@ -311,7 +311,7 @@ void GodotPhysicsServer2D::area_set_space(RID p_area, RID p_space) {
|
||||
|
||||
RID GodotPhysicsServer2D::area_get_space(RID p_area) const {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, RID());
|
||||
ERR_FAIL_NULL_V(area, RID());
|
||||
|
||||
GodotSpace2D *space = area->get_space();
|
||||
if (!space) {
|
||||
@ -322,20 +322,20 @@ RID GodotPhysicsServer2D::area_get_space(RID p_area) const {
|
||||
|
||||
void GodotPhysicsServer2D::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND(!shape);
|
||||
ERR_FAIL_NULL(shape);
|
||||
|
||||
area->add_shape(shape, p_transform, p_disabled);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND(!shape);
|
||||
ERR_FAIL_NULL(shape);
|
||||
ERR_FAIL_COND(!shape->is_configured());
|
||||
|
||||
area->set_shape(p_shape_idx, shape);
|
||||
@ -343,14 +343,14 @@ void GodotPhysicsServer2D::area_set_shape(RID p_area, int p_shape_idx, RID p_sha
|
||||
|
||||
void GodotPhysicsServer2D::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
area->set_shape_transform(p_shape_idx, p_transform);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
ERR_FAIL_INDEX(p_shape, area->get_shape_count());
|
||||
FLUSH_QUERY_CHECK(area);
|
||||
|
||||
@ -359,38 +359,38 @@ void GodotPhysicsServer2D::area_set_shape_disabled(RID p_area, int p_shape, bool
|
||||
|
||||
int GodotPhysicsServer2D::area_get_shape_count(RID p_area) const {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, -1);
|
||||
ERR_FAIL_NULL_V(area, -1);
|
||||
|
||||
return area->get_shape_count();
|
||||
}
|
||||
|
||||
RID GodotPhysicsServer2D::area_get_shape(RID p_area, int p_shape_idx) const {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, RID());
|
||||
ERR_FAIL_NULL_V(area, RID());
|
||||
|
||||
GodotShape2D *shape = area->get_shape(p_shape_idx);
|
||||
ERR_FAIL_COND_V(!shape, RID());
|
||||
ERR_FAIL_NULL_V(shape, RID());
|
||||
|
||||
return shape->get_self();
|
||||
}
|
||||
|
||||
Transform2D GodotPhysicsServer2D::area_get_shape_transform(RID p_area, int p_shape_idx) const {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, Transform2D());
|
||||
ERR_FAIL_NULL_V(area, Transform2D());
|
||||
|
||||
return area->get_shape_transform(p_shape_idx);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::area_remove_shape(RID p_area, int p_shape_idx) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
area->remove_shape(p_shape_idx);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::area_clear_shapes(RID p_area) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
while (area->get_shape_count()) {
|
||||
area->remove_shape(0);
|
||||
@ -403,7 +403,7 @@ void GodotPhysicsServer2D::area_attach_object_instance_id(RID p_area, ObjectID p
|
||||
p_area = space->get_default_area()->get_self();
|
||||
}
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
area->set_instance_id(p_id);
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ ObjectID GodotPhysicsServer2D::area_get_object_instance_id(RID p_area) const {
|
||||
p_area = space->get_default_area()->get_self();
|
||||
}
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, ObjectID());
|
||||
ERR_FAIL_NULL_V(area, ObjectID());
|
||||
return area->get_instance_id();
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ void GodotPhysicsServer2D::area_attach_canvas_instance_id(RID p_area, ObjectID p
|
||||
p_area = space->get_default_area()->get_self();
|
||||
}
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
area->set_canvas_instance_id(p_id);
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ ObjectID GodotPhysicsServer2D::area_get_canvas_instance_id(RID p_area) const {
|
||||
p_area = space->get_default_area()->get_self();
|
||||
}
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, ObjectID());
|
||||
ERR_FAIL_NULL_V(area, ObjectID());
|
||||
return area->get_canvas_instance_id();
|
||||
}
|
||||
|
||||
@ -443,13 +443,13 @@ void GodotPhysicsServer2D::area_set_param(RID p_area, AreaParameter p_param, con
|
||||
p_area = space->get_default_area()->get_self();
|
||||
}
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
area->set_param(p_param, p_value);
|
||||
};
|
||||
|
||||
void GodotPhysicsServer2D::area_set_transform(RID p_area, const Transform2D &p_transform) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
area->set_transform(p_transform);
|
||||
};
|
||||
|
||||
@ -459,27 +459,27 @@ Variant GodotPhysicsServer2D::area_get_param(RID p_area, AreaParameter p_param)
|
||||
p_area = space->get_default_area()->get_self();
|
||||
}
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, Variant());
|
||||
ERR_FAIL_NULL_V(area, Variant());
|
||||
|
||||
return area->get_param(p_param);
|
||||
};
|
||||
|
||||
Transform2D GodotPhysicsServer2D::area_get_transform(RID p_area) const {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, Transform2D());
|
||||
ERR_FAIL_NULL_V(area, Transform2D());
|
||||
|
||||
return area->get_transform();
|
||||
};
|
||||
|
||||
void GodotPhysicsServer2D::area_set_pickable(RID p_area, bool p_pickable) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
area->set_pickable(p_pickable);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::area_set_monitorable(RID p_area, bool p_monitorable) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
FLUSH_QUERY_CHECK(area);
|
||||
|
||||
area->set_monitorable(p_monitorable);
|
||||
@ -487,42 +487,42 @@ void GodotPhysicsServer2D::area_set_monitorable(RID p_area, bool p_monitorable)
|
||||
|
||||
void GodotPhysicsServer2D::area_set_collision_layer(RID p_area, uint32_t p_layer) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
area->set_collision_layer(p_layer);
|
||||
}
|
||||
|
||||
uint32_t GodotPhysicsServer2D::area_get_collision_layer(RID p_area) const {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, 0);
|
||||
ERR_FAIL_NULL_V(area, 0);
|
||||
|
||||
return area->get_collision_layer();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::area_set_collision_mask(RID p_area, uint32_t p_mask) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
area->set_collision_mask(p_mask);
|
||||
}
|
||||
|
||||
uint32_t GodotPhysicsServer2D::area_get_collision_mask(RID p_area) const {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND_V(!area, 0);
|
||||
ERR_FAIL_NULL_V(area, 0);
|
||||
|
||||
return area->get_collision_mask();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::area_set_monitor_callback(RID p_area, const Callable &p_callback) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
area->set_monitor_callback(p_callback.is_valid() ? p_callback : Callable());
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::area_set_area_monitor_callback(RID p_area, const Callable &p_callback) {
|
||||
GodotArea2D *area = area_owner.get_or_null(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
ERR_FAIL_NULL(area);
|
||||
|
||||
area->set_area_monitor_callback(p_callback.is_valid() ? p_callback : Callable());
|
||||
}
|
||||
@ -538,11 +538,11 @@ RID GodotPhysicsServer2D::body_create() {
|
||||
|
||||
void GodotPhysicsServer2D::body_set_space(RID p_body, RID p_space) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
GodotSpace2D *space = nullptr;
|
||||
if (p_space.is_valid()) {
|
||||
space = space_owner.get_or_null(p_space);
|
||||
ERR_FAIL_COND(!space);
|
||||
ERR_FAIL_NULL(space);
|
||||
}
|
||||
|
||||
if (body->get_space() == space) {
|
||||
@ -555,7 +555,7 @@ void GodotPhysicsServer2D::body_set_space(RID p_body, RID p_space) {
|
||||
|
||||
RID GodotPhysicsServer2D::body_get_space(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, RID());
|
||||
ERR_FAIL_NULL_V(body, RID());
|
||||
|
||||
GodotSpace2D *space = body->get_space();
|
||||
if (!space) {
|
||||
@ -566,7 +566,7 @@ RID GodotPhysicsServer2D::body_get_space(RID p_body) const {
|
||||
|
||||
void GodotPhysicsServer2D::body_set_mode(RID p_body, BodyMode p_mode) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
FLUSH_QUERY_CHECK(body);
|
||||
|
||||
body->set_mode(p_mode);
|
||||
@ -574,27 +574,27 @@ void GodotPhysicsServer2D::body_set_mode(RID p_body, BodyMode p_mode) {
|
||||
|
||||
PhysicsServer2D::BodyMode GodotPhysicsServer2D::body_get_mode(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
|
||||
ERR_FAIL_NULL_V(body, BODY_MODE_STATIC);
|
||||
|
||||
return body->get_mode();
|
||||
};
|
||||
|
||||
void GodotPhysicsServer2D::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND(!shape);
|
||||
ERR_FAIL_NULL(shape);
|
||||
|
||||
body->add_shape(shape, p_transform, p_disabled);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
GodotShape2D *shape = shape_owner.get_or_null(p_shape);
|
||||
ERR_FAIL_COND(!shape);
|
||||
ERR_FAIL_NULL(shape);
|
||||
ERR_FAIL_COND(!shape->is_configured());
|
||||
|
||||
body->set_shape(p_shape_idx, shape);
|
||||
@ -602,45 +602,45 @@ void GodotPhysicsServer2D::body_set_shape(RID p_body, int p_shape_idx, RID p_sha
|
||||
|
||||
void GodotPhysicsServer2D::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_shape_transform(p_shape_idx, p_transform);
|
||||
}
|
||||
|
||||
int GodotPhysicsServer2D::body_get_shape_count(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, -1);
|
||||
ERR_FAIL_NULL_V(body, -1);
|
||||
|
||||
return body->get_shape_count();
|
||||
}
|
||||
|
||||
RID GodotPhysicsServer2D::body_get_shape(RID p_body, int p_shape_idx) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, RID());
|
||||
ERR_FAIL_NULL_V(body, RID());
|
||||
|
||||
GodotShape2D *shape = body->get_shape(p_shape_idx);
|
||||
ERR_FAIL_COND_V(!shape, RID());
|
||||
ERR_FAIL_NULL_V(shape, RID());
|
||||
|
||||
return shape->get_self();
|
||||
}
|
||||
|
||||
Transform2D GodotPhysicsServer2D::body_get_shape_transform(RID p_body, int p_shape_idx) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, Transform2D());
|
||||
ERR_FAIL_NULL_V(body, Transform2D());
|
||||
|
||||
return body->get_shape_transform(p_shape_idx);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_remove_shape(RID p_body, int p_shape_idx) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->remove_shape(p_shape_idx);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_clear_shapes(RID p_body) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
while (body->get_shape_count()) {
|
||||
body->remove_shape(0);
|
||||
@ -649,7 +649,7 @@ void GodotPhysicsServer2D::body_clear_shapes(RID p_body) {
|
||||
|
||||
void GodotPhysicsServer2D::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
|
||||
FLUSH_QUERY_CHECK(body);
|
||||
|
||||
@ -658,7 +658,7 @@ void GodotPhysicsServer2D::body_set_shape_disabled(RID p_body, int p_shape_idx,
|
||||
|
||||
void GodotPhysicsServer2D::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, real_t p_margin) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
|
||||
FLUSH_QUERY_CHECK(body);
|
||||
|
||||
@ -667,123 +667,123 @@ void GodotPhysicsServer2D::body_set_shape_as_one_way_collision(RID p_body, int p
|
||||
|
||||
void GodotPhysicsServer2D::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
body->set_continuous_collision_detection_mode(p_mode);
|
||||
}
|
||||
|
||||
GodotPhysicsServer2D::CCDMode GodotPhysicsServer2D::body_get_continuous_collision_detection_mode(RID p_body) const {
|
||||
const GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, CCD_MODE_DISABLED);
|
||||
ERR_FAIL_NULL_V(body, CCD_MODE_DISABLED);
|
||||
|
||||
return body->get_continuous_collision_detection_mode();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_instance_id(p_id);
|
||||
}
|
||||
|
||||
ObjectID GodotPhysicsServer2D::body_get_object_instance_id(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, ObjectID());
|
||||
ERR_FAIL_NULL_V(body, ObjectID());
|
||||
|
||||
return body->get_instance_id();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_canvas_instance_id(p_id);
|
||||
}
|
||||
|
||||
ObjectID GodotPhysicsServer2D::body_get_canvas_instance_id(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, ObjectID());
|
||||
ERR_FAIL_NULL_V(body, ObjectID());
|
||||
|
||||
return body->get_canvas_instance_id();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_collision_layer(RID p_body, uint32_t p_layer) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
body->set_collision_layer(p_layer);
|
||||
}
|
||||
|
||||
uint32_t GodotPhysicsServer2D::body_get_collision_layer(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0);
|
||||
ERR_FAIL_NULL_V(body, 0);
|
||||
|
||||
return body->get_collision_layer();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_collision_mask(RID p_body, uint32_t p_mask) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
body->set_collision_mask(p_mask);
|
||||
}
|
||||
|
||||
uint32_t GodotPhysicsServer2D::body_get_collision_mask(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0);
|
||||
ERR_FAIL_NULL_V(body, 0);
|
||||
|
||||
return body->get_collision_mask();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_collision_priority(RID p_body, real_t p_priority) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_collision_priority(p_priority);
|
||||
}
|
||||
|
||||
real_t GodotPhysicsServer2D::body_get_collision_priority(RID p_body) const {
|
||||
const GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0);
|
||||
ERR_FAIL_NULL_V(body, 0);
|
||||
|
||||
return body->get_collision_priority();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_param(p_param, p_value);
|
||||
}
|
||||
|
||||
Variant GodotPhysicsServer2D::body_get_param(RID p_body, BodyParameter p_param) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0);
|
||||
ERR_FAIL_NULL_V(body, 0);
|
||||
|
||||
return body->get_param(p_param);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_reset_mass_properties(RID p_body) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
return body->reset_mass_properties();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_state(p_state, p_variant);
|
||||
}
|
||||
|
||||
Variant GodotPhysicsServer2D::body_get_state(RID p_body, BodyState p_state) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, Variant());
|
||||
ERR_FAIL_NULL_V(body, Variant());
|
||||
|
||||
return body->get_state(p_state);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->apply_central_impulse(p_impulse);
|
||||
body->wakeup();
|
||||
@ -791,7 +791,7 @@ void GodotPhysicsServer2D::body_apply_central_impulse(RID p_body, const Vector2
|
||||
|
||||
void GodotPhysicsServer2D::body_apply_torque_impulse(RID p_body, real_t p_torque) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
_update_shapes();
|
||||
|
||||
@ -801,7 +801,7 @@ void GodotPhysicsServer2D::body_apply_torque_impulse(RID p_body, real_t p_torque
|
||||
|
||||
void GodotPhysicsServer2D::body_apply_impulse(RID p_body, const Vector2 &p_impulse, const Vector2 &p_position) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
_update_shapes();
|
||||
|
||||
@ -811,7 +811,7 @@ void GodotPhysicsServer2D::body_apply_impulse(RID p_body, const Vector2 &p_impul
|
||||
|
||||
void GodotPhysicsServer2D::body_apply_central_force(RID p_body, const Vector2 &p_force) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->apply_central_force(p_force);
|
||||
body->wakeup();
|
||||
@ -819,7 +819,7 @@ void GodotPhysicsServer2D::body_apply_central_force(RID p_body, const Vector2 &p
|
||||
|
||||
void GodotPhysicsServer2D::body_apply_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->apply_force(p_force, p_position);
|
||||
body->wakeup();
|
||||
@ -827,7 +827,7 @@ void GodotPhysicsServer2D::body_apply_force(RID p_body, const Vector2 &p_force,
|
||||
|
||||
void GodotPhysicsServer2D::body_apply_torque(RID p_body, real_t p_torque) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->apply_torque(p_torque);
|
||||
body->wakeup();
|
||||
@ -835,7 +835,7 @@ void GodotPhysicsServer2D::body_apply_torque(RID p_body, real_t p_torque) {
|
||||
|
||||
void GodotPhysicsServer2D::body_add_constant_central_force(RID p_body, const Vector2 &p_force) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->add_constant_central_force(p_force);
|
||||
body->wakeup();
|
||||
@ -843,7 +843,7 @@ void GodotPhysicsServer2D::body_add_constant_central_force(RID p_body, const Vec
|
||||
|
||||
void GodotPhysicsServer2D::body_add_constant_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->add_constant_force(p_force, p_position);
|
||||
body->wakeup();
|
||||
@ -851,7 +851,7 @@ void GodotPhysicsServer2D::body_add_constant_force(RID p_body, const Vector2 &p_
|
||||
|
||||
void GodotPhysicsServer2D::body_add_constant_torque(RID p_body, real_t p_torque) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->add_constant_torque(p_torque);
|
||||
body->wakeup();
|
||||
@ -859,7 +859,7 @@ void GodotPhysicsServer2D::body_add_constant_torque(RID p_body, real_t p_torque)
|
||||
|
||||
void GodotPhysicsServer2D::body_set_constant_force(RID p_body, const Vector2 &p_force) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_constant_force(p_force);
|
||||
if (!p_force.is_zero_approx()) {
|
||||
@ -869,13 +869,13 @@ void GodotPhysicsServer2D::body_set_constant_force(RID p_body, const Vector2 &p_
|
||||
|
||||
Vector2 GodotPhysicsServer2D::body_get_constant_force(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, Vector2());
|
||||
ERR_FAIL_NULL_V(body, Vector2());
|
||||
return body->get_constant_force();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_constant_torque(RID p_body, real_t p_torque) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_constant_torque(p_torque);
|
||||
if (!Math::is_zero_approx(p_torque)) {
|
||||
@ -885,14 +885,14 @@ void GodotPhysicsServer2D::body_set_constant_torque(RID p_body, real_t p_torque)
|
||||
|
||||
real_t GodotPhysicsServer2D::body_get_constant_torque(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0);
|
||||
ERR_FAIL_NULL_V(body, 0);
|
||||
|
||||
return body->get_constant_torque();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
_update_shapes();
|
||||
|
||||
@ -906,7 +906,7 @@ void GodotPhysicsServer2D::body_set_axis_velocity(RID p_body, const Vector2 &p_a
|
||||
|
||||
void GodotPhysicsServer2D::body_add_collision_exception(RID p_body, RID p_body_b) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->add_exception(p_body_b);
|
||||
body->wakeup();
|
||||
@ -914,7 +914,7 @@ void GodotPhysicsServer2D::body_add_collision_exception(RID p_body, RID p_body_b
|
||||
|
||||
void GodotPhysicsServer2D::body_remove_collision_exception(RID p_body, RID p_body_b) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->remove_exception(p_body_b);
|
||||
body->wakeup();
|
||||
@ -922,7 +922,7 @@ void GodotPhysicsServer2D::body_remove_collision_exception(RID p_body, RID p_bod
|
||||
|
||||
void GodotPhysicsServer2D::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
for (int i = 0; i < body->get_exceptions().size(); i++) {
|
||||
p_exceptions->push_back(body->get_exceptions()[i]);
|
||||
@ -931,55 +931,55 @@ void GodotPhysicsServer2D::body_get_collision_exceptions(RID p_body, List<RID> *
|
||||
|
||||
void GodotPhysicsServer2D::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
};
|
||||
|
||||
real_t GodotPhysicsServer2D::body_get_contacts_reported_depth_threshold(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0);
|
||||
ERR_FAIL_NULL_V(body, 0);
|
||||
return 0;
|
||||
};
|
||||
|
||||
void GodotPhysicsServer2D::body_set_omit_force_integration(RID p_body, bool p_omit) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
|
||||
body->set_omit_force_integration(p_omit);
|
||||
};
|
||||
|
||||
bool GodotPhysicsServer2D::body_is_omitting_force_integration(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, false);
|
||||
ERR_FAIL_NULL_V(body, false);
|
||||
return body->get_omit_force_integration();
|
||||
};
|
||||
|
||||
void GodotPhysicsServer2D::body_set_max_contacts_reported(RID p_body, int p_contacts) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
body->set_max_contacts_reported(p_contacts);
|
||||
}
|
||||
|
||||
int GodotPhysicsServer2D::body_get_max_contacts_reported(RID p_body) const {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, -1);
|
||||
ERR_FAIL_NULL_V(body, -1);
|
||||
return body->get_max_contacts_reported();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_state_sync_callback(RID p_body, const Callable &p_callable) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
body->set_state_sync_callback(p_callable);
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
body->set_force_integration_callback(p_callable, p_udata);
|
||||
}
|
||||
|
||||
bool GodotPhysicsServer2D::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) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, false);
|
||||
ERR_FAIL_NULL_V(body, false);
|
||||
ERR_FAIL_INDEX_V(p_body_shape, body->get_shape_count(), false);
|
||||
|
||||
return shape_collide(body->get_shape(p_body_shape)->get_self(), body->get_transform() * body->get_shape_transform(p_body_shape), Vector2(), p_shape, p_shape_xform, p_motion, r_results, p_result_max, r_result_count);
|
||||
@ -987,13 +987,13 @@ bool GodotPhysicsServer2D::body_collide_shape(RID p_body, int p_body_shape, RID
|
||||
|
||||
void GodotPhysicsServer2D::body_set_pickable(RID p_body, bool p_pickable) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_NULL(body);
|
||||
body->set_pickable(p_pickable);
|
||||
}
|
||||
|
||||
bool GodotPhysicsServer2D::body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, false);
|
||||
ERR_FAIL_NULL_V(body, false);
|
||||
ERR_FAIL_COND_V(!body->get_space(), false);
|
||||
ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
|
||||
|
||||
@ -1010,7 +1010,7 @@ PhysicsDirectBodyState2D *GodotPhysicsServer2D::body_get_direct_state(RID p_body
|
||||
}
|
||||
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_COND_V(!body, nullptr);
|
||||
ERR_FAIL_NULL_V(body, nullptr);
|
||||
|
||||
if (!body->get_space()) {
|
||||
return nullptr;
|
||||
@ -1044,7 +1044,7 @@ void GodotPhysicsServer2D::joint_clear(RID p_joint) {
|
||||
|
||||
void GodotPhysicsServer2D::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
|
||||
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
|
||||
ERR_FAIL_COND(!joint);
|
||||
ERR_FAIL_NULL(joint);
|
||||
|
||||
switch (p_param) {
|
||||
case JOINT_PARAM_BIAS:
|
||||
@ -1061,7 +1061,7 @@ void GodotPhysicsServer2D::joint_set_param(RID p_joint, JointParam p_param, real
|
||||
|
||||
real_t GodotPhysicsServer2D::joint_get_param(RID p_joint, JointParam p_param) const {
|
||||
const GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, -1);
|
||||
ERR_FAIL_NULL_V(joint, -1);
|
||||
|
||||
switch (p_param) {
|
||||
case JOINT_PARAM_BIAS:
|
||||
@ -1080,7 +1080,7 @@ real_t GodotPhysicsServer2D::joint_get_param(RID p_joint, JointParam p_param) co
|
||||
|
||||
void GodotPhysicsServer2D::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
|
||||
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
|
||||
ERR_FAIL_COND(!joint);
|
||||
ERR_FAIL_NULL(joint);
|
||||
|
||||
joint->disable_collisions_between_bodies(p_disable);
|
||||
|
||||
@ -1100,22 +1100,22 @@ void GodotPhysicsServer2D::joint_disable_collisions_between_bodies(RID p_joint,
|
||||
|
||||
bool GodotPhysicsServer2D::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
|
||||
const GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, true);
|
||||
ERR_FAIL_NULL_V(joint, true);
|
||||
|
||||
return joint->is_disabled_collisions_between_bodies();
|
||||
}
|
||||
|
||||
void GodotPhysicsServer2D::joint_make_pin(RID p_joint, const Vector2 &p_pos, RID p_body_a, RID p_body_b) {
|
||||
GodotBody2D *A = body_owner.get_or_null(p_body_a);
|
||||
ERR_FAIL_COND(!A);
|
||||
ERR_FAIL_NULL(A);
|
||||
GodotBody2D *B = nullptr;
|
||||
if (body_owner.owns(p_body_b)) {
|
||||
B = body_owner.get_or_null(p_body_b);
|
||||
ERR_FAIL_COND(!B);
|
||||
ERR_FAIL_NULL(B);
|
||||
}
|
||||
|
||||
GodotJoint2D *prev_joint = joint_owner.get_or_null(p_joint);
|
||||
ERR_FAIL_COND(prev_joint == nullptr);
|
||||
ERR_FAIL_NULL(prev_joint);
|
||||
|
||||
GodotJoint2D *joint = memnew(GodotPinJoint2D(p_pos, A, B));
|
||||
|
||||
@ -1126,13 +1126,13 @@ void GodotPhysicsServer2D::joint_make_pin(RID p_joint, const Vector2 &p_pos, RID
|
||||
|
||||
void GodotPhysicsServer2D::joint_make_groove(RID p_joint, const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) {
|
||||
GodotBody2D *A = body_owner.get_or_null(p_body_a);
|
||||
ERR_FAIL_COND(!A);
|
||||
ERR_FAIL_NULL(A);
|
||||
|
||||
GodotBody2D *B = body_owner.get_or_null(p_body_b);
|
||||
ERR_FAIL_COND(!B);
|
||||
ERR_FAIL_NULL(B);
|
||||
|
||||
GodotJoint2D *prev_joint = joint_owner.get_or_null(p_joint);
|
||||
ERR_FAIL_COND(prev_joint == nullptr);
|
||||
ERR_FAIL_NULL(prev_joint);
|
||||
|
||||
GodotJoint2D *joint = memnew(GodotGrooveJoint2D(p_a_groove1, p_a_groove2, p_b_anchor, A, B));
|
||||
|
||||
@ -1143,13 +1143,13 @@ void GodotPhysicsServer2D::joint_make_groove(RID p_joint, const Vector2 &p_a_gro
|
||||
|
||||
void GodotPhysicsServer2D::joint_make_damped_spring(RID p_joint, const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) {
|
||||
GodotBody2D *A = body_owner.get_or_null(p_body_a);
|
||||
ERR_FAIL_COND(!A);
|
||||
ERR_FAIL_NULL(A);
|
||||
|
||||
GodotBody2D *B = body_owner.get_or_null(p_body_b);
|
||||
ERR_FAIL_COND(!B);
|
||||
ERR_FAIL_NULL(B);
|
||||
|
||||
GodotJoint2D *prev_joint = joint_owner.get_or_null(p_joint);
|
||||
ERR_FAIL_COND(prev_joint == nullptr);
|
||||
ERR_FAIL_NULL(prev_joint);
|
||||
|
||||
GodotJoint2D *joint = memnew(GodotDampedSpringJoint2D(p_anchor_a, p_anchor_b, A, B));
|
||||
|
||||
@ -1214,7 +1214,7 @@ real_t GodotPhysicsServer2D::damped_spring_joint_get_param(RID p_joint, DampedSp
|
||||
|
||||
PhysicsServer2D::JointType GodotPhysicsServer2D::joint_get_type(RID p_joint) const {
|
||||
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, JOINT_TYPE_PIN);
|
||||
ERR_FAIL_NULL_V(joint, JOINT_TYPE_PIN);
|
||||
|
||||
return joint->get_type();
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ int GodotPhysicsDirectSpaceState2D::intersect_shape(const ShapeParameters &p_par
|
||||
}
|
||||
|
||||
GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
ERR_FAIL_NULL_V(shape, 0);
|
||||
|
||||
Rect2 aabb = p_parameters.transform.xform(shape->get_aabb());
|
||||
aabb = aabb.merge(Rect2(aabb.position + p_parameters.motion, aabb.size)); //motion
|
||||
@ -255,7 +255,7 @@ int GodotPhysicsDirectSpaceState2D::intersect_shape(const ShapeParameters &p_par
|
||||
|
||||
bool GodotPhysicsDirectSpaceState2D::cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) {
|
||||
GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
|
||||
ERR_FAIL_COND_V(!shape, false);
|
||||
ERR_FAIL_NULL_V(shape, false);
|
||||
|
||||
Rect2 aabb = p_parameters.transform.xform(shape->get_aabb());
|
||||
aabb = aabb.merge(Rect2(aabb.position + p_parameters.motion, aabb.size)); //motion
|
||||
@ -342,7 +342,7 @@ bool GodotPhysicsDirectSpaceState2D::collide_shape(const ShapeParameters &p_para
|
||||
}
|
||||
|
||||
GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
ERR_FAIL_NULL_V(shape, 0);
|
||||
|
||||
Rect2 aabb = p_parameters.transform.xform(shape->get_aabb());
|
||||
aabb = aabb.merge(Rect2(aabb.position + p_parameters.motion, aabb.size)); //motion
|
||||
@ -439,7 +439,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
|
||||
|
||||
bool GodotPhysicsDirectSpaceState2D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) {
|
||||
GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
ERR_FAIL_NULL_V(shape, 0);
|
||||
|
||||
real_t margin = MAX(p_parameters.margin, TEST_MOTION_MARGIN_MIN_VALUE);
|
||||
|
||||
|
@ -565,7 +565,7 @@ void GodotBody3D::integrate_forces(real_t p_step) {
|
||||
// Add default gravity and damping from space area.
|
||||
if (!stopped) {
|
||||
GodotArea3D *default_area = get_space()->get_default_area();
|
||||
ERR_FAIL_COND(!default_area);
|
||||
ERR_FAIL_NULL(default_area);
|
||||
|
||||
if (!gravity_done) {
|
||||
Vector3 default_gravity;
|
||||
|
@ -59,7 +59,7 @@ void GodotBroadPhase3DBVH::remove(ID p_id) {
|
||||
GodotCollisionObject3D *GodotBroadPhase3DBVH::get_object(ID p_id) const {
|
||||
ERR_FAIL_COND_V(!p_id, nullptr);
|
||||
GodotCollisionObject3D *it = bvh.get(p_id - 1);
|
||||
ERR_FAIL_COND_V(!it, nullptr);
|
||||
ERR_FAIL_NULL_V(it, nullptr);
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po
|
||||
}
|
||||
|
||||
GenerateContactsFunc contacts_func = generate_contacts_func_table[version_A][version_B];
|
||||
ERR_FAIL_COND(!contacts_func);
|
||||
ERR_FAIL_NULL(contacts_func);
|
||||
contacts_func(points_A, pointcount_A, points_B, pointcount_B, p_callback);
|
||||
}
|
||||
|
||||
@ -2409,7 +2409,7 @@ bool sat_calculate_penetration(const GodotShape3D *p_shape_A, const Transform3D
|
||||
} else {
|
||||
collision_func = collision_table[type_A - 2][type_B - 2];
|
||||
}
|
||||
ERR_FAIL_COND_V(!collision_func, false);
|
||||
ERR_FAIL_NULL_V(collision_func, false);
|
||||
|
||||
collision_func(A, *transform_A, B, *transform_B, &callback, margin_A, margin_B);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1010,7 +1010,7 @@ void GodotSoftBody3D::predict_motion(real_t p_delta) {
|
||||
// Add default gravity and damping from space area.
|
||||
if (!gravity_done) {
|
||||
GodotArea3D *default_area = get_space()->get_default_area();
|
||||
ERR_FAIL_COND(!default_area);
|
||||
ERR_FAIL_NULL(default_area);
|
||||
|
||||
Vector3 default_gravity;
|
||||
default_area->compute_gravity(get_transform().get_origin(), default_gravity);
|
||||
@ -1223,7 +1223,7 @@ void GodotSoftBody3D::destroy() {
|
||||
}
|
||||
|
||||
void GodotSoftBodyShape3D::update_bounds() {
|
||||
ERR_FAIL_COND(!soft_body);
|
||||
ERR_FAIL_NULL(soft_body);
|
||||
|
||||
AABB collision_aabb = soft_body->get_bounds();
|
||||
collision_aabb.grow_by(soft_body->get_collision_margin());
|
||||
|
@ -211,7 +211,7 @@ int GodotPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_par
|
||||
}
|
||||
|
||||
GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
ERR_FAIL_NULL_V(shape, 0);
|
||||
|
||||
AABB aabb = p_parameters.transform.xform(shape->get_aabb());
|
||||
|
||||
@ -262,7 +262,7 @@ int GodotPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_par
|
||||
|
||||
bool GodotPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, ShapeRestInfo *r_info) {
|
||||
GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
|
||||
ERR_FAIL_COND_V(!shape, false);
|
||||
ERR_FAIL_NULL_V(shape, false);
|
||||
|
||||
AABB aabb = p_parameters.transform.xform(shape->get_aabb());
|
||||
aabb = aabb.merge(AABB(aabb.position + p_parameters.motion, aabb.size)); //motion
|
||||
@ -385,7 +385,7 @@ bool GodotPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_para
|
||||
}
|
||||
|
||||
GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
ERR_FAIL_NULL_V(shape, 0);
|
||||
|
||||
AABB aabb = p_parameters.transform.xform(shape->get_aabb());
|
||||
aabb = aabb.grow(p_parameters.margin);
|
||||
@ -511,7 +511,7 @@ static void _rest_cbk_result(const Vector3 &p_point_A, int p_index_A, const Vect
|
||||
|
||||
bool GodotPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) {
|
||||
GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
ERR_FAIL_NULL_V(shape, 0);
|
||||
|
||||
real_t margin = MAX(p_parameters.margin, TEST_MOTION_MARGIN_MIN_VALUE);
|
||||
|
||||
@ -574,7 +574,7 @@ Vector3 GodotPhysicsDirectSpaceState3D::get_closest_point_to_object_volume(RID p
|
||||
if (!obj) {
|
||||
obj = GodotPhysicsServer3D::godot_singleton->body_owner.get_or_null(p_object);
|
||||
}
|
||||
ERR_FAIL_COND_V(!obj, Vector3());
|
||||
ERR_FAIL_NULL_V(obj, Vector3());
|
||||
|
||||
ERR_FAIL_COND_V(obj->get_space() != space, Vector3());
|
||||
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
|
||||
void geometry_instance_free(RenderGeometryInstance *p_geometry_instance) override {
|
||||
GeometryInstanceDummy *ginstance = static_cast<GeometryInstanceDummy *>(p_geometry_instance);
|
||||
ERR_FAIL_COND(!ginstance);
|
||||
ERR_FAIL_NULL(ginstance);
|
||||
|
||||
geometry_instance_alloc.free(ginstance);
|
||||
}
|
||||
|
@ -52,14 +52,14 @@ void MeshStorage::mesh_initialize(RID p_rid) {
|
||||
|
||||
void MeshStorage::mesh_free(RID p_rid) {
|
||||
DummyMesh *mesh = mesh_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
|
||||
mesh_owner.free(p_rid);
|
||||
}
|
||||
|
||||
void MeshStorage::mesh_clear(RID p_mesh) {
|
||||
DummyMesh *m = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!m);
|
||||
ERR_FAIL_NULL(m);
|
||||
|
||||
m->surfaces.clear();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
|
||||
virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) override {
|
||||
DummyMesh *m = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!m);
|
||||
ERR_FAIL_NULL(m);
|
||||
m->surfaces.push_back(RS::SurfaceData());
|
||||
RS::SurfaceData *s = &m->surfaces.write[m->surfaces.size() - 1];
|
||||
s->format = p_surface.format;
|
||||
@ -99,7 +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_NULL_V(m, RS::SurfaceData());
|
||||
ERR_FAIL_INDEX_V(p_surface, m->surfaces.size(), RS::SurfaceData());
|
||||
RS::SurfaceData s = m->surfaces[p_surface];
|
||||
return s;
|
||||
@ -107,7 +107,7 @@ public:
|
||||
|
||||
virtual int mesh_get_surface_count(RID p_mesh) const override {
|
||||
DummyMesh *m = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!m, 0);
|
||||
ERR_FAIL_NULL_V(m, 0);
|
||||
return m->surfaces.size();
|
||||
}
|
||||
|
||||
|
@ -73,21 +73,21 @@ public:
|
||||
|
||||
virtual RID texture_allocate() override {
|
||||
DummyTexture *texture = memnew(DummyTexture);
|
||||
ERR_FAIL_COND_V(!texture, RID());
|
||||
ERR_FAIL_NULL_V(texture, RID());
|
||||
return texture_owner.make_rid(texture);
|
||||
};
|
||||
|
||||
virtual void texture_free(RID p_rid) override {
|
||||
// delete the texture
|
||||
DummyTexture *texture = texture_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND(!texture);
|
||||
ERR_FAIL_NULL(texture);
|
||||
texture_owner.free(p_rid);
|
||||
memdelete(texture);
|
||||
};
|
||||
|
||||
virtual void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override {
|
||||
DummyTexture *t = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!t);
|
||||
ERR_FAIL_NULL(t);
|
||||
t->image = p_image->duplicate();
|
||||
};
|
||||
virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) override{};
|
||||
@ -105,7 +105,7 @@ public:
|
||||
|
||||
virtual Ref<Image> texture_2d_get(RID p_texture) const override {
|
||||
DummyTexture *t = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND_V(!t, Ref<Image>());
|
||||
ERR_FAIL_NULL_V(t, Ref<Image>());
|
||||
return t->image;
|
||||
};
|
||||
virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const override { return Ref<Image>(); };
|
||||
|
@ -416,9 +416,9 @@ void RendererCanvasCull::canvas_initialize(RID p_rid) {
|
||||
|
||||
void RendererCanvasCull::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) {
|
||||
Canvas *canvas = canvas_owner.get_or_null(p_canvas);
|
||||
ERR_FAIL_COND(!canvas);
|
||||
ERR_FAIL_NULL(canvas);
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
int idx = canvas->find_item(canvas_item);
|
||||
ERR_FAIL_COND(idx == -1);
|
||||
@ -427,7 +427,7 @@ void RendererCanvasCull::canvas_set_item_mirroring(RID p_canvas, RID p_item, con
|
||||
|
||||
void RendererCanvasCull::canvas_set_modulate(RID p_canvas, const Color &p_color) {
|
||||
Canvas *canvas = canvas_owner.get_or_null(p_canvas);
|
||||
ERR_FAIL_COND(!canvas);
|
||||
ERR_FAIL_NULL(canvas);
|
||||
canvas->modulate = p_color;
|
||||
}
|
||||
|
||||
@ -437,7 +437,7 @@ void RendererCanvasCull::canvas_set_disable_scale(bool p_disable) {
|
||||
|
||||
void RendererCanvasCull::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) {
|
||||
Canvas *canvas = canvas_owner.get_or_null(p_canvas);
|
||||
ERR_FAIL_COND(!canvas);
|
||||
ERR_FAIL_NULL(canvas);
|
||||
|
||||
canvas->parent = p_parent;
|
||||
canvas->parent_scale = p_scale;
|
||||
@ -452,7 +452,7 @@ void RendererCanvasCull::canvas_item_initialize(RID p_rid) {
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
if (canvas_item->parent.is_valid()) {
|
||||
if (canvas_owner.owns(canvas_item->parent)) {
|
||||
@ -496,7 +496,7 @@ void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_visible(RID p_item, bool p_visible) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->visible = p_visible;
|
||||
|
||||
@ -505,21 +505,21 @@ void RendererCanvasCull::canvas_item_set_visible(RID p_item, bool p_visible) {
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_light_mask(RID p_item, int p_mask) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->light_mask = p_mask;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->xform = p_transform;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_visibility_layer(RID p_item, uint32_t p_visibility_layer) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->visibility_layer = p_visibility_layer;
|
||||
}
|
||||
@ -533,21 +533,21 @@ uint32_t RendererCanvasCull::canvas_item_get_visibility_layer(RID p_item) {
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_clip(RID p_item, bool p_clip) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->clip = p_clip;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->distance_field = p_enable;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->custom_rect = p_custom_rect;
|
||||
canvas_item->rect = p_rect;
|
||||
@ -555,38 +555,38 @@ void RendererCanvasCull::canvas_item_set_custom_rect(RID p_item, bool p_custom_r
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_modulate(RID p_item, const Color &p_color) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->modulate = p_color;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_self_modulate(RID p_item, const Color &p_color) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->self_modulate = p_color;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->behind = p_enable;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_update_when_visible(RID p_item, bool p_update) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->update_when_visible = p_update;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width, bool p_antialiased) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandPrimitive *line = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!line);
|
||||
ERR_FAIL_NULL(line);
|
||||
|
||||
Vector2 diff = (p_from - p_to);
|
||||
Vector2 dir = diff.orthogonal().normalized();
|
||||
@ -640,7 +640,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||
|
||||
{
|
||||
Item::CommandPrimitive *left_border = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!left_border);
|
||||
ERR_FAIL_NULL(left_border);
|
||||
|
||||
left_border->points[0] = begin_left;
|
||||
left_border->points[1] = begin_left + border;
|
||||
@ -656,7 +656,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||
}
|
||||
{
|
||||
Item::CommandPrimitive *right_border = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!right_border);
|
||||
ERR_FAIL_NULL(right_border);
|
||||
|
||||
right_border->points[0] = begin_right;
|
||||
right_border->points[1] = begin_right - border;
|
||||
@ -672,7 +672,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||
}
|
||||
{
|
||||
Item::CommandPrimitive *top_border = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!top_border);
|
||||
ERR_FAIL_NULL(top_border);
|
||||
|
||||
top_border->points[0] = begin_left;
|
||||
top_border->points[1] = begin_left + border2;
|
||||
@ -688,7 +688,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||
}
|
||||
{
|
||||
Item::CommandPrimitive *bottom_border = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!bottom_border);
|
||||
ERR_FAIL_NULL(bottom_border);
|
||||
|
||||
bottom_border->points[0] = end_left;
|
||||
bottom_border->points[1] = end_left - border2;
|
||||
@ -704,7 +704,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||
}
|
||||
{
|
||||
Item::CommandPrimitive *top_left_corner = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!top_left_corner);
|
||||
ERR_FAIL_NULL(top_left_corner);
|
||||
|
||||
top_left_corner->points[0] = begin_left;
|
||||
top_left_corner->points[1] = begin_left + border2;
|
||||
@ -720,7 +720,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||
}
|
||||
{
|
||||
Item::CommandPrimitive *top_right_corner = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!top_right_corner);
|
||||
ERR_FAIL_NULL(top_right_corner);
|
||||
|
||||
top_right_corner->points[0] = begin_right;
|
||||
top_right_corner->points[1] = begin_right + border2;
|
||||
@ -736,7 +736,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||
}
|
||||
{
|
||||
Item::CommandPrimitive *bottom_left_corner = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!bottom_left_corner);
|
||||
ERR_FAIL_NULL(bottom_left_corner);
|
||||
|
||||
bottom_left_corner->points[0] = end_left;
|
||||
bottom_left_corner->points[1] = end_left - border2;
|
||||
@ -752,7 +752,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
|
||||
}
|
||||
{
|
||||
Item::CommandPrimitive *bottom_right_corner = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!bottom_right_corner);
|
||||
ERR_FAIL_NULL(bottom_right_corner);
|
||||
|
||||
bottom_right_corner->points[0] = end_right;
|
||||
bottom_right_corner->points[1] = end_right - border2;
|
||||
@ -815,7 +815,7 @@ static Vector2 compute_polyline_edge_offset_clamped(const Vector2 &p_segment_dir
|
||||
void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width, bool p_antialiased) {
|
||||
ERR_FAIL_COND(p_points.size() < 2);
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Color color = Color(1, 1, 1, 1);
|
||||
|
||||
@ -823,7 +823,7 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
|
||||
int point_count = p_points.size();
|
||||
|
||||
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!pline);
|
||||
ERR_FAIL_NULL(pline);
|
||||
|
||||
if (p_width < 0) {
|
||||
if (p_antialiased) {
|
||||
@ -899,10 +899,10 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
|
||||
Color color2 = Color(1, 1, 1, 0);
|
||||
|
||||
Item::CommandPolygon *pline_left = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!pline_left);
|
||||
ERR_FAIL_NULL(pline_left);
|
||||
|
||||
Item::CommandPolygon *pline_right = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!pline_right);
|
||||
ERR_FAIL_NULL(pline_right);
|
||||
|
||||
PackedColorArray colors_left;
|
||||
PackedVector2Array points_left;
|
||||
@ -1086,7 +1086,7 @@ void RendererCanvasCull::canvas_item_add_multiline(RID p_item, const Vector<Poin
|
||||
// TODO: `canvas_item_add_line`(`multiline`, `polyline`) share logic, should factor out.
|
||||
if (p_width < 0) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Vector<Color> colors;
|
||||
if (p_colors.size() == 1) {
|
||||
@ -1102,7 +1102,7 @@ void RendererCanvasCull::canvas_item_add_multiline(RID p_item, const Vector<Poin
|
||||
}
|
||||
|
||||
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!pline);
|
||||
ERR_FAIL_NULL(pline);
|
||||
pline->primitive = RS::PRIMITIVE_LINES;
|
||||
pline->polygon.create(Vector<int>(), p_points, colors);
|
||||
} else {
|
||||
@ -1128,20 +1128,20 @@ void RendererCanvasCull::canvas_item_add_multiline(RID p_item, const Vector<Poin
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
|
||||
ERR_FAIL_COND(!rect);
|
||||
ERR_FAIL_NULL(rect);
|
||||
rect->modulate = p_color;
|
||||
rect->rect = p_rect;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandPolygon *circle = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!circle);
|
||||
ERR_FAIL_NULL(circle);
|
||||
|
||||
circle->primitive = RS::PRIMITIVE_TRIANGLES;
|
||||
|
||||
@ -1177,10 +1177,10 @@ void RendererCanvasCull::canvas_item_add_circle(RID p_item, const Point2 &p_pos,
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
|
||||
ERR_FAIL_COND(!rect);
|
||||
ERR_FAIL_NULL(rect);
|
||||
rect->modulate = p_modulate;
|
||||
rect->rect = p_rect;
|
||||
rect->flags = 0;
|
||||
@ -1208,10 +1208,10 @@ void RendererCanvasCull::canvas_item_add_texture_rect(RID p_item, const Rect2 &p
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_msdf_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, int p_outline_size, float p_px_range, float p_scale) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
|
||||
ERR_FAIL_COND(!rect);
|
||||
ERR_FAIL_NULL(rect);
|
||||
rect->modulate = p_modulate;
|
||||
rect->rect = p_rect;
|
||||
|
||||
@ -1242,10 +1242,10 @@ void RendererCanvasCull::canvas_item_add_msdf_texture_rect_region(RID p_item, co
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_lcd_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
|
||||
ERR_FAIL_COND(!rect);
|
||||
ERR_FAIL_NULL(rect);
|
||||
rect->modulate = p_modulate;
|
||||
rect->rect = p_rect;
|
||||
|
||||
@ -1274,10 +1274,10 @@ void RendererCanvasCull::canvas_item_add_lcd_texture_rect_region(RID p_item, con
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
|
||||
ERR_FAIL_COND(!rect);
|
||||
ERR_FAIL_NULL(rect);
|
||||
rect->modulate = p_modulate;
|
||||
rect->rect = p_rect;
|
||||
|
||||
@ -1315,10 +1315,10 @@ void RendererCanvasCull::canvas_item_add_texture_rect_region(RID p_item, const R
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, RS::NinePatchAxisMode p_x_axis_mode, RS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandNinePatch *style = canvas_item->alloc_command<Item::CommandNinePatch>();
|
||||
ERR_FAIL_COND(!style);
|
||||
ERR_FAIL_NULL(style);
|
||||
|
||||
style->texture = p_texture;
|
||||
|
||||
@ -1339,10 +1339,10 @@ void RendererCanvasCull::canvas_item_add_primitive(RID p_item, const Vector<Poin
|
||||
ERR_FAIL_COND(pc == 0 || pc > 4);
|
||||
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandPrimitive *prim = canvas_item->alloc_command<Item::CommandPrimitive>();
|
||||
ERR_FAIL_COND(!prim);
|
||||
ERR_FAIL_NULL(prim);
|
||||
|
||||
for (int i = 0; i < p_points.size(); i++) {
|
||||
prim->points[i] = p_points[i];
|
||||
@ -1365,7 +1365,7 @@ void RendererCanvasCull::canvas_item_add_primitive(RID p_item, const Vector<Poin
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
#ifdef DEBUG_ENABLED
|
||||
int pointcount = p_points.size();
|
||||
ERR_FAIL_COND(pointcount < 3);
|
||||
@ -1378,7 +1378,7 @@ void RendererCanvasCull::canvas_item_add_polygon(RID p_item, const Vector<Point2
|
||||
ERR_FAIL_COND_MSG(indices.is_empty(), "Invalid polygon data, triangulation failed.");
|
||||
|
||||
Item::CommandPolygon *polygon = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!polygon);
|
||||
ERR_FAIL_NULL(polygon);
|
||||
polygon->primitive = RS::PRIMITIVE_TRIANGLES;
|
||||
polygon->texture = p_texture;
|
||||
polygon->polygon.create(indices, p_points, p_colors, p_uvs);
|
||||
@ -1386,7 +1386,7 @@ void RendererCanvasCull::canvas_item_add_polygon(RID p_item, const Vector<Point2
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
int vertex_count = p_points.size();
|
||||
ERR_FAIL_COND(vertex_count == 0);
|
||||
@ -1398,7 +1398,7 @@ void RendererCanvasCull::canvas_item_add_triangle_array(RID p_item, const Vector
|
||||
Vector<int> indices = p_indices;
|
||||
|
||||
Item::CommandPolygon *polygon = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!polygon);
|
||||
ERR_FAIL_NULL(polygon);
|
||||
|
||||
polygon->texture = p_texture;
|
||||
|
||||
@ -1409,20 +1409,20 @@ void RendererCanvasCull::canvas_item_add_triangle_array(RID p_item, const Vector
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandTransform *tr = canvas_item->alloc_command<Item::CommandTransform>();
|
||||
ERR_FAIL_COND(!tr);
|
||||
ERR_FAIL_NULL(tr);
|
||||
tr->xform = p_transform;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
ERR_FAIL_COND(!p_mesh.is_valid());
|
||||
|
||||
Item::CommandMesh *m = canvas_item->alloc_command<Item::CommandMesh>();
|
||||
ERR_FAIL_COND(!m);
|
||||
ERR_FAIL_NULL(m);
|
||||
m->mesh = p_mesh;
|
||||
if (canvas_item->skeleton.is_valid()) {
|
||||
m->mesh_instance = RSG::mesh_storage->mesh_instance_create(p_mesh);
|
||||
@ -1437,10 +1437,10 @@ void RendererCanvasCull::canvas_item_add_mesh(RID p_item, const RID &p_mesh, con
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandParticles *part = canvas_item->alloc_command<Item::CommandParticles>();
|
||||
ERR_FAIL_COND(!part);
|
||||
ERR_FAIL_NULL(part);
|
||||
part->particles = p_particles;
|
||||
|
||||
part->texture = p_texture;
|
||||
@ -1451,10 +1451,10 @@ void RendererCanvasCull::canvas_item_add_particles(RID p_item, RID p_particles,
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandMultiMesh *mm = canvas_item->alloc_command<Item::CommandMultiMesh>();
|
||||
ERR_FAIL_COND(!mm);
|
||||
ERR_FAIL_NULL(mm);
|
||||
mm->multimesh = p_mesh;
|
||||
|
||||
mm->texture = p_texture;
|
||||
@ -1462,19 +1462,19 @@ void RendererCanvasCull::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandClipIgnore *ci = canvas_item->alloc_command<Item::CommandClipIgnore>();
|
||||
ERR_FAIL_COND(!ci);
|
||||
ERR_FAIL_NULL(ci);
|
||||
ci->ignore = p_ignore;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_add_animation_slice(RID p_item, double p_animation_length, double p_slice_begin, double p_slice_end, double p_offset) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
Item::CommandAnimationSlice *as = canvas_item->alloc_command<Item::CommandAnimationSlice>();
|
||||
ERR_FAIL_COND(!as);
|
||||
ERR_FAIL_NULL(as);
|
||||
as->animation_length = p_animation_length;
|
||||
as->slice_begin = p_slice_begin;
|
||||
as->slice_end = p_slice_end;
|
||||
@ -1483,7 +1483,7 @@ void RendererCanvasCull::canvas_item_add_animation_slice(RID p_item, double p_an
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->sort_y = p_enable;
|
||||
|
||||
@ -1494,21 +1494,21 @@ void RendererCanvasCull::canvas_item_set_z_index(RID p_item, int p_z) {
|
||||
ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN || p_z > RS::CANVAS_ITEM_Z_MAX);
|
||||
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->z_index = p_z;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->z_relative = p_enable;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
if (canvas_item->skeleton == p_skeleton) {
|
||||
return;
|
||||
}
|
||||
@ -1537,7 +1537,7 @@ void RendererCanvasCull::canvas_item_attach_skeleton(RID p_item, RID p_skeleton)
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
if (p_enable && (canvas_item->copy_back_buffer == nullptr)) {
|
||||
canvas_item->copy_back_buffer = memnew(RendererCanvasRender::Item::CopyBackBuffer);
|
||||
}
|
||||
@ -1554,14 +1554,14 @@ void RendererCanvasCull::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_e
|
||||
|
||||
void RendererCanvasCull::canvas_item_clear(RID p_item) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->clear();
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_draw_index(RID p_item, int p_index) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->index = p_index;
|
||||
|
||||
@ -1580,21 +1580,21 @@ void RendererCanvasCull::canvas_item_set_draw_index(RID p_item, int p_index) {
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_material(RID p_item, RID p_material) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->material = p_material;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
canvas_item->use_parent_material = p_enable;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_visibility_notifier(RID p_item, bool p_enable, const Rect2 &p_area, const Callable &p_enter_callable, const Callable &p_exit_callable) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
if (p_enable) {
|
||||
if (!canvas_item->visibility_notifier) {
|
||||
@ -1614,7 +1614,7 @@ void RendererCanvasCull::canvas_item_set_visibility_notifier(RID p_item, bool p_
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_canvas_group_mode(RID p_item, RS::CanvasGroupMode p_mode, float p_clear_margin, bool p_fit_empty, float p_fit_margin, bool p_blur_mipmaps) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_NULL(canvas_item);
|
||||
|
||||
if (p_mode == RS::CANVAS_GROUP_MODE_DISABLED) {
|
||||
if (canvas_item->canvas_group != nullptr) {
|
||||
@ -1644,7 +1644,7 @@ void RendererCanvasCull::canvas_light_initialize(RID p_rid) {
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
if (clight->mode == p_mode) {
|
||||
return;
|
||||
@ -1665,7 +1665,7 @@ void RendererCanvasCull::canvas_light_set_mode(RID p_light, RS::CanvasLightMode
|
||||
|
||||
void RendererCanvasCull::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
if (clight->canvas.is_valid()) {
|
||||
Canvas *canvas = canvas_owner.get_or_null(clight->canvas);
|
||||
@ -1694,28 +1694,28 @@ void RendererCanvasCull::canvas_light_attach_to_canvas(RID p_light, RID p_canvas
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_enabled(RID p_light, bool p_enabled) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->enabled = p_enabled;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_texture_scale(RID p_light, float p_scale) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->scale = p_scale;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->xform = p_transform;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_texture(RID p_light, RID p_texture) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
if (clight->texture == p_texture) {
|
||||
return;
|
||||
@ -1727,35 +1727,35 @@ void RendererCanvasCull::canvas_light_set_texture(RID p_light, RID p_texture) {
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->texture_offset = p_offset;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_color(RID p_light, const Color &p_color) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->color = p_color;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_height(RID p_light, float p_height) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->height = p_height;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_energy(RID p_light, float p_energy) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->energy = p_energy;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->z_min = p_min_z;
|
||||
clight->z_max = p_max_z;
|
||||
@ -1763,7 +1763,7 @@ void RendererCanvasCull::canvas_light_set_z_range(RID p_light, int p_min_z, int
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->layer_max = p_max_layer;
|
||||
clight->layer_min = p_min_layer;
|
||||
@ -1771,35 +1771,35 @@ void RendererCanvasCull::canvas_light_set_layer_range(RID p_light, int p_min_lay
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->item_mask = p_mask;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->item_shadow_mask = p_mask;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_directional_distance(RID p_light, float p_distance) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->directional_distance = p_distance;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_blend_mode(RID p_light, RS::CanvasLightBlendMode p_mode) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->blend_mode = p_mode;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
if (clight->use_shadow == p_enabled) {
|
||||
return;
|
||||
@ -1811,21 +1811,21 @@ void RendererCanvasCull::canvas_light_set_shadow_enabled(RID p_light, bool p_ena
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_shadow_filter(RID p_light, RS::CanvasLightShadowFilter p_filter) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->shadow_filter = p_filter;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
|
||||
clight->shadow_color = p_color;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) {
|
||||
RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!clight);
|
||||
ERR_FAIL_NULL(clight);
|
||||
clight->shadow_smooth = p_smooth;
|
||||
}
|
||||
|
||||
@ -1838,7 +1838,7 @@ void RendererCanvasCull::canvas_light_occluder_initialize(RID p_rid) {
|
||||
|
||||
void RendererCanvasCull::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
|
||||
RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
|
||||
if (occluder->canvas.is_valid()) {
|
||||
Canvas *canvas = canvas_owner.get_or_null(occluder->canvas);
|
||||
@ -1859,14 +1859,14 @@ void RendererCanvasCull::canvas_light_occluder_attach_to_canvas(RID p_occluder,
|
||||
|
||||
void RendererCanvasCull::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
|
||||
RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
|
||||
occluder->enabled = p_enabled;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
|
||||
RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
|
||||
if (occluder->polygon.is_valid()) {
|
||||
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(occluder->polygon);
|
||||
@ -1882,7 +1882,7 @@ void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p
|
||||
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_polygon);
|
||||
if (!occluder_poly) {
|
||||
occluder->polygon = RID();
|
||||
ERR_FAIL_COND(!occluder_poly);
|
||||
ERR_FAIL_NULL(occluder_poly);
|
||||
} else {
|
||||
occluder_poly->owners.insert(occluder);
|
||||
occluder->occluder = occluder_poly->occluder;
|
||||
@ -1894,19 +1894,19 @@ void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p
|
||||
|
||||
void RendererCanvasCull::canvas_light_occluder_set_as_sdf_collision(RID p_occluder, bool p_enable) {
|
||||
RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
|
||||
RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
|
||||
occluder->xform = p_xform;
|
||||
}
|
||||
|
||||
void RendererCanvasCull::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
|
||||
RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
|
||||
occluder->light_mask = p_mask;
|
||||
}
|
||||
@ -1922,7 +1922,7 @@ void RendererCanvasCull::canvas_occluder_polygon_initialize(RID p_rid) {
|
||||
|
||||
void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) {
|
||||
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_occluder_polygon);
|
||||
ERR_FAIL_COND(!occluder_poly);
|
||||
ERR_FAIL_NULL(occluder_poly);
|
||||
|
||||
uint32_t pc = p_shape.size();
|
||||
ERR_FAIL_COND(pc < 2);
|
||||
@ -1946,7 +1946,7 @@ void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygo
|
||||
|
||||
void RendererCanvasCull::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, RS::CanvasOccluderPolygonCullMode p_mode) {
|
||||
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_occluder_polygon);
|
||||
ERR_FAIL_COND(!occluder_poly);
|
||||
ERR_FAIL_NULL(occluder_poly);
|
||||
occluder_poly->cull_mode = p_mode;
|
||||
RSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode);
|
||||
for (RendererCanvasRender::LightOccluderInstance *E : occluder_poly->owners) {
|
||||
@ -1983,12 +1983,12 @@ void RendererCanvasCull::canvas_texture_set_texture_repeat(RID p_canvas_texture,
|
||||
|
||||
void RendererCanvasCull::canvas_item_set_default_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) {
|
||||
Item *ci = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!ci);
|
||||
ERR_FAIL_NULL(ci);
|
||||
ci->texture_filter = p_filter;
|
||||
}
|
||||
void RendererCanvasCull::canvas_item_set_default_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) {
|
||||
Item *ci = canvas_item_owner.get_or_null(p_item);
|
||||
ERR_FAIL_COND(!ci);
|
||||
ERR_FAIL_NULL(ci);
|
||||
ci->texture_repeat = p_repeat;
|
||||
}
|
||||
|
||||
@ -2033,11 +2033,11 @@ void RendererCanvasCull::update_visibility_notifiers() {
|
||||
bool RendererCanvasCull::free(RID p_rid) {
|
||||
if (canvas_owner.owns(p_rid)) {
|
||||
Canvas *canvas = canvas_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND_V(!canvas, false);
|
||||
ERR_FAIL_NULL_V(canvas, false);
|
||||
|
||||
while (canvas->viewports.size()) {
|
||||
RendererViewport::Viewport *vp = RSG::viewport->viewport_owner.get_or_null(*canvas->viewports.begin());
|
||||
ERR_FAIL_COND_V(!vp, true);
|
||||
ERR_FAIL_NULL_V(vp, true);
|
||||
|
||||
HashMap<RID, RendererViewport::Viewport::CanvasData>::Iterator E = vp->canvas_map.find(p_rid);
|
||||
ERR_FAIL_COND_V(!E, true);
|
||||
@ -2062,7 +2062,7 @@ bool RendererCanvasCull::free(RID p_rid) {
|
||||
|
||||
} else if (canvas_item_owner.owns(p_rid)) {
|
||||
Item *canvas_item = canvas_item_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND_V(!canvas_item, true);
|
||||
ERR_FAIL_NULL_V(canvas_item, true);
|
||||
|
||||
if (canvas_item->parent.is_valid()) {
|
||||
if (canvas_owner.owns(canvas_item->parent)) {
|
||||
@ -2101,7 +2101,7 @@ bool RendererCanvasCull::free(RID p_rid) {
|
||||
|
||||
} else if (canvas_light_owner.owns(p_rid)) {
|
||||
RendererCanvasRender::Light *canvas_light = canvas_light_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND_V(!canvas_light, true);
|
||||
ERR_FAIL_NULL_V(canvas_light, true);
|
||||
|
||||
if (canvas_light->canvas.is_valid()) {
|
||||
Canvas *canvas = canvas_owner.get_or_null(canvas_light->canvas);
|
||||
@ -2116,7 +2116,7 @@ bool RendererCanvasCull::free(RID p_rid) {
|
||||
|
||||
} else if (canvas_light_occluder_owner.owns(p_rid)) {
|
||||
RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND_V(!occluder, true);
|
||||
ERR_FAIL_NULL_V(occluder, true);
|
||||
|
||||
if (occluder->polygon.is_valid()) {
|
||||
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(occluder->polygon);
|
||||
@ -2134,7 +2134,7 @@ bool RendererCanvasCull::free(RID p_rid) {
|
||||
|
||||
} else if (canvas_light_occluder_polygon_owner.owns(p_rid)) {
|
||||
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND_V(!occluder_poly, true);
|
||||
ERR_FAIL_NULL_V(occluder_poly, true);
|
||||
RSG::canvas_render->free(occluder_poly->occluder);
|
||||
|
||||
while (occluder_poly->owners.size()) {
|
||||
|
@ -72,7 +72,7 @@ Dependency *Fog::fog_volume_get_dependency(RID p_fog_volume) const {
|
||||
|
||||
void Fog::fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) {
|
||||
FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
|
||||
ERR_FAIL_COND(!fog_volume);
|
||||
ERR_FAIL_NULL(fog_volume);
|
||||
|
||||
if (p_shape == fog_volume->shape) {
|
||||
return;
|
||||
@ -84,7 +84,7 @@ void Fog::fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) {
|
||||
|
||||
void Fog::fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) {
|
||||
FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
|
||||
ERR_FAIL_COND(!fog_volume);
|
||||
ERR_FAIL_NULL(fog_volume);
|
||||
|
||||
fog_volume->size = p_size;
|
||||
fog_volume->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
@ -92,27 +92,27 @@ void Fog::fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) {
|
||||
|
||||
void Fog::fog_volume_set_material(RID p_fog_volume, RID p_material) {
|
||||
FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
|
||||
ERR_FAIL_COND(!fog_volume);
|
||||
ERR_FAIL_NULL(fog_volume);
|
||||
fog_volume->material = p_material;
|
||||
}
|
||||
|
||||
RID Fog::fog_volume_get_material(RID p_fog_volume) const {
|
||||
FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
|
||||
ERR_FAIL_COND_V(!fog_volume, RID());
|
||||
ERR_FAIL_NULL_V(fog_volume, RID());
|
||||
|
||||
return fog_volume->material;
|
||||
}
|
||||
|
||||
RS::FogVolumeShape Fog::fog_volume_get_shape(RID p_fog_volume) const {
|
||||
FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
|
||||
ERR_FAIL_COND_V(!fog_volume, RS::FOG_VOLUME_SHAPE_BOX);
|
||||
ERR_FAIL_NULL_V(fog_volume, RS::FOG_VOLUME_SHAPE_BOX);
|
||||
|
||||
return fog_volume->shape;
|
||||
}
|
||||
|
||||
AABB Fog::fog_volume_get_aabb(RID p_fog_volume) const {
|
||||
FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
|
||||
ERR_FAIL_COND_V(!fog_volume, AABB());
|
||||
ERR_FAIL_NULL_V(fog_volume, AABB());
|
||||
|
||||
switch (fog_volume->shape) {
|
||||
case RS::FOG_VOLUME_SHAPE_ELLIPSOID:
|
||||
@ -133,7 +133,7 @@ AABB Fog::fog_volume_get_aabb(RID p_fog_volume) const {
|
||||
|
||||
Vector3 Fog::fog_volume_get_size(RID p_fog_volume) const {
|
||||
const FogVolume *fog_volume = fog_volume_owner.get_or_null(p_fog_volume);
|
||||
ERR_FAIL_COND_V(!fog_volume, Vector3());
|
||||
ERR_FAIL_NULL_V(fog_volume, Vector3());
|
||||
return fog_volume->size;
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ RS::ShaderNativeSourceCode Fog::FogShaderData::get_native_source_code() const {
|
||||
|
||||
Fog::FogShaderData::~FogShaderData() {
|
||||
Fog *fog_singleton = Fog::get_singleton();
|
||||
ERR_FAIL_COND(!fog_singleton);
|
||||
ERR_FAIL_NULL(fog_singleton);
|
||||
//pipeline variants will clear themselves if shader is gone
|
||||
if (version.is_valid()) {
|
||||
fog_singleton->volumetric_fog.shader.version_free(version);
|
||||
@ -627,7 +627,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
|
||||
|
||||
for (int i = 0; i < (int)p_fog_volumes.size(); i++) {
|
||||
FogVolumeInstance *fog_volume_instance = fog_volume_instance_owner.get_or_null(p_fog_volumes[i]);
|
||||
ERR_FAIL_COND(!fog_volume_instance);
|
||||
ERR_FAIL_NULL(fog_volume_instance);
|
||||
RID fog_volume = fog_volume_instance->volume;
|
||||
|
||||
RID fog_material = RendererRD::Fog::get_singleton()->fog_volume_get_material(fog_volume);
|
||||
@ -646,11 +646,11 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
|
||||
material = static_cast<FogMaterialData *>(material_storage->material_get_data(fog_material, RendererRD::MaterialStorage::SHADER_TYPE_FOG));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
FogShaderData *shader_data = material->shader_data;
|
||||
|
||||
ERR_FAIL_COND(!shader_data);
|
||||
ERR_FAIL_NULL(shader_data);
|
||||
|
||||
any_uses_time |= shader_data->uses_time;
|
||||
|
||||
|
@ -257,25 +257,25 @@ public:
|
||||
|
||||
void fog_volume_instance_set_transform(RID p_fog_volume_instance, const Transform3D &p_transform) {
|
||||
Fog::FogVolumeInstance *fvi = fog_volume_instance_owner.get_or_null(p_fog_volume_instance);
|
||||
ERR_FAIL_COND(!fvi);
|
||||
ERR_FAIL_NULL(fvi);
|
||||
fvi->transform = p_transform;
|
||||
}
|
||||
|
||||
void fog_volume_instance_set_active(RID p_fog_volume_instance, bool p_active) {
|
||||
Fog::FogVolumeInstance *fvi = fog_volume_instance_owner.get_or_null(p_fog_volume_instance);
|
||||
ERR_FAIL_COND(!fvi);
|
||||
ERR_FAIL_NULL(fvi);
|
||||
fvi->active = p_active;
|
||||
}
|
||||
|
||||
RID fog_volume_instance_get_volume(RID p_fog_volume_instance) const {
|
||||
Fog::FogVolumeInstance *fvi = fog_volume_instance_owner.get_or_null(p_fog_volume_instance);
|
||||
ERR_FAIL_COND_V(!fvi, RID());
|
||||
ERR_FAIL_NULL_V(fvi, RID());
|
||||
return fvi->volume;
|
||||
}
|
||||
|
||||
Vector3 fog_volume_instance_get_position(RID p_fog_volume_instance) const {
|
||||
Fog::FogVolumeInstance *fvi = fog_volume_instance_owner.get_or_null(p_fog_volume_instance);
|
||||
ERR_FAIL_COND_V(!fvi, Vector3());
|
||||
ERR_FAIL_NULL_V(fvi, Vector3());
|
||||
return fvi->transform.get_origin();
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ void GI::voxel_gi_initialize(RID p_voxel_gi) {
|
||||
|
||||
void GI::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
if (voxel_gi->octree_buffer.is_valid()) {
|
||||
RD::get_singleton()->free(voxel_gi->octree_buffer);
|
||||
@ -191,20 +191,20 @@ void GI::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xfo
|
||||
|
||||
AABB GI::voxel_gi_get_bounds(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, AABB());
|
||||
ERR_FAIL_NULL_V(voxel_gi, AABB());
|
||||
|
||||
return voxel_gi->bounds;
|
||||
}
|
||||
|
||||
Vector3i GI::voxel_gi_get_octree_size(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, Vector3i());
|
||||
ERR_FAIL_NULL_V(voxel_gi, Vector3i());
|
||||
return voxel_gi->octree_size;
|
||||
}
|
||||
|
||||
Vector<uint8_t> GI::voxel_gi_get_octree_cells(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
|
||||
ERR_FAIL_NULL_V(voxel_gi, Vector<uint8_t>());
|
||||
|
||||
if (voxel_gi->octree_buffer.is_valid()) {
|
||||
return RD::get_singleton()->buffer_get_data(voxel_gi->octree_buffer);
|
||||
@ -214,7 +214,7 @@ Vector<uint8_t> GI::voxel_gi_get_octree_cells(RID p_voxel_gi) const {
|
||||
|
||||
Vector<uint8_t> GI::voxel_gi_get_data_cells(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
|
||||
ERR_FAIL_NULL_V(voxel_gi, Vector<uint8_t>());
|
||||
|
||||
if (voxel_gi->data_buffer.is_valid()) {
|
||||
return RD::get_singleton()->buffer_get_data(voxel_gi->data_buffer);
|
||||
@ -224,7 +224,7 @@ Vector<uint8_t> GI::voxel_gi_get_data_cells(RID p_voxel_gi) const {
|
||||
|
||||
Vector<uint8_t> GI::voxel_gi_get_distance_field(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
|
||||
ERR_FAIL_NULL_V(voxel_gi, Vector<uint8_t>());
|
||||
|
||||
if (voxel_gi->data_buffer.is_valid()) {
|
||||
return RD::get_singleton()->texture_get_data(voxel_gi->sdf_texture, 0);
|
||||
@ -234,21 +234,21 @@ Vector<uint8_t> GI::voxel_gi_get_distance_field(RID p_voxel_gi) const {
|
||||
|
||||
Vector<int> GI::voxel_gi_get_level_counts(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, Vector<int>());
|
||||
ERR_FAIL_NULL_V(voxel_gi, Vector<int>());
|
||||
|
||||
return voxel_gi->level_counts;
|
||||
}
|
||||
|
||||
Transform3D GI::voxel_gi_get_to_cell_xform(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, Transform3D());
|
||||
ERR_FAIL_NULL_V(voxel_gi, Transform3D());
|
||||
|
||||
return voxel_gi->to_cell_xform;
|
||||
}
|
||||
|
||||
void GI::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->dynamic_range = p_range;
|
||||
voxel_gi->version++;
|
||||
@ -256,14 +256,14 @@ void GI::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) {
|
||||
|
||||
float GI::voxel_gi_get_dynamic_range(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
|
||||
return voxel_gi->dynamic_range;
|
||||
}
|
||||
|
||||
void GI::voxel_gi_set_propagation(RID p_voxel_gi, float p_range) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->propagation = p_range;
|
||||
voxel_gi->version++;
|
||||
@ -271,72 +271,72 @@ void GI::voxel_gi_set_propagation(RID p_voxel_gi, float p_range) {
|
||||
|
||||
float GI::voxel_gi_get_propagation(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
return voxel_gi->propagation;
|
||||
}
|
||||
|
||||
void GI::voxel_gi_set_energy(RID p_voxel_gi, float p_energy) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->energy = p_energy;
|
||||
}
|
||||
|
||||
float GI::voxel_gi_get_energy(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
return voxel_gi->energy;
|
||||
}
|
||||
|
||||
void GI::voxel_gi_set_baked_exposure_normalization(RID p_voxel_gi, float p_baked_exposure) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->baked_exposure = p_baked_exposure;
|
||||
}
|
||||
|
||||
float GI::voxel_gi_get_baked_exposure_normalization(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
return voxel_gi->baked_exposure;
|
||||
}
|
||||
|
||||
void GI::voxel_gi_set_bias(RID p_voxel_gi, float p_bias) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->bias = p_bias;
|
||||
}
|
||||
|
||||
float GI::voxel_gi_get_bias(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
return voxel_gi->bias;
|
||||
}
|
||||
|
||||
void GI::voxel_gi_set_normal_bias(RID p_voxel_gi, float p_normal_bias) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->normal_bias = p_normal_bias;
|
||||
}
|
||||
|
||||
float GI::voxel_gi_get_normal_bias(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
return voxel_gi->normal_bias;
|
||||
}
|
||||
|
||||
void GI::voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->interior = p_enable;
|
||||
}
|
||||
|
||||
void GI::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->use_two_bounces = p_enable;
|
||||
voxel_gi->version++;
|
||||
@ -344,50 +344,50 @@ void GI::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) {
|
||||
|
||||
bool GI::voxel_gi_is_using_two_bounces(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, false);
|
||||
ERR_FAIL_NULL_V(voxel_gi, false);
|
||||
return voxel_gi->use_two_bounces;
|
||||
}
|
||||
|
||||
bool GI::voxel_gi_is_interior(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
return voxel_gi->interior;
|
||||
}
|
||||
|
||||
uint32_t GI::voxel_gi_get_version(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
return voxel_gi->version;
|
||||
}
|
||||
|
||||
uint32_t GI::voxel_gi_get_data_version(RID p_voxel_gi) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, 0);
|
||||
ERR_FAIL_NULL_V(voxel_gi, 0);
|
||||
return voxel_gi->data_version;
|
||||
}
|
||||
|
||||
RID GI::voxel_gi_get_octree_buffer(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, RID());
|
||||
ERR_FAIL_NULL_V(voxel_gi, RID());
|
||||
return voxel_gi->octree_buffer;
|
||||
}
|
||||
|
||||
RID GI::voxel_gi_get_data_buffer(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, RID());
|
||||
ERR_FAIL_NULL_V(voxel_gi, RID());
|
||||
return voxel_gi->data_buffer;
|
||||
}
|
||||
|
||||
RID GI::voxel_gi_get_sdf_texture(RID p_voxel_gi) {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, RID());
|
||||
ERR_FAIL_NULL_V(voxel_gi, RID());
|
||||
|
||||
return voxel_gi->sdf_texture;
|
||||
}
|
||||
|
||||
Dependency *GI::voxel_gi_get_dependency(RID p_voxel_gi) const {
|
||||
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND_V(!voxel_gi, nullptr);
|
||||
ERR_FAIL_NULL_V(voxel_gi, nullptr);
|
||||
|
||||
return &voxel_gi->dependency;
|
||||
}
|
||||
@ -4054,28 +4054,28 @@ void GI::voxel_gi_instance_free(RID p_rid) {
|
||||
|
||||
void GI::voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) {
|
||||
VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->transform = p_xform;
|
||||
}
|
||||
|
||||
bool GI::voxel_gi_needs_update(RID p_probe) const {
|
||||
VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!voxel_gi, false);
|
||||
ERR_FAIL_NULL_V(voxel_gi, false);
|
||||
|
||||
return voxel_gi->last_probe_version != voxel_gi_get_version(voxel_gi->probe);
|
||||
}
|
||||
|
||||
void GI::voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RenderGeometryInstance *> &p_dynamic_objects) {
|
||||
VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->update(p_update_light_instances, p_light_instances, p_dynamic_objects);
|
||||
}
|
||||
|
||||
void GI::debug_voxel_gi(RID p_voxel_gi, RD::DrawListID p_draw_list, RID p_framebuffer, const Projection &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) {
|
||||
VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_voxel_gi);
|
||||
ERR_FAIL_COND(!voxel_gi);
|
||||
ERR_FAIL_NULL(voxel_gi);
|
||||
|
||||
voxel_gi->debug(p_draw_list, p_framebuffer, p_camera_with_transform, p_lighting, p_emission, p_alpha);
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ public:
|
||||
|
||||
_FORCE_INLINE_ RID voxel_gi_instance_get_texture(RID p_probe) {
|
||||
VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!voxel_gi, RID());
|
||||
ERR_FAIL_NULL_V(voxel_gi, RID());
|
||||
return voxel_gi->texture;
|
||||
};
|
||||
|
||||
|
@ -170,7 +170,7 @@ RS::ShaderNativeSourceCode SkyRD::SkyShaderData::get_native_source_code() const
|
||||
|
||||
SkyRD::SkyShaderData::~SkyShaderData() {
|
||||
RendererSceneRenderRD *scene_singleton = static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton);
|
||||
ERR_FAIL_COND(!scene_singleton);
|
||||
ERR_FAIL_NULL(scene_singleton);
|
||||
//pipeline variants will clear themselves if shader is gone
|
||||
if (version.is_valid()) {
|
||||
scene_singleton->sky.sky_shader.shader.version_free(version);
|
||||
@ -1007,11 +1007,11 @@ void SkyRD::setup_sky(RID p_env, Ref<RenderSceneBuffersRD> p_render_buffers, con
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
shader_data = material->shader_data;
|
||||
|
||||
ERR_FAIL_COND(!shader_data);
|
||||
ERR_FAIL_NULL(shader_data);
|
||||
|
||||
material->set_as_used();
|
||||
|
||||
@ -1220,7 +1220,7 @@ void SkyRD::update_radiance_buffers(Ref<RenderSceneBuffersRD> p_render_buffers,
|
||||
ERR_FAIL_COND(p_env.is_null());
|
||||
|
||||
Sky *sky = get_sky(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_env));
|
||||
ERR_FAIL_COND(!sky);
|
||||
ERR_FAIL_NULL(sky);
|
||||
|
||||
RID sky_material = sky_get_material(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_env));
|
||||
|
||||
@ -1238,11 +1238,11 @@ void SkyRD::update_radiance_buffers(Ref<RenderSceneBuffersRD> p_render_buffers,
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
SkyShaderData *shader_data = material->shader_data;
|
||||
|
||||
ERR_FAIL_COND(!shader_data);
|
||||
ERR_FAIL_NULL(shader_data);
|
||||
|
||||
bool update_single_frame = sky->mode == RS::SKY_MODE_REALTIME || sky->mode == RS::SKY_MODE_QUALITY;
|
||||
RS::SkyMode sky_mode = sky->mode;
|
||||
@ -1401,7 +1401,7 @@ void SkyRD::update_res_buffers(Ref<RenderSceneBuffersRD> p_render_buffers, RID p
|
||||
RS::EnvironmentBG background = RendererSceneRenderRD::get_singleton()->environment_get_background(p_env);
|
||||
|
||||
if (!(background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) || sky) {
|
||||
ERR_FAIL_COND(!sky);
|
||||
ERR_FAIL_NULL(sky);
|
||||
sky_material = sky_get_material(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_env));
|
||||
|
||||
if (sky_material.is_valid()) {
|
||||
@ -1422,10 +1422,10 @@ void SkyRD::update_res_buffers(Ref<RenderSceneBuffersRD> p_render_buffers, RID p
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
SkyShaderData *shader_data = material->shader_data;
|
||||
ERR_FAIL_COND(!shader_data);
|
||||
ERR_FAIL_NULL(shader_data);
|
||||
|
||||
if (!shader_data->uses_quarter_res && !shader_data->uses_half_res) {
|
||||
return;
|
||||
@ -1509,7 +1509,7 @@ void SkyRD::draw_sky(RD::DrawListID p_draw_list, Ref<RenderSceneBuffersRD> p_ren
|
||||
RS::EnvironmentBG background = RendererSceneRenderRD::get_singleton()->environment_get_background(p_env);
|
||||
|
||||
if (!(background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) || sky) {
|
||||
ERR_FAIL_COND(!sky);
|
||||
ERR_FAIL_NULL(sky);
|
||||
sky_material = sky_get_material(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_env));
|
||||
|
||||
if (sky_material.is_valid()) {
|
||||
@ -1530,10 +1530,10 @@ void SkyRD::draw_sky(RD::DrawListID p_draw_list, Ref<RenderSceneBuffersRD> p_ren
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
SkyShaderData *shader_data = material->shader_data;
|
||||
ERR_FAIL_COND(!shader_data);
|
||||
ERR_FAIL_NULL(shader_data);
|
||||
|
||||
material->set_as_used();
|
||||
|
||||
@ -1649,14 +1649,14 @@ void SkyRD::update_dirty_skys() {
|
||||
|
||||
RID SkyRD::sky_get_material(RID p_sky) const {
|
||||
Sky *sky = get_sky(p_sky);
|
||||
ERR_FAIL_COND_V(!sky, RID());
|
||||
ERR_FAIL_NULL_V(sky, RID());
|
||||
|
||||
return sky->material;
|
||||
}
|
||||
|
||||
float SkyRD::sky_get_baked_exposure(RID p_sky) const {
|
||||
Sky *sky = get_sky(p_sky);
|
||||
ERR_FAIL_COND_V(!sky, 1.0);
|
||||
ERR_FAIL_NULL_V(sky, 1.0);
|
||||
|
||||
return sky->baked_exposure;
|
||||
}
|
||||
@ -1675,7 +1675,7 @@ SkyRD::Sky *SkyRD::get_sky(RID p_sky) const {
|
||||
|
||||
void SkyRD::free_sky(RID p_sky) {
|
||||
Sky *sky = get_sky(p_sky);
|
||||
ERR_FAIL_COND(!sky);
|
||||
ERR_FAIL_NULL(sky);
|
||||
|
||||
sky->free();
|
||||
sky_owner.free(p_sky);
|
||||
@ -1683,7 +1683,7 @@ void SkyRD::free_sky(RID p_sky) {
|
||||
|
||||
void SkyRD::sky_set_radiance_size(RID p_sky, int p_radiance_size) {
|
||||
Sky *sky = get_sky(p_sky);
|
||||
ERR_FAIL_COND(!sky);
|
||||
ERR_FAIL_NULL(sky);
|
||||
|
||||
if (sky->set_radiance_size(p_radiance_size)) {
|
||||
invalidate_sky(sky);
|
||||
@ -1692,7 +1692,7 @@ void SkyRD::sky_set_radiance_size(RID p_sky, int p_radiance_size) {
|
||||
|
||||
void SkyRD::sky_set_mode(RID p_sky, RS::SkyMode p_mode) {
|
||||
Sky *sky = get_sky(p_sky);
|
||||
ERR_FAIL_COND(!sky);
|
||||
ERR_FAIL_NULL(sky);
|
||||
|
||||
if (sky->set_mode(p_mode)) {
|
||||
invalidate_sky(sky);
|
||||
@ -1701,7 +1701,7 @@ void SkyRD::sky_set_mode(RID p_sky, RS::SkyMode p_mode) {
|
||||
|
||||
void SkyRD::sky_set_material(RID p_sky, RID p_material) {
|
||||
Sky *sky = get_sky(p_sky);
|
||||
ERR_FAIL_COND(!sky);
|
||||
ERR_FAIL_NULL(sky);
|
||||
|
||||
if (sky->set_material(p_material)) {
|
||||
invalidate_sky(sky);
|
||||
@ -1710,7 +1710,7 @@ void SkyRD::sky_set_material(RID p_sky, RID p_material) {
|
||||
|
||||
Ref<Image> SkyRD::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) {
|
||||
Sky *sky = get_sky(p_sky);
|
||||
ERR_FAIL_COND_V(!sky, Ref<Image>());
|
||||
ERR_FAIL_NULL_V(sky, Ref<Image>());
|
||||
|
||||
update_dirty_skys();
|
||||
|
||||
@ -1719,7 +1719,7 @@ Ref<Image> SkyRD::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irrad
|
||||
|
||||
RID SkyRD::sky_get_radiance_texture_rd(RID p_sky) const {
|
||||
Sky *sky = get_sky(p_sky);
|
||||
ERR_FAIL_COND_V(!sky, RID());
|
||||
ERR_FAIL_NULL_V(sky, RID());
|
||||
|
||||
return sky->radiance;
|
||||
}
|
||||
|
@ -3716,7 +3716,7 @@ void RenderForwardClustered::_geometry_instance_add_surface(GeometryInstanceForw
|
||||
m_src = scene_shader.default_material;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
_geometry_instance_add_surface_with_material_chain(ginstance, p_surface, material, m_src, p_mesh);
|
||||
|
||||
@ -3979,7 +3979,7 @@ void RenderForwardClustered::GeometryInstanceForwardClustered::set_lightmap_capt
|
||||
|
||||
void RenderForwardClustered::geometry_instance_free(RenderGeometryInstance *p_geometry_instance) {
|
||||
GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance);
|
||||
ERR_FAIL_COND(!ginstance);
|
||||
ERR_FAIL_NULL(ginstance);
|
||||
if (ginstance->lightmap_sh != nullptr) {
|
||||
geometry_instance_lightmap_sh.free(ginstance->lightmap_sh);
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ SceneShaderForwardClustered::ShaderData::ShaderData() :
|
||||
|
||||
SceneShaderForwardClustered::ShaderData::~ShaderData() {
|
||||
SceneShaderForwardClustered *shader_singleton = (SceneShaderForwardClustered *)SceneShaderForwardClustered::singleton;
|
||||
ERR_FAIL_COND(!shader_singleton);
|
||||
ERR_FAIL_NULL(shader_singleton);
|
||||
//pipeline variants will clear themselves if shader is gone
|
||||
if (version.is_valid()) {
|
||||
shader_singleton->shader.version_free(version);
|
||||
|
@ -2246,7 +2246,7 @@ void RenderForwardMobile::GeometryInstanceForwardMobile::set_lightmap_capture(co
|
||||
|
||||
void RenderForwardMobile::geometry_instance_free(RenderGeometryInstance *p_geometry_instance) {
|
||||
GeometryInstanceForwardMobile *ginstance = static_cast<GeometryInstanceForwardMobile *>(p_geometry_instance);
|
||||
ERR_FAIL_COND(!ginstance);
|
||||
ERR_FAIL_NULL(ginstance);
|
||||
if (ginstance->lightmap_sh != nullptr) {
|
||||
geometry_instance_lightmap_sh.free(ginstance->lightmap_sh);
|
||||
}
|
||||
@ -2473,7 +2473,7 @@ void RenderForwardMobile::_geometry_instance_add_surface(GeometryInstanceForward
|
||||
m_src = scene_shader.default_material;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
_geometry_instance_add_surface_with_material_chain(ginstance, p_surface, material, m_src, p_mesh);
|
||||
|
||||
|
@ -364,7 +364,7 @@ SceneShaderForwardMobile::ShaderData::ShaderData() :
|
||||
|
||||
SceneShaderForwardMobile::ShaderData::~ShaderData() {
|
||||
SceneShaderForwardMobile *shader_singleton = (SceneShaderForwardMobile *)SceneShaderForwardMobile::singleton;
|
||||
ERR_FAIL_COND(!shader_singleton);
|
||||
ERR_FAIL_NULL(shader_singleton);
|
||||
//pipeline variants will clear themselves if shader is gone
|
||||
if (version.is_valid()) {
|
||||
shader_singleton->shader.version_free(version);
|
||||
|
@ -329,7 +329,7 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve
|
||||
|
||||
void RendererCanvasRenderRD::free_polygon(PolygonID p_polygon) {
|
||||
PolygonBuffers *pb_ptr = polygon_buffers.polygons.getptr(p_polygon);
|
||||
ERR_FAIL_COND(!pb_ptr);
|
||||
ERR_FAIL_NULL(pb_ptr);
|
||||
|
||||
PolygonBuffers &pb = *pb_ptr;
|
||||
|
||||
@ -1561,7 +1561,7 @@ void RendererCanvasRenderRD::light_set_texture(RID p_rid, RID p_texture) {
|
||||
RendererRD::TextureStorage *texture_storage = RendererRD::TextureStorage::get_singleton();
|
||||
|
||||
CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND(!cl);
|
||||
ERR_FAIL_NULL(cl);
|
||||
if (cl->texture == p_texture) {
|
||||
return;
|
||||
}
|
||||
@ -1580,7 +1580,7 @@ void RendererCanvasRenderRD::light_set_texture(RID p_rid, RID p_texture) {
|
||||
|
||||
void RendererCanvasRenderRD::light_set_use_shadow(RID p_rid, bool p_enable) {
|
||||
CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND(!cl);
|
||||
ERR_FAIL_NULL(cl);
|
||||
|
||||
cl->shadow.enabled = p_enable;
|
||||
}
|
||||
@ -1849,7 +1849,7 @@ RID RendererCanvasRenderRD::occluder_polygon_create() {
|
||||
|
||||
void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) {
|
||||
OccluderPolygon *oc = occluder_polygon_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!oc);
|
||||
ERR_FAIL_NULL(oc);
|
||||
|
||||
Vector<Vector2> lines;
|
||||
|
||||
@ -2020,7 +2020,7 @@ void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Ve
|
||||
|
||||
void RendererCanvasRenderRD::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
|
||||
OccluderPolygon *oc = occluder_polygon_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!oc);
|
||||
ERR_FAIL_NULL(oc);
|
||||
oc->cull_mode = p_mode;
|
||||
}
|
||||
|
||||
@ -2250,7 +2250,7 @@ RS::ShaderNativeSourceCode RendererCanvasRenderRD::CanvasShaderData::get_native_
|
||||
|
||||
RendererCanvasRenderRD::CanvasShaderData::~CanvasShaderData() {
|
||||
RendererCanvasRenderRD *canvas_singleton = static_cast<RendererCanvasRenderRD *>(RendererCanvasRender::singleton);
|
||||
ERR_FAIL_COND(!canvas_singleton);
|
||||
ERR_FAIL_NULL(canvas_singleton);
|
||||
//pipeline variants will clear themselves if shader is gone
|
||||
if (version.is_valid()) {
|
||||
canvas_singleton->shader.canvas_shader.version_free(version);
|
||||
@ -2704,7 +2704,7 @@ void fragment() {
|
||||
bool RendererCanvasRenderRD::free(RID p_rid) {
|
||||
if (canvas_light_owner.owns(p_rid)) {
|
||||
CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND_V(!cl, false);
|
||||
ERR_FAIL_NULL_V(cl, false);
|
||||
light_set_use_shadow(p_rid, false);
|
||||
canvas_light_owner.free(p_rid);
|
||||
} else if (occluder_polygon_owner.owns(p_rid)) {
|
||||
|
@ -314,7 +314,7 @@ void ShaderRD::_compile_variant(uint32_t p_variant, const CompileData *p_data) {
|
||||
RS::ShaderNativeSourceCode ShaderRD::version_get_native_source_code(RID p_version) {
|
||||
Version *version = version_owner.get_or_null(p_version);
|
||||
RS::ShaderNativeSourceCode source_code;
|
||||
ERR_FAIL_COND_V(!version, source_code);
|
||||
ERR_FAIL_NULL_V(version, source_code);
|
||||
|
||||
source_code.versions.resize(variant_defines.size());
|
||||
|
||||
@ -567,7 +567,7 @@ void ShaderRD::version_set_code(RID p_version, const HashMap<String, String> &p_
|
||||
ERR_FAIL_COND(is_compute);
|
||||
|
||||
Version *version = version_owner.get_or_null(p_version);
|
||||
ERR_FAIL_COND(!version);
|
||||
ERR_FAIL_NULL(version);
|
||||
version->vertex_globals = p_vertex_globals.utf8();
|
||||
version->fragment_globals = p_fragment_globals.utf8();
|
||||
version->uniforms = p_uniforms.utf8();
|
||||
@ -599,7 +599,7 @@ void ShaderRD::version_set_compute_code(RID p_version, const HashMap<String, Str
|
||||
ERR_FAIL_COND(!is_compute);
|
||||
|
||||
Version *version = version_owner.get_or_null(p_version);
|
||||
ERR_FAIL_COND(!version);
|
||||
ERR_FAIL_NULL(version);
|
||||
|
||||
version->compute_globals = p_compute_globals.utf8();
|
||||
version->uniforms = p_uniforms.utf8();
|
||||
@ -630,7 +630,7 @@ void ShaderRD::version_set_compute_code(RID p_version, const HashMap<String, Str
|
||||
|
||||
bool ShaderRD::version_is_valid(RID p_version) {
|
||||
Version *version = version_owner.get_or_null(p_version);
|
||||
ERR_FAIL_COND_V(!version, false);
|
||||
ERR_FAIL_NULL_V(version, false);
|
||||
|
||||
if (version->dirty) {
|
||||
_initialize_version(version);
|
||||
|
@ -162,7 +162,7 @@ public:
|
||||
ERR_FAIL_COND_V(!variants_enabled[p_variant], RID());
|
||||
|
||||
Version *version = version_owner.get_or_null(p_version);
|
||||
ERR_FAIL_COND_V(!version, RID());
|
||||
ERR_FAIL_NULL_V(version, RID());
|
||||
|
||||
if (version->dirty) {
|
||||
_initialize_version(version);
|
||||
|
@ -174,14 +174,14 @@ void LightStorage::light_free(RID p_rid) {
|
||||
|
||||
void LightStorage::light_set_color(RID p_light, const Color &p_color) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->color = p_color;
|
||||
}
|
||||
|
||||
void LightStorage::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
|
||||
|
||||
if (light->param[p_param] == p_value) {
|
||||
@ -216,7 +216,7 @@ void LightStorage::light_set_param(RID p_light, RS::LightParam p_param, float p_
|
||||
|
||||
void LightStorage::light_set_shadow(RID p_light, bool p_enabled) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
light->shadow = p_enabled;
|
||||
|
||||
light->version++;
|
||||
@ -226,7 +226,7 @@ void LightStorage::light_set_shadow(RID p_light, bool p_enabled) {
|
||||
void LightStorage::light_set_projector(RID p_light, RID p_texture) {
|
||||
TextureStorage *texture_storage = TextureStorage::get_singleton();
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
if (light->projector == p_texture) {
|
||||
return;
|
||||
@ -250,14 +250,14 @@ void LightStorage::light_set_projector(RID p_light, RID p_texture) {
|
||||
|
||||
void LightStorage::light_set_negative(RID p_light, bool p_enable) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->negative = p_enable;
|
||||
}
|
||||
|
||||
void LightStorage::light_set_cull_mask(RID p_light, uint32_t p_mask) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->cull_mask = p_mask;
|
||||
|
||||
@ -267,7 +267,7 @@ void LightStorage::light_set_cull_mask(RID p_light, uint32_t p_mask) {
|
||||
|
||||
void LightStorage::light_set_distance_fade(RID p_light, bool p_enabled, float p_begin, float p_shadow, float p_length) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->distance_fade = p_enabled;
|
||||
light->distance_fade_begin = p_begin;
|
||||
@ -277,7 +277,7 @@ void LightStorage::light_set_distance_fade(RID p_light, bool p_enabled, float p_
|
||||
|
||||
void LightStorage::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->reverse_cull = p_enabled;
|
||||
|
||||
@ -287,7 +287,7 @@ void LightStorage::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled)
|
||||
|
||||
void LightStorage::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->bake_mode = p_bake_mode;
|
||||
|
||||
@ -297,7 +297,7 @@ void LightStorage::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mod
|
||||
|
||||
void LightStorage::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->max_sdfgi_cascade = p_cascade;
|
||||
|
||||
@ -307,7 +307,7 @@ void LightStorage::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade)
|
||||
|
||||
void LightStorage::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->omni_shadow_mode = p_mode;
|
||||
|
||||
@ -317,14 +317,14 @@ void LightStorage::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMo
|
||||
|
||||
RS::LightOmniShadowMode LightStorage::light_omni_get_shadow_mode(RID p_light) {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE);
|
||||
ERR_FAIL_NULL_V(light, RS::LIGHT_OMNI_SHADOW_CUBE);
|
||||
|
||||
return light->omni_shadow_mode;
|
||||
}
|
||||
|
||||
void LightStorage::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->directional_shadow_mode = p_mode;
|
||||
light->version++;
|
||||
@ -333,7 +333,7 @@ void LightStorage::light_directional_set_shadow_mode(RID p_light, RS::LightDirec
|
||||
|
||||
void LightStorage::light_directional_set_blend_splits(RID p_light, bool p_enable) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->directional_blend_splits = p_enable;
|
||||
light->version++;
|
||||
@ -342,63 +342,63 @@ void LightStorage::light_directional_set_blend_splits(RID p_light, bool p_enable
|
||||
|
||||
bool LightStorage::light_directional_get_blend_splits(RID p_light) const {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, false);
|
||||
ERR_FAIL_NULL_V(light, false);
|
||||
|
||||
return light->directional_blend_splits;
|
||||
}
|
||||
|
||||
void LightStorage::light_directional_set_sky_mode(RID p_light, RS::LightDirectionalSkyMode p_mode) {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
|
||||
light->directional_sky_mode = p_mode;
|
||||
}
|
||||
|
||||
RS::LightDirectionalSkyMode LightStorage::light_directional_get_sky_mode(RID p_light) const {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);
|
||||
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);
|
||||
|
||||
return light->directional_sky_mode;
|
||||
}
|
||||
|
||||
RS::LightDirectionalShadowMode LightStorage::light_directional_get_shadow_mode(RID p_light) {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
|
||||
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
|
||||
|
||||
return light->directional_shadow_mode;
|
||||
}
|
||||
|
||||
uint32_t LightStorage::light_get_max_sdfgi_cascade(RID p_light) {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, 0);
|
||||
ERR_FAIL_NULL_V(light, 0);
|
||||
|
||||
return light->max_sdfgi_cascade;
|
||||
}
|
||||
|
||||
RS::LightBakeMode LightStorage::light_get_bake_mode(RID p_light) {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LIGHT_BAKE_DISABLED);
|
||||
ERR_FAIL_NULL_V(light, RS::LIGHT_BAKE_DISABLED);
|
||||
|
||||
return light->bake_mode;
|
||||
}
|
||||
|
||||
uint64_t LightStorage::light_get_version(RID p_light) const {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, 0);
|
||||
ERR_FAIL_NULL_V(light, 0);
|
||||
|
||||
return light->version;
|
||||
}
|
||||
|
||||
uint32_t LightStorage::light_get_cull_mask(RID p_light) const {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, 0);
|
||||
ERR_FAIL_NULL_V(light, 0);
|
||||
|
||||
return light->cull_mask;
|
||||
}
|
||||
|
||||
AABB LightStorage::light_get_aabb(RID p_light) const {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, AABB());
|
||||
ERR_FAIL_NULL_V(light, AABB());
|
||||
|
||||
switch (light->type) {
|
||||
case RS::LIGHT_SPOT: {
|
||||
@ -471,21 +471,21 @@ void LightStorage::light_instance_free(RID p_light) {
|
||||
|
||||
void LightStorage::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) {
|
||||
LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
|
||||
ERR_FAIL_COND(!light_instance);
|
||||
ERR_FAIL_NULL(light_instance);
|
||||
|
||||
light_instance->transform = p_transform;
|
||||
}
|
||||
|
||||
void LightStorage::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) {
|
||||
LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
|
||||
ERR_FAIL_COND(!light_instance);
|
||||
ERR_FAIL_NULL(light_instance);
|
||||
|
||||
light_instance->aabb = p_aabb;
|
||||
}
|
||||
|
||||
void LightStorage::light_instance_set_shadow_transform(RID p_light_instance, const Projection &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) {
|
||||
LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
|
||||
ERR_FAIL_COND(!light_instance);
|
||||
ERR_FAIL_NULL(light_instance);
|
||||
|
||||
ERR_FAIL_INDEX(p_pass, 6);
|
||||
|
||||
@ -501,7 +501,7 @@ void LightStorage::light_instance_set_shadow_transform(RID p_light_instance, con
|
||||
|
||||
void LightStorage::light_instance_mark_visible(RID p_light_instance) {
|
||||
LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
|
||||
ERR_FAIL_COND(!light_instance);
|
||||
ERR_FAIL_NULL(light_instance);
|
||||
|
||||
light_instance->last_scene_pass = RendererSceneRenderRD::get_singleton()->get_scene_pass();
|
||||
}
|
||||
@ -1026,7 +1026,7 @@ void LightStorage::reflection_probe_free(RID p_rid) {
|
||||
|
||||
void LightStorage::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->update_mode = p_mode;
|
||||
reflection_probe->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
||||
@ -1034,35 +1034,35 @@ void LightStorage::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionP
|
||||
|
||||
void LightStorage::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->intensity = p_intensity;
|
||||
}
|
||||
|
||||
void LightStorage::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->ambient_mode = p_mode;
|
||||
}
|
||||
|
||||
void LightStorage::reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->ambient_color = p_color;
|
||||
}
|
||||
|
||||
void LightStorage::reflection_probe_set_ambient_energy(RID p_probe, float p_energy) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->ambient_color_energy = p_energy;
|
||||
}
|
||||
|
||||
void LightStorage::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->max_distance = p_distance;
|
||||
|
||||
@ -1071,7 +1071,7 @@ void LightStorage::reflection_probe_set_max_distance(RID p_probe, float p_distan
|
||||
|
||||
void LightStorage::reflection_probe_set_size(RID p_probe, const Vector3 &p_size) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
if (reflection_probe->size == p_size) {
|
||||
return;
|
||||
@ -1082,7 +1082,7 @@ void LightStorage::reflection_probe_set_size(RID p_probe, const Vector3 &p_size)
|
||||
|
||||
void LightStorage::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->origin_offset = p_offset;
|
||||
reflection_probe->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
||||
@ -1090,7 +1090,7 @@ void LightStorage::reflection_probe_set_origin_offset(RID p_probe, const Vector3
|
||||
|
||||
void LightStorage::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->interior = p_enable;
|
||||
reflection_probe->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
||||
@ -1098,14 +1098,14 @@ void LightStorage::reflection_probe_set_as_interior(RID p_probe, bool p_enable)
|
||||
|
||||
void LightStorage::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->box_projection = p_enable;
|
||||
}
|
||||
|
||||
void LightStorage::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->enable_shadows = p_enable;
|
||||
reflection_probe->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
||||
@ -1113,7 +1113,7 @@ void LightStorage::reflection_probe_set_enable_shadows(RID p_probe, bool p_enabl
|
||||
|
||||
void LightStorage::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->cull_mask = p_layers;
|
||||
reflection_probe->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
||||
@ -1121,7 +1121,7 @@ void LightStorage::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers
|
||||
|
||||
void LightStorage::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
ERR_FAIL_COND(p_resolution < 32);
|
||||
|
||||
reflection_probe->resolution = p_resolution;
|
||||
@ -1129,7 +1129,7 @@ void LightStorage::reflection_probe_set_resolution(RID p_probe, int p_resolution
|
||||
|
||||
void LightStorage::reflection_probe_set_mesh_lod_threshold(RID p_probe, float p_ratio) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->mesh_lod_threshold = p_ratio;
|
||||
|
||||
@ -1138,14 +1138,14 @@ void LightStorage::reflection_probe_set_mesh_lod_threshold(RID p_probe, float p_
|
||||
|
||||
void LightStorage::reflection_probe_set_baked_exposure(RID p_probe, float p_exposure) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
ERR_FAIL_NULL(reflection_probe);
|
||||
|
||||
reflection_probe->baked_exposure = p_exposure;
|
||||
}
|
||||
|
||||
AABB LightStorage::reflection_probe_get_aabb(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, AABB());
|
||||
ERR_FAIL_NULL_V(reflection_probe, AABB());
|
||||
|
||||
AABB aabb;
|
||||
aabb.position = -reflection_probe->size / 2;
|
||||
@ -1156,103 +1156,103 @@ AABB LightStorage::reflection_probe_get_aabb(RID p_probe) const {
|
||||
|
||||
RS::ReflectionProbeUpdateMode LightStorage::reflection_probe_get_update_mode(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
|
||||
ERR_FAIL_NULL_V(reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
|
||||
|
||||
return reflection_probe->update_mode;
|
||||
}
|
||||
|
||||
uint32_t LightStorage::reflection_probe_get_cull_mask(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
ERR_FAIL_NULL_V(reflection_probe, 0);
|
||||
|
||||
return reflection_probe->cull_mask;
|
||||
}
|
||||
|
||||
Vector3 LightStorage::reflection_probe_get_size(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, Vector3());
|
||||
ERR_FAIL_NULL_V(reflection_probe, Vector3());
|
||||
|
||||
return reflection_probe->size;
|
||||
}
|
||||
|
||||
Vector3 LightStorage::reflection_probe_get_origin_offset(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, Vector3());
|
||||
ERR_FAIL_NULL_V(reflection_probe, Vector3());
|
||||
|
||||
return reflection_probe->origin_offset;
|
||||
}
|
||||
|
||||
bool LightStorage::reflection_probe_renders_shadows(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, false);
|
||||
ERR_FAIL_NULL_V(reflection_probe, false);
|
||||
|
||||
return reflection_probe->enable_shadows;
|
||||
}
|
||||
|
||||
float LightStorage::reflection_probe_get_origin_max_distance(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
ERR_FAIL_NULL_V(reflection_probe, 0);
|
||||
|
||||
return reflection_probe->max_distance;
|
||||
}
|
||||
|
||||
float LightStorage::reflection_probe_get_mesh_lod_threshold(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
ERR_FAIL_NULL_V(reflection_probe, 0);
|
||||
|
||||
return reflection_probe->mesh_lod_threshold;
|
||||
}
|
||||
|
||||
int LightStorage::reflection_probe_get_resolution(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
ERR_FAIL_NULL_V(reflection_probe, 0);
|
||||
|
||||
return reflection_probe->resolution;
|
||||
}
|
||||
|
||||
float LightStorage::reflection_probe_get_baked_exposure(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 1.0);
|
||||
ERR_FAIL_NULL_V(reflection_probe, 1.0);
|
||||
|
||||
return reflection_probe->baked_exposure;
|
||||
}
|
||||
|
||||
float LightStorage::reflection_probe_get_intensity(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
ERR_FAIL_NULL_V(reflection_probe, 0);
|
||||
|
||||
return reflection_probe->intensity;
|
||||
}
|
||||
|
||||
bool LightStorage::reflection_probe_is_interior(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, false);
|
||||
ERR_FAIL_NULL_V(reflection_probe, false);
|
||||
|
||||
return reflection_probe->interior;
|
||||
}
|
||||
|
||||
bool LightStorage::reflection_probe_is_box_projection(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, false);
|
||||
ERR_FAIL_NULL_V(reflection_probe, false);
|
||||
|
||||
return reflection_probe->box_projection;
|
||||
}
|
||||
|
||||
RS::ReflectionProbeAmbientMode LightStorage::reflection_probe_get_ambient_mode(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_AMBIENT_DISABLED);
|
||||
ERR_FAIL_NULL_V(reflection_probe, RS::REFLECTION_PROBE_AMBIENT_DISABLED);
|
||||
return reflection_probe->ambient_mode;
|
||||
}
|
||||
|
||||
Color LightStorage::reflection_probe_get_ambient_color(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, Color());
|
||||
ERR_FAIL_NULL_V(reflection_probe, Color());
|
||||
|
||||
return reflection_probe->ambient_color;
|
||||
}
|
||||
float LightStorage::reflection_probe_get_ambient_color_energy(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
ERR_FAIL_NULL_V(reflection_probe, 0);
|
||||
|
||||
return reflection_probe->ambient_color_energy;
|
||||
}
|
||||
@ -1286,7 +1286,7 @@ void LightStorage::reflection_atlas_free(RID p_ref_atlas) {
|
||||
|
||||
void LightStorage::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {
|
||||
ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(p_ref_atlas);
|
||||
ERR_FAIL_COND(!ra);
|
||||
ERR_FAIL_NULL(ra);
|
||||
|
||||
if (ra->size == p_reflection_size && ra->count == p_reflection_count) {
|
||||
return; //no changes
|
||||
@ -1325,7 +1325,7 @@ void LightStorage::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_s
|
||||
|
||||
int LightStorage::reflection_atlas_get_size(RID p_ref_atlas) const {
|
||||
ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(p_ref_atlas);
|
||||
ERR_FAIL_COND_V(!ra, 0);
|
||||
ERR_FAIL_NULL_V(ra, 0);
|
||||
|
||||
return ra->size;
|
||||
}
|
||||
@ -1349,7 +1349,7 @@ void LightStorage::reflection_probe_instance_free(RID p_instance) {
|
||||
|
||||
void LightStorage::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!rpi);
|
||||
ERR_FAIL_NULL(rpi);
|
||||
|
||||
rpi->transform = p_transform;
|
||||
rpi->dirty = true;
|
||||
@ -1357,13 +1357,13 @@ void LightStorage::reflection_probe_instance_set_transform(RID p_instance, const
|
||||
|
||||
void LightStorage::reflection_probe_release_atlas_index(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!rpi);
|
||||
ERR_FAIL_NULL(rpi);
|
||||
|
||||
if (rpi->atlas.is_null()) {
|
||||
return; //nothing to release
|
||||
}
|
||||
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
|
||||
ERR_FAIL_COND(!atlas);
|
||||
ERR_FAIL_NULL(atlas);
|
||||
ERR_FAIL_INDEX(rpi->atlas_index, atlas->reflections.size());
|
||||
atlas->reflections.write[rpi->atlas_index].owner = RID();
|
||||
|
||||
@ -1375,7 +1375,7 @@ void LightStorage::reflection_probe_release_atlas_index(RID p_instance) {
|
||||
|
||||
bool LightStorage::reflection_probe_instance_needs_redraw(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, false);
|
||||
ERR_FAIL_NULL_V(rpi, false);
|
||||
|
||||
if (rpi->rendering) {
|
||||
return false;
|
||||
@ -1394,7 +1394,7 @@ bool LightStorage::reflection_probe_instance_needs_redraw(RID p_instance) {
|
||||
|
||||
bool LightStorage::reflection_probe_instance_has_reflection(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, false);
|
||||
ERR_FAIL_NULL_V(rpi, false);
|
||||
|
||||
return rpi->atlas.is_valid();
|
||||
}
|
||||
@ -1402,10 +1402,10 @@ bool LightStorage::reflection_probe_instance_has_reflection(RID p_instance) {
|
||||
bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
|
||||
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(p_reflection_atlas);
|
||||
|
||||
ERR_FAIL_COND_V(!atlas, false);
|
||||
ERR_FAIL_NULL_V(atlas, false);
|
||||
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, false);
|
||||
ERR_FAIL_NULL_V(rpi, false);
|
||||
|
||||
if (atlas->render_buffers.is_null()) {
|
||||
atlas->render_buffers.instantiate();
|
||||
@ -1511,14 +1511,14 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
|
||||
|
||||
Ref<RenderSceneBuffers> LightStorage::reflection_probe_atlas_get_render_buffers(RID p_reflection_atlas) {
|
||||
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(p_reflection_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, Ref<RenderSceneBuffersRD>());
|
||||
ERR_FAIL_NULL_V(atlas, Ref<RenderSceneBuffersRD>());
|
||||
|
||||
return atlas->render_buffers;
|
||||
}
|
||||
|
||||
bool LightStorage::reflection_probe_instance_postprocess_step(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, false);
|
||||
ERR_FAIL_NULL_V(rpi, false);
|
||||
ERR_FAIL_COND_V(!rpi->rendering, false);
|
||||
ERR_FAIL_COND_V(rpi->atlas.is_null(), false);
|
||||
|
||||
@ -1569,30 +1569,30 @@ bool LightStorage::reflection_probe_instance_postprocess_step(RID p_instance) {
|
||||
|
||||
uint32_t LightStorage::reflection_probe_instance_get_resolution(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, 0);
|
||||
ERR_FAIL_NULL_V(rpi, 0);
|
||||
|
||||
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
|
||||
ERR_FAIL_COND_V(!atlas, 0);
|
||||
ERR_FAIL_NULL_V(atlas, 0);
|
||||
return atlas->size;
|
||||
}
|
||||
|
||||
RID LightStorage::reflection_probe_instance_get_framebuffer(RID p_instance, int p_index) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, RID());
|
||||
ERR_FAIL_NULL_V(rpi, RID());
|
||||
ERR_FAIL_INDEX_V(p_index, 6, RID());
|
||||
|
||||
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
|
||||
ERR_FAIL_COND_V(!atlas, RID());
|
||||
ERR_FAIL_NULL_V(atlas, RID());
|
||||
return atlas->reflections[rpi->atlas_index].fbs[p_index];
|
||||
}
|
||||
|
||||
RID LightStorage::reflection_probe_instance_get_depth_framebuffer(RID p_instance, int p_index) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, RID());
|
||||
ERR_FAIL_NULL_V(rpi, RID());
|
||||
ERR_FAIL_INDEX_V(p_index, 6, RID());
|
||||
|
||||
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
|
||||
ERR_FAIL_COND_V(!atlas, RID());
|
||||
ERR_FAIL_NULL_V(atlas, RID());
|
||||
return atlas->depth_fb;
|
||||
}
|
||||
|
||||
@ -1747,7 +1747,7 @@ void LightStorage::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_use
|
||||
TextureStorage *texture_storage = TextureStorage::get_singleton();
|
||||
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND(!lm);
|
||||
ERR_FAIL_NULL(lm);
|
||||
|
||||
lightmap_array_version++;
|
||||
|
||||
@ -1795,19 +1795,19 @@ void LightStorage::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_use
|
||||
|
||||
void LightStorage::lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND(!lm);
|
||||
ERR_FAIL_NULL(lm);
|
||||
lm->bounds = p_bounds;
|
||||
}
|
||||
|
||||
void LightStorage::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND(!lm);
|
||||
ERR_FAIL_NULL(lm);
|
||||
lm->interior = p_interior;
|
||||
}
|
||||
|
||||
void LightStorage::lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND(!lm);
|
||||
ERR_FAIL_NULL(lm);
|
||||
|
||||
if (p_points.size()) {
|
||||
ERR_FAIL_COND(p_points.size() * 9 != p_point_sh.size());
|
||||
@ -1823,33 +1823,33 @@ void LightStorage::lightmap_set_probe_capture_data(RID p_lightmap, const PackedV
|
||||
|
||||
void LightStorage::lightmap_set_baked_exposure_normalization(RID p_lightmap, float p_exposure) {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND(!lm);
|
||||
ERR_FAIL_NULL(lm);
|
||||
|
||||
lm->baked_exposure = p_exposure;
|
||||
}
|
||||
|
||||
PackedVector3Array LightStorage::lightmap_get_probe_capture_points(RID p_lightmap) const {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND_V(!lm, PackedVector3Array());
|
||||
ERR_FAIL_NULL_V(lm, PackedVector3Array());
|
||||
|
||||
return lm->points;
|
||||
}
|
||||
|
||||
PackedColorArray LightStorage::lightmap_get_probe_capture_sh(RID p_lightmap) const {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND_V(!lm, PackedColorArray());
|
||||
ERR_FAIL_NULL_V(lm, PackedColorArray());
|
||||
return lm->point_sh;
|
||||
}
|
||||
|
||||
PackedInt32Array LightStorage::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND_V(!lm, PackedInt32Array());
|
||||
ERR_FAIL_NULL_V(lm, PackedInt32Array());
|
||||
return lm->tetrahedra;
|
||||
}
|
||||
|
||||
PackedInt32Array LightStorage::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND_V(!lm, PackedInt32Array());
|
||||
ERR_FAIL_NULL_V(lm, PackedInt32Array());
|
||||
return lm->bsp_tree;
|
||||
}
|
||||
|
||||
@ -1866,7 +1866,7 @@ Dependency *LightStorage::lightmap_get_dependency(RID p_lightmap) const {
|
||||
|
||||
void LightStorage::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND(!lm);
|
||||
ERR_FAIL_NULL(lm);
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
r_sh[i] = Color(0, 0, 0, 0);
|
||||
@ -1916,13 +1916,13 @@ void LightStorage::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point,
|
||||
|
||||
bool LightStorage::lightmap_is_interior(RID p_lightmap) const {
|
||||
const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND_V(!lm, false);
|
||||
ERR_FAIL_NULL_V(lm, false);
|
||||
return lm->interior;
|
||||
}
|
||||
|
||||
AABB LightStorage::lightmap_get_aabb(RID p_lightmap) const {
|
||||
const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND_V(!lm, AABB());
|
||||
ERR_FAIL_NULL_V(lm, AABB());
|
||||
return lm->bounds;
|
||||
}
|
||||
|
||||
@ -1940,7 +1940,7 @@ void LightStorage::lightmap_instance_free(RID p_lightmap) {
|
||||
|
||||
void LightStorage::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) {
|
||||
LightmapInstance *li = lightmap_instance_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND(!li);
|
||||
ERR_FAIL_NULL(li);
|
||||
li->transform = p_transform;
|
||||
}
|
||||
|
||||
@ -1972,7 +1972,7 @@ void LightStorage::_update_shadow_atlas(ShadowAtlas *shadow_atlas) {
|
||||
|
||||
void LightStorage::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) {
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND(!shadow_atlas);
|
||||
ERR_FAIL_NULL(shadow_atlas);
|
||||
ERR_FAIL_COND(p_size < 0);
|
||||
p_size = next_power_of_2(p_size);
|
||||
|
||||
@ -2007,7 +2007,7 @@ void LightStorage::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits
|
||||
|
||||
void LightStorage::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND(!shadow_atlas);
|
||||
ERR_FAIL_NULL(shadow_atlas);
|
||||
ERR_FAIL_INDEX(p_quadrant, 4);
|
||||
ERR_FAIL_INDEX(p_subdivision, 16384);
|
||||
|
||||
@ -2196,10 +2196,10 @@ bool LightStorage::_shadow_atlas_find_omni_shadows(ShadowAtlas *shadow_atlas, in
|
||||
|
||||
bool LightStorage::shadow_atlas_update_light(RID p_atlas, RID p_light_instance, float p_coverage, uint64_t p_light_version) {
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND_V(!shadow_atlas, false);
|
||||
ERR_FAIL_NULL_V(shadow_atlas, false);
|
||||
|
||||
LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
|
||||
ERR_FAIL_COND_V(!li, false);
|
||||
ERR_FAIL_NULL_V(li, false);
|
||||
|
||||
if (shadow_atlas->size == 0 || shadow_atlas->smallest_subdiv == 0) {
|
||||
return false;
|
||||
@ -2341,7 +2341,7 @@ void LightStorage::_shadow_atlas_invalidate_shadow(ShadowAtlas::Quadrant::Shadow
|
||||
|
||||
void LightStorage::shadow_atlas_update(RID p_atlas) {
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND(!shadow_atlas);
|
||||
ERR_FAIL_NULL(shadow_atlas);
|
||||
|
||||
_update_shadow_atlas(shadow_atlas);
|
||||
}
|
||||
@ -2416,7 +2416,7 @@ int LightStorage::get_directional_light_shadow_size(RID p_light_intance) {
|
||||
Rect2i r = _get_directional_shadow_rect(directional_shadow.size, directional_shadow.light_count, 0);
|
||||
|
||||
LightInstance *light_instance = light_instance_owner.get_or_null(p_light_intance);
|
||||
ERR_FAIL_COND_V(!light_instance, 0);
|
||||
ERR_FAIL_NULL_V(light_instance, 0);
|
||||
|
||||
switch (light_directional_get_shadow_mode(light_instance->light)) {
|
||||
case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL:
|
||||
|
@ -490,7 +490,7 @@ public:
|
||||
|
||||
virtual RS::LightType light_get_type(RID p_light) const override {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
|
||||
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL);
|
||||
|
||||
return light->type;
|
||||
}
|
||||
@ -498,21 +498,21 @@ public:
|
||||
|
||||
virtual float light_get_param(RID p_light, RS::LightParam p_param) override {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, 0);
|
||||
ERR_FAIL_NULL_V(light, 0);
|
||||
|
||||
return light->param[p_param];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ RID light_get_projector(RID p_light) {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RID());
|
||||
ERR_FAIL_NULL_V(light, RID());
|
||||
|
||||
return light->projector;
|
||||
}
|
||||
|
||||
virtual Color light_get_color(RID p_light) override {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, Color());
|
||||
ERR_FAIL_NULL_V(light, Color());
|
||||
|
||||
return light->color;
|
||||
}
|
||||
@ -539,35 +539,35 @@ public:
|
||||
|
||||
virtual bool light_has_shadow(RID p_light) const override {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
|
||||
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL);
|
||||
|
||||
return light->shadow;
|
||||
}
|
||||
|
||||
virtual bool light_has_projector(RID p_light) const override {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
|
||||
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL);
|
||||
|
||||
return TextureStorage::get_singleton()->owns_texture(light->projector);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool light_is_negative(RID p_light) const {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
|
||||
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL);
|
||||
|
||||
return light->negative;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ float light_get_transmittance_bias(RID p_light) const {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, 0.0);
|
||||
ERR_FAIL_NULL_V(light, 0.0);
|
||||
|
||||
return light->param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS];
|
||||
}
|
||||
|
||||
virtual bool light_get_reverse_cull_face_mode(RID p_light) const override {
|
||||
const Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_COND_V(!light, false);
|
||||
ERR_FAIL_NULL_V(light, false);
|
||||
|
||||
return light->reverse_cull;
|
||||
}
|
||||
@ -657,7 +657,7 @@ public:
|
||||
ERR_FAIL_COND_V(!li->shadow_atlases.has(p_shadow_atlas), 0);
|
||||
#endif
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
|
||||
ERR_FAIL_COND_V(!shadow_atlas, 0);
|
||||
ERR_FAIL_NULL_V(shadow_atlas, 0);
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_FAIL_COND_V(!shadow_atlas->shadow_owners.has(p_light_instance), 0);
|
||||
#endif
|
||||
@ -835,7 +835,7 @@ public:
|
||||
|
||||
_FORCE_INLINE_ RID reflection_atlas_get_texture(RID p_ref_atlas) {
|
||||
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(p_ref_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, RID());
|
||||
ERR_FAIL_NULL_V(atlas, RID());
|
||||
return atlas->reflection;
|
||||
}
|
||||
|
||||
@ -859,47 +859,47 @@ public:
|
||||
|
||||
_FORCE_INLINE_ RID reflection_probe_instance_get_probe(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, RID());
|
||||
ERR_FAIL_NULL_V(rpi, RID());
|
||||
|
||||
return rpi->probe;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ RendererRD::ForwardID reflection_probe_instance_get_forward_id(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, 0);
|
||||
ERR_FAIL_NULL_V(rpi, 0);
|
||||
|
||||
return rpi->forward_id;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void reflection_probe_instance_set_cull_mask(RID p_instance, uint32_t p_render_pass) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!rpi);
|
||||
ERR_FAIL_NULL(rpi);
|
||||
rpi->cull_mask = p_render_pass;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void reflection_probe_instance_set_render_pass(RID p_instance, uint32_t p_render_pass) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!rpi);
|
||||
ERR_FAIL_NULL(rpi);
|
||||
rpi->last_pass = p_render_pass;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ uint32_t reflection_probe_instance_get_render_pass(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, 0);
|
||||
ERR_FAIL_NULL_V(rpi, 0);
|
||||
|
||||
return rpi->last_pass;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Transform3D reflection_probe_instance_get_transform(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, Transform3D());
|
||||
ERR_FAIL_NULL_V(rpi, Transform3D());
|
||||
|
||||
return rpi->transform;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int reflection_probe_instance_get_atlas_index(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, -1);
|
||||
ERR_FAIL_NULL_V(rpi, -1);
|
||||
|
||||
return rpi->atlas_index;
|
||||
}
|
||||
@ -942,12 +942,12 @@ public:
|
||||
}
|
||||
_FORCE_INLINE_ RID lightmap_get_texture(RID p_lightmap) const {
|
||||
const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND_V(!lm, RID());
|
||||
ERR_FAIL_NULL_V(lm, RID());
|
||||
return lm->light_texture;
|
||||
}
|
||||
_FORCE_INLINE_ float lightmap_get_baked_exposure_normalization(RID p_lightmap) const {
|
||||
const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND_V(!lm, 1.0);
|
||||
ERR_FAIL_NULL_V(lm, 1.0);
|
||||
return lm->baked_exposure;
|
||||
}
|
||||
_FORCE_INLINE_ int32_t lightmap_get_array_index(RID p_lightmap) const {
|
||||
@ -1007,44 +1007,44 @@ public:
|
||||
virtual bool shadow_atlas_update_light(RID p_atlas, RID p_light_instance, float p_coverage, uint64_t p_light_version) override;
|
||||
_FORCE_INLINE_ bool shadow_atlas_owns_light_instance(RID p_atlas, RID p_light_intance) {
|
||||
ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, false);
|
||||
ERR_FAIL_NULL_V(atlas, false);
|
||||
return atlas->shadow_owners.has(p_light_intance);
|
||||
}
|
||||
_FORCE_INLINE_ uint32_t shadow_atlas_get_light_instance_key(RID p_atlas, RID p_light_intance) {
|
||||
ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, -1);
|
||||
ERR_FAIL_NULL_V(atlas, -1);
|
||||
return atlas->shadow_owners[p_light_intance];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ RID shadow_atlas_get_texture(RID p_atlas) {
|
||||
ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, RID());
|
||||
ERR_FAIL_NULL_V(atlas, RID());
|
||||
return atlas->depth;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int shadow_atlas_get_size(RID p_atlas) {
|
||||
ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, 0);
|
||||
ERR_FAIL_NULL_V(atlas, 0);
|
||||
return atlas->size;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int shadow_atlas_get_quadrant_shadow_size(RID p_atlas, uint32_t p_quadrant) {
|
||||
ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, 0);
|
||||
ERR_FAIL_NULL_V(atlas, 0);
|
||||
ERR_FAIL_UNSIGNED_INDEX_V(p_quadrant, 4, 0);
|
||||
return atlas->quadrants[p_quadrant].shadows.size();
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ uint32_t shadow_atlas_get_quadrant_subdivision(RID p_atlas, uint32_t p_quadrant) {
|
||||
ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, 0);
|
||||
ERR_FAIL_NULL_V(atlas, 0);
|
||||
ERR_FAIL_UNSIGNED_INDEX_V(p_quadrant, 4, 0);
|
||||
return atlas->quadrants[p_quadrant].subdivision;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ RID shadow_atlas_get_fb(RID p_atlas) {
|
||||
ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_COND_V(!atlas, RID());
|
||||
ERR_FAIL_NULL_V(atlas, RID());
|
||||
return atlas->fb;
|
||||
}
|
||||
|
||||
|
@ -1834,7 +1834,7 @@ void MaterialStorage::shader_initialize(RID p_rid) {
|
||||
|
||||
void MaterialStorage::shader_free(RID p_rid) {
|
||||
Shader *shader = shader_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND(!shader);
|
||||
ERR_FAIL_NULL(shader);
|
||||
|
||||
//make material unreference this
|
||||
while (shader->owners.size()) {
|
||||
@ -1850,7 +1850,7 @@ void MaterialStorage::shader_free(RID p_rid) {
|
||||
|
||||
void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND(!shader);
|
||||
ERR_FAIL_NULL(shader);
|
||||
|
||||
shader->code = p_code;
|
||||
String mode_string = ShaderLanguage::get_shader_type(p_code);
|
||||
@ -1927,7 +1927,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
|
||||
|
||||
void MaterialStorage::shader_set_path_hint(RID p_shader, const String &p_path) {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND(!shader);
|
||||
ERR_FAIL_NULL(shader);
|
||||
|
||||
shader->path_hint = p_path;
|
||||
if (shader->data) {
|
||||
@ -1937,13 +1937,13 @@ void MaterialStorage::shader_set_path_hint(RID p_shader, const String &p_path) {
|
||||
|
||||
String MaterialStorage::shader_get_code(RID p_shader) const {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND_V(!shader, String());
|
||||
ERR_FAIL_NULL_V(shader, String());
|
||||
return shader->code;
|
||||
}
|
||||
|
||||
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);
|
||||
ERR_FAIL_NULL(shader);
|
||||
if (shader->data) {
|
||||
return shader->data->get_shader_uniform_list(p_param_list);
|
||||
}
|
||||
@ -1951,7 +1951,7 @@ void MaterialStorage::get_shader_parameter_list(RID p_shader, List<PropertyInfo>
|
||||
|
||||
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);
|
||||
ERR_FAIL_NULL(shader);
|
||||
|
||||
if (p_texture.is_valid() && TextureStorage::get_singleton()->owns_texture(p_texture)) {
|
||||
if (!shader->default_texture_parameter.has(p_name)) {
|
||||
@ -1978,7 +1978,7 @@ void MaterialStorage::shader_set_default_texture_parameter(RID p_shader, const S
|
||||
|
||||
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());
|
||||
ERR_FAIL_NULL_V(shader, RID());
|
||||
if (shader->default_texture_parameter.has(p_name) && shader->default_texture_parameter[p_name].has(p_index)) {
|
||||
return shader->default_texture_parameter[p_name][p_index];
|
||||
}
|
||||
@ -1988,7 +1988,7 @@ RID MaterialStorage::shader_get_default_texture_parameter(RID p_shader, const St
|
||||
|
||||
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());
|
||||
ERR_FAIL_NULL_V(shader, Variant());
|
||||
if (shader->data) {
|
||||
return shader->data->get_default_parameter(p_param);
|
||||
}
|
||||
@ -2002,7 +2002,7 @@ void MaterialStorage::shader_set_data_request_function(ShaderType p_shader_type,
|
||||
|
||||
RS::ShaderNativeSourceCode MaterialStorage::shader_get_native_source_code(RID p_shader) const {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND_V(!shader, RS::ShaderNativeSourceCode());
|
||||
ERR_FAIL_NULL_V(shader, RS::ShaderNativeSourceCode());
|
||||
if (shader->data) {
|
||||
return shader->data->get_native_source_code();
|
||||
}
|
||||
@ -2067,7 +2067,7 @@ void MaterialStorage::material_initialize(RID p_rid) {
|
||||
|
||||
void MaterialStorage::material_free(RID p_rid) {
|
||||
Material *material = material_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
// Need to clear texture arrays to prevent spin locking of their RID's.
|
||||
// This happens when the app is being closed.
|
||||
@ -2085,7 +2085,7 @@ void MaterialStorage::material_free(RID p_rid) {
|
||||
|
||||
void MaterialStorage::material_set_shader(RID p_material, RID p_shader) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
if (material->data) {
|
||||
memdelete(material->data);
|
||||
@ -2105,7 +2105,7 @@ void MaterialStorage::material_set_shader(RID p_material, RID p_shader) {
|
||||
}
|
||||
|
||||
Shader *shader = get_shader(p_shader);
|
||||
ERR_FAIL_COND(!shader);
|
||||
ERR_FAIL_NULL(shader);
|
||||
material->shader = shader;
|
||||
material->shader_type = shader->type;
|
||||
material->shader_id = p_shader.get_local_index();
|
||||
@ -2137,7 +2137,7 @@ MaterialStorage::ShaderData *MaterialStorage::material_get_shader_data(RID p_mat
|
||||
|
||||
void MaterialStorage::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
if (p_value.get_type() == Variant::NIL) {
|
||||
material->params.erase(p_param);
|
||||
@ -2156,7 +2156,7 @@ void MaterialStorage::material_set_param(RID p_material, const StringName &p_par
|
||||
|
||||
Variant MaterialStorage::material_get_param(RID p_material, const StringName &p_param) const {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND_V(!material, Variant());
|
||||
ERR_FAIL_NULL_V(material, Variant());
|
||||
if (material->params.has(p_param)) {
|
||||
return material->params[p_param];
|
||||
} else {
|
||||
@ -2166,7 +2166,7 @@ Variant MaterialStorage::material_get_param(RID p_material, const StringName &p_
|
||||
|
||||
void MaterialStorage::material_set_next_pass(RID p_material, RID p_next_material) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
|
||||
if (material->next_pass == p_next_material) {
|
||||
return;
|
||||
@ -2182,7 +2182,7 @@ void MaterialStorage::material_set_next_pass(RID p_material, RID p_next_material
|
||||
|
||||
void MaterialStorage::material_set_render_priority(RID p_material, int priority) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
material->priority = priority;
|
||||
if (material->data) {
|
||||
material->data->set_render_priority(priority);
|
||||
@ -2192,7 +2192,7 @@ void MaterialStorage::material_set_render_priority(RID p_material, int priority)
|
||||
|
||||
bool MaterialStorage::material_is_animated(RID p_material) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND_V(!material, false);
|
||||
ERR_FAIL_NULL_V(material, false);
|
||||
if (material->shader && material->shader->data) {
|
||||
if (material->shader->data->is_animated()) {
|
||||
return true;
|
||||
@ -2205,7 +2205,7 @@ bool MaterialStorage::material_is_animated(RID p_material) {
|
||||
|
||||
bool MaterialStorage::material_casts_shadows(RID p_material) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND_V(!material, true);
|
||||
ERR_FAIL_NULL_V(material, true);
|
||||
if (material->shader && material->shader->data) {
|
||||
if (material->shader->data->casts_shadows()) {
|
||||
return true;
|
||||
@ -2218,7 +2218,7 @@ bool MaterialStorage::material_casts_shadows(RID p_material) {
|
||||
|
||||
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);
|
||||
ERR_FAIL_NULL(material);
|
||||
if (material->shader && material->shader->data) {
|
||||
material->shader->data->get_instance_param_list(r_parameters);
|
||||
|
||||
@ -2230,7 +2230,7 @@ void MaterialStorage::material_get_instance_shader_parameters(RID p_material, Li
|
||||
|
||||
void MaterialStorage::material_update_dependency(RID p_material, DependencyTracker *p_instance) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
ERR_FAIL_NULL(material);
|
||||
p_instance->update_dependency(&material->dependency);
|
||||
if (material->next_pass.is_valid()) {
|
||||
material_update_dependency(material->next_pass, p_instance);
|
||||
|
@ -228,7 +228,7 @@ void MeshStorage::mesh_free(RID p_rid) {
|
||||
mesh_clear(p_rid);
|
||||
mesh_set_shadow_mesh(p_rid, RID());
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
|
||||
mesh->dependency.deleted_notify(p_rid);
|
||||
if (mesh->instances.size()) {
|
||||
@ -248,7 +248,7 @@ void MeshStorage::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count
|
||||
ERR_FAIL_COND(p_blend_shape_count < 0);
|
||||
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
|
||||
ERR_FAIL_COND(mesh->surface_count > 0); //surfaces already exist
|
||||
|
||||
@ -258,7 +258,7 @@ void MeshStorage::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count
|
||||
/// Returns stride
|
||||
void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
|
||||
ERR_FAIL_COND(mesh->surface_count == RS::MAX_MESH_SURFACES);
|
||||
|
||||
@ -462,13 +462,13 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
||||
|
||||
int MeshStorage::mesh_get_blend_shape_count(RID p_mesh) const {
|
||||
const Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, -1);
|
||||
ERR_FAIL_NULL_V(mesh, -1);
|
||||
return mesh->blend_shape_count;
|
||||
}
|
||||
|
||||
void MeshStorage::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
ERR_FAIL_INDEX((int)p_mode, 2);
|
||||
|
||||
mesh->blend_shape_mode = p_mode;
|
||||
@ -476,13 +476,13 @@ void MeshStorage::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mod
|
||||
|
||||
RS::BlendShapeMode MeshStorage::mesh_get_blend_shape_mode(RID p_mesh) const {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, RS::BLEND_SHAPE_MODE_NORMALIZED);
|
||||
ERR_FAIL_NULL_V(mesh, RS::BLEND_SHAPE_MODE_NORMALIZED);
|
||||
return mesh->blend_shape_mode;
|
||||
}
|
||||
|
||||
void MeshStorage::mesh_surface_update_vertex_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
|
||||
ERR_FAIL_COND(p_data.size() == 0);
|
||||
ERR_FAIL_COND(mesh->surfaces[p_surface]->vertex_buffer.is_null());
|
||||
@ -494,7 +494,7 @@ void MeshStorage::mesh_surface_update_vertex_region(RID p_mesh, int p_surface, i
|
||||
|
||||
void MeshStorage::mesh_surface_update_attribute_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
|
||||
ERR_FAIL_COND(p_data.size() == 0);
|
||||
ERR_FAIL_COND(mesh->surfaces[p_surface]->attribute_buffer.is_null());
|
||||
@ -506,7 +506,7 @@ void MeshStorage::mesh_surface_update_attribute_region(RID p_mesh, int p_surface
|
||||
|
||||
void MeshStorage::mesh_surface_update_skin_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
|
||||
ERR_FAIL_COND(p_data.size() == 0);
|
||||
ERR_FAIL_COND(mesh->surfaces[p_surface]->skin_buffer.is_null());
|
||||
@ -518,7 +518,7 @@ void MeshStorage::mesh_surface_update_skin_region(RID p_mesh, int p_surface, int
|
||||
|
||||
void MeshStorage::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
|
||||
mesh->surfaces[p_surface]->material = p_material;
|
||||
|
||||
@ -528,7 +528,7 @@ void MeshStorage::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_mat
|
||||
|
||||
RID MeshStorage::mesh_surface_get_material(RID p_mesh, int p_surface) const {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, RID());
|
||||
ERR_FAIL_NULL_V(mesh, RID());
|
||||
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RID());
|
||||
|
||||
return mesh->surfaces[p_surface]->material;
|
||||
@ -536,7 +536,7 @@ RID MeshStorage::mesh_surface_get_material(RID p_mesh, int p_surface) const {
|
||||
|
||||
RS::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, RS::SurfaceData());
|
||||
ERR_FAIL_NULL_V(mesh, RS::SurfaceData());
|
||||
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData());
|
||||
|
||||
Mesh::Surface &s = *mesh->surfaces[p_surface];
|
||||
@ -578,13 +578,13 @@ RS::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const {
|
||||
|
||||
int MeshStorage::mesh_get_surface_count(RID p_mesh) const {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, 0);
|
||||
ERR_FAIL_NULL_V(mesh, 0);
|
||||
return mesh->surface_count;
|
||||
}
|
||||
|
||||
void MeshStorage::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
mesh->custom_aabb = p_aabb;
|
||||
|
||||
mesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
@ -592,13 +592,13 @@ void MeshStorage::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {
|
||||
|
||||
AABB MeshStorage::mesh_get_custom_aabb(RID p_mesh) const {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, AABB());
|
||||
ERR_FAIL_NULL_V(mesh, AABB());
|
||||
return mesh->custom_aabb;
|
||||
}
|
||||
|
||||
AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, AABB());
|
||||
ERR_FAIL_NULL_V(mesh, AABB());
|
||||
|
||||
if (mesh->custom_aabb != AABB()) {
|
||||
return mesh->custom_aabb;
|
||||
@ -706,7 +706,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
|
||||
|
||||
void MeshStorage::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
|
||||
Mesh *shadow_mesh = mesh_owner.get_or_null(mesh->shadow_mesh);
|
||||
if (shadow_mesh) {
|
||||
@ -725,7 +725,7 @@ void MeshStorage::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) {
|
||||
|
||||
void MeshStorage::mesh_clear(RID p_mesh) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
|
||||
// Clear instance data before mesh data.
|
||||
for (MeshInstance *mi : mesh->instances) {
|
||||
@ -783,14 +783,14 @@ void MeshStorage::mesh_clear(RID p_mesh) {
|
||||
|
||||
bool MeshStorage::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, false);
|
||||
ERR_FAIL_NULL_V(mesh, false);
|
||||
|
||||
return mesh->blend_shape_count > 0 || (mesh->has_bone_weights && p_has_skeleton);
|
||||
}
|
||||
|
||||
Dependency *MeshStorage::mesh_get_dependency(RID p_mesh) const {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, nullptr);
|
||||
ERR_FAIL_NULL_V(mesh, nullptr);
|
||||
|
||||
return &mesh->dependency;
|
||||
}
|
||||
@ -799,7 +799,7 @@ Dependency *MeshStorage::mesh_get_dependency(RID p_mesh) const {
|
||||
|
||||
RID MeshStorage::mesh_instance_create(RID p_base) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_base);
|
||||
ERR_FAIL_COND_V(!mesh, RID());
|
||||
ERR_FAIL_NULL_V(mesh, RID());
|
||||
|
||||
RID rid = mesh_instance_owner.make_rid();
|
||||
MeshInstance *mi = mesh_instance_owner.get_or_null(rid);
|
||||
@ -838,7 +838,7 @@ void MeshStorage::mesh_instance_set_skeleton(RID p_mesh_instance, RID p_skeleton
|
||||
|
||||
void MeshStorage::mesh_instance_set_blend_shape_weight(RID p_mesh_instance, int p_shape, float p_weight) {
|
||||
MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
|
||||
ERR_FAIL_COND(!mi);
|
||||
ERR_FAIL_NULL(mi);
|
||||
ERR_FAIL_INDEX(p_shape, (int)mi->blend_weights.size());
|
||||
mi->blend_weights[p_shape] = p_weight;
|
||||
mi->weights_dirty = true;
|
||||
@ -1293,7 +1293,7 @@ void MeshStorage::multimesh_free(RID p_rid) {
|
||||
|
||||
void MeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
|
||||
if (multimesh->instances == p_instances && multimesh->xform_format == p_transform_format && multimesh->uses_colors == p_use_colors && multimesh->uses_custom_data == p_use_custom_data) {
|
||||
return;
|
||||
@ -1390,7 +1390,7 @@ void MeshStorage::_multimesh_enable_motion_vectors(MultiMesh *multimesh) {
|
||||
|
||||
void MeshStorage::_multimesh_get_motion_vectors_offsets(RID p_multimesh, uint32_t &r_current_offset, uint32_t &r_prev_offset) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
r_current_offset = multimesh->motion_vectors_current_offset;
|
||||
if (!_multimesh_uses_motion_vectors(multimesh)) {
|
||||
multimesh->motion_vectors_previous_offset = multimesh->motion_vectors_current_offset;
|
||||
@ -1406,13 +1406,13 @@ bool MeshStorage::_multimesh_uses_motion_vectors_offsets(RID p_multimesh) {
|
||||
|
||||
int MeshStorage::multimesh_get_instance_count(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, 0);
|
||||
ERR_FAIL_NULL_V(multimesh, 0);
|
||||
return multimesh->instances;
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
if (multimesh->mesh == p_mesh) {
|
||||
return;
|
||||
}
|
||||
@ -1599,7 +1599,7 @@ void MeshStorage::_multimesh_re_create_aabb(MultiMesh *multimesh, const float *p
|
||||
|
||||
void MeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->instances);
|
||||
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D);
|
||||
|
||||
@ -1636,7 +1636,7 @@ void MeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index,
|
||||
|
||||
void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->instances);
|
||||
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D);
|
||||
|
||||
@ -1663,7 +1663,7 @@ void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_ind
|
||||
|
||||
void MeshStorage::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->instances);
|
||||
ERR_FAIL_COND(!multimesh->uses_colors);
|
||||
|
||||
@ -1686,7 +1686,7 @@ void MeshStorage::multimesh_instance_set_color(RID p_multimesh, int p_index, con
|
||||
|
||||
void MeshStorage::multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->instances);
|
||||
ERR_FAIL_COND(!multimesh->uses_custom_data);
|
||||
|
||||
@ -1709,21 +1709,21 @@ void MeshStorage::multimesh_instance_set_custom_data(RID p_multimesh, int p_inde
|
||||
|
||||
RID MeshStorage::multimesh_get_mesh(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, RID());
|
||||
ERR_FAIL_NULL_V(multimesh, RID());
|
||||
|
||||
return multimesh->mesh;
|
||||
}
|
||||
|
||||
Dependency *MeshStorage::multimesh_get_dependency(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, nullptr);
|
||||
ERR_FAIL_NULL_V(multimesh, nullptr);
|
||||
|
||||
return &multimesh->dependency;
|
||||
}
|
||||
|
||||
Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, Transform3D());
|
||||
ERR_FAIL_NULL_V(multimesh, Transform3D());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform3D());
|
||||
ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D, Transform3D());
|
||||
|
||||
@ -1754,7 +1754,7 @@ Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p
|
||||
|
||||
Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, Transform2D());
|
||||
ERR_FAIL_NULL_V(multimesh, Transform2D());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform2D());
|
||||
ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D, Transform2D());
|
||||
|
||||
@ -1779,7 +1779,7 @@ Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, in
|
||||
|
||||
Color MeshStorage::multimesh_instance_get_color(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, Color());
|
||||
ERR_FAIL_NULL_V(multimesh, Color());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
|
||||
ERR_FAIL_COND_V(!multimesh->uses_colors, Color());
|
||||
|
||||
@ -1802,7 +1802,7 @@ Color MeshStorage::multimesh_instance_get_color(RID p_multimesh, int p_index) co
|
||||
|
||||
Color MeshStorage::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, Color());
|
||||
ERR_FAIL_NULL_V(multimesh, Color());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
|
||||
ERR_FAIL_COND_V(!multimesh->uses_custom_data, Color());
|
||||
|
||||
@ -1825,7 +1825,7 @@ Color MeshStorage::multimesh_instance_get_custom_data(RID p_multimesh, int p_ind
|
||||
|
||||
void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));
|
||||
|
||||
bool uses_motion_vectors = (RSG::viewport->get_num_viewports_with_motion_vectors() > 0);
|
||||
@ -1864,7 +1864,7 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
|
||||
|
||||
Vector<float> MeshStorage::multimesh_get_buffer(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, Vector<float>());
|
||||
ERR_FAIL_NULL_V(multimesh, Vector<float>());
|
||||
if (multimesh->buffer.is_null()) {
|
||||
return Vector<float>();
|
||||
} else {
|
||||
@ -1886,7 +1886,7 @@ Vector<float> MeshStorage::multimesh_get_buffer(RID p_multimesh) const {
|
||||
|
||||
void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_COND(p_visible < -1 || p_visible > multimesh->instances);
|
||||
if (multimesh->visible_instances == p_visible) {
|
||||
return;
|
||||
@ -1908,13 +1908,13 @@ void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible
|
||||
|
||||
int MeshStorage::multimesh_get_visible_instances(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, 0);
|
||||
ERR_FAIL_NULL_V(multimesh, 0);
|
||||
return multimesh->visible_instances;
|
||||
}
|
||||
|
||||
AABB MeshStorage::multimesh_get_aabb(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, AABB());
|
||||
ERR_FAIL_NULL_V(multimesh, AABB());
|
||||
if (multimesh->aabb_dirty) {
|
||||
const_cast<MeshStorage *>(this)->_update_dirty_multimeshes();
|
||||
}
|
||||
@ -2004,7 +2004,7 @@ void MeshStorage::_skeleton_make_dirty(Skeleton *skeleton) {
|
||||
|
||||
void MeshStorage::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton) {
|
||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||
ERR_FAIL_COND(!skeleton);
|
||||
ERR_FAIL_NULL(skeleton);
|
||||
ERR_FAIL_COND(p_bones < 0);
|
||||
|
||||
if (skeleton->size == p_bones && skeleton->use_2d == p_2d_skeleton) {
|
||||
@ -2047,7 +2047,7 @@ void MeshStorage::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_
|
||||
|
||||
int MeshStorage::skeleton_get_bone_count(RID p_skeleton) const {
|
||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||
ERR_FAIL_COND_V(!skeleton, 0);
|
||||
ERR_FAIL_NULL_V(skeleton, 0);
|
||||
|
||||
return skeleton->size;
|
||||
}
|
||||
@ -2055,7 +2055,7 @@ int MeshStorage::skeleton_get_bone_count(RID p_skeleton) const {
|
||||
void MeshStorage::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform3D &p_transform) {
|
||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||
|
||||
ERR_FAIL_COND(!skeleton);
|
||||
ERR_FAIL_NULL(skeleton);
|
||||
ERR_FAIL_INDEX(p_bone, skeleton->size);
|
||||
ERR_FAIL_COND(skeleton->use_2d);
|
||||
|
||||
@ -2080,7 +2080,7 @@ void MeshStorage::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const
|
||||
Transform3D MeshStorage::skeleton_bone_get_transform(RID p_skeleton, int p_bone) const {
|
||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||
|
||||
ERR_FAIL_COND_V(!skeleton, Transform3D());
|
||||
ERR_FAIL_NULL_V(skeleton, Transform3D());
|
||||
ERR_FAIL_INDEX_V(p_bone, skeleton->size, Transform3D());
|
||||
ERR_FAIL_COND_V(skeleton->use_2d, Transform3D());
|
||||
|
||||
@ -2107,7 +2107,7 @@ Transform3D MeshStorage::skeleton_bone_get_transform(RID p_skeleton, int p_bone)
|
||||
void MeshStorage::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {
|
||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||
|
||||
ERR_FAIL_COND(!skeleton);
|
||||
ERR_FAIL_NULL(skeleton);
|
||||
ERR_FAIL_INDEX(p_bone, skeleton->size);
|
||||
ERR_FAIL_COND(!skeleton->use_2d);
|
||||
|
||||
@ -2128,7 +2128,7 @@ void MeshStorage::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, con
|
||||
Transform2D MeshStorage::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const {
|
||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||
|
||||
ERR_FAIL_COND_V(!skeleton, Transform2D());
|
||||
ERR_FAIL_NULL_V(skeleton, Transform2D());
|
||||
ERR_FAIL_INDEX_V(p_bone, skeleton->size, Transform2D());
|
||||
ERR_FAIL_COND_V(!skeleton->use_2d, Transform2D());
|
||||
|
||||
@ -2177,7 +2177,7 @@ void MeshStorage::_update_dirty_skeletons() {
|
||||
|
||||
void MeshStorage::skeleton_update_dependency(RID p_skeleton, DependencyTracker *p_instance) {
|
||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||
ERR_FAIL_COND(!skeleton);
|
||||
ERR_FAIL_NULL(skeleton);
|
||||
|
||||
p_instance->update_dependency(&skeleton->dependency);
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ public:
|
||||
|
||||
_FORCE_INLINE_ const RID *mesh_get_surface_count_and_materials(RID p_mesh, uint32_t &r_surface_count) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, nullptr);
|
||||
ERR_FAIL_NULL_V(mesh, nullptr);
|
||||
r_surface_count = mesh->surface_count;
|
||||
if (r_surface_count == 0) {
|
||||
return nullptr;
|
||||
@ -394,7 +394,7 @@ public:
|
||||
|
||||
_FORCE_INLINE_ void *mesh_get_surface(RID p_mesh, uint32_t p_surface_index) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, nullptr);
|
||||
ERR_FAIL_NULL_V(mesh, nullptr);
|
||||
ERR_FAIL_UNSIGNED_INDEX_V(p_surface_index, mesh->surface_count, nullptr);
|
||||
|
||||
return mesh->surfaces[p_surface_index];
|
||||
@ -402,7 +402,7 @@ public:
|
||||
|
||||
_FORCE_INLINE_ RID mesh_get_shadow_mesh(RID p_mesh) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, RID());
|
||||
ERR_FAIL_NULL_V(mesh, RID());
|
||||
|
||||
return mesh->shadow_mesh;
|
||||
}
|
||||
@ -486,7 +486,7 @@ public:
|
||||
|
||||
_FORCE_INLINE_ void mesh_instance_surface_get_vertex_arrays_and_format(RID p_mesh_instance, uint32_t p_surface_index, uint32_t p_input_mask, bool p_input_motion_vectors, RID &r_vertex_array_rd, RD::VertexFormatID &r_vertex_format) {
|
||||
MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
|
||||
ERR_FAIL_COND(!mi);
|
||||
ERR_FAIL_NULL(mi);
|
||||
Mesh *mesh = mi->mesh;
|
||||
ERR_FAIL_UNSIGNED_INDEX(p_surface_index, mesh->surface_count);
|
||||
|
||||
@ -719,7 +719,7 @@ public:
|
||||
|
||||
_FORCE_INLINE_ RID skeleton_get_3d_uniform_set(RID p_skeleton, RID p_shader, uint32_t p_set) const {
|
||||
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
|
||||
ERR_FAIL_COND_V(!skeleton, RID());
|
||||
ERR_FAIL_NULL_V(skeleton, RID());
|
||||
if (skeleton->size == 0) {
|
||||
return RID();
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ void ParticlesStorage::particles_free(RID p_rid) {
|
||||
|
||||
void ParticlesStorage::particles_set_mode(RID p_particles, RS::ParticlesMode p_mode) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
if (particles->mode == p_mode) {
|
||||
return;
|
||||
}
|
||||
@ -246,7 +246,7 @@ void ParticlesStorage::particles_set_mode(RID p_particles, RS::ParticlesMode p_m
|
||||
|
||||
void ParticlesStorage::particles_set_emitting(RID p_particles, bool p_emitting) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->emitting = p_emitting;
|
||||
}
|
||||
@ -254,7 +254,7 @@ void ParticlesStorage::particles_set_emitting(RID p_particles, bool p_emitting)
|
||||
bool ParticlesStorage::particles_get_emitting(RID p_particles) {
|
||||
ERR_FAIL_COND_V_MSG(RSG::threaded, false, "This function should never be used with threaded rendering, as it stalls the renderer.");
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, false);
|
||||
ERR_FAIL_NULL_V(particles, false);
|
||||
|
||||
return particles->emitting;
|
||||
}
|
||||
@ -311,7 +311,7 @@ void ParticlesStorage::_particles_free_data(Particles *particles) {
|
||||
|
||||
void ParticlesStorage::particles_set_amount(RID p_particles, int p_amount) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
if (particles->amount == p_amount) {
|
||||
return;
|
||||
@ -331,48 +331,48 @@ void ParticlesStorage::particles_set_amount(RID p_particles, int p_amount) {
|
||||
|
||||
void ParticlesStorage::particles_set_lifetime(RID p_particles, double p_lifetime) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->lifetime = p_lifetime;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_one_shot(RID p_particles, bool p_one_shot) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->one_shot = p_one_shot;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_pre_process_time(RID p_particles, double p_time) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->pre_process_time = p_time;
|
||||
}
|
||||
void ParticlesStorage::particles_set_explosiveness_ratio(RID p_particles, real_t p_ratio) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->explosiveness = p_ratio;
|
||||
}
|
||||
void ParticlesStorage::particles_set_randomness_ratio(RID p_particles, real_t p_ratio) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->randomness = p_ratio;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->custom_aabb = p_aabb;
|
||||
particles->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_speed_scale(RID p_particles, double p_scale) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->speed_scale = p_scale;
|
||||
}
|
||||
void ParticlesStorage::particles_set_use_local_coordinates(RID p_particles, bool p_enable) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->use_local_coords = p_enable;
|
||||
particles->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_PARTICLES);
|
||||
@ -380,7 +380,7 @@ void ParticlesStorage::particles_set_use_local_coordinates(RID p_particles, bool
|
||||
|
||||
void ParticlesStorage::particles_set_fixed_fps(RID p_particles, int p_fps) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->fixed_fps = p_fps;
|
||||
|
||||
@ -396,21 +396,21 @@ void ParticlesStorage::particles_set_fixed_fps(RID p_particles, int p_fps) {
|
||||
|
||||
void ParticlesStorage::particles_set_interpolate(RID p_particles, bool p_enable) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->interpolate = p_enable;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_fractional_delta(RID p_particles, bool p_enable) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->fractional_delta = p_enable;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_trails(RID p_particles, bool p_enable, double p_length) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
ERR_FAIL_COND(p_length < 0.01);
|
||||
p_length = MIN(10.0, p_length);
|
||||
|
||||
@ -429,7 +429,7 @@ void ParticlesStorage::particles_set_trails(RID p_particles, bool p_enable, doub
|
||||
|
||||
void ParticlesStorage::particles_set_trail_bind_poses(RID p_particles, const Vector<Transform3D> &p_bind_poses) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
if (particles->trail_bind_pose_buffer.is_valid() && particles->trail_bind_poses.size() != p_bind_poses.size()) {
|
||||
_particles_free_data(particles);
|
||||
|
||||
@ -446,21 +446,21 @@ void ParticlesStorage::particles_set_trail_bind_poses(RID p_particles, const Vec
|
||||
|
||||
void ParticlesStorage::particles_set_collision_base_size(RID p_particles, real_t p_size) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->collision_base_size = p_size;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_transform_align(RID p_particles, RS::ParticlesTransformAlign p_transform_align) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->transform_align = p_transform_align;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_process_material(RID p_particles, RID p_material) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->process_material = p_material;
|
||||
particles->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_PARTICLES); //the instance buffer may have changed
|
||||
@ -468,35 +468,35 @@ void ParticlesStorage::particles_set_process_material(RID p_particles, RID p_mat
|
||||
|
||||
RID ParticlesStorage::particles_get_process_material(RID p_particles) const {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, RID());
|
||||
ERR_FAIL_NULL_V(particles, RID());
|
||||
|
||||
return particles->process_material;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->draw_order = p_order;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_draw_passes(RID p_particles, int p_passes) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->draw_passes.resize(p_passes);
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
ERR_FAIL_INDEX(p_pass, particles->draw_passes.size());
|
||||
particles->draw_passes.write[p_pass] = p_mesh;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_restart(RID p_particles) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->restart_request = true;
|
||||
}
|
||||
@ -520,7 +520,7 @@ void ParticlesStorage::_particles_allocate_emission_buffer(Particles *particles)
|
||||
|
||||
void ParticlesStorage::particles_set_subemitter(RID p_particles, RID p_subemitter_particles) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
ERR_FAIL_COND(p_particles == p_subemitter_particles);
|
||||
|
||||
particles->sub_emitter = p_subemitter_particles;
|
||||
@ -533,7 +533,7 @@ void ParticlesStorage::particles_set_subemitter(RID p_particles, RID p_subemitte
|
||||
|
||||
void ParticlesStorage::particles_emit(RID p_particles, const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
ERR_FAIL_COND(particles->amount == 0);
|
||||
|
||||
if (particles->emitting) {
|
||||
@ -573,7 +573,7 @@ void ParticlesStorage::particles_emit(RID p_particles, const Transform3D &p_tran
|
||||
|
||||
void ParticlesStorage::particles_request_process(RID p_particles) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
if (!particles->dirty) {
|
||||
particles->dirty = true;
|
||||
@ -588,7 +588,7 @@ AABB ParticlesStorage::particles_get_current_aabb(RID p_particles) {
|
||||
}
|
||||
|
||||
const Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, AABB());
|
||||
ERR_FAIL_NULL_V(particles, AABB());
|
||||
|
||||
int total_amount = particles->amount;
|
||||
if (particles->trails_enabled && particles->trail_bind_poses.size() > 1) {
|
||||
@ -639,28 +639,28 @@ AABB ParticlesStorage::particles_get_current_aabb(RID p_particles) {
|
||||
|
||||
AABB ParticlesStorage::particles_get_aabb(RID p_particles) const {
|
||||
const Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, AABB());
|
||||
ERR_FAIL_NULL_V(particles, AABB());
|
||||
|
||||
return particles->custom_aabb;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_emission_transform(RID p_particles, const Transform3D &p_transform) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
particles->emission_transform = p_transform;
|
||||
}
|
||||
|
||||
int ParticlesStorage::particles_get_draw_passes(RID p_particles) const {
|
||||
const Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, 0);
|
||||
ERR_FAIL_NULL_V(particles, 0);
|
||||
|
||||
return particles->draw_passes.size();
|
||||
}
|
||||
|
||||
RID ParticlesStorage::particles_get_draw_pass_mesh(RID p_particles, int p_pass) const {
|
||||
const Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, RID());
|
||||
ERR_FAIL_NULL_V(particles, RID());
|
||||
ERR_FAIL_INDEX_V(p_pass, particles->draw_passes.size(), RID());
|
||||
|
||||
return particles->draw_passes[p_pass];
|
||||
@ -668,32 +668,32 @@ RID ParticlesStorage::particles_get_draw_pass_mesh(RID p_particles, int p_pass)
|
||||
|
||||
void ParticlesStorage::particles_update_dependency(RID p_particles, DependencyTracker *p_instance) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
p_instance->update_dependency(&particles->dependency);
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_get_instance_buffer_motion_vectors_offsets(RID p_particles, uint32_t &r_current_offset, uint32_t &r_prev_offset) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
r_current_offset = particles->instance_motion_vectors_current_offset;
|
||||
r_prev_offset = particles->instance_motion_vectors_previous_offset;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_add_collision(RID p_particles, RID p_particles_collision_instance) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->collisions.insert(p_particles_collision_instance);
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_remove_collision(RID p_particles, RID p_particles_collision_instance) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->collisions.erase(p_particles_collision_instance);
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_set_canvas_sdf_collision(RID p_particles, bool p_enable, const Transform2D &p_xform, const Rect2 &p_to_screen, RID p_texture) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
particles->has_sdf_collision = p_enable;
|
||||
particles->sdf_collision_transform = p_xform;
|
||||
particles->sdf_collision_to_screen = p_to_screen;
|
||||
@ -1106,7 +1106,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
||||
m = static_cast<ParticleProcessMaterialData *>(material_storage->material_get_data(particles_shader.default_material, MaterialStorage::SHADER_TYPE_PARTICLES));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!m);
|
||||
ERR_FAIL_NULL(m);
|
||||
|
||||
p_particles->has_collision_cache = m->shader_data->uses_collision;
|
||||
|
||||
@ -1142,7 +1142,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
||||
|
||||
void ParticlesStorage::particles_set_view_axis(RID p_particles, const Vector3 &p_axis, const Vector3 &p_up_axis) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND(!particles);
|
||||
ERR_FAIL_NULL(particles);
|
||||
|
||||
if (particles->draw_order != RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) {
|
||||
return;
|
||||
@ -1590,7 +1590,7 @@ Dependency *ParticlesStorage::particles_get_dependency(RID p_particles) const {
|
||||
bool ParticlesStorage::particles_is_inactive(RID p_particles) const {
|
||||
ERR_FAIL_COND_V_MSG(RSG::threaded, false, "This function should never be used with threaded rendering, as it stalls the renderer.");
|
||||
const Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, false);
|
||||
ERR_FAIL_NULL_V(particles, false);
|
||||
return !particles->emitting && particles->inactive;
|
||||
}
|
||||
|
||||
@ -1722,7 +1722,7 @@ void ParticlesStorage::particles_collision_free(RID p_rid) {
|
||||
|
||||
RID ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_particles_collision) const {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND_V(!particles_collision, RID());
|
||||
ERR_FAIL_NULL_V(particles_collision, RID());
|
||||
ERR_FAIL_COND_V(particles_collision->type != RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE, RID());
|
||||
|
||||
if (particles_collision->heightfield_texture == RID()) {
|
||||
@ -1757,7 +1757,7 @@ RID ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_part
|
||||
|
||||
void ParticlesStorage::particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
|
||||
if (p_type == particles_collision->type) {
|
||||
return;
|
||||
@ -1773,13 +1773,13 @@ void ParticlesStorage::particles_collision_set_collision_type(RID p_particles_co
|
||||
|
||||
void ParticlesStorage::particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
particles_collision->cull_mask = p_cull_mask;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
|
||||
particles_collision->radius = p_radius;
|
||||
particles_collision->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
@ -1787,7 +1787,7 @@ void ParticlesStorage::particles_collision_set_sphere_radius(RID p_particles_col
|
||||
|
||||
void ParticlesStorage::particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
|
||||
particles_collision->extents = p_extents;
|
||||
particles_collision->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
@ -1795,41 +1795,41 @@ void ParticlesStorage::particles_collision_set_box_extents(RID p_particles_colli
|
||||
|
||||
void ParticlesStorage::particles_collision_set_attractor_strength(RID p_particles_collision, real_t p_strength) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
|
||||
particles_collision->attractor_strength = p_strength;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_collision_set_attractor_directionality(RID p_particles_collision, real_t p_directionality) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
|
||||
particles_collision->attractor_directionality = p_directionality;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_collision_set_attractor_attenuation(RID p_particles_collision, real_t p_curve) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
|
||||
particles_collision->attractor_attenuation = p_curve;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
|
||||
particles_collision->field_texture = p_texture;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_collision_height_field_update(RID p_particles_collision) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
particles_collision->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_collision_set_height_field_resolution(RID p_particles_collision, RS::ParticlesCollisionHeightfieldResolution p_resolution) {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND(!particles_collision);
|
||||
ERR_FAIL_NULL(particles_collision);
|
||||
ERR_FAIL_INDEX(p_resolution, RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);
|
||||
|
||||
if (particles_collision->heightfield_resolution == p_resolution) {
|
||||
@ -1846,7 +1846,7 @@ void ParticlesStorage::particles_collision_set_height_field_resolution(RID p_par
|
||||
|
||||
AABB ParticlesStorage::particles_collision_get_aabb(RID p_particles_collision) const {
|
||||
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND_V(!particles_collision, AABB());
|
||||
ERR_FAIL_NULL_V(particles_collision, AABB());
|
||||
|
||||
switch (particles_collision->type) {
|
||||
case RS::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT:
|
||||
@ -1867,13 +1867,13 @@ AABB ParticlesStorage::particles_collision_get_aabb(RID p_particles_collision) c
|
||||
|
||||
Vector3 ParticlesStorage::particles_collision_get_extents(RID p_particles_collision) const {
|
||||
const ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND_V(!particles_collision, Vector3());
|
||||
ERR_FAIL_NULL_V(particles_collision, Vector3());
|
||||
return particles_collision->extents;
|
||||
}
|
||||
|
||||
bool ParticlesStorage::particles_collision_is_heightfield(RID p_particles_collision) const {
|
||||
const ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_COND_V(!particles_collision, false);
|
||||
ERR_FAIL_NULL_V(particles_collision, false);
|
||||
return particles_collision->type == RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE;
|
||||
}
|
||||
|
||||
@ -1898,12 +1898,12 @@ void ParticlesStorage::particles_collision_instance_free(RID p_rid) {
|
||||
|
||||
void ParticlesStorage::particles_collision_instance_set_transform(RID p_collision_instance, const Transform3D &p_transform) {
|
||||
ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(p_collision_instance);
|
||||
ERR_FAIL_COND(!pci);
|
||||
ERR_FAIL_NULL(pci);
|
||||
pci->transform = p_transform;
|
||||
}
|
||||
|
||||
void ParticlesStorage::particles_collision_instance_set_active(RID p_collision_instance, bool p_active) {
|
||||
ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(p_collision_instance);
|
||||
ERR_FAIL_COND(!pci);
|
||||
ERR_FAIL_NULL(pci);
|
||||
pci->active = p_active;
|
||||
}
|
||||
|
@ -471,19 +471,19 @@ public:
|
||||
|
||||
_FORCE_INLINE_ RS::ParticlesMode particles_get_mode(RID p_particles) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, RS::PARTICLES_MODE_2D);
|
||||
ERR_FAIL_NULL_V(particles, RS::PARTICLES_MODE_2D);
|
||||
return particles->mode;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ uint32_t particles_get_frame_counter(RID p_particles) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, false);
|
||||
ERR_FAIL_NULL_V(particles, false);
|
||||
return particles->frame_counter;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ uint32_t particles_get_amount(RID p_particles, uint32_t &r_trail_divisor) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, 0);
|
||||
ERR_FAIL_NULL_V(particles, 0);
|
||||
|
||||
if (particles->trails_enabled && particles->trail_bind_poses.size() > 1) {
|
||||
r_trail_divisor = particles->trail_bind_poses.size();
|
||||
@ -496,21 +496,21 @@ public:
|
||||
|
||||
_FORCE_INLINE_ bool particles_has_collision(RID p_particles) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, 0);
|
||||
ERR_FAIL_NULL_V(particles, 0);
|
||||
|
||||
return particles->has_collision_cache;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ uint32_t particles_is_using_local_coords(RID p_particles) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, false);
|
||||
ERR_FAIL_NULL_V(particles, false);
|
||||
|
||||
return particles->use_local_coords;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ RID particles_get_instance_buffer_uniform_set(RID p_particles, RID p_shader, uint32_t p_set) {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_COND_V(!particles, RID());
|
||||
ERR_FAIL_NULL_V(particles, RID());
|
||||
if (particles->particles_transforms_buffer_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(particles->particles_transforms_buffer_uniform_set)) {
|
||||
_particles_update_buffers(particles);
|
||||
Vector<RD::Uniform> uniforms;
|
||||
|
@ -764,7 +764,7 @@ RID TextureStorage::texture_allocate() {
|
||||
|
||||
void TextureStorage::texture_free(RID p_texture) {
|
||||
Texture *t = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!t);
|
||||
ERR_FAIL_NULL(t);
|
||||
ERR_FAIL_COND(t->is_render_target);
|
||||
|
||||
t->cleanup();
|
||||
@ -1089,7 +1089,7 @@ void TextureStorage::texture_3d_initialize(RID p_texture, Image::Format p_format
|
||||
|
||||
void TextureStorage::texture_proxy_initialize(RID p_texture, RID p_base) {
|
||||
Texture *tex = texture_owner.get_or_null(p_base);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
Texture proxy_tex = *tex;
|
||||
|
||||
proxy_tex.rd_view.format_override = tex->rd_format;
|
||||
@ -1112,7 +1112,7 @@ void TextureStorage::_texture_2d_update(RID p_texture, const Ref<Image> &p_image
|
||||
ERR_FAIL_COND(p_image.is_null() || p_image->is_empty());
|
||||
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
ERR_FAIL_COND(tex->is_render_target);
|
||||
ERR_FAIL_COND(p_image->get_width() != tex->width || p_image->get_height() != tex->height);
|
||||
ERR_FAIL_COND(p_image->get_format() != tex->format);
|
||||
@ -1136,7 +1136,7 @@ void TextureStorage::texture_2d_update(RID p_texture, const Ref<Image> &p_image,
|
||||
|
||||
void TextureStorage::texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
ERR_FAIL_COND(tex->type != TextureStorage::TYPE_3D);
|
||||
|
||||
Image::Image3DValidateError verr = Image::validate_3d_image(tex->format, tex->width, tex->height, tex->depth, tex->mipmaps > 1, p_data);
|
||||
@ -1174,10 +1174,10 @@ void TextureStorage::texture_3d_update(RID p_texture, const Vector<Ref<Image>> &
|
||||
|
||||
void TextureStorage::texture_proxy_update(RID p_texture, RID p_proxy_to) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
ERR_FAIL_COND(!tex->is_proxy);
|
||||
Texture *proxy_to = texture_owner.get_or_null(p_proxy_to);
|
||||
ERR_FAIL_COND(!proxy_to);
|
||||
ERR_FAIL_NULL(proxy_to);
|
||||
ERR_FAIL_COND(proxy_to->is_proxy);
|
||||
|
||||
if (tex->proxy_to.is_valid()) {
|
||||
@ -1191,7 +1191,7 @@ void TextureStorage::texture_proxy_update(RID p_texture, RID p_proxy_to) {
|
||||
tex->rd_texture_srgb = RID();
|
||||
}
|
||||
Texture *prev_tex = texture_owner.get_or_null(tex->proxy_to);
|
||||
ERR_FAIL_COND(!prev_tex);
|
||||
ERR_FAIL_NULL(prev_tex);
|
||||
prev_tex->proxies.erase(p_texture);
|
||||
}
|
||||
|
||||
@ -1261,7 +1261,7 @@ void TextureStorage::texture_3d_placeholder_initialize(RID p_texture) {
|
||||
|
||||
Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND_V(!tex, Ref<Image>());
|
||||
ERR_FAIL_NULL_V(tex, Ref<Image>());
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (tex->image_cache_2d.is_valid() && !tex->is_render_target) {
|
||||
@ -1315,7 +1315,7 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
|
||||
|
||||
Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) const {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND_V(!tex, Ref<Image>());
|
||||
ERR_FAIL_NULL_V(tex, Ref<Image>());
|
||||
|
||||
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer);
|
||||
ERR_FAIL_COND_V(data.size() == 0, Ref<Image>());
|
||||
@ -1330,7 +1330,7 @@ Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons
|
||||
|
||||
Vector<Ref<Image>> TextureStorage::texture_3d_get(RID p_texture) const {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND_V(!tex, Vector<Ref<Image>>());
|
||||
ERR_FAIL_NULL_V(tex, Vector<Ref<Image>>());
|
||||
ERR_FAIL_COND_V(tex->type != TextureStorage::TYPE_3D, Vector<Ref<Image>>());
|
||||
|
||||
Vector<uint8_t> all_data = RD::get_singleton()->texture_get_data(tex->rd_texture, 0);
|
||||
@ -1359,10 +1359,10 @@ Vector<Ref<Image>> TextureStorage::texture_3d_get(RID p_texture) const {
|
||||
|
||||
void TextureStorage::texture_replace(RID p_texture, RID p_by_texture) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
ERR_FAIL_COND(tex->proxy_to.is_valid()); //can't replace proxy
|
||||
Texture *by_tex = texture_owner.get_or_null(p_by_texture);
|
||||
ERR_FAIL_COND(!by_tex);
|
||||
ERR_FAIL_NULL(by_tex);
|
||||
ERR_FAIL_COND(by_tex->proxy_to.is_valid()); //can't replace proxy
|
||||
|
||||
if (tex == by_tex) {
|
||||
@ -1404,7 +1404,7 @@ void TextureStorage::texture_replace(RID p_texture, RID p_by_texture) {
|
||||
|
||||
void TextureStorage::texture_set_size_override(RID p_texture, int p_width, int p_height) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
ERR_FAIL_COND(tex->type != TextureStorage::TYPE_2D);
|
||||
|
||||
tex->width_2d = p_width;
|
||||
@ -1413,28 +1413,28 @@ void TextureStorage::texture_set_size_override(RID p_texture, int p_width, int p
|
||||
|
||||
void TextureStorage::texture_set_path(RID p_texture, const String &p_path) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
|
||||
tex->path = p_path;
|
||||
}
|
||||
|
||||
String TextureStorage::texture_get_path(RID p_texture) const {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND_V(!tex, String());
|
||||
ERR_FAIL_NULL_V(tex, String());
|
||||
|
||||
return tex->path;
|
||||
}
|
||||
|
||||
Image::Format TextureStorage::texture_get_format(RID p_texture) const {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND_V(!tex, Image::FORMAT_MAX);
|
||||
ERR_FAIL_NULL_V(tex, Image::FORMAT_MAX);
|
||||
|
||||
return tex->format;
|
||||
}
|
||||
|
||||
void TextureStorage::texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
|
||||
tex->detect_3d_callback_ud = p_userdata;
|
||||
tex->detect_3d_callback = p_callback;
|
||||
@ -1442,7 +1442,7 @@ void TextureStorage::texture_set_detect_3d_callback(RID p_texture, RS::TextureDe
|
||||
|
||||
void TextureStorage::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
|
||||
tex->detect_normal_callback_ud = p_userdata;
|
||||
tex->detect_normal_callback = p_callback;
|
||||
@ -1450,7 +1450,7 @@ void TextureStorage::texture_set_detect_normal_callback(RID p_texture, RS::Textu
|
||||
|
||||
void TextureStorage::texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_NULL(tex);
|
||||
|
||||
tex->detect_roughness_callback_ud = p_userdata;
|
||||
tex->detect_roughness_callback = p_callback;
|
||||
@ -1554,7 +1554,7 @@ RID TextureStorage::texture_get_rd_texture(RID p_texture, bool p_srgb) const {
|
||||
|
||||
uint64_t TextureStorage::texture_get_native_handle(RID p_texture, bool p_srgb) const {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND_V(!tex, 0);
|
||||
ERR_FAIL_NULL_V(tex, 0);
|
||||
|
||||
if (p_srgb && tex->rd_texture_srgb.is_valid()) {
|
||||
return RD::get_singleton()->texture_get_native_handle(tex->rd_texture_srgb);
|
||||
@ -2418,14 +2418,14 @@ void TextureStorage::decal_free(RID p_rid) {
|
||||
|
||||
void TextureStorage::decal_set_size(RID p_decal, const Vector3 &p_size) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
decal->size = p_size;
|
||||
decal->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
}
|
||||
|
||||
void TextureStorage::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
ERR_FAIL_INDEX(p_type, RS::DECAL_TEXTURE_MAX);
|
||||
|
||||
if (decal->textures[p_type] == p_texture) {
|
||||
@ -2449,32 +2449,32 @@ void TextureStorage::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID
|
||||
|
||||
void TextureStorage::decal_set_emission_energy(RID p_decal, float p_energy) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
decal->emission_energy = p_energy;
|
||||
}
|
||||
|
||||
void TextureStorage::decal_set_albedo_mix(RID p_decal, float p_mix) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
decal->albedo_mix = p_mix;
|
||||
}
|
||||
|
||||
void TextureStorage::decal_set_modulate(RID p_decal, const Color &p_modulate) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
decal->modulate = p_modulate;
|
||||
}
|
||||
|
||||
void TextureStorage::decal_set_cull_mask(RID p_decal, uint32_t p_layers) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
decal->cull_mask = p_layers;
|
||||
decal->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_DECAL);
|
||||
}
|
||||
|
||||
void TextureStorage::decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
decal->distance_fade = p_enabled;
|
||||
decal->distance_fade_begin = p_begin;
|
||||
decal->distance_fade_length = p_length;
|
||||
@ -2482,14 +2482,14 @@ void TextureStorage::decal_set_distance_fade(RID p_decal, bool p_enabled, float
|
||||
|
||||
void TextureStorage::decal_set_fade(RID p_decal, float p_above, float p_below) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
decal->upper_fade = p_above;
|
||||
decal->lower_fade = p_below;
|
||||
}
|
||||
|
||||
void TextureStorage::decal_set_normal_fade(RID p_decal, float p_fade) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND(!decal);
|
||||
ERR_FAIL_NULL(decal);
|
||||
decal->normal_fade = p_fade;
|
||||
}
|
||||
|
||||
@ -2510,21 +2510,21 @@ void TextureStorage::decal_atlas_remove_texture(RID p_texture) {
|
||||
|
||||
AABB TextureStorage::decal_get_aabb(RID p_decal) const {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND_V(!decal, AABB());
|
||||
ERR_FAIL_NULL_V(decal, AABB());
|
||||
|
||||
return AABB(-decal->size / 2, decal->size);
|
||||
}
|
||||
|
||||
uint32_t TextureStorage::decal_get_cull_mask(RID p_decal) const {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND_V(!decal, 0);
|
||||
ERR_FAIL_NULL_V(decal, 0);
|
||||
|
||||
return decal->cull_mask;
|
||||
}
|
||||
|
||||
Dependency *TextureStorage::decal_get_dependency(RID p_decal) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND_V(!decal, nullptr);
|
||||
ERR_FAIL_NULL_V(decal, nullptr);
|
||||
|
||||
return &decal->dependency;
|
||||
}
|
||||
@ -2742,7 +2742,7 @@ void TextureStorage::texture_add_to_decal_atlas(RID p_texture, bool p_panorama_t
|
||||
|
||||
void TextureStorage::texture_remove_from_decal_atlas(RID p_texture, bool p_panorama_to_dp) {
|
||||
DecalAtlas::Texture *t = decal_atlas.textures.getptr(p_texture);
|
||||
ERR_FAIL_COND(!t);
|
||||
ERR_FAIL_NULL(t);
|
||||
t->users--;
|
||||
if (p_panorama_to_dp) {
|
||||
ERR_FAIL_COND(t->panorama_to_dp_users == 0);
|
||||
@ -2771,13 +2771,13 @@ void TextureStorage::decal_instance_free(RID p_decal_instance) {
|
||||
|
||||
void TextureStorage::decal_instance_set_transform(RID p_decal_instance, const Transform3D &p_transform) {
|
||||
DecalInstance *di = decal_instance_owner.get_or_null(p_decal_instance);
|
||||
ERR_FAIL_COND(!di);
|
||||
ERR_FAIL_NULL(di);
|
||||
di->transform = p_transform;
|
||||
}
|
||||
|
||||
void TextureStorage::decal_instance_set_sorting_offset(RID p_decal_instance, float p_sorting_offset) {
|
||||
DecalInstance *di = decal_instance_owner.get_or_null(p_decal_instance);
|
||||
ERR_FAIL_COND(!di);
|
||||
ERR_FAIL_NULL(di);
|
||||
di->sorting_offset = p_sorting_offset;
|
||||
}
|
||||
|
||||
@ -3222,7 +3222,7 @@ Point2i TextureStorage::render_target_get_position(RID p_render_target) const {
|
||||
|
||||
void TextureStorage::render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
if (rt->size.x != p_width || rt->size.y != p_height || rt->view_count != p_view_count) {
|
||||
rt->size.x = p_width;
|
||||
rt->size.y = p_height;
|
||||
@ -3233,21 +3233,21 @@ void TextureStorage::render_target_set_size(RID p_render_target, int p_width, in
|
||||
|
||||
Size2i TextureStorage::render_target_get_size(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, Size2i());
|
||||
ERR_FAIL_NULL_V(rt, Size2i());
|
||||
|
||||
return rt->size;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_texture(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
return rt->texture;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_set_override(RID p_render_target, RID p_color_texture, RID p_depth_texture, RID p_velocity_texture) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
|
||||
rt->overridden.color = p_color_texture;
|
||||
rt->overridden.depth = p_depth_texture;
|
||||
@ -3256,21 +3256,21 @@ void TextureStorage::render_target_set_override(RID p_render_target, RID p_color
|
||||
|
||||
RID TextureStorage::render_target_get_override_color(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
return rt->overridden.color;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_override_depth(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
return rt->overridden.depth;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_override_depth_slice(RID p_render_target, const uint32_t p_layer) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
if (rt->overridden.depth.is_null()) {
|
||||
return RID();
|
||||
@ -3289,14 +3289,14 @@ RID TextureStorage::render_target_get_override_depth_slice(RID p_render_target,
|
||||
|
||||
RID TextureStorage::render_target_get_override_velocity(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
return rt->overridden.velocity;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_override_velocity_slice(RID p_render_target, const uint32_t p_layer) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
if (rt->overridden.velocity.is_null()) {
|
||||
return RID();
|
||||
@ -3315,14 +3315,14 @@ RID TextureStorage::render_target_get_override_velocity_slice(RID p_render_targe
|
||||
|
||||
void TextureStorage::render_target_set_transparent(RID p_render_target, bool p_is_transparent) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
rt->is_transparent = p_is_transparent;
|
||||
_update_render_target(rt);
|
||||
}
|
||||
|
||||
bool TextureStorage::render_target_get_transparent(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, false);
|
||||
ERR_FAIL_NULL_V(rt, false);
|
||||
|
||||
return rt->is_transparent;
|
||||
}
|
||||
@ -3336,19 +3336,19 @@ bool TextureStorage::render_target_get_direct_to_screen(RID p_render_target) con
|
||||
|
||||
bool TextureStorage::render_target_was_used(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, false);
|
||||
ERR_FAIL_NULL_V(rt, false);
|
||||
return rt->was_used;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_set_as_unused(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
rt->was_used = false;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
if (p_msaa == rt->msaa) {
|
||||
return;
|
||||
}
|
||||
@ -3359,14 +3359,14 @@ void TextureStorage::render_target_set_msaa(RID p_render_target, RS::ViewportMSA
|
||||
|
||||
RS::ViewportMSAA TextureStorage::render_target_get_msaa(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RS::VIEWPORT_MSAA_DISABLED);
|
||||
ERR_FAIL_NULL_V(rt, RS::VIEWPORT_MSAA_DISABLED);
|
||||
|
||||
return rt->msaa;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_set_use_hdr(RID p_render_target, bool p_use_hdr) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
|
||||
if (p_use_hdr == rt->use_hdr) {
|
||||
return;
|
||||
@ -3378,21 +3378,21 @@ void TextureStorage::render_target_set_use_hdr(RID p_render_target, bool p_use_h
|
||||
|
||||
bool TextureStorage::render_target_is_using_hdr(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, false);
|
||||
ERR_FAIL_NULL_V(rt, false);
|
||||
|
||||
return rt->use_hdr;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_rd_framebuffer(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
return rt->get_framebuffer();
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_rd_texture(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
if (rt->overridden.color.is_valid()) {
|
||||
return rt->overridden.color;
|
||||
@ -3403,7 +3403,7 @@ RID TextureStorage::render_target_get_rd_texture(RID p_render_target) {
|
||||
|
||||
RID TextureStorage::render_target_get_rd_texture_slice(RID p_render_target, uint32_t p_layer) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
if (rt->view_count == 1) {
|
||||
return rt->color;
|
||||
@ -3421,20 +3421,20 @@ RID TextureStorage::render_target_get_rd_texture_slice(RID p_render_target, uint
|
||||
|
||||
RID TextureStorage::render_target_get_rd_texture_msaa(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
return rt->color_multisample;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_rd_backbuffer(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
return rt->backbuffer;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_rd_backbuffer_framebuffer(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
if (!rt->backbuffer.is_valid()) {
|
||||
_create_render_target_backbuffer(rt);
|
||||
@ -3445,32 +3445,32 @@ RID TextureStorage::render_target_get_rd_backbuffer_framebuffer(RID p_render_tar
|
||||
|
||||
void TextureStorage::render_target_request_clear(RID p_render_target, const Color &p_clear_color) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
rt->clear_requested = true;
|
||||
rt->clear_color = p_clear_color;
|
||||
}
|
||||
|
||||
bool TextureStorage::render_target_is_clear_requested(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, false);
|
||||
ERR_FAIL_NULL_V(rt, false);
|
||||
return rt->clear_requested;
|
||||
}
|
||||
|
||||
Color TextureStorage::render_target_get_clear_request_color(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, Color());
|
||||
ERR_FAIL_NULL_V(rt, Color());
|
||||
return rt->use_hdr ? rt->clear_color.srgb_to_linear() : rt->clear_color;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_disable_clear_request(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
rt->clear_requested = false;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_do_clear_request(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
if (!rt->clear_requested) {
|
||||
return;
|
||||
}
|
||||
@ -3483,7 +3483,7 @@ void TextureStorage::render_target_do_clear_request(RID p_render_target) {
|
||||
|
||||
void TextureStorage::render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
if (rt->sdf_oversize == p_size && rt->sdf_scale == p_scale) {
|
||||
return;
|
||||
}
|
||||
@ -3525,28 +3525,28 @@ Rect2i TextureStorage::_render_target_get_sdf_rect(const RenderTarget *rt) const
|
||||
|
||||
Rect2i TextureStorage::render_target_get_sdf_rect(RID p_render_target) const {
|
||||
const RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, Rect2i());
|
||||
ERR_FAIL_NULL_V(rt, Rect2i());
|
||||
|
||||
return _render_target_get_sdf_rect(rt);
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_mark_sdf_enabled(RID p_render_target, bool p_enabled) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
|
||||
rt->sdf_enabled = p_enabled;
|
||||
}
|
||||
|
||||
bool TextureStorage::render_target_is_sdf_enabled(RID p_render_target) const {
|
||||
const RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, false);
|
||||
ERR_FAIL_NULL_V(rt, false);
|
||||
|
||||
return rt->sdf_enabled;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_sdf_texture(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
if (rt->sdf_buffer_read.is_null()) {
|
||||
// no texture, create a dummy one for the 2D uniform set
|
||||
RD::TextureFormat tformat;
|
||||
@ -3684,7 +3684,7 @@ void TextureStorage::_render_target_clear_sdf(RenderTarget *rt) {
|
||||
|
||||
RID TextureStorage::render_target_get_sdf_framebuffer(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
if (rt->sdf_buffer_write_fb.is_null()) {
|
||||
_render_target_allocate_sdf(rt);
|
||||
@ -3694,7 +3694,7 @@ RID TextureStorage::render_target_get_sdf_framebuffer(RID p_render_target) {
|
||||
}
|
||||
void TextureStorage::render_target_sdf_process(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
ERR_FAIL_COND(rt->sdf_buffer_write_fb.is_null());
|
||||
|
||||
RenderTargetSDF::PushConstant push_constant;
|
||||
@ -3772,7 +3772,7 @@ void TextureStorage::render_target_copy_to_back_buffer(RID p_render_target, cons
|
||||
ERR_FAIL_NULL(copy_effects);
|
||||
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
if (!rt->backbuffer.is_valid()) {
|
||||
_create_render_target_backbuffer(rt);
|
||||
}
|
||||
@ -3825,7 +3825,7 @@ void TextureStorage::render_target_copy_to_back_buffer(RID p_render_target, cons
|
||||
|
||||
void TextureStorage::render_target_clear_back_buffer(RID p_render_target, const Rect2i &p_region, const Color &p_color) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
|
||||
CopyEffects *copy_effects = CopyEffects::get_singleton();
|
||||
ERR_FAIL_NULL(copy_effects);
|
||||
@ -3854,7 +3854,7 @@ void TextureStorage::render_target_clear_back_buffer(RID p_render_target, const
|
||||
|
||||
void TextureStorage::render_target_gen_back_buffer_mipmaps(RID p_render_target, const Rect2i &p_region) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
|
||||
CopyEffects *copy_effects = CopyEffects::get_singleton();
|
||||
ERR_FAIL_NULL(copy_effects);
|
||||
@ -3899,51 +3899,51 @@ void TextureStorage::render_target_gen_back_buffer_mipmaps(RID p_render_target,
|
||||
|
||||
RID TextureStorage::render_target_get_framebuffer_uniform_set(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
return rt->framebuffer_uniform_set;
|
||||
}
|
||||
RID TextureStorage::render_target_get_backbuffer_uniform_set(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
return rt->backbuffer_uniform_set;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_set_framebuffer_uniform_set(RID p_render_target, RID p_uniform_set) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
rt->framebuffer_uniform_set = p_uniform_set;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_set_backbuffer_uniform_set(RID p_render_target, RID p_uniform_set) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
rt->backbuffer_uniform_set = p_uniform_set;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_set_vrs_mode(RID p_render_target, RS::ViewportVRSMode p_mode) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
|
||||
rt->vrs_mode = p_mode;
|
||||
}
|
||||
|
||||
RS::ViewportVRSMode TextureStorage::render_target_get_vrs_mode(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RS::VIEWPORT_VRS_DISABLED);
|
||||
ERR_FAIL_NULL_V(rt, RS::VIEWPORT_VRS_DISABLED);
|
||||
|
||||
return rt->vrs_mode;
|
||||
}
|
||||
|
||||
void TextureStorage::render_target_set_vrs_texture(RID p_render_target, RID p_texture) {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
ERR_FAIL_NULL(rt);
|
||||
|
||||
rt->vrs_texture = p_texture;
|
||||
}
|
||||
|
||||
RID TextureStorage::render_target_get_vrs_texture(RID p_render_target) const {
|
||||
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
ERR_FAIL_NULL_V(rt, RID());
|
||||
|
||||
return rt->vrs_texture;
|
||||
}
|
||||
|
@ -175,27 +175,27 @@ void Utilities::visibility_notifier_free(RID p_notifier) {
|
||||
|
||||
void Utilities::visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) {
|
||||
VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
||||
ERR_FAIL_COND(!vn);
|
||||
ERR_FAIL_NULL(vn);
|
||||
vn->aabb = p_aabb;
|
||||
vn->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
}
|
||||
|
||||
void Utilities::visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) {
|
||||
VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
||||
ERR_FAIL_COND(!vn);
|
||||
ERR_FAIL_NULL(vn);
|
||||
vn->enter_callback = p_enter_callbable;
|
||||
vn->exit_callback = p_exit_callable;
|
||||
}
|
||||
|
||||
AABB Utilities::visibility_notifier_get_aabb(RID p_notifier) const {
|
||||
const VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
||||
ERR_FAIL_COND_V(!vn, AABB());
|
||||
ERR_FAIL_NULL_V(vn, AABB());
|
||||
return vn->aabb;
|
||||
}
|
||||
|
||||
void Utilities::visibility_notifier_call(RID p_notifier, bool p_enter, bool p_deferred) {
|
||||
VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
||||
ERR_FAIL_COND(!vn);
|
||||
ERR_FAIL_NULL(vn);
|
||||
|
||||
if (p_enter) {
|
||||
if (!vn->enter_callback.is_null()) {
|
||||
|
@ -63,7 +63,7 @@ void RendererSceneCull::camera_initialize(RID p_rid) {
|
||||
|
||||
void RendererSceneCull::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
camera->type = Camera::PERSPECTIVE;
|
||||
camera->fov = p_fovy_degrees;
|
||||
camera->znear = p_z_near;
|
||||
@ -72,7 +72,7 @@ void RendererSceneCull::camera_set_perspective(RID p_camera, float p_fovy_degree
|
||||
|
||||
void RendererSceneCull::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
camera->type = Camera::ORTHOGONAL;
|
||||
camera->size = p_size;
|
||||
camera->znear = p_z_near;
|
||||
@ -81,7 +81,7 @@ void RendererSceneCull::camera_set_orthogonal(RID p_camera, float p_size, float
|
||||
|
||||
void RendererSceneCull::camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
camera->type = Camera::FRUSTUM;
|
||||
camera->size = p_size;
|
||||
camera->offset = p_offset;
|
||||
@ -91,32 +91,32 @@ void RendererSceneCull::camera_set_frustum(RID p_camera, float p_size, Vector2 p
|
||||
|
||||
void RendererSceneCull::camera_set_transform(RID p_camera, const Transform3D &p_transform) {
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
camera->transform = p_transform.orthonormalized();
|
||||
}
|
||||
|
||||
void RendererSceneCull::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
|
||||
camera->visible_layers = p_layers;
|
||||
}
|
||||
|
||||
void RendererSceneCull::camera_set_environment(RID p_camera, RID p_env) {
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
camera->env = p_env;
|
||||
}
|
||||
|
||||
void RendererSceneCull::camera_set_camera_attributes(RID p_camera, RID p_attributes) {
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
camera->attributes = p_attributes;
|
||||
}
|
||||
|
||||
void RendererSceneCull::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
camera->vaspect = p_enable;
|
||||
}
|
||||
|
||||
@ -390,25 +390,25 @@ void RendererSceneCull::scenario_initialize(RID p_rid) {
|
||||
|
||||
void RendererSceneCull::scenario_set_environment(RID p_scenario, RID p_environment) {
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND(!scenario);
|
||||
ERR_FAIL_NULL(scenario);
|
||||
scenario->environment = p_environment;
|
||||
}
|
||||
|
||||
void RendererSceneCull::scenario_set_camera_attributes(RID p_scenario, RID p_camera_attributes) {
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND(!scenario);
|
||||
ERR_FAIL_NULL(scenario);
|
||||
scenario->camera_attributes = p_camera_attributes;
|
||||
}
|
||||
|
||||
void RendererSceneCull::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND(!scenario);
|
||||
ERR_FAIL_NULL(scenario);
|
||||
scenario->fallback_environment = p_environment;
|
||||
}
|
||||
|
||||
void RendererSceneCull::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) {
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND(!scenario);
|
||||
ERR_FAIL_NULL(scenario);
|
||||
RSG::light_storage->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count);
|
||||
}
|
||||
|
||||
@ -418,13 +418,13 @@ bool RendererSceneCull::is_scenario(RID p_scenario) const {
|
||||
|
||||
RID RendererSceneCull::scenario_get_environment(RID p_scenario) {
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND_V(!scenario, RID());
|
||||
ERR_FAIL_NULL_V(scenario, RID());
|
||||
return scenario->environment;
|
||||
}
|
||||
|
||||
void RendererSceneCull::scenario_remove_viewport_visibility_mask(RID p_scenario, RID p_viewport) {
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND(!scenario);
|
||||
ERR_FAIL_NULL(scenario);
|
||||
if (!scenario->viewport_visibility_masks.has(p_viewport)) {
|
||||
return;
|
||||
}
|
||||
@ -436,7 +436,7 @@ void RendererSceneCull::scenario_remove_viewport_visibility_mask(RID p_scenario,
|
||||
|
||||
void RendererSceneCull::scenario_add_viewport_visibility_mask(RID p_scenario, RID p_viewport) {
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND(!scenario);
|
||||
ERR_FAIL_NULL(scenario);
|
||||
ERR_FAIL_COND(scenario->viewport_visibility_masks.has(p_viewport));
|
||||
|
||||
uint64_t new_mask = 1;
|
||||
@ -510,7 +510,7 @@ void RendererSceneCull::_instance_update_mesh_instance(Instance *p_instance) {
|
||||
|
||||
void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
Scenario *scenario = instance->scenario;
|
||||
|
||||
@ -753,7 +753,7 @@ void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
|
||||
|
||||
void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
if (instance->scenario) {
|
||||
instance->scenario->instances.remove(&instance->scenario_item);
|
||||
@ -819,7 +819,7 @@ void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
|
||||
|
||||
if (p_scenario.is_valid()) {
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND(!scenario);
|
||||
ERR_FAIL_NULL(scenario);
|
||||
|
||||
instance->scenario = scenario;
|
||||
|
||||
@ -852,7 +852,7 @@ void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
|
||||
|
||||
void RendererSceneCull::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
if (instance->layer_mask == p_mask) {
|
||||
return;
|
||||
@ -879,7 +879,7 @@ void RendererSceneCull::instance_set_layer_mask(RID p_instance, uint32_t p_mask)
|
||||
|
||||
void RendererSceneCull::instance_set_pivot_data(RID p_instance, float p_sorting_offset, bool p_use_aabb_center) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->sorting_offset = p_sorting_offset;
|
||||
instance->use_aabb_center = p_use_aabb_center;
|
||||
@ -896,7 +896,7 @@ void RendererSceneCull::instance_set_pivot_data(RID p_instance, float p_sorting_
|
||||
|
||||
void RendererSceneCull::instance_geometry_set_transparency(RID p_instance, float p_transparency) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->transparency = p_transparency;
|
||||
|
||||
@ -909,7 +909,7 @@ void RendererSceneCull::instance_geometry_set_transparency(RID p_instance, float
|
||||
|
||||
void RendererSceneCull::instance_set_transform(RID p_instance, const Transform3D &p_transform) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
if (instance->transform == p_transform) {
|
||||
return; //must be checked to avoid worst evil
|
||||
@ -929,14 +929,14 @@ void RendererSceneCull::instance_set_transform(RID p_instance, const Transform3D
|
||||
|
||||
void RendererSceneCull::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->object_id = p_id;
|
||||
}
|
||||
|
||||
void RendererSceneCull::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
if (instance->update_item.in_list()) {
|
||||
_update_dirty_instance(instance);
|
||||
@ -949,7 +949,7 @@ void RendererSceneCull::instance_set_blend_shape_weight(RID p_instance, int p_sh
|
||||
|
||||
void RendererSceneCull::instance_set_surface_override_material(RID p_instance, int p_surface, RID p_material) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
if (instance->base_type == RS::INSTANCE_MESH) {
|
||||
//may not have been updated yet, may also have not been set yet. When updated will be correcte, worst case
|
||||
@ -965,7 +965,7 @@ void RendererSceneCull::instance_set_surface_override_material(RID p_instance, i
|
||||
|
||||
void RendererSceneCull::instance_set_visible(RID p_instance, bool p_visible) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
if (instance->visible == p_visible) {
|
||||
return;
|
||||
@ -1015,7 +1015,7 @@ inline bool is_geometry_instance(RenderingServer::InstanceType p_type) {
|
||||
|
||||
void RendererSceneCull::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
ERR_FAIL_COND(!is_geometry_instance(instance->base_type));
|
||||
|
||||
if (p_aabb != AABB()) {
|
||||
@ -1040,7 +1040,7 @@ void RendererSceneCull::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
|
||||
|
||||
void RendererSceneCull::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
if (instance->skeleton == p_skeleton) {
|
||||
return;
|
||||
@ -1066,7 +1066,7 @@ void RendererSceneCull::instance_attach_skeleton(RID p_instance, RID p_skeleton)
|
||||
|
||||
void RendererSceneCull::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->extra_margin = p_margin;
|
||||
_instance_queue_update(instance, true, false);
|
||||
@ -1074,7 +1074,7 @@ void RendererSceneCull::instance_set_extra_visibility_margin(RID p_instance, rea
|
||||
|
||||
void RendererSceneCull::instance_set_ignore_culling(RID p_instance, bool p_enabled) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
instance->ignore_all_culling = p_enabled;
|
||||
|
||||
if (instance->scenario && instance->array_index >= 0) {
|
||||
@ -1090,7 +1090,7 @@ void RendererSceneCull::instance_set_ignore_culling(RID p_instance, bool p_enabl
|
||||
Vector<ObjectID> RendererSceneCull::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
|
||||
Vector<ObjectID> instances;
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND_V(!scenario, instances);
|
||||
ERR_FAIL_NULL_V(scenario, instances);
|
||||
|
||||
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
|
||||
|
||||
@ -1114,7 +1114,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_aabb(const AABB &p_aabb, RID
|
||||
Vector<ObjectID> RendererSceneCull::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
|
||||
Vector<ObjectID> instances;
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND_V(!scenario, instances);
|
||||
ERR_FAIL_NULL_V(scenario, instances);
|
||||
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
|
||||
|
||||
struct CullRay {
|
||||
@ -1137,7 +1137,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_ray(const Vector3 &p_from, co
|
||||
Vector<ObjectID> RendererSceneCull::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
|
||||
Vector<ObjectID> instances;
|
||||
Scenario *scenario = scenario_owner.get_or_null(p_scenario);
|
||||
ERR_FAIL_COND_V(!scenario, instances);
|
||||
ERR_FAIL_NULL_V(scenario, instances);
|
||||
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
|
||||
|
||||
Vector<Vector3> points = Geometry3D::compute_convex_mesh_points(&p_convex[0], p_convex.size());
|
||||
@ -1161,7 +1161,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_convex(const Vector<Plane> &p
|
||||
|
||||
void RendererSceneCull::instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
//ERR_FAIL_COND(((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK));
|
||||
|
||||
@ -1238,7 +1238,7 @@ void RendererSceneCull::instance_geometry_set_flag(RID p_instance, RS::InstanceF
|
||||
|
||||
void RendererSceneCull::instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->cast_shadows = p_shadow_casting_setting;
|
||||
|
||||
@ -1270,7 +1270,7 @@ void RendererSceneCull::instance_geometry_set_cast_shadows_setting(RID p_instanc
|
||||
|
||||
void RendererSceneCull::instance_geometry_set_material_override(RID p_instance, RID p_material) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->material_override = p_material;
|
||||
_instance_queue_update(instance, false, true);
|
||||
@ -1284,7 +1284,7 @@ void RendererSceneCull::instance_geometry_set_material_override(RID p_instance,
|
||||
|
||||
void RendererSceneCull::instance_geometry_set_material_overlay(RID p_instance, RID p_material) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->material_overlay = p_material;
|
||||
_instance_queue_update(instance, false, true);
|
||||
@ -1298,7 +1298,7 @@ void RendererSceneCull::instance_geometry_set_material_overlay(RID p_instance, R
|
||||
|
||||
void RendererSceneCull::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) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->visibility_range_begin = p_min;
|
||||
instance->visibility_range_end = p_max;
|
||||
@ -1320,7 +1320,7 @@ void RendererSceneCull::instance_geometry_set_visibility_range(RID p_instance, f
|
||||
|
||||
void RendererSceneCull::instance_set_visibility_parent(RID p_instance, RID p_parent_instance) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
Instance *old_parent = instance->visibility_parent;
|
||||
if (old_parent) {
|
||||
@ -1440,7 +1440,7 @@ void RendererSceneCull::_update_instance_visibility_dependencies(Instance *p_ins
|
||||
|
||||
void RendererSceneCull::instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
if (instance->lightmap) {
|
||||
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(((Instance *)instance->lightmap)->base_data);
|
||||
@ -1471,7 +1471,7 @@ void RendererSceneCull::instance_geometry_set_lightmap(RID p_instance, RID p_lig
|
||||
|
||||
void RendererSceneCull::instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
instance->lod_bias = p_lod_bias;
|
||||
|
||||
@ -1484,7 +1484,7 @@ void RendererSceneCull::instance_geometry_set_lod_bias(RID p_instance, float p_l
|
||||
|
||||
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);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
ERR_FAIL_COND(p_value.get_type() == Variant::OBJECT);
|
||||
|
||||
@ -1522,7 +1522,7 @@ void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, c
|
||||
|
||||
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());
|
||||
ERR_FAIL_NULL_V(instance, Variant());
|
||||
|
||||
if (instance->instance_shader_uniforms.has(p_parameter)) {
|
||||
return instance->instance_shader_uniforms[p_parameter].value;
|
||||
@ -1532,7 +1532,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_parameter(RID p_instance
|
||||
|
||||
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());
|
||||
ERR_FAIL_NULL_V(instance, Variant());
|
||||
|
||||
if (instance->instance_shader_uniforms.has(p_parameter)) {
|
||||
return instance->instance_shader_uniforms[p_parameter].default_value;
|
||||
@ -1542,7 +1542,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_parameter_default_value(
|
||||
|
||||
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);
|
||||
ERR_FAIL_NULL(instance);
|
||||
|
||||
const_cast<RendererSceneCull *>(this)->update_dirty_instances();
|
||||
|
||||
@ -2517,7 +2517,7 @@ void RendererSceneCull::render_camera(const Ref<RenderSceneBuffers> &p_render_bu
|
||||
#ifndef _3D_DISABLED
|
||||
|
||||
Camera *camera = camera_owner.get_or_null(p_camera);
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
|
||||
Vector2 jitter;
|
||||
if (p_jitter_phase_count > 0) {
|
||||
@ -3397,7 +3397,7 @@ void RendererSceneCull::render_empty_scene(const Ref<RenderSceneBuffers> &p_rend
|
||||
bool RendererSceneCull::_render_reflection_probe_step(Instance *p_instance, int p_step) {
|
||||
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
|
||||
Scenario *scenario = p_instance->scenario;
|
||||
ERR_FAIL_COND_V(!scenario, true);
|
||||
ERR_FAIL_NULL_V(scenario, true);
|
||||
|
||||
RenderingServerDefault::redraw_request(); //update, so it updates in editor
|
||||
|
||||
|
@ -824,7 +824,7 @@ void RendererViewport::viewport_initialize(RID p_rid) {
|
||||
|
||||
void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (viewport->use_xr == p_use_xr) {
|
||||
return;
|
||||
@ -842,7 +842,7 @@ void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) {
|
||||
|
||||
void RendererViewport::viewport_set_scaling_3d_mode(RID p_viewport, RS::ViewportScaling3DMode p_mode) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
ERR_FAIL_COND_EDMSG(p_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR2 && OS::get_singleton()->get_current_rendering_method() != "forward_plus", "FSR2 is only available when using the Forward+ renderer.");
|
||||
|
||||
if (viewport->scaling_3d_mode == p_mode) {
|
||||
@ -862,7 +862,7 @@ void RendererViewport::viewport_set_scaling_3d_mode(RID p_viewport, RS::Viewport
|
||||
|
||||
void RendererViewport::viewport_set_fsr_sharpness(RID p_viewport, float p_sharpness) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->fsr_sharpness = p_sharpness;
|
||||
if (viewport->render_buffers.is_valid()) {
|
||||
@ -872,7 +872,7 @@ void RendererViewport::viewport_set_fsr_sharpness(RID p_viewport, float p_sharpn
|
||||
|
||||
void RendererViewport::viewport_set_texture_mipmap_bias(RID p_viewport, float p_mipmap_bias) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->texture_mipmap_bias = p_mipmap_bias;
|
||||
if (viewport->render_buffers.is_valid()) {
|
||||
@ -882,7 +882,7 @@ void RendererViewport::viewport_set_texture_mipmap_bias(RID p_viewport, float p_
|
||||
|
||||
void RendererViewport::viewport_set_scaling_3d_scale(RID p_viewport, float p_scaling_3d_scale) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
// Clamp to reasonable values that are actually useful.
|
||||
// Values above 2.0 don't serve a practical purpose since the viewport
|
||||
@ -899,7 +899,7 @@ void RendererViewport::viewport_set_size(RID p_viewport, int p_width, int p_heig
|
||||
ERR_FAIL_COND(p_width < 0 || p_height < 0);
|
||||
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
ERR_FAIL_COND_MSG(viewport->use_xr, "Cannot set viewport size when using XR");
|
||||
|
||||
_viewport_set_size(viewport, p_width, p_height, 1);
|
||||
@ -924,7 +924,7 @@ bool RendererViewport::_viewport_requires_motion_vectors(Viewport *p_viewport) {
|
||||
|
||||
void RendererViewport::viewport_set_active(RID p_viewport, bool p_active) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (p_active) {
|
||||
ERR_FAIL_COND_MSG(active_viewports.has(viewport), "Can't make active a Viewport that is already active.");
|
||||
@ -939,21 +939,21 @@ void RendererViewport::viewport_set_active(RID p_viewport, bool p_active) {
|
||||
|
||||
void RendererViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->parent = p_parent_viewport;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->clear_mode = p_clear_mode;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, DisplayServer::WindowID p_screen) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (p_screen != DisplayServer::INVALID_WINDOW_ID) {
|
||||
// If using OpenGL we can optimize this operation by rendering directly to system_fbo
|
||||
@ -979,7 +979,7 @@ void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_
|
||||
|
||||
void RendererViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (p_enable == viewport->viewport_render_direct_to_screen) {
|
||||
return;
|
||||
@ -1003,28 +1003,28 @@ void RendererViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool
|
||||
|
||||
void RendererViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->update_mode = p_mode;
|
||||
}
|
||||
|
||||
RID RendererViewport::viewport_get_render_target(RID p_viewport) const {
|
||||
const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND_V(!viewport, RID());
|
||||
ERR_FAIL_NULL_V(viewport, RID());
|
||||
|
||||
return viewport->render_target;
|
||||
}
|
||||
|
||||
RID RendererViewport::viewport_get_texture(RID p_viewport) const {
|
||||
const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND_V(!viewport, RID());
|
||||
ERR_FAIL_NULL_V(viewport, RID());
|
||||
|
||||
return RSG::texture_storage->render_target_get_texture(viewport->render_target);
|
||||
}
|
||||
|
||||
RID RendererViewport::viewport_get_occluder_debug_texture(RID p_viewport) const {
|
||||
const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND_V(!viewport, RID());
|
||||
ERR_FAIL_NULL_V(viewport, RID());
|
||||
|
||||
if (viewport->use_occlusion_culling && viewport->debug_draw == RenderingServer::VIEWPORT_DEBUG_DRAW_OCCLUDERS) {
|
||||
return RendererSceneOcclusionCull::get_singleton()->buffer_get_debug_texture(p_viewport);
|
||||
@ -1034,7 +1034,7 @@ RID RendererViewport::viewport_get_occluder_debug_texture(RID p_viewport) const
|
||||
|
||||
void RendererViewport::viewport_set_prev_camera_data(RID p_viewport, const RendererSceneRender::CameraData *p_camera_data) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
uint64_t frame = RSG::rasterizer->get_frame_number();
|
||||
if (viewport->prev_camera_data_frame != frame) {
|
||||
viewport->prev_camera_data = *p_camera_data;
|
||||
@ -1044,26 +1044,26 @@ void RendererViewport::viewport_set_prev_camera_data(RID p_viewport, const Rende
|
||||
|
||||
const RendererSceneRender::CameraData *RendererViewport::viewport_get_prev_camera_data(RID p_viewport) {
|
||||
const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND_V(!viewport, nullptr);
|
||||
ERR_FAIL_NULL_V(viewport, nullptr);
|
||||
return &viewport->prev_camera_data;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_disable_2d(RID p_viewport, bool p_disable) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->disable_2d = p_disable;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_environment_mode(RID p_viewport, RS::ViewportEnvironmentMode p_mode) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->disable_environment = p_mode;
|
||||
}
|
||||
|
||||
bool RendererViewport::viewport_is_environment_disabled(Viewport *viewport) {
|
||||
ERR_FAIL_COND_V(!viewport, false);
|
||||
ERR_FAIL_NULL_V(viewport, false);
|
||||
|
||||
if (viewport->parent.is_valid() && viewport->disable_environment == RS::VIEWPORT_ENVIRONMENT_INHERIT) {
|
||||
Viewport *parent = viewport_owner.get_or_null(viewport->parent);
|
||||
@ -1074,21 +1074,21 @@ bool RendererViewport::viewport_is_environment_disabled(Viewport *viewport) {
|
||||
|
||||
void RendererViewport::viewport_set_disable_3d(RID p_viewport, bool p_disable) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->disable_3d = p_disable;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->camera = p_camera;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (viewport->scenario.is_valid()) {
|
||||
RSG::scene->scenario_remove_viewport_visibility_mask(viewport->scenario, p_viewport);
|
||||
@ -1102,11 +1102,11 @@ void RendererViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
|
||||
|
||||
void RendererViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
ERR_FAIL_COND(viewport->canvas_map.has(p_canvas));
|
||||
RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.get_or_null(p_canvas);
|
||||
ERR_FAIL_COND(!canvas);
|
||||
ERR_FAIL_NULL(canvas);
|
||||
|
||||
canvas->viewports.insert(p_viewport);
|
||||
viewport->canvas_map[p_canvas] = Viewport::CanvasData();
|
||||
@ -1117,10 +1117,10 @@ void RendererViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
|
||||
|
||||
void RendererViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.get_or_null(p_canvas);
|
||||
ERR_FAIL_COND(!canvas);
|
||||
ERR_FAIL_NULL(canvas);
|
||||
|
||||
viewport->canvas_map.erase(p_canvas);
|
||||
canvas->viewports.erase(p_viewport);
|
||||
@ -1128,7 +1128,7 @@ void RendererViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
|
||||
|
||||
void RendererViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
|
||||
viewport->canvas_map[p_canvas].transform = p_offset;
|
||||
@ -1136,7 +1136,7 @@ void RendererViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canva
|
||||
|
||||
void RendererViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
RSG::texture_storage->render_target_set_transparent(viewport->render_target, p_enabled);
|
||||
viewport->transparent_bg = p_enabled;
|
||||
@ -1144,14 +1144,14 @@ void RendererViewport::viewport_set_transparent_background(RID p_viewport, bool
|
||||
|
||||
void RendererViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->global_transform = p_transform;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
|
||||
viewport->canvas_map[p_canvas].layer = p_layer;
|
||||
@ -1160,7 +1160,7 @@ void RendererViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas
|
||||
|
||||
void RendererViewport::viewport_set_positional_shadow_atlas_size(RID p_viewport, int p_size, bool p_16_bits) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->shadow_atlas_size = p_size;
|
||||
viewport->shadow_atlas_16_bits = p_16_bits;
|
||||
@ -1170,14 +1170,14 @@ void RendererViewport::viewport_set_positional_shadow_atlas_size(RID p_viewport,
|
||||
|
||||
void RendererViewport::viewport_set_positional_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
RSG::light_storage->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_msaa_2d(RID p_viewport, RS::ViewportMSAA p_msaa) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (viewport->msaa_2d == p_msaa) {
|
||||
return;
|
||||
@ -1188,7 +1188,7 @@ void RendererViewport::viewport_set_msaa_2d(RID p_viewport, RS::ViewportMSAA p_m
|
||||
|
||||
void RendererViewport::viewport_set_msaa_3d(RID p_viewport, RS::ViewportMSAA p_msaa) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (viewport->msaa_3d == p_msaa) {
|
||||
return;
|
||||
@ -1199,7 +1199,7 @@ void RendererViewport::viewport_set_msaa_3d(RID p_viewport, RS::ViewportMSAA p_m
|
||||
|
||||
void RendererViewport::viewport_set_use_hdr_2d(RID p_viewport, bool p_use_hdr_2d) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (viewport->use_hdr_2d == p_use_hdr_2d) {
|
||||
return;
|
||||
@ -1210,7 +1210,7 @@ void RendererViewport::viewport_set_use_hdr_2d(RID p_viewport, bool p_use_hdr_2d
|
||||
|
||||
void RendererViewport::viewport_set_screen_space_aa(RID p_viewport, RS::ViewportScreenSpaceAA p_mode) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (viewport->screen_space_aa == p_mode) {
|
||||
return;
|
||||
@ -1221,7 +1221,7 @@ void RendererViewport::viewport_set_screen_space_aa(RID p_viewport, RS::Viewport
|
||||
|
||||
void RendererViewport::viewport_set_use_taa(RID p_viewport, bool p_use_taa) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
ERR_FAIL_COND_EDMSG(OS::get_singleton()->get_current_rendering_method() != "forward_plus", "TAA is only available when using the Forward+ renderer.");
|
||||
|
||||
if (viewport->use_taa == p_use_taa) {
|
||||
@ -1241,7 +1241,7 @@ void RendererViewport::viewport_set_use_taa(RID p_viewport, bool p_use_taa) {
|
||||
|
||||
void RendererViewport::viewport_set_use_debanding(RID p_viewport, bool p_use_debanding) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (viewport->use_debanding == p_use_debanding) {
|
||||
return;
|
||||
@ -1254,7 +1254,7 @@ void RendererViewport::viewport_set_use_debanding(RID p_viewport, bool p_use_deb
|
||||
|
||||
void RendererViewport::viewport_set_use_occlusion_culling(RID p_viewport, bool p_use_occlusion_culling) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
if (viewport->use_occlusion_culling == p_use_occlusion_culling) {
|
||||
return;
|
||||
@ -1289,7 +1289,7 @@ void RendererViewport::viewport_set_occlusion_culling_build_quality(RS::Viewport
|
||||
|
||||
void RendererViewport::viewport_set_mesh_lod_threshold(RID p_viewport, float p_pixels) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->mesh_lod_threshold = p_pixels;
|
||||
}
|
||||
@ -1308,62 +1308,62 @@ int RendererViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRende
|
||||
|
||||
void RendererViewport::viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->debug_draw = p_draw;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_measure_render_time(RID p_viewport, bool p_enable) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->measure_render_time = p_enable;
|
||||
}
|
||||
|
||||
float RendererViewport::viewport_get_measured_render_time_cpu(RID p_viewport) const {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND_V(!viewport, 0);
|
||||
ERR_FAIL_NULL_V(viewport, 0);
|
||||
|
||||
return double(viewport->time_cpu_end - viewport->time_cpu_begin) / 1000.0;
|
||||
}
|
||||
|
||||
float RendererViewport::viewport_get_measured_render_time_gpu(RID p_viewport) const {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND_V(!viewport, 0);
|
||||
ERR_FAIL_NULL_V(viewport, 0);
|
||||
|
||||
return double((viewport->time_gpu_end - viewport->time_gpu_begin) / 1000) / 1000.0;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_snap_2d_transforms_to_pixel(RID p_viewport, bool p_enabled) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
viewport->snap_2d_transforms_to_pixel = p_enabled;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_snap_2d_vertices_to_pixel(RID p_viewport, bool p_enabled) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
viewport->snap_2d_vertices_to_pixel = p_enabled;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_default_canvas_item_texture_filter(RID p_viewport, RS::CanvasItemTextureFilter p_filter) {
|
||||
ERR_FAIL_COND_MSG(p_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, "Viewport does not accept DEFAULT as texture filter (it's the topmost choice already).)");
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->texture_filter = p_filter;
|
||||
}
|
||||
void RendererViewport::viewport_set_default_canvas_item_texture_repeat(RID p_viewport, RS::CanvasItemTextureRepeat p_repeat) {
|
||||
ERR_FAIL_COND_MSG(p_repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, "Viewport does not accept DEFAULT as texture repeat (it's the topmost choice already).)");
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
viewport->texture_repeat = p_repeat;
|
||||
}
|
||||
|
||||
void RendererViewport::viewport_set_sdf_oversize_and_scale(RID p_viewport, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
RSG::texture_storage->render_target_set_sdf_size_and_scale(viewport->render_target, p_size, p_scale);
|
||||
}
|
||||
@ -1384,7 +1384,7 @@ RID RendererViewport::viewport_find_from_screen_attachment(DisplayServer::Window
|
||||
|
||||
void RendererViewport::viewport_set_vrs_mode(RID p_viewport, RS::ViewportVRSMode p_mode) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
RSG::texture_storage->render_target_set_vrs_mode(viewport->render_target, p_mode);
|
||||
_configure_3d_render_buffers(viewport);
|
||||
@ -1392,7 +1392,7 @@ void RendererViewport::viewport_set_vrs_mode(RID p_viewport, RS::ViewportVRSMode
|
||||
|
||||
void RendererViewport::viewport_set_vrs_texture(RID p_viewport, RID p_texture) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
|
||||
RSG::texture_storage->render_target_set_vrs_texture(viewport->render_target, p_texture);
|
||||
_configure_3d_render_buffers(viewport);
|
||||
@ -1460,7 +1460,7 @@ void RendererViewport::set_default_clear_color(const Color &p_color) {
|
||||
|
||||
void RendererViewport::viewport_set_canvas_cull_mask(RID p_viewport, uint32_t p_canvas_cull_mask) {
|
||||
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
ERR_FAIL_NULL(viewport);
|
||||
viewport->canvas_cull_mask = p_canvas_cull_mask;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ Vector<uint8_t> RenderingDevice::shader_compile_spirv_from_source(ShaderStage p_
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!compile_to_spirv_function, Vector<uint8_t>());
|
||||
ERR_FAIL_NULL_V(compile_to_spirv_function, Vector<uint8_t>());
|
||||
|
||||
return compile_to_spirv_function(p_stage, p_source_code, p_language, r_error, this);
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ void ShaderCompiler::_dump_function_deps(const SL::ShaderNode *p_node, const Str
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!fnode);
|
||||
ERR_FAIL_NULL(fnode);
|
||||
|
||||
r_to_add += "\n";
|
||||
|
||||
|
@ -5319,7 +5319,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!base_function, nullptr); //bug, wtf
|
||||
ERR_FAIL_NULL_V(base_function, nullptr); // Bug, wtf.
|
||||
|
||||
for (int i = 0; i < call_function->arguments.size(); i++) {
|
||||
int argidx = i + 1;
|
||||
@ -5751,7 +5751,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!expr, nullptr);
|
||||
ERR_FAIL_NULL_V(expr, nullptr);
|
||||
|
||||
/* OK now see what's NEXT to the operator.. */
|
||||
|
||||
|
@ -64,7 +64,7 @@ void RendererCameraAttributes::camera_attributes_set_dof_blur_bokeh_shape(RS::DO
|
||||
|
||||
void RendererCameraAttributes::camera_attributes_set_dof_blur(RID p_camera_attributes, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND(!cam_attributes);
|
||||
ERR_FAIL_NULL(cam_attributes);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" && (p_far_enable || p_near_enable)) {
|
||||
WARN_PRINT_ONCE_ED("DoF blur is only available when using the Forward+ or Mobile rendering backends.");
|
||||
@ -83,63 +83,63 @@ void RendererCameraAttributes::camera_attributes_set_dof_blur(RID p_camera_attri
|
||||
|
||||
bool RendererCameraAttributes::camera_attributes_get_dof_far_enabled(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, false);
|
||||
ERR_FAIL_NULL_V(cam_attributes, false);
|
||||
return cam_attributes->dof_blur_far_enabled;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_dof_far_distance(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->dof_blur_far_distance;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_dof_far_transition(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->dof_blur_far_transition;
|
||||
}
|
||||
|
||||
bool RendererCameraAttributes::camera_attributes_get_dof_near_enabled(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, false);
|
||||
ERR_FAIL_NULL_V(cam_attributes, false);
|
||||
return cam_attributes->dof_blur_near_enabled;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_dof_near_distance(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->dof_blur_near_distance;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_dof_near_transition(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->dof_blur_near_transition;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_dof_blur_amount(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->dof_blur_amount;
|
||||
}
|
||||
|
||||
void RendererCameraAttributes::camera_attributes_set_exposure(RID p_camera_attributes, float p_multiplier, float p_exposure_normalization) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND(!cam_attributes);
|
||||
ERR_FAIL_NULL(cam_attributes);
|
||||
cam_attributes->exposure_multiplier = p_multiplier;
|
||||
cam_attributes->exposure_normalization = p_exposure_normalization;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_exposure_normalization_factor(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 1.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 1.0);
|
||||
|
||||
return cam_attributes->exposure_multiplier * cam_attributes->exposure_normalization;
|
||||
}
|
||||
|
||||
void RendererCameraAttributes::camera_attributes_set_auto_exposure(RID p_camera_attributes, bool p_enable, float p_min_sensitivity, float p_max_sensitivity, float p_speed, float p_scale) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND(!cam_attributes);
|
||||
ERR_FAIL_NULL(cam_attributes);
|
||||
if (!cam_attributes->use_auto_exposure && p_enable) {
|
||||
cam_attributes->auto_exposure_version = ++auto_exposure_counter;
|
||||
}
|
||||
@ -157,30 +157,30 @@ void RendererCameraAttributes::camera_attributes_set_auto_exposure(RID p_camera_
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_auto_exposure_min_sensitivity(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->auto_exposure_min_sensitivity;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_auto_exposure_max_sensitivity(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->auto_exposure_max_sensitivity;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_auto_exposure_adjust_speed(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->auto_exposure_adjust_speed;
|
||||
}
|
||||
|
||||
float RendererCameraAttributes::camera_attributes_get_auto_exposure_scale(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0.0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0.0);
|
||||
return cam_attributes->auto_exposure_scale;
|
||||
}
|
||||
|
||||
uint64_t RendererCameraAttributes::camera_attributes_get_auto_exposure_version(RID p_camera_attributes) {
|
||||
CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
|
||||
ERR_FAIL_COND_V(!cam_attributes, 0);
|
||||
ERR_FAIL_NULL_V(cam_attributes, 0);
|
||||
return cam_attributes->auto_exposure_version;
|
||||
}
|
||||
|
@ -46,50 +46,50 @@ void RendererEnvironmentStorage::environment_free(RID p_rid) {
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->background = p_bg;
|
||||
}
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_sky(RID p_env, RID p_sky) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->sky = p_sky;
|
||||
}
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_sky_custom_fov(RID p_env, float p_scale) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->sky_custom_fov = p_scale;
|
||||
}
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->sky_orientation = p_orientation;
|
||||
}
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_bg_color(RID p_env, const Color &p_color) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->bg_color = p_color;
|
||||
}
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_bg_energy(RID p_env, float p_multiplier, float p_intensity) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->bg_energy_multiplier = p_multiplier;
|
||||
env->bg_intensity = p_intensity;
|
||||
}
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_canvas_max_layer(RID p_env, int p_max_layer) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->canvas_max_layer = p_max_layer;
|
||||
}
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->ambient_light = p_color;
|
||||
env->ambient_source = p_ambient;
|
||||
env->ambient_light_energy = p_energy;
|
||||
@ -99,79 +99,79 @@ void RendererEnvironmentStorage::environment_set_ambient_light(RID p_env, const
|
||||
|
||||
RS::EnvironmentBG RendererEnvironmentStorage::environment_get_background(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RS::ENV_BG_CLEAR_COLOR);
|
||||
ERR_FAIL_NULL_V(env, RS::ENV_BG_CLEAR_COLOR);
|
||||
return env->background;
|
||||
}
|
||||
|
||||
RID RendererEnvironmentStorage::environment_get_sky(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RID());
|
||||
ERR_FAIL_NULL_V(env, RID());
|
||||
return env->sky;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_sky_custom_fov(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->sky_custom_fov;
|
||||
}
|
||||
|
||||
Basis RendererEnvironmentStorage::environment_get_sky_orientation(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, Basis());
|
||||
ERR_FAIL_NULL_V(env, Basis());
|
||||
return env->sky_orientation;
|
||||
}
|
||||
|
||||
Color RendererEnvironmentStorage::environment_get_bg_color(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, Color());
|
||||
ERR_FAIL_NULL_V(env, Color());
|
||||
return env->bg_color;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_bg_energy_multiplier(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->bg_energy_multiplier;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_bg_intensity(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->bg_intensity;
|
||||
}
|
||||
|
||||
int RendererEnvironmentStorage::environment_get_canvas_max_layer(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0);
|
||||
ERR_FAIL_NULL_V(env, 0);
|
||||
return env->canvas_max_layer;
|
||||
}
|
||||
|
||||
RS::EnvironmentAmbientSource RendererEnvironmentStorage::environment_get_ambient_source(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RS::ENV_AMBIENT_SOURCE_BG);
|
||||
ERR_FAIL_NULL_V(env, RS::ENV_AMBIENT_SOURCE_BG);
|
||||
return env->ambient_source;
|
||||
}
|
||||
|
||||
Color RendererEnvironmentStorage::environment_get_ambient_light(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, Color());
|
||||
ERR_FAIL_NULL_V(env, Color());
|
||||
return env->ambient_light;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ambient_light_energy(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->ambient_light_energy;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ambient_sky_contribution(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->ambient_sky_contribution;
|
||||
}
|
||||
|
||||
RS::EnvironmentReflectionSource RendererEnvironmentStorage::environment_get_reflection_source(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RS::ENV_REFLECTION_SOURCE_BG);
|
||||
ERR_FAIL_NULL_V(env, RS::ENV_REFLECTION_SOURCE_BG);
|
||||
return env->reflection_source;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ RS::EnvironmentReflectionSource RendererEnvironmentStorage::environment_get_refl
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->exposure = p_exposure;
|
||||
env->tone_mapper = p_tone_mapper;
|
||||
env->white = p_white;
|
||||
@ -187,19 +187,19 @@ void RendererEnvironmentStorage::environment_set_tonemap(RID p_env, RS::Environm
|
||||
|
||||
RS::EnvironmentToneMapper RendererEnvironmentStorage::environment_get_tone_mapper(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RS::ENV_TONE_MAPPER_LINEAR);
|
||||
ERR_FAIL_NULL_V(env, RS::ENV_TONE_MAPPER_LINEAR);
|
||||
return env->tone_mapper;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_exposure(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->exposure;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_white(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->white;
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ float RendererEnvironmentStorage::environment_get_white(RID p_env) const {
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_fog_aerial_perspective, float p_sky_affect) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->fog_enabled = p_enable;
|
||||
env->fog_light_color = p_light_color;
|
||||
env->fog_light_energy = p_light_energy;
|
||||
@ -221,55 +221,55 @@ void RendererEnvironmentStorage::environment_set_fog(RID p_env, bool p_enable, c
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_fog_enabled(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->fog_enabled;
|
||||
}
|
||||
|
||||
Color RendererEnvironmentStorage::environment_get_fog_light_color(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, Color(0.5, 0.6, 0.7));
|
||||
ERR_FAIL_NULL_V(env, Color(0.5, 0.6, 0.7));
|
||||
return env->fog_light_color;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_fog_light_energy(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->fog_light_energy;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_fog_sun_scatter(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->fog_sun_scatter;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_fog_density(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.001);
|
||||
ERR_FAIL_NULL_V(env, 0.001);
|
||||
return env->fog_density;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_fog_height(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->fog_height;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_fog_height_density(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->fog_height_density;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_fog_aerial_perspective(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->fog_aerial_perspective;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_fog_sky_affect(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->fog_sky_affect;
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ float RendererEnvironmentStorage::environment_get_fog_sky_affect(RID p_env) cons
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_albedo, const Color &p_emission, float p_emission_energy, float p_anisotropy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount, float p_ambient_inject, float p_sky_affect) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Volumetric fog can only be enabled when using the Forward+ rendering backend.");
|
||||
@ -300,79 +300,79 @@ void RendererEnvironmentStorage::environment_set_volumetric_fog(RID p_env, bool
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_volumetric_fog_enabled(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->volumetric_fog_enabled;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_density(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.01);
|
||||
ERR_FAIL_NULL_V(env, 0.01);
|
||||
return env->volumetric_fog_density;
|
||||
}
|
||||
|
||||
Color RendererEnvironmentStorage::environment_get_volumetric_fog_scattering(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, Color(1, 1, 1));
|
||||
ERR_FAIL_NULL_V(env, Color(1, 1, 1));
|
||||
return env->volumetric_fog_scattering;
|
||||
}
|
||||
|
||||
Color RendererEnvironmentStorage::environment_get_volumetric_fog_emission(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, Color(0, 0, 0));
|
||||
ERR_FAIL_NULL_V(env, Color(0, 0, 0));
|
||||
return env->volumetric_fog_emission;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_emission_energy(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->volumetric_fog_emission_energy;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_anisotropy(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.2);
|
||||
ERR_FAIL_NULL_V(env, 0.2);
|
||||
return env->volumetric_fog_anisotropy;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_length(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 64.0);
|
||||
ERR_FAIL_NULL_V(env, 64.0);
|
||||
return env->volumetric_fog_length;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_detail_spread(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 2.0);
|
||||
ERR_FAIL_NULL_V(env, 2.0);
|
||||
return env->volumetric_fog_detail_spread;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_gi_inject(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->volumetric_fog_gi_inject;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_sky_affect(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->volumetric_fog_sky_affect;
|
||||
}
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_volumetric_fog_temporal_reprojection(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, true);
|
||||
ERR_FAIL_NULL_V(env, true);
|
||||
return env->volumetric_fog_temporal_reprojection;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_temporal_reprojection_amount(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.9);
|
||||
ERR_FAIL_NULL_V(env, 0.9);
|
||||
return env->volumetric_fog_temporal_reprojection_amount;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_volumetric_fog_ambient_inject(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->volumetric_fog_ambient_inject;
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ float RendererEnvironmentStorage::environment_get_volumetric_fog_ambient_inject(
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, float p_glow_map_strength, RID p_glow_map) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
ERR_FAIL_COND_MSG(p_levels.size() != 7, "Size of array of glow levels must be 7");
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" && p_enable) {
|
||||
@ -403,73 +403,73 @@ void RendererEnvironmentStorage::environment_set_glow(RID p_env, bool p_enable,
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_glow_enabled(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->glow_enabled;
|
||||
}
|
||||
|
||||
Vector<float> RendererEnvironmentStorage::environment_get_glow_levels(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, Vector<float>());
|
||||
ERR_FAIL_NULL_V(env, Vector<float>());
|
||||
return env->glow_levels;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_glow_intensity(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.8);
|
||||
ERR_FAIL_NULL_V(env, 0.8);
|
||||
return env->glow_intensity;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_glow_strength(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->glow_strength;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_glow_bloom(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->glow_bloom;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_glow_mix(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.01);
|
||||
ERR_FAIL_NULL_V(env, 0.01);
|
||||
return env->glow_mix;
|
||||
}
|
||||
|
||||
RS::EnvironmentGlowBlendMode RendererEnvironmentStorage::environment_get_glow_blend_mode(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT);
|
||||
ERR_FAIL_NULL_V(env, RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT);
|
||||
return env->glow_blend_mode;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_glow_hdr_bleed_threshold(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->glow_hdr_bleed_threshold;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_glow_hdr_luminance_cap(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 12.0);
|
||||
ERR_FAIL_NULL_V(env, 12.0);
|
||||
return env->glow_hdr_luminance_cap;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_glow_hdr_bleed_scale(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 2.0);
|
||||
ERR_FAIL_NULL_V(env, 2.0);
|
||||
return env->glow_hdr_bleed_scale;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_glow_map_strength(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->glow_map_strength;
|
||||
}
|
||||
|
||||
RID RendererEnvironmentStorage::environment_get_glow_map(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RID());
|
||||
ERR_FAIL_NULL_V(env, RID());
|
||||
return env->glow_map;
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ RID RendererEnvironmentStorage::environment_get_glow_map(RID p_env) const {
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Screen-space reflections (SSR) can only be enabled when using the Forward+ rendering backend.");
|
||||
@ -492,31 +492,31 @@ void RendererEnvironmentStorage::environment_set_ssr(RID p_env, bool p_enable, i
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_ssr_enabled(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->ssr_enabled;
|
||||
}
|
||||
|
||||
int RendererEnvironmentStorage::environment_get_ssr_max_steps(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 64);
|
||||
ERR_FAIL_NULL_V(env, 64);
|
||||
return env->ssr_max_steps;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssr_fade_in(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.15);
|
||||
ERR_FAIL_NULL_V(env, 0.15);
|
||||
return env->ssr_fade_in;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssr_fade_out(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 2.0);
|
||||
ERR_FAIL_NULL_V(env, 2.0);
|
||||
return env->ssr_fade_out;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssr_depth_tolerance(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.2);
|
||||
ERR_FAIL_NULL_V(env, 0.2);
|
||||
return env->ssr_depth_tolerance;
|
||||
}
|
||||
|
||||
@ -524,7 +524,7 @@ float RendererEnvironmentStorage::environment_get_ssr_depth_tolerance(RID p_env)
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Screen-space ambient occlusion (SSAO) can only be enabled when using the Forward+ rendering backend.");
|
||||
@ -543,55 +543,55 @@ void RendererEnvironmentStorage::environment_set_ssao(RID p_env, bool p_enable,
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_ssao_enabled(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->ssao_enabled;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssao_radius(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->ssao_radius;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssao_intensity(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 2.0);
|
||||
ERR_FAIL_NULL_V(env, 2.0);
|
||||
return env->ssao_intensity;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssao_power(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.5);
|
||||
ERR_FAIL_NULL_V(env, 1.5);
|
||||
return env->ssao_power;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssao_detail(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.5);
|
||||
ERR_FAIL_NULL_V(env, 0.5);
|
||||
return env->ssao_detail;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssao_horizon(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.06);
|
||||
ERR_FAIL_NULL_V(env, 0.06);
|
||||
return env->ssao_horizon;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssao_sharpness(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.98);
|
||||
ERR_FAIL_NULL_V(env, 0.98);
|
||||
return env->ssao_sharpness;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssao_direct_light_affect(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->ssao_direct_light_affect;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssao_ao_channel_affect(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.0);
|
||||
ERR_FAIL_NULL_V(env, 0.0);
|
||||
return env->ssao_ao_channel_affect;
|
||||
}
|
||||
|
||||
@ -599,7 +599,7 @@ float RendererEnvironmentStorage::environment_get_ssao_ao_channel_affect(RID p_e
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_ssil(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_sharpness, float p_normal_rejection) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Screen-space indirect lighting (SSIL) can only be enabled when using the Forward+ rendering backend.");
|
||||
@ -614,31 +614,31 @@ void RendererEnvironmentStorage::environment_set_ssil(RID p_env, bool p_enable,
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_ssil_enabled(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->ssil_enabled;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssil_radius(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 5.0);
|
||||
ERR_FAIL_NULL_V(env, 5.0);
|
||||
return env->ssil_radius;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssil_intensity(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->ssil_intensity;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssil_sharpness(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.98);
|
||||
ERR_FAIL_NULL_V(env, 0.98);
|
||||
return env->ssil_sharpness;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_ssil_normal_rejection(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->ssil_normal_rejection;
|
||||
}
|
||||
|
||||
@ -646,7 +646,7 @@ float RendererEnvironmentStorage::environment_get_ssil_normal_rejection(RID p_en
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_sdfgi(RID p_env, bool p_enable, int p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("SDFGI can only be enabled when using the Forward+ rendering backend.");
|
||||
@ -666,61 +666,61 @@ void RendererEnvironmentStorage::environment_set_sdfgi(RID p_env, bool p_enable,
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_sdfgi_enabled(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->sdfgi_enabled;
|
||||
}
|
||||
|
||||
int RendererEnvironmentStorage::environment_get_sdfgi_cascades(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 4);
|
||||
ERR_FAIL_NULL_V(env, 4);
|
||||
return env->sdfgi_cascades;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_sdfgi_min_cell_size(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.2);
|
||||
ERR_FAIL_NULL_V(env, 0.2);
|
||||
return env->sdfgi_min_cell_size;
|
||||
}
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_sdfgi_use_occlusion(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->sdfgi_use_occlusion;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_sdfgi_bounce_feedback(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 0.5);
|
||||
ERR_FAIL_NULL_V(env, 0.5);
|
||||
return env->sdfgi_bounce_feedback;
|
||||
}
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_sdfgi_read_sky_light(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, true);
|
||||
ERR_FAIL_NULL_V(env, true);
|
||||
return env->sdfgi_read_sky_light;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_sdfgi_energy(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->sdfgi_energy;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_sdfgi_normal_bias(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.1);
|
||||
ERR_FAIL_NULL_V(env, 1.1);
|
||||
return env->sdfgi_normal_bias;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_sdfgi_probe_bias(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.1);
|
||||
ERR_FAIL_NULL_V(env, 1.1);
|
||||
return env->sdfgi_probe_bias;
|
||||
}
|
||||
|
||||
RS::EnvironmentSDFGIYScale RendererEnvironmentStorage::environment_get_sdfgi_y_scale(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RS::ENV_SDFGI_Y_SCALE_75_PERCENT);
|
||||
ERR_FAIL_NULL_V(env, RS::ENV_SDFGI_Y_SCALE_75_PERCENT);
|
||||
return env->sdfgi_y_scale;
|
||||
}
|
||||
|
||||
@ -728,7 +728,7 @@ RS::EnvironmentSDFGIYScale RendererEnvironmentStorage::environment_get_sdfgi_y_s
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND(!env);
|
||||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Adjustments are not supported when using the GL Compatibility backend yet. Support will be added in a future release.");
|
||||
@ -744,36 +744,36 @@ void RendererEnvironmentStorage::environment_set_adjustment(RID p_env, bool p_en
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_adjustments_enabled(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->adjustments_enabled;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_adjustments_brightness(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->adjustments_brightness;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_adjustments_contrast(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->adjustments_contrast;
|
||||
}
|
||||
|
||||
float RendererEnvironmentStorage::environment_get_adjustments_saturation(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, 1.0);
|
||||
ERR_FAIL_NULL_V(env, 1.0);
|
||||
return env->adjustments_saturation;
|
||||
}
|
||||
|
||||
bool RendererEnvironmentStorage::environment_get_use_1d_color_correction(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, false);
|
||||
ERR_FAIL_NULL_V(env, false);
|
||||
return env->use_1d_color_correction;
|
||||
}
|
||||
|
||||
RID RendererEnvironmentStorage::environment_get_color_correction(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_COND_V(!env, RID());
|
||||
ERR_FAIL_NULL_V(env, RID());
|
||||
return env->color_correction;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user