Mesh: remove DerivedMesh for displist conversion
This commit is contained in:
@@ -58,7 +58,7 @@ enum {
|
|||||||
/* prototypes */
|
/* prototypes */
|
||||||
|
|
||||||
struct Depsgraph;
|
struct Depsgraph;
|
||||||
struct DerivedMesh;
|
struct Mesh;
|
||||||
struct ListBase;
|
struct ListBase;
|
||||||
struct Main;
|
struct Main;
|
||||||
struct Object;
|
struct Object;
|
||||||
@@ -89,12 +89,12 @@ bool BKE_displist_has_faces(struct ListBase *lb);
|
|||||||
|
|
||||||
void BKE_displist_make_surf(
|
void BKE_displist_make_surf(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
|
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
|
||||||
struct DerivedMesh **r_dm_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
|
struct Mesh **r_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
|
||||||
void BKE_displist_make_curveTypes(
|
void BKE_displist_make_curveTypes(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const bool for_orco);
|
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const bool for_orco);
|
||||||
void BKE_displist_make_curveTypes_forRender(
|
void BKE_displist_make_curveTypes_forRender(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
|
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
|
||||||
struct DerivedMesh **r_dm_final, const bool for_orco, const bool use_render_resolution);
|
struct Mesh **r_final, const bool for_orco, const bool use_render_resolution);
|
||||||
void BKE_displist_make_curveTypes_forOrco(
|
void BKE_displist_make_curveTypes_forOrco(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
|
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
|
||||||
void BKE_displist_make_mball(
|
void BKE_displist_make_mball(
|
||||||
@@ -107,11 +107,6 @@ void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const flo
|
|||||||
|
|
||||||
float BKE_displist_calc_taper(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *taperobj, int cur, int tot);
|
float BKE_displist_calc_taper(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *taperobj, int cur, int tot);
|
||||||
|
|
||||||
/* add Orco layer to the displist object which has got derived mesh and return orco */
|
|
||||||
float *BKE_displist_make_orco(
|
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
|
|
||||||
const bool for_render, const bool use_render_resolution);
|
|
||||||
|
|
||||||
void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
|
void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -920,7 +920,7 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
|
|||||||
|
|
||||||
static void curve_calc_modifiers_post(
|
static void curve_calc_modifiers_post(
|
||||||
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *nurb,
|
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *nurb,
|
||||||
ListBase *dispbase, DerivedMesh **r_dm_final,
|
ListBase *dispbase, Mesh **r_final,
|
||||||
const bool for_render, const bool use_render_resolution)
|
const bool for_render, const bool use_render_resolution)
|
||||||
{
|
{
|
||||||
VirtualModifierData virtualModifierData;
|
VirtualModifierData virtualModifierData;
|
||||||
@@ -955,8 +955,8 @@ static void curve_calc_modifiers_post(
|
|||||||
md = pretessellatePoint->next;
|
md = pretessellatePoint->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r_dm_final && *r_dm_final) {
|
if (r_final && *r_final) {
|
||||||
(*r_dm_final)->release(*r_dm_final);
|
BKE_id_free(NULL, r_final);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; md; md = md->next) {
|
for (; md; md = md->next) {
|
||||||
@@ -982,7 +982,7 @@ static void curve_calc_modifiers_post(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!r_dm_final) {
|
if (!r_final) {
|
||||||
/* makeDisplistCurveTypes could be used for beveling, where derived mesh
|
/* makeDisplistCurveTypes could be used for beveling, where derived mesh
|
||||||
* is totally unnecessary, so we could stop modifiers applying
|
* is totally unnecessary, so we could stop modifiers applying
|
||||||
* when we found constructive modifier but derived mesh is unwanted result
|
* when we found constructive modifier but derived mesh is unwanted result
|
||||||
@@ -1055,7 +1055,7 @@ static void curve_calc_modifiers_post(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r_dm_final) {
|
if (r_final) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
/* see: mesh_calc_modifiers */
|
/* see: mesh_calc_modifiers */
|
||||||
if (modified->totface == 0) {
|
if (modified->totface == 0) {
|
||||||
@@ -1070,11 +1070,10 @@ static void curve_calc_modifiers_post(
|
|||||||
/* XXX2.8(Sybren): make sure the face normals are recalculated as well */
|
/* XXX2.8(Sybren): make sure the face normals are recalculated as well */
|
||||||
BKE_mesh_ensure_normals(modified);
|
BKE_mesh_ensure_normals(modified);
|
||||||
|
|
||||||
(*r_dm_final) = CDDM_from_mesh_ex(modified, CD_DUPLICATE, CD_MASK_MESH);
|
(*r_final) = modified;
|
||||||
BKE_id_free(NULL, modified);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*r_dm_final) = NULL;
|
(*r_final) = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1230,7 +1229,7 @@ static void curve_calc_orcodm(
|
|||||||
|
|
||||||
void BKE_displist_make_surf(
|
void BKE_displist_make_surf(
|
||||||
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
|
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
|
||||||
DerivedMesh **r_dm_final,
|
Mesh **r_final,
|
||||||
const bool for_render, const bool for_orco, const bool use_render_resolution)
|
const bool for_render, const bool for_orco, const bool use_render_resolution)
|
||||||
{
|
{
|
||||||
ListBase nubase = {NULL, NULL};
|
ListBase nubase = {NULL, NULL};
|
||||||
@@ -1315,7 +1314,7 @@ void BKE_displist_make_surf(
|
|||||||
|
|
||||||
if (!for_orco) {
|
if (!for_orco) {
|
||||||
BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
|
BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
|
||||||
curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_dm_final,
|
curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_final,
|
||||||
for_render, use_render_resolution);
|
for_render, use_render_resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1543,7 +1542,7 @@ static void calc_bevfac_mapping(Curve *cu, BevList *bl, Nurb *nu,
|
|||||||
|
|
||||||
static void do_makeDispListCurveTypes(
|
static void do_makeDispListCurveTypes(
|
||||||
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
|
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
|
||||||
DerivedMesh **r_dm_final,
|
Mesh **r_final,
|
||||||
const bool for_render, const bool for_orco, const bool use_render_resolution)
|
const bool for_render, const bool for_orco, const bool use_render_resolution)
|
||||||
{
|
{
|
||||||
Curve *cu = ob->data;
|
Curve *cu = ob->data;
|
||||||
@@ -1552,7 +1551,7 @@ static void do_makeDispListCurveTypes(
|
|||||||
if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
|
if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
|
||||||
|
|
||||||
if (ob->type == OB_SURF) {
|
if (ob->type == OB_SURF) {
|
||||||
BKE_displist_make_surf(depsgraph, scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
|
BKE_displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render, for_orco, use_render_resolution);
|
||||||
}
|
}
|
||||||
else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
|
else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
|
||||||
ListBase dlbev;
|
ListBase dlbev;
|
||||||
@@ -1778,7 +1777,7 @@ static void do_makeDispListCurveTypes(
|
|||||||
|
|
||||||
if (!for_orco) {
|
if (!for_orco) {
|
||||||
BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
|
BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
|
||||||
curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
|
curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_final, for_render, use_render_resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
|
if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
|
||||||
@@ -1807,21 +1806,21 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, Scene *scene, Object *ob
|
|||||||
|
|
||||||
dispbase = &(ob->runtime.curve_cache->disp);
|
dispbase = &(ob->runtime.curve_cache->disp);
|
||||||
|
|
||||||
do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
|
do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->runtime.mesh_eval, 0, for_orco, 0);
|
||||||
|
|
||||||
boundbox_displist_object(ob);
|
boundbox_displist_object(ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_displist_make_curveTypes_forRender(
|
void BKE_displist_make_curveTypes_forRender(
|
||||||
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
|
Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
|
||||||
DerivedMesh **r_dm_final, const bool for_orco,
|
Mesh **r_final, const bool for_orco,
|
||||||
const bool use_render_resolution)
|
const bool use_render_resolution)
|
||||||
{
|
{
|
||||||
if (ob->runtime.curve_cache == NULL) {
|
if (ob->runtime.curve_cache == NULL) {
|
||||||
ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
|
ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
|
||||||
}
|
}
|
||||||
|
|
||||||
do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
|
do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, r_final, true, for_orco, use_render_resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_displist_make_curveTypes_forOrco(
|
void BKE_displist_make_curveTypes_forOrco(
|
||||||
@@ -1834,33 +1833,6 @@ void BKE_displist_make_curveTypes_forOrco(
|
|||||||
do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, NULL, 1, 1, 1);
|
do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, NULL, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add Orco layer to the displist object which has got derived mesh and return orco */
|
|
||||||
/* XXX2.8(Sybren): can be removed once DerivedMesh port is done */
|
|
||||||
#ifdef WITH_DERIVEDMESH_DEPRECATED_FUNCS
|
|
||||||
float *BKE_displist_make_orco(
|
|
||||||
Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm_final,
|
|
||||||
const bool for_render,
|
|
||||||
const bool use_render_resolution)
|
|
||||||
{
|
|
||||||
float *orco;
|
|
||||||
|
|
||||||
if (dm_final == NULL)
|
|
||||||
dm_final = ob->derivedFinal;
|
|
||||||
|
|
||||||
if (!dm_final->getVertDataArray(dm_final, CD_ORCO)) {
|
|
||||||
curve_calc_orcodm(depsgraph, scene, ob, dm_final, for_render, use_render_resolution);
|
|
||||||
}
|
|
||||||
|
|
||||||
orco = dm_final->getVertDataArray(dm_final, CD_ORCO);
|
|
||||||
|
|
||||||
if (orco) {
|
|
||||||
orco = MEM_dupallocN(orco);
|
|
||||||
}
|
|
||||||
|
|
||||||
return orco;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
|
void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
|
||||||
{
|
{
|
||||||
DispList *dl;
|
DispList *dl;
|
||||||
|
|||||||
@@ -857,7 +857,7 @@ Mesh *BKE_mesh_new_from_object(
|
|||||||
case OB_SURF:
|
case OB_SURF:
|
||||||
{
|
{
|
||||||
ListBase dispbase = {NULL, NULL};
|
ListBase dispbase = {NULL, NULL};
|
||||||
DerivedMesh *derivedFinal = NULL;
|
Mesh *me_eval_final = NULL;
|
||||||
int uv_from_orco;
|
int uv_from_orco;
|
||||||
|
|
||||||
/* copies object and modifiers (but not the data) */
|
/* copies object and modifiers (but not the data) */
|
||||||
@@ -899,12 +899,12 @@ Mesh *BKE_mesh_new_from_object(
|
|||||||
copycu->editnurb = tmpcu->editnurb;
|
copycu->editnurb = tmpcu->editnurb;
|
||||||
|
|
||||||
/* get updated display list, and convert to a mesh */
|
/* get updated display list, and convert to a mesh */
|
||||||
BKE_displist_make_curveTypes_forRender(depsgraph, sce, tmpobj, &dispbase, &derivedFinal, false, render);
|
BKE_displist_make_curveTypes_forRender(depsgraph, sce, tmpobj, &dispbase, &me_eval_final, false, render);
|
||||||
|
|
||||||
copycu->editfont = NULL;
|
copycu->editfont = NULL;
|
||||||
copycu->editnurb = NULL;
|
copycu->editnurb = NULL;
|
||||||
|
|
||||||
tmpobj->derivedFinal = derivedFinal;
|
tmpobj->runtime.mesh_eval = me_eval_final;
|
||||||
|
|
||||||
/* convert object type to mesh */
|
/* convert object type to mesh */
|
||||||
uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;
|
uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user