Edit Mesh: Remove old unused code and files

Cleanup after recent refactor.
This commit is contained in:
Clément Foucault 2019-02-04 01:35:21 +01:00
parent 86193d25db
commit 112cf6eadf
8 changed files with 6 additions and 492 deletions

View File

@ -270,11 +270,6 @@ data_to_c_simple(modes/shaders/armature_dof_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_common_lib.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_frag.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_geom_tri.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_geom_edge.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_points_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facedot_frag.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facedot_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_mix_frag.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facefill_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facefill_frag.glsl SRC)

View File

@ -49,11 +49,6 @@ extern char datatoc_paint_weight_frag_glsl[];
extern char datatoc_edit_mesh_overlay_common_lib_glsl[];
extern char datatoc_edit_mesh_overlay_frag_glsl[];
extern char datatoc_edit_mesh_overlay_vert_glsl[];
extern char datatoc_edit_mesh_overlay_geom_tri_glsl[];
extern char datatoc_edit_mesh_overlay_geom_edge_glsl[];
extern char datatoc_edit_mesh_overlay_points_vert_glsl[];
extern char datatoc_edit_mesh_overlay_facedot_frag_glsl[];
extern char datatoc_edit_mesh_overlay_facedot_vert_glsl[];
extern char datatoc_edit_mesh_overlay_mix_frag_glsl[];
extern char datatoc_edit_mesh_overlay_facefill_vert_glsl[];
extern char datatoc_edit_mesh_overlay_facefill_frag_glsl[];
@ -218,16 +213,15 @@ static void EDIT_MESH_engine_init(void *vedata)
.frag = (const char *[]){datatoc_gpu_shader_point_varying_color_frag_glsl, NULL},
.defs = (const char *[]){world_clip_def_or_empty, "#define FACEDOT\n", NULL},
});
sh_data->overlay_facefill = DRW_shader_create_from_arrays({
.vert = (const char *[]){lib, datatoc_edit_mesh_overlay_facefill_vert_glsl, NULL},
.frag = (const char *[]){lib, datatoc_edit_mesh_overlay_facefill_frag_glsl, NULL},
.defs = (const char *[]){world_clip_def_or_empty, NULL},
});
MEM_freeN(lib);
sh_data->overlay_mix = DRW_shader_create_fullscreen(datatoc_edit_mesh_overlay_mix_frag_glsl, NULL);
sh_data->overlay_facefill = DRW_shader_create_from_arrays({
.vert = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_edit_mesh_overlay_facefill_vert_glsl, NULL},
.frag = (const char *[]){datatoc_common_globals_lib_glsl, datatoc_edit_mesh_overlay_facefill_frag_glsl, NULL},
.defs = (const char *[]){world_clip_def_or_empty, NULL},
});
sh_data->normals_face = DRW_shader_create_from_arrays({
.vert = (const char *[]){world_clip_lib_or_empty, datatoc_edit_normals_vert_glsl, NULL},
.geom = (const char *[]){world_clip_lib_or_empty, datatoc_edit_normals_geom_glsl, NULL},

View File

@ -1,21 +0,0 @@
flat in int isSelected;
#ifdef VERTEX_FACING
flat in float facing;
#endif
out vec4 FragColor;
void main()
{
if (isSelected != 0) {
FragColor = colorFaceDot;
}
else {
FragColor = colorVertex;
}
#ifdef VERTEX_FACING
FragColor.a *= 1.0 - abs(facing) * 0.4;
#endif
}

View File

@ -1,36 +0,0 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
in vec3 pos;
in vec4 norAndFlag;
flat out int isSelected;
#ifdef VERTEX_FACING
uniform mat4 ProjectionMatrix;
uniform mat4 ModelViewMatrix;
uniform mat3 NormalMatrix;
flat out float facing;
#endif
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
/* Bias Facedot Z position in clipspace. */
gl_Position.z -= 0.00035;
gl_PointSize = sizeFaceDot;
isSelected = int(norAndFlag.w);
#ifdef VERTEX_FACING
vec3 view_normal = normalize(NormalMatrix * norAndFlag.xyz);
vec3 view_vec = (ProjectionMatrix[3][3] == 0.0)
? normalize((ModelViewMatrix * vec4(pos, 1.0)).xyz)
: vec3(0.0, 0.0, 1.0);
facing = dot(view_vec, view_normal);
#endif
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}

View File

@ -14,18 +14,7 @@ void main()
ivec4 data_m = data & dataMask;
if ((data_m.x & FACE_ACTIVE) != 0) {
faceColor = colorFaceSelect;
}
else if ((data_m.x & FACE_SELECTED) != 0) {
faceColor = colorFaceSelect;
}
else if ((data_m.x & FACE_FREESTYLE) != 0) {
faceColor = colorFaceFreestyle;
}
else {
faceColor = colorFace;
}
faceColor = EDIT_MESH_face_color(data_m.x);
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);

