Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache.c
| Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
| #define VCLASS_EMPTY_AXES_SHADOW (1 << 13) | #define VCLASS_EMPTY_AXES_SHADOW (1 << 13) | ||||
| #define VCLASS_EMPTY_SIZE (1 << 14) | #define VCLASS_EMPTY_SIZE (1 << 14) | ||||
| typedef struct Vert { | typedef struct Vert { | ||||
| float pos[3]; | float pos[3]; | ||||
| int class; | int class; | ||||
| } Vert; | } Vert; | ||||
| typedef struct VertShaded { | |||||
| float pos[3]; | |||||
| int class; | |||||
| float nor[3]; | |||||
| } VertShaded; | |||||
| /* Batch's only (free'd as an array) */ | /* Batch's only (free'd as an array) */ | ||||
| static struct DRWShapeCache { | static struct DRWShapeCache { | ||||
| GPUBatch *drw_procedural_verts; | GPUBatch *drw_procedural_verts; | ||||
| GPUBatch *drw_procedural_lines; | GPUBatch *drw_procedural_lines; | ||||
| GPUBatch *drw_procedural_tris; | GPUBatch *drw_procedural_tris; | ||||
| GPUBatch *drw_cursor; | GPUBatch *drw_cursor; | ||||
| GPUBatch *drw_cursor_only_circle; | GPUBatch *drw_cursor_only_circle; | ||||
| GPUBatch *drw_fullscreen_quad; | GPUBatch *drw_fullscreen_quad; | ||||
| GPUBatch *drw_quad; | GPUBatch *drw_quad; | ||||
| GPUBatch *drw_quad_wires; | GPUBatch *drw_quad_wires; | ||||
| GPUBatch *drw_grid; | GPUBatch *drw_grid; | ||||
| GPUBatch *drw_sphere; | GPUBatch *drw_sphere; | ||||
| GPUBatch *drw_plain_axes; | GPUBatch *drw_plain_axes; | ||||
jbakker: remove this on it is not used anymore | |||||
| GPUBatch *drw_single_arrow; | GPUBatch *drw_single_arrow; | ||||
| GPUBatch *drw_cube; | GPUBatch *drw_cube; | ||||
| GPUBatch *drw_circle; | GPUBatch *drw_circle; | ||||
| GPUBatch *drw_normal_arrow; | GPUBatch *drw_normal_arrow; | ||||
| GPUBatch *drw_empty_cube; | GPUBatch *drw_empty_cube; | ||||
| GPUBatch *drw_empty_sphere; | GPUBatch *drw_empty_sphere; | ||||
| GPUBatch *drw_empty_cylinder; | GPUBatch *drw_empty_cylinder; | ||||
| GPUBatch *drw_empty_capsule_body; | GPUBatch *drw_empty_capsule_body; | ||||
| ▲ Show 20 Lines • Show All 374 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* Sphere */ | /* Sphere */ | ||||
| static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lon) | static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lon) | ||||
| { | { | ||||
| float x = sinf(lat) * cosf(lon); | float x = sinf(lat) * cosf(lon); | ||||
| float y = cosf(lat); | float y = cosf(lat); | ||||
| float z = sinf(lat) * sinf(lon); | float z = sinf(lat) * sinf(lon); | ||||
| GPU_vertbuf_vert_set(vbo, *v_ofs, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED}); | GPU_vertbuf_vert_set(vbo, *v_ofs, &(VertShaded){{x, y, z}, VCLASS_EMPTY_SCALED, {x, y, z}}); | ||||
| (*v_ofs)++; | (*v_ofs)++; | ||||
| } | } | ||||
| GPUBatch *DRW_cache_sphere_get(void) | GPUBatch *DRW_cache_sphere_get(void) | ||||
| { | { | ||||
| if (!SHC.drw_sphere) { | if (!SHC.drw_sphere) { | ||||
| const int lat_res = 32; | const int lat_res = 32; | ||||
| const int lon_res = 24; | const int lon_res = 24; | ||||
| GPUVertFormat format = extra_vert_format(); | GPUVertFormat format = extra_vert_format(); | ||||
| GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | |||||
| GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); | GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); | ||||
| int v_len = (lat_res - 1) * lon_res * 6; | int v_len = (lat_res - 1) * lon_res * 6; | ||||
| GPU_vertbuf_data_alloc(vbo, v_len); | GPU_vertbuf_data_alloc(vbo, v_len); | ||||
| const float lon_inc = 2 * M_PI / lon_res; | const float lon_inc = 2 * M_PI / lon_res; | ||||
| const float lat_inc = M_PI / lat_res; | const float lat_inc = M_PI / lat_res; | ||||
| float lon, lat; | float lon, lat; | ||||
| ▲ Show 20 Lines • Show All 2,963 Lines • Show Last 20 Lines | |||||
remove this on it is not used anymore