Skip to content

Commit

Permalink
Initialize class/struct variables with default values in modules/
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Feb 8, 2021
1 parent 57e2822 commit f7209b4
Show file tree
Hide file tree
Showing 100 changed files with 533 additions and 772 deletions.
1 change: 0 additions & 1 deletion modules/basis_universal/texture_basisu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ Vector<uint8_t> TextureBasisU::get_basisu_data() const {
};

TextureBasisU::TextureBasisU() {
flags = FLAGS_DEFAULT;
texture = RenderingServer::get_singleton()->texture_create();
};

Expand Down
2 changes: 1 addition & 1 deletion modules/basis_universal/texture_basisu.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TextureBasisU : public Texture {
RID texture;
Size2 tex_size;

uint32_t flags;
uint32_t flags = FLAGS_DEFAULT;

Vector<uint8_t> data;

Expand Down
30 changes: 15 additions & 15 deletions modules/bmp/image_loader_bmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ class ImageLoaderBMP : public ImageFormatLoader {

struct bmp_header_s {
struct bmp_file_header_s {
uint16_t bmp_signature;
uint32_t bmp_file_size;
uint32_t bmp_file_padding;
uint32_t bmp_file_offset;
uint16_t bmp_signature = 0;
uint32_t bmp_file_size = 0;
uint32_t bmp_file_padding = 0;
uint32_t bmp_file_offset = 0;
} bmp_file_header;

struct bmp_info_header_s {
uint32_t bmp_header_size;
uint32_t bmp_width;
uint32_t bmp_height;
uint16_t bmp_planes;
uint16_t bmp_bit_count;
uint32_t bmp_compression;
uint32_t bmp_size_image;
uint32_t bmp_pixels_per_meter_x;
uint32_t bmp_pixels_per_meter_y;
uint32_t bmp_colors_used;
uint32_t bmp_important_colors;
uint32_t bmp_header_size = 0;
uint32_t bmp_width = 0;
uint32_t bmp_height = 0;
uint16_t bmp_planes = 0;
uint16_t bmp_bit_count = 0;
uint32_t bmp_compression = 0;
uint32_t bmp_size_image = 0;
uint32_t bmp_pixels_per_meter_x = 0;
uint32_t bmp_pixels_per_meter_y = 0;
uint32_t bmp_colors_used = 0;
uint32_t bmp_important_colors = 0;
} bmp_info_header;
};

Expand Down
10 changes: 5 additions & 5 deletions modules/bullet/area_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ class AreaBullet : public RigidCollisionObjectBullet {
private:
// These are used by function callEvent. Instead to create this each call I create if one time.
Variant call_event_res[5];
Variant *call_event_res_ptr[5];
Variant *call_event_res_ptr[5] = {};

btGhostObject *btGhost;
btGhostObject *btGhost = nullptr;
Vector<OverlappingObjectData> overlappingObjects;
bool monitorable = true;

PhysicsServer3D::AreaSpaceOverrideMode spOv_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
bool spOv_gravityPoint = false;
real_t spOv_gravityPointDistanceScale = 0;
real_t spOv_gravityPointAttenuation = 1;
real_t spOv_gravityPointDistanceScale = 0.0;
real_t spOv_gravityPointAttenuation = 1.0;
Vector3 spOv_gravityVec = Vector3(0, -1, 0);
real_t spOv_gravityMag = 10;
real_t spOv_gravityMag = 10.0;
real_t spOv_linearDump = 0.1;
real_t spOv_angularDump = 0.1;
int spOv_priority = 0;
Expand Down
4 changes: 1 addition & 3 deletions modules/bullet/btRayShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@
*/

btRayShape::btRayShape(btScalar length) :
btConvexInternalShape(),
m_shapeAxis(0, 0, 1) {
btConvexInternalShape() {
m_shapeType = CUSTOM_CONVEX_SHAPE_TYPE;
setLength(length);
slipsOnSlope = false;
}

btRayShape::~btRayShape() {
Expand Down
6 changes: 3 additions & 3 deletions modules/bullet/btRayShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
/// Ray shape around z axis
ATTRIBUTE_ALIGNED16(class)
btRayShape : public btConvexInternalShape {
btScalar m_length;
bool slipsOnSlope;
btScalar m_length = 0;
bool slipsOnSlope = false;
/// The default axis is the z
btVector3 m_shapeAxis;
btVector3 m_shapeAxis = btVector3(0, 0, 1);

btTransform m_cacheSupportPoint;
btScalar m_cacheScaledLength;
Expand Down
2 changes: 1 addition & 1 deletion modules/bullet/collision_object_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class CollisionObjectBullet : public RIDBullet {
};

protected:
Type type;
Type type = TYPE_AREA;
ObjectID instance_id;
uint32_t collisionLayer = 0;
uint32_t collisionMask = 0;
Expand Down
2 changes: 1 addition & 1 deletion modules/bullet/godot_motion_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GodotMotionState : public btMotionState {
/// This data is used to store last world position
btTransform bodyCurrentWorldTransform;

RigidBodyBullet *owner;
RigidBodyBullet *owner = nullptr;

public:
GodotMotionState(RigidBodyBullet *p_owner) :
Expand Down
2 changes: 1 addition & 1 deletion modules/bullet/godot_ray_world_algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class GodotRayWorldAlgorithm : public btActivatingCollisionAlgorithm {
const btDiscreteDynamicsWorld *m_world;
btPersistentManifold *m_manifoldPtr;
bool m_ownManifold = false;
bool m_isSwapped;
bool m_isSwapped = false;

public:
GodotRayWorldAlgorithm(const btDiscreteDynamicsWorld *world, btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped);
Expand Down
38 changes: 19 additions & 19 deletions modules/bullet/godot_result_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ struct GodotClosestRayResultCallback : public btCollisionWorld::ClosestRayResult
bool m_pickRay = false;
int m_shapeId = 0;

bool collide_with_bodies;
bool collide_with_areas;
bool collide_with_bodies = false;
bool collide_with_areas = false;

public:
GodotClosestRayResultCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
Expand All @@ -84,8 +84,8 @@ struct GodotClosestRayResultCallback : public btCollisionWorld::ClosestRayResult
// store all colliding object
struct GodotAllConvexResultCallback : public btCollisionWorld::ConvexResultCallback {
public:
PhysicsDirectSpaceState3D::ShapeResult *m_results;
int m_resultMax;
PhysicsDirectSpaceState3D::ShapeResult *m_results = nullptr;
int m_resultMax = 0;
const Set<RID> *m_exclude;
int count = 0;

Expand Down Expand Up @@ -117,8 +117,8 @@ struct GodotClosestConvexResultCallback : public btCollisionWorld::ClosestConvex
const Set<RID> *m_exclude;
int m_shapeId = 0;

bool collide_with_bodies;
bool collide_with_areas;
bool collide_with_bodies = false;
bool collide_with_areas = false;

GodotClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld),
Expand All @@ -134,13 +134,13 @@ struct GodotClosestConvexResultCallback : public btCollisionWorld::ClosestConvex
struct GodotAllContactResultCallback : public btCollisionWorld::ContactResultCallback {
public:
const btCollisionObject *m_self_object;
PhysicsDirectSpaceState3D::ShapeResult *m_results;
int m_resultMax;
PhysicsDirectSpaceState3D::ShapeResult *m_results = nullptr;
int m_resultMax = 0;
const Set<RID> *m_exclude;
int m_count = 0;

bool collide_with_bodies;
bool collide_with_areas;
bool collide_with_bodies = false;
bool collide_with_areas = false;

GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
m_self_object(p_self_object),
Expand All @@ -159,13 +159,13 @@ struct GodotAllContactResultCallback : public btCollisionWorld::ContactResultCal
struct GodotContactPairContactResultCallback : public btCollisionWorld::ContactResultCallback {
public:
const btCollisionObject *m_self_object;
Vector3 *m_results;
int m_resultMax;
Vector3 *m_results = nullptr;
int m_resultMax = 0;
const Set<RID> *m_exclude;
int m_count = 0;

bool collide_with_bodies;
bool collide_with_areas;
bool collide_with_bodies = false;
bool collide_with_areas = false;

GodotContactPairContactResultCallback(btCollisionObject *p_self_object, Vector3 *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
m_self_object(p_self_object),
Expand All @@ -183,14 +183,14 @@ struct GodotContactPairContactResultCallback : public btCollisionWorld::ContactR
struct GodotRestInfoContactResultCallback : public btCollisionWorld::ContactResultCallback {
public:
const btCollisionObject *m_self_object;
PhysicsDirectSpaceState3D::ShapeRestInfo *m_result;
PhysicsDirectSpaceState3D::ShapeRestInfo *m_result = nullptr;
const Set<RID> *m_exclude;
bool m_collided = false;
real_t m_min_distance = 0;
const btCollisionObject *m_rest_info_collision_object;
real_t m_min_distance = 0.0;
const btCollisionObject *m_rest_info_collision_object = nullptr;
btVector3 m_rest_info_bt_point;
bool collide_with_bodies;
bool collide_with_areas;
bool collide_with_bodies = false;
bool collide_with_areas = false;

GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
m_self_object(p_self_object),
Expand Down
2 changes: 1 addition & 1 deletion modules/bullet/rid_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BulletPhysicsServer3D;

class RIDBullet {
RID self;
BulletPhysicsServer3D *physicsServer;
BulletPhysicsServer3D *physicsServer = nullptr;

public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
Expand Down
22 changes: 11 additions & 11 deletions modules/bullet/rigid_body_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class BulletPhysicsDirectBodyState3D : public PhysicsDirectBodyState3D {
}

public:
RigidBodyBullet *body;
real_t deltaTime;
RigidBodyBullet *body = nullptr;
real_t deltaTime = 0.0;

private:
BulletPhysicsDirectBodyState3D() {}
Expand Down Expand Up @@ -144,13 +144,13 @@ class BulletPhysicsDirectBodyState3D : public PhysicsDirectBodyState3D {
class RigidBodyBullet : public RigidCollisionObjectBullet {
public:
struct CollisionData {
RigidBodyBullet *otherObject;
int other_object_shape;
int local_shape;
RigidBodyBullet *otherObject = nullptr;
int other_object_shape = 0;
int local_shape = 0;
Vector3 hitLocalLocation;
Vector3 hitWorldLocation;
Vector3 hitNormal;
real_t appliedImpulse;
real_t appliedImpulse = 0.0;
};

struct ForceIntegrationCallback {
Expand All @@ -169,7 +169,7 @@ class RigidBodyBullet : public RigidCollisionObjectBullet {
};

struct KinematicUtilities {
RigidBodyBullet *owner;
RigidBodyBullet *owner = nullptr;
btScalar safe_margin;
Vector<KinematicShape> shapes;

Expand All @@ -194,10 +194,10 @@ class RigidBodyBullet : public RigidCollisionObjectBullet {
GodotMotionState *godotMotionState;
btRigidBody *btBody;
uint16_t locked_axis = 0;
real_t mass = 1;
real_t gravity_scale = 1;
real_t linearDamp = 0;
real_t angularDamp = 0;
real_t mass = 1.0;
real_t gravity_scale = 1.0;
real_t linearDamp = 0.0;
real_t angularDamp = 0.0;
bool can_sleep = true;
bool omit_forces_integration = false;
bool can_integrate_forces = false;
Expand Down
10 changes: 5 additions & 5 deletions modules/bullet/shape_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ class ConcavePolygonShapeBullet : public ShapeBullet {
class HeightMapShapeBullet : public ShapeBullet {
public:
Vector<real_t> heights;
int width;
int depth;
real_t min_height;
real_t max_height;
int width = 0;
int depth = 0;
real_t min_height = 0.0;
real_t max_height = 0.0;

HeightMapShapeBullet();

Expand All @@ -231,7 +231,7 @@ class HeightMapShapeBullet : public ShapeBullet {

class RayShapeBullet : public ShapeBullet {
public:
real_t length = 1;
real_t length = 1.0;
bool slips_on_slope = false;

RayShapeBullet();
Expand Down
2 changes: 1 addition & 1 deletion modules/bullet/soft_body_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SoftBodyBullet : public CollisionObjectBullet {
private:
btSoftBody *bt_soft_body = nullptr;
Vector<Vector<int>> indices_table;
btSoftBody::Material *mat0; // This is just a copy of pointer managed by btSoftBody
btSoftBody::Material *mat0 = nullptr; // This is just a copy of pointer managed by btSoftBody
bool isScratched = false;

Ref<Mesh> soft_mesh;
Expand Down
12 changes: 6 additions & 6 deletions modules/bullet/space_bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,13 +1092,13 @@ struct RecoverPenetrationBroadPhaseCallback : public btBroadphaseAabbCallback {
btDbvtVolume bounds;

const btCollisionObject *self_collision_object;
uint32_t collision_layer;
uint32_t collision_mask;
uint32_t collision_layer = 0;
uint32_t collision_mask = 0;

struct CompoundLeafCallback : btDbvt::ICollide {
private:
RecoverPenetrationBroadPhaseCallback *parent_callback;
btCollisionObject *collision_object;
RecoverPenetrationBroadPhaseCallback *parent_callback = nullptr;
btCollisionObject *collision_object = nullptr;

public:
CompoundLeafCallback(RecoverPenetrationBroadPhaseCallback *p_parent_callback, btCollisionObject *p_collision_object) :
Expand All @@ -1116,8 +1116,8 @@ struct RecoverPenetrationBroadPhaseCallback : public btBroadphaseAabbCallback {

public:
struct BroadphaseResult {
btCollisionObject *collision_object;
int compound_child_index;
btCollisionObject *collision_object = nullptr;
int compound_child_index = 0;
};

Vector<BroadphaseResult> results;
Expand Down
6 changes: 3 additions & 3 deletions modules/bullet/space_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ class SpaceBullet : public RIDBullet {
btGhostPairCallback *ghostPairCallback = nullptr;
GodotFilterCallback *godotFilterCallback = nullptr;

btGjkEpaPenetrationDepthSolver *gjk_epa_pen_solver;
btVoronoiSimplexSolver *gjk_simplex_solver;
btGjkEpaPenetrationDepthSolver *gjk_epa_pen_solver = nullptr;
btVoronoiSimplexSolver *gjk_simplex_solver = nullptr;

BulletPhysicsDirectSpaceState *direct_access;
Vector3 gravityDirection = Vector3(0, -1, 0);
real_t gravityMagnitude = 10;
real_t gravityMagnitude = 10.0;

real_t linear_damp = 0.0;
real_t angular_damp = 0.0;
Expand Down
Loading

0 comments on commit f7209b4

Please sign in to comment.