MCPcopy Create free account
hub / github.com/defold/defold / CreateNames

Function CreateNames

engine/modelc/src/modelimporter_gltf.cpp:1955–2017  ·  view source on GitHub ↗

As we use names for comparisons and lookups, it's awkward to support items with NULL names

Source from the content-addressed store, hash-verified

1953
1954// As we use names for comparisons and lookups, it's awkward to support items with NULL names
1955static void CreateNames(cgltf_options* options, cgltf_data* data)
1956{
1957#define CREATE_NAME(NODE, PREFIX, INDEX) \
1958 if (!(NODE)->name) \
1959 { \
1960 (NODE)->name = CreateCgltfName(PREFIX, INDEX); \
1961 }
1962
1963 for (int i = 0; i < data->nodes_count; ++i)
1964 {
1965 CREATE_NAME(&data->nodes[i], "node", i);
1966 }
1967
1968 for (int i = 0; i < data->skins_count; ++i)
1969 {
1970 cgltf_skin* skin = &data->skins[i];
1971 CREATE_NAME(skin, "skin", i);
1972
1973 for (int j = 0; j < skin->joints_count; ++j)
1974 {
1975 CREATE_NAME(skin->joints[j], "joint", j);
1976 }
1977 }
1978
1979 for (uint32_t i = 0; i < data->samplers_count; ++i)
1980 {
1981 CREATE_NAME(&data->samplers[i], "sampler", i);
1982 }
1983
1984 for (uint32_t i = 0; i < data->buffers_count; ++i)
1985 {
1986 if (!(data->buffers[i].name || data->buffers[i].uri))
1987 data->buffers[i].name = CreateCgltfName("buffer", i);
1988 }
1989
1990 for (uint32_t i = 0; i < data->images_count; ++i)
1991 {
1992 CREATE_NAME(&data->images[i], "image", i);
1993 }
1994
1995 for (uint32_t i = 0; i < data->textures_count; ++i)
1996 {
1997 CREATE_NAME(&data->textures[i], "texture", i);
1998 }
1999
2000 for (uint32_t i = 0; i < data->materials_count; ++i)
2001 {
2002 CREATE_NAME(&data->materials[i], "material", i);
2003 }
2004
2005 for (uint32_t i = 0; i < data->meshes_count; ++i)
2006 {
2007 CREATE_NAME(&data->meshes[i], "model", i); // our "Model"
2008 }
2009
2010 // first, count number of animated nodes we have
2011 for (uint32_t i = 0; i < data->animations_count; ++i)
2012 {

Callers 1

LoadGltfFromBufferFunction · 0.85

Calls 1

CreateCgltfNameFunction · 0.85

Tested by

no test coverage detected