From 4f163972bbd9c7379b01a1f9aa5310646ca7865e Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 10 Jun 2019 12:38:51 -0300 Subject: Refactored RID/RID_Owner to always use O(1) allocation. * Implements a growing chunked allocator * Removed redudant methods get and getptr, only getornull is supported now. --- modules/bullet/bullet_physics_server.cpp | 370 +++++++++++++------------- modules/bullet/bullet_physics_server.h | 26 +- modules/bullet/rid_bullet.h | 2 +- modules/bullet/space_bullet.cpp | 8 +- modules/gdnavigation/gd_navigation_server.cpp | 58 ++-- modules/gdnavigation/gd_navigation_server.h | 8 +- modules/gdnavigation/nav_rid.h | 2 +- 7 files changed, 238 insertions(+), 236 deletions(-) (limited to 'modules') diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index e507987297..fceb5d2b4b 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -134,7 +134,7 @@ RID BulletPhysicsServer::shape_create(ShapeType p_shape) { } void BulletPhysicsServer::shape_set_data(RID p_shape, const Variant &p_data) { - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); shape->set_data(p_data); } @@ -144,25 +144,25 @@ void BulletPhysicsServer::shape_set_custom_solver_bias(RID p_shape, real_t p_bia } PhysicsServer::ShapeType BulletPhysicsServer::shape_get_type(RID p_shape) const { - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, PhysicsServer::SHAPE_CUSTOM); return shape->get_type(); } Variant BulletPhysicsServer::shape_get_data(RID p_shape) const { - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, Variant()); return shape->get_data(); } void BulletPhysicsServer::shape_set_margin(RID p_shape, real_t p_margin) { - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); shape->set_margin(p_margin); } real_t BulletPhysicsServer::shape_get_margin(RID p_shape) const { - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0.0); return shape->get_margin(); } @@ -179,7 +179,7 @@ RID BulletPhysicsServer::space_create() { void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) { - SpaceBullet *space = space_owner.get(p_space); + SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); if (space_is_active(p_space) == p_active) { @@ -196,47 +196,47 @@ void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) { } bool BulletPhysicsServer::space_is_active(RID p_space) const { - SpaceBullet *space = space_owner.get(p_space); + SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, false); return -1 != active_spaces.find(space); } void BulletPhysicsServer::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) { - SpaceBullet *space = space_owner.get(p_space); + SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); space->set_param(p_param, p_value); } real_t BulletPhysicsServer::space_get_param(RID p_space, SpaceParameter p_param) const { - SpaceBullet *space = space_owner.get(p_space); + SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, 0); return space->get_param(p_param); } PhysicsDirectSpaceState *BulletPhysicsServer::space_get_direct_state(RID p_space) { - SpaceBullet *space = space_owner.get(p_space); + SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, NULL); return space->get_direct_state(); } void BulletPhysicsServer::space_set_debug_contacts(RID p_space, int p_max_contacts) { - SpaceBullet *space = space_owner.get(p_space); + SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); space->set_debug_contacts(p_max_contacts); } Vector BulletPhysicsServer::space_get_contacts(RID p_space) const { - SpaceBullet *space = space_owner.get(p_space); + SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, Vector()); return space->get_debug_contacts(); } int BulletPhysicsServer::space_get_contact_count(RID p_space) const { - SpaceBullet *space = space_owner.get(p_space); + SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, 0); return space->get_debug_contact_count(); @@ -250,91 +250,91 @@ RID BulletPhysicsServer::area_create() { } void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); SpaceBullet *space = NULL; if (p_space.is_valid()) { - space = space_owner.get(p_space); + space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); } area->set_space(space); } RID BulletPhysicsServer::area_get_space(RID p_area) const { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); return area->get_space()->get_self(); } void BulletPhysicsServer::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_spOv_mode(p_mode); } PhysicsServer::AreaSpaceOverrideMode BulletPhysicsServer::area_get_space_override_mode(RID p_area) const { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED); return area->get_spOv_mode(); } void BulletPhysicsServer::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); area->add_shape(shape, p_transform, p_disabled); } void BulletPhysicsServer::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); area->set_shape(p_shape_idx, shape); } void BulletPhysicsServer::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_shape_transform(p_shape_idx, p_transform); } int BulletPhysicsServer::area_get_shape_count(RID p_area) const { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, 0); return area->get_shape_count(); } RID BulletPhysicsServer::area_get_shape(RID p_area, int p_shape_idx) const { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, RID()); return area->get_shape(p_shape_idx)->get_self(); } Transform BulletPhysicsServer::area_get_shape_transform(RID p_area, int p_shape_idx) const { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, Transform()); return area->get_shape_transform(p_shape_idx); } void BulletPhysicsServer::area_remove_shape(RID p_area, int p_shape_idx) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); return area->remove_shape_full(p_shape_idx); } void BulletPhysicsServer::area_clear_shapes(RID p_area) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); for (int i = area->get_shape_count(); 0 < i; --i) @@ -342,7 +342,7 @@ void BulletPhysicsServer::area_clear_shapes(RID p_area) { } void BulletPhysicsServer::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_shape_disabled(p_shape_idx, p_disabled); @@ -352,7 +352,7 @@ void BulletPhysicsServer::area_attach_object_instance_id(RID p_area, ObjectID p_ if (space_owner.owns(p_area)) { return; } - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_instance_id(p_id); } @@ -361,20 +361,20 @@ ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const { if (space_owner.owns(p_area)) { return 0; } - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, ObjectID()); return area->get_instance_id(); } void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { if (space_owner.owns(p_area)) { - SpaceBullet *space = space_owner.get(p_area); + SpaceBullet *space = space_owner.getornull(p_area); if (space) { space->set_param(p_param, p_value); } } else { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_param(p_param, p_value); @@ -383,10 +383,10 @@ void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, cons Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) const { if (space_owner.owns(p_area)) { - SpaceBullet *space = space_owner.get(p_area); + SpaceBullet *space = space_owner.getornull(p_area); return space->get_param(p_param); } else { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, Variant()); return area->get_param(p_param); @@ -394,58 +394,58 @@ Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) c } void BulletPhysicsServer::area_set_transform(RID p_area, const Transform &p_transform) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_transform(p_transform); } Transform BulletPhysicsServer::area_get_transform(RID p_area) const { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, Transform()); return area->get_transform(); } void BulletPhysicsServer::area_set_collision_mask(RID p_area, uint32_t p_mask) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_collision_mask(p_mask); } void BulletPhysicsServer::area_set_collision_layer(RID p_area, uint32_t p_layer) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_collision_layer(p_layer); } void BulletPhysicsServer::area_set_monitorable(RID p_area, bool p_monitorable) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_monitorable(p_monitorable); } void BulletPhysicsServer::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_event_callback(CollisionObjectBullet::TYPE_RIGID_BODY, p_receiver ? p_receiver->get_instance_id() : 0, p_method); } void BulletPhysicsServer::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_event_callback(CollisionObjectBullet::TYPE_AREA, p_receiver ? p_receiver->get_instance_id() : 0, p_method); } void BulletPhysicsServer::area_set_ray_pickable(RID p_area, bool p_enable) { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_ray_pickable(p_enable); } bool BulletPhysicsServer::area_is_ray_pickable(RID p_area) const { - AreaBullet *area = area_owner.get(p_area); + AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, false); return area->is_ray_pickable(); } @@ -461,12 +461,12 @@ RID BulletPhysicsServer::body_create(BodyMode p_mode, bool p_init_sleeping) { } void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); SpaceBullet *space = NULL; if (p_space.is_valid()) { - space = space_owner.get(p_space); + space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); } @@ -477,7 +477,7 @@ void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) { } RID BulletPhysicsServer::body_get_space(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, RID()); SpaceBullet *space = body->get_space(); @@ -487,53 +487,53 @@ RID BulletPhysicsServer::body_get_space(RID p_body) const { } void BulletPhysicsServer::body_set_mode(RID p_body, PhysicsServer::BodyMode p_mode) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_mode(p_mode); } PhysicsServer::BodyMode BulletPhysicsServer::body_get_mode(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, BODY_MODE_STATIC); return body->get_mode(); } void BulletPhysicsServer::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); body->add_shape(shape, p_transform, p_disabled); } void BulletPhysicsServer::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - ShapeBullet *shape = shape_owner.get(p_shape); + ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); body->set_shape(p_shape_idx, shape); } void BulletPhysicsServer::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_shape_transform(p_shape_idx, p_transform); } int BulletPhysicsServer::body_get_shape_count(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_shape_count(); } RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, RID()); ShapeBullet *shape = body->get_shape(p_shape_idx); @@ -543,27 +543,27 @@ RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const { } Transform BulletPhysicsServer::body_get_shape_transform(RID p_body, int p_shape_idx) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Transform()); return body->get_shape_transform(p_shape_idx); } void BulletPhysicsServer::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_shape_disabled(p_shape_idx, p_disabled); } void BulletPhysicsServer::body_remove_shape(RID p_body, int p_shape_idx) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->remove_shape_full(p_shape_idx); } void BulletPhysicsServer::body_clear_shapes(RID p_body) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->remove_all_shapes(); @@ -584,42 +584,42 @@ uint32_t BulletPhysicsServer::body_get_object_instance_id(RID p_body) const { } void BulletPhysicsServer::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_continuous_collision_detection(p_enable); } bool BulletPhysicsServer::body_is_continuous_collision_detection_enabled(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->is_continuous_collision_detection_enabled(); } void BulletPhysicsServer::body_set_collision_layer(RID p_body, uint32_t p_layer) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_layer(p_layer); } uint32_t BulletPhysicsServer::body_get_collision_layer(RID p_body) const { - const RigidBodyBullet *body = rigid_body_owner.get(p_body); + const RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_layer(); } void BulletPhysicsServer::body_set_collision_mask(RID p_body, uint32_t p_mask) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_mask(p_mask); } uint32_t BulletPhysicsServer::body_get_collision_mask(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_mask(); @@ -635,21 +635,21 @@ uint32_t BulletPhysicsServer::body_get_user_flags(RID p_body) const { } void BulletPhysicsServer::body_set_param(RID p_body, BodyParameter p_param, float p_value) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_param(p_param, p_value); } float BulletPhysicsServer::body_get_param(RID p_body, BodyParameter p_param) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_param(p_param); } void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); if (body->get_kinematic_utilities()) { @@ -659,7 +659,7 @@ void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_ma } real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); if (body->get_kinematic_utilities()) { @@ -671,90 +671,90 @@ real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const { } void BulletPhysicsServer::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_state(p_state, p_variant); } Variant BulletPhysicsServer::body_get_state(RID p_body, BodyState p_state) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Variant()); return body->get_state(p_state); } void BulletPhysicsServer::body_set_applied_force(RID p_body, const Vector3 &p_force) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_applied_force(p_force); } Vector3 BulletPhysicsServer::body_get_applied_force(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector3()); return body->get_applied_force(); } void BulletPhysicsServer::body_set_applied_torque(RID p_body, const Vector3 &p_torque) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_applied_torque(p_torque); } Vector3 BulletPhysicsServer::body_get_applied_torque(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector3()); return body->get_applied_torque(); } void BulletPhysicsServer::body_add_central_force(RID p_body, const Vector3 &p_force) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_central_force(p_force); } void BulletPhysicsServer::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_force(p_force, p_pos); } void BulletPhysicsServer::body_add_torque(RID p_body, const Vector3 &p_torque) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_torque(p_torque); } void BulletPhysicsServer::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_central_impulse(p_impulse); } void BulletPhysicsServer::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_impulse(p_pos, p_impulse); } void BulletPhysicsServer::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_torque_impulse(p_impulse); } void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); Vector3 v = body->get_linear_velocity(); @@ -765,39 +765,39 @@ void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_ax } void BulletPhysicsServer::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_axis_lock(p_axis, p_lock); } bool BulletPhysicsServer::body_is_axis_locked(RID p_body, BodyAxis p_axis) const { - const RigidBodyBullet *body = rigid_body_owner.get(p_body); + const RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->is_axis_locked(p_axis); } void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - RigidBodyBullet *other_body = rigid_body_owner.get(p_body_b); + RigidBodyBullet *other_body = rigid_body_owner.getornull(p_body_b); ERR_FAIL_COND(!other_body); body->add_collision_exception(other_body); } void BulletPhysicsServer::body_remove_collision_exception(RID p_body, RID p_body_b) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - RigidBodyBullet *other_body = rigid_body_owner.get(p_body_b); + RigidBodyBullet *other_body = rigid_body_owner.getornull(p_body_b); ERR_FAIL_COND(!other_body); body->remove_collision_exception(other_body); } void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List *p_exceptions) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); for (int i = 0; i < body->get_exceptions().size(); i++) { p_exceptions->push_back(body->get_exceptions()[i]); @@ -805,14 +805,14 @@ void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List *p } void BulletPhysicsServer::body_set_max_contacts_reported(RID p_body, int p_contacts) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_max_collisions_detection(p_contacts); } int BulletPhysicsServer::body_get_max_contacts_reported(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_max_collisions_detection(); @@ -828,45 +828,45 @@ float BulletPhysicsServer::body_get_contacts_reported_depth_threshold(RID p_body } void BulletPhysicsServer::body_set_omit_force_integration(RID p_body, bool p_omit) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_omit_forces_integration(p_omit); } bool BulletPhysicsServer::body_is_omitting_force_integration(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->get_omit_forces_integration(); } void BulletPhysicsServer::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(0), p_method, p_udata); } void BulletPhysicsServer::body_set_ray_pickable(RID p_body, bool p_enable) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_ray_pickable(p_enable); } bool BulletPhysicsServer::body_is_ray_pickable(RID p_body) const { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->is_ray_pickable(); } PhysicsDirectBodyState *BulletPhysicsServer::body_get_direct_state(RID p_body) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, NULL); return BulletPhysicsDirectBodyState::get_singleton(body); } bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); ERR_FAIL_COND_V(!body->get_space(), false); @@ -874,7 +874,7 @@ bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, } int BulletPhysicsServer::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) { - RigidBodyBullet *body = rigid_body_owner.get(p_body); + RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); ERR_FAIL_COND_V(!body->get_space(), 0); @@ -891,19 +891,19 @@ RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) { } void BulletPhysicsServer::soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->update_visual_server(p_visual_server_handler); } void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); SpaceBullet *space = NULL; if (p_space.is_valid()) { - space = space_owner.get(p_space); + space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); } @@ -914,7 +914,7 @@ void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) { } RID BulletPhysicsServer::soft_body_get_space(RID p_body) const { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, RID()); SpaceBullet *space = body->get_space(); @@ -924,47 +924,47 @@ RID BulletPhysicsServer::soft_body_get_space(RID p_body) const { } void BulletPhysicsServer::soft_body_set_mesh(RID p_body, const REF &p_mesh) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_soft_mesh(p_mesh); } void BulletPhysicsServer::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_layer(p_layer); } uint32_t BulletPhysicsServer::soft_body_get_collision_layer(RID p_body) const { - const SoftBodyBullet *body = soft_body_owner.get(p_body); + const SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_layer(); } void BulletPhysicsServer::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_mask(p_mask); } uint32_t BulletPhysicsServer::soft_body_get_collision_mask(RID p_body) const { - const SoftBodyBullet *body = soft_body_owner.get(p_body); + const SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_mask(); } void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_body_b) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - CollisionObjectBullet *other_body = rigid_body_owner.get(p_body_b); + CollisionObjectBullet *other_body = rigid_body_owner.getornull(p_body_b); if (!other_body) { - other_body = soft_body_owner.get(p_body_b); + other_body = soft_body_owner.getornull(p_body_b); } ERR_FAIL_COND(!other_body); @@ -972,12 +972,12 @@ void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_bo } void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p_body_b) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - CollisionObjectBullet *other_body = rigid_body_owner.get(p_body_b); + CollisionObjectBullet *other_body = rigid_body_owner.getornull(p_body_b); if (!other_body) { - other_body = soft_body_owner.get(p_body_b); + other_body = soft_body_owner.getornull(p_body_b); } ERR_FAIL_COND(!other_body); @@ -985,7 +985,7 @@ void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p } void BulletPhysicsServer::soft_body_get_collision_exceptions(RID p_body, List *p_exceptions) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); for (int i = 0; i < body->get_exceptions().size(); i++) { p_exceptions->push_back(body->get_exceptions()[i]); @@ -1004,14 +1004,14 @@ Variant BulletPhysicsServer::soft_body_get_state(RID p_body, BodyState p_state) } void BulletPhysicsServer::soft_body_set_transform(RID p_body, const Transform &p_transform) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_soft_transform(p_transform); } Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int vertex_index) const { - const SoftBodyBullet *body = soft_body_owner.get(p_body); + const SoftBodyBullet *body = soft_body_owner.getornull(p_body); Vector3 pos; ERR_FAIL_COND_V(!body, pos); @@ -1020,133 +1020,133 @@ Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int verte } void BulletPhysicsServer::soft_body_set_ray_pickable(RID p_body, bool p_enable) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_ray_pickable(p_enable); } bool BulletPhysicsServer::soft_body_is_ray_pickable(RID p_body) const { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->is_ray_pickable(); } void BulletPhysicsServer::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_simulation_precision(p_simulation_precision); } int BulletPhysicsServer::soft_body_get_simulation_precision(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_simulation_precision(); } void BulletPhysicsServer::soft_body_set_total_mass(RID p_body, real_t p_total_mass) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_total_mass(p_total_mass); } real_t BulletPhysicsServer::soft_body_get_total_mass(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_total_mass(); } void BulletPhysicsServer::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_linear_stiffness(p_stiffness); } real_t BulletPhysicsServer::soft_body_get_linear_stiffness(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_linear_stiffness(); } void BulletPhysicsServer::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_areaAngular_stiffness(p_stiffness); } real_t BulletPhysicsServer::soft_body_get_areaAngular_stiffness(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_areaAngular_stiffness(); } void BulletPhysicsServer::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_volume_stiffness(p_stiffness); } real_t BulletPhysicsServer::soft_body_get_volume_stiffness(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_volume_stiffness(); } void BulletPhysicsServer::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_pressure_coefficient(p_pressure_coefficient); } real_t BulletPhysicsServer::soft_body_get_pressure_coefficient(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_pressure_coefficient(); } void BulletPhysicsServer::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); return body->set_pose_matching_coefficient(p_pose_matching_coefficient); } real_t BulletPhysicsServer::soft_body_get_pose_matching_coefficient(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_pose_matching_coefficient(); } void BulletPhysicsServer::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_damping_coefficient(p_damping_coefficient); } real_t BulletPhysicsServer::soft_body_get_damping_coefficient(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_damping_coefficient(); } void BulletPhysicsServer::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_drag_coefficient(p_drag_coefficient); } real_t BulletPhysicsServer::soft_body_get_drag_coefficient(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_drag_coefficient(); } void BulletPhysicsServer::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_node_position(p_point_index, p_global_position); } Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int p_point_index) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector3(0., 0., 0.)); Vector3 pos; body->get_node_position(p_point_index, pos); @@ -1154,7 +1154,7 @@ Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int } Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_index) const { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector3()); Vector3 res; body->get_node_offset(p_point_index, res); @@ -1162,25 +1162,25 @@ Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_ } void BulletPhysicsServer::soft_body_remove_all_pinned_points(RID p_body) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->reset_all_node_mass(); } void BulletPhysicsServer::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_node_mass(p_point_index, p_pin ? 0 : 1); } bool BulletPhysicsServer::soft_body_is_point_pinned(RID p_body, int p_point_index) { - SoftBodyBullet *body = soft_body_owner.get(p_body); + SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_node_mass(p_point_index); } PhysicsServer::JointType BulletPhysicsServer::joint_get_type(RID p_joint) const { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, JOINT_PIN); return joint->get_type(); } @@ -1195,28 +1195,28 @@ int BulletPhysicsServer::joint_get_solver_priority(RID p_joint) const { } void BulletPhysicsServer::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); joint->disable_collisions_between_bodies(p_disable); } bool BulletPhysicsServer::joint_is_disabled_collisions_between_bodies(RID p_joint) const { - JointBullet *joint(joint_owner.get(p_joint)); + JointBullet *joint(joint_owner.getornull(p_joint)); ERR_FAIL_COND_V(!joint, false); return joint->is_disabled_collisions_between_bodies(); } RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) { - RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A); + RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); RigidBodyBullet *body_B = NULL; if (p_body_B.is_valid()) { - body_B = rigid_body_owner.get(p_body_B); + body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); JointAssertSameSpace(body_A, body_B, RID()); } @@ -1230,7 +1230,7 @@ RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A } void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); PinJointBullet *pin_joint = static_cast(joint); @@ -1238,7 +1238,7 @@ void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param } float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0); PinJointBullet *pin_joint = static_cast(joint); @@ -1246,7 +1246,7 @@ float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_para } void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); PinJointBullet *pin_joint = static_cast(joint); @@ -1254,7 +1254,7 @@ void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) } Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, Vector3()); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); PinJointBullet *pin_joint = static_cast(joint); @@ -1262,7 +1262,7 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const { } void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); PinJointBullet *pin_joint = static_cast(joint); @@ -1270,7 +1270,7 @@ void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) } Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, Vector3()); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); PinJointBullet *pin_joint = static_cast(joint); @@ -1278,13 +1278,13 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const { } RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) { - RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A); + RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); RigidBodyBullet *body_B = NULL; if (p_body_B.is_valid()) { - body_B = rigid_body_owner.get(p_body_B); + body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); JointAssertSameSpace(body_A, body_B, RID()); } @@ -1298,13 +1298,13 @@ RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hin } RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) { - RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A); + RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); RigidBodyBullet *body_B = NULL; if (p_body_B.is_valid()) { - body_B = rigid_body_owner.get(p_body_B); + body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); JointAssertSameSpace(body_A, body_B, RID()); } @@ -1318,7 +1318,7 @@ RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 & } void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); HingeJointBullet *hinge_joint = static_cast(joint); @@ -1326,7 +1326,7 @@ void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_p } float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0); HingeJointBullet *hinge_joint = static_cast(joint); @@ -1334,7 +1334,7 @@ float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_ } void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); HingeJointBullet *hinge_joint = static_cast(joint); @@ -1342,7 +1342,7 @@ void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_fla } bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, false); ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false); HingeJointBullet *hinge_joint = static_cast(joint); @@ -1350,13 +1350,13 @@ bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_fla } RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { - RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A); + RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); RigidBodyBullet *body_B = NULL; if (p_body_B.is_valid()) { - body_B = rigid_body_owner.get(p_body_B); + body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); JointAssertSameSpace(body_A, body_B, RID()); } @@ -1370,7 +1370,7 @@ RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_lo } void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER); SliderJointBullet *slider_joint = static_cast(joint); @@ -1378,7 +1378,7 @@ void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p } float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_SLIDER, 0); SliderJointBullet *slider_joint = static_cast(joint); @@ -1386,13 +1386,13 @@ float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam } RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { - RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A); + RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); RigidBodyBullet *body_B = NULL; if (p_body_B.is_valid()) { - body_B = rigid_body_owner.get(p_body_B); + body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); JointAssertSameSpace(body_A, body_B, RID()); } @@ -1404,7 +1404,7 @@ RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform & } void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST); ConeTwistJointBullet *coneTwist_joint = static_cast(joint); @@ -1412,7 +1412,7 @@ void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJoint } float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0.); ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0.); ConeTwistJointBullet *coneTwist_joint = static_cast(joint); @@ -1420,13 +1420,13 @@ float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJoin } RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { - RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A); + RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); RigidBodyBullet *body_B = NULL; if (p_body_B.is_valid()) { - body_B = rigid_body_owner.get(p_body_B); + body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); JointAssertSameSpace(body_A, body_B, RID()); } @@ -1440,7 +1440,7 @@ RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform } void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); Generic6DOFJointBullet *generic_6dof_joint = static_cast(joint); @@ -1448,7 +1448,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axi } float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0); Generic6DOFJointBullet *generic_6dof_joint = static_cast(joint); @@ -1456,7 +1456,7 @@ float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Ax } void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); Generic6DOFJointBullet *generic_6dof_joint = static_cast(joint); @@ -1464,7 +1464,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis } bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, false); ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false); Generic6DOFJointBullet *generic_6dof_joint = static_cast(joint); @@ -1472,7 +1472,7 @@ bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis } void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_precision) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); Generic6DOFJointBullet *generic_6dof_joint = static_cast(joint); @@ -1480,7 +1480,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_pr } int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) { - JointBullet *joint = joint_owner.get(p_joint); + JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0); Generic6DOFJointBullet *generic_6dof_joint = static_cast(joint); @@ -1490,7 +1490,7 @@ int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) { void BulletPhysicsServer::free(RID p_rid) { if (shape_owner.owns(p_rid)) { - ShapeBullet *shape = shape_owner.get(p_rid); + ShapeBullet *shape = shape_owner.getornull(p_rid); // Notify the shape is configured for (Map::Element *element = shape->get_owners().front(); element; element = element->next()) { @@ -1501,7 +1501,7 @@ void BulletPhysicsServer::free(RID p_rid) { bulletdelete(shape); } else if (rigid_body_owner.owns(p_rid)) { - RigidBodyBullet *body = rigid_body_owner.get(p_rid); + RigidBodyBullet *body = rigid_body_owner.getornull(p_rid); body->set_space(NULL); @@ -1512,7 +1512,7 @@ void BulletPhysicsServer::free(RID p_rid) { } else if (soft_body_owner.owns(p_rid)) { - SoftBodyBullet *body = soft_body_owner.get(p_rid); + SoftBodyBullet *body = soft_body_owner.getornull(p_rid); body->set_space(NULL); @@ -1521,7 +1521,7 @@ void BulletPhysicsServer::free(RID p_rid) { } else if (area_owner.owns(p_rid)) { - AreaBullet *area = area_owner.get(p_rid); + AreaBullet *area = area_owner.getornull(p_rid); area->set_space(NULL); @@ -1532,14 +1532,14 @@ void BulletPhysicsServer::free(RID p_rid) { } else if (joint_owner.owns(p_rid)) { - JointBullet *joint = joint_owner.get(p_rid); + JointBullet *joint = joint_owner.getornull(p_rid); joint->destroy_internal_constraint(); joint_owner.free(p_rid); bulletdelete(joint); } else if (space_owner.owns(p_rid)) { - SpaceBullet *space = space_owner.get(p_rid); + SpaceBullet *space = space_owner.getornull(p_rid); space->remove_all_collision_objects(); diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h index 4a3b4a2edc..22032d32e3 100644 --- a/modules/bullet/bullet_physics_server.h +++ b/modules/bullet/bullet_physics_server.h @@ -33,13 +33,13 @@ #include "area_bullet.h" #include "core/rid.h" +#include "core/rid_owner.h" #include "joint_bullet.h" #include "rigid_body_bullet.h" #include "servers/physics_server.h" #include "shape_bullet.h" #include "soft_body_bullet.h" #include "space_bullet.h" - /** @author AndreaCatania */ @@ -53,12 +53,12 @@ class BulletPhysicsServer : public PhysicsServer { char active_spaces_count; Vector active_spaces; - mutable RID_Owner space_owner; - mutable RID_Owner shape_owner; - mutable RID_Owner area_owner; - mutable RID_Owner rigid_body_owner; - mutable RID_Owner soft_body_owner; - mutable RID_Owner joint_owner; + mutable RID_PtrOwner space_owner; + mutable RID_PtrOwner shape_owner; + mutable RID_PtrOwner area_owner; + mutable RID_PtrOwner rigid_body_owner; + mutable RID_PtrOwner soft_body_owner; + mutable RID_PtrOwner joint_owner; protected: static void _bind_methods(); @@ -67,22 +67,22 @@ public: BulletPhysicsServer(); ~BulletPhysicsServer(); - _FORCE_INLINE_ RID_Owner *get_space_owner() { + _FORCE_INLINE_ RID_PtrOwner *get_space_owner() { return &space_owner; } - _FORCE_INLINE_ RID_Owner *get_shape_owner() { + _FORCE_INLINE_ RID_PtrOwner *get_shape_owner() { return &shape_owner; } - _FORCE_INLINE_ RID_Owner *get_area_owner() { + _FORCE_INLINE_ RID_PtrOwner *get_area_owner() { return &area_owner; } - _FORCE_INLINE_ RID_Owner *get_rigid_body_owner() { + _FORCE_INLINE_ RID_PtrOwner *get_rigid_body_owner() { return &rigid_body_owner; } - _FORCE_INLINE_ RID_Owner *get_soft_body_owner() { + _FORCE_INLINE_ RID_PtrOwner *get_soft_body_owner() { return &soft_body_owner; } - _FORCE_INLINE_ RID_Owner *get_joint_owner() { + _FORCE_INLINE_ RID_PtrOwner *get_joint_owner() { return &joint_owner; } diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h index 28bcedb01a..d073e209cd 100644 --- a/modules/bullet/rid_bullet.h +++ b/modules/bullet/rid_bullet.h @@ -39,7 +39,7 @@ class BulletPhysicsServer; -class RIDBullet : public RID_Data { +class RIDBullet { RID self; BulletPhysicsServer *physicsServer; diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 762637ce75..dae1719aa9 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -122,7 +122,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra if (p_result_max <= 0) return 0; - ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); + ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape); btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale_abs(), p_margin); if (!btShape->isConvex()) { @@ -152,7 +152,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra } bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) { - ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); + ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape); btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale(), p_margin); if (!btShape->isConvex()) { @@ -207,7 +207,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform & if (p_result_max <= 0) return 0; - ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); + ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape); btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin); if (!btShape->isConvex()) { @@ -239,7 +239,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform & bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { - ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); + ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape); btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin); if (!btShape->isConvex()) { diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp index f3ffd93c9c..0686230072 100644 --- a/modules/gdnavigation/gd_navigation_server.cpp +++ b/modules/gdnavigation/gd_navigation_server.cpp @@ -140,7 +140,7 @@ RID GdNavigationServer::map_create() const { } COMMAND_2(map_set_active, RID, p_map, bool, p_active) { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND(map == NULL); if (p_active) { @@ -153,56 +153,56 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) { } bool GdNavigationServer::map_is_active(RID p_map) const { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND_V(map == NULL, false); return active_maps.find(map) >= 0; } COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND(map == NULL); map->set_up(p_up); } Vector3 GdNavigationServer::map_get_up(RID p_map) const { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND_V(map == NULL, Vector3()); return map->get_up(); } COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND(map == NULL); map->set_cell_size(p_cell_size); } real_t GdNavigationServer::map_get_cell_size(RID p_map) const { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND_V(map == NULL, 0); return map->get_cell_size(); } COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND(map == NULL); map->set_edge_connection_margin(p_connection_margin); } real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND_V(map == NULL, 0); return map->get_edge_connection_margin(); } Vector GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND_V(map == NULL, Vector()); return map->get_path(p_origin, p_destination, p_optimize); @@ -219,7 +219,7 @@ RID GdNavigationServer::region_create() const { } COMMAND_2(region_set_map, RID, p_region, RID, p_map) { - NavRegion *region = region_owner.get(p_region); + NavRegion *region = region_owner.getornull(p_region); ERR_FAIL_COND(region == NULL); if (region->get_map() != NULL) { @@ -232,7 +232,7 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) { } if (p_map.is_valid()) { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND(map == NULL); map->add_region(region); @@ -241,14 +241,14 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) { } COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) { - NavRegion *region = region_owner.get(p_region); + NavRegion *region = region_owner.getornull(p_region); ERR_FAIL_COND(region == NULL); region->set_transform(p_transform); } COMMAND_2(region_set_navmesh, RID, p_region, Ref, p_nav_mesh) { - NavRegion *region = region_owner.get(p_region); + NavRegion *region = region_owner.getornull(p_region); ERR_FAIL_COND(region == NULL); region->set_mesh(p_nav_mesh); @@ -275,7 +275,7 @@ RID GdNavigationServer::agent_create() const { } COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); if (agent->get_map()) { @@ -288,7 +288,7 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) { agent->set_map(NULL); if (p_map.is_valid()) { - NavMap *map = map_owner.get(p_map); + NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND(map == NULL); agent->set_map(map); @@ -301,77 +301,77 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) { } COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->neighborDist_ = p_dist; } COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->maxNeighbors_ = p_count; } COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->timeHorizon_ = p_time; } COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->radius_ = p_radius; } COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->maxSpeed_ = p_max_speed; } COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z); } COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z); } COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z); } COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->get_agent()->ignore_y_ = p_ignore; } bool GdNavigationServer::agent_is_map_changed(RID p_agent) const { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND_V(agent == NULL, false); return agent->is_map_changed(); } COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) { - RvoAgent *agent = agent_owner.get(p_agent); + RvoAgent *agent = agent_owner.getornull(p_agent); ERR_FAIL_COND(agent == NULL); agent->set_callback(p_receiver == NULL ? 0 : p_receiver->get_instance_id(), p_method, p_udata); @@ -387,7 +387,7 @@ COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_ COMMAND_1(free, RID, p_object) { if (map_owner.owns(p_object)) { - NavMap *map = map_owner.get(p_object); + NavMap *map = map_owner.getornull(p_object); // Removes any assigned region std::vector regions = map->get_regions(); @@ -408,7 +408,7 @@ COMMAND_1(free, RID, p_object) { memdelete(map); } else if (region_owner.owns(p_object)) { - NavRegion *region = region_owner.get(p_object); + NavRegion *region = region_owner.getornull(p_object); // Removes this region from the map if assigned if (region->get_map() != NULL) { @@ -420,7 +420,7 @@ COMMAND_1(free, RID, p_object) { memdelete(region); } else if (agent_owner.owns(p_object)) { - RvoAgent *agent = agent_owner.get(p_object); + RvoAgent *agent = agent_owner.getornull(p_object); // Removes this agent from the map if assigned if (agent->get_map() != NULL) { diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h index 80ba06880c..b0fcdaf834 100644 --- a/modules/gdnavigation/gd_navigation_server.h +++ b/modules/gdnavigation/gd_navigation_server.h @@ -31,6 +31,8 @@ #ifndef GD_NAVIGATION_SERVER_H #define GD_NAVIGATION_SERVER_H +#include "core/rid.h" +#include "core/rid_owner.h" #include "servers/navigation_server.h" #include "nav_map.h" @@ -73,9 +75,9 @@ class GdNavigationServer : public NavigationServer { std::vector commands; - mutable RID_Owner map_owner; - mutable RID_Owner region_owner; - mutable RID_Owner agent_owner; + mutable RID_PtrOwner map_owner; + mutable RID_PtrOwner region_owner; + mutable RID_PtrOwner agent_owner; bool active; Vector active_maps; diff --git a/modules/gdnavigation/nav_rid.h b/modules/gdnavigation/nav_rid.h index 96e22800c2..b7cee74237 100644 --- a/modules/gdnavigation/nav_rid.h +++ b/modules/gdnavigation/nav_rid.h @@ -37,7 +37,7 @@ @author AndreaCatania */ -class NavRid : public RID_Data { +class NavRid { RID self; public: -- cgit v1.2.3 From 3f335ce3d446372eeb9ed87f7e117099c4d2dd6a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 11 Jun 2019 15:43:37 -0300 Subject: Texture refactor -Texture renamed to Texture2D -TextureLayered as base now inherits 2Darray, cubemap and cubemap array -Removed all references to flags in textures (they will go in the shader) -Texture3D gone for now (will come back later done properly) -Create base rasterizer for RenderDevice, RasterizerRD --- modules/assimp/import_utils.h | 16 ++++++++----- modules/dds/texture_loader_dds.cpp | 2 +- modules/etc/texture_loader_pkm.cpp | 2 +- modules/gdnative/arvr/arvr_interface_gdnative.cpp | 3 ++- .../videodecoder/video_stream_gdnative.cpp | 10 ++++++--- .../gdnative/videodecoder/video_stream_gdnative.h | 2 +- modules/gridmap/grid_map_editor_plugin.cpp | 2 +- modules/opensimplex/noise_texture.cpp | 26 ++++++++++++---------- modules/opensimplex/noise_texture.h | 11 ++++----- modules/pvr/texture_loader_pvr.cpp | 11 +++------ modules/theora/video_stream_theora.cpp | 8 ++++--- modules/theora/video_stream_theora.h | 2 +- modules/visual_script/visual_script_editor.cpp | 20 ++++++++--------- modules/visual_script/visual_script_editor.h | 4 ++-- .../visual_script_property_selector.cpp | 4 ++-- modules/webm/video_stream_webm.cpp | 9 +++++--- modules/webm/video_stream_webm.h | 2 +- 17 files changed, 71 insertions(+), 63 deletions(-) (limited to 'modules') diff --git a/modules/assimp/import_utils.h b/modules/assimp/import_utils.h index c522b01727..0eb055956b 100644 --- a/modules/assimp/import_utils.h +++ b/modules/assimp/import_utils.h @@ -189,7 +189,7 @@ public: } /** - * Converts aiMatrix4x4 to godot Transform + * Converts aiMatrix4x4 to godot Transform */ static const Transform assimp_matrix_transform(const aiMatrix4x4 p_matrix) { aiMatrix4x4 matrix = p_matrix; @@ -322,15 +322,18 @@ public: ERR_FAIL_COND(map_mode == NULL); aiTextureMapMode tex_mode = map_mode[0]; - int32_t flags = Texture::FLAGS_DEFAULT; + // FIXME: Commented out during Vulkan port. + /* + int32_t flags = Texture2D::FLAGS_DEFAULT; if (tex_mode == aiTextureMapMode_Wrap) { //Default } else if (tex_mode == aiTextureMapMode_Clamp) { - flags = flags & ~Texture::FLAG_REPEAT; + flags = flags & ~Texture2D::FLAG_REPEAT; } else if (tex_mode == aiTextureMapMode_Mirror) { - flags = flags | Texture::FLAG_MIRRORED_REPEAT; + flags = flags | Texture2D::FLAG_MIRRORED_REPEAT; } texture->set_flags(flags); + */ } /** @@ -391,7 +394,7 @@ public: } return Ref(); } else { - Ref texture = ResourceLoader::load(p_path); + Ref texture = ResourceLoader::load(p_path); ERR_FAIL_COND_V(texture.is_null(), Ref()); Ref image = texture->get_data(); ERR_FAIL_COND_V(image.is_null(), Ref()); @@ -418,7 +421,8 @@ public: if (image_state.raw_image.is_valid()) { image_state.texture.instance(); image_state.texture->create_from_image(image_state.raw_image); - image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY); + // FIXME: Commented out during Vulkan port. + //image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY); return true; } } diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index a7701329d8..5494744c48 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -457,7 +457,7 @@ void ResourceFormatDDS::get_recognized_extensions(List *p_extensions) co bool ResourceFormatDDS::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatDDS::get_resource_type(const String &p_path) const { diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index 27c2358306..facdc2e473 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -103,7 +103,7 @@ void ResourceFormatPKM::get_recognized_extensions(List *p_extensions) co bool ResourceFormatPKM::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPKM::get_resource_type(const String &p_path) const { diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index 5efa915f62..eb43a3971c 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -297,7 +297,8 @@ godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) { RID *render_target = (RID *)p_render_target; RID eye_texture = VSG::storage->render_target_get_texture(*render_target); - uint32_t texid = VS::get_singleton()->texture_get_texid(eye_texture); +#warning need to obtain this ID again + uint32_t texid = 0; //VS::get_singleton()->texture_get_texid(eye_texture); return texid; } diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index dbe00cdf71..8dcafc1987 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -132,7 +132,11 @@ bool VideoStreamPlaybackGDNative::open_file(const String &p_file) { pcm_write_idx = -1; samples_decoded = 0; - texture->create((int)texture_size.width, (int)texture_size.height, Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE); + Ref img; + img.instance(); + img->create((int)texture_size.width, false, (int)texture_size.height, Image::FORMAT_RGBA8); + + texture->create_from_image(img); } return file_opened; @@ -192,7 +196,7 @@ void VideoStreamPlaybackGDNative::update_texture() { Ref img = memnew(Image(texture_size.width, texture_size.height, 0, Image::FORMAT_RGBA8, *pba)); - texture->set_data(img); + texture->update(img, true); } // ctor and dtor @@ -283,7 +287,7 @@ void VideoStreamPlaybackGDNative::set_paused(bool p_paused) { paused = p_paused; } -Ref VideoStreamPlaybackGDNative::get_texture() const { +Ref VideoStreamPlaybackGDNative::get_texture() const { return texture; } diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index bb0346efb4..024cdec196 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -168,7 +168,7 @@ public: //virtual int mix(int16_t* p_buffer,int p_frames)=0; - virtual Ref get_texture() const; + virtual Ref get_texture() const; virtual void update(float p_delta); virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 28d301ada1..a8cb039cb3 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -925,7 +925,7 @@ void GridMapEditor::update_palette() { for (List<_CGMEItemSort>::Element *E = il.front(); E; E = E->next()) { int id = E->get().id; String name = mesh_library->get_item_name(id); - Ref preview = mesh_library->get_item_preview(id); + Ref preview = mesh_library->get_item_preview(id); if (name == "") { name = "#" + itos(id); diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index aa1c822813..19aa281a72 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -42,17 +42,16 @@ NoiseTexture::NoiseTexture() { seamless = false; as_normalmap = false; bump_strength = 8.0; - flags = FLAGS_DEFAULT; noise = Ref(); - texture = VS::get_singleton()->texture_create(); - _queue_update(); } NoiseTexture::~NoiseTexture() { - VS::get_singleton()->free(texture); + if (texture.is_valid()) { + VS::get_singleton()->free(texture); + } if (noise_thread) { Thread::wait_to_finish(noise_thread); memdelete(noise_thread); @@ -101,8 +100,12 @@ void NoiseTexture::_validate_property(PropertyInfo &property) const { void NoiseTexture::_set_texture_data(const Ref &p_image) { data = p_image; if (data.is_valid()) { - VS::get_singleton()->texture_allocate(texture, size.x, size.y, 0, Image::FORMAT_RGBA8, VS::TEXTURE_TYPE_2D, flags); - VS::get_singleton()->texture_set_data(texture, p_image); + if (texture.is_valid()) { + RID new_texture = VS::get_singleton()->texture_2d_create(p_image); + VS::get_singleton()->texture_replace(texture, new_texture); + } else { + texture = VS::get_singleton()->texture_2d_create(p_image); + } } emit_changed(); } @@ -250,13 +253,12 @@ int NoiseTexture::get_height() const { return size.y; } -void NoiseTexture::set_flags(uint32_t p_flags) { - flags = p_flags; - VS::get_singleton()->texture_set_flags(texture, flags); -} +RID NoiseTexture::get_rid() const { + if (!texture.is_valid()) { + texture = VS::get_singleton()->texture_2d_placeholder_create(); + } -uint32_t NoiseTexture::get_flags() const { - return flags; + return texture; } Ref NoiseTexture::get_data() const { diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h index 285fd1eba9..b1d7d3fac9 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -39,8 +39,8 @@ #include "editor/editor_plugin.h" #include "editor/property_editor.h" -class NoiseTexture : public Texture { - GDCLASS(NoiseTexture, Texture); +class NoiseTexture : public Texture2D { + GDCLASS(NoiseTexture, Texture2D); private: Ref data; @@ -51,7 +51,7 @@ private: bool update_queued; bool regen_queued; - RID texture; + mutable RID texture; uint32_t flags; Ref noise; @@ -91,10 +91,7 @@ public: int get_width() const; int get_height() const; - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - - virtual RID get_rid() const { return texture; } + virtual RID get_rid() const; virtual bool has_alpha() const { return false; } virtual Ref get_data() const; diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 65c21d5af8..36f2fe1ba1 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -154,16 +154,11 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, w.release(); - int tex_flags = Texture::FLAG_FILTER | Texture::FLAG_REPEAT; - - if (mipmaps) - tex_flags |= Texture::FLAG_MIPMAPS; - Ref image = memnew(Image(width, height, mipmaps, format, data)); ERR_FAIL_COND_V(image->empty(), RES()); Ref texture = memnew(ImageTexture); - texture->create_from_image(image, tex_flags); + texture->create_from_image(image); if (r_error) *r_error = OK; @@ -177,12 +172,12 @@ void ResourceFormatPVR::get_recognized_extensions(List *p_extensions) co } bool ResourceFormatPVR::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPVR::get_resource_type(const String &p_path) const { if (p_path.get_extension().to_lower() == "pvr") - return "Texture"; + return "Texture2D"; return ""; } diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 00c7e87568..de229745f5 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -110,7 +110,7 @@ void VideoStreamPlaybackTheora::video_write(void) { Ref img = memnew(Image(size.x, size.y, 0, Image::FORMAT_RGBA8, frame_data)); //zero copy image creation - texture->set_data(img); //zero copy send to visual server + texture->update(img, true); //zero copy send to visual server frames_pending = 1; } @@ -336,7 +336,9 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) { size.x = w; size.y = h; - texture->create(w, h, Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE); + Ref img; + img.instance(); + img->create(w, h, false, Image::FORMAT_RGBA8); } else { /* tear down the partial theora setup */ @@ -369,7 +371,7 @@ float VideoStreamPlaybackTheora::get_time() const { return time - /* AudioServer::get_singleton()->get_output_latency() - */ delay_compensation; }; -Ref VideoStreamPlaybackTheora::get_texture() const { +Ref VideoStreamPlaybackTheora::get_texture() const { return texture; } diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index 0f201ffa9d..c0a0faec4b 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -147,7 +147,7 @@ public: void set_file(const String &p_file); - virtual Ref get_texture() const; + virtual Ref get_texture() const; virtual void update(float p_delta); virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index ec20698ae8..18851e6ab6 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -499,7 +499,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { graph->show(); select_func_text->hide(); - Ref type_icons[Variant::VARIANT_MAX] = { + Ref type_icons[Variant::VARIANT_MAX] = { Control::get_icon("Variant", "EditorIcons"), Control::get_icon("bool", "EditorIcons"), Control::get_icon("int", "EditorIcons"), @@ -529,7 +529,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Control::get_icon("PoolColorArray", "EditorIcons") }; - Ref seq_port = Control::get_icon("VisualShaderPort", "EditorIcons"); + Ref seq_port = Control::get_icon("VisualShaderPort", "EditorIcons"); for (List::Element *F = funcs.front(); F; F = F->next()) { // loop through all the functions @@ -702,7 +702,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { vbc->add_child(hbc2); if (left_ok) { - Ref t; + Ref t; if (left_type >= 0 && left_type < Variant::VARIANT_MAX) { t = type_icons[left_type]; } @@ -830,7 +830,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { hbc->add_child(memnew(Label(right_name))); } - Ref t; + Ref t; if (right_type >= 0 && right_type < Variant::VARIANT_MAX) { t = type_icons[right_type]; } @@ -846,7 +846,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { bool dark_theme = get_constant("dark_theme", "Editor"); if (i < mixed_seq_ports) { - gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref(), seq_port); + gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref(), seq_port); } else { gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), right_ok, right_type, _color_from_type(right_type, dark_theme)); } @@ -955,7 +955,7 @@ void VisualScriptEditor::_update_members() { variables->add_button(0, Control::get_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable.")); variables->set_custom_color(0, Control::get_color("mono_color", "Editor")); - Ref type_icons[Variant::VARIANT_MAX] = { + Ref type_icons[Variant::VARIANT_MAX] = { Control::get_icon("Variant", "EditorIcons"), Control::get_icon("bool", "EditorIcons"), Control::get_icon("int", "EditorIcons"), @@ -2369,7 +2369,7 @@ void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) { button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color); } -void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud) { +void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud) { Array ud = p_ud; ERR_FAIL_COND(ud.size() != 2); @@ -2447,7 +2447,7 @@ String VisualScriptEditor::get_name() { return name; } -Ref VisualScriptEditor::get_icon() { +Ref VisualScriptEditor::get_icon() { return Control::get_icon("VisualScript", "EditorIcons"); } @@ -4467,9 +4467,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) { TreeItem *root = members->get_root(); - Ref del_icon = Control::get_icon("Remove", "EditorIcons"); + Ref del_icon = Control::get_icon("Remove", "EditorIcons"); - Ref edit_icon = Control::get_icon("Edit", "EditorIcons"); + Ref edit_icon = Control::get_icon("Edit", "EditorIcons"); if (ti->get_parent() == root->get_children()) { diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index 7f3bf79d50..40e9e1cc98 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -277,7 +277,7 @@ class VisualScriptEditor : public ScriptEditorBase { void _selected_method(const String &p_method, const String &p_type, const bool p_connecting); void _draw_color_over_button(Object *obj, Color p_color); - void _button_resource_previewed(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud); + void _button_resource_previewed(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, Variant p_ud); VisualScriptNode::TypeGuess _guess_output_type(int p_port_action_node, int p_port_action_output, Set &p_visited_nodes); @@ -298,7 +298,7 @@ public: virtual Vector get_functions(); virtual void reload_text(); virtual String get_name(); - virtual Ref get_icon(); + virtual Ref get_icon(); virtual bool is_unsaved(); virtual Variant get_edit_state(); virtual void set_edit_state(const Variant &p_state); diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 99d7ffd05f..e629175094 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -98,7 +98,7 @@ void VisualScriptPropertySelector::_update_search() { List methods; List props; TreeItem *category = NULL; - Ref type_icons[Variant::VARIANT_MAX] = { + Ref type_icons[Variant::VARIANT_MAX] = { Control::get_icon("Variant", "EditorIcons"), Control::get_icon("bool", "EditorIcons"), Control::get_icon("int", "EditorIcons"), @@ -133,7 +133,7 @@ void VisualScriptPropertySelector::_update_search() { if (category) { category->set_text(0, b.replace_first("*", "")); category->set_selectable(0, false); - Ref icon; + Ref icon; String rep = b.replace("*", ""); icon = EditorNode::get_singleton()->get_class_icon(rep); category->set_icon(0, icon); diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 2763d30bb5..54d34a48c5 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -141,7 +141,10 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) { } frame_data.resize((webm->getWidth() * webm->getHeight()) << 2); - texture->create(webm->getWidth(), webm->getHeight(), Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE); + Ref img; + img.instance(); + img->create(webm->getWidth(), webm->getHeight(), false, Image::FORMAT_RGBA8); + texture->create_from_image(img); return true; } @@ -231,7 +234,7 @@ void VideoStreamPlaybackWebm::set_audio_track(int p_idx) { audio_track = p_idx; } -Ref VideoStreamPlaybackWebm::get_texture() const { +Ref VideoStreamPlaybackWebm::get_texture() const { return texture; } @@ -356,7 +359,7 @@ void VideoStreamPlaybackWebm::update(float p_delta) { if (converted) { Ref img = memnew(Image(image.w, image.h, 0, Image::FORMAT_RGBA8, frame_data)); - texture->set_data(img); //Zero copy send to visual server + texture->update(img); //Zero copy send to visual server video_frame_done = true; } } diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h index e679196cf2..f2a68dd701 100644 --- a/modules/webm/video_stream_webm.h +++ b/modules/webm/video_stream_webm.h @@ -90,7 +90,7 @@ public: virtual void set_audio_track(int p_idx); - virtual Ref get_texture() const; + virtual Ref get_texture() const; virtual void update(float p_delta); virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata); -- cgit v1.2.3 From 9b0dd4f571ff431e23b9097e7f29746f4157be12 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 15 Jun 2019 23:45:24 -0300 Subject: A lot of progress with canvas rendering, still far from working. --- modules/gdnative/arvr/arvr_interface_gdnative.cpp | 5 +++-- modules/mobile_vr/mobile_vr_interface.cpp | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index eb43a3971c..967bcee522 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -286,9 +286,10 @@ void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_re screen_rect.size.x /= 2.0; screen_rect.position.x += screen_rect.size.x; } - - VSG::rasterizer->set_current_render_target(RID()); +#warning this needs to be redone +#if 0 VSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0); +#endif } godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) { diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index 22b708f206..97bc7945cd 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -426,11 +426,13 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t eye_center.y = 0.0; // unset our render target so we are outputting to our main screen by making RasterizerStorageGLES3::system_fbo our current FBO +#if 0 VSG::rasterizer->set_current_render_target(RID()); // and output VSG::rasterizer->output_lens_distorted_to_screen(p_render_target, dest, k1, k2, eye_center, oversample); -}; +#endif +} void MobileVRInterface::process() { _THREAD_SAFE_METHOD_ -- cgit v1.2.3 From 50e9befb888480a3d6cb2fa46b58c0753b69bd86 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 12 Jul 2019 10:12:48 -0300 Subject: Changes to material required to add custom shaders in RD renderer --- modules/gridmap/grid_map_editor_plugin.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules') diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index a8cb039cb3..e1e0044cea 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1458,14 +1458,12 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8)); outer_mat->set_on_top_of_alpha(); outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - outer_mat->set_line_width(3.0); outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); selection_floor_mat.instance(); selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1)); selection_floor_mat->set_on_top_of_alpha(); selection_floor_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - selection_floor_mat->set_line_width(3.0); d[VS::ARRAY_VERTEX] = lines; VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d); -- cgit v1.2.3 From c613ead5fa2361296cf8d9a80d4648492ff4e16f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 29 Jul 2019 12:59:18 -0300 Subject: Added a spinlock template as well as a thread work pool class. Also, optimized shader compilation to happen on threads. --- modules/glslang/register_types.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index ef159e743d..843bd93c05 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -140,9 +140,6 @@ static PoolVector _compile_shader_glsl(RenderingDevice::ShaderStage p_s ERR_FAIL_COND_V(p_language==RenderingDevice::SHADER_LANGUAGE_HLSL,ret); - // initialize in case it's not initialized. This is done once per thread - // and it's safe to call multiple times - glslang::InitializeProcess(); EShLanguage stages[RenderingDevice::SHADER_STAGE_MAX] = { EShLangVertex, EShLangFragment, @@ -229,6 +226,9 @@ static PoolVector _compile_shader_glsl(RenderingDevice::ShaderStage p_s } void preregister_glslang_types() { + // initialize in case it's not initialized. This is done once per thread + // and it's safe to call multiple times + glslang::InitializeProcess(); RenderingDevice::shader_set_compile_function(_compile_shader_glsl); } @@ -236,5 +236,5 @@ void register_glslang_types() { } void unregister_glslang_types() { - + glslang::FinalizeProcess(); } -- cgit v1.2.3 From 4fe3ee1730167b90ec8ae70c871c1dad032981d5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 28 Jul 2019 19:58:32 -0300 Subject: Moved the shader source compilation code outside RenderingDevice and Vulkan --- modules/glslang/SCsub | 68 +++++++++++ modules/glslang/config.py | 5 + modules/glslang/register_types.cpp | 240 +++++++++++++++++++++++++++++++++++++ modules/glslang/register_types.h | 34 ++++++ modules/register_module_types.h | 1 + 5 files changed, 348 insertions(+) create mode 100644 modules/glslang/SCsub create mode 100644 modules/glslang/config.py create mode 100644 modules/glslang/register_types.cpp create mode 100644 modules/glslang/register_types.h (limited to 'modules') diff --git a/modules/glslang/SCsub b/modules/glslang/SCsub new file mode 100644 index 0000000000..484036dc94 --- /dev/null +++ b/modules/glslang/SCsub @@ -0,0 +1,68 @@ +#!/usr/bin/env python + +Import('env') +Import('env_modules') + +env_glslang = env_modules.Clone() + +# Thirdparty source files +# Not unbundled so far since not widespread as shared library +thirdparty_dir = "#thirdparty/glslang/" +thirdparty_sources = [ +"glslang/MachineIndependent/RemoveTree.cpp", +"glslang/MachineIndependent/ParseHelper.cpp", +"glslang/MachineIndependent/iomapper.cpp", +"glslang/MachineIndependent/propagateNoContraction.cpp", +"glslang/MachineIndependent/Intermediate.cpp", +"glslang/MachineIndependent/linkValidate.cpp", +"glslang/MachineIndependent/attribute.cpp", +"glslang/MachineIndependent/Scan.cpp", +"glslang/MachineIndependent/Initialize.cpp", +"glslang/MachineIndependent/Constant.cpp", +"glslang/MachineIndependent/reflection.cpp", +"glslang/MachineIndependent/limits.cpp", +"glslang/MachineIndependent/preprocessor/PpScanner.cpp", +"glslang/MachineIndependent/preprocessor/PpTokens.cpp", +"glslang/MachineIndependent/preprocessor/PpAtom.cpp", +"glslang/MachineIndependent/preprocessor/PpContext.cpp", +"glslang/MachineIndependent/preprocessor/Pp.cpp", +"glslang/MachineIndependent/InfoSink.cpp", +"glslang/MachineIndependent/intermOut.cpp", +"glslang/MachineIndependent/SymbolTable.cpp", +"glslang/MachineIndependent/glslang_tab.cpp", +"glslang/MachineIndependent/pch.cpp", +"glslang/MachineIndependent/Versions.cpp", +"glslang/MachineIndependent/ShaderLang.cpp", +"glslang/MachineIndependent/parseConst.cpp", +"glslang/MachineIndependent/PoolAlloc.cpp", +"glslang/MachineIndependent/ParseContextBase.cpp", +"glslang/MachineIndependent/IntermTraverse.cpp", +"glslang/GenericCodeGen/Link.cpp", +"glslang/GenericCodeGen/CodeGen.cpp", +"OGLCompilersDLL/InitializeDll.cpp", +"SPIRV/InReadableOrder.cpp", +"SPIRV/GlslangToSpv.cpp", +"SPIRV/SpvBuilder.cpp", +"SPIRV/SpvTools.cpp", +"SPIRV/disassemble.cpp", +"SPIRV/doc.cpp", +"SPIRV/SPVRemapper.cpp", +"SPIRV/SpvPostProcess.cpp", +"SPIRV/Logger.cpp" +] + +if (env["platform"]=="windows"): + thirdparty_sources.append("glslang/OSDependent/Windows/ossource.cpp") +else: + thirdparty_sources.append("glslang/OSDependent/Unix/ossource.cpp") + +thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + + +env_glslang.add_source_files(env.modules_sources, thirdparty_sources) +# Godot's own source files +env_glslang.add_source_files(env.modules_sources, "*.cpp") +env.Prepend(CPPPATH=[thirdparty_dir]) + + + diff --git a/modules/glslang/config.py b/modules/glslang/config.py new file mode 100644 index 0000000000..1c8cd12a2d --- /dev/null +++ b/modules/glslang/config.py @@ -0,0 +1,5 @@ +def can_build(env, platform): + return True + +def configure(env): + pass diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp new file mode 100644 index 0000000000..ef159e743d --- /dev/null +++ b/modules/glslang/register_types.cpp @@ -0,0 +1,240 @@ +/*************************************************************************/ +/* register_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "register_types.h" +#include "servers/visual/rendering_device.h" + +#include "thirdparty/glslang/SPIRV/GlslangToSpv.h" +#include "thirdparty/glslang/glslang/Include/Types.h" +#include "thirdparty/glslang/glslang/Public/ShaderLang.h" + +static const TBuiltInResource default_builtin_resource = { + .maxLights = 32, + .maxClipPlanes = 6, + .maxTextureUnits = 32, + .maxTextureCoords = 32, + .maxVertexAttribs = 64, + .maxVertexUniformComponents = 4096, + .maxVaryingFloats = 64, + .maxVertexTextureImageUnits = 32, + .maxCombinedTextureImageUnits = 80, + .maxTextureImageUnits = 32, + .maxFragmentUniformComponents = 4096, + .maxDrawBuffers = 32, + .maxVertexUniformVectors = 128, + .maxVaryingVectors = 8, + .maxFragmentUniformVectors = 16, + .maxVertexOutputVectors = 16, + .maxFragmentInputVectors = 15, + .minProgramTexelOffset = -8, + .maxProgramTexelOffset = 7, + .maxClipDistances = 8, + .maxComputeWorkGroupCountX = 65535, + .maxComputeWorkGroupCountY = 65535, + .maxComputeWorkGroupCountZ = 65535, + .maxComputeWorkGroupSizeX = 1024, + .maxComputeWorkGroupSizeY = 1024, + .maxComputeWorkGroupSizeZ = 64, + .maxComputeUniformComponents = 1024, + .maxComputeTextureImageUnits = 16, + .maxComputeImageUniforms = 8, + .maxComputeAtomicCounters = 8, + .maxComputeAtomicCounterBuffers = 1, + .maxVaryingComponents = 60, + .maxVertexOutputComponents = 64, + .maxGeometryInputComponents = 64, + .maxGeometryOutputComponents = 128, + .maxFragmentInputComponents = 128, + .maxImageUnits = 8, + .maxCombinedImageUnitsAndFragmentOutputs = 8, + .maxCombinedShaderOutputResources = 8, + .maxImageSamples = 0, + .maxVertexImageUniforms = 0, + .maxTessControlImageUniforms = 0, + .maxTessEvaluationImageUniforms = 0, + .maxGeometryImageUniforms = 0, + .maxFragmentImageUniforms = 8, + .maxCombinedImageUniforms = 8, + .maxGeometryTextureImageUnits = 16, + .maxGeometryOutputVertices = 256, + .maxGeometryTotalOutputComponents = 1024, + .maxGeometryUniformComponents = 1024, + .maxGeometryVaryingComponents = 64, + .maxTessControlInputComponents = 128, + .maxTessControlOutputComponents = 128, + .maxTessControlTextureImageUnits = 16, + .maxTessControlUniformComponents = 1024, + .maxTessControlTotalOutputComponents = 4096, + .maxTessEvaluationInputComponents = 128, + .maxTessEvaluationOutputComponents = 128, + .maxTessEvaluationTextureImageUnits = 16, + .maxTessEvaluationUniformComponents = 1024, + .maxTessPatchComponents = 120, + .maxPatchVertices = 32, + .maxTessGenLevel = 64, + .maxViewports = 16, + .maxVertexAtomicCounters = 0, + .maxTessControlAtomicCounters = 0, + .maxTessEvaluationAtomicCounters = 0, + .maxGeometryAtomicCounters = 0, + .maxFragmentAtomicCounters = 8, + .maxCombinedAtomicCounters = 8, + .maxAtomicCounterBindings = 1, + .maxVertexAtomicCounterBuffers = 0, + .maxTessControlAtomicCounterBuffers = 0, + .maxTessEvaluationAtomicCounterBuffers = 0, + .maxGeometryAtomicCounterBuffers = 0, + .maxFragmentAtomicCounterBuffers = 1, + .maxCombinedAtomicCounterBuffers = 1, + .maxAtomicCounterBufferSize = 16384, + .maxTransformFeedbackBuffers = 4, + .maxTransformFeedbackInterleavedComponents = 64, + .maxCullDistances = 8, + .maxCombinedClipAndCullDistances = 8, + .maxSamples = 4, + .limits = { + .nonInductiveForLoops = 1, + .whileLoops = 1, + .doWhileLoops = 1, + .generalUniformIndexing = 1, + .generalAttributeMatrixVectorIndexing = 1, + .generalVaryingIndexing = 1, + .generalSamplerIndexing = 1, + .generalVariableIndexing = 1, + .generalConstantMatrixVectorIndexing = 1, + } +}; + + + +static PoolVector _compile_shader_glsl(RenderingDevice::ShaderStage p_stage, const String &p_source_code, RenderingDevice::ShaderLanguage p_language, String *r_error) { + + PoolVector ret; + + ERR_FAIL_COND_V(p_language==RenderingDevice::SHADER_LANGUAGE_HLSL,ret); + + // initialize in case it's not initialized. This is done once per thread + // and it's safe to call multiple times + glslang::InitializeProcess(); + EShLanguage stages[RenderingDevice::SHADER_STAGE_MAX] = { + EShLangVertex, + EShLangFragment, + EShLangTessControl, + EShLangTessEvaluation, + EShLangCompute + }; + + int ClientInputSemanticsVersion = 100; // maps to, say, #define VULKAN 100 + + glslang::EShTargetClientVersion VulkanClientVersion = glslang::EShTargetVulkan_1_0; + glslang::EShTargetLanguageVersion TargetVersion = glslang::EShTargetSpv_1_0; + glslang::TShader::ForbidIncluder includer; + + glslang::TShader shader(stages[p_stage]); + CharString cs = p_source_code.ascii(); + const char *cs_strings = cs.get_data(); + + shader.setStrings(&cs_strings, 1); + shader.setEnvInput(glslang::EShSourceGlsl, stages[p_stage], glslang::EShClientVulkan, ClientInputSemanticsVersion); + shader.setEnvClient(glslang::EShClientVulkan, VulkanClientVersion); + shader.setEnvTarget(glslang::EShTargetSpv, TargetVersion); + + EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules); + const int DefaultVersion = 100; + std::string pre_processed_code; + + //preprocess + if (!shader.preprocess(&default_builtin_resource, DefaultVersion, ENoProfile, false, false, messages, &pre_processed_code, includer)) { + + if (r_error) { + (*r_error) = "Failed pre-process:\n"; + (*r_error) += shader.getInfoLog(); + (*r_error) += "\n"; + (*r_error) += shader.getInfoDebugLog(); + } + + return ret; + } + //set back.. + cs_strings = pre_processed_code.c_str(); + shader.setStrings(&cs_strings, 1); + + //parse + if (!shader.parse(&default_builtin_resource, DefaultVersion, false, messages)) { + if (r_error) { + (*r_error) = "Failed parse:\n"; + (*r_error) += shader.getInfoLog(); + (*r_error) += "\n"; + (*r_error) += shader.getInfoDebugLog(); + } + return ret; + } + + //link + glslang::TProgram program; + program.addShader(&shader); + + if (!program.link(messages)) { + if (r_error) { + (*r_error) = "Failed link:\n"; + (*r_error) += program.getInfoLog(); + (*r_error) += "\n"; + (*r_error) += program.getInfoDebugLog(); + } + + return ret; + } + + + std::vector SpirV; + spv::SpvBuildLogger logger; + glslang::SpvOptions spvOptions; + glslang::GlslangToSpv(*program.getIntermediate(stages[p_stage]), SpirV, &logger, &spvOptions); + + + ret.resize(SpirV.size() * sizeof(uint32_t)); + { + PoolVector::Write w = ret.write(); + copymem(w.ptr(),&SpirV[0],SpirV.size()*sizeof(uint32_t)); + } + + return ret; +} + +void preregister_glslang_types() { + RenderingDevice::shader_set_compile_function(_compile_shader_glsl); +} + +void register_glslang_types() { +} +void unregister_glslang_types() { + + +} diff --git a/modules/glslang/register_types.h b/modules/glslang/register_types.h new file mode 100644 index 0000000000..83bfaf8d93 --- /dev/null +++ b/modules/glslang/register_types.h @@ -0,0 +1,34 @@ +/*************************************************************************/ +/* register_types.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#define MODULE_GLSLANG_HAS_PREREGISTER +void preregister_glslang_types(); +void register_glslang_types(); +void unregister_glslang_types(); diff --git a/modules/register_module_types.h b/modules/register_module_types.h index b410457201..acd9fc7c97 100644 --- a/modules/register_module_types.h +++ b/modules/register_module_types.h @@ -31,6 +31,7 @@ #ifndef REGISTER_MODULE_TYPES_H #define REGISTER_MODULE_TYPES_H +void preregister_module_types(); void register_module_types(); void unregister_module_types(); -- cgit v1.2.3 From eb48be51dbe97aa4fbbbe0d0ebd8a98bee6b263e Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sat, 22 Jun 2019 19:34:26 +0300 Subject: Add static Vulkan loader. Initial Vulkan support for Windows. Initial Vulkan support for macOS. --- modules/gdnative/arvr/arvr_interface_gdnative.cpp | 4 + modules/glslang/SCsub | 86 +++++----- modules/glslang/register_types.cpp | 197 +++++++++++----------- 3 files changed, 148 insertions(+), 139 deletions(-) (limited to 'modules') diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index 967bcee522..7c791a3108 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -286,7 +286,9 @@ void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_re screen_rect.size.x /= 2.0; screen_rect.position.x += screen_rect.size.x; } +#ifndef _MSC_VER #warning this needs to be redone +#endif #if 0 VSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0); #endif @@ -298,7 +300,9 @@ godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) { RID *render_target = (RID *)p_render_target; RID eye_texture = VSG::storage->render_target_get_texture(*render_target); +#ifndef _MSC_VER #warning need to obtain this ID again +#endif uint32_t texid = 0; //VS::get_singleton()->texture_get_texid(eye_texture); return texid; diff --git a/modules/glslang/SCsub b/modules/glslang/SCsub index 484036dc94..7e401ff52c 100644 --- a/modules/glslang/SCsub +++ b/modules/glslang/SCsub @@ -9,52 +9,52 @@ env_glslang = env_modules.Clone() # Not unbundled so far since not widespread as shared library thirdparty_dir = "#thirdparty/glslang/" thirdparty_sources = [ -"glslang/MachineIndependent/RemoveTree.cpp", -"glslang/MachineIndependent/ParseHelper.cpp", -"glslang/MachineIndependent/iomapper.cpp", -"glslang/MachineIndependent/propagateNoContraction.cpp", -"glslang/MachineIndependent/Intermediate.cpp", -"glslang/MachineIndependent/linkValidate.cpp", -"glslang/MachineIndependent/attribute.cpp", -"glslang/MachineIndependent/Scan.cpp", -"glslang/MachineIndependent/Initialize.cpp", -"glslang/MachineIndependent/Constant.cpp", -"glslang/MachineIndependent/reflection.cpp", -"glslang/MachineIndependent/limits.cpp", -"glslang/MachineIndependent/preprocessor/PpScanner.cpp", -"glslang/MachineIndependent/preprocessor/PpTokens.cpp", -"glslang/MachineIndependent/preprocessor/PpAtom.cpp", -"glslang/MachineIndependent/preprocessor/PpContext.cpp", -"glslang/MachineIndependent/preprocessor/Pp.cpp", -"glslang/MachineIndependent/InfoSink.cpp", -"glslang/MachineIndependent/intermOut.cpp", -"glslang/MachineIndependent/SymbolTable.cpp", -"glslang/MachineIndependent/glslang_tab.cpp", -"glslang/MachineIndependent/pch.cpp", -"glslang/MachineIndependent/Versions.cpp", -"glslang/MachineIndependent/ShaderLang.cpp", -"glslang/MachineIndependent/parseConst.cpp", -"glslang/MachineIndependent/PoolAlloc.cpp", -"glslang/MachineIndependent/ParseContextBase.cpp", -"glslang/MachineIndependent/IntermTraverse.cpp", -"glslang/GenericCodeGen/Link.cpp", -"glslang/GenericCodeGen/CodeGen.cpp", -"OGLCompilersDLL/InitializeDll.cpp", -"SPIRV/InReadableOrder.cpp", -"SPIRV/GlslangToSpv.cpp", -"SPIRV/SpvBuilder.cpp", -"SPIRV/SpvTools.cpp", -"SPIRV/disassemble.cpp", -"SPIRV/doc.cpp", -"SPIRV/SPVRemapper.cpp", -"SPIRV/SpvPostProcess.cpp", -"SPIRV/Logger.cpp" + "glslang/MachineIndependent/RemoveTree.cpp", + "glslang/MachineIndependent/ParseHelper.cpp", + "glslang/MachineIndependent/iomapper.cpp", + "glslang/MachineIndependent/propagateNoContraction.cpp", + "glslang/MachineIndependent/Intermediate.cpp", + "glslang/MachineIndependent/linkValidate.cpp", + "glslang/MachineIndependent/attribute.cpp", + "glslang/MachineIndependent/Scan.cpp", + "glslang/MachineIndependent/Initialize.cpp", + "glslang/MachineIndependent/Constant.cpp", + "glslang/MachineIndependent/reflection.cpp", + "glslang/MachineIndependent/limits.cpp", + "glslang/MachineIndependent/preprocessor/PpScanner.cpp", + "glslang/MachineIndependent/preprocessor/PpTokens.cpp", + "glslang/MachineIndependent/preprocessor/PpAtom.cpp", + "glslang/MachineIndependent/preprocessor/PpContext.cpp", + "glslang/MachineIndependent/preprocessor/Pp.cpp", + "glslang/MachineIndependent/InfoSink.cpp", + "glslang/MachineIndependent/intermOut.cpp", + "glslang/MachineIndependent/SymbolTable.cpp", + "glslang/MachineIndependent/glslang_tab.cpp", + "glslang/MachineIndependent/pch.cpp", + "glslang/MachineIndependent/Versions.cpp", + "glslang/MachineIndependent/ShaderLang.cpp", + "glslang/MachineIndependent/parseConst.cpp", + "glslang/MachineIndependent/PoolAlloc.cpp", + "glslang/MachineIndependent/ParseContextBase.cpp", + "glslang/MachineIndependent/IntermTraverse.cpp", + "glslang/GenericCodeGen/Link.cpp", + "glslang/GenericCodeGen/CodeGen.cpp", + "OGLCompilersDLL/InitializeDll.cpp", + "SPIRV/InReadableOrder.cpp", + "SPIRV/GlslangToSpv.cpp", + "SPIRV/SpvBuilder.cpp", + "SPIRV/SpvTools.cpp", + "SPIRV/disassemble.cpp", + "SPIRV/doc.cpp", + "SPIRV/SPVRemapper.cpp", + "SPIRV/SpvPostProcess.cpp", + "SPIRV/Logger.cpp" ] if (env["platform"]=="windows"): - thirdparty_sources.append("glslang/OSDependent/Windows/ossource.cpp") + thirdparty_sources.append("glslang/OSDependent/Windows/ossource.cpp") else: - thirdparty_sources.append("glslang/OSDependent/Unix/ossource.cpp") + thirdparty_sources.append("glslang/OSDependent/Unix/ossource.cpp") thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] @@ -64,5 +64,3 @@ env_glslang.add_source_files(env.modules_sources, thirdparty_sources) env_glslang.add_source_files(env.modules_sources, "*.cpp") env.Prepend(CPPPATH=[thirdparty_dir]) - - diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index ef159e743d..fffddcc94a 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -36,104 +36,111 @@ #include "thirdparty/glslang/glslang/Public/ShaderLang.h" static const TBuiltInResource default_builtin_resource = { - .maxLights = 32, - .maxClipPlanes = 6, - .maxTextureUnits = 32, - .maxTextureCoords = 32, - .maxVertexAttribs = 64, - .maxVertexUniformComponents = 4096, - .maxVaryingFloats = 64, - .maxVertexTextureImageUnits = 32, - .maxCombinedTextureImageUnits = 80, - .maxTextureImageUnits = 32, - .maxFragmentUniformComponents = 4096, - .maxDrawBuffers = 32, - .maxVertexUniformVectors = 128, - .maxVaryingVectors = 8, - .maxFragmentUniformVectors = 16, - .maxVertexOutputVectors = 16, - .maxFragmentInputVectors = 15, - .minProgramTexelOffset = -8, - .maxProgramTexelOffset = 7, - .maxClipDistances = 8, - .maxComputeWorkGroupCountX = 65535, - .maxComputeWorkGroupCountY = 65535, - .maxComputeWorkGroupCountZ = 65535, - .maxComputeWorkGroupSizeX = 1024, - .maxComputeWorkGroupSizeY = 1024, - .maxComputeWorkGroupSizeZ = 64, - .maxComputeUniformComponents = 1024, - .maxComputeTextureImageUnits = 16, - .maxComputeImageUniforms = 8, - .maxComputeAtomicCounters = 8, - .maxComputeAtomicCounterBuffers = 1, - .maxVaryingComponents = 60, - .maxVertexOutputComponents = 64, - .maxGeometryInputComponents = 64, - .maxGeometryOutputComponents = 128, - .maxFragmentInputComponents = 128, - .maxImageUnits = 8, - .maxCombinedImageUnitsAndFragmentOutputs = 8, - .maxCombinedShaderOutputResources = 8, - .maxImageSamples = 0, - .maxVertexImageUniforms = 0, - .maxTessControlImageUniforms = 0, - .maxTessEvaluationImageUniforms = 0, - .maxGeometryImageUniforms = 0, - .maxFragmentImageUniforms = 8, - .maxCombinedImageUniforms = 8, - .maxGeometryTextureImageUnits = 16, - .maxGeometryOutputVertices = 256, - .maxGeometryTotalOutputComponents = 1024, - .maxGeometryUniformComponents = 1024, - .maxGeometryVaryingComponents = 64, - .maxTessControlInputComponents = 128, - .maxTessControlOutputComponents = 128, - .maxTessControlTextureImageUnits = 16, - .maxTessControlUniformComponents = 1024, - .maxTessControlTotalOutputComponents = 4096, - .maxTessEvaluationInputComponents = 128, - .maxTessEvaluationOutputComponents = 128, - .maxTessEvaluationTextureImageUnits = 16, - .maxTessEvaluationUniformComponents = 1024, - .maxTessPatchComponents = 120, - .maxPatchVertices = 32, - .maxTessGenLevel = 64, - .maxViewports = 16, - .maxVertexAtomicCounters = 0, - .maxTessControlAtomicCounters = 0, - .maxTessEvaluationAtomicCounters = 0, - .maxGeometryAtomicCounters = 0, - .maxFragmentAtomicCounters = 8, - .maxCombinedAtomicCounters = 8, - .maxAtomicCounterBindings = 1, - .maxVertexAtomicCounterBuffers = 0, - .maxTessControlAtomicCounterBuffers = 0, - .maxTessEvaluationAtomicCounterBuffers = 0, - .maxGeometryAtomicCounterBuffers = 0, - .maxFragmentAtomicCounterBuffers = 1, - .maxCombinedAtomicCounterBuffers = 1, - .maxAtomicCounterBufferSize = 16384, - .maxTransformFeedbackBuffers = 4, - .maxTransformFeedbackInterleavedComponents = 64, - .maxCullDistances = 8, - .maxCombinedClipAndCullDistances = 8, - .maxSamples = 4, - .limits = { - .nonInductiveForLoops = 1, - .whileLoops = 1, - .doWhileLoops = 1, - .generalUniformIndexing = 1, - .generalAttributeMatrixVectorIndexing = 1, - .generalVaryingIndexing = 1, - .generalSamplerIndexing = 1, - .generalVariableIndexing = 1, - .generalConstantMatrixVectorIndexing = 1, + /*maxLights*/ 32, + /*maxClipPlanes*/ 6, + /*maxTextureUnits*/ 32, + /*maxTextureCoords*/ 32, + /*maxVertexAttribs*/ 64, + /*maxVertexUniformComponents*/ 4096, + /*maxVaryingFloats*/ 64, + /*maxVertexTextureImageUnits*/ 32, + /*maxCombinedTextureImageUnits*/ 80, + /*maxTextureImageUnits*/ 32, + /*maxFragmentUniformComponents*/ 4096, + /*maxDrawBuffers*/ 32, + /*maxVertexUniformVectors*/ 128, + /*maxVaryingVectors*/ 8, + /*maxFragmentUniformVectors*/ 16, + /*maxVertexOutputVectors*/ 16, + /*maxFragmentInputVectors*/ 15, + /*minProgramTexelOffset*/ -8, + /*maxProgramTexelOffset*/ 7, + /*maxClipDistances*/ 8, + /*maxComputeWorkGroupCountX*/ 65535, + /*maxComputeWorkGroupCountY*/ 65535, + /*maxComputeWorkGroupCountZ*/ 65535, + /*maxComputeWorkGroupSizeX*/ 1024, + /*maxComputeWorkGroupSizeY*/ 1024, + /*maxComputeWorkGroupSizeZ*/ 64, + /*maxComputeUniformComponents*/ 1024, + /*maxComputeTextureImageUnits*/ 16, + /*maxComputeImageUniforms*/ 8, + /*maxComputeAtomicCounters*/ 8, + /*maxComputeAtomicCounterBuffers*/ 1, + /*maxVaryingComponents*/ 60, + /*maxVertexOutputComponents*/ 64, + /*maxGeometryInputComponents*/ 64, + /*maxGeometryOutputComponents*/ 128, + /*maxFragmentInputComponents*/ 128, + /*maxImageUnits*/ 8, + /*maxCombinedImageUnitsAndFragmentOutputs*/ 8, + /*maxCombinedShaderOutputResources*/ 8, + /*maxImageSamples*/ 0, + /*maxVertexImageUniforms*/ 0, + /*maxTessControlImageUniforms*/ 0, + /*maxTessEvaluationImageUniforms*/ 0, + /*maxGeometryImageUniforms*/ 0, + /*maxFragmentImageUniforms*/ 8, + /*maxCombinedImageUniforms*/ 8, + /*maxGeometryTextureImageUnits*/ 16, + /*maxGeometryOutputVertices*/ 256, + /*maxGeometryTotalOutputComponents*/ 1024, + /*maxGeometryUniformComponents*/ 1024, + /*maxGeometryVaryingComponents*/ 64, + /*maxTessControlInputComponents*/ 128, + /*maxTessControlOutputComponents*/ 128, + /*maxTessControlTextureImageUnits*/ 16, + /*maxTessControlUniformComponents*/ 1024, + /*maxTessControlTotalOutputComponents*/ 4096, + /*maxTessEvaluationInputComponents*/ 128, + /*maxTessEvaluationOutputComponents*/ 128, + /*maxTessEvaluationTextureImageUnits*/ 16, + /*maxTessEvaluationUniformComponents*/ 1024, + /*maxTessPatchComponents*/ 120, + /*maxPatchVertices*/ 32, + /*maxTessGenLevel*/ 64, + /*maxViewports*/ 16, + /*maxVertexAtomicCounters*/ 0, + /*maxTessControlAtomicCounters*/ 0, + /*maxTessEvaluationAtomicCounters*/ 0, + /*maxGeometryAtomicCounters*/ 0, + /*maxFragmentAtomicCounters*/ 8, + /*maxCombinedAtomicCounters*/ 8, + /*maxAtomicCounterBindings*/ 1, + /*maxVertexAtomicCounterBuffers*/ 0, + /*maxTessControlAtomicCounterBuffers*/ 0, + /*maxTessEvaluationAtomicCounterBuffers*/ 0, + /*maxGeometryAtomicCounterBuffers*/ 0, + /*maxFragmentAtomicCounterBuffers*/ 1, + /*maxCombinedAtomicCounterBuffers*/ 1, + /*maxAtomicCounterBufferSize*/ 16384, + /*maxTransformFeedbackBuffers*/ 4, + /*maxTransformFeedbackInterleavedComponents*/ 64, + /*maxCullDistances*/ 8, + /*maxCombinedClipAndCullDistances*/ 8, + /*maxSamples*/ 4, + /*maxMeshOutputVerticesNV*/ 0, + /*maxMeshOutputPrimitivesNV*/ 0, + /*maxMeshWorkGroupSizeX_NV*/ 0, + /*maxMeshWorkGroupSizeY_NV*/ 0, + /*maxMeshWorkGroupSizeZ_NV*/ 0, + /*maxTaskWorkGroupSizeX_NV*/ 0, + /*maxTaskWorkGroupSizeY_NV*/ 0, + /*maxTaskWorkGroupSizeZ_NV*/ 0, + /*maxMeshViewCountNV*/ 0, + /*limits*/ { + /*nonInductiveForLoops*/ 1, + /*whileLoops*/ 1, + /*doWhileLoops*/ 1, + /*generalUniformIndexing*/ 1, + /*generalAttributeMatrixVectorIndexing*/ 1, + /*generalVaryingIndexing*/ 1, + /*generalSamplerIndexing*/ 1, + /*generalVariableIndexing*/ 1, + /*generalConstantMatrixVectorIndexing*/ 1, } }; - - static PoolVector _compile_shader_glsl(RenderingDevice::ShaderStage p_stage, const String &p_source_code, RenderingDevice::ShaderLanguage p_language, String *r_error) { PoolVector ret; -- cgit v1.2.3 From 449df8f688080c02bfbbfafc45421875b77deb1b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 18 Aug 2019 19:40:52 -0300 Subject: Base 3D engine done, still untested, though. --- modules/gridmap/grid_map_editor_plugin.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index e1e0044cea..7b846569dc 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1022,8 +1022,7 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) { Vector3 edited_floor = node->has_meta("_editor_floor_") ? node->get_meta("_editor_floor_") : Variant(); for (int i = 0; i < 3; i++) { - if (VS::get_singleton()->mesh_get_surface_count(grid[i]) > 0) - VS::get_singleton()->mesh_remove_surface(grid[i], 0); + VS::get_singleton()->mesh_clear(grid[i]); edit_floor[i] = edited_floor[i]; } -- cgit v1.2.3 From 6deffa62fbd1e91873afa663630b788b9ffabee3 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 14 Sep 2019 00:37:42 -0300 Subject: Several fixes to 3D rendering, and multimesh implementation. --- modules/gridmap/grid_map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 1e73a715db..7fe58f8ce7 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -514,7 +514,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) { Octant::MultimeshInstance mmi; RID mm = VS::get_singleton()->multimesh_create(); - VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE); + VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D); VS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid()); int idx = 0; -- cgit v1.2.3 From dd3682e5feb433117fbf62c363c7ba6ff214f8fa Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 15 Sep 2019 01:01:52 -0300 Subject: Modernized default 3D material, fixes material bugs. --- modules/assimp/editor_scene_importer_assimp.cpp | 64 +++++++++++-------------- modules/bullet/space_bullet.cpp | 24 +++++----- modules/csg/csg_shape.cpp | 12 ++--- modules/gridmap/grid_map_editor_plugin.cpp | 19 ++++---- modules/gridmap/grid_map_editor_plugin.h | 8 ++-- 5 files changed, 61 insertions(+), 66 deletions(-) (limited to 'modules') diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index 69ab068648..7a84a5329d 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -995,15 +995,15 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat } aiMaterial *ai_material = state.assimp_scene->mMaterials[ai_mesh->mMaterialIndex]; - Ref mat; + Ref mat; mat.instance(); int32_t mat_two_sided = 0; if (AI_SUCCESS == ai_material->Get(AI_MATKEY_TWOSIDED, mat_two_sided)) { if (mat_two_sided > 0) { - mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); } else { - mat->set_cull_mode(SpatialMaterial::CULL_BACK); + mat->set_cull_mode(StandardMaterial3D::CULL_BACK); } } @@ -1015,7 +1015,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Culling handling for meshes // cull all back faces - mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // Now process materials aiTextureType base_color = aiTextureType_BASE_COLOR; @@ -1028,13 +1028,11 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // anything transparent must be culled if (image_data.raw_image->detect_alpha() != Image::ALPHA_NONE) { - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); - mat->set_cull_mode( - SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode } - mat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, image_data.texture); } } @@ -1048,22 +1046,18 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // anything transparent must be culled if (image_data.raw_image->detect_alpha() != Image::ALPHA_NONE) { - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); - mat->set_cull_mode( - SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode } - mat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, image_data.texture); } aiColor4D clr_diffuse; if (AI_SUCCESS == ai_material->Get(AI_MATKEY_COLOR_DIFFUSE, clr_diffuse)) { if (Math::is_equal_approx(clr_diffuse.a, 1.0f) == false) { - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); - mat->set_cull_mode( - SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode } mat->set_albedo(Color(clr_diffuse.r, clr_diffuse.g, clr_diffuse.b, clr_diffuse.a)); } @@ -1078,14 +1072,14 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_normal, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); - mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture); + mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true); + mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture); } else { aiString texture_path; if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_NORMAL_TEXTURE, AI_PROPERTIES, texture_path)) { if (AssimpUtils::CreateAssimpTexture(state, texture_path, filename, path, image_data)) { - mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); - mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture); + mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true); + mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture); } } } @@ -1100,8 +1094,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_normal_camera, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); - mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture); + mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true); + mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture); } } @@ -1114,8 +1108,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_emission_color, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); - mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture); + mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true); + mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture); } } @@ -1128,7 +1122,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_metalness, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_texture(SpatialMaterial::TEXTURE_METALLIC, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_METALLIC, image_data.texture); } } @@ -1141,7 +1135,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_roughness, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_ROUGHNESS, image_data.texture); } } @@ -1154,16 +1148,16 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_emissive, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::FEATURE_EMISSION, true); - mat->set_texture(SpatialMaterial::TEXTURE_EMISSION, image_data.texture); + mat->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); + mat->set_texture(StandardMaterial3D::TEXTURE_EMISSION, image_data.texture); } else { // Process emission textures aiString texture_emissive_path; if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_EMISSION_TEXTURE, AI_PROPERTIES, texture_emissive_path)) { if (AssimpUtils::CreateAssimpTexture(state, texture_emissive_path, filename, path, image_data)) { - mat->set_feature(SpatialMaterial::FEATURE_EMISSION, true); - mat->set_texture(SpatialMaterial::TEXTURE_EMISSION, image_data.texture); + mat->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); + mat->set_texture(StandardMaterial3D::TEXTURE_EMISSION, image_data.texture); } } else { float pbr_emission = 0.0f; @@ -1183,7 +1177,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_specular, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_texture(SpatialMaterial::TEXTURE_METALLIC, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_METALLIC, image_data.texture); } } @@ -1196,8 +1190,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_ao_map, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true); - mat->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, image_data.texture); + mat->set_feature(StandardMaterial3D::FEATURE_AMBIENT_OCCLUSION, true); + mat->set_texture(StandardMaterial3D::TEXTURE_AMBIENT_OCCLUSION, image_data.texture); } } diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index dae1719aa9..69f3d1b393 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -890,8 +890,8 @@ void SpaceBullet::update_gravity() { static ImmediateGeometry *motionVec(NULL); static ImmediateGeometry *normalLine(NULL); -static Ref red_mat; -static Ref blue_mat; +static Ref red_mat; +static Ref blue_mat; #endif bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes) { @@ -908,21 +908,21 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f motionVec->set_as_toplevel(true); normalLine->set_as_toplevel(true); - red_mat = Ref(memnew(SpatialMaterial)); - red_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + red_mat = Ref(memnew(StandardMaterial3D)); + red_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); red_mat->set_line_width(20.0); - red_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - red_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - red_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + red_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + red_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + red_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); red_mat->set_albedo(Color(1, 0, 0, 1)); motionVec->set_material_override(red_mat); - blue_mat = Ref(memnew(SpatialMaterial)); - blue_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + blue_mat = Ref(memnew(StandardMaterial3D)); + blue_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); blue_mat->set_line_width(20.0); - blue_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - blue_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - blue_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + blue_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + blue_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + blue_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); blue_mat->set_albedo(Color(0, 0, 1, 1)); normalLine->set_material_override(blue_mat); } diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index c8a72ff813..33e4e9748c 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -896,7 +896,7 @@ void CSGMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh::get_material); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGMesh::set_mesh(const Ref &p_mesh) { @@ -1059,7 +1059,7 @@ void CSGSphere::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments"); ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1"), "set_rings", "get_rings"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGSphere::set_radius(const float p_radius) { @@ -1245,7 +1245,7 @@ void CSGBox::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGBox::set_width(const float p_width) { @@ -1462,7 +1462,7 @@ void CSGCylinder::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_sides", "get_sides"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cone"), "set_cone", "is_cone"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGCylinder::set_radius(const float p_radius) { @@ -1689,7 +1689,7 @@ void CSGTorus::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_sides", "get_sides"); ADD_PROPERTY(PropertyInfo(Variant::INT, "ring_sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_ring_sides", "get_ring_sides"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGTorus::set_inner_radius(const float p_inner_radius) { @@ -2330,7 +2330,7 @@ void CSGPolygon::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_continuous_u"), "set_path_continuous_u", "is_path_continuous_u"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_joined"), "set_path_joined", "is_path_joined"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); BIND_ENUM_CONSTANT(MODE_DEPTH); BIND_ENUM_CONSTANT(MODE_SPIN); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 7b846569dc..2144ff264f 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1446,8 +1446,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { inner_mat.instance(); inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2)); - inner_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - inner_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + inner_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + inner_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); d[VS::ARRAY_VERTEX] = triangles; VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_TRIANGLES, d); @@ -1456,13 +1456,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { outer_mat.instance(); outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8)); outer_mat->set_on_top_of_alpha(); - outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + + outer_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + outer_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); selection_floor_mat.instance(); selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1)); selection_floor_mat->set_on_top_of_alpha(); - selection_floor_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + selection_floor_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); d[VS::ARRAY_VERTEX] = lines; VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d); @@ -1489,10 +1490,10 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { accumulated_floor_delta = 0.0; indicator_mat.instance(); - indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + indicator_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + indicator_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); indicator_mat->set_albedo(Color(0.8, 0.5, 0.1)); } diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 5e6221b4f0..d6459cee0a 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -125,10 +125,10 @@ class GridMapEditor : public VBoxContainer { List clipboard_items; - Ref indicator_mat; - Ref inner_mat; - Ref outer_mat; - Ref selection_floor_mat; + Ref indicator_mat; + Ref inner_mat; + Ref outer_mat; + Ref selection_floor_mat; bool updating; -- cgit v1.2.3 From 4aea9f74e650743fe6585d5230dd6e5f6c94c478 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 26 Sep 2019 23:16:44 -0300 Subject: Rewritten StreamTexture for better code reuse, added basis universal support --- modules/basis_universal/SCsub | 38 +++++ modules/basis_universal/config.py | 5 + modules/basis_universal/register_types.cpp | 262 +++++++++++++++++++++++++++++ modules/basis_universal/register_types.h | 32 ++++ modules/basis_universal/texture_bu.cpp | 203 ++++++++++++++++++++++ modules/basis_universal/texture_bu.h | 47 ++++++ modules/cvtt/image_compress_cvtt.cpp | 4 +- modules/cvtt/image_compress_cvtt.h | 2 +- modules/etc/image_etc.cpp | 59 ++----- modules/squish/image_compress_squish.cpp | 62 ++----- modules/squish/image_compress_squish.h | 2 +- 11 files changed, 614 insertions(+), 102 deletions(-) create mode 100644 modules/basis_universal/SCsub create mode 100644 modules/basis_universal/config.py create mode 100644 modules/basis_universal/register_types.cpp create mode 100644 modules/basis_universal/register_types.h create mode 100644 modules/basis_universal/texture_bu.cpp create mode 100644 modules/basis_universal/texture_bu.h (limited to 'modules') diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub new file mode 100644 index 0000000000..5fe994cda9 --- /dev/null +++ b/modules/basis_universal/SCsub @@ -0,0 +1,38 @@ +#!/usr/bin/env python +import string + +Import('env') +Import('env_modules') + +env_bu = env_modules.Clone() +env_bu.Append(CPPPATH=["#thirdparty/basis_universal", "#thirdparty/basis_universal/transcoder"]) + +if env['target'] == "debug": + env_bu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) + +tool_sources = string.split(""" + #thirdparty/basis_universal/basisu_astc_decomp.cpp + #thirdparty/basis_universal/basisu_backend.cpp + #thirdparty/basis_universal/basisu_basis_file.cpp + #thirdparty/basis_universal/basisu_comp.cpp + #thirdparty/basis_universal/basisu_enc.cpp + #thirdparty/basis_universal/basisu_etc.cpp + #thirdparty/basis_universal/basisu_frontend.cpp + #thirdparty/basis_universal/basisu_global_selector_palette_helpers.cpp + #thirdparty/basis_universal/basisu_gpu_texture.cpp + #thirdparty/basis_universal/basisu_pvrtc1_4.cpp + #thirdparty/basis_universal/basisu_resample_filters.cpp + #thirdparty/basis_universal/basisu_resampler.cpp + #thirdparty/basis_universal/basisu_ssim.cpp + #thirdparty/basis_universal/basisu_tool.cpp + #thirdparty/basis_universal/lodepng.cpp + """) + +transcoder_sources = ["#thirdparty/basis_universal/transcoder/basisu_transcoder.cpp"] + +if env['tools']: + env_bu.add_source_files(env.modules_sources, tool_sources) + +env_bu.add_source_files(env.modules_sources, transcoder_sources) + +env_bu.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/basis_universal/config.py b/modules/basis_universal/config.py new file mode 100644 index 0000000000..1c8cd12a2d --- /dev/null +++ b/modules/basis_universal/config.py @@ -0,0 +1,5 @@ +def can_build(env, platform): + return True + +def configure(env): + pass diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp new file mode 100644 index 0000000000..226567982b --- /dev/null +++ b/modules/basis_universal/register_types.cpp @@ -0,0 +1,262 @@ +#include "register_types.h" + +#include "core/os/os.h" +#include "texture_bu.h" + +#ifdef TOOLS_ENABLED +#include "thirdparty/basis_universal/basisu_comp.h" +#endif + +#include "thirdparty/basis_universal/transcoder/basisu.h" + +#include "servers/visual_server.h" + +enum BasisDecompressFormat { + BASIS_DECOMPRESS_RG, + BASIS_DECOMPRESS_RGB, + BASIS_DECOMPRESS_RGBA, + BASIS_DECOMPRESS_RG_AS_RA +}; + +//workaround for lack of ETC2 RG +#define USE_RG_AS_RGBA + +basist::etc1_global_selector_codebook *sel_codebook = nullptr; + +static PoolVector basis_universal_packer(const Ref &p_image, Image::UsedChannels p_channels) { + + PoolVector budata; + +#ifdef TOOLS_ENABLED + + { + Ref image = p_image->duplicate(); + + // unfortunately, basis universal does not support compressing supplied mipmaps, + // so for the time being, only compressing individual images will have to do. + + if (image->has_mipmaps()) { + image->clear_mipmaps(); + } + if (image->get_format() != Image::FORMAT_RGBA8) { + image->convert(Image::FORMAT_RGBA8); + } + + basisu::image buimg(image->get_width(), image->get_height()); + + { + PoolVector vec = image->get_data(); + PoolVector::Read r = vec.read(); + + memcpy(buimg.get_ptr(), r.ptr(), vec.size()); + } + + //image->save_png("pepeche.png"); + + basisu::basis_compressor_params params; + params.m_max_endpoint_clusters = 512; + params.m_max_selector_clusters = 512; + params.m_multithreading = true; + params.m_no_hybrid_sel_cb = true; //fixme, default on this causes crashes + params.m_pSel_codebook = sel_codebook; + params.m_quality_level = 0; + //params.m_disable_hierarchical_endpoint_codebooks = true; + //params.m_no_selector_rdo = true; + + basisu::job_pool jpool(OS::get_singleton()->get_processor_count()); + params.m_pJob_pool = &jpool; + + params.m_mip_gen = false; //sorry, please some day support provided mipmaps. + params.m_source_images.push_back(buimg); + + BasisDecompressFormat decompress_format; + params.m_check_for_alpha = false; + + switch (p_channels) { + case Image::USED_CHANNELS_L: { + decompress_format = BASIS_DECOMPRESS_RGB; + } break; + case Image::USED_CHANNELS_LA: { + params.m_force_alpha = true; + decompress_format = BASIS_DECOMPRESS_RGBA; + } break; + case Image::USED_CHANNELS_R: { + decompress_format = BASIS_DECOMPRESS_RGB; + } break; + case Image::USED_CHANNELS_RG: { +#ifdef USE_RG_AS_RGBA + image->convert_rg_to_ra_rgba8(); + decompress_format = BASIS_DECOMPRESS_RG_AS_RA; + +#else + + params.m_seperate_rg_to_color_alpha = true; + decompress_format = BASIS_DECOMPRESS_RG; + +#endif + + } break; + case Image::USED_CHANNELS_RGB: { + decompress_format = BASIS_DECOMPRESS_RGB; + } break; + case Image::USED_CHANNELS_RGBA: { + params.m_force_alpha = true; + decompress_format = BASIS_DECOMPRESS_RGBA; + } break; + } + + basisu::basis_compressor c; + c.init(params); + + int buerr = c.process(); + ERR_FAIL_COND_V(buerr != basisu::basis_compressor::cECSuccess, budata); + + const basisu::uint8_vec &buvec = c.get_output_basis_file(); + budata.resize(buvec.size() + 4); + + { + PoolVector::Write w = budata.write(); + uint32_t *decf = (uint32_t *)w.ptr(); + *decf = decompress_format; + memcpy(w.ptr() + 4, &buvec[0], buvec.size()); + } + } + +#endif + return budata; +} + +static Ref basis_universal_unpacker(const PoolVector &p_buffer) { + Ref image; + + PoolVector::Read r = p_buffer.read(); + const uint8_t *ptr = r.ptr(); + int size = p_buffer.size(); + + basist::transcoder_texture_format format; + Image::Format imgfmt; + + switch (*(uint32_t *)(ptr)) { + case BASIS_DECOMPRESS_RG: { + + if (VS::get_singleton()->has_os_feature("rgtc")) { + format = basist::cTFBC5; // get this from renderer + imgfmt = Image::FORMAT_RGTC_RG; + } else if (VS::get_singleton()->has_os_feature("etc2")) { + //unfortunately, basis universal does not support + // + ERR_FAIL_V(image); //unimplemented here + //format = basist::cTFETC1; // get this from renderer + //imgfmt = Image::FORMAT_RGTC_RG; + } else { + //decompress + } + } break; + case BASIS_DECOMPRESS_RGB: { + if (VS::get_singleton()->has_os_feature("bptc")) { + format = basist::cTFBC7_M6_OPAQUE_ONLY; // get this from renderer + imgfmt = Image::FORMAT_BPTC_RGBA; + } else if (VS::get_singleton()->has_os_feature("s3tc")) { + format = basist::cTFBC1; // get this from renderer + imgfmt = Image::FORMAT_DXT1; + } else if (VS::get_singleton()->has_os_feature("etc")) { + + format = basist::cTFETC1; // get this from renderer + imgfmt = Image::FORMAT_ETC; + } else { + format = basist::cTFBGR565; // get this from renderer + imgfmt = Image::FORMAT_RGB565; + } + + } break; + case BASIS_DECOMPRESS_RGBA: { + if (VS::get_singleton()->has_os_feature("bptc")) { + format = basist::cTFBC7_M5; // get this from renderer + imgfmt = Image::FORMAT_BPTC_RGBA; + } else if (VS::get_singleton()->has_os_feature("s3tc")) { + format = basist::cTFBC3; // get this from renderer + imgfmt = Image::FORMAT_DXT5; + } else if (VS::get_singleton()->has_os_feature("etc2")) { + format = basist::cTFETC2; // get this from renderer + imgfmt = Image::FORMAT_ETC2_RGBA8; + } else { + //gles2 most likely + format = basist::cTFRGBA4444; // get this from renderer + imgfmt = Image::FORMAT_RGBA4444; + } + } break; + case BASIS_DECOMPRESS_RG_AS_RA: { + if (VS::get_singleton()->has_os_feature("s3tc")) { + format = basist::cTFBC3; // get this from renderer + imgfmt = Image::FORMAT_DXT5_RA_AS_RG; + } else if (VS::get_singleton()->has_os_feature("etc2")) { + format = basist::cTFETC2; // get this from renderer + imgfmt = Image::FORMAT_ETC2_RGBA8; + } else { + //gles2 most likely, bad for normalmaps, nothing to do about this. + format = basist::cTFRGBA32; + imgfmt = Image::FORMAT_RGBA8; + } + } break; + } + + ptr += 4; + size -= 4; + + basist::basisu_transcoder tr(NULL); + + ERR_FAIL_COND_V(!tr.validate_header(ptr, size), image); + + basist::basisu_image_info info; + tr.get_image_info(ptr, size, info, 0); + + int block_size = basist::basis_get_bytes_per_block(format); + PoolVector gpudata; + gpudata.resize(info.m_total_blocks * block_size); + + { + PoolVector::Write w = gpudata.write(); + uint8_t *dst = w.ptr(); + for (int i = 0; i < gpudata.size(); i++) + dst[i] = 0x00; + + int ofs = 0; + tr.start_transcoding(ptr, size); + for (uint32_t i = 0; i < info.m_total_levels; i++) { + + basist::basisu_image_level_info level; + tr.get_image_level_info(ptr, size, level, 0, i); + + bool ret = tr.transcode_image_level(ptr, size, 0, i, dst + ofs, level.m_total_blocks - i, format); + if (!ret) { + printf("failed! on level %i\n", i); + break; + }; + + ofs += level.m_total_blocks * block_size; + }; + }; + + image.instance(); + image->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); + + return image; +} + +void register_basis_universal_types() { +#ifdef TOOLS_ENABLED + sel_codebook = new basist::etc1_global_selector_codebook(basist::g_global_selector_cb_size, basist::g_global_selector_cb); + Image::basis_universal_packer = basis_universal_packer; +#endif + Image::basis_universal_unpacker = basis_universal_unpacker; + // ClassDB::register_class(); +} + +void unregister_basis_universal_types() { + +#ifdef TOOLS_ENABLED + delete sel_codebook; +#endif + Image::basis_universal_packer = NULL; + Image::basis_universal_unpacker = NULL; +} diff --git a/modules/basis_universal/register_types.h b/modules/basis_universal/register_types.h new file mode 100644 index 0000000000..3e9acc0896 --- /dev/null +++ b/modules/basis_universal/register_types.h @@ -0,0 +1,32 @@ +/*************************************************************************/ +/* register_types.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +void register_basis_universal_types(); +void unregister_basis_universal_types(); diff --git a/modules/basis_universal/texture_bu.cpp b/modules/basis_universal/texture_bu.cpp new file mode 100644 index 0000000000..73a945b33d --- /dev/null +++ b/modules/basis_universal/texture_bu.cpp @@ -0,0 +1,203 @@ +#include "texture_bu.h" +#if 0 +#include "core/os/os.h" + +#ifdef TOOLS_ENABLED +#include "basisu_comp.h" +#endif + +#include "transcoder/basisu.h" + +void TextureBU::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_bu_data", "data"), &TextureBU::set_bu_data); + ClassDB::bind_method(D_METHOD("get_bu_data"), &TextureBU::get_data); + ClassDB::bind_method(D_METHOD("import"), &TextureBU::import); + + ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "bu_data"), "set_bu_data", "get_bu_data"); + +}; + +int TextureBU::get_width() const { + + return tex_size.x; +}; + +int TextureBU::get_height() const { + + return tex_size.y; +}; + +RID TextureBU::get_rid() const { + + return texture; +}; + + +bool TextureBU::has_alpha() const { + + return false; +}; + +void TextureBU::set_flags(uint32_t p_flags) { + + flags = p_flags; + VisualServer::get_singleton()->texture_set_flags(texture, p_flags); +}; + +uint32_t TextureBU::get_flags() const { + + return flags; +}; + + +void TextureBU::set_bu_data(const PoolVector& p_data) { + +#ifdef TOOLS_ENABLED + data = p_data; +#endif + + PoolVector::Read r = p_data.read(); + const void* ptr = r.ptr(); + int size = p_data.size(); + + basist::transcoder_texture_format format; + Image::Format imgfmt; + + if (OS::get_singleton()->has_feature("s3tc")) { + + format = basist::cTFBC3; // get this from renderer + imgfmt = Image::FORMAT_DXT5; + + } else if (OS::get_singleton()->has_feature("etc2")) { + + format = basist::cTFETC2; + imgfmt = Image::FORMAT_ETC2_RGBA8; + }; + + basist::basisu_transcoder tr(NULL); + + ERR_FAIL_COND(!tr.validate_header(ptr, size)); + + basist::basisu_image_info info; + tr.get_image_info(ptr, size, info, 0); + tex_size = Size2(info.m_width, info.m_height); + + int block_size = basist::basis_get_bytes_per_block(format); + PoolVector gpudata; + gpudata.resize(info.m_total_blocks * block_size); + + { + PoolVector::Write w = gpudata.write(); + uint8_t* dst = w.ptr(); + for (int i=0; i img; + img.instance(); + img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); + + VisualServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), VS::TEXTURE_TYPE_2D, flags); + VisualServer::get_singleton()->texture_set_data(texture, img); +}; + +Error TextureBU::import(const Ref& p_img) { + +#ifdef TOOLS_ENABLED + + PoolVector budata; + + { + Image::Format format = p_img->get_format(); + if (format != Image::FORMAT_RGB8 && format != Image::FORMAT_RGBA8) { + ERR_FAIL_V(ERR_INVALID_PARAMETER); + return ERR_INVALID_PARAMETER; + }; + + Ref copy = p_img->duplicate(); + if (format == Image::FORMAT_RGB8) + copy->convert(Image::FORMAT_RGBA8); + + basisu::image buimg(p_img->get_width(), p_img->get_height()); + int size = p_img->get_width() * p_img->get_height() * 4; + + PoolVector vec = copy->get_data(); + { + PoolVector::Read r = vec.read(); + memcpy(buimg.get_ptr(), r.ptr(), size); + }; + + basisu::basis_compressor_params params; + params.m_max_endpoint_clusters = 512; + params.m_max_selector_clusters = 512; + params.m_multithreading = true; + + basisu::job_pool jpool(1); + params.m_pJob_pool = &jpool; + + params.m_mip_gen = p_img->get_mipmap_count() > 0; + params.m_source_images.push_back(buimg); + + basisu::basis_compressor c; + c.init(params); + + int buerr = c.process(); + if (buerr != basisu::basis_compressor::cECSuccess) { + ERR_FAIL_V(ERR_INVALID_PARAMETER); + return ERR_INVALID_PARAMETER; + }; + + const basisu::uint8_vec& buvec = c.get_output_basis_file(); + budata.resize(buvec.size()); + + { + PoolVector::Write w = budata.write(); + memcpy(w.ptr(), &buvec[0], budata.size()); + }; + }; + + set_bu_data(budata); + + return OK; +#else + + return ERR_UNAVAILABLE; +#endif +}; + + +PoolVector TextureBU::get_bu_data() const { + + return data; +}; + +TextureBU::TextureBU() { + + flags = FLAGS_DEFAULT; + texture = VisualServer::get_singleton()->texture_create(); +}; + + +TextureBU::~TextureBU() { + + VisualServer::get_singleton()->free(texture); +}; + +#endif diff --git a/modules/basis_universal/texture_bu.h b/modules/basis_universal/texture_bu.h new file mode 100644 index 0000000000..9ec9194a96 --- /dev/null +++ b/modules/basis_universal/texture_bu.h @@ -0,0 +1,47 @@ +#include "scene/resources/texture.h" + +#ifdef TOOLS_ENABLED +#include "thirdparty/basis_universal/basisu_comp.h" +#endif + +#include "thirdparty/basis_universal/transcoder/basisu.h" + +#if 0 +class TextureBU : public Texture { + + GDCLASS(TextureBU, Texture); + RES_BASE_EXTENSION("butex"); + + RID texture; + Size2 tex_size; + + uint32_t flags; + + PoolVector data; + + static void _bind_methods(); + +public: + + virtual int get_width() const; + virtual int get_height() const; + virtual RID get_rid() const; + virtual bool has_alpha() const; + + virtual void set_flags(uint32_t p_flags); + virtual uint32_t get_flags() const; + + + Error import(const Ref &p_img); + + void set_bu_data(const PoolVector& p_data); + + PoolVector get_bu_data() const; + String get_img_path() const; + + TextureBU(); + ~TextureBU(); + +}; + +#endif diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp index c261350e89..4d762b7a7b 100644 --- a/modules/cvtt/image_compress_cvtt.cpp +++ b/modules/cvtt/image_compress_cvtt.cpp @@ -136,7 +136,7 @@ static void _digest_job_queue(void *p_job_queue) { } } -void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressSource p_source) { +void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels) { if (p_image->get_format() >= Image::FORMAT_BPTC_RGBA) return; //do not compress, already compressed @@ -167,7 +167,7 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS flags |= cvtt::Flags::BC7_RespectPunchThrough; - if (p_source == Image::COMPRESS_SOURCE_NORMAL) { + if (p_channels == Image::USED_CHANNELS_RG) { //guessing this is a normalmap flags |= cvtt::Flags::Uniform; } diff --git a/modules/cvtt/image_compress_cvtt.h b/modules/cvtt/image_compress_cvtt.h index ecb876ecc6..c1772199af 100644 --- a/modules/cvtt/image_compress_cvtt.h +++ b/modules/cvtt/image_compress_cvtt.h @@ -33,7 +33,7 @@ #include "core/image.h" -void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressSource p_source); +void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels); void image_decompress_cvtt(Image *p_image); #endif // IMAGE_COMPRESS_CVTT_H diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index b80138c99d..006902462b 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -36,18 +36,18 @@ #include "core/os/os.h" #include "core/print_string.h" -static Image::Format _get_etc2_mode(Image::DetectChannels format) { +static Image::Format _get_etc2_mode(Image::UsedChannels format) { switch (format) { - case Image::DETECTED_R: + case Image::USED_CHANNELS_R: return Image::FORMAT_ETC2_R11; - case Image::DETECTED_RG: + case Image::USED_CHANNELS_RG: return Image::FORMAT_ETC2_RG11; - case Image::DETECTED_RGB: + case Image::USED_CHANNELS_RGB: return Image::FORMAT_ETC2_RGB8; - case Image::DETECTED_RGBA: + case Image::USED_CHANNELS_RGBA: return Image::FORMAT_ETC2_RGBA8; // TODO: would be nice if we could use FORMAT_ETC2_RGB8A1 for FORMAT_RGBA5551 @@ -88,47 +88,8 @@ static Etc::Image::Format _image_format_to_etc2comp_format(Image::Format format) } } -static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_format, Image::CompressSource p_source) { +static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_format, Image::UsedChannels p_channels) { Image::Format img_format = p_img->get_format(); - Image::DetectChannels detected_channels = p_img->get_detected_channels(); - - if (p_source == Image::COMPRESS_SOURCE_LAYERED) { - //keep what comes in - switch (p_img->get_format()) { - case Image::FORMAT_L8: { - detected_channels = Image::DETECTED_L; - } break; - case Image::FORMAT_LA8: { - detected_channels = Image::DETECTED_LA; - } break; - case Image::FORMAT_R8: { - detected_channels = Image::DETECTED_R; - } break; - case Image::FORMAT_RG8: { - detected_channels = Image::DETECTED_RG; - } break; - case Image::FORMAT_RGB8: { - detected_channels = Image::DETECTED_RGB; - } break; - case Image::FORMAT_RGBA8: - case Image::FORMAT_RGBA4444: - case Image::FORMAT_RGBA5551: { - detected_channels = Image::DETECTED_RGBA; - } break; - default: { - } - } - } - - if (p_source == Image::COMPRESS_SOURCE_SRGB && (detected_channels == Image::DETECTED_R || detected_channels == Image::DETECTED_RG)) { - //R and RG do not support SRGB - detected_channels = Image::DETECTED_RGB; - } - - if (p_source == Image::COMPRESS_SOURCE_NORMAL) { - //use RG channels only for normal - detected_channels = Image::DETECTED_RG; - } if (img_format >= Image::FORMAT_DXT1) { return; //do not compress, already compressed @@ -153,7 +114,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f uint32_t imgw = p_img->get_width(), imgh = p_img->get_height(); - Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels); + Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(p_channels); Ref img = p_img->duplicate(); @@ -241,11 +202,11 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f } static void _compress_etc1(Image *p_img, float p_lossy_quality) { - _compress_etc(p_img, p_lossy_quality, true, Image::COMPRESS_SOURCE_GENERIC); + _compress_etc(p_img, p_lossy_quality, true, Image::USED_CHANNELS_RGB); } -static void _compress_etc2(Image *p_img, float p_lossy_quality, Image::CompressSource p_source) { - _compress_etc(p_img, p_lossy_quality, false, p_source); +static void _compress_etc2(Image *p_img, float p_lossy_quality, Image::UsedChannels p_channels) { + _compress_etc(p_img, p_lossy_quality, false, p_channels); } void _register_etc_compress_func() { diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index 58b8115dfc..2f680fd3d0 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -50,7 +50,7 @@ void image_decompress_squish(Image *p_image) { squish_flags = squish::kDxt1; } else if (p_image->get_format() == Image::FORMAT_DXT3) { squish_flags = squish::kDxt3; - } else if (p_image->get_format() == Image::FORMAT_DXT5) { + } else if (p_image->get_format() == Image::FORMAT_DXT5 || p_image->get_format() == Image::FORMAT_DXT5_RA_AS_RG) { squish_flags = squish::kDxt5; } else if (p_image->get_format() == Image::FORMAT_RGTC_R) { squish_flags = squish::kBc4; @@ -71,9 +71,13 @@ void image_decompress_squish(Image *p_image) { } p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data); + + if (p_image->get_format() == Image::FORMAT_DXT5_RA_AS_RG) { + p_image->convert_ra_rgba8_to_rg(); + } } -void image_compress_squish(Image *p_image, float p_lossy_quality, Image::CompressSource p_source) { +void image_compress_squish(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels) { if (p_image->get_format() >= Image::FORMAT_DXT1) return; //do not compress, already compressed @@ -92,75 +96,35 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::Compres Image::Format target_format = Image::FORMAT_RGBA8; - Image::DetectChannels dc = p_image->get_detected_channels(); - - if (p_source == Image::COMPRESS_SOURCE_LAYERED) { - //keep what comes in - switch (p_image->get_format()) { - case Image::FORMAT_L8: { - dc = Image::DETECTED_L; - } break; - case Image::FORMAT_LA8: { - dc = Image::DETECTED_LA; - } break; - case Image::FORMAT_R8: { - dc = Image::DETECTED_R; - } break; - case Image::FORMAT_RG8: { - dc = Image::DETECTED_RG; - } break; - case Image::FORMAT_RGB8: { - dc = Image::DETECTED_RGB; - } break; - case Image::FORMAT_RGBA8: - case Image::FORMAT_RGBA4444: - case Image::FORMAT_RGBA5551: { - dc = Image::DETECTED_RGBA; - } break; - default: { - } - } - } - p_image->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert - if (p_source == Image::COMPRESS_SOURCE_SRGB && (dc == Image::DETECTED_R || dc == Image::DETECTED_RG)) { - //R and RG do not support SRGB - dc = Image::DETECTED_RGB; - } - - if (p_source == Image::COMPRESS_SOURCE_NORMAL) { - //R and RG do not support SRGB - dc = Image::DETECTED_RG; - } - - switch (dc) { - case Image::DETECTED_L: { + switch (p_channels) { + case Image::USED_CHANNELS_L: { target_format = Image::FORMAT_DXT1; squish_comp |= squish::kDxt1; } break; - case Image::DETECTED_LA: { + case Image::USED_CHANNELS_LA: { target_format = Image::FORMAT_DXT5; squish_comp |= squish::kDxt5; } break; - case Image::DETECTED_R: { + case Image::USED_CHANNELS_R: { target_format = Image::FORMAT_RGTC_R; squish_comp |= squish::kBc4; } break; - case Image::DETECTED_RG: { + case Image::USED_CHANNELS_RG: { target_format = Image::FORMAT_RGTC_RG; squish_comp |= squish::kBc5; } break; - case Image::DETECTED_RGB: { + case Image::USED_CHANNELS_RGB: { target_format = Image::FORMAT_DXT1; squish_comp |= squish::kDxt1; } break; - case Image::DETECTED_RGBA: { + case Image::USED_CHANNELS_RGBA: { //TODO, should convert both, then measure which one does a better job target_format = Image::FORMAT_DXT5; diff --git a/modules/squish/image_compress_squish.h b/modules/squish/image_compress_squish.h index b5a209ceb9..19e6d57474 100644 --- a/modules/squish/image_compress_squish.h +++ b/modules/squish/image_compress_squish.h @@ -33,7 +33,7 @@ #include "core/image.h" -void image_compress_squish(Image *p_image, float p_lossy_quality, Image::CompressSource p_source); +void image_compress_squish(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels); void image_decompress_squish(Image *p_image); #endif // IMAGE_COMPRESS_SQUISH_H -- cgit v1.2.3 From 7458a601cecf4d6f22ffd284ebe5ec114f7f0b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 27 Sep 2019 09:05:04 +0200 Subject: basis_universal: Fix py3 build and document license and provenance Also drop unneeded files. Fix build with MinGW. Closes #32384. --- modules/basis_universal/SCsub | 55 +++++++++++++++++++++++-------------------- modules/etc/image_etc.cpp | 7 ++++-- 2 files changed, 35 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub index 5fe994cda9..b933e78de8 100644 --- a/modules/basis_universal/SCsub +++ b/modules/basis_universal/SCsub @@ -1,38 +1,43 @@ #!/usr/bin/env python -import string Import('env') Import('env_modules') env_bu = env_modules.Clone() -env_bu.Append(CPPPATH=["#thirdparty/basis_universal", "#thirdparty/basis_universal/transcoder"]) + +# Thirdparty source files +# Not unbundled so far since not widespread as shared library +thirdparty_dir = "#thirdparty/basis_universal/" +tool_sources = [ + "basisu_astc_decomp.cpp", + "basisu_backend.cpp", + "basisu_basis_file.cpp", + "basisu_comp.cpp", + "basisu_enc.cpp", + "basisu_etc.cpp", + "basisu_frontend.cpp", + "basisu_global_selector_palette_helpers.cpp", + "basisu_gpu_texture.cpp", + "basisu_pvrtc1_4.cpp", + "basisu_resample_filters.cpp", + "basisu_resampler.cpp", + "basisu_ssim.cpp", + "basisu_tool.cpp", + "lodepng.cpp", +] +tool_sources = [thirdparty_dir + file for file in tool_sources] +transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"] + +env_bu.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"]) if env['target'] == "debug": env_bu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) -tool_sources = string.split(""" - #thirdparty/basis_universal/basisu_astc_decomp.cpp - #thirdparty/basis_universal/basisu_backend.cpp - #thirdparty/basis_universal/basisu_basis_file.cpp - #thirdparty/basis_universal/basisu_comp.cpp - #thirdparty/basis_universal/basisu_enc.cpp - #thirdparty/basis_universal/basisu_etc.cpp - #thirdparty/basis_universal/basisu_frontend.cpp - #thirdparty/basis_universal/basisu_global_selector_palette_helpers.cpp - #thirdparty/basis_universal/basisu_gpu_texture.cpp - #thirdparty/basis_universal/basisu_pvrtc1_4.cpp - #thirdparty/basis_universal/basisu_resample_filters.cpp - #thirdparty/basis_universal/basisu_resampler.cpp - #thirdparty/basis_universal/basisu_ssim.cpp - #thirdparty/basis_universal/basisu_tool.cpp - #thirdparty/basis_universal/lodepng.cpp - """) - -transcoder_sources = ["#thirdparty/basis_universal/transcoder/basisu_transcoder.cpp"] - +env_thirdparty = env_bu.Clone() +env_thirdparty.disable_warnings() if env['tools']: - env_bu.add_source_files(env.modules_sources, tool_sources) - -env_bu.add_source_files(env.modules_sources, transcoder_sources) + env_thirdparty.add_source_files(env.modules_sources, tool_sources) +env_thirdparty.add_source_files(env.modules_sources, transcoder_sources) +# Godot source files env_bu.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index 006902462b..24ee8e458e 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -100,17 +100,20 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f return; } + // FIXME: Commented out during Vulkan rebase. + /* if (force_etc1_format) { // If VRAM compression is using ETC, but image has alpha, convert to RGBA4444 or LA8 // This saves space while maintaining the alpha channel - if (detected_channels == Image::DETECTED_RGBA) { + if (detected_channels == Image::USED_CHANNELS_RGBA) { p_img->convert(Image::FORMAT_RGBA4444); return; - } else if (detected_channels == Image::DETECTED_LA) { + } else if (detected_channels == Image::USE_CHANNELS_LA) { p_img->convert(Image::FORMAT_LA8); return; } } + */ uint32_t imgw = p_img->get_width(), imgh = p_img->get_height(); -- cgit v1.2.3 From 65ad12e79ae17c72e04af03371ac32df7e37f229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 27 Sep 2019 09:39:53 +0200 Subject: glslang: Disable warnings and allow unbundling --- modules/glslang/SCsub | 106 +++++++++++++++++++------------------ modules/glslang/register_types.cpp | 15 +++--- 2 files changed, 61 insertions(+), 60 deletions(-) (limited to 'modules') diff --git a/modules/glslang/SCsub b/modules/glslang/SCsub index 7e401ff52c..8c9445436e 100644 --- a/modules/glslang/SCsub +++ b/modules/glslang/SCsub @@ -6,61 +6,63 @@ Import('env_modules') env_glslang = env_modules.Clone() # Thirdparty source files -# Not unbundled so far since not widespread as shared library -thirdparty_dir = "#thirdparty/glslang/" -thirdparty_sources = [ - "glslang/MachineIndependent/RemoveTree.cpp", - "glslang/MachineIndependent/ParseHelper.cpp", - "glslang/MachineIndependent/iomapper.cpp", - "glslang/MachineIndependent/propagateNoContraction.cpp", - "glslang/MachineIndependent/Intermediate.cpp", - "glslang/MachineIndependent/linkValidate.cpp", - "glslang/MachineIndependent/attribute.cpp", - "glslang/MachineIndependent/Scan.cpp", - "glslang/MachineIndependent/Initialize.cpp", - "glslang/MachineIndependent/Constant.cpp", - "glslang/MachineIndependent/reflection.cpp", - "glslang/MachineIndependent/limits.cpp", - "glslang/MachineIndependent/preprocessor/PpScanner.cpp", - "glslang/MachineIndependent/preprocessor/PpTokens.cpp", - "glslang/MachineIndependent/preprocessor/PpAtom.cpp", - "glslang/MachineIndependent/preprocessor/PpContext.cpp", - "glslang/MachineIndependent/preprocessor/Pp.cpp", - "glslang/MachineIndependent/InfoSink.cpp", - "glslang/MachineIndependent/intermOut.cpp", - "glslang/MachineIndependent/SymbolTable.cpp", - "glslang/MachineIndependent/glslang_tab.cpp", - "glslang/MachineIndependent/pch.cpp", - "glslang/MachineIndependent/Versions.cpp", - "glslang/MachineIndependent/ShaderLang.cpp", - "glslang/MachineIndependent/parseConst.cpp", - "glslang/MachineIndependent/PoolAlloc.cpp", - "glslang/MachineIndependent/ParseContextBase.cpp", - "glslang/MachineIndependent/IntermTraverse.cpp", - "glslang/GenericCodeGen/Link.cpp", - "glslang/GenericCodeGen/CodeGen.cpp", - "OGLCompilersDLL/InitializeDll.cpp", - "SPIRV/InReadableOrder.cpp", - "SPIRV/GlslangToSpv.cpp", - "SPIRV/SpvBuilder.cpp", - "SPIRV/SpvTools.cpp", - "SPIRV/disassemble.cpp", - "SPIRV/doc.cpp", - "SPIRV/SPVRemapper.cpp", - "SPIRV/SpvPostProcess.cpp", - "SPIRV/Logger.cpp" -] +if env['builtin_glslang']: + thirdparty_dir = "#thirdparty/glslang/" + thirdparty_sources = [ + "glslang/MachineIndependent/RemoveTree.cpp", + "glslang/MachineIndependent/ParseHelper.cpp", + "glslang/MachineIndependent/iomapper.cpp", + "glslang/MachineIndependent/propagateNoContraction.cpp", + "glslang/MachineIndependent/Intermediate.cpp", + "glslang/MachineIndependent/linkValidate.cpp", + "glslang/MachineIndependent/attribute.cpp", + "glslang/MachineIndependent/Scan.cpp", + "glslang/MachineIndependent/Initialize.cpp", + "glslang/MachineIndependent/Constant.cpp", + "glslang/MachineIndependent/reflection.cpp", + "glslang/MachineIndependent/limits.cpp", + "glslang/MachineIndependent/preprocessor/PpScanner.cpp", + "glslang/MachineIndependent/preprocessor/PpTokens.cpp", + "glslang/MachineIndependent/preprocessor/PpAtom.cpp", + "glslang/MachineIndependent/preprocessor/PpContext.cpp", + "glslang/MachineIndependent/preprocessor/Pp.cpp", + "glslang/MachineIndependent/InfoSink.cpp", + "glslang/MachineIndependent/intermOut.cpp", + "glslang/MachineIndependent/SymbolTable.cpp", + "glslang/MachineIndependent/glslang_tab.cpp", + "glslang/MachineIndependent/pch.cpp", + "glslang/MachineIndependent/Versions.cpp", + "glslang/MachineIndependent/ShaderLang.cpp", + "glslang/MachineIndependent/parseConst.cpp", + "glslang/MachineIndependent/PoolAlloc.cpp", + "glslang/MachineIndependent/ParseContextBase.cpp", + "glslang/MachineIndependent/IntermTraverse.cpp", + "glslang/GenericCodeGen/Link.cpp", + "glslang/GenericCodeGen/CodeGen.cpp", + "OGLCompilersDLL/InitializeDll.cpp", + "SPIRV/InReadableOrder.cpp", + "SPIRV/GlslangToSpv.cpp", + "SPIRV/SpvBuilder.cpp", + "SPIRV/SpvTools.cpp", + "SPIRV/disassemble.cpp", + "SPIRV/doc.cpp", + "SPIRV/SPVRemapper.cpp", + "SPIRV/SpvPostProcess.cpp", + "SPIRV/Logger.cpp" + ] -if (env["platform"]=="windows"): - thirdparty_sources.append("glslang/OSDependent/Windows/ossource.cpp") -else: - thirdparty_sources.append("glslang/OSDependent/Unix/ossource.cpp") + if (env["platform"]=="windows"): + thirdparty_sources.append("glslang/OSDependent/Windows/ossource.cpp") + else: + thirdparty_sources.append("glslang/OSDependent/Unix/ossource.cpp") -thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + env_glslang.Prepend(CPPPATH=[thirdparty_dir]) + + env_thirdparty = env_glslang.Clone() + env_thirdparty.disable_warnings() + env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources) -env_glslang.add_source_files(env.modules_sources, thirdparty_sources) # Godot's own source files env_glslang.add_source_files(env.modules_sources, "*.cpp") -env.Prepend(CPPPATH=[thirdparty_dir]) - diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index b8d8dbc947..a335391d89 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -29,11 +29,12 @@ /*************************************************************************/ #include "register_types.h" + #include "servers/visual/rendering_device.h" -#include "thirdparty/glslang/SPIRV/GlslangToSpv.h" -#include "thirdparty/glslang/glslang/Include/Types.h" -#include "thirdparty/glslang/glslang/Public/ShaderLang.h" +#include +#include +#include static const TBuiltInResource default_builtin_resource = { /*maxLights*/ 32, @@ -145,7 +146,7 @@ static PoolVector _compile_shader_glsl(RenderingDevice::ShaderStage p_s PoolVector ret; - ERR_FAIL_COND_V(p_language==RenderingDevice::SHADER_LANGUAGE_HLSL,ret); + ERR_FAIL_COND_V(p_language == RenderingDevice::SHADER_LANGUAGE_HLSL, ret); EShLanguage stages[RenderingDevice::SHADER_STAGE_MAX] = { EShLangVertex, @@ -174,7 +175,7 @@ static PoolVector _compile_shader_glsl(RenderingDevice::ShaderStage p_s const int DefaultVersion = 100; std::string pre_processed_code; - //preprocess + //preprocess if (!shader.preprocess(&default_builtin_resource, DefaultVersion, ENoProfile, false, false, messages, &pre_processed_code, includer)) { if (r_error) { @@ -216,17 +217,15 @@ static PoolVector _compile_shader_glsl(RenderingDevice::ShaderStage p_s return ret; } - std::vector SpirV; spv::SpvBuildLogger logger; glslang::SpvOptions spvOptions; glslang::GlslangToSpv(*program.getIntermediate(stages[p_stage]), SpirV, &logger, &spvOptions); - ret.resize(SpirV.size() * sizeof(uint32_t)); { PoolVector::Write w = ret.write(); - copymem(w.ptr(),&SpirV[0],SpirV.size()*sizeof(uint32_t)); + copymem(w.ptr(), &SpirV[0], SpirV.size() * sizeof(uint32_t)); } return ret; -- cgit v1.2.3 From d5cf1a872bc71e638dabe38926f2ef1bfbea667e Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 27 Sep 2019 09:05:22 -0300 Subject: Fixes to Basis Universal. --- modules/basis_universal/register_types.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 226567982b..780630c857 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -57,11 +57,12 @@ static PoolVector basis_universal_packer(const Ref &p_image, Ima params.m_max_endpoint_clusters = 512; params.m_max_selector_clusters = 512; params.m_multithreading = true; - params.m_no_hybrid_sel_cb = true; //fixme, default on this causes crashes + //params.m_no_hybrid_sel_cb = true; //fixme, default on this causes crashes //seems fixed? params.m_pSel_codebook = sel_codebook; - params.m_quality_level = 0; + //params.m_quality_level = 0; //params.m_disable_hierarchical_endpoint_codebooks = true; //params.m_no_selector_rdo = true; + params.m_no_auto_global_sel_pal = true; basisu::job_pool jpool(OS::get_singleton()->get_processor_count()); params.m_pJob_pool = &jpool; -- cgit v1.2.3 From 3695c087829843b108bf55296d7dca39a08f135b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 27 Sep 2019 14:43:04 +0200 Subject: basis_universal: Use proper basisu_transcoder.h header, fixes Clang build Also renames bu to basisu to be more explicit and match upstream name. --- modules/basis_universal/SCsub | 10 +- modules/basis_universal/register_types.cpp | 11 +- modules/basis_universal/texture_basisu.cpp | 203 +++++++++++++++++++++++++++++ modules/basis_universal/texture_basisu.h | 47 +++++++ modules/basis_universal/texture_bu.cpp | 203 ----------------------------- modules/basis_universal/texture_bu.h | 47 ------- 6 files changed, 260 insertions(+), 261 deletions(-) create mode 100644 modules/basis_universal/texture_basisu.cpp create mode 100644 modules/basis_universal/texture_basisu.h delete mode 100644 modules/basis_universal/texture_bu.cpp delete mode 100644 modules/basis_universal/texture_bu.h (limited to 'modules') diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub index b933e78de8..3e179762a5 100644 --- a/modules/basis_universal/SCsub +++ b/modules/basis_universal/SCsub @@ -3,7 +3,7 @@ Import('env') Import('env_modules') -env_bu = env_modules.Clone() +env_basisu = env_modules.Clone() # Thirdparty source files # Not unbundled so far since not widespread as shared library @@ -28,16 +28,16 @@ tool_sources = [ tool_sources = [thirdparty_dir + file for file in tool_sources] transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"] -env_bu.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"]) +env_basisu.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"]) if env['target'] == "debug": - env_bu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) + env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) -env_thirdparty = env_bu.Clone() +env_thirdparty = env_basisu.Clone() env_thirdparty.disable_warnings() if env['tools']: env_thirdparty.add_source_files(env.modules_sources, tool_sources) env_thirdparty.add_source_files(env.modules_sources, transcoder_sources) # Godot source files -env_bu.add_source_files(env.modules_sources, "*.cpp") +env_basisu.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 780630c857..04f488de96 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -1,15 +1,14 @@ #include "register_types.h" #include "core/os/os.h" -#include "texture_bu.h" +#include "servers/visual_server.h" +#include "texture_basisu.h" #ifdef TOOLS_ENABLED -#include "thirdparty/basis_universal/basisu_comp.h" +#include #endif -#include "thirdparty/basis_universal/transcoder/basisu.h" - -#include "servers/visual_server.h" +#include enum BasisDecompressFormat { BASIS_DECOMPRESS_RG, @@ -250,7 +249,7 @@ void register_basis_universal_types() { Image::basis_universal_packer = basis_universal_packer; #endif Image::basis_universal_unpacker = basis_universal_unpacker; - // ClassDB::register_class(); + //ClassDB::register_class(); } void unregister_basis_universal_types() { diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp new file mode 100644 index 0000000000..20c4974da5 --- /dev/null +++ b/modules/basis_universal/texture_basisu.cpp @@ -0,0 +1,203 @@ +#include "texture_basisu.h" +#if 0 +#include "core/os/os.h" + +#ifdef TOOLS_ENABLED +#include +#endif + +#include + +void TextureBasisU::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_basisu_data", "data"), &TextureBasisU::set_basisu_data); + ClassDB::bind_method(D_METHOD("get_basisu_data"), &TextureBasisU::get_data); + ClassDB::bind_method(D_METHOD("import"), &TextureBasisU::import); + + ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data"); + +}; + +int TextureBasisU::get_width() const { + + return tex_size.x; +}; + +int TextureBasisU::get_height() const { + + return tex_size.y; +}; + +RID TextureBasisU::get_rid() const { + + return texture; +}; + + +bool TextureBasisU::has_alpha() const { + + return false; +}; + +void TextureBasisU::set_flags(uint32_t p_flags) { + + flags = p_flags; + VisualServer::get_singleton()->texture_set_flags(texture, p_flags); +}; + +uint32_t TextureBasisU::get_flags() const { + + return flags; +}; + + +void TextureBasisU::set_basisu_data(const PoolVector& p_data) { + +#ifdef TOOLS_ENABLED + data = p_data; +#endif + + PoolVector::Read r = p_data.read(); + const void* ptr = r.ptr(); + int size = p_data.size(); + + basist::transcoder_texture_format format; + Image::Format imgfmt; + + if (OS::get_singleton()->has_feature("s3tc")) { + + format = basist::cTFBC3; // get this from renderer + imgfmt = Image::FORMAT_DXT5; + + } else if (OS::get_singleton()->has_feature("etc2")) { + + format = basist::cTFETC2; + imgfmt = Image::FORMAT_ETC2_RGBA8; + }; + + basist::basisu_transcoder tr(NULL); + + ERR_FAIL_COND(!tr.validate_header(ptr, size)); + + basist::basisu_image_info info; + tr.get_image_info(ptr, size, info, 0); + tex_size = Size2(info.m_width, info.m_height); + + int block_size = basist::basis_get_bytes_per_block(format); + PoolVector gpudata; + gpudata.resize(info.m_total_blocks * block_size); + + { + PoolVector::Write w = gpudata.write(); + uint8_t* dst = w.ptr(); + for (int i=0; i img; + img.instance(); + img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); + + VisualServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), VS::TEXTURE_TYPE_2D, flags); + VisualServer::get_singleton()->texture_set_data(texture, img); +}; + +Error TextureBasisU::import(const Ref& p_img) { + +#ifdef TOOLS_ENABLED + + PoolVector budata; + + { + Image::Format format = p_img->get_format(); + if (format != Image::FORMAT_RGB8 && format != Image::FORMAT_RGBA8) { + ERR_FAIL_V(ERR_INVALID_PARAMETER); + return ERR_INVALID_PARAMETER; + }; + + Ref copy = p_img->duplicate(); + if (format == Image::FORMAT_RGB8) + copy->convert(Image::FORMAT_RGBA8); + + basisu::image buimg(p_img->get_width(), p_img->get_height()); + int size = p_img->get_width() * p_img->get_height() * 4; + + PoolVector vec = copy->get_data(); + { + PoolVector::Read r = vec.read(); + memcpy(buimg.get_ptr(), r.ptr(), size); + }; + + basisu::basis_compressor_params params; + params.m_max_endpoint_clusters = 512; + params.m_max_selector_clusters = 512; + params.m_multithreading = true; + + basisu::job_pool jpool(1); + params.m_pJob_pool = &jpool; + + params.m_mip_gen = p_img->get_mipmap_count() > 0; + params.m_source_images.push_back(buimg); + + basisu::basis_compressor c; + c.init(params); + + int buerr = c.process(); + if (buerr != basisu::basis_compressor::cECSuccess) { + ERR_FAIL_V(ERR_INVALID_PARAMETER); + return ERR_INVALID_PARAMETER; + }; + + const basisu::uint8_vec& buvec = c.get_output_basis_file(); + budata.resize(buvec.size()); + + { + PoolVector::Write w = budata.write(); + memcpy(w.ptr(), &buvec[0], budata.size()); + }; + }; + + set_basisu_data(budata); + + return OK; +#else + + return ERR_UNAVAILABLE; +#endif +}; + + +PoolVector TextureBasisU::get_basisu_data() const { + + return data; +}; + +TextureBasisU::TextureBasisU() { + + flags = FLAGS_DEFAULT; + texture = VisualServer::get_singleton()->texture_create(); +}; + + +TextureBasisU::~TextureBasisU() { + + VisualServer::get_singleton()->free(texture); +}; + +#endif diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h new file mode 100644 index 0000000000..20cfd65e3a --- /dev/null +++ b/modules/basis_universal/texture_basisu.h @@ -0,0 +1,47 @@ +#include "scene/resources/texture.h" + +#ifdef TOOLS_ENABLED +#include +#endif + +#include + +#if 0 +class TextureBasisU : public Texture { + + GDCLASS(TextureBasisU, Texture); + RES_BASE_EXTENSION("butex"); + + RID texture; + Size2 tex_size; + + uint32_t flags; + + PoolVector data; + + static void _bind_methods(); + +public: + + virtual int get_width() const; + virtual int get_height() const; + virtual RID get_rid() const; + virtual bool has_alpha() const; + + virtual void set_flags(uint32_t p_flags); + virtual uint32_t get_flags() const; + + + Error import(const Ref &p_img); + + void set_basisu_data(const PoolVector& p_data); + + PoolVector get_basisu_data() const; + String get_img_path() const; + + TextureBasisU(); + ~TextureBasisU(); + +}; + +#endif diff --git a/modules/basis_universal/texture_bu.cpp b/modules/basis_universal/texture_bu.cpp deleted file mode 100644 index 73a945b33d..0000000000 --- a/modules/basis_universal/texture_bu.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include "texture_bu.h" -#if 0 -#include "core/os/os.h" - -#ifdef TOOLS_ENABLED -#include "basisu_comp.h" -#endif - -#include "transcoder/basisu.h" - -void TextureBU::_bind_methods() { - - ClassDB::bind_method(D_METHOD("set_bu_data", "data"), &TextureBU::set_bu_data); - ClassDB::bind_method(D_METHOD("get_bu_data"), &TextureBU::get_data); - ClassDB::bind_method(D_METHOD("import"), &TextureBU::import); - - ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "bu_data"), "set_bu_data", "get_bu_data"); - -}; - -int TextureBU::get_width() const { - - return tex_size.x; -}; - -int TextureBU::get_height() const { - - return tex_size.y; -}; - -RID TextureBU::get_rid() const { - - return texture; -}; - - -bool TextureBU::has_alpha() const { - - return false; -}; - -void TextureBU::set_flags(uint32_t p_flags) { - - flags = p_flags; - VisualServer::get_singleton()->texture_set_flags(texture, p_flags); -}; - -uint32_t TextureBU::get_flags() const { - - return flags; -}; - - -void TextureBU::set_bu_data(const PoolVector& p_data) { - -#ifdef TOOLS_ENABLED - data = p_data; -#endif - - PoolVector::Read r = p_data.read(); - const void* ptr = r.ptr(); - int size = p_data.size(); - - basist::transcoder_texture_format format; - Image::Format imgfmt; - - if (OS::get_singleton()->has_feature("s3tc")) { - - format = basist::cTFBC3; // get this from renderer - imgfmt = Image::FORMAT_DXT5; - - } else if (OS::get_singleton()->has_feature("etc2")) { - - format = basist::cTFETC2; - imgfmt = Image::FORMAT_ETC2_RGBA8; - }; - - basist::basisu_transcoder tr(NULL); - - ERR_FAIL_COND(!tr.validate_header(ptr, size)); - - basist::basisu_image_info info; - tr.get_image_info(ptr, size, info, 0); - tex_size = Size2(info.m_width, info.m_height); - - int block_size = basist::basis_get_bytes_per_block(format); - PoolVector gpudata; - gpudata.resize(info.m_total_blocks * block_size); - - { - PoolVector::Write w = gpudata.write(); - uint8_t* dst = w.ptr(); - for (int i=0; i img; - img.instance(); - img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); - - VisualServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), VS::TEXTURE_TYPE_2D, flags); - VisualServer::get_singleton()->texture_set_data(texture, img); -}; - -Error TextureBU::import(const Ref& p_img) { - -#ifdef TOOLS_ENABLED - - PoolVector budata; - - { - Image::Format format = p_img->get_format(); - if (format != Image::FORMAT_RGB8 && format != Image::FORMAT_RGBA8) { - ERR_FAIL_V(ERR_INVALID_PARAMETER); - return ERR_INVALID_PARAMETER; - }; - - Ref copy = p_img->duplicate(); - if (format == Image::FORMAT_RGB8) - copy->convert(Image::FORMAT_RGBA8); - - basisu::image buimg(p_img->get_width(), p_img->get_height()); - int size = p_img->get_width() * p_img->get_height() * 4; - - PoolVector vec = copy->get_data(); - { - PoolVector::Read r = vec.read(); - memcpy(buimg.get_ptr(), r.ptr(), size); - }; - - basisu::basis_compressor_params params; - params.m_max_endpoint_clusters = 512; - params.m_max_selector_clusters = 512; - params.m_multithreading = true; - - basisu::job_pool jpool(1); - params.m_pJob_pool = &jpool; - - params.m_mip_gen = p_img->get_mipmap_count() > 0; - params.m_source_images.push_back(buimg); - - basisu::basis_compressor c; - c.init(params); - - int buerr = c.process(); - if (buerr != basisu::basis_compressor::cECSuccess) { - ERR_FAIL_V(ERR_INVALID_PARAMETER); - return ERR_INVALID_PARAMETER; - }; - - const basisu::uint8_vec& buvec = c.get_output_basis_file(); - budata.resize(buvec.size()); - - { - PoolVector::Write w = budata.write(); - memcpy(w.ptr(), &buvec[0], budata.size()); - }; - }; - - set_bu_data(budata); - - return OK; -#else - - return ERR_UNAVAILABLE; -#endif -}; - - -PoolVector TextureBU::get_bu_data() const { - - return data; -}; - -TextureBU::TextureBU() { - - flags = FLAGS_DEFAULT; - texture = VisualServer::get_singleton()->texture_create(); -}; - - -TextureBU::~TextureBU() { - - VisualServer::get_singleton()->free(texture); -}; - -#endif diff --git a/modules/basis_universal/texture_bu.h b/modules/basis_universal/texture_bu.h deleted file mode 100644 index 9ec9194a96..0000000000 --- a/modules/basis_universal/texture_bu.h +++ /dev/null @@ -1,47 +0,0 @@ -#include "scene/resources/texture.h" - -#ifdef TOOLS_ENABLED -#include "thirdparty/basis_universal/basisu_comp.h" -#endif - -#include "thirdparty/basis_universal/transcoder/basisu.h" - -#if 0 -class TextureBU : public Texture { - - GDCLASS(TextureBU, Texture); - RES_BASE_EXTENSION("butex"); - - RID texture; - Size2 tex_size; - - uint32_t flags; - - PoolVector data; - - static void _bind_methods(); - -public: - - virtual int get_width() const; - virtual int get_height() const; - virtual RID get_rid() const; - virtual bool has_alpha() const; - - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - - - Error import(const Ref &p_img); - - void set_bu_data(const PoolVector& p_data); - - PoolVector get_bu_data() const; - String get_img_path() const; - - TextureBU(); - ~TextureBU(); - -}; - -#endif -- cgit v1.2.3 From 26318f3bd1b9fa9c7b7708cbef95b4cee56f1718 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sat, 5 Oct 2019 10:30:13 +0300 Subject: Fix Vector3 ambiguities and out of bounds init. --- modules/assimp/editor_scene_importer_assimp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index 7a84a5329d..2e653f4c5d 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -167,8 +167,7 @@ struct EditorSceneImporterAssetImportInterpolate { float t2 = t * t; float t3 = t2 * t; - return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 + - (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); + return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); } T bezier(T start, T control_1, T control_2, T end, float t) { -- cgit v1.2.3 From fff4240bb43a9e5680017087def8b884a23ff657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 5 Nov 2019 12:01:00 +0100 Subject: Fix code formatting issues and VS compilation Also temporarily disable multicheck build so that we get a full build even when there are style issues on Vulkan. Fixes #33356. --- modules/basis_universal/register_types.cpp | 30 ++++++++++++++++++++++++++++++ modules/basis_universal/texture_basisu.cpp | 30 ++++++++++++++++++++++++++++++ modules/basis_universal/texture_basisu.h | 30 ++++++++++++++++++++++++++++++ modules/bullet/rid_bullet.h | 2 +- 4 files changed, 91 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 04f488de96..125b092ad3 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* register_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #include "register_types.h" #include "core/os/os.h" diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp index 20c4974da5..787018cb08 100644 --- a/modules/basis_universal/texture_basisu.cpp +++ b/modules/basis_universal/texture_basisu.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* texture_basisu.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #include "texture_basisu.h" #if 0 #include "core/os/os.h" diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h index 20cfd65e3a..d60f7bf08c 100644 --- a/modules/basis_universal/texture_basisu.h +++ b/modules/basis_universal/texture_basisu.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* texture_basisu.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #include "scene/resources/texture.h" #ifdef TOOLS_ENABLED diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h index d073e209cd..b76641ca54 100644 --- a/modules/bullet/rid_bullet.h +++ b/modules/bullet/rid_bullet.h @@ -39,7 +39,7 @@ class BulletPhysicsServer; -class RIDBullet { +class RIDBullet { RID self; BulletPhysicsServer *physicsServer; -- cgit v1.2.3 From db81928e08cb58d5f67908c6dfcf9433e572ffe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 11 Feb 2020 14:01:43 +0100 Subject: Vulkan: Move thirdparty code out of drivers, style fixes - `vk_enum_string_helper.h` is a generated file taken from the SDK (Vulkan-ValidationLayers). - `vk_mem_alloc.h` is a library from GPUOpen: https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator --- modules/basis_universal/register_types.cpp | 4 ++-- modules/basis_universal/register_types.h | 4 ++-- modules/basis_universal/texture_basisu.cpp | 4 ++-- modules/basis_universal/texture_basisu.h | 4 ++-- modules/gdnavigation/gd_navigation_server.cpp | 2 +- modules/gdnavigation/gd_navigation_server.h | 2 +- modules/gdnavigation/nav_map.cpp | 4 ++-- modules/gdnavigation/nav_map.h | 4 ++-- modules/gdnavigation/nav_region.cpp | 4 ++-- modules/gdnavigation/nav_region.h | 4 ++-- modules/gdnavigation/nav_rid.h | 4 ++-- modules/gdnavigation/nav_utils.h | 4 ++-- modules/gdnavigation/rvo_agent.cpp | 2 +- modules/gdnavigation/rvo_agent.h | 2 +- modules/glslang/register_types.cpp | 4 ++-- modules/glslang/register_types.h | 4 ++-- 16 files changed, 28 insertions(+), 28 deletions(-) (limited to 'modules') diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 125b092ad3..4071f3477a 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/basis_universal/register_types.h b/modules/basis_universal/register_types.h index 3e9acc0896..977374fbfc 100644 --- a/modules/basis_universal/register_types.h +++ b/modules/basis_universal/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp index 787018cb08..3b3805157b 100644 --- a/modules/basis_universal/texture_basisu.cpp +++ b/modules/basis_universal/texture_basisu.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h index d60f7bf08c..8474a63258 100644 --- a/modules/basis_universal/texture_basisu.h +++ b/modules/basis_universal/texture_basisu.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp index 0686230072..ddfb3c10fa 100644 --- a/modules/gdnavigation/gd_navigation_server.cpp +++ b/modules/gdnavigation/gd_navigation_server.cpp @@ -6,7 +6,7 @@ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h index b0fcdaf834..564e9870a0 100644 --- a/modules/gdnavigation/gd_navigation_server.h +++ b/modules/gdnavigation/gd_navigation_server.h @@ -6,7 +6,7 @@ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp index 3d0e02c77d..d1765f4da9 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -1,12 +1,12 @@ /*************************************************************************/ -/* rvo_space.cpp */ +/* nav_map.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/nav_map.h b/modules/gdnavigation/nav_map.h index 636c07e437..128a82580c 100644 --- a/modules/gdnavigation/nav_map.h +++ b/modules/gdnavigation/nav_map.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* rvo_space.h */ +/* nav_map.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp index 03477085ce..d2d9d8b517 100644 --- a/modules/gdnavigation/nav_region.cpp +++ b/modules/gdnavigation/nav_region.cpp @@ -1,12 +1,12 @@ /*************************************************************************/ -/* nav_region.h */ +/* nav_region.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/nav_region.h b/modules/gdnavigation/nav_region.h index c961257163..d99254d1ad 100644 --- a/modules/gdnavigation/nav_region.h +++ b/modules/gdnavigation/nav_region.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* nav_region.cpp */ +/* nav_region.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/nav_rid.h b/modules/gdnavigation/nav_rid.h index b7cee74237..c119ecc5e0 100644 --- a/modules/gdnavigation/nav_rid.h +++ b/modules/gdnavigation/nav_rid.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* rvo_rid.h */ +/* nav_rid.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h index 1048f58294..bdf9eb34a8 100644 --- a/modules/gdnavigation/nav_utils.h +++ b/modules/gdnavigation/nav_utils.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* utils.h */ +/* nav_utils.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/rvo_agent.cpp b/modules/gdnavigation/rvo_agent.cpp index 37a9b31351..eb66eb3a05 100644 --- a/modules/gdnavigation/rvo_agent.cpp +++ b/modules/gdnavigation/rvo_agent.cpp @@ -6,7 +6,7 @@ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/gdnavigation/rvo_agent.h b/modules/gdnavigation/rvo_agent.h index 6a84c1b95c..914cbaa7d9 100644 --- a/modules/gdnavigation/rvo_agent.h +++ b/modules/gdnavigation/rvo_agent.h @@ -6,7 +6,7 @@ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index a335391d89..1e4481a6a0 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/glslang/register_types.h b/modules/glslang/register_types.h index 83bfaf8d93..37a1ef67f2 100644 --- a/modules/glslang/register_types.h +++ b/modules/glslang/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ -- cgit v1.2.3