Fix drawing of planar transfrom manipulators, update matrix code
This commit is contained in:
@@ -44,6 +44,8 @@
|
|||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
|
#include "GPU_matrix.h"
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
#include "RNA_access.h"
|
#include "RNA_access.h"
|
||||||
@@ -73,12 +75,12 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float origin[2])
|
|||||||
const float len = arrow->line_len;
|
const float len = arrow->line_len;
|
||||||
const float draw_line_ofs = (arrow->manipulator.line_width * 0.5f) / arrow->manipulator.scale;
|
const float draw_line_ofs = (arrow->manipulator.line_width * 0.5f) / arrow->manipulator.scale;
|
||||||
|
|
||||||
glPushMatrix();
|
gpuPushMatrix();
|
||||||
glTranslatef(UNPACK2(origin), 0.0f);
|
gpuTranslate3f(UNPACK2(origin), 0.0f);
|
||||||
glScalef(arrow->manipulator.scale, arrow->manipulator.scale, 0.0f);
|
gpuScale3f(arrow->manipulator.scale, arrow->manipulator.scale, 0.0f);
|
||||||
glRotatef(RAD2DEGF(arrow->angle), 0.0f, 0.0f, 1.0f);
|
gpuRotate3f(RAD2DEGF(arrow->angle), 0.0f, 0.0f, 1.0f);
|
||||||
/* local offset */
|
/* local offset */
|
||||||
glTranslatef(arrow->manipulator.offset[0] + draw_line_ofs, arrow->manipulator.offset[1], 0.0f);
|
gpuTranslate3f(arrow->manipulator.offset[0] + draw_line_ofs, arrow->manipulator.offset[1], 0.0f);
|
||||||
|
|
||||||
/* TODO get rid of immediate mode */
|
/* TODO get rid of immediate mode */
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
@@ -91,7 +93,7 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float origin[2])
|
|||||||
glVertex2f(0.0f, len + size * 1.7f);
|
glVertex2f(0.0f, len + size * 1.7f);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glPopMatrix();
|
gpuPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manipulator_arrow2d_draw(const bContext *UNUSED(C), struct wmManipulator *manipulator)
|
static void manipulator_arrow2d_draw(const bContext *UNUSED(C), struct wmManipulator *manipulator)
|
||||||
|
@@ -101,9 +101,12 @@ static void manipulator_arrow_get_final_pos(wmManipulator *manipulator, float r_
|
|||||||
|
|
||||||
static void arrow_draw_geom(const ArrowManipulator *arrow, const bool select, const float color[4])
|
static void arrow_draw_geom(const ArrowManipulator *arrow, const bool select, const float color[4])
|
||||||
{
|
{
|
||||||
|
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||||
|
bool unbind_shader = true;
|
||||||
|
|
||||||
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||||
|
|
||||||
if (arrow->style & MANIPULATOR_ARROW_STYLE_CROSS) {
|
if (arrow->style & MANIPULATOR_ARROW_STYLE_CROSS) {
|
||||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
||||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
|
||||||
immUniformColor4fv(color);
|
immUniformColor4fv(color);
|
||||||
|
|
||||||
immBegin(GL_LINES, 4);
|
immBegin(GL_LINES, 4);
|
||||||
@@ -112,8 +115,6 @@ static void arrow_draw_geom(const ArrowManipulator *arrow, const bool select, co
|
|||||||
immVertex2f(pos, 0.f, -1.0);
|
immVertex2f(pos, 0.f, -1.0);
|
||||||
immVertex2f(pos, 0.f, 1.0);
|
immVertex2f(pos, 0.f, 1.0);
|
||||||
immEnd();
|
immEnd();
|
||||||
|
|
||||||
immUnbindProgram();
|
|
||||||
}
|
}
|
||||||
else if (arrow->style & MANIPULATOR_ARROW_STYLE_CONE) {
|
else if (arrow->style & MANIPULATOR_ARROW_STYLE_CONE) {
|
||||||
const float unitx = arrow->aspect[0];
|
const float unitx = arrow->aspect[0];
|
||||||
@@ -125,32 +126,13 @@ static void arrow_draw_geom(const ArrowManipulator *arrow, const bool select, co
|
|||||||
{-unitx, unity, 0},
|
{-unitx, unity, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
|
||||||
|
|
||||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
|
||||||
immUniformColor4fv(color);
|
|
||||||
|
|
||||||
glLineWidth(arrow->manipulator.line_width);
|
glLineWidth(arrow->manipulator.line_width);
|
||||||
|
wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, PRIM_LINE_STRIP);
|
||||||
const int vec_size = ARRAY_SIZE(vec);
|
|
||||||
immBegin(PRIM_LINE_STRIP, vec_size);
|
|
||||||
for (int i = 0; i < vec_size; i++) {
|
|
||||||
immVertex3fv(pos, vec[i]);
|
|
||||||
}
|
|
||||||
immEnd();
|
|
||||||
|
|
||||||
glLineWidth(1.0);
|
|
||||||
immUnbindProgram();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef USE_MANIPULATOR_CUSTOM_ARROWS
|
#ifdef USE_MANIPULATOR_CUSTOM_ARROWS
|
||||||
wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_arrow, select, color);
|
wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_arrow, select, color);
|
||||||
#else
|
#else
|
||||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
|
||||||
|
|
||||||
immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR);
|
|
||||||
immUniformColor4fv(color);
|
|
||||||
|
|
||||||
const float vec[2][3] = {
|
const float vec[2][3] = {
|
||||||
{0.0f, 0.0f, 0.0f},
|
{0.0f, 0.0f, 0.0f},
|
||||||
@@ -158,15 +140,8 @@ static void arrow_draw_geom(const ArrowManipulator *arrow, const bool select, co
|
|||||||
};
|
};
|
||||||
|
|
||||||
glLineWidth(arrow->manipulator.line_width);
|
glLineWidth(arrow->manipulator.line_width);
|
||||||
|
wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, PRIM_LINE_STRIP);
|
||||||
|
|
||||||
const int vec_size = ARRAY_SIZE(vec);
|
|
||||||
immBegin(PRIM_LINE_STRIP, vec_size);
|
|
||||||
for (int i = 0; i < vec_size; i++) {
|
|
||||||
immVertex3fv(pos, vec[i]);
|
|
||||||
}
|
|
||||||
immEnd();
|
|
||||||
|
|
||||||
glLineWidth(1.0);
|
|
||||||
|
|
||||||
/* *** draw arrow head *** */
|
/* *** draw arrow head *** */
|
||||||
|
|
||||||
@@ -182,6 +157,7 @@ static void arrow_draw_geom(const ArrowManipulator *arrow, const bool select, co
|
|||||||
|
|
||||||
/* draw cube */
|
/* draw cube */
|
||||||
immUnbindProgram();
|
immUnbindProgram();
|
||||||
|
unbind_shader = false;
|
||||||
wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_cube, select, color);
|
wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_cube, select, color);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -202,14 +178,15 @@ static void arrow_draw_geom(const ArrowManipulator *arrow, const bool select, co
|
|||||||
if (use_lighting) {
|
if (use_lighting) {
|
||||||
glShadeModel(GL_FLAT);
|
glShadeModel(GL_FLAT);
|
||||||
}
|
}
|
||||||
immUnbindProgram();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpuPopMatrix();
|
gpuPopMatrix();
|
||||||
|
|
||||||
|
|
||||||
#endif /* USE_MANIPULATOR_CUSTOM_ARROWS */
|
#endif /* USE_MANIPULATOR_CUSTOM_ARROWS */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unbind_shader) {
|
||||||
|
immUnbindProgram();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arrow_draw_intern(ArrowManipulator *arrow, const bool select, const bool highlight)
|
static void arrow_draw_intern(ArrowManipulator *arrow, const bool select, const bool highlight)
|
||||||
|
@@ -45,6 +45,8 @@
|
|||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
|
#include "GPU_matrix.h"
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
#include "RNA_access.h"
|
#include "RNA_access.h"
|
||||||
@@ -187,13 +189,13 @@ static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipul
|
|||||||
r.xmax = half_w;
|
r.xmax = half_w;
|
||||||
r.ymax = half_h;
|
r.ymax = half_h;
|
||||||
|
|
||||||
glPushMatrix();
|
gpuPushMatrix();
|
||||||
glTranslatef(manipulator->origin[0] + manipulator->offset[0],
|
gpuTranslate3f(manipulator->origin[0] + manipulator->offset[0],
|
||||||
manipulator->origin[1] + manipulator->offset[1], 0.0f);
|
manipulator->origin[1] + manipulator->offset[1], 0.0f);
|
||||||
if (cage->style & MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM)
|
if (cage->style & MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM)
|
||||||
glScalef(cage->scale[0], cage->scale[0], 1.0);
|
gpuScale3f(cage->scale[0], cage->scale[0], 1.0);
|
||||||
else
|
else
|
||||||
glScalef(cage->scale[0], cage->scale[1], 1.0);
|
gpuScale3f(cage->scale[0], cage->scale[1], 1.0);
|
||||||
|
|
||||||
if (w > h)
|
if (w > h)
|
||||||
aspx = h / w;
|
aspx = h / w;
|
||||||
@@ -218,7 +220,7 @@ static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipul
|
|||||||
w, h, cage->manipulator.line_width);
|
w, h, cage->manipulator.line_width);
|
||||||
|
|
||||||
glLineWidth(1.0);
|
glLineWidth(1.0);
|
||||||
glPopMatrix();
|
gpuPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int manipulator_rect_transform_get_cursor(wmManipulator *manipulator)
|
static int manipulator_rect_transform_get_cursor(wmManipulator *manipulator)
|
||||||
|
@@ -38,6 +38,8 @@
|
|||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
#include "DNA_manipulator_types.h"
|
#include "DNA_manipulator_types.h"
|
||||||
|
|
||||||
|
#include "GPU_immediate.h"
|
||||||
|
#include "GPU_matrix.h"
|
||||||
#include "GPU_select.h"
|
#include "GPU_select.h"
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
@@ -83,19 +85,17 @@ static void manipulator_primitive_draw_geom(
|
|||||||
{
|
{
|
||||||
float (*verts)[3];
|
float (*verts)[3];
|
||||||
float vert_count;
|
float vert_count;
|
||||||
|
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||||
|
|
||||||
if (style == MANIPULATOR_PRIMITIVE_STYLE_PLANE) {
|
if (style == MANIPULATOR_PRIMITIVE_STYLE_PLANE) {
|
||||||
verts = verts_plane;
|
verts = verts_plane;
|
||||||
vert_count = ARRAY_SIZE(verts_plane);
|
vert_count = ARRAY_SIZE(verts_plane);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||||
glVertexPointer(3, GL_FLOAT, 0, verts);
|
wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, PRIM_QUADS);
|
||||||
glColor4fv(col_inner);
|
wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, PRIM_LINE_LOOP);
|
||||||
glDrawArrays(GL_QUADS, 0, vert_count);
|
immUnbindProgram();
|
||||||
glColor4fv(col_outer);
|
|
||||||
glDrawArrays(GL_LINE_LOOP, 0, vert_count);
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manipulator_primitive_draw_intern(
|
static void manipulator_primitive_draw_intern(
|
||||||
@@ -120,19 +120,19 @@ static void manipulator_primitive_draw_intern(
|
|||||||
copy_v3_v3(mat[3], prim->manipulator.origin);
|
copy_v3_v3(mat[3], prim->manipulator.origin);
|
||||||
mul_mat3_m4_fl(mat, prim->manipulator.scale);
|
mul_mat3_m4_fl(mat, prim->manipulator.scale);
|
||||||
|
|
||||||
glPushMatrix();
|
gpuPushMatrix();
|
||||||
glMultMatrixf(mat);
|
gpuMultMatrix3D(mat);
|
||||||
|
|
||||||
manipulator_color_get(&prim->manipulator, highlight, col_outer);
|
manipulator_color_get(&prim->manipulator, highlight, col_outer);
|
||||||
copy_v4_v4(col_inner, col_outer);
|
copy_v4_v4(col_inner, col_outer);
|
||||||
col_inner[3] *= 0.5f;
|
col_inner[3] *= 0.5f;
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glTranslatef(UNPACK3(prim->manipulator.offset));
|
gpuTranslate3fv(prim->manipulator.offset);
|
||||||
manipulator_primitive_draw_geom(col_inner, col_outer, prim->style);
|
manipulator_primitive_draw_geom(col_inner, col_outer, prim->style);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
glPopMatrix();
|
gpuPopMatrix();
|
||||||
|
|
||||||
if (prim->manipulator.interaction_data) {
|
if (prim->manipulator.interaction_data) {
|
||||||
ManipulatorInteraction *inter = prim->manipulator.interaction_data;
|
ManipulatorInteraction *inter = prim->manipulator.interaction_data;
|
||||||
@@ -145,15 +145,15 @@ static void manipulator_primitive_draw_intern(
|
|||||||
copy_v3_v3(mat[3], inter->init_origin);
|
copy_v3_v3(mat[3], inter->init_origin);
|
||||||
mul_mat3_m4_fl(mat, inter->init_scale);
|
mul_mat3_m4_fl(mat, inter->init_scale);
|
||||||
|
|
||||||
glPushMatrix();
|
gpuPushMatrix();
|
||||||
glMultMatrixf(mat);
|
gpuMultMatrix3D(mat);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glTranslatef(UNPACK3(prim->manipulator.offset));
|
gpuTranslate3f(UNPACK3(prim->manipulator.offset));
|
||||||
manipulator_primitive_draw_geom(col_inner, col_outer, prim->style);
|
manipulator_primitive_draw_geom(col_inner, col_outer, prim->style);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
glPopMatrix();
|
gpuPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include "GPU_batch.h"
|
#include "GPU_batch.h"
|
||||||
#include "GPU_glew.h"
|
#include "GPU_glew.h"
|
||||||
|
#include "GPU_immediate.h"
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
@@ -112,6 +113,18 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo
|
|||||||
Batch_discard_all(batch);
|
Batch_discard_all(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wm_manipulator_vec_draw(
|
||||||
|
const float color[4], const float (*verts)[3], unsigned int vert_count,
|
||||||
|
unsigned int pos, unsigned int primitive_type)
|
||||||
|
{
|
||||||
|
immUniformColor4fv(color);
|
||||||
|
immBegin(primitive_type, vert_count);
|
||||||
|
for (int i = 0; i < vert_count; i++) {
|
||||||
|
immVertex3fv(pos, verts[i]);
|
||||||
|
}
|
||||||
|
immEnd();
|
||||||
|
}
|
||||||
|
|
||||||
/* Still unused */
|
/* Still unused */
|
||||||
wmManipulator *WM_manipulator_new(
|
wmManipulator *WM_manipulator_new(
|
||||||
void (*draw)(const bContext *C, wmManipulator *customdata),
|
void (*draw)(const bContext *C, wmManipulator *customdata),
|
||||||
|
@@ -219,6 +219,9 @@ bool wm_manipulatormap_deselect_all(struct wmManipulatorMap *mmap, struct wmMani
|
|||||||
/* Manipulator drawing */
|
/* Manipulator drawing */
|
||||||
|
|
||||||
void wm_manipulator_geometryinfo_draw(const struct ManipulatorGeomInfo *info, const bool select, const float color[4]);
|
void wm_manipulator_geometryinfo_draw(const struct ManipulatorGeomInfo *info, const bool select, const float color[4]);
|
||||||
|
void wm_manipulator_vec_draw(
|
||||||
|
const float color[4], const float (*verts)[3], unsigned int vert_count,
|
||||||
|
unsigned int pos, unsigned int primitive_type);
|
||||||
|
|
||||||
#endif /* __WM_MANIPULATOR_INTERN_H__ */
|
#endif /* __WM_MANIPULATOR_INTERN_H__ */
|
||||||
|
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
#include "ED_view3d.h"
|
#include "ED_view3d.h"
|
||||||
|
|
||||||
#include "GPU_glew.h"
|
#include "GPU_glew.h"
|
||||||
|
#include "GPU_matrix.h"
|
||||||
#include "GPU_select.h"
|
#include "GPU_select.h"
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
@@ -256,11 +257,11 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext
|
|||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||||
glPushMatrix();
|
gpuPushMatrix();
|
||||||
glLoadIdentity();
|
gpuLoadIdentity();
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
|
glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
|
||||||
glPopMatrix();
|
gpuPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw_manipulators contains all visible manipulators - draw them */
|
/* draw_manipulators contains all visible manipulators - draw them */
|
||||||
|
Reference in New Issue
Block a user