Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/modes/object_mode.c
| Show All 25 Lines | |||||
| #include "DRW_engine.h" | #include "DRW_engine.h" | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_camera_types.h" | #include "DNA_camera_types.h" | ||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meta_types.h" | |||||
| #include "DNA_object_force.h" | #include "DNA_object_force.h" | ||||
| #include "DNA_lightprobe_types.h" | #include "DNA_lightprobe_types.h" | ||||
| #include "DNA_particle_types.h" | #include "DNA_particle_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_mball.h" | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_texture.h" | #include "BKE_texture.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | typedef struct OBJECT_PrivateData { | ||||
| /* Speaker */ | /* Speaker */ | ||||
| DRWShadingGroup *speaker; | DRWShadingGroup *speaker; | ||||
| /* Probe */ | /* Probe */ | ||||
| DRWShadingGroup *probe_cube; | DRWShadingGroup *probe_cube; | ||||
| DRWShadingGroup *probe_planar; | DRWShadingGroup *probe_planar; | ||||
| DRWShadingGroup *probe_grid; | DRWShadingGroup *probe_grid; | ||||
| /* MetaBalls */ | |||||
| DRWShadingGroup *mball_circle; | |||||
| /* Lamps */ | /* Lamps */ | ||||
| DRWShadingGroup *lamp_center; | DRWShadingGroup *lamp_center; | ||||
| DRWShadingGroup *lamp_center_group; | DRWShadingGroup *lamp_center_group; | ||||
| DRWShadingGroup *lamp_groundpoint; | DRWShadingGroup *lamp_groundpoint; | ||||
| DRWShadingGroup *lamp_groundline; | DRWShadingGroup *lamp_groundline; | ||||
| DRWShadingGroup *lamp_circle; | DRWShadingGroup *lamp_circle; | ||||
| DRWShadingGroup *lamp_circle_shadow; | DRWShadingGroup *lamp_circle_shadow; | ||||
| DRWShadingGroup *lamp_sunrays; | DRWShadingGroup *lamp_sunrays; | ||||
| ▲ Show 20 Lines • Show All 785 Lines • ▼ Show 20 Lines | if (!stl->g_data) { | ||||
| stl->g_data->wire_transform = shgroup_wire(psl->non_meshes, ts.colorTransform, sh); | stl->g_data->wire_transform = shgroup_wire(psl->non_meshes, ts.colorTransform, sh); | ||||
| /* Active */ | /* Active */ | ||||
| stl->g_data->wire_active = shgroup_wire(psl->non_meshes, ts.colorActive, sh); | stl->g_data->wire_active = shgroup_wire(psl->non_meshes, ts.colorActive, sh); | ||||
| stl->g_data->wire_active_group = shgroup_wire(psl->non_meshes, ts.colorGroupActive, sh); | stl->g_data->wire_active_group = shgroup_wire(psl->non_meshes, ts.colorGroupActive, sh); | ||||
| } | } | ||||
| { | { | ||||
| /* Metaballs Helpers */ | |||||
| struct Gwn_Batch *geom; | |||||
| geom = DRW_cache_screenspace_circle_get(); | |||||
| stl->g_data->mball_circle = shgroup_instance_mball_helpers(psl->non_meshes, geom); | |||||
| } | |||||
| { | |||||
| /* Lamps */ | /* Lamps */ | ||||
| /* TODO | /* TODO | ||||
| * for now we create multiple times the same VBO with only lamp center coordinates | * for now we create multiple times the same VBO with only lamp center coordinates | ||||
| * but ideally we would only create it once */ | * but ideally we would only create it once */ | ||||
| struct Gwn_Batch *geom; | struct Gwn_Batch *geom; | ||||
| /* start with buflimit because we don't want stipples */ | /* start with buflimit because we don't want stipples */ | ||||
| geom = DRW_cache_single_line_get(); | geom = DRW_cache_single_line_get(); | ||||
| ▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | static void OBJECT_cache_init(void *vedata) | ||||
| { | { | ||||
| /* Empty/Background Image Pass */ | /* Empty/Background Image Pass */ | ||||
| psl->reference_image = DRW_pass_create( | psl->reference_image = DRW_pass_create( | ||||
| "Refrence Image Pass", | "Refrence Image Pass", | ||||
| DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND); | DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND); | ||||
| } | } | ||||
| } | } | ||||
| static void DRW_shgroup_mball_helpers(OBJECT_StorageList *stl, Object *ob, SceneLayer *scene_layer) | |||||
| { | |||||
| MetaBall *mb = ob->data; | |||||
| float *color; | |||||
| DRW_object_wire_theme_get(ob, scene_layer, &color); | |||||
| for (MetaElem *ml = mb->elems.first; ml != NULL; ml = ml->next) { | |||||
| /* draw radius */ | |||||
| BKE_mball_element_calc_display_m3x4(ml->draw_scale_xform, ob->obmat, &ml->x); | |||||
| DRW_shgroup_call_dynamic_add(stl->g_data->mball_circle, ml->draw_scale_xform, &ml->rad, color); | |||||
| } | |||||
| } | |||||
| static void DRW_shgroup_lamp(OBJECT_StorageList *stl, Object *ob, SceneLayer *scene_layer) | static void DRW_shgroup_lamp(OBJECT_StorageList *stl, Object *ob, SceneLayer *scene_layer) | ||||
| { | { | ||||
| Lamp *la = ob->data; | Lamp *la = ob->data; | ||||
| float *color; | float *color; | ||||
| int theme_id = DRW_object_wire_theme_get(ob, scene_layer, &color); | int theme_id = DRW_object_wire_theme_get(ob, scene_layer, &color); | ||||
| static float zero = 0.0f; | static float zero = 0.0f; | ||||
| float **la_mats = (float **)DRW_object_engine_data_get(ob, &draw_engine_object_type, NULL); | float **la_mats = (float **)DRW_object_engine_data_get(ob, &draw_engine_object_type, NULL); | ||||
| ▲ Show 20 Lines • Show All 719 Lines • ▼ Show 20 Lines | case OB_CURVE: | ||||
| if (theme_id == TH_UNDEFINED) { | if (theme_id == TH_UNDEFINED) { | ||||
| theme_id = DRW_object_wire_theme_get(ob, scene_layer, NULL); | theme_id = DRW_object_wire_theme_get(ob, scene_layer, NULL); | ||||
| } | } | ||||
| DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); | DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); | ||||
| DRW_shgroup_call_add(shgroup, geom, ob->obmat); | DRW_shgroup_call_add(shgroup, geom, ob->obmat); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case OB_MBALL: | |||||
| { | |||||
| Object *obedit = scene->obedit; | |||||
| if (ob != obedit) { | |||||
| DRW_shgroup_mball_helpers(stl, ob, scene_layer); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case OB_LAMP: | case OB_LAMP: | ||||
| DRW_shgroup_lamp(stl, ob, scene_layer); | DRW_shgroup_lamp(stl, ob, scene_layer); | ||||
| break; | break; | ||||
| case OB_CAMERA: | case OB_CAMERA: | ||||
| DRW_shgroup_camera(stl, ob, scene_layer); | DRW_shgroup_camera(stl, ob, scene_layer); | ||||
| break; | break; | ||||
| case OB_EMPTY: | case OB_EMPTY: | ||||
| DRW_shgroup_empty(stl, psl, ob, scene_layer); | DRW_shgroup_empty(stl, psl, ob, scene_layer); | ||||
| ▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines | |||||