Merge branch 'master' into ccache

pull/5686/head
Kim Kulling 2024-08-29 23:55:54 +02:00 committed by GitHub
commit bfe14c232f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 196 additions and 7 deletions

View File

@ -2487,6 +2487,57 @@ const std::map<std::string,std::pair<std::string,char>> transform_types = {
{"GeometricScalingInverse", {"GeometricScalingInverse", 'i'}} {"GeometricScalingInverse", {"GeometricScalingInverse", 'i'}}
}; };
//add metadata to fbx property
void add_meta(FBX::Node& fbx_node, const aiNode* node){
if(node->mMetaData == nullptr) return;
aiMetadata* meta = node->mMetaData;
for (unsigned int i = 0; i < meta->mNumProperties; ++i) {
aiString key = meta->mKeys[i];
aiMetadataEntry* entry = &meta->mValues[i];
switch (entry->mType) {
case AI_BOOL:{
bool val = *static_cast<bool *>(entry->mData);
fbx_node.AddP70bool(key.C_Str(), val);
break;
}
case AI_INT32:{
int32_t val = *static_cast<int32_t *>(entry->mData);
fbx_node.AddP70int(key.C_Str(), val);
break;
}
case AI_UINT64:{
//use string to add uint64
uint64_t val = *static_cast<uint64_t *>(entry->mData);
fbx_node.AddP70string(key.C_Str(), std::to_string(val).c_str());
break;
}
case AI_FLOAT:{
float val = *static_cast<float *>(entry->mData);
fbx_node.AddP70double(key.C_Str(), val);
break;
}
case AI_DOUBLE:{
double val = *static_cast<double *>(entry->mData);
fbx_node.AddP70double(key.C_Str(), val);
break;
}
case AI_AISTRING:{
aiString val = *static_cast<aiString *>(entry->mData);
fbx_node.AddP70string(key.C_Str(), val.C_Str());
break;
}
case AI_AIMETADATA: {
//ignore
break;
}
default:
break;
}
}
}
// write a single model node to the stream // write a single model node to the stream
void FBXExporter::WriteModelNode( void FBXExporter::WriteModelNode(
StreamWriterLE& outstream, StreamWriterLE& outstream,
@ -2554,6 +2605,7 @@ void FBXExporter::WriteModelNode(
} }
} }
} }
add_meta(p, node);
m.AddChild(p); m.AddChild(p);
// not sure what these are for, // not sure what these are for,

View File

@ -940,7 +940,7 @@ namespace glTF2 {
if (outfile->Write(bodyBuffer->GetPointer(), 1, bodyBuffer->byteLength) != bodyBuffer->byteLength) { if (outfile->Write(bodyBuffer->GetPointer(), 1, bodyBuffer->byteLength) != bodyBuffer->byteLength) {
throw DeadlyExportError("Failed to write body data!"); throw DeadlyExportError("Failed to write body data!");
} }
if (curPaddingLength && outfile->Write(&padding, 1, paddingLength) != paddingLength) { if (curPaddingLength && outfile->Write(&padding, 1, curPaddingLength) != curPaddingLength) {
throw DeadlyExportError("Failed to write body data padding!"); throw DeadlyExportError("Failed to write body data padding!");
} }
} }

View File

@ -0,0 +1,33 @@
// Export headers for Swift (iOS)
module libassimp {
header "ColladaMetaData.h"
header "GltfMaterial.h"
header "ObjMaterial.h"
header "anim.h"
header "camera.h"
header "cexport.h"
header "cfileio.h"
header "cimport.h"
header "color4.h"
header "commonMetaData.h"
header "config.h"
header "defs.h"
header "importerdesc.h"
header "light.h"
header "material.h"
header "matrix3x3.h"
header "matrix4x4.h"
header "mesh.h"
header "metadata.h"
header "pbrmaterial.h"
header "postprocess.h"
header "quaternion.h"
header "revision.h"
header "scene.h"
header "texture.h"
header "types.h"
header "vector2.h"
header "vector3.h"
header "version.h"
export *
}

