Fix for properly unlinking target object pointers when objects are deleted
from scenes.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#define LS_MODIFIER_TYPE_THICKNESS 3
|
||||
|
||||
struct Main;
|
||||
struct Object;
|
||||
|
||||
FreestyleLineStyle *FRS_new_linestyle(char *name, struct Main *main);
|
||||
void FRS_free_linestyle(FreestyleLineStyle *linestyle);
|
||||
@@ -58,4 +59,6 @@ void FRS_move_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineSt
|
||||
void FRS_list_modifier_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase);
|
||||
char *FRS_path_from_ID_to_color_ramp(FreestyleLineStyle *linestyle, ColorBand *color_ramp);
|
||||
|
||||
void FRS_unlink_linestyle_target_object(FreestyleLineStyle *linestyle, struct Object *ob);
|
||||
|
||||
#endif
|
||||
|
@@ -368,3 +368,30 @@ char *FRS_path_from_ID_to_color_ramp(FreestyleLineStyle *linestyle, ColorBand *c
|
||||
found:
|
||||
return BLI_sprintfN("color_modifiers[\"%s\"].color_ramp", m->name);
|
||||
}
|
||||
|
||||
void FRS_unlink_linestyle_target_object(FreestyleLineStyle *linestyle, struct Object *ob)
|
||||
{
|
||||
LineStyleModifier *m;
|
||||
|
||||
for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
|
||||
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
|
||||
if (((LineStyleColorModifier_DistanceFromObject *)m)->target == ob) {
|
||||
((LineStyleColorModifier_DistanceFromObject *)m)->target = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (m = (LineStyleModifier *)linestyle->alpha_modifiers.first; m; m = m->next) {
|
||||
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
|
||||
if (((LineStyleAlphaModifier_DistanceFromObject *)m)->target == ob) {
|
||||
((LineStyleAlphaModifier_DistanceFromObject *)m)->target = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (m = (LineStyleModifier *)linestyle->thickness_modifiers.first; m; m = m->next) {
|
||||
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
|
||||
if (((LineStyleThicknessModifier_DistanceFromObject *)m)->target == ob) {
|
||||
((LineStyleThicknessModifier_DistanceFromObject *)m)->target = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -102,6 +102,8 @@
|
||||
|
||||
#include "GPU_material.h"
|
||||
|
||||
#include "FRS_freestyle.h"
|
||||
|
||||
/* Local function protos */
|
||||
static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul);
|
||||
|
||||
@@ -577,6 +579,14 @@ void unlink_object(Object *ob)
|
||||
}
|
||||
SEQ_END
|
||||
}
|
||||
|
||||
{
|
||||
SceneRenderLayer *srl;
|
||||
|
||||
for (srl= sce->r.layers.first; srl; srl= srl->next) {
|
||||
FRS_unlink_target_object(&srl->freestyleConfig, ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sce= sce->id.next;
|
||||
|
@@ -39,6 +39,7 @@ extern "C" {
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_object.h"
|
||||
|
||||
extern Scene *freestyle_scene;
|
||||
extern float freestyle_viewpoint[3];
|
||||
@@ -71,6 +72,8 @@ extern "C" {
|
||||
short FRS_get_active_lineset_index(FreestyleConfig *config);
|
||||
void FRS_set_active_lineset_index(FreestyleConfig *config, short index);
|
||||
|
||||
void FRS_unlink_target_object(FreestyleConfig *config, struct Object *ob);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -519,6 +519,15 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
void FRS_unlink_target_object(FreestyleConfig *config, Object *ob)
|
||||
{
|
||||
FreestyleLineSet *lineset;
|
||||
|
||||
for(lineset=(FreestyleLineSet *)config->linesets.first; lineset; lineset=lineset->next) {
|
||||
FRS_unlink_linestyle_target_object(lineset->linestyle, ob);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user