Use const ref parameters in the GLTF module

This commit is contained in:
Aaron Franke 2025-09-26 15:22:45 -07:00
parent 0b5ad6c73c
commit dcb6431c01
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
37 changed files with 197 additions and 197 deletions

View file

@ -165,19 +165,19 @@ void GLTFAccessor::set_type(int p_accessor_type) {
}
Vector<double> GLTFAccessor::get_min() const {
return min;
return Vector<double>(min);
}
void GLTFAccessor::set_min(Vector<double> p_min) {
min = p_min;
void GLTFAccessor::set_min(const Vector<double> &p_min) {
min = Vector<double>(p_min);
}
Vector<double> GLTFAccessor::get_max() const {
return max;
return Vector<double>(max);
}
void GLTFAccessor::set_max(Vector<double> p_max) {
max = p_max;
void GLTFAccessor::set_max(const Vector<double> &p_max) {
max = Vector<double>(p_max);
}
int64_t GLTFAccessor::get_sparse_count() const {

View file

@ -146,10 +146,10 @@ public:
void set_type(int p_accessor_type);
Vector<double> get_min() const;
void set_min(Vector<double> p_min);
void set_min(const Vector<double> &p_min);
Vector<double> get_max() const;
void set_max(Vector<double> p_max);
void set_max(const Vector<double> &p_max);
int64_t get_sparse_count() const;
void set_sparse_count(int64_t p_sparse_count);

View file

@ -74,7 +74,7 @@ String GLTFAnimation::get_original_name() {
return original_name;
}
void GLTFAnimation::set_original_name(String p_name) {
void GLTFAnimation::set_original_name(const String &p_name) {
original_name = p_name;
}

View file

@ -71,7 +71,7 @@ public:
static Animation::InterpolationType gltf_to_godot_interpolation(Interpolation p_gltf_interpolation);
String get_original_name();
void set_original_name(String p_name);
void set_original_name(const String &p_name);
bool get_loop() const;
void set_loop(bool p_val);

View file

@ -99,7 +99,7 @@ Camera3D *GLTFCamera::to_node() const {
return camera;
}
Ref<GLTFCamera> GLTFCamera::from_dictionary(const Dictionary p_dictionary) {
Ref<GLTFCamera> GLTFCamera::from_dictionary(const Dictionary &p_dictionary) {
ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), Ref<GLTFCamera>(), "Failed to parse glTF camera, missing required field 'type'.");
Ref<GLTFCamera> camera;
camera.instantiate();

View file

@ -70,6 +70,6 @@ public:
static Ref<GLTFCamera> from_node(const Camera3D *p_camera);
Camera3D *to_node() const;
static Ref<GLTFCamera> from_dictionary(const Dictionary p_dictionary);
static Ref<GLTFCamera> from_dictionary(const Dictionary &p_dictionary);
virtual Dictionary to_dictionary() const;
};

View file

@ -54,7 +54,7 @@ String GLTFMesh::get_original_name() {
return original_name;
}
void GLTFMesh::set_original_name(String p_name) {
void GLTFMesh::set_original_name(const String &p_name) {
original_name = p_name;
}
@ -62,24 +62,24 @@ Ref<ImporterMesh> GLTFMesh::get_mesh() {
return mesh;
}
void GLTFMesh::set_mesh(Ref<ImporterMesh> p_mesh) {
void GLTFMesh::set_mesh(const Ref<ImporterMesh> &p_mesh) {
mesh = p_mesh;
}
TypedArray<Material> GLTFMesh::get_instance_materials() {
return instance_materials;
return TypedArray<Material>(instance_materials);
}
void GLTFMesh::set_instance_materials(TypedArray<Material> p_instance_materials) {
instance_materials = p_instance_materials;
void GLTFMesh::set_instance_materials(const TypedArray<Material> &p_instance_materials) {
instance_materials = TypedArray<Material>(p_instance_materials);
}
Vector<float> GLTFMesh::get_blend_weights() {
return blend_weights;
return Vector<float>(blend_weights);
}
void GLTFMesh::set_blend_weights(Vector<float> p_blend_weights) {
blend_weights = p_blend_weights;
void GLTFMesh::set_blend_weights(const Vector<float> &p_blend_weights) {
blend_weights = Vector<float>(p_blend_weights);
}
Variant GLTFMesh::get_additional_data(const StringName &p_extension_name) {

View file

@ -49,13 +49,13 @@ protected:
public:
String get_original_name();
void set_original_name(String p_name);
void set_original_name(const String &p_name);
Ref<ImporterMesh> get_mesh();
void set_mesh(Ref<ImporterMesh> p_mesh);
void set_mesh(const Ref<ImporterMesh> &p_mesh);
Vector<float> get_blend_weights();
void set_blend_weights(Vector<float> p_blend_weights);
void set_blend_weights(const Vector<float> &p_blend_weights);
TypedArray<Material> get_instance_materials();
void set_instance_materials(TypedArray<Material> p_instance_materials);
void set_instance_materials(const TypedArray<Material> &p_instance_materials);
Variant get_additional_data(const StringName &p_extension_name);
void set_additional_data(const StringName &p_extension_name, Variant p_additional_data);
};

View file

@ -85,7 +85,7 @@ void GLTFNode::_bind_methods() {
String GLTFNode::get_original_name() {
return original_name;
}
void GLTFNode::set_original_name(String p_name) {
void GLTFNode::set_original_name(const String &p_name) {
original_name = p_name;
}
@ -109,7 +109,7 @@ Transform3D GLTFNode::get_xform() {
return transform;
}
void GLTFNode::set_xform(Transform3D p_xform) {
void GLTFNode::set_xform(const Transform3D &p_xform) {
transform = p_xform;
}
@ -149,7 +149,7 @@ Vector3 GLTFNode::get_position() {
return transform.origin;
}
void GLTFNode::set_position(Vector3 p_position) {
void GLTFNode::set_position(const Vector3 &p_position) {
transform.origin = p_position;
}
@ -157,7 +157,7 @@ Quaternion GLTFNode::get_rotation() {
return transform.basis.get_rotation_quaternion();
}
void GLTFNode::set_rotation(Quaternion p_rotation) {
void GLTFNode::set_rotation(const Quaternion &p_rotation) {
transform.basis.set_quaternion_scale(p_rotation, transform.basis.get_scale());
}
@ -165,16 +165,16 @@ Vector3 GLTFNode::get_scale() {
return transform.basis.get_scale();
}
void GLTFNode::set_scale(Vector3 p_scale) {
void GLTFNode::set_scale(const Vector3 &p_scale) {
transform.basis = transform.basis.orthonormalized() * Basis::from_scale(p_scale);
}
Vector<int> GLTFNode::get_children() {
return children;
return Vector<int>(children);
}
void GLTFNode::set_children(Vector<int> p_children) {
children = p_children;
void GLTFNode::set_children(const Vector<int> &p_children) {
children = Vector<int>(p_children);
}
void GLTFNode::append_child_index(int p_child_index) {

View file

@ -60,7 +60,7 @@ protected:
public:
String get_original_name();
void set_original_name(String p_name);
void set_original_name(const String &p_name);
GLTFNodeIndex get_parent();
void set_parent(GLTFNodeIndex p_parent);
@ -69,10 +69,10 @@ public:
void set_height(int p_height);
Transform3D get_xform();
void set_xform(Transform3D p_xform);
void set_xform(const Transform3D &p_xform);
Transform3D get_rest_xform();
void set_rest_xform(Transform3D p_rest_xform);
void set_rest_xform(const Transform3D &p_rest_xform);
GLTFMeshIndex get_mesh();
void set_mesh(GLTFMeshIndex p_mesh);
@ -87,16 +87,16 @@ public:
void set_skeleton(GLTFSkeletonIndex p_skeleton);
Vector3 get_position();
void set_position(Vector3 p_position);
void set_position(const Vector3 &p_position);
Quaternion get_rotation();
void set_rotation(Quaternion p_rotation);
void set_rotation(const Quaternion &p_rotation);
Vector3 get_scale();
void set_scale(Vector3 p_scale);
void set_scale(const Vector3 &p_scale);
Vector<int> get_children();
void set_children(Vector<int> p_children);
void set_children(const Vector<int> &p_children);
void append_child_index(int p_child_index);
GLTFLightIndex get_light();

View file

@ -107,7 +107,7 @@ Ref<Expression> GLTFObjectModelProperty::get_gltf_to_godot_expression() const {
return gltf_to_godot_expr;
}
void GLTFObjectModelProperty::set_gltf_to_godot_expression(Ref<Expression> p_gltf_to_godot_expr) {
void GLTFObjectModelProperty::set_gltf_to_godot_expression(const Ref<Expression> &p_gltf_to_godot_expr) {
gltf_to_godot_expr = p_gltf_to_godot_expr;
}
@ -115,20 +115,20 @@ Ref<Expression> GLTFObjectModelProperty::get_godot_to_gltf_expression() const {
return godot_to_gltf_expr;
}
void GLTFObjectModelProperty::set_godot_to_gltf_expression(Ref<Expression> p_godot_to_gltf_expr) {
void GLTFObjectModelProperty::set_godot_to_gltf_expression(const Ref<Expression> &p_godot_to_gltf_expr) {
godot_to_gltf_expr = p_godot_to_gltf_expr;
}
TypedArray<NodePath> GLTFObjectModelProperty::get_node_paths() const {
return node_paths;
return TypedArray<NodePath>(node_paths);
}
bool GLTFObjectModelProperty::has_node_paths() const {
return !node_paths.is_empty();
}
void GLTFObjectModelProperty::set_node_paths(TypedArray<NodePath> p_node_paths) {
node_paths = p_node_paths;
void GLTFObjectModelProperty::set_node_paths(const TypedArray<NodePath> &p_node_paths) {
node_paths = TypedArray<NodePath>(p_node_paths);
}
GLTFObjectModelProperty::GLTFObjectModelType GLTFObjectModelProperty::get_object_model_type() const {

View file

@ -73,14 +73,14 @@ public:
GLTFAccessor::GLTFAccessorType get_accessor_type() const;
Ref<Expression> get_gltf_to_godot_expression() const;
void set_gltf_to_godot_expression(Ref<Expression> p_gltf_to_godot_expr);
void set_gltf_to_godot_expression(const Ref<Expression> &p_gltf_to_godot_expr);
Ref<Expression> get_godot_to_gltf_expression() const;
void set_godot_to_gltf_expression(Ref<Expression> p_godot_to_gltf_expr);
void set_godot_to_gltf_expression(const Ref<Expression> &p_godot_to_gltf_expr);
TypedArray<NodePath> get_node_paths() const;
bool has_node_paths() const;
void set_node_paths(TypedArray<NodePath> p_node_paths);
void set_node_paths(const TypedArray<NodePath> &p_node_paths);
GLTFObjectModelType get_object_model_type() const;
void set_object_model_type(GLTFObjectModelType p_type);

View file

@ -54,19 +54,19 @@ void GLTFSkeleton::_bind_methods() {
}
Vector<GLTFNodeIndex> GLTFSkeleton::get_joints() {
return joints;
return Vector<GLTFNodeIndex>(joints);
}
void GLTFSkeleton::set_joints(Vector<GLTFNodeIndex> p_joints) {
joints = p_joints;
void GLTFSkeleton::set_joints(const Vector<GLTFNodeIndex> &p_joints) {
joints = Vector<GLTFNodeIndex>(p_joints);
}
Vector<GLTFNodeIndex> GLTFSkeleton::get_roots() {
return roots;
return Vector<GLTFNodeIndex>(roots);
}
void GLTFSkeleton::set_roots(Vector<GLTFNodeIndex> p_roots) {
roots = p_roots;
void GLTFSkeleton::set_roots(const Vector<GLTFNodeIndex> &p_roots) {
roots = Vector<GLTFNodeIndex>(p_roots);
}
Skeleton3D *GLTFSkeleton::get_godot_skeleton() {
@ -77,7 +77,7 @@ TypedArray<String> GLTFSkeleton::get_unique_names() {
return GLTFTemplateConvert::to_array(unique_names);
}
void GLTFSkeleton::set_unique_names(TypedArray<String> p_unique_names) {
void GLTFSkeleton::set_unique_names(const TypedArray<String> &p_unique_names) {
GLTFTemplateConvert::set_from_array(unique_names, p_unique_names);
}
@ -85,7 +85,7 @@ Dictionary GLTFSkeleton::get_godot_bone_node() {
return GLTFTemplateConvert::to_dictionary(godot_bone_node);
}
void GLTFSkeleton::set_godot_bone_node(Dictionary p_indict) {
void GLTFSkeleton::set_godot_bone_node(const Dictionary &p_indict) {
GLTFTemplateConvert::set_from_dictionary(godot_bone_node, p_indict);
}

View file

@ -65,10 +65,10 @@ protected:
public:
Vector<GLTFNodeIndex> get_joints();
void set_joints(Vector<GLTFNodeIndex> p_joints);
void set_joints(const Vector<GLTFNodeIndex> &p_joints);
Vector<GLTFNodeIndex> get_roots();
void set_roots(Vector<GLTFNodeIndex> p_roots);
void set_roots(const Vector<GLTFNodeIndex> &p_roots);
Skeleton3D *get_godot_skeleton();
@ -80,7 +80,7 @@ public:
// }
TypedArray<String> get_unique_names();
void set_unique_names(TypedArray<String> p_unique_names);
void set_unique_names(const TypedArray<String> &p_unique_names);
//RBMap<int32_t, GLTFNodeIndex> get_godot_bone_node() {
// return godot_bone_node;
@ -89,7 +89,7 @@ public:
// godot_bone_node = p_godot_bone_node;
//}
Dictionary get_godot_bone_node();
void set_godot_bone_node(Dictionary p_indict);
void set_godot_bone_node(const Dictionary &p_indict);
//Dictionary get_godot_bone_node() {
// return VariantConversion::to_dict(godot_bone_node);

View file

@ -81,15 +81,15 @@ Vector<GLTFNodeIndex> GLTFSkin::get_joints_original() {
return joints_original;
}
void GLTFSkin::set_joints_original(Vector<GLTFNodeIndex> p_joints_original) {
joints_original = p_joints_original;
void GLTFSkin::set_joints_original(const Vector<GLTFNodeIndex> &p_joints_original) {
joints_original = Vector<GLTFNodeIndex>(p_joints_original);
}
TypedArray<Transform3D> GLTFSkin::get_inverse_binds() {
return GLTFTemplateConvert::to_array(inverse_binds);
}
void GLTFSkin::set_inverse_binds(TypedArray<Transform3D> p_inverse_binds) {
void GLTFSkin::set_inverse_binds(const TypedArray<Transform3D> &p_inverse_binds) {
GLTFTemplateConvert::set_from_array(inverse_binds, p_inverse_binds);
}
@ -97,24 +97,24 @@ Vector<GLTFNodeIndex> GLTFSkin::get_joints() {
return joints;
}
void GLTFSkin::set_joints(Vector<GLTFNodeIndex> p_joints) {
joints = p_joints;
void GLTFSkin::set_joints(const Vector<GLTFNodeIndex> &p_joints) {
joints = Vector<GLTFNodeIndex>(p_joints);
}
Vector<GLTFNodeIndex> GLTFSkin::get_non_joints() {
return non_joints;
}
void GLTFSkin::set_non_joints(Vector<GLTFNodeIndex> p_non_joints) {
non_joints = p_non_joints;
void GLTFSkin::set_non_joints(const Vector<GLTFNodeIndex> &p_non_joints) {
non_joints = Vector<GLTFNodeIndex>(p_non_joints);
}
Vector<GLTFNodeIndex> GLTFSkin::get_roots() {
return roots;
}
void GLTFSkin::set_roots(Vector<GLTFNodeIndex> p_roots) {
roots = p_roots;
void GLTFSkin::set_roots(const Vector<GLTFNodeIndex> &p_roots) {
roots = Vector<GLTFNodeIndex>(p_roots);
}
int GLTFSkin::get_skeleton() {
@ -129,7 +129,7 @@ Dictionary GLTFSkin::get_joint_i_to_bone_i() {
return GLTFTemplateConvert::to_dictionary(joint_i_to_bone_i);
}
void GLTFSkin::set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i) {
void GLTFSkin::set_joint_i_to_bone_i(const Dictionary &p_joint_i_to_bone_i) {
GLTFTemplateConvert::set_from_dictionary(joint_i_to_bone_i, p_joint_i_to_bone_i);
}
@ -143,7 +143,7 @@ Dictionary GLTFSkin::get_joint_i_to_name() {
return ret;
}
void GLTFSkin::set_joint_i_to_name(Dictionary p_joint_i_to_name) {
void GLTFSkin::set_joint_i_to_name(const Dictionary &p_joint_i_to_name) {
joint_i_to_name = HashMap<int, StringName>();
for (const KeyValue<Variant, Variant> &kv : p_joint_i_to_name) {
joint_i_to_name[kv.key] = kv.value;
@ -154,7 +154,7 @@ Ref<Skin> GLTFSkin::get_godot_skin() {
return godot_skin;
}
void GLTFSkin::set_godot_skin(Ref<Skin> p_godot_skin) {
void GLTFSkin::set_godot_skin(const Ref<Skin> &p_godot_skin) {
godot_skin = p_godot_skin;
}

View file

@ -86,31 +86,31 @@ public:
void set_skin_root(GLTFNodeIndex p_skin_root);
Vector<GLTFNodeIndex> get_joints_original();
void set_joints_original(Vector<GLTFNodeIndex> p_joints_original);
void set_joints_original(const Vector<GLTFNodeIndex> &p_joints_original);
TypedArray<Transform3D> get_inverse_binds();
void set_inverse_binds(TypedArray<Transform3D> p_inverse_binds);
void set_inverse_binds(const TypedArray<Transform3D> &p_inverse_binds);
Vector<GLTFNodeIndex> get_joints();
void set_joints(Vector<GLTFNodeIndex> p_joints);
void set_joints(const Vector<GLTFNodeIndex> &p_joints);
Vector<GLTFNodeIndex> get_non_joints();
void set_non_joints(Vector<GLTFNodeIndex> p_non_joints);
void set_non_joints(const Vector<GLTFNodeIndex> &p_non_joints);
Vector<GLTFNodeIndex> get_roots();
void set_roots(Vector<GLTFNodeIndex> p_roots);
void set_roots(const Vector<GLTFNodeIndex> &p_roots);
int get_skeleton();
void set_skeleton(int p_skeleton);
Dictionary get_joint_i_to_bone_i();
void set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i);
void set_joint_i_to_bone_i(const Dictionary &p_joint_i_to_bone_i);
Dictionary get_joint_i_to_name();
void set_joint_i_to_name(Dictionary p_joint_i_to_name);
void set_joint_i_to_name(const Dictionary &p_joint_i_to_name);
Ref<Skin> get_godot_skin();
void set_godot_skin(Ref<Skin> p_godot_skin);
void set_godot_skin(const Ref<Skin> &p_godot_skin);
Dictionary to_dictionary();
Error from_dictionary(const Dictionary &dict);