forked from bartvdbraak/blender
Sculpt draw code:
Remove legacy code completely, now dyntopo, multires et al even work on GL 1.1 for really hardcore users :p Real purpose here though is to be able to have fast multires drawing even with VBO off, since it requires using indices for vertex buffers. Also made own code elf puke an eaten normal update function which made multires not update normals in solid mode...sorry.
This commit is contained in:
parent
6568b6d1cd
commit
3e3e7ee41c
@ -666,7 +666,7 @@ static void cdDM_drawMappedFaces(
|
|||||||
unsigned int *fi_map;
|
unsigned int *fi_map;
|
||||||
|
|
||||||
findex_buffer = GPU_buffer_alloc(dm->drawObject->tot_loop_verts * sizeof(int), false);
|
findex_buffer = GPU_buffer_alloc(dm->drawObject->tot_loop_verts * sizeof(int), false);
|
||||||
fi_map = GPU_buffer_lock(findex_buffer);
|
fi_map = GPU_buffer_lock(findex_buffer, GPU_BINDING_ARRAY);
|
||||||
|
|
||||||
if (fi_map) {
|
if (fi_map) {
|
||||||
for (i = 0; i < dm->numTessFaceData; i++, mf++) {
|
for (i = 0; i < dm->numTessFaceData; i++, mf++) {
|
||||||
@ -689,7 +689,7 @@ static void cdDM_drawMappedFaces(
|
|||||||
start_element = 0;
|
start_element = 0;
|
||||||
mf = cddm->mface;
|
mf = cddm->mface;
|
||||||
|
|
||||||
GPU_buffer_unlock(findex_buffer);
|
GPU_buffer_unlock(findex_buffer, GPU_BINDING_ARRAY);
|
||||||
GPU_buffer_bind_as_color(findex_buffer);
|
GPU_buffer_bind_as_color(findex_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1034,7 +1034,7 @@ static void cdDM_drawMappedFacesGLSL(
|
|||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts, true);
|
buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts, true);
|
||||||
}
|
}
|
||||||
varray = GPU_buffer_lock_stream(buffer);
|
varray = GPU_buffer_lock_stream(buffer, GPU_BINDING_ARRAY);
|
||||||
if (varray == NULL) {
|
if (varray == NULL) {
|
||||||
GPU_buffer_unbind();
|
GPU_buffer_unbind();
|
||||||
GPU_buffer_free(buffer);
|
GPU_buffer_free(buffer);
|
||||||
@ -1114,7 +1114,7 @@ static void cdDM_drawMappedFacesGLSL(
|
|||||||
tot_loops += 3;
|
tot_loops += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GPU_buffer_unlock(buffer);
|
GPU_buffer_unlock(buffer, GPU_BINDING_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (a = 0; a < tot_active_mat; a++) {
|
for (a = 0; a < tot_active_mat; a++) {
|
||||||
|
@ -1087,7 +1087,8 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
|
|||||||
GPU_build_grid_pbvh_buffers(node->prim_indices,
|
GPU_build_grid_pbvh_buffers(node->prim_indices,
|
||||||
node->totprim,
|
node->totprim,
|
||||||
bvh->grid_hidden,
|
bvh->grid_hidden,
|
||||||
bvh->gridkey.grid_size);
|
bvh->gridkey.grid_size,
|
||||||
|
&bvh->gridkey);
|
||||||
break;
|
break;
|
||||||
case PBVH_FACES:
|
case PBVH_FACES:
|
||||||
node->draw_buffers =
|
node->draw_buffers =
|
||||||
|
@ -2246,6 +2246,8 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
|
|||||||
int a;
|
int a;
|
||||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||||
|
|
||||||
|
ccgdm_pbvh_update(ccgdm);
|
||||||
|
|
||||||
if (ccgdm->pbvh && ccgdm->multires.mmd) {
|
if (ccgdm->pbvh && ccgdm->multires.mmd) {
|
||||||
if (BKE_pbvh_has_faces(ccgdm->pbvh)) {
|
if (BKE_pbvh_has_faces(ccgdm->pbvh)) {
|
||||||
BKE_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL,
|
BKE_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL,
|
||||||
|
@ -47,6 +47,7 @@ struct DerivedMesh;
|
|||||||
struct GSet;
|
struct GSet;
|
||||||
struct GPUVertPointLink;
|
struct GPUVertPointLink;
|
||||||
struct PBVH;
|
struct PBVH;
|
||||||
|
struct MVert;
|
||||||
|
|
||||||
typedef struct GPUBuffer {
|
typedef struct GPUBuffer {
|
||||||
int size; /* in bytes */
|
int size; /* in bytes */
|
||||||
@ -152,6 +153,9 @@ void GPU_buffer_free(GPUBuffer *buffer);
|
|||||||
|
|
||||||
void GPU_drawobject_free(struct DerivedMesh *dm);
|
void GPU_drawobject_free(struct DerivedMesh *dm);
|
||||||
|
|
||||||
|
/* free special global multires grid buffer */
|
||||||
|
void GPU_buffer_multires_free(bool force);
|
||||||
|
|
||||||
/* flag that controls data type to fill buffer with, a modifier will prepare. */
|
/* flag that controls data type to fill buffer with, a modifier will prepare. */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GPU_BUFFER_VERTEX = 0,
|
GPU_BUFFER_VERTEX = 0,
|
||||||
@ -164,6 +168,10 @@ typedef enum {
|
|||||||
GPU_BUFFER_TRIANGLES
|
GPU_BUFFER_TRIANGLES
|
||||||
} GPUBufferType;
|
} GPUBufferType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPU_BINDING_ARRAY = 0,
|
||||||
|
GPU_BINDING_INDEX = 1,
|
||||||
|
} GPUBindingType;
|
||||||
|
|
||||||
/* called before drawing */
|
/* called before drawing */
|
||||||
void GPU_vertex_setup(struct DerivedMesh *dm);
|
void GPU_vertex_setup(struct DerivedMesh *dm);
|
||||||
@ -181,10 +189,12 @@ void GPU_triangle_setup(struct DerivedMesh *dm);
|
|||||||
int GPU_attrib_element_size(GPUAttrib data[], int numdata);
|
int GPU_attrib_element_size(GPUAttrib data[], int numdata);
|
||||||
void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata, int element_size);
|
void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata, int element_size);
|
||||||
|
|
||||||
|
void GPU_buffer_bind(GPUBuffer *buffer, GPUBindingType binding);
|
||||||
|
|
||||||
/* can't lock more than one buffer at once */
|
/* can't lock more than one buffer at once */
|
||||||
void *GPU_buffer_lock(GPUBuffer *buffer);
|
void *GPU_buffer_lock(GPUBuffer *buffer, GPUBindingType binding);
|
||||||
void *GPU_buffer_lock_stream(GPUBuffer *buffer);
|
void *GPU_buffer_lock_stream(GPUBuffer *buffer, GPUBindingType binding);
|
||||||
void GPU_buffer_unlock(GPUBuffer *buffer);
|
void GPU_buffer_unlock(GPUBuffer *buffer, GPUBindingType binding);
|
||||||
|
|
||||||
/* switch color rendering on=1/off=0 */
|
/* switch color rendering on=1/off=0 */
|
||||||
void GPU_color_switch(int mode);
|
void GPU_color_switch(int mode);
|
||||||
@ -202,20 +212,19 @@ void GPU_interleaved_attrib_unbind(void);
|
|||||||
typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
|
typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
|
||||||
|
|
||||||
/* build */
|
/* build */
|
||||||
GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(
|
GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(const int (*face_vert_indices)[4],
|
||||||
const int (*face_vert_indices)[4],
|
|
||||||
const struct MFace *mface, const struct MVert *mvert,
|
const struct MFace *mface, const struct MVert *mvert,
|
||||||
const int *face_indices, int totface);
|
const int *face_indices, int totface);
|
||||||
|
|
||||||
GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid,
|
GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid,
|
||||||
unsigned int **grid_hidden, int gridsize);
|
unsigned int **grid_hidden, int gridsize, const struct CCGKey *key);
|
||||||
|
|
||||||
GPU_PBVH_Buffers *GPU_build_bmesh_pbvh_buffers(int smooth_shading);
|
GPU_PBVH_Buffers *GPU_build_bmesh_pbvh_buffers(int smooth_shading);
|
||||||
|
|
||||||
/* update */
|
/* update */
|
||||||
|
|
||||||
void GPU_update_mesh_pbvh_buffers(
|
void GPU_update_mesh_pbvh_buffers(
|
||||||
GPU_PBVH_Buffers *buffers, const MVert *mvert,
|
GPU_PBVH_Buffers *buffers, const struct MVert *mvert,
|
||||||
const int *vert_indices, int totvert, const float *vmask,
|
const int *vert_indices, int totvert, const float *vmask,
|
||||||
const int (*face_vert_indices)[4], bool show_diffuse_color);
|
const int (*face_vert_indices)[4], bool show_diffuse_color);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,11 @@
|
|||||||
* \ingroup gpu
|
* \ingroup gpu
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "BKE_DerivedMesh.h"
|
||||||
|
|
||||||
#include "BLI_sys_types.h"
|
#include "BLI_sys_types.h"
|
||||||
#include "GPU_init_exit.h" /* interface */
|
#include "GPU_init_exit.h" /* interface */
|
||||||
|
#include "GPU_buffers.h"
|
||||||
|
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ void GPU_exit(void)
|
|||||||
gpu_codegen_exit();
|
gpu_codegen_exit();
|
||||||
|
|
||||||
gpu_extensions_exit(); /* must come last */
|
gpu_extensions_exit(); /* must come last */
|
||||||
|
GPU_buffer_multires_free(true);
|
||||||
|
|
||||||
initialized = false;
|
initialized = false;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,8 @@ EnumPropertyItem navigation_mode_items[] = {
|
|||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_idprop.h"
|
#include "BKE_idprop.h"
|
||||||
|
#include "BKE_pbvh.h"
|
||||||
|
#include "BKE_paint.h"
|
||||||
|
|
||||||
#include "GPU_draw.h"
|
#include "GPU_draw.h"
|
||||||
#include "GPU_select.h"
|
#include "GPU_select.h"
|
||||||
@ -141,13 +143,23 @@ static void rna_userdef_language_update(Main *UNUSED(bmain), Scene *UNUSED(scene
|
|||||||
UI_reinit_font();
|
UI_reinit_font();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void update_cb(PBVHNode *node, void *UNUSED(rebuild))
|
||||||
|
{
|
||||||
|
BKE_pbvh_node_mark_rebuild_draw(node);
|
||||||
|
}
|
||||||
|
|
||||||
static void rna_userdef_vbo_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
|
static void rna_userdef_vbo_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
|
||||||
{
|
{
|
||||||
Object *ob;
|
Object *ob;
|
||||||
|
|
||||||
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
||||||
GPU_drawobject_free(ob->derivedFinal);
|
GPU_drawobject_free(ob->derivedFinal);
|
||||||
|
|
||||||
|
if (ob->sculpt && ob->sculpt->pbvh) {
|
||||||
|
BKE_pbvh_search_callback(ob->sculpt->pbvh, NULL, NULL, update_cb, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
GPU_buffer_multires_free(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user