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

« back to all changes in this revision

Viewing changes to source/blender/bmesh/intern/bmesh_operator_api_inline.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        oflags[bm->stackdepth - 1].f ^= oflag;
70
70
}
71
71
 
72
 
BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname,
73
 
                                        void *element, int val)
74
 
{
75
 
        BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int));
76
 
}
77
 
 
78
 
BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname,
79
 
                                          void *element, float val)
80
 
{
81
 
        BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float));
 
72
BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot,
 
73
                                        void *element, const int val)
 
74
{
 
75
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INT);
 
76
        BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
 
77
}
 
78
 
 
79
BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot,
 
80
                                        void *element, const int val)
 
81
{
 
82
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
 
83
        BLI_assert(val == false || val == true);
 
84
        BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
 
85
}
 
86
 
 
87
BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot,
 
88
                                          void *element, const float val)
 
89
{
 
90
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_FLT);
 
91
        BMO_slot_map_insert(op, slot, element, &val, sizeof(float));
82
92
}
83
93
 
84
94
 
87
97
 * do NOT use these for non-operator-api-allocated memory! instead
88
98
 * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */
89
99
 
90
 
BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname,
91
 
                                        void *element, void *val)
92
 
{
93
 
        BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void *));
94
 
}
95
 
 
96
 
BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element)
97
 
{
98
 
        BMOpSlot *slot = BMO_slot_get(op, slotname);
99
 
        BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING);
 
100
BLI_INLINE void BMO_slot_map_ptr_insert(BMOperator *op, BMOpSlot *slot,
 
101
                                        const void *element, void *val)
 
102
{
 
103
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
 
104
        BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
 
105
}
 
106
 
 
107
BLI_INLINE void BMO_slot_map_elem_insert(BMOperator *op, BMOpSlot *slot,
 
108
                                        const void *element, void *val)
 
109
{
 
110
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
 
111
        BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
 
112
}
 
113
 
 
114
 
 
115
/* no values */
 
116
BLI_INLINE void BMO_slot_map_empty_insert(BMOperator *op, BMOpSlot *slot,
 
117
                                        const void *element)
 
118
{
 
119
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_EMPTY);
 
120
        BMO_slot_map_insert(op, slot, element, NULL, 0);
 
121
}
 
122
 
 
123
BLI_INLINE int BMO_slot_map_contains(BMOpSlot *slot, const void *element)
 
124
{
 
125
        BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
100
126
 
101
127
        /* sanity check */
102
 
        if (!slot->data.ghash) return 0;
 
128
        if (UNLIKELY(slot->data.ghash == NULL)) {
 
129
                return 0;
 
130
        }
103
131
 
104
132
        return BLI_ghash_haskey(slot->data.ghash, element);
105
133
}
106
134
 
107
 
BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slotname,
108
 
                                       void *element)
 
135
BLI_INLINE void *BMO_slot_map_data_get(BMOpSlot *slot, const void *element)
109
136
{
110
137
        BMOElemMapping *mapping;
111
 
        BMOpSlot *slot = BMO_slot_get(op, slotname);
112
 
        BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING);
 
138
        BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
113
139
 
114
140
        /* sanity check */
115
 
        if (!slot->data.ghash) return NULL;
 
141
        if (UNLIKELY(slot->data.ghash == NULL)) {
 
142
                return NULL;
 
143
        }
116
144
 
117
145
        mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element);
118
146
 
119
 
        if (!mapping) return NULL;
 
147
        if (!mapping) {
 
148
                return NULL;
 
149
        }
120
150
 
121
151
        return mapping + 1;
122
152
}
123
153
 
124
 
BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname,
125
 
                                        void *element)
 
154
BLI_INLINE float BMO_slot_map_float_get(BMOpSlot *slot, const void *element)
126
155
{
127
 
        float *val = (float *) BMO_slot_map_data_get(bm, op, slotname, element);
 
156
        float *val;
 
157
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_FLT);
 
158
 
 
159
        val = (float *) BMO_slot_map_data_get(slot, element);
128
160
        if (val) return *val;
129
161
 
130
162
        return 0.0f;
131
163
}
132
164
 
133
 
BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname,
134
 
                                    void *element)
 
165
BLI_INLINE int BMO_slot_map_int_get(BMOpSlot *slot, const void *element)
135
166
{
136
 
        int *val = (int *) BMO_slot_map_data_get(bm, op, slotname, element);
 
167
        int *val;
 
168
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INT);
 
169
 
 
170
        val = (int *) BMO_slot_map_data_get(slot, element);
137
171
        if (val) return *val;
138
172
 
139
173
        return 0;
140
174
}
141
175
 
142
 
BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname,
143
 
                                      void *element)
144
 
{
145
 
        void **val = (void **) BMO_slot_map_data_get(bm, op, slotname, element);
 
176
BLI_INLINE bool BMO_slot_map_bool_get(BMOpSlot *slot, const void *element)
 
177
{
 
178
        int *val;
 
179
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_BOOL);
 
180
 
 
181
        val = (int *) BMO_slot_map_data_get(slot, element);
 
182
        BLI_assert(val == NULL || *val == false || *val == true);
 
183
        if (val) return (bool)*val;
 
184
 
 
185
        return false;
 
186
}
 
187
 
 
188
BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element)
 
189
{
 
190
        void **val = (void **) BMO_slot_map_data_get(slot, element);
 
191
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
 
192
        if (val) return *val;
 
193
 
 
194
        return NULL;
 
195
}
 
196
 
 
197
BLI_INLINE void *BMO_slot_map_elem_get(BMOpSlot *slot, const void *element)
 
198
{
 
199
        void **val = (void **) BMO_slot_map_data_get(slot, element);
 
200
        BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
146
201
        if (val) return *val;
147
202
 
148
203
        return NULL;