00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 INLINE TransformBlend::
00022 TransformBlend() {
00023 }
00024
00025
00026
00027
00028
00029
00030 INLINE TransformBlend::
00031 TransformBlend(const VertexTransform *transform0, PN_stdfloat) {
00032 add_transform(transform0, 1.0f);
00033 }
00034
00035
00036
00037
00038
00039
00040 INLINE TransformBlend::
00041 TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0,
00042 const VertexTransform *transform1, PN_stdfloat weight1) {
00043 add_transform(transform0, weight0);
00044 add_transform(transform1, weight1);
00045 normalize_weights();
00046 }
00047
00048
00049
00050
00051
00052
00053 INLINE TransformBlend::
00054 TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0,
00055 const VertexTransform *transform1, PN_stdfloat weight1,
00056 const VertexTransform *transform2, PN_stdfloat weight2) {
00057 add_transform(transform0, weight0);
00058 add_transform(transform1, weight1);
00059 add_transform(transform2, weight2);
00060 normalize_weights();
00061 }
00062
00063
00064
00065
00066
00067
00068 INLINE TransformBlend::
00069 TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0,
00070 const VertexTransform *transform1, PN_stdfloat weight1,
00071 const VertexTransform *transform2, PN_stdfloat weight2,
00072 const VertexTransform *transform3, PN_stdfloat weight3) {
00073 add_transform(transform0, weight0);
00074 add_transform(transform1, weight1);
00075 add_transform(transform2, weight2);
00076 add_transform(transform3, weight3);
00077 normalize_weights();
00078 }
00079
00080
00081
00082
00083
00084
00085 INLINE TransformBlend::
00086 TransformBlend(const TransformBlend ©) :
00087 _entries(copy._entries)
00088 {
00089 }
00090
00091
00092
00093
00094
00095
00096 INLINE void TransformBlend::
00097 operator = (const TransformBlend ©) {
00098 _entries = copy._entries;
00099 Thread *current_thread = Thread::get_current_thread();
00100 clear_result(current_thread);
00101 }
00102
00103
00104
00105
00106
00107
00108 INLINE TransformBlend::
00109 ~TransformBlend() {
00110 }
00111
00112
00113
00114
00115
00116
00117 INLINE bool TransformBlend::
00118 operator < (const TransformBlend &other) const {
00119 return compare_to(other) < 0;
00120 }
00121
00122
00123
00124
00125
00126
00127 INLINE bool TransformBlend::
00128 operator == (const TransformBlend &other) const {
00129 return compare_to(other) == 0;
00130 }
00131
00132
00133
00134
00135
00136
00137 INLINE bool TransformBlend::
00138 operator != (const TransformBlend &other) const {
00139 return compare_to(other) != 0;
00140 }
00141
00142
00143
00144
00145
00146
00147
00148 INLINE int TransformBlend::
00149 get_num_transforms() const {
00150 return _entries.size();
00151 }
00152
00153
00154
00155
00156
00157
00158
00159 INLINE const VertexTransform *TransformBlend::
00160 get_transform(int n) const {
00161 nassertr(n >= 0 && n < (int)_entries.size(), NULL);
00162 return _entries[n]._transform;
00163 }
00164
00165
00166
00167
00168
00169
00170
00171 INLINE PN_stdfloat TransformBlend::
00172 get_weight(int n) const {
00173 nassertr(n >= 0 && n < (int)_entries.size(), 0.0f);
00174 return _entries[n]._weight;
00175 }
00176
00177
00178
00179
00180
00181
00182
00183 INLINE void TransformBlend::
00184 set_transform(int n, const VertexTransform *transform) {
00185 nassertv(n >= 0 && n < (int)_entries.size());
00186 _entries[n]._transform = transform;
00187 }
00188
00189
00190
00191
00192
00193
00194
00195 INLINE void TransformBlend::
00196 set_weight(int n, PN_stdfloat weight) {
00197 nassertv(n >= 0 && n < (int)_entries.size());
00198 _entries[n]._weight = weight;
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208 INLINE void TransformBlend::
00209 update_blend(Thread *current_thread) const {
00210 CDLockedReader cdata(_cycler, current_thread);
00211 if (cdata->_global_modified != VertexTransform::get_global_modified(current_thread)) {
00212 CDWriter cdataw(((TransformBlend *)this)->_cycler, cdata, false);
00213 ((TransformBlend *)this)->recompute_result(cdataw, current_thread);
00214 }
00215 }
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 INLINE void TransformBlend::
00228 get_blend(LMatrix4 &result, Thread *current_thread) const {
00229 CDReader cdata(_cycler, current_thread);
00230 result = cdata->_result;
00231 }
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 INLINE void TransformBlend::
00242 transform_point(LPoint4 &point, Thread *current_thread) const {
00243 if (!_entries.empty()) {
00244 CDReader cdata(_cycler, current_thread);
00245 point = point * cdata->_result;
00246 }
00247 }
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 INLINE void TransformBlend::
00258 transform_point(LPoint3 &point, Thread *current_thread) const {
00259 if (!_entries.empty()) {
00260 CDReader cdata(_cycler, current_thread);
00261 point = point * cdata->_result;
00262 }
00263 }
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 INLINE void TransformBlend::
00274 transform_vector(LVector3 &vector, Thread *current_thread) const {
00275 if (!_entries.empty()) {
00276 CDReader cdata(_cycler, current_thread);
00277 vector = vector * cdata->_result;
00278 }
00279 }
00280
00281 #ifndef STDFLOAT_DOUBLE
00282
00283
00284
00285
00286
00287
00288
00289
00290 INLINE void TransformBlend::
00291 transform_point(LPoint4d &point, Thread *current_thread) const {
00292 if (!_entries.empty()) {
00293 CDReader cdata(_cycler, current_thread);
00294 point = point * LCAST(double, cdata->_result);
00295 }
00296 }
00297 #else // STDFLOAT_DOUBLE
00298
00299
00300
00301
00302
00303
00304
00305
00306 INLINE void TransformBlend::
00307 transform_point(LPoint4f &point, Thread *current_thread) const {
00308 if (!_entries.empty()) {
00309 CDReader cdata(_cycler, current_thread);
00310 point = point * LCAST(float, cdata->_result);
00311 }
00312 }
00313 #endif // STDFLOAT_DOUBLE
00314
00315 #ifndef STDFLOAT_DOUBLE
00316
00317
00318
00319
00320
00321
00322
00323
00324 INLINE void TransformBlend::
00325 transform_point(LPoint3d &point, Thread *current_thread) const {
00326 if (!_entries.empty()) {
00327 CDReader cdata(_cycler, current_thread);
00328 point = point * LCAST(double, cdata->_result);
00329 }
00330 }
00331 #else // STDFLOAT_DOUBLE
00332
00333
00334
00335
00336
00337
00338
00339
00340 INLINE void TransformBlend::
00341 transform_point(LPoint3f &point, Thread *current_thread) const {
00342 if (!_entries.empty()) {
00343 CDReader cdata(_cycler, current_thread);
00344 point = point * LCAST(float, cdata->_result);
00345 }
00346 }
00347 #endif // STDFLOAT_DOUBLE
00348
00349 #ifndef STDFLOAT_DOUBLE
00350
00351
00352
00353
00354
00355
00356
00357
00358 INLINE void TransformBlend::
00359 transform_vector(LVector3d &vector, Thread *current_thread) const {
00360 if (!_entries.empty()) {
00361 CDReader cdata(_cycler, current_thread);
00362 vector = vector * LCAST(double, cdata->_result);
00363 }
00364 }
00365 #else // STDFLOAT_DOUBLE
00366
00367
00368
00369
00370
00371
00372
00373
00374 INLINE void TransformBlend::
00375 transform_vector(LVector3f &vector, Thread *current_thread) const {
00376 if (!_entries.empty()) {
00377 CDReader cdata(_cycler, current_thread);
00378 vector = vector * LCAST(float, cdata->_result);
00379 }
00380 }
00381 #endif // STDFLOAT_DOUBLE
00382
00383
00384
00385
00386
00387
00388
00389 INLINE UpdateSeq TransformBlend::
00390 get_modified(Thread *current_thread) const {
00391 CDLockedReader cdata(_cycler, current_thread);
00392 if (cdata->_global_modified != VertexTransform::get_global_modified(current_thread)) {
00393 CDWriter cdataw(((TransformBlend *)this)->_cycler, cdata, false);
00394 ((TransformBlend *)this)->recompute_result(cdataw, current_thread);
00395 return cdataw->_modified;
00396 } else {
00397 return cdata->_modified;
00398 }
00399 }
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 INLINE bool TransformBlend::TransformEntry::
00410 operator < (const TransformBlend::TransformEntry &other) const {
00411 return _transform < other._transform;
00412 }
00413
00414
00415
00416
00417
00418
00419 INLINE TransformBlend::CData::
00420 CData() :
00421 _result(LMatrix4::ident_mat())
00422 {
00423 }
00424
00425
00426
00427
00428
00429
00430 INLINE TransformBlend::CData::
00431 CData(const TransformBlend::CData ©) :
00432 _result(copy._result),
00433 _modified(copy._modified),
00434 _global_modified(copy._global_modified)
00435 {
00436 }
00437
00438 INLINE ostream &
00439 operator << (ostream &out, const TransformBlend &obj) {
00440 obj.output(out);
00441 return out;
00442 }