View File

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*- #-*- coding: utf-8 -*-
from ctypes import POINTER, c_void_p, c_uint, c_char, c_float, Structure, c_double, c_ubyte, c_size_t, c_uint32 from ctypes import POINTER, c_void_p, c_uint, c_char, c_float, Structure, c_double, c_ubyte, c_size_t, c_uint32, c_int
class Vector2D(Structure): class Vector2D(Structure):
@ -78,7 +78,7 @@ class String(Structure):
# the number of bytes from the beginning of the string to its end. # the number of bytes from the beginning of the string to its end.
("length", c_uint32), ("length", c_uint32),
# String buffer. Size limit is MAXLEN # String buffer. Size limit is AI_MAXLEN
("data", c_char*AI_MAXLEN), ("data", c_char*AI_MAXLEN),
] ]
@ -1010,6 +1010,54 @@ class Animation(Structure):
] ]
class SkeletonBone(Structure):
"""
See 'mesh.h' for details
"""
_fields_ = [
# The parent bone index, is -1 one if this bone represents the root bone.
("mParent", c_int),
# The number of weights
("mNumnWeights", c_uint),
# The mesh index, which will get influenced by the weight
("mMeshId", POINTER(Mesh)),
# The influence weights of this bone, by vertex index.
("mWeights", POINTER(VertexWeight)),
# Matrix that transforms from bone space to mesh space in bind pose.
#
# This matrix describes the position of the mesh
# in the local space of this bone when the skeleton was bound.
# Thus it can be used directly to determine a desired vertex position,
# given the world-space transform of the bone when animated,
# and the position of the vertex in mesh space.
#
# It is sometimes called an inverse-bind matrix,
# or inverse bind pose matrix
("mOffsetMatrix", Matrix4x4),
# Matrix that transforms the locale bone in bind pose.
("mLocalMatrix", Matrix4x4)
]
class Skeleton(Structure):
"""
See 'mesh.h' for details
"""
_fields_ = [
# Name
("mName", String),
# Number of bones
("mNumBones", c_uint),
# Bones
("mBones", POINTER(POINTER(SkeletonBone)))
]
class ExportDataBlob(Structure): class ExportDataBlob(Structure):
""" """
See 'cexport.h' for details. See 'cexport.h' for details.
@ -1131,6 +1179,15 @@ class Scene(Structure):
# can be used to store format-specific metadata as well. # can be used to store format-specific metadata as well.
("mMetadata", POINTER(Metadata)), ("mMetadata", POINTER(Metadata)),
# The name of the scene itself
("mName", String),
# Number of skeletons
("mNumSkeletons", c_uint),
# Skeletons
("mSkeletons", POINTER(POINTER(Skeleton))),
# Internal data, do not touch # Internal data, do not touch
("mPrivate", POINTER(c_char)), ("mPrivate", POINTER(c_char)),
] ]

View File