View File

@ -1,124 +0,0 @@
/* Solid Wirefram implementation
* Mike Erwin, Clément Foucault */
layout(lines) in;
layout(triangle_strip, max_vertices=4) out;
uniform mat4 ProjectionMatrix;
uniform mat4 ViewProjectionMatrixInverse;
uniform vec2 viewportSize;
in vec4 pPos[];
in ivec4 vData[];
#ifdef VERTEX_FACING
in float vFacing[];
#endif
/* these are the same for all vertices
* and does not need interpolation */
flat out vec3 edgesCrease;
flat out vec3 edgesBweight;
flat out vec4 faceColor;
flat out ivec3 flag;
#ifdef VERTEX_SELECTION
out vec3 vertexColor;
#endif
#ifdef VERTEX_FACING
out float facing;
#endif
/* See fragment shader */
flat out vec2 ssPos[3];
/* Some bugged AMD drivers need these global variables. See T55961 */
#ifdef VERTEX_SELECTION
vec3 vertex_color[3];
#endif
#ifdef VERTEX_FACING
float v_facing[3];
#endif
/* project to screen space */
vec2 proj(vec4 pos)
{
return (0.5 * (pos.xy / pos.w) + 0.5) * viewportSize;
}
void doVertex(int v, vec4 pos)
{
#ifdef VERTEX_SELECTION
vertexColor = vertex_color[v];
#endif
#ifdef VERTEX_FACING
facing = v_facing[v];
#endif
gl_Position = pos;
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_set_clip_distance(gl_in[v].gl_ClipDistance);
#endif
EmitVertex();
}
void main()
{
/* Face */
faceColor = vec4(0.0);
/* Proj Vertex */
vec2 pos[2] = vec2[2](proj(pPos[0]), proj(pPos[1]));
/* little optimization use a vec4 to vectorize
* following operations */
vec4 dirs1, dirs2;
/* Edge normalized vector */
dirs1.xy = normalize(pos[1] - pos[0]);
/* perpendicular to dir */
dirs1.zw = vec2(-dirs1.y, dirs1.x);
/* Make it view independent */
dirs1 *= sizeEdgeFix / viewportSize.xyxy;
dirs2 = dirs1;
/* Perspective */
if (ProjectionMatrix[3][3] == 0.0) {
dirs1 *= pPos[0].w;
dirs2 *= pPos[1].w;
}
#ifdef VERTEX_SELECTION
vertex_color[0] = EDIT_MESH_vertex_color(vData[0].x).rgb;
vertex_color[1] = EDIT_MESH_vertex_color(vData[1].x).rgb;
#endif
#ifdef VERTEX_FACING
/* Weird but some buggy AMD drivers need this. */
v_facing[0] = vFacing[0];
v_facing[1] = vFacing[1];
#endif
/* Edge / Vert data */
ssPos[0] = ssPos[2] = pos[0];
ssPos[1] = pos[1];
flag[0] = flag[2] = (vData[0].x << 8);
flag[1] = (vData[1].x << 8);
doVertex(0, pPos[0] + vec4( dirs1.zw, 0.0, 0.0));
doVertex(0, pPos[0] + vec4(-dirs1.zw, 0.0, 0.0));
flag[2] |= vData[0].y;
edgesCrease[2] = vData[0].z / 255.0;
edgesBweight[2] = vData[0].w / 255.0;
doVertex(1, pPos[1] + vec4( dirs2.zw, 0.0, 0.0));
doVertex(1, pPos[1] + vec4(-dirs2.zw, 0.0, 0.0));
EndPrimitive();
}

