Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_immediate_util.c
| Show First 20 Lines • Show All 596 Lines • ▼ Show 20 Lines | for (int j = 0; j < stacks; j++) { | ||||
| /* second tri */ | /* second tri */ | ||||
| immVertex3fv(pos, v3); | immVertex3fv(pos, v3); | ||||
| immVertex3fv(pos, v4); | immVertex3fv(pos, v4); | ||||
| immVertex3fv(pos, v1); | immVertex3fv(pos, v1); | ||||
| } | } | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| } | } | ||||
| /* OpenGL Circle Drawing - Tables for Optimized Drawing Speed */ | |||||
| /* 32 values of sin function (still same result!) */ | |||||
| #define CIRCLE_RESOL 32 | |||||
| static const float sinval[CIRCLE_RESOL] = { | |||||
| 0.00000000, 0.20129852, 0.39435585, 0.57126821, 0.72479278, 0.84864425, 0.93775213, | |||||
| 0.98846832, 0.99871650, 0.96807711, 0.89780453, 0.79077573, 0.65137248, 0.48530196, | |||||
| 0.29936312, 0.10116832, -0.10116832, -0.29936312, -0.48530196, -0.65137248, -0.79077573, | |||||
| -0.89780453, -0.96807711, -0.99871650, -0.98846832, -0.93775213, -0.84864425, -0.72479278, | |||||
| -0.57126821, -0.39435585, -0.20129852, 0.00000000, | |||||
| }; | |||||
| /* 32 values of cos function (still same result!) */ | |||||
| static const float cosval[CIRCLE_RESOL] = { | |||||
| 1.00000000, 0.97952994, 0.91895781, 0.82076344, 0.68896691, 0.52896401, 0.34730525, | |||||
| 0.15142777, -0.05064916, -0.25065253, -0.44039415, -0.61210598, -0.75875812, -0.87434661, | |||||
| -0.95413925, -0.99486932, -0.99486932, -0.95413925, -0.87434661, -0.75875812, -0.61210598, | |||||
| -0.44039415, -0.25065253, -0.05064916, 0.15142777, 0.34730525, 0.52896401, 0.68896691, | |||||
| 0.82076344, 0.91895781, 0.97952994, 1.00000000, | |||||
| }; | |||||
| static void circball_array_fill(const float verts[CIRCLE_RESOL][3], | |||||
| const float cent[3], | |||||
| float rad, | |||||
| const float tmat[4][4]) | |||||
| { | |||||
| float vx[3], vy[3]; | |||||
| float *viter = (float *)verts; | |||||
| mul_v3_v3fl(vx, tmat[0], rad); | |||||
| mul_v3_v3fl(vy, tmat[1], rad); | |||||
| for (uint a = 0; a < CIRCLE_RESOL; a++, viter += 3) { | |||||
| viter[0] = cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0]; | |||||
| viter[1] = cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1]; | |||||
| viter[2] = cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2]; | |||||
| } | |||||
| } | |||||
| void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], uint pos) | |||||
| { | |||||
| float verts[CIRCLE_RESOL][3]; | |||||
| circball_array_fill(verts, cent, rad, tmat); | |||||
| immBegin(GPU_PRIM_LINE_LOOP, CIRCLE_RESOL); | |||||
| for (int i = 0; i < CIRCLE_RESOL; i++) { | |||||
| immVertex3fv(pos, verts[i]); | |||||
| } | |||||
| immEnd(); | |||||
| } | |||||
| void imm_drawX(const float cent[3], float size, const float tmat[4][4], uint pos) | |||||
| { | |||||
| /* Draw an "X" indicating where the previous snap point is. | |||||
| * This is useful for indicating perpendicular snap. */ | |||||
| /* v1, v2, v3 and v4 indicate the coordinates of the ends of the "X". */ | |||||
| float vx[3], vy[3], v1[3], v2[3], v3[3], v4[4]; | |||||
| mul_v3_v3fl(vx, tmat[0], size); | |||||
| mul_v3_v3fl(vy, tmat[1], size); | |||||
| add_v3_v3v3(v1, vx, vy); | |||||
| sub_v3_v3v3(v2, vx, vy); | |||||
| negate_v3_v3(v3, v1); | |||||
| negate_v3_v3(v4, v2); | |||||
| add_v3_v3(v1, cent); | |||||
| add_v3_v3(v2, cent); | |||||
| add_v3_v3(v3, cent); | |||||
| add_v3_v3(v4, cent); | |||||
| immBegin(GPU_PRIM_LINES, 4); | |||||
| immVertex3fv(pos, v3); | |||||
| immVertex3fv(pos, v1); | |||||
| immVertex3fv(pos, v4); | |||||
| immVertex3fv(pos, v2); | |||||
| immEnd(); | |||||
| } | |||||
| No newline at end of file | |||||