mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-22 23:18:01 +03:00
3d: Gate edge drawing on per-instance flag
In both TapirEngine and SealEngine an instance is outlined only when the global edge draw option and its per-instance edge flag are both on. The per-instance flag is exposed via Set/GetInstanceDrawParam, whose edge index differs by engine (Tapir 0, Seal 2). For the global option the engine only distinguishes on/off, so drop the RE_draw_edge_mode enum.
This commit is contained in:
+2
-6
@@ -92,12 +92,6 @@ enum RE_draw_options {
|
||||
RE_DRAW_OPTION_MAX
|
||||
};
|
||||
|
||||
enum RE_draw_edge_mode {
|
||||
RE_DRAW_EDGE_NONE = 0,
|
||||
RE_DRAW_EDGE_CHARACTERS_ONLY = 1,
|
||||
RE_DRAW_EDGE_ALL = 2,
|
||||
};
|
||||
|
||||
struct RE_options {
|
||||
int anti_aliasing;
|
||||
int wait_vsync;
|
||||
@@ -129,6 +123,7 @@ struct RE_back_cg {
|
||||
|
||||
struct RE_plugin {
|
||||
struct draw_plugin plugin;
|
||||
enum RE_plugin_version version;
|
||||
int sprite;
|
||||
int nr_instances;
|
||||
struct RE_instance **instances;
|
||||
@@ -203,6 +198,7 @@ struct RE_instance {
|
||||
vec3 scale;
|
||||
float alpha;
|
||||
bool draw;
|
||||
bool draw_edge;
|
||||
bool draw_shadow;
|
||||
bool make_shadow;
|
||||
float shadow_volume_bone_radius;
|
||||
|
||||
@@ -41,6 +41,7 @@ static struct RE_instance *create_instance(struct RE_plugin *plugin)
|
||||
{
|
||||
struct RE_instance *instance = xcalloc_aligned(1, struct RE_instance);
|
||||
instance->plugin = plugin;
|
||||
instance->draw_edge = plugin->version == RE_TAPIR_PLUGIN;
|
||||
for (int i = 0; i < RE_NR_INSTANCE_TARGETS; i++)
|
||||
instance->target[i] = -1;
|
||||
glm_vec3_one(instance->scale);
|
||||
@@ -236,6 +237,7 @@ struct RE_plugin *RE_plugin_new(enum RE_plugin_version version)
|
||||
return NULL;
|
||||
|
||||
struct RE_plugin *plugin = xcalloc_aligned(1, struct RE_plugin);
|
||||
plugin->version = version;
|
||||
plugin->plugin.name = "ReignEngine";
|
||||
plugin->plugin.update = RE_render;
|
||||
plugin->plugin.to_json = RE_to_json;
|
||||
@@ -247,6 +249,8 @@ struct RE_plugin *RE_plugin_new(enum RE_plugin_version version)
|
||||
for (int i = 0; i < RE_NR_BACK_CGS; i++)
|
||||
RE_back_cg_init(&plugin->back_cg[i]);
|
||||
plugin->mag_speed = 1;
|
||||
if (version == RE_TAPIR_PLUGIN)
|
||||
plugin->draw_options[RE_DRAW_OPTION_EDGE] = 1;
|
||||
plugin->edge_length = 0.02f;
|
||||
plugin->fog_type = RE_FOG_NONE;
|
||||
plugin->fog_near = 1.0f;
|
||||
|
||||
+2
-3
@@ -1072,8 +1072,7 @@ static void render_shadow_map(struct RE_plugin *plugin, mat4 light_space_transfo
|
||||
|
||||
static void render_outlines(struct RE_plugin *plugin, mat4 view_transform)
|
||||
{
|
||||
enum RE_draw_edge_mode mode = plugin->draw_options[RE_DRAW_OPTION_EDGE];
|
||||
if (mode == RE_DRAW_EDGE_NONE)
|
||||
if (plugin->draw_options[RE_DRAW_OPTION_EDGE] == 0)
|
||||
return;
|
||||
struct outline_renderer *or = &plugin->renderer->outline;
|
||||
if (!or->program)
|
||||
@@ -1095,7 +1094,7 @@ static void render_outlines(struct RE_plugin *plugin, mat4 view_transform)
|
||||
struct RE_instance *inst = plugin->instances[i];
|
||||
if (!inst || !inst->draw)
|
||||
continue;
|
||||
if (mode == RE_DRAW_EDGE_CHARACTERS_ONLY && inst->type != RE_ITYPE_SKINNED)
|
||||
if (!inst->draw_edge)
|
||||
continue;
|
||||
struct model *model = inst->model;
|
||||
if (inst->model && model->nr_bones > 0) {
|
||||
|
||||
+30
-3
@@ -1825,8 +1825,35 @@ static int TapirEngine_CreatePlugin(void)
|
||||
return ReignEngine_create_plugin(RE_TAPIR_PLUGIN);
|
||||
}
|
||||
|
||||
HLL_WARN_UNIMPLEMENTED(false, bool, TapirEngine, SetInstanceDrawParam, int plugin_number, int instance_number, int draw_param, int value);
|
||||
//bool TapirEngine_GetInstanceDrawParam(int PluginNumber, int InstanceNumber, int DrawParam, int *Value);
|
||||
static bool TapirEngine_SetInstanceDrawParam(int plugin_number, int instance_number, int draw_param, int value)
|
||||
{
|
||||
struct RE_plugin *p = get_plugin(plugin_number);
|
||||
struct RE_instance *ri = get_instance(plugin_number, instance_number);
|
||||
if (!p || !ri)
|
||||
return false;
|
||||
int edge_index = p->version >= RE_SEAL_PLUGIN ? 2 : 0;
|
||||
if (draw_param == edge_index) {
|
||||
ri->draw_edge = value != 0;
|
||||
return true;
|
||||
}
|
||||
WARNING("unimplemented InstanceDrawParam: %d", draw_param);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TapirEngine_GetInstanceDrawParam(int plugin_number, int instance_number, int draw_param, int *value)
|
||||
{
|
||||
struct RE_plugin *p = get_plugin(plugin_number);
|
||||
struct RE_instance *ri = get_instance(plugin_number, instance_number);
|
||||
if (!p || !ri)
|
||||
return false;
|
||||
int edge_index = p->version >= RE_SEAL_PLUGIN ? 2 : 0;
|
||||
if (draw_param == edge_index) {
|
||||
*value = ri->draw_edge;
|
||||
return true;
|
||||
}
|
||||
WARNING("unimplemented InstanceDrawParam: %d", draw_param);
|
||||
return false;
|
||||
}
|
||||
|
||||
static float TapirEngine_CalcInstance2DDetectionHeight(int plugin, int instance, float x, float z)
|
||||
{
|
||||
@@ -2313,7 +2340,7 @@ HLL_LIBRARY(ReignEngine, REIGN_EXPORTS,
|
||||
#define TAPIR_EXPORTS \
|
||||
HLL_EXPORT(CreatePlugin, TapirEngine_CreatePlugin), \
|
||||
HLL_EXPORT(SetInstanceDrawParam, TapirEngine_SetInstanceDrawParam), \
|
||||
HLL_TODO_EXPORT(GetInstanceDrawParam, TapirEngine_GetInstanceDrawParam), \
|
||||
HLL_EXPORT(GetInstanceDrawParam, TapirEngine_GetInstanceDrawParam), \
|
||||
HLL_EXPORT(CalcInstance2DDetectionHeight, TapirEngine_CalcInstance2DDetectionHeight), \
|
||||
HLL_EXPORT(CalcInstance2DDetection, TapirEngine_CalcInstance2DDetection), \
|
||||
HLL_EXPORT(FindInstancePath, TapirEngine_FindInstancePath), \
|
||||
|
||||
Reference in New Issue
Block a user