Armature: Cleanup: Remove unused function and use less silly wire drawing.
This commit is contained in:
@@ -315,6 +315,7 @@ DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create(struct GPUMaterial
|
||||
DRWShadingGroup *DRW_shgroup_instance_create(
|
||||
struct GPUShader *shader, DRWPass *pass, struct Gwn_Batch *geom, struct Gwn_VertFormat *format);
|
||||
DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_line_batch_create_with_format(struct GPUShader *shader, DRWPass *pass, struct Gwn_VertFormat *format);
|
||||
DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DRWPass *pass, int size);
|
||||
DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, struct Gwn_VertBuf *tf_target);
|
||||
|
||||
@@ -81,7 +81,7 @@ static struct {
|
||||
DRWShadingGroup *bone_box_solid;
|
||||
DRWShadingGroup *bone_box_wire;
|
||||
DRWShadingGroup *bone_box_outline;
|
||||
DRWShadingGroup *bone_wire_wire;
|
||||
DRWShadingGroup *bone_wire;
|
||||
DRWShadingGroup *bone_stick;
|
||||
DRWShadingGroup *bone_envelope_solid;
|
||||
DRWShadingGroup *bone_envelope_distance;
|
||||
@@ -171,17 +171,21 @@ static void drw_shgroup_bone_box(
|
||||
}
|
||||
|
||||
/* Wire */
|
||||
static void drw_shgroup_bone_wire_wire(const float (*bone_mat)[4], const float color[4])
|
||||
static void drw_shgroup_bone_wire(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_wire_wire == NULL) {
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_wire_wire_outline_get();
|
||||
g_data.bone_wire_wire = shgroup_instance_wire(g_data.passes.bone_wire, geom);
|
||||
if (g_data.bone_wire == NULL) {
|
||||
g_data.bone_wire = shgroup_dynlines_flat_color(g_data.passes.bone_wire);
|
||||
}
|
||||
float final_bonemat[4][4];
|
||||
mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
|
||||
DRW_shgroup_call_dynamic_add(g_data.bone_wire_wire, final_bonemat, color);
|
||||
float head[3], tail[3];
|
||||
mul_v3_m4v3(head, g_data.ob->obmat, bone_mat[3]);
|
||||
DRW_shgroup_call_dynamic_add(g_data.bone_wire, head, color);
|
||||
|
||||
add_v3_v3v3(tail, bone_mat[3], bone_mat[1]);
|
||||
mul_m4_v3(g_data.ob->obmat, tail);
|
||||
DRW_shgroup_call_dynamic_add(g_data.bone_wire, tail, color);
|
||||
}
|
||||
|
||||
/* Stick */
|
||||
static void drw_shgroup_bone_stick(
|
||||
const float (*bone_mat)[4],
|
||||
const float col_wire[4], const float col_bone[4], const float col_head[4], const float col_tail[4])
|
||||
@@ -1287,12 +1291,12 @@ static void draw_bone_wire(
|
||||
BLI_assert(bbones_mat != NULL);
|
||||
|
||||
for (int i = pchan->bone->segments; i--; bbones_mat++) {
|
||||
drw_shgroup_bone_wire_wire(bbones_mat->mat, col_wire);
|
||||
drw_shgroup_bone_wire(bbones_mat->mat, col_wire);
|
||||
}
|
||||
}
|
||||
else if (eBone) {
|
||||
for (int i = 0; i < eBone->segments; i++) {
|
||||
drw_shgroup_bone_wire_wire(eBone->disp_bbone_mat[i], col_wire);
|
||||
drw_shgroup_bone_wire(eBone->disp_bbone_mat[i], col_wire);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1650,37 +1650,6 @@ Gwn_Batch *DRW_cache_bone_octahedral_get(void)
|
||||
return SHC.drw_bone_octahedral;
|
||||
}
|
||||
|
||||
Gwn_Batch *DRW_cache_bone_octahedral_wire_outline_get(void)
|
||||
{
|
||||
if (!SHC.drw_bone_octahedral_wire) {
|
||||
uint v_idx = 0;
|
||||
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, n1, n2; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
/* Vertices */
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, 12 * 2);
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
const float *co1 = bone_octahedral_verts[bone_octahedral_wire[i * 2]];
|
||||
const float *co2 = bone_octahedral_verts[bone_octahedral_wire[i * 2 + 1]];
|
||||
const float *n1 = bone_octahedral_solid_normals[bone_octahedral_wire_adjacent_face[i * 2]];
|
||||
const float *n2 = bone_octahedral_solid_normals[bone_octahedral_wire_adjacent_face[i * 2 + 1]];
|
||||
add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n1, n2);
|
||||
}
|
||||
|
||||
SHC.drw_bone_octahedral_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
|
||||
}
|
||||
return SHC.drw_bone_octahedral_wire;
|
||||
}
|
||||
|
||||
|
||||
/* XXX TODO move that 1 unit cube to more common/generic place? */
|
||||
static const float bone_box_verts[8][3] = {
|
||||
{ 1.0f, 0.0f, 1.0f},
|
||||
@@ -1820,64 +1789,6 @@ Gwn_Batch *DRW_cache_bone_box_get(void)
|
||||
return SHC.drw_bone_box;
|
||||
}
|
||||
|
||||
Gwn_Batch *DRW_cache_bone_box_wire_outline_get(void)
|
||||
{
|
||||
if (!SHC.drw_bone_box_wire) {
|
||||
uint v_idx = 0;
|
||||
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, n1, n2; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
/* Vertices */
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, 12 * 2);
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
const float *co1 = bone_box_verts[bone_box_wire[i * 2]];
|
||||
const float *co2 = bone_box_verts[bone_box_wire[i * 2 + 1]];
|
||||
const float *n1 = bone_box_solid_normals[bone_box_wire_adjacent_face[i * 2]];
|
||||
const float *n2 = bone_box_solid_normals[bone_box_wire_adjacent_face[i * 2 + 1]];
|
||||
add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n1, n2);
|
||||
}
|
||||
|
||||
SHC.drw_bone_box_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
|
||||
}
|
||||
return SHC.drw_bone_box_wire;
|
||||
}
|
||||
|
||||
|
||||
Gwn_Batch *DRW_cache_bone_wire_wire_outline_get(void)
|
||||
{
|
||||
if (!SHC.drw_bone_wire_wire) {
|
||||
uint v_idx = 0;
|
||||
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, n1, n2; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
/* Vertices */
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, 2);
|
||||
|
||||
const float co1[3] = {0.0f, 0.0f, 0.0f};
|
||||
const float co2[3] = {0.0f, 1.0f, 0.0f};
|
||||
const float n[3] = {1.0f, 0.0f, 0.0f};
|
||||
add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n, n);
|
||||
|
||||
SHC.drw_bone_wire_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO);
|
||||
}
|
||||
return SHC.drw_bone_wire_wire;
|
||||
}
|
||||
|
||||
/* Helpers for envelope bone's solid sphere-with-hidden-equatorial-cylinder.
|
||||
* Note that here we only encode head/tail in forth component of the vector. */
|
||||
static void benv_lat_lon_to_co(const float lat, const float lon, float r_nor[3])
|
||||
|
||||
@@ -97,10 +97,7 @@ struct Gwn_Batch *DRW_cache_lightprobe_planar_get(void);
|
||||
|
||||
/* Bones */
|
||||
struct Gwn_Batch *DRW_cache_bone_octahedral_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_octahedral_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_box_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_box_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_wire_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_envelope_solid_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_envelope_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_envelope_head_wire_outline_get(void);
|
||||
|
||||
@@ -203,6 +203,7 @@ static struct {
|
||||
struct Gwn_VertFormat *instance_bone_envelope_distance;
|
||||
struct Gwn_VertFormat *instance_bone_envelope_outline;
|
||||
struct Gwn_VertFormat *instance_mball_handles;
|
||||
struct Gwn_VertFormat *dynlines_color;
|
||||
} g_formats = {NULL};
|
||||
|
||||
void DRW_globals_free(void)
|
||||
@@ -218,6 +219,20 @@ void DRW_globals_free(void)
|
||||
}
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_dynlines_flat_color(DRWPass *pass)
|
||||
{
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_FLAT_COLOR);
|
||||
|
||||
DRW_shgroup_instance_format(g_formats.dynlines_color, {
|
||||
{"pos" , DRW_ATTRIB_FLOAT, 3},
|
||||
{"color" , DRW_ATTRIB_FLOAT, 4}
|
||||
});
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_line_batch_create_with_format(sh, pass, g_formats.dynlines_color);
|
||||
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(DRWPass *pass, float color[4])
|
||||
{
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
@@ -99,6 +99,7 @@ typedef struct GlobalsUboStorage {
|
||||
void DRW_globals_update(void);
|
||||
void DRW_globals_free(void);
|
||||
|
||||
struct DRWShadingGroup *shgroup_dynlines_flat_color(struct DRWPass *pass);
|
||||
struct DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(struct DRWPass *pass, float color[4]);
|
||||
struct DRWShadingGroup *shgroup_dynpoints_uniform_color(struct DRWPass *pass, float color[4], float *size);
|
||||
struct DRWShadingGroup *shgroup_groundlines_uniform_color(struct DRWPass *pass, float color[4]);
|
||||
|
||||
@@ -797,16 +797,21 @@ DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPas
|
||||
return shgroup;
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_line_batch_create_with_format(struct GPUShader *shader, DRWPass *pass, Gwn_VertFormat *format)
|
||||
{
|
||||
DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
|
||||
shgroup->type = DRW_SHG_LINE_BATCH;
|
||||
|
||||
drw_shgroup_batching_init(shgroup, shader, format);
|
||||
|
||||
return shgroup;
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass)
|
||||
{
|
||||
DRW_shgroup_instance_format(g_pos_format, {{"pos", DRW_ATTRIB_FLOAT, 3}});
|
||||
|
||||
DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
|
||||
shgroup->type = DRW_SHG_LINE_BATCH;
|
||||
|
||||
drw_shgroup_batching_init(shgroup, shader, g_pos_format);
|
||||
|
||||
return shgroup;
|
||||
return DRW_shgroup_line_batch_create_with_format(shader, pass, g_pos_format);
|
||||
}
|
||||
|
||||
/* Very special batch. Use this if you position
|
||||
|
||||
Reference in New Issue
Block a user