195 lines
4.3 KiB
C
195 lines
4.3 KiB
C
|
void
|
||
|
asset_mgr_startup(void)
|
||
|
{
|
||
|
g_engine->asset_mgr.meshes.hash = hash_create(NEAREST_PRIME_1024, sizeof(handle_t));
|
||
|
g_engine->asset_mgr.materials.hash = hash_create(NEAREST_PRIME_256, sizeof(handle_t));
|
||
|
g_engine->asset_mgr.cameras.hash = hash_create(NEAREST_PRIME_256, sizeof(handle_t));
|
||
|
g_engine->asset_mgr.sounds.hash = hash_create(NEAREST_PRIME_256, sizeof(handle_t));
|
||
|
g_engine->asset_mgr.audio_sources.hash = hash_create(NEAREST_PRIME_256, sizeof(handle_t));
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_mesh(mesh_t mesh)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.meshes.count;
|
||
|
|
||
|
g_engine->asset_mgr.meshes.data[handle] = mesh;
|
||
|
hash_add(&g_engine->asset_mgr.meshes.hash, HASH_CSTR(mesh.name), &handle);
|
||
|
|
||
|
g_engine->asset_mgr.meshes.count++;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_material(material_t material)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.materials.count;
|
||
|
|
||
|
g_engine->asset_mgr.materials.data[handle] = material;
|
||
|
hash_add(&g_engine->asset_mgr.materials.hash, HASH_CSTR(material.name), &handle);
|
||
|
|
||
|
g_engine->asset_mgr.materials.count++;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_sound(sound_t sound)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.sounds.count;
|
||
|
|
||
|
g_engine->asset_mgr.sounds.data[handle] = sound;
|
||
|
hash_add(&g_engine->asset_mgr.sounds.hash, HASH_CSTR(sound.name), &handle);
|
||
|
|
||
|
g_engine->asset_mgr.sounds.count++;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_audio_source(audio_source_t source)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.audio_sources.count;
|
||
|
|
||
|
g_engine->asset_mgr.audio_sources.data[handle] = source;
|
||
|
hash_add(&g_engine->asset_mgr.audio_sources.hash, HASH_CSTR(source.name), &handle);
|
||
|
|
||
|
g_engine->asset_mgr.audio_sources.count++;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_transform(transform_t transform)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.transforms.count;
|
||
|
|
||
|
g_engine->asset_mgr.transforms.data[handle] = transform;
|
||
|
g_engine->asset_mgr.transforms.count++;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_camera(camera_t camera)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.cameras.count;
|
||
|
|
||
|
g_engine->asset_mgr.cameras.data[handle] = camera;
|
||
|
hash_add(&g_engine->asset_mgr.cameras.hash, HASH_CSTR(camera.name), &handle);
|
||
|
|
||
|
g_engine->asset_mgr.cameras.count++;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_renderable(renderable_t renderable)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.renderables.count;
|
||
|
|
||
|
g_engine->asset_mgr.renderables.data[handle] = renderable;
|
||
|
|
||
|
g_engine->asset_mgr.renderables.count++;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_collider(box_collider_t collider)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.colliders.count;
|
||
|
|
||
|
g_engine->asset_mgr.colliders.data[handle] = collider;
|
||
|
|
||
|
g_engine->asset_mgr.colliders.count++;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
insert_light(point_light_t light)
|
||
|
{
|
||
|
handle_t handle = g_engine->asset_mgr.lights.count;
|
||
|
|
||
|
g_engine->asset_mgr.lights.data[handle] = light;
|
||
|
|
||
|
g_engine->asset_mgr.lights.count++;
|
||
|
}
|
||
|
|
||
|
handle_t
|
||
|
get_mesh_handle(const char* name)
|
||
|
{
|
||
|
handle_t* handle = (handle_t*)hash_get(g_engine->asset_mgr.meshes.hash, HASH_CSTR(name));
|
||
|
|
||
|
return *handle;
|
||
|
}
|
||
|
|
||
|
mesh_t*
|
||
|
get_mesh(handle_t handle)
|
||
|
{
|
||
|
mesh_t* result = &g_engine->asset_mgr.meshes.data[handle];
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
handle_t
|
||
|
get_material_handle(const char* name)
|
||
|
{
|
||
|
handle_t* handle = (handle_t*)hash_get(g_engine->asset_mgr.materials.hash, HASH_CSTR(name));
|
||
|
|
||
|
return *handle;
|
||
|
}
|
||
|
|
||
|
material_t*
|
||
|
get_material(handle_t handle)
|
||
|
{
|
||
|
material_t* result = &g_engine->asset_mgr.materials.data[handle];
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
handle_t
|
||
|
get_sound_handle(const char* name)
|
||
|
{
|
||
|
handle_t* handle = (handle_t*)hash_get(g_engine->asset_mgr.sounds.hash, HASH_CSTR(name));
|
||
|
|
||
|
return *handle;
|
||
|
}
|
||
|
|
||
|
sound_t*
|
||
|
get_sound(handle_t handle)
|
||
|
{
|
||
|
sound_t* result = &g_engine->asset_mgr.sounds.data[handle];
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
handle_t
|
||
|
get_audio_source_handle(const char* name)
|
||
|
{
|
||
|
handle_t* handle = (handle_t*)hash_get(g_engine->asset_mgr.audio_sources.hash, HASH_CSTR(name));
|
||
|
|
||
|
return *handle;
|
||
|
}
|
||
|
|
||
|
audio_source_t*
|
||
|
get_audio_source(handle_t handle)
|
||
|
{
|
||
|
audio_source_t* result = &g_engine->asset_mgr.audio_sources.data[handle];
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
renderable_t*
|
||
|
get_renderable(handle_t handle)
|
||
|
{
|
||
|
renderable_t* result = &g_engine->asset_mgr.renderables.data[handle];
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
transform_t*
|
||
|
get_transform(handle_t handle)
|
||
|
{
|
||
|
transform_t* result = &g_engine->asset_mgr.transforms.data[handle];
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
camera_t*
|
||
|
get_camera(handle_t handle)
|
||
|
{
|
||
|
camera_t* result = &g_engine->asset_mgr.cameras.data[handle];
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
handle_t
|
||
|
get_camera_handle(const char* name)
|
||
|
{
|
||
|
handle_t* handle = (handle_t*)hash_get(g_engine->asset_mgr.cameras.hash, HASH_CSTR(name));
|
||
|
|
||
|
return *handle;
|
||
|
}
|