[Bf-blender-cvs] [c7222a2] master: Optimize vertex parent in cases there are only deform and SS modifiers

Sergey Sharybin noreply at git.blender.org
Fri Oct 31 20:15:50 CET 2014


Commit: c7222a234ddae3281d2bdc76a01a98bf19e9bb3d
Author: Sergey Sharybin
Date:   Fri Oct 31 20:06:19 2014 +0100
Branches: master
https://developer.blender.org/rBc7222a234ddae3281d2bdc76a01a98bf19e9bb3d

Optimize vertex parent in cases there are only deform and SS modifiers

In cases when the subsurf modifier is the last in the stack and there
are only deformation modifiers before it we can skip doing full orig
vertex lookup.

This is rather common situation here in animatic.

===================================================================

M	source/blender/blenkernel/intern/object.c

===================================================================

diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 53b0e0c..82bcbaf 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -107,6 +107,7 @@
 #include "BKE_sequencer.h"
 #include "BKE_speaker.h"
 #include "BKE_softbody.h"
+#include "BKE_subsurf.h"
 #include "BKE_material.h"
 #include "BKE_camera.h"
 #include "BKE_image.h"
@@ -119,6 +120,8 @@
 #include "BPY_extern.h"
 #endif
 
+#include "CCGSubSurf.h"
+
 #include "GPU_material.h"
 
 /* Vertex parent modifies original BMesh which is not safe for threading.
@@ -2153,6 +2156,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
 			if (nr < numVerts) {
 				/* avoid dm->getVertDataArray() since it allocates arrays in the dm (not thread safe) */
 				int i;
+				bool use_special_ss_case = false;
 
 				if (em && dm->type == DM_TYPE_EDITBMESH) {
 					if (em->bm->elem_table_dirty & BM_VERT) {
@@ -2169,8 +2173,35 @@ static void give_parvert(Object *par, int nr, float vec[3])
 					}
 				}
 
-				/* get the average of all verts with (original index == nr) */
-				if (CustomData_has_layer(&dm->vertData, CD_ORIGINDEX)) {
+				if (dm->type == DM_TYPE_CCGDM) {
+					ModifierData *md;
+					VirtualModifierData virtualModifierData;
+					use_special_ss_case = true;
+					for (md = modifiers_getVirtualModifierList(par, &virtualModifierData);
+					     md != NULL;
+					     md = md->next)
+					{
+						ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+						/* TODO(sergey): Check for disabled modifiers. */
+						if (mti->type != eModifierTypeType_OnlyDeform && md->next != NULL) {
+							use_special_ss_case = false;
+							break;
+						}
+					}
+				}
+
+				if (use_special_ss_case) {
+					/* Special case if the last modifier is SS and no constructive modifier
+					 * are in front of it.
+					 */
+					CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
+					CCGVert *ccg_vert = ccgSubSurf_getVert(ccgdm->ss, SET_INT_IN_POINTER(nr));
+					float *co = ccgSubSurf_getVertData(ccgdm->ss, ccg_vert);
+					add_v3_v3(vec, co);
+					count++;
+				}
+				else if (CustomData_has_layer(&dm->vertData, CD_ORIGINDEX)) {
+					/* Get the average of all verts with (original index == nr). */
 					for (i = 0; i < numVerts; i++) {
 						const int *index = dm->getVertData(dm, i, CD_ORIGINDEX);
 						if (*index == nr) {




More information about the Bf-blender-cvs mailing list