[cpp] Format fixes.

This commit is contained in:
Mario Zechner 2022-07-25 15:21:38 +02:00
parent 3e1b2b10cb
commit 0860331e99
2 changed files with 149 additions and 149 deletions

View File

@ -549,161 +549,161 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
} }
switch (type) { switch (type) {
case AttachmentType_Region: { case AttachmentType_Region: {
Sequence *sequence = readSequence(Json::getItem(attachmentMap, "sequence")); Sequence *sequence = readSequence(Json::getItem(attachmentMap, "sequence"));
attachment = _attachmentLoader->newRegionAttachment(*skin, attachmentName, attachmentPath, sequence); attachment = _attachmentLoader->newRegionAttachment(*skin, attachmentName, attachmentPath, sequence);
if (!attachment) { if (!attachment) {
delete skeletonData; delete skeletonData;
setError(root, "Error reading attachment: ", skinAttachmentName); setError(root, "Error reading attachment: ", skinAttachmentName);
return NULL; return NULL;
}
RegionAttachment *region = static_cast<RegionAttachment *>(attachment);
region->_path = attachmentPath;
region->_x = Json::getFloat(attachmentMap, "x", 0) * _scale;
region->_y = Json::getFloat(attachmentMap, "y", 0) * _scale;
region->_scaleX = Json::getFloat(attachmentMap, "scaleX", 1);
region->_scaleY = Json::getFloat(attachmentMap, "scaleY", 1);
region->_rotation = Json::getFloat(attachmentMap, "rotation", 0);
region->_width = Json::getFloat(attachmentMap, "width", 32) * _scale;
region->_height = Json::getFloat(attachmentMap, "height", 32) * _scale;
region->_sequence = sequence;
color = Json::getString(attachmentMap, "color", 0);
if (color) toColor(region->getColor(), color, true);
if (region->_region != NULL) region->updateRegion();
_attachmentLoader->configureAttachment(region);
break;
}
case AttachmentType_Mesh:
case AttachmentType_Linkedmesh: {
Sequence *sequence = readSequence(Json::getItem(attachmentMap, "sequence"));
attachment = _attachmentLoader->newMeshAttachment(*skin, attachmentName, attachmentPath, sequence);
if (!attachment) {
delete skeletonData;
setError(root, "Error reading attachment: ", skinAttachmentName);
return NULL;
}
MeshAttachment *mesh = static_cast<MeshAttachment *>(attachment);
mesh->_path = attachmentPath;
color = Json::getString(attachmentMap, "color", 0);
if (color) toColor(mesh->getColor(), color, true);
mesh->_width = Json::getFloat(attachmentMap, "width", 32) * _scale;
mesh->_height = Json::getFloat(attachmentMap, "height", 32) * _scale;
mesh->_sequence = sequence;
entry = Json::getItem(attachmentMap, "parent");
if (!entry) {
int verticesLength;
entry = Json::getItem(attachmentMap, "triangles");
mesh->_triangles.ensureCapacity(entry->_size);
mesh->_triangles.setSize(entry->_size, 0);
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii)
mesh->_triangles[ii] = (unsigned short) entry->_valueInt;
entry = Json::getItem(attachmentMap, "uvs");
verticesLength = entry->_size;
mesh->_regionUVs.ensureCapacity(verticesLength);
mesh->_regionUVs.setSize(verticesLength, 0);
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii)
mesh->_regionUVs[ii] = entry->_valueFloat;
readVertices(attachmentMap, mesh, verticesLength);
if (mesh->_region != NULL) mesh->updateRegion();
mesh->_hullLength = Json::getInt(attachmentMap, "hull", 0);
entry = Json::getItem(attachmentMap, "edges");
if (entry) {
mesh->_edges.ensureCapacity(entry->_size);
mesh->_edges.setSize(entry->_size, 0);
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii)
mesh->_edges[ii] = entry->_valueInt;
} }
_attachmentLoader->configureAttachment(mesh);
} else { RegionAttachment *region = static_cast<RegionAttachment *>(attachment);
bool inheritTimelines = Json::getInt(attachmentMap, "timelines", 1) ? true : false; region->_path = attachmentPath;
LinkedMesh *linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh,
String(Json::getString( region->_x = Json::getFloat(attachmentMap, "x", 0) * _scale;
attachmentMap, region->_y = Json::getFloat(attachmentMap, "y", 0) * _scale;
"skin", 0)), region->_scaleX = Json::getFloat(attachmentMap, "scaleX", 1);
slot->getIndex(), region->_scaleY = Json::getFloat(attachmentMap, "scaleY", 1);
String(entry->_valueString), region->_rotation = Json::getFloat(attachmentMap, "rotation", 0);
inheritTimelines); region->_width = Json::getFloat(attachmentMap, "width", 32) * _scale;
_linkedMeshes.add(linkedMesh); region->_height = Json::getFloat(attachmentMap, "height", 32) * _scale;
region->_sequence = sequence;
color = Json::getString(attachmentMap, "color", 0);
if (color) toColor(region->getColor(), color, true);
if (region->_region != NULL) region->updateRegion();
_attachmentLoader->configureAttachment(region);
break;
} }
break; case AttachmentType_Mesh:
} case AttachmentType_Linkedmesh: {
case AttachmentType_Boundingbox: { Sequence *sequence = readSequence(Json::getItem(attachmentMap, "sequence"));
attachment = _attachmentLoader->newBoundingBoxAttachment(*skin, attachmentName); attachment = _attachmentLoader->newMeshAttachment(*skin, attachmentName, attachmentPath, sequence);
BoundingBoxAttachment *box = static_cast<BoundingBoxAttachment *>(attachment); if (!attachment) {
delete skeletonData;
setError(root, "Error reading attachment: ", skinAttachmentName);
return NULL;
}
int vertexCount = Json::getInt(attachmentMap, "vertexCount", 0) << 1; MeshAttachment *mesh = static_cast<MeshAttachment *>(attachment);
readVertices(attachmentMap, box, vertexCount); mesh->_path = attachmentPath;
color = Json::getString(attachmentMap, "color", NULL);
if (color) toColor(box->getColor(), color, true);
_attachmentLoader->configureAttachment(attachment);
break;
}
case AttachmentType_Path: {
attachment = _attachmentLoader->newPathAttachment(*skin, attachmentName);
PathAttachment *pathAttatchment = static_cast<PathAttachment *>(attachment); color = Json::getString(attachmentMap, "color", 0);
if (color) toColor(mesh->getColor(), color, true);
int vertexCount = 0; mesh->_width = Json::getFloat(attachmentMap, "width", 32) * _scale;
pathAttatchment->_closed = Json::getInt(attachmentMap, "closed", 0) ? true : false; mesh->_height = Json::getFloat(attachmentMap, "height", 32) * _scale;
pathAttatchment->_constantSpeed = Json::getInt(attachmentMap, "constantSpeed", 1) ? true mesh->_sequence = sequence;
: false;
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0);
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
pathAttatchment->_lengths.ensureCapacity(vertexCount / 3); entry = Json::getItem(attachmentMap, "parent");
pathAttatchment->_lengths.setSize(vertexCount / 3, 0); if (!entry) {
int verticesLength;
entry = Json::getItem(attachmentMap, "triangles");
mesh->_triangles.ensureCapacity(entry->_size);
mesh->_triangles.setSize(entry->_size, 0);
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii)
mesh->_triangles[ii] = (unsigned short) entry->_valueInt;
curves = Json::getItem(attachmentMap, "lengths"); entry = Json::getItem(attachmentMap, "uvs");
for (curves = curves->_child, ii = 0; curves; curves = curves->_next, ++ii) verticesLength = entry->_size;
pathAttatchment->_lengths[ii] = curves->_valueFloat * _scale; mesh->_regionUVs.ensureCapacity(verticesLength);
color = Json::getString(attachmentMap, "color", NULL); mesh->_regionUVs.setSize(verticesLength, 0);
if (color) toColor(pathAttatchment->getColor(), color, true); for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii)
_attachmentLoader->configureAttachment(attachment); mesh->_regionUVs[ii] = entry->_valueFloat;
break;
}
case AttachmentType_Point: {
attachment = _attachmentLoader->newPointAttachment(*skin, attachmentName);
PointAttachment *point = static_cast<PointAttachment *>(attachment); readVertices(attachmentMap, mesh, verticesLength);
point->_x = Json::getFloat(attachmentMap, "x", 0) * _scale; if (mesh->_region != NULL) mesh->updateRegion();
point->_y = Json::getFloat(attachmentMap, "y", 0) * _scale;
point->_rotation = Json::getFloat(attachmentMap, "rotation", 0);
color = Json::getString(attachmentMap, "color", NULL);
if (color) toColor(point->getColor(), color, true);
_attachmentLoader->configureAttachment(attachment);
break;
}
case AttachmentType_Clipping: {
attachment = _attachmentLoader->newClippingAttachment(*skin, attachmentName);
ClippingAttachment *clip = static_cast<ClippingAttachment *>(attachment); mesh->_hullLength = Json::getInt(attachmentMap, "hull", 0);
int vertexCount = 0; entry = Json::getItem(attachmentMap, "edges");
const char *end = Json::getString(attachmentMap, "end", 0); if (entry) {
if (end) clip->_endSlot = skeletonData->findSlot(end); mesh->_edges.ensureCapacity(entry->_size);
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0) << 1; mesh->_edges.setSize(entry->_size, 0);
readVertices(attachmentMap, clip, vertexCount); for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii)
color = Json::getString(attachmentMap, "color", NULL); mesh->_edges[ii] = entry->_valueInt;
if (color) toColor(clip->getColor(), color, true); }
_attachmentLoader->configureAttachment(attachment); _attachmentLoader->configureAttachment(mesh);
break; } else {
} bool inheritTimelines = Json::getInt(attachmentMap, "timelines", 1) ? true : false;
LinkedMesh *linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh,
String(Json::getString(
attachmentMap,
"skin", 0)),
slot->getIndex(),
String(entry->_valueString),
inheritTimelines);
_linkedMeshes.add(linkedMesh);
}
break;
}
case AttachmentType_Boundingbox: {
attachment = _attachmentLoader->newBoundingBoxAttachment(*skin, attachmentName);
BoundingBoxAttachment *box = static_cast<BoundingBoxAttachment *>(attachment);
int vertexCount = Json::getInt(attachmentMap, "vertexCount", 0) << 1;
readVertices(attachmentMap, box, vertexCount);
color = Json::getString(attachmentMap, "color", NULL);
if (color) toColor(box->getColor(), color, true);
_attachmentLoader->configureAttachment(attachment);
break;
}
case AttachmentType_Path: {
attachment = _attachmentLoader->newPathAttachment(*skin, attachmentName);
PathAttachment *pathAttatchment = static_cast<PathAttachment *>(attachment);
int vertexCount = 0;
pathAttatchment->_closed = Json::getInt(attachmentMap, "closed", 0) ? true : false;
pathAttatchment->_constantSpeed = Json::getInt(attachmentMap, "constantSpeed", 1) ? true
: false;
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0);
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
pathAttatchment->_lengths.ensureCapacity(vertexCount / 3);
pathAttatchment->_lengths.setSize(vertexCount / 3, 0);
curves = Json::getItem(attachmentMap, "lengths");
for (curves = curves->_child, ii = 0; curves; curves = curves->_next, ++ii)
pathAttatchment->_lengths[ii] = curves->_valueFloat * _scale;
color = Json::getString(attachmentMap, "color", NULL);
if (color) toColor(pathAttatchment->getColor(), color, true);
_attachmentLoader->configureAttachment(attachment);
break;
}
case AttachmentType_Point: {
attachment = _attachmentLoader->newPointAttachment(*skin, attachmentName);
PointAttachment *point = static_cast<PointAttachment *>(attachment);
point->_x = Json::getFloat(attachmentMap, "x", 0) * _scale;
point->_y = Json::getFloat(attachmentMap, "y", 0) * _scale;
point->_rotation = Json::getFloat(attachmentMap, "rotation", 0);
color = Json::getString(attachmentMap, "color", NULL);
if (color) toColor(point->getColor(), color, true);
_attachmentLoader->configureAttachment(attachment);
break;
}
case AttachmentType_Clipping: {
attachment = _attachmentLoader->newClippingAttachment(*skin, attachmentName);
ClippingAttachment *clip = static_cast<ClippingAttachment *>(attachment);
int vertexCount = 0;
const char *end = Json::getString(attachmentMap, "end", 0);
if (end) clip->_endSlot = skeletonData->findSlot(end);
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0) << 1;
readVertices(attachmentMap, clip, vertexCount);
color = Json::getString(attachmentMap, "color", NULL);
if (color) toColor(clip->getColor(), color, true);
_attachmentLoader->configureAttachment(attachment);
break;
}
} }
skin->setAttachment(slot->getIndex(), skinAttachmentName, attachment); skin->setAttachment(slot->getIndex(), skinAttachmentName, attachment);