View File

@ -1,227 +0,0 @@
/* Solid Wirefram implementation
* Mike Erwin, Clément Foucault */
layout(triangles) in;
/* To fix the edge artifacts, we render
* an outline strip around the screenspace
* triangle. Order is important.
* TODO diagram
*/
layout(triangle_strip, max_vertices=11) out;
uniform mat4 ProjectionMatrix;
uniform vec2 viewportSize;
uniform bool isXray = false;
in vec4 pPos[];
#ifdef USE_WORLD_CLIP_PLANES
/* Worldspace position. */
in vec3 wsPos[];
#endif
in ivec4 vData[];
#ifdef VERTEX_FACING
in float vFacing[];
#endif
/* these are the same for all vertices
* and does not need interpolation */
flat out vec3 edgesCrease;
flat out vec3 edgesBweight;
flat out vec4 faceColor;
flat out ivec3 flag;
flat out vec2 ssPos[3];
#ifdef VERTEX_SELECTION
out vec3 vertexColor;
#endif
#ifdef VERTEX_FACING
out float facing;
#endif
#ifdef ANTI_ALIASING
#define Z_OFFSET -0.0005
#else
#define Z_OFFSET 0.0
#endif
/* Some bugged AMD drivers need these global variables. See T55961 */
#ifdef VERTEX_SELECTION
vec3 vertex_color[3];
#endif
#ifdef VERTEX_FACING
float v_facing[3];
#endif
/* project to screen space */
vec2 proj(vec4 pos)
{
return (0.5 * (pos.xy / pos.w) + 0.5) * viewportSize;
}
void doVertex(int v)
{
#ifdef VERTEX_SELECTION
vertexColor = vertex_color[v];
#endif
#ifdef VERTEX_FACING
facing = v_facing[v];
#endif
gl_Position = pPos[v];
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_set_clip_distance(gl_in[v].gl_ClipDistance);
#endif
EmitVertex();
}
void doVertexOfs(int v, vec2 fixvec)
{
#ifdef VERTEX_SELECTION
vertexColor = vertex_color[v];
#endif
#ifdef VERTEX_FACING
facing = v_facing[v];
#endif
float z_ofs = Z_OFFSET * ((ProjectionMatrix[3][3] == 0.0) ? 1.0 : 0.0);
gl_Position = pPos[v] + vec4(fixvec * pPos[v].w, z_ofs, 0.0);
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_set_clip_distance(gl_in[v].gl_ClipDistance);
#endif
EmitVertex();
}
void mask_edge_flag(int v, ivec3 eflag)
{
int vaf = (v + 1) % 3;
/* Only shade the edge that we are currently drawing.
* (fix corner bleeding) */
flag = eflag;
flag[vaf] &= ~EDGE_EXISTS;
flag[v] &= ~EDGE_EXISTS;
}
vec2 compute_fixvec(int i)
{
int i1 = (i + 1) % 3;
int i2 = (i + 2) % 3;
/* This fix the case when 2 vertices are perfectly aligned
* and corner vectors have nowhere to go.
* ie: length(cornervec[i]) == 0 */
const float epsilon = 1e-2; /* in pixel so not that much */
const vec2 bias[3] = vec2[3](
vec2( epsilon, epsilon),
vec2(-epsilon, epsilon),
vec2( 0.0, -epsilon)
);
vec2 v1 = ssPos[i] + bias[i];
vec2 v2 = ssPos[i1] + bias[i1];
vec2 v3 = ssPos[i2] + bias[i2];
/* Edge normalized vector */
vec2 dir = normalize(v2 - v1);
vec2 dir2 = normalize(v3 - v1);
/* perpendicular to dir */
vec2 perp = vec2(-dir.y, dir.x);
/* Backface case */
if (dot(perp, dir2) > 0.0) {
perp = -perp;
}
/* Make it view independent */
return perp * sizeEdgeFix / viewportSize;
}
void main()
{
/* Edge */
ivec3 eflag;
for (int v = 0; v < 3; ++v) {
eflag[v] = vData[v].y | (vData[v].x << 8);
edgesCrease[v] = vData[v].z / 255.0;
edgesBweight[v] = vData[v].w / 255.0;
}
/* Face */
vec4 fcol;
if ((vData[0].x & FACE_ACTIVE) != 0) {
fcol = colorFaceSelect;
}
else if ((vData[0].x & FACE_SELECTED) != 0) {
fcol = colorFaceSelect;
}
else if ((vData[0].x & FACE_FREESTYLE) != 0) {
fcol = colorFaceFreestyle;
}
else {
fcol = colorFace;
}
/* Vertex */
ssPos[0] = proj(pPos[0]);
ssPos[1] = proj(pPos[1]);
ssPos[2] = proj(pPos[2]);
#ifdef VERTEX_SELECTION
vertex_color[0] = EDIT_MESH_vertex_color(vData[0].x).rgb;
vertex_color[1] = EDIT_MESH_vertex_color(vData[1].x).rgb;
vertex_color[2] = EDIT_MESH_vertex_color(vData[2].x).rgb;
#endif
#ifdef VERTEX_FACING
/* Weird but some buggy AMD drivers need this. */
v_facing[0] = vFacing[0];
v_facing[1] = vFacing[1];
v_facing[2] = vFacing[2];
#endif
/* Remember that we are assuming the last vertex
* of a triangle is the provoking vertex (decide what flat attributes are). */
if ((eflag[2] & EDGE_EXISTS) != 0) {
/* Do 0 -> 1 edge strip */
faceColor = vec4(fcol.rgb, 0.0);
mask_edge_flag(0, eflag);
vec2 fixvec = compute_fixvec(0);
doVertexOfs(0, fixvec);
doVertexOfs(1, fixvec);
}
doVertex(0);
doVertex(1);
/* Do face triangle */
faceColor = fcol;
flag = (isXray) ? ivec3(0) : eflag;
doVertex(2);
faceColor.a = 0.0; /* to not let face color bleed */
if ((eflag[0] & EDGE_EXISTS) != 0) {
/* Do 1 -> 2 edge strip */
mask_edge_flag(1, eflag);
vec2 fixvec = compute_fixvec(1);
doVertexOfs(1, fixvec);
doVertexOfs(2, fixvec);
}
EndPrimitive();
if ((eflag[1] & EDGE_EXISTS) != 0) {
/* Do 2 -> 0 edge strip */
mask_edge_flag(2, eflag);
doVertex(2);
doVertex(0);
vec2 fixvec = compute_fixvec(2);
doVertexOfs(2, fixvec);
doVertexOfs(0, fixvec);
EndPrimitive();
}
}

