mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[c][cpp][flutter][ios] Make attachment in Skin.setAttachment optional
This commit is contained in:
parent
1531c15505
commit
c6495719ca
@ -11,9 +11,9 @@ void spine_skin_dispose(spine_skin self) {
|
||||
delete (Skin *) self;
|
||||
}
|
||||
|
||||
void spine_skin_set_attachment(spine_skin self, size_t slotIndex, const char *name, spine_attachment attachment) {
|
||||
void spine_skin_set_attachment(spine_skin self, size_t slotIndex, const char *name, /*@null*/ spine_attachment attachment) {
|
||||
Skin *_self = (Skin *) self;
|
||||
_self->setAttachment(slotIndex, String(name), *((Attachment *) attachment));
|
||||
_self->setAttachment(slotIndex, String(name), (Attachment *) attachment);
|
||||
}
|
||||
|
||||
/*@null*/ spine_attachment spine_skin_get_attachment(spine_skin self, size_t slotIndex, const char *name) {
|
||||
|
||||
@ -17,7 +17,7 @@ SPINE_C_API void spine_skin_dispose(spine_skin self);
|
||||
* Adds an attachment to the skin for the specified slot index and name. If the
|
||||
* name already exists for the slot, the previous value is replaced.
|
||||
*/
|
||||
SPINE_C_API void spine_skin_set_attachment(spine_skin self, size_t slotIndex, const char *name, spine_attachment attachment);
|
||||
SPINE_C_API void spine_skin_set_attachment(spine_skin self, size_t slotIndex, const char *name, /*@null*/ spine_attachment attachment);
|
||||
/**
|
||||
* Returns the attachment for the specified slot index and name, or NULL.
|
||||
*/
|
||||
|
||||
@ -118,7 +118,7 @@ namespace spine {
|
||||
|
||||
/// Adds an attachment to the skin for the specified slot index and name.
|
||||
/// If the name already exists for the slot, the previous value is replaced.
|
||||
void setAttachment(size_t slotIndex, const String &name, Attachment &attachment);
|
||||
void setAttachment(size_t slotIndex, const String &name, Attachment *attachment);
|
||||
|
||||
/// Returns the attachment for the specified slot index and name, or NULL.
|
||||
Attachment *getAttachment(size_t slotIndex, const String &name);
|
||||
|
||||
@ -560,7 +560,7 @@ Skin *SkeletonBinary::readSkin(DataInput &input, SkeletonData &skeletonData, boo
|
||||
String name(input.readStringRef());
|
||||
Attachment *attachment = readAttachment(input, *skin, slotIndex, name, skeletonData, nonessential);
|
||||
if (attachment)
|
||||
skin->setAttachment(slotIndex, name, *attachment);
|
||||
skin->setAttachment(slotIndex, name, attachment);
|
||||
else {
|
||||
setError("Error reading attachment: ", name.buffer());
|
||||
delete skin;
|
||||
|
||||
@ -537,7 +537,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
for (Json *entry = slotEntry->_child; entry; entry = entry->_next) {
|
||||
Attachment *attachment = readAttachment(entry, skin, slot->getIndex(), entry->_name, skeletonData);
|
||||
if (attachment)
|
||||
skin->setAttachment(slot->getIndex(), entry->_name, *attachment);
|
||||
skin->setAttachment(slot->getIndex(), entry->_name, attachment);
|
||||
else
|
||||
SKELETON_JSON_ERROR(root, "Error reading attachment: ", entry->_name);
|
||||
}
|
||||
|
||||
@ -99,8 +99,8 @@ Skin::~Skin() {
|
||||
}
|
||||
}
|
||||
|
||||
void Skin::setAttachment(size_t slotIndex, const String &name, Attachment &attachment) {
|
||||
_attachments.put(slotIndex, name, &attachment);
|
||||
void Skin::setAttachment(size_t slotIndex, const String &name, Attachment *attachment) {
|
||||
_attachments.put(slotIndex, name, attachment);
|
||||
}
|
||||
|
||||
Attachment *Skin::getAttachment(size_t slotIndex, const String &name) {
|
||||
@ -162,7 +162,7 @@ void Skin::addSkin(Skin &other) {
|
||||
AttachmentMap::Entries entries = other.getAttachments();
|
||||
while (entries.hasNext()) {
|
||||
AttachmentMap::Entry &entry = entries.next();
|
||||
setAttachment(entry._slotIndex, entry._name, *entry._attachment);
|
||||
setAttachment(entry._slotIndex, entry._name, entry._attachment);
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,9 +177,9 @@ void Skin::copySkin(Skin &other) {
|
||||
while (entries.hasNext()) {
|
||||
AttachmentMap::Entry &entry = entries.next();
|
||||
if (entry._attachment->getRTTI().isExactly(MeshAttachment::rtti))
|
||||
setAttachment(entry._slotIndex, entry._name, static_cast<MeshAttachment *>(entry._attachment)->newLinkedMesh());
|
||||
setAttachment(entry._slotIndex, entry._name, &static_cast<MeshAttachment *>(entry._attachment)->newLinkedMesh());
|
||||
else
|
||||
setAttachment(entry._slotIndex, entry._name, entry._attachment->copy());
|
||||
setAttachment(entry._slotIndex, entry._name, &entry._attachment->copy());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -65,9 +65,9 @@ class Skin {
|
||||
|
||||
/// Adds an attachment to the skin for the specified slot index and name. If
|
||||
/// the name already exists for the slot, the previous value is replaced.
|
||||
void setAttachment(int slotIndex, String name, Attachment attachment) {
|
||||
SpineBindings.bindings
|
||||
.spine_skin_set_attachment(_ptr, slotIndex, name.toNativeUtf8().cast<Char>(), attachment.nativePtr.cast());
|
||||
void setAttachment(int slotIndex, String name, Attachment? attachment) {
|
||||
SpineBindings.bindings.spine_skin_set_attachment(
|
||||
_ptr, slotIndex, name.toNativeUtf8().cast<Char>(), attachment?.nativePtr.cast() ?? Pointer.fromAddress(0));
|
||||
}
|
||||
|
||||
/// Returns the attachment for the specified slot index and name, or NULL.
|
||||
|
||||
4
spine-godot/.vscode/settings.json
vendored
4
spine-godot/.vscode/settings.json
vendored
@ -1,7 +1,7 @@
|
||||
{
|
||||
"clangd.enable": true,
|
||||
"cmake.configureOnOpen": false,
|
||||
"clangd.enable": false,
|
||||
"C_Cpp.intelliSenseEngine": "default",
|
||||
"C_Cpp.intelliSenseEngine": "disabled",
|
||||
"C_Cpp.default.browse.path": [
|
||||
"${workspaceFolder}/godot-cpp/gen",
|
||||
"${workspaceFolder}"
|
||||
|
||||
47
spine-godot/build/generate-compile-commands.sh
Executable file
47
spine-godot/build/generate-compile-commands.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
if [ ! -d ../godot ]; then
|
||||
echo "No Godot clone found. Run ./setup.sh <Godot branch or tag> <dev> first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect system
|
||||
cpus=2
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
cpus=$(sysctl -n hw.logicalcpu)
|
||||
arch="arm64"
|
||||
if [ `uname -m` == "x86_64" ]; then
|
||||
arch="x86_64"
|
||||
fi
|
||||
else
|
||||
cpus=$(grep -c ^processor /proc/cpuinfo)
|
||||
fi
|
||||
|
||||
echo "Generating compile_commands.json..."
|
||||
pushd ../godot
|
||||
|
||||
# Generate essential header files first
|
||||
echo "Generating required header files..."
|
||||
scons -j$cpus custom_modules="../spine_godot" opengl3=yes arch=$arch \
|
||||
core/version_generated.gen.h \
|
||||
core/disabled_classes.gen.h \
|
||||
core/object/gdvirtual.gen.inc
|
||||
|
||||
# Now generate compile_commands.json
|
||||
# The 'compiledb' target specifically generates only the compile_commands.json
|
||||
scons compiledb=yes custom_modules="../spine_godot" opengl3=yes arch=$arch compiledb
|
||||
|
||||
# Copy the compile_commands.json to the parent directory for easy IDE access
|
||||
if [ -f compile_commands.json ]; then
|
||||
cp compile_commands.json ..
|
||||
echo "compile_commands.json generated successfully and copied to spine-godot/"
|
||||
else
|
||||
echo "Failed to generate compile_commands.json"
|
||||
fi
|
||||
|
||||
popd
|
||||
popd > /dev/null
|
||||
@ -72,4 +72,31 @@ fi
|
||||
|
||||
popd
|
||||
|
||||
# Generate compile_commands.json for IDE integration
|
||||
echo "Generating compile_commands.json for IDE integration..."
|
||||
pushd ../godot > /dev/null
|
||||
|
||||
# Detect architecture for macOS
|
||||
arch=""
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
if [ `uname -m` == "arm64" ]; then
|
||||
arch="arch=arm64"
|
||||
else
|
||||
arch="arch=x86_64"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Generate compilation database without building
|
||||
scons compiledb=yes custom_modules="../spine_godot" opengl3=yes $arch compiledb
|
||||
|
||||
# Copy to parent directory for easy IDE access
|
||||
if [ -f compile_commands.json ]; then
|
||||
cp compile_commands.json ..
|
||||
echo "compile_commands.json generated successfully and copied to spine-godot/"
|
||||
else
|
||||
echo "Warning: Failed to generate compile_commands.json"
|
||||
fi
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
popd > /dev/null
|
||||
@ -72,8 +72,8 @@ public class Skin: NSObject {
|
||||
|
||||
/// Adds an attachment to the skin for the specified slot index and name. If the name already
|
||||
/// exists for the slot, the previous value is replaced.
|
||||
public func setAttachment(_ slotIndex: Int, _ name: String, _ attachment: Attachment) {
|
||||
spine_skin_set_attachment(_ptr.assumingMemoryBound(to: spine_skin_wrapper.self), slotIndex, name, attachment._ptr.assumingMemoryBound(to: spine_attachment_wrapper.self))
|
||||
public func setAttachment(_ slotIndex: Int, _ name: String, _ attachment: Attachment?) {
|
||||
spine_skin_set_attachment(_ptr.assumingMemoryBound(to: spine_skin_wrapper.self), slotIndex, name, attachment?._ptr.assumingMemoryBound(to: spine_attachment_wrapper.self))
|
||||
}
|
||||
|
||||
/// Returns the attachment for the specified slot index and name, or NULL.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user