@ -1,7 +1,13 @@
# assimp for iOS # assimp for iOS
(deployment target 6.0+, 32/64bit) (deployment target 6.0+, 32/64bit)
Builds assimp libraries for several iOS CPU architectures at once, and outputs a fat binary from the result. ### Requirements
- cmake
- pkg-config
Note: all these packages can be installed with [brew](https://brew.sh)
Builds assimp libraries for several iOS CPU architectures at once, and outputs a fat binary / XCFramework from the result.
Run the **build.sh** script from the ```./port/iOS/``` directory. See **./build.sh --help** for information about command line options. Run the **build.sh** script from the ```./port/iOS/``` directory. See **./build.sh --help** for information about command line options.
@ -15,11 +21,11 @@ shadeds-Mac:iOS arul$ ./build.sh --help
Example: Example:
```bash ```bash
cd ./port/iOS/ cd ./port/iOS/
./build.sh --stdlib=libc++ --archs="armv7 arm64 i386" ./build.sh --stdlib=libc++ --archs="arm64 x86_64" --no-fat --min-version="16.0"
``` ```
Supported architectures/devices: Supported architectures/devices:
### Simulator ### Simulator [CPU Architectures](https://docs.elementscompiler.com/Platforms/Cocoa/CpuArchitectures/)
- i386 - i386
- x86_64 - x86_64

View File

@ -76,7 +76,7 @@ build_arch()
rm CMakeCache.txt rm CMakeCache.txt
CMAKE_CLI_INPUT="-DCMAKE_C_COMPILER=$CMAKE_C_COMPILER -DCMAKE_CXX_COMPILER=$CMAKE_CXX_COMPILER -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS" CMAKE_CLI_INPUT="-DCMAKE_C_COMPILER=$CMAKE_C_COMPILER -DCMAKE_CXX_COMPILER=$CMAKE_CXX_COMPILER -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DASSIMP_BUILD_ZLIB=ON"
echo "[!] Running CMake with -G 'Unix Makefiles' $CMAKE_CLI_INPUT" echo "[!] Running CMake with -G 'Unix Makefiles' $CMAKE_CLI_INPUT"
@ -102,6 +102,7 @@ CPP_STD_LIB=${CPP_STD_LIB_LIST[0]}
CPP_STD=${CPP_STD_LIST[0]} CPP_STD=${CPP_STD_LIST[0]}
DEPLOY_ARCHS=${BUILD_ARCHS_ALL[*]} DEPLOY_ARCHS=${BUILD_ARCHS_ALL[*]}
DEPLOY_FAT=1 DEPLOY_FAT=1
DEPLOY_XCFramework=1
for i in "$@"; do for i in "$@"; do
case $i in case $i in
@ -117,6 +118,11 @@ for i in "$@"; do
DEPLOY_ARCHS=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` DEPLOY_ARCHS=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
echo "[!] Selecting architectures: $DEPLOY_ARCHS" echo "[!] Selecting architectures: $DEPLOY_ARCHS"
;; ;;
--min-version=*)
MIN_IOS_VERSION=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
IOS_SDK_TARGET=$MIN_IOS_VERSION
echo "[!] Selecting minimum iOS version: $MIN_IOS_VERSION"
;;
--debug) --debug)
BUILD_TYPE=Debug BUILD_TYPE=Debug
echo "[!] Selecting build type: Debug" echo "[!] Selecting build type: Debug"
@ -129,11 +135,17 @@ for i in "$@"; do
DEPLOY_FAT=0 DEPLOY_FAT=0
echo "[!] Fat binary will not be created." echo "[!] Fat binary will not be created."
;; ;;
--no-xcframework)
DEPLOY_XCFramework=0
echo "[!] XCFramework will not be created."
;;
-h|--help) -h|--help)
echo " - don't build fat library (--no-fat)." echo " - don't build fat library (--no-fat)."
echo " - don't build XCFramework (--no-xcframework)."
echo " - Include debug information and symbols, no compiler optimizations (--debug)." echo " - Include debug information and symbols, no compiler optimizations (--debug)."
echo " - generate dynamic libraries rather than static ones (--shared-lib)." echo " - generate dynamic libraries rather than static ones (--shared-lib)."
echo " - supported architectures (--archs): $(echo $(join , ${BUILD_ARCHS_ALL[*]}) | sed 's/,/, /g')" echo " - supported architectures (--archs): $(echo $(join , ${BUILD_ARCHS_ALL[*]}) | sed 's/,/, /g')"
echo " - minimum iOS version (--min-version): 16.0"
echo " - supported C++ STD libs (--stdlib): $(echo $(join , ${CPP_STD_LIB_LIST[*]}) | sed 's/,/, /g')" echo " - supported C++ STD libs (--stdlib): $(echo $(join , ${CPP_STD_LIB_LIST[*]}) | sed 's/,/, /g')"
echo " - supported C++ standards (--std): $(echo $(join , ${CPP_STD_LIST[*]}) | sed 's/,/, /g')" echo " - supported C++ standards (--std): $(echo $(join , ${CPP_STD_LIST[*]}) | sed 's/,/, /g')"
exit exit
@ -196,3 +208,32 @@ if [[ "$DEPLOY_FAT" -eq 1 ]]; then
echo "[!] Done! The fat binaries can be found at $BUILD_DIR" echo "[!] Done! The fat binaries can be found at $BUILD_DIR"
fi fi
make_xcframework()
{
LIB_NAME=$1
FRAMEWORK_PATH=$BUILD_DIR/$LIB_NAME.xcframework
ARGS = ""
for ARCH_TARGET in $DEPLOY_ARCHS; do
if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then
ARGS="$ARGS -library $BUILD_DIR/$ARCH_TARGET/$LIB_NAME.dylib -headers ./include "
else
ARGS="$ARGS -library $BUILD_DIR/$ARCH_TARGET/$LIB_NAME.a -headers ./include "
fi
done
xcodebuild -create-xcframework $ARGS -output $FRAMEWORK_PATH
}
if [[ "$DEPLOY_XCFramework" -eq 1 ]]; then
echo '[+] Creating XCFramework ...'
if [[ "$BUILD_TYPE" =~ "Debug" ]]; then
make_xcframework 'libassimpd'
else
make_xcframework 'libassimp'
fi
echo "[!] Done! The XCFramework can be found at $BUILD_DIR"
fi