Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-10-31 22:06:19 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2014-10-31 22:06:19 +0300
commitc7222a234ddae3281d2bdc76a01a98bf19e9bb3d (patch)
treee9778fdd25b518e4d55ae3cd62b11f6ad0974b22 /source/blender/blenkernel/intern/object.c
parent3248be1fbf7a7a0b669a7c374f38bc74200cae99 (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 53b0e0cf4a1..82bcbaff31a 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) {