From 30dc2c08c60c9875a6bf0545d2aad00065f02c7c Mon Sep 17 00:00:00 2001 From: Stephen Gowen Date: Thu, 19 Oct 2017 15:36:38 -0400 Subject: [PATCH] Wip --- spine-cpp/spine-cpp/include/spine/HashMap.h | 2 +- spine-cpp/spine-cpp/include/spine/Skeleton.h | 12 ++--- spine-cpp/spine-cpp/include/spine/Skin.h | 10 +++- spine-cpp/spine-cpp/src/spine/Skeleton.cpp | 49 ++++++++++++++------ 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/spine-cpp/spine-cpp/include/spine/HashMap.h b/spine-cpp/spine-cpp/include/spine/HashMap.h index 0eaff11df..d7828c2fc 100755 --- a/spine-cpp/spine-cpp/include/spine/HashMap.h +++ b/spine-cpp/spine-cpp/include/spine/HashMap.h @@ -89,7 +89,7 @@ namespace Spine Entry* _entry; }; - HashMap(size_t capacity) : _capacity(capacity), _hashFunction(), _header(), _trailer() + HashMap(size_t capacity = 65535) : _capacity(capacity), _hashFunction(), _header(), _trailer() { _hashTable = new Entry[capacity]; for (int i = 0; i < _capacity; ++i) diff --git a/spine-cpp/spine-cpp/include/spine/Skeleton.h b/spine-cpp/spine-cpp/include/spine/Skeleton.h index 99022c939..07bfd9e3b 100644 --- a/spine-cpp/spine-cpp/include/spine/Skeleton.h +++ b/spine-cpp/spine-cpp/include/spine/Skeleton.h @@ -120,7 +120,7 @@ namespace Spine /// @param width The width of the AABB /// @param height The height of the AABB. /// @param vertexBuffer Reference to hold a SimpleArray of floats. This method will assign it with new floats as needed. - void getBounds(float& outX, float& outY, float& outWidth, float& outHeight, SimpleArray& vertexBuffer); + void getBounds(float& outX, float& outY, float& outWidth, float& outHeight, SimpleArray& outVertexBuffer); Bone* getRootBone(); @@ -170,15 +170,15 @@ namespace Spine bool _flipX, _flipY; float _x, _y; - void sortIkConstraint(IkConstraint constraint); + void sortIkConstraint(IkConstraint* constraint); - void sortPathConstraint(PathConstraint constraint); + void sortPathConstraint(PathConstraint* constraint); - void sortTransformConstraint(TransformConstraint constraint); + void sortTransformConstraint(TransformConstraint* constraint); - void sortPathConstraintAttachment(Skin skin, int slotIndex, Bone slotBone); + void sortPathConstraintAttachment(Skin* skin, int slotIndex, Bone* slotBone); - void sortPathConstraintAttachment(Attachment attachment, Bone slotBone); + void sortPathConstraintAttachment(Attachment* attachment, Bone* slotBone); void sortBone(Bone bone); diff --git a/spine-cpp/spine-cpp/include/spine/Skin.h b/spine-cpp/spine-cpp/include/spine/Skin.h index 72ee57f50..b0f858f39 100644 --- a/spine-cpp/spine-cpp/include/spine/Skin.h +++ b/spine-cpp/spine-cpp/include/spine/Skin.h @@ -94,8 +94,14 @@ struct HashAttachmentKey { std::size_t operator()(const Spine::Skin::AttachmentKey& val) const { - std::size_t h1 = std::hash{}(val._slotIndex); - std::size_t h2 = std::hash{}(val._name); + std::size_t h1 = static_castgetBones().size()); - bones = new SimpleArray(data.bones.Count); + _bones.reserve(_data.getBones().size()); + foreach (BoneData boneData in data.bones) { Bone bone; @@ -63,8 +74,9 @@ namespace Spine bones.Add(bone); } - slots = new SimpleArray(data.slots.Count); - drawOrder = new SimpleArray(data.slots.Count); + _slots.reserve(_data.getSlots().size()); + _drawOrder.reserve(_data.getSlots().size()); + foreach (SlotData slotData in data.slots) { Bone bone = bones.Items[slotData.boneData.index]; @@ -74,16 +86,23 @@ namespace Spine } ikConstraints = new SimpleArray(data.ikConstraints.Count); + foreach (IkConstraintData ikConstraintData in data.ikConstraints) - ikConstraints.Add(new IkConstraint(ikConstraintData, this)); + { + ikConstraints.Add(new IkConstraint(ikConstraintData, this)); + } transformConstraints = new SimpleArray(data.transformConstraints.Count); foreach (TransformConstraintData transformConstraintData in data.transformConstraints) - transformConstraints.Add(new TransformConstraint(transformConstraintData, this)); + { + transformConstraints.Add(new TransformConstraint(transformConstraintData, this)); + } pathConstraints = new SimpleArray (data.pathConstraints.Count); foreach (PathConstraintData pathConstraintData in data.pathConstraints) - pathConstraints.Add(new PathConstraint(pathConstraintData, this)); + { + pathConstraints.Add(new PathConstraint(pathConstraintData, this)); + } updateCache(); updateWorldTransform(); @@ -443,7 +462,7 @@ namespace Spine _time += delta; } - void Skeleton::getBounds(float& outX, float& outY, float& outWidth, float& outHeight, SimpleArray& vertexBuffer) + void Skeleton::getBounds(float& outX, float& outY, float& outWidth, float& outHeight, SimpleArray& outVertexBuffer) { float minX = std::numeric_limits::max(); float minY = std::numeric_limits::max(); @@ -643,7 +662,7 @@ namespace Spine _flipY = inValue; } - void Skeleton::sortIkConstraint(IkConstraint constraint) + void Skeleton::sortIkConstraint(IkConstraint* constraint) { Bone target = constraint.target; sortBone(target); @@ -667,7 +686,7 @@ namespace Spine constrained.Items[constrained.Count - 1].sorted = true; } - void Skeleton::sortPathConstraint(PathConstraint constraint) + void Skeleton::sortPathConstraint(PathConstraint* constraint) { Slot slot = constraint.target; int slotIndex = slot.data.index; @@ -714,7 +733,7 @@ namespace Spine } } - void Skeleton::sortTransformConstraint(TransformConstraint constraint) + void Skeleton::sortTransformConstraint(TransformConstraint* constraint) { sortBone(constraint.target); @@ -752,7 +771,7 @@ namespace Spine } } - void Skeleton::sortPathConstraintAttachment(Skin skin, int slotIndex, Bone slotBone) + void Skeleton::sortPathConstraintAttachment(Skin* skin, int slotIndex, Bone* slotBone) { foreach (var entry in skin.Attachments) { @@ -763,7 +782,7 @@ namespace Spine } } - void Skeleton::sortPathConstraintAttachment(Attachment attachment, Bone slotBone) + void Skeleton::sortPathConstraintAttachment(Attachment* attachment, Bone* slotBone) { if (!(attachment is PathAttachment)) { @@ -790,7 +809,7 @@ namespace Spine } } - void Skeleton::sortBone(Bone bone) + void Skeleton::sortBone(Bone* bone) { if (bone.sorted) {