Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] GLTF: Move shared defines into a file and only list used extensions #69320

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/gltf/gltf_accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void GLTFAccessor::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "component_type"), "set_component_type", "get_component_type"); // int
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalized"), "set_normalized", "get_normalized"); // bool
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); // int
ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type"); // GLTFDocument::GLTFType
ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type"); // GLTFType
ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "min"), "set_min", "get_min"); // Vector<real_t>
ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "max"), "set_max", "get_max"); // Vector<real_t>
ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_count"), "set_sparse_count", "get_sparse_count"); // int
Expand Down Expand Up @@ -121,7 +121,7 @@ int GLTFAccessor::get_type() {
}

void GLTFAccessor::set_type(int p_type) {
type = (GLTFDocument::GLTFType)p_type; // TODO: Register enum
type = (GLTFType)p_type; // TODO: Register enum
}

PoolVector<float> GLTFAccessor::get_min() {
Expand Down
5 changes: 2 additions & 3 deletions modules/gltf/gltf_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
#define GLTF_ACCESSOR_H

#include "core/resource.h"

#include "gltf_document.h"
#include "gltf_defines.h"

struct GLTFAccessor : public Resource {
GDCLASS(GLTFAccessor, Resource);
Expand All @@ -45,7 +44,7 @@ struct GLTFAccessor : public Resource {
int component_type = 0;
bool normalized = false;
int count = 0;
GLTFDocument::GLTFType type = GLTFDocument::TYPE_SCALAR;
GLTFType type = GLTFType::TYPE_SCALAR;
PoolVector<float> min;
PoolVector<float> max;
int sparse_count = 0;
Expand Down
3 changes: 1 addition & 2 deletions modules/gltf/gltf_buffer_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
#define GLTF_BUFFER_VIEW_H

#include "core/resource.h"

#include "gltf_document.h"
#include "gltf_defines.h"

class GLTFBufferView : public Resource {
GDCLASS(GLTFBufferView, Resource);
Expand Down
90 changes: 90 additions & 0 deletions modules/gltf/gltf_defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*************************************************************************/
/* gltf_defines.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#ifndef GLTF_DEFINES_H
#define GLTF_DEFINES_H

// This file should only be included by other headers.

// Godot classes used by GLTF headers.
class AnimationPlayer;
class BoneAttachment;
class CSGShape;
class DirectionalLight;
class GridMap;
class Light;
class MultiMeshInstance;
class Skeleton;
class Skin;

// GLTF classes.
struct GLTFAccessor;
class GLTFAnimation;
class GLTFBufferView;
class GLTFCamera;
class GLTFDocument;
class GLTFLight;
class GLTFMesh;
class GLTFNode;
class GLTFSkeleton;
class GLTFSkin;
class GLTFSpecGloss;
class GLTFState;
class GLTFTexture;
class GLTFTextureSampler;
class PackedSceneGLTF;

// GLTF index aliases.
using GLTFAccessorIndex = int;
using GLTFAnimationIndex = int;
using GLTFBufferIndex = int;
using GLTFBufferViewIndex = int;
using GLTFCameraIndex = int;
using GLTFImageIndex = int;
using GLTFLightIndex = int;
using GLTFMaterialIndex = int;
using GLTFMeshIndex = int;
using GLTFNodeIndex = int;
using GLTFSkeletonIndex = int;
using GLTFSkinIndex = int;
using GLTFTextureIndex = int;
using GLTFTextureSamplerIndex = int;

enum GLTFType {
TYPE_SCALAR,
TYPE_VEC2,
TYPE_VEC3,
TYPE_VEC4,
TYPE_MAT2,
TYPE_MAT3,
TYPE_MAT4,
};

#endif // GLTF_DEFINES_H
Loading