View File

@ -1,56 +0,0 @@
uniform mat3 NormalMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
uniform float ofs = 3e-5;
in vec3 pos;
in ivec4 data;
#ifdef VERTEX_FACING
in vec3 vnor;
#endif
out vec4 finalColor;
void main()
{
finalColor = colorVertex;
finalColor = ((data.x & VERTEX_SELECTED) != 0) ? colorVertexSelect : finalColor;
finalColor = ((data.x & VERTEX_ACTIVE) != 0) ? vec4(colorEditMeshActive.xyz, 1.0) : finalColor;
gl_PointSize = sizeVertex * 2.0;
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
gl_Position.z -= ofs * ((ProjectionMatrix[3][3] == 0.0) ? 1.0 : 0.0);
/* Make selected and active vertex always on top. */
if ((data.x & VERTEX_SELECTED) != 0) {
gl_Position.z -= 1e-7;
}
if ((data.x & VERTEX_ACTIVE) != 0) {
gl_Position.z -= 1e-7;
}
#ifdef VERTEX_FACING
vec4 vPos = ModelViewMatrix * vec4(pos, 1.0);
vec3 view_normal = normalize(NormalMatrix * vnor);
vec3 view_vec = (ProjectionMatrix[3][3] == 0.0)
? normalize(vPos.xyz)
: vec3(0.0, 0.0, 1.0);
float facing = dot(view_vec, view_normal);
facing = 1.0 - abs(facing) * 0.4;
finalColor = mix(colorEditMeshMiddle, finalColor, facing);
finalColor.a = 1.0;
#endif
if ((data.x & VERTEX_EXISTS) == 0) {
gl_Position = vec4(0.0);
gl_PointSize = 0.0;
}
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}