Hi. I’m trying to make the top right ‘screen’ object’s sprite change to a custom-loaded PNG when interacted with:
It works as expected if I have it update to an existing atlas (that I’ve put together through the editor) but crashes with Assertion failed: i < m_Count, file D:\a\defold\defold\engine\gamesys\build\proto\gamesys/texture_set_ddf.h, line 127
when I apply one created with resource.create_atlas().
function create_atlas()
--image data -> texture -> usable atlas
local data = sys.load_resource(custom_image_attempt_path)
local loaded_image = imageloader.load({data = data, channels = 4, no_vertical_flip = true})
-- create a texture from loaded image data
local new_texture_path = "/my_texture.texturec"
local my_texture_id = resource.create_texture(new_texture_path, loaded_image.header, loaded_image.buffer)
-- create an atlas with one animation and one geometry
-- note that the function doesn't support hashes for the texture,
-- you need to use a string for the texture path here as well
local params = {
texture = my_texture_id,
animations = {
{
id = "1",
flip_horizontal = false,
height = 362,
fps = 30,
flip_vertical = false,
width = 247,
playback = 0,
frame_start = 1,
frame_end = 2
}
},
geometries = {
{
vertices = {
0, 362,
0, 0,
247, 0,
247, 362
},
uvs = {
2, 364,
2, 2,
249, 2,
249, 364
},
indices = {0,1,2,0,2,3}
}
}
--construct atlas from above texture+animations+geometries
local my_atlas_id = resource.create_atlas("/my_atlas.texturesetc", params)
return my_atlas_id
end
function on_interact()
local new_display = create_atlas()
go.set("#sprite", "image", new_display)
sprite.play_flipbook("#sprite", "1")
end
full crash info
Assertion failed: i < m_Count, file D:\a\defold\defold\engine\gamesys\build\proto\gamesys/texture_set_ddf.h, line 127
INFO:CRASH: Successfully wrote Crashdump to file
ERROR:CRASH: CALL STACK:
ERROR:CRASH: 0 0x7FF725B79230 dmCrash::GenerateCallstack D:\a\defold\defold\engine\crash\src\backtrace_win32.cpp:144
ERROR:CRASH: 1 0x7FF725F31D38 raise /tmp/job3587689057160942225/minkernel/crts/ucrt/src/appcrt/misc/signal.cpp:547
ERROR:CRASH: 2 0x7FF725F222BC abort /tmp/job3587689057160942225/minkernel/crts/ucrt/src/appcrt/startup/abort.cpp:71
ERROR:CRASH: 3 0x7FF725F215A0 common_assert_to_stderr<wchar_t> /tmp/job3587689057160942225/minkernel/crts/ucrt/src/appcrt/startup/assert.cpp:186
ERROR:CRASH: 4 0x7FF725F210B8 _wassert /tmp/job3587689057160942225/minkernel/crts/ucrt/src/appcrt/startup/assert.cpp:443
ERROR:CRASH: 5 0x7FF725CF0EA0 dmGameSystem::ResolveAnimationData D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_sprite.cpp:988
ERROR:CRASH: 6 0x7FF725CF3DF0 dmGameSystem::UpdateVertexAndIndexCount D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_sprite.cpp:1729
ERROR:CRASH: 7 0x7FF725CEC700 dmGameSystem::CompSpriteRender D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_sprite.cpp:1870
ERROR:CRASH: 8 0x7FF725BCF1A0 dmGameObject::Render D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2664
ERROR:CRASH: 9 0x7FF725C4DE60 dmEngine::StepFrame D:\a\defold\defold\engine\engine\src\engine.cpp:1663
ERROR:CRASH: 10 0x7FF725C48D80 dmEngineUpdate D:\a\defold\defold\engine\engine\src\engine.cpp:2177
ERROR:CRASH: 11 0x7FF725C4E910 dmEngine::RunLoop D:\a\defold\defold\engine\engine\src\engine_loop.cpp:83
ERROR:CRASH: 12 0x7FF725B66DC0 engine_main D:\a\defold\defold\engine\engine\src\engine_main.cpp:148
ERROR:CRASH: 13 0x7FF725EDAE54 __scrt_common_main_seh D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
ERROR:CRASH: 14 0x7FF81E932560 BaseThreadInitThunk :0
ERROR:CRASH: 15 0x7FF82056AA30 RtlUserThreadStart :0
ERROR:CRASH:
Comparing to .get_atlas() on the sprite-only object in the bottom left, I see a couple of differences:
- my constructed atlas’s texture has become hashed
texture = hash: [/my_texture.texturec]
vs the exampletexture = "/_generated_5429ebb7.texturec"
- UVs 4 and 6 mysteriously change from
= 2
to= 2.0000042915344
Seems like a very similar issue to 63731, so I have the problem function isolated into its own project if anyone still wants a look.