Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_nla.c
| Show First 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | void recalcData_nla(TransInfo *t) | ||||
| /* For each strip we've got, perform some additional validation of the values | /* For each strip we've got, perform some additional validation of the values | ||||
| * that got set before using RNA to set the value (which does some special | * that got set before using RNA to set the value (which does some special | ||||
| * operations when setting these values to make sure that everything works ok). | * operations when setting these values to make sure that everything works ok). | ||||
| */ | */ | ||||
| for (i = 0; i < tc->data_len; i++, tdn++) { | for (i = 0; i < tc->data_len; i++, tdn++) { | ||||
| NlaStrip *strip = tdn->strip; | NlaStrip *strip = tdn->strip; | ||||
| PointerRNA strip_ptr; | PointerRNA strip_ptr; | ||||
| short pExceeded, nExceeded, iter; | short iter; | ||||
| int delta_y1, delta_y2; | int delta_y1, delta_y2; | ||||
| /* if this tdn has no handles, that means it is just a dummy that should be skipped */ | /* if this tdn has no handles, that means it is just a dummy that should be skipped */ | ||||
| if (tdn->handle == 0) { | if (tdn->handle == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* set refresh tags for objects using this animation, | /* set refresh tags for objects using this animation, | ||||
| Show All 37 Lines | if (t->state == TRANS_CANCEL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* firstly, check if the proposed transform locations would overlap with any neighboring strips | /* firstly, check if the proposed transform locations would overlap with any neighboring strips | ||||
| * (barring transitions) which are absolute barriers since they are not being moved | * (barring transitions) which are absolute barriers since they are not being moved | ||||
| * | * | ||||
| * this is done as a iterative procedure (done 5 times max for now) | * this is done as a iterative procedure (done 5 times max for now) | ||||
| */ | */ | ||||
| NlaStrip *prev = strip->prev; | |||||
| while (prev != NULL && (prev->type & NLASTRIP_TYPE_TRANSITION)) { | |||||
| prev = prev->prev; | |||||
| } | |||||
| NlaStrip *next = strip->next; | |||||
| while (next != NULL && (next->type & NLASTRIP_TYPE_TRANSITION)) { | |||||
| next = next->next; | |||||
| } | |||||
| for (iter = 0; iter < 5; iter++) { | for (iter = 0; iter < 5; iter++) { | ||||
| pExceeded = ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && | |||||
| (tdn->h1[0] < strip->prev->end)); | const bool pExceeded = (prev != NULL) && (tdn->h1[0] < prev->end); | ||||
| nExceeded = ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && | const bool nExceeded = (next != NULL) && (tdn->h2[0] > next->start); | ||||
| (tdn->h2[0] > strip->next->start)); | |||||
| if ((pExceeded && nExceeded) || (iter == 4)) { | if ((pExceeded && nExceeded) || (iter == 4)) { | ||||
| /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise) | /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a | ||||
| * compromise) | |||||
| * - Simply crop strip to fit within the bounds of the strips bounding it | * - Simply crop strip to fit within the bounds of the strips bounding it | ||||
| * - If there were no neighbors, clear the transforms | * - If there were no neighbors, clear the transforms | ||||
| * (make it default to the strip's current values). | * (make it default to the strip's current values). | ||||
| */ | */ | ||||
| if (strip->prev && strip->next) { | if (prev && next) { | ||||
| tdn->h1[0] = strip->prev->end; | tdn->h1[0] = prev->end; | ||||
| tdn->h2[0] = strip->next->start; | tdn->h2[0] = next->start; | ||||
| } | } | ||||
| else { | else { | ||||
| tdn->h1[0] = strip->start; | tdn->h1[0] = strip->start; | ||||
| tdn->h2[0] = strip->end; | tdn->h2[0] = strip->end; | ||||
| } | } | ||||
| } | } | ||||
| else if (nExceeded) { | else if (nExceeded) { | ||||
| /* move backwards */ | /* move backwards */ | ||||
| float offset = tdn->h2[0] - strip->next->start; | float offset = tdn->h2[0] - next->start; | ||||
| tdn->h1[0] -= offset; | tdn->h1[0] -= offset; | ||||
| tdn->h2[0] -= offset; | tdn->h2[0] -= offset; | ||||
| } | } | ||||
| else if (pExceeded) { | else if (pExceeded) { | ||||
| /* more forwards */ | /* more forwards */ | ||||
| float offset = strip->prev->end - tdn->h1[0]; | float offset = prev->end - tdn->h1[0]; | ||||
| tdn->h1[0] += offset; | tdn->h1[0] += offset; | ||||
| tdn->h2[0] += offset; | tdn->h2[0] += offset; | ||||
| } | } | ||||
| else { /* all is fine and well */ | else { /* all is fine and well */ | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 173 Lines • Show Last 20 Lines | |||||