~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/editors/physics/rigidbody_constraint.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
}
78
78
 
79
79
 
80
 
void ED_rigidbody_con_add(wmOperator *op, Scene *scene, Object *ob, int type)
 
80
bool ED_rigidbody_constraint_add(Scene *scene, Object *ob, int type, ReportList *reports)
81
81
{
82
82
        RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
83
83
 
84
84
        /* check that object doesn't already have a constraint */
85
85
        if (ob->rigidbody_constraint) {
86
 
                BKE_reportf(op->reports, RPT_INFO, "Object '%s' already has a Rigid Body Constraint", ob->id.name + 2);
87
 
                return;
 
86
                BKE_reportf(reports, RPT_INFO, "Object '%s' already has a Rigid Body Constraint", ob->id.name + 2);
 
87
                return false;
88
88
        }
89
89
        /* create constraint group if it doesn't already exits */
90
90
        if (rbw->constraints == NULL) {
91
 
                rbw->constraints = add_group(G.main, "RigidBodyConstraints");
 
91
                rbw->constraints = BKE_group_add(G.main, "RigidBodyConstraints");
92
92
        }
93
93
        /* make rigidbody constraint settings */
94
94
        ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, type);
95
95
        ob->rigidbody_constraint->flag |= RBC_FLAG_NEEDS_VALIDATE;
96
96
 
97
97
        /* add constraint to rigid body constraint group */
98
 
        add_to_group(rbw->constraints, ob, scene, NULL);
 
98
        BKE_group_object_add(rbw->constraints, ob, scene, NULL);
 
99
 
 
100
        DAG_id_tag_update(&ob->id, OB_RECALC_OB);
 
101
        return true;
99
102
}
100
103
 
101
 
void ED_rigidbody_con_remove(Scene *scene, Object *ob)
 
104
void ED_rigidbody_constraint_remove(Scene *scene, Object *ob)
102
105
{
103
106
        RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
104
107
 
105
108
        BKE_rigidbody_remove_constraint(scene, ob);
106
109
        if (rbw)
107
 
                rem_from_group(rbw->constraints, ob, scene, NULL);
 
110
                BKE_group_object_unlink(rbw->constraints, ob, scene, NULL);
108
111
 
109
112
        DAG_id_tag_update(&ob->id, OB_RECALC_OB);
110
113
}
120
123
        RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
121
124
        Object *ob = (scene) ? OBACT : NULL;
122
125
        int type = RNA_enum_get(op->ptr, "type");
 
126
        bool change;
123
127
 
124
128
        /* sanity checks */
125
129
        if (ELEM(NULL, scene, rbw)) {
127
131
                return OPERATOR_CANCELLED;
128
132
        }
129
133
        /* apply to active object */
130
 
        ED_rigidbody_con_add(op, scene, ob, type);
131
 
 
132
 
        /* send updates */
133
 
        DAG_ids_flush_update(CTX_data_main(C), 0);
134
 
 
135
 
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
136
 
 
137
 
        /* done */
138
 
        return OPERATOR_FINISHED;
 
134
        change = ED_rigidbody_constraint_add(scene, ob, type, op->reports);
 
135
 
 
136
        if (change) {
 
137
                /* send updates */
 
138
                WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
 
139
 
 
140
                /* done */
 
141
                return OPERATOR_FINISHED;
 
142
        }
 
143
        else {
 
144
                return OPERATOR_CANCELLED;
 
145
        }
139
146
}
140
147
 
141
148
void RIGIDBODY_OT_constraint_add(wmOperatorType *ot)
153
160
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
154
161
 
155
162
        /* properties */
156
 
        ot->prop = RNA_def_enum(ot->srna, "type", rigidbody_con_type_items, RBC_TYPE_FIXED, "Rigid Body Constraint Type", "");
 
163
        ot->prop = RNA_def_enum(ot->srna, "type", rigidbody_constraint_type_items, RBC_TYPE_FIXED, "Rigid Body Constraint Type", "");
157
164
}
158
165
 
159
166
/* ************ Remove Rigid Body Constraint ************** */
173
180
                return OPERATOR_CANCELLED;
174
181
        }
175
182
        else {
176
 
                ED_rigidbody_con_remove(scene, ob);
 
183
                ED_rigidbody_constraint_remove(scene, ob);
177
184
        }
178
185
 
179
186
        /* send updates */
180
 
        DAG_ids_flush_update(CTX_data_main(C), 0);
181
 
 
182
187
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
183
188
 
184
189
        /* done */