Implement TapirEngine.SetInstanceMeshShow

This commit is contained in:
kichikuou
2025-06-16 11:43:26 +09:00
parent bba3f96a1b
commit e2440a5a44
6 changed files with 26 additions and 2 deletions
+1
View File
@@ -214,6 +214,7 @@ bool RE_instance_load(struct RE_instance *instance, const char *name);
bool RE_instance_load_motion(struct RE_instance *instance, const char *name);
bool RE_instance_load_next_motion(struct RE_instance *instance, const char *name);
bool RE_instance_free_next_motion(struct RE_instance *instance);
bool RE_instance_set_mesh_show(struct RE_instance *instance, const char *mesh_name, bool show);
bool RE_instance_set_vertex_pos(struct RE_instance *instance, int index, float x, float y, float z);
int RE_instance_get_bone_index(struct RE_instance *instance, const char *name);
bool RE_instance_trans_local_pos_to_world_pos_by_bone(struct RE_instance *instance, int bone, vec3 offset, vec3 out);
+2
View File
@@ -50,8 +50,10 @@ struct model {
};
struct mesh {
char *name;
uint32_t flags;
bool is_transparent;
bool hidden;
GLuint vao;
GLuint attr_buffer;
GLuint index_buffer;
+2
View File
@@ -317,6 +317,7 @@ static void add_mesh(struct model *model, struct pol_mesh *m, uint32_t material_
}
model->meshes = xrealloc_array(model->meshes, model->nr_meshes, model->nr_meshes + 1, sizeof(struct mesh));
struct mesh *mesh = &model->meshes[model->nr_meshes++];
mesh->name = xstrdup(m->name);
mesh->flags = m->flags;
mesh->material = material;
if (re_plugin_version == RE_REIGN_PLUGIN)
@@ -393,6 +394,7 @@ static void add_mesh(struct model *model, struct pol_mesh *m, uint32_t material_
static void destroy_mesh(struct mesh *mesh)
{
free(mesh->name);
glDeleteVertexArrays(1, &mesh->vao);
glDeleteBuffers(1, &mesh->attr_buffer);
if (mesh->index_buffer)
+13
View File
@@ -502,6 +502,19 @@ bool RE_instance_free_next_motion(struct RE_instance *instance)
return true;
}
bool RE_instance_set_mesh_show(struct RE_instance *instance, const char *mesh_name, bool show)
{
if (!instance || !instance->model)
return false;
for (int i = 0; i < instance->model->nr_meshes; i++) {
if (!strcmp(instance->model->meshes[i].name, mesh_name)) {
instance->model->meshes[i].hidden = !show;
return true;
}
}
return false;
}
bool RE_instance_set_vertex_pos(struct RE_instance *instance, int index, float x, float y, float z)
{
if (!instance)
+2
View File
@@ -362,6 +362,8 @@ static void render_model(struct RE_instance *inst, struct RE_renderer *r, enum d
for (int i = 0; i < model->nr_meshes; i++) {
struct mesh *mesh = &model->meshes[i];
if (mesh->hidden)
continue;
struct material *material = &model->materials[mesh->material];
bool is_transparent = mesh->is_transparent || inst->alpha < 1.0f;
if (phase != (is_transparent ? DRAW_TRANSPARENT : DRAW_OPAQUE))
+6 -2
View File
@@ -1891,7 +1891,11 @@ static bool TapirEngine_GetInstancePathLine(int plugin, int instance, struct pag
}
//bool TapirEngine_CreateInstancePathLineList(int PluginNumber, int InstanceNumber, int PathInstanceNumber);
//bool TapirEngine_SetInstanceMeshShow(int PluginNumber, int InstanceNumber, struct string *pIMeshName, bool Show);
static bool TapirEngine_SetInstanceMeshShow(int plugin, int instance, struct string *mesh_name, bool show)
{
return RE_instance_set_mesh_show(get_instance(plugin, instance), mesh_name->text, show);
}
static bool TapirEngine_SetDrawOption(int plugin_number, int draw_option, int param)
{
@@ -2303,7 +2307,7 @@ HLL_LIBRARY(ReignEngine, REIGN_EXPORTS,
HLL_EXPORT(OptimizeInstancePathLine, TapirEngine_OptimizeInstancePathLine), \
HLL_EXPORT(GetInstancePathLine, TapirEngine_GetInstancePathLine), \
HLL_TODO_EXPORT(CreateInstancePathLineList, TapirEngine_CreateInstancePathLineList), \
HLL_TODO_EXPORT(SetInstanceMeshShow, TapirEngine_SetInstanceMeshShow), \
HLL_EXPORT(SetInstanceMeshShow, TapirEngine_SetInstanceMeshShow), \
HLL_EXPORT(SetDrawOption, TapirEngine_SetDrawOption), \
HLL_EXPORT(GetDrawOption, TapirEngine_GetDrawOption), \
HLL_TODO_EXPORT(SetDebugMode, TapirEngine_SetDebugMode), \