Cleanup: nuke (nearly) all remaining usages of DM from RNA.

Only case remaining is a nasty ccgdm/opensubdiv update case, TBD once
subsurf case is addressed.
This commit is contained in:
Bastien Montagne 2018-06-22 17:54:48 +02:00
parent 122e0105e2
commit 79615c5adb
4 changed files with 19 additions and 27 deletions

@ -53,7 +53,6 @@
#include "BKE_camera.h" #include "BKE_camera.h"
#include "BKE_collection.h" #include "BKE_collection.h"
#include "BKE_curve.h" #include "BKE_curve.h"
#include "BKE_DerivedMesh.h"
#include "BKE_displist.h" #include "BKE_displist.h"
#include "BKE_mesh.h" #include "BKE_mesh.h"
#include "BKE_armature.h" #include "BKE_armature.h"

@ -68,7 +68,6 @@ static const EnumPropertyItem space_items[] = {
#include "BKE_anim.h" #include "BKE_anim.h"
#include "BKE_bvhutils.h" #include "BKE_bvhutils.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_constraint.h" #include "BKE_constraint.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_customdata.h" #include "BKE_customdata.h"
@ -289,9 +288,9 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int
#endif #endif
/* don't call inside a loop */ /* don't call inside a loop */
static int dm_looptri_to_poly_index(DerivedMesh *dm, const MLoopTri *lt) static int mesh_looptri_to_poly_index(Mesh *me_eval, const MLoopTri *lt)
{ {
const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly; return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly;
} }
@ -302,7 +301,7 @@ static void rna_Object_ray_cast(
{ {
bool success = false; bool success = false;
if (ob->derivedFinal == NULL) { if (ob->runtime.mesh_eval == NULL) {
BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for ray casting", ob->id.name + 2); BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for ray casting", ob->id.name + 2);
return; return;
} }
@ -315,7 +314,7 @@ static void rna_Object_ray_cast(
BVHTreeFromMesh treeData = {NULL}; BVHTreeFromMesh treeData = {NULL};
/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4); BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4);
/* may fail if the mesh has no faces, in that case the ray-cast misses */ /* may fail if the mesh has no faces, in that case the ray-cast misses */
if (treeData.tree != NULL) { if (treeData.tree != NULL) {
@ -335,7 +334,7 @@ static void rna_Object_ray_cast(
copy_v3_v3(r_location, hit.co); copy_v3_v3(r_location, hit.co);
copy_v3_v3(r_normal, hit.no); copy_v3_v3(r_normal, hit.no);
*r_index = dm_looptri_to_poly_index(ob->derivedFinal, &treeData.looptri[hit.index]); *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval, &treeData.looptri[hit.index]);
} }
} }
@ -357,14 +356,14 @@ static void rna_Object_closest_point_on_mesh(
{ {
BVHTreeFromMesh treeData = {NULL}; BVHTreeFromMesh treeData = {NULL};
if (ob->derivedFinal == NULL) { if (ob->runtime.mesh_eval == NULL) {
BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for finding nearest point", BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for finding nearest point",
ob->id.name + 2); ob->id.name + 2);
return; return;
} }
/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4); BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4);
if (treeData.tree == NULL) { if (treeData.tree == NULL) {
BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for finding nearest point", BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for finding nearest point",
@ -382,7 +381,7 @@ static void rna_Object_closest_point_on_mesh(
copy_v3_v3(r_location, nearest.co); copy_v3_v3(r_location, nearest.co);
copy_v3_v3(r_normal, nearest.no); copy_v3_v3(r_normal, nearest.no);
*r_index = dm_looptri_to_poly_index(ob->derivedFinal, &treeData.looptri[nearest.index]); *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval, &treeData.looptri[nearest.index]);
goto finally; goto finally;
} }
@ -409,10 +408,12 @@ static int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings)
} }
#ifndef NDEBUG #ifndef NDEBUG
void rna_Object_dm_info(struct Object *ob, int type, char *result)
#include "BKE_mesh_runtime.h"
void rna_Object_me_eval_info(struct Object *ob, int type, char *result)
{ {
DerivedMesh *dm = NULL; Mesh *me_eval = NULL;
bool dm_release = false;
char *ret = NULL; char *ret = NULL;
result[0] = '\0'; result[0] = '\0';
@ -420,24 +421,19 @@ void rna_Object_dm_info(struct Object *ob, int type, char *result)
switch (type) { switch (type) {
case 0: case 0:
if (ob->type == OB_MESH) { if (ob->type == OB_MESH) {
dm = CDDM_from_mesh(ob->data); me_eval = ob->data;
ret = DM_debug_info(dm);
dm_release = true;
} }
break; break;
case 1: case 1:
dm = ob->derivedDeform; me_eval = ob->runtime.mesh_deform_eval;
break; break;
case 2: case 2:
dm = ob->derivedFinal; me_eval = ob->runtime.mesh_eval;
break; break;
} }
if (dm) { if (me_eval) {
ret = DM_debug_info(dm); ret = BKE_mesh_runtime_debug_info(me_eval);
if (dm_release) {
dm->release(dm);
}
if (ret) { if (ret) {
strcpy(result, ret); strcpy(result, ret);
MEM_freeN(ret); MEM_freeN(ret);
@ -664,7 +660,7 @@ void RNA_api_object(StructRNA *srna)
#ifndef NDEBUG #ifndef NDEBUG
/* mesh */ /* mesh */
func = RNA_def_function(srna, "dm_info", "rna_Object_dm_info"); func = RNA_def_function(srna, "dm_info", "rna_Object_me_eval_info");
RNA_def_function_ui_description(func, "Returns a string for derived mesh data"); RNA_def_function_ui_description(func, "Returns a string for derived mesh data");
parm = RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply"); parm = RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply");

@ -139,8 +139,6 @@ static const EnumPropertyItem part_hair_ren_as_items[] = {
#include "BKE_cloth.h" #include "BKE_cloth.h"
#include "BKE_colortools.h" #include "BKE_colortools.h"
#include "BKE_deform.h" #include "BKE_deform.h"
#include "BKE_DerivedMesh.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_effect.h" #include "BKE_effect.h"
#include "BKE_material.h" #include "BKE_material.h"
#include "BKE_modifier.h" #include "BKE_modifier.h"

@ -104,7 +104,6 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_DerivedMesh.h"
#include "BKE_particle.h" #include "BKE_particle.h"
#include "BKE_pbvh.h" #include "BKE_pbvh.h"
#include "BKE_pointcache.h" #include "BKE_pointcache.h"