Sculpt dyntopo: Split off dyntopo stuff from pbvh_bmesh.c into a new file, dyntopo.c.

This commit is contained in:
Joseph Eagar 2021-07-18 13:12:08 -07:00
parent 5b10d08db3
commit e3b58b6451
6 changed files with 2802 additions and 3045 deletions

View File

@ -0,0 +1,24 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
/** \file
* \ingroup bke
* \brief Dynamic topology remeshing API
*/
typedef struct DynTopo DynTopo;

View File

@ -121,6 +121,7 @@ set(SRC
intern/displist.cc
intern/displist_tangent.c
intern/dynamicpaint.c
intern/dyntopo.c
intern/editlattice.c
intern/editmesh.c
intern/editmesh_bvh.c

File diff suppressed because it is too large Load Diff

View File

@ -2238,8 +2238,6 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob)
pbvh = build_pbvh_for_dynamic_topology(ob);
ob->sculpt->pbvh = pbvh;
// reorder mesh elements to improve memory cache performance
SCULPT_reorder_bmesh(ob->sculpt);
}
else {
Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
@ -2280,6 +2278,12 @@ bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const View3D *v3d)
return false;
}
#if 0
if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
return !(v3d && (v3d->shading.type > OB_SOLID));
}
#endif
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
/* Regular mesh only draws from PBVH without modifiers and shape keys. */
const bool full_shading = (v3d && (v3d->shading.type > OB_SOLID));

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@
#pragma once
#include "BLI_ghash.h"
#include "DNA_customdata_types.h"
#include "DNA_material_types.h"
/** \file
@ -128,6 +129,7 @@ typedef enum {
} PBVHFlags;
typedef struct PBVHBMeshLog PBVHBMeshLog;
struct DMFlagMat;
struct PBVH {
PBVHType type;
@ -163,7 +165,7 @@ struct PBVH {
CCGKey gridkey;
CCGElem **grids;
void **gridfaces;
const DMFlagMat *grid_flag_mats;
const struct DMFlagMat *grid_flag_mats;
int totgrid;
BLI_bitmap **grid_hidden;
@ -267,3 +269,39 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode);
void pbvh_free_all_draw_buffers(PBVHNode *node);
void pbvh_update_free_all_draw_buffers(PBVH *pbvh, PBVHNode *node);
BLI_INLINE int pbvh_bmesh_node_index_from_vert(PBVH *pbvh, const BMVert *key)
{
const int node_index = BM_ELEM_CD_GET_INT((const BMElem *)key, pbvh->cd_vert_node_offset);
BLI_assert(node_index != DYNTOPO_NODE_NONE);
BLI_assert(node_index < pbvh->totnode);
return node_index;
}
BLI_INLINE int pbvh_bmesh_node_index_from_face(PBVH *pbvh, const BMFace *key)
{
const int node_index = BM_ELEM_CD_GET_INT((const BMElem *)key, pbvh->cd_face_node_offset);
BLI_assert(node_index != DYNTOPO_NODE_NONE);
BLI_assert(node_index < pbvh->totnode);
return node_index;
}
BLI_INLINE PBVHNode *pbvh_bmesh_node_from_vert(PBVH *pbvh, const BMVert *key)
{
int ni = pbvh_bmesh_node_index_from_vert(pbvh, key);
return ni >= 0 ? pbvh->nodes + ni : NULL;
// return &pbvh->nodes[pbvh_bmesh_node_index_from_vert(pbvh, key)];
}
BLI_INLINE PBVHNode *pbvh_bmesh_node_from_face(PBVH *pbvh, const BMFace *key)
{
int ni = pbvh_bmesh_node_index_from_face(pbvh, key);
return ni >= 0 ? pbvh->nodes + ni : NULL;
// return &pbvh->nodes[pbvh_bmesh_node_index_from_face(pbvh, key)];
}
bool pbvh_bmesh_node_limit_ensure(PBVH *pbvh, int node_index);
void pbvh_bmesh_check_nodes(PBVH *pbvh);
void bke_pbvh_insert_face_finalize(PBVH *pbvh, BMFace *f, const int ni);
void bke_pbvh_insert_face(PBVH *pbvh, struct BMFace *f);