mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[ue] Simplify attachment atlas page texture lookup.
This commit is contained in:
parent
119b739a6d
commit
1b6ace271f
@ -93,6 +93,17 @@ void USpineAtlasAsset::BeginDestroy() {
|
||||
Super::BeginDestroy();
|
||||
}
|
||||
|
||||
class UETextureLoader : public TextureLoader {
|
||||
void load(AtlasPage &page, const String &path) {
|
||||
page.texture = (void*)(uintptr_t)page.index;
|
||||
}
|
||||
|
||||
void unload(void *texture) {
|
||||
}
|
||||
};
|
||||
|
||||
UETextureLoader textureLoader;
|
||||
|
||||
Atlas *USpineAtlasAsset::GetAtlas() {
|
||||
if (!atlas) {
|
||||
if (atlas) {
|
||||
@ -102,13 +113,7 @@ Atlas *USpineAtlasAsset::GetAtlas() {
|
||||
std::string t = TCHAR_TO_UTF8(*rawData);
|
||||
|
||||
atlas = new (__FILE__, __LINE__)
|
||||
Atlas(t.c_str(), strlen(t.c_str()), "", nullptr);
|
||||
Vector<AtlasPage *> &pages = atlas->getPages();
|
||||
for (size_t i = 0, n = pages.size(), j = 0; i < n; i++) {
|
||||
AtlasPage *page = pages[i];
|
||||
if (atlasPages.Num() > 0 && atlasPages.Num() > (int32) i)
|
||||
page->texture = atlasPages[j++];
|
||||
}
|
||||
Atlas(t.c_str(), strlen(t.c_str()), "", &textureLoader);
|
||||
}
|
||||
return this->atlas;
|
||||
}
|
||||
|
||||
@ -268,14 +268,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon
|
||||
// to the correct skeleton data yet, we won't find any regions.
|
||||
// ignore regions for which we can't find a material
|
||||
UMaterialInstanceDynamic *material = nullptr;
|
||||
int foundPageIndex = -1;
|
||||
for (int pageIndex = 0; pageIndex < component->Atlas->atlasPages.Num(); pageIndex++) {
|
||||
AtlasPage *page = component->Atlas->GetAtlas()->getPages()[pageIndex];
|
||||
if (attachmentAtlasRegion->page == page) {
|
||||
foundPageIndex = pageIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int foundPageIndex = (int)(intptr_t)attachmentAtlasRegion->rendererObject;
|
||||
if (foundPageIndex == -1) {
|
||||
clipper.clipEnd(*slot);
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user