View File

@ -40,8 +40,8 @@ void SpineAnimationTrack::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_draw_order_threshold"), &SpineAnimationTrack::get_draw_order_threshold); ClassDB::bind_method(D_METHOD("get_draw_order_threshold"), &SpineAnimationTrack::get_draw_order_threshold);
ClassDB::bind_method(D_METHOD("set_mix_blend", "mix_blend"), &SpineAnimationTrack::set_mix_blend); ClassDB::bind_method(D_METHOD("set_mix_blend", "mix_blend"), &SpineAnimationTrack::set_mix_blend);
ClassDB::bind_method(D_METHOD("get_mix_blend"), &SpineAnimationTrack::get_mix_blend); ClassDB::bind_method(D_METHOD("get_mix_blend"), &SpineAnimationTrack::get_mix_blend);
ClassDB::bind_method(D_METHOD("set_blend_tree_mode", "blend_tree_mode_enabled"), &SpineAnimationTrack::set_blend_tree_mode); ClassDB::bind_method(D_METHOD("set_blend_tree_mode", "blend_tree_mode_enabled"), &SpineAnimationTrack::set_blend_tree_mode);
ClassDB::bind_method(D_METHOD("get_blend_tree_mode"), &SpineAnimationTrack::get_blend_tree_mode); ClassDB::bind_method(D_METHOD("get_blend_tree_mode"), &SpineAnimationTrack::get_blend_tree_mode);
ClassDB::bind_method(D_METHOD("set_debug", "debug"), &SpineAnimationTrack::set_debug); ClassDB::bind_method(D_METHOD("set_debug", "debug"), &SpineAnimationTrack::set_debug);
ClassDB::bind_method(D_METHOD("get_debug"), &SpineAnimationTrack::get_debug); ClassDB::bind_method(D_METHOD("get_debug"), &SpineAnimationTrack::get_debug);
@ -60,7 +60,7 @@ void SpineAnimationTrack::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VARIANT_FLOAT, "attachment_threshold"), "set_attachment_threshold", "get_attachment_threshold"); ADD_PROPERTY(PropertyInfo(Variant::VARIANT_FLOAT, "attachment_threshold"), "set_attachment_threshold", "get_attachment_threshold");
ADD_PROPERTY(PropertyInfo(Variant::VARIANT_FLOAT, "draw_order_threshold"), "set_draw_order_threshold", "get_draw_order_threshold"); ADD_PROPERTY(PropertyInfo(Variant::VARIANT_FLOAT, "draw_order_threshold"), "set_draw_order_threshold", "get_draw_order_threshold");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_blend", PROPERTY_HINT_ENUM, "Setup,First,Replace,Add"), "set_mix_blend", "get_mix_blend"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_blend", PROPERTY_HINT_ENUM, "Setup,First,Replace,Add"), "set_mix_blend", "get_mix_blend");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blend_tree_mode"), "set_blend_tree_mode", "get_blend_tree_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blend_tree_mode"), "set_blend_tree_mode", "get_blend_tree_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug"), "set_debug", "get_debug"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug"), "set_debug", "get_debug");
} }
@ -251,7 +251,7 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (blend_tree_mode) { if (blend_tree_mode) {
AnimationTreeEditor* tree_editor = AnimationTreeEditor::get_singleton(); AnimationTreeEditor *tree_editor = AnimationTreeEditor::get_singleton();
// When the animation tree dock is no longer visible, bail. // When the animation tree dock is no longer visible, bail.
if (!tree_editor->is_visible_in_tree()) { if (!tree_editor->is_visible_in_tree()) {
skeleton->setToSetupPose(); skeleton->setToSetupPose();
@ -512,11 +512,11 @@ SpineConstant::MixBlend SpineAnimationTrack::get_mix_blend() {
} }
void SpineAnimationTrack::set_blend_tree_mode(bool _blend_tree_mode) { void SpineAnimationTrack::set_blend_tree_mode(bool _blend_tree_mode) {
blend_tree_mode = _blend_tree_mode; blend_tree_mode = _blend_tree_mode;
} }
bool SpineAnimationTrack::get_blend_tree_mode() { bool SpineAnimationTrack::get_blend_tree_mode() {
return blend_tree_mode; return blend_tree_mode;
} }
void SpineAnimationTrack::set_debug(bool _debug) { void SpineAnimationTrack::set_debug(bool _debug) {