00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GZ_MATRIX_H__
00023 #define __GZ_MATRIX_H__
00024 #include "gzBasicTypes.h"
00025 #include "gzBase.h"
00026
00035 #include <math.h>
00036
00037 #define gzSqrt(x) sqrt(x) // Default implementation
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 class GZ_BASE_EXPORT gzVec2
00056 {
00057 public:
00058 gzVec2( ){};
00059 gzVec2( const gzReal &v1_val , const gzReal &v2_val):v1(v1_val),v2(v2_val){};
00060
00061 gzVoid set(const gzReal &v1_val, const gzReal &v2_val){ v1=v1_val;v2=v2_val;}
00062
00063 gzReal length() const
00064 {
00065 return (gzReal)gzSqrt(v1*v1+v2*v2);
00066 }
00067
00068
00069 gzReal magnitude() const
00070 {
00071 return v1*v1+v2*v2;
00072 }
00073
00074
00075 gzVec2 unit() const
00076 {
00077 gzReal len(length());
00078 if(len)
00079 {
00080 gzReal invlen(GZ_REAL_ONE/len);
00081 return gzVec2(v1*invlen,v2*invlen);
00082 }
00083 else
00084 return gzVec2(0,0);
00085 }
00086
00087 gzVec2 abs() const
00088 {
00089 return gzVec2(gzAbs(v1),gzAbs(v2));
00090 }
00091
00092
00093 gzVoid normalize()
00094 {
00095 gzReal len(length());
00096 if(!len)
00097 return;
00098
00099 gzReal invlen(GZ_REAL_ONE/len);
00100
00101 v1=v1*invlen;
00102 v2=v2*invlen;
00103 }
00104
00105 gzBool operator==( const gzVec2 &right) const { return (v1==right.v1) && (v2==right.v2); }
00106 gzBool operator!=( const gzVec2 &right) const { return (v1!=right.v1) || (v2!=right.v2); }
00107
00108 gzVec2 & operator+=(const gzVec2 &vector)
00109 {
00110 v1+=vector.v1;
00111 v2+=vector.v2;
00112 return *this;
00113 }
00114
00115 gzVec2 & operator-=(const gzVec2 &vector)
00116 {
00117 v1+=vector.v1;
00118 v2+=vector.v2;
00119 return *this;
00120 }
00121
00122 gzVec2 & operator *= (const gzReal &val)
00123 {
00124 v1*=val;
00125 v2*=val;
00126 return *this;
00127 }
00128
00129 gzVec2 operator * (const gzReal &val) const
00130 {
00131 return gzVec2(v1*val,v2*val);
00132 }
00133
00134 gzVec2 operator / (const gzReal &val) const
00135 {
00136 gzReal inv=GZ_REAL_ONE/val;
00137
00138 return gzVec2(v1*inv,v2*inv);
00139 }
00140
00141 gzVec2 operator - (const gzVec2 &vector_b) const
00142 {
00143 return gzVec2(v1-vector_b.v1,v2-vector_b.v2);
00144 }
00145
00146 gzVec2 operator + (const gzVec2 &vector_b) const
00147 {
00148 return gzVec2(v1+vector_b.v1,v2+vector_b.v2);
00149 }
00150
00151 gzULong hash() const;
00152
00153 public:
00154
00155 union
00156 {
00157 struct
00158 {
00159 gzReal v1,v2;
00160 };
00161 struct
00162 {
00163 gzReal x,y;
00164 };
00165 struct
00166 {
00167 gzReal s,t;
00168 };
00169 struct
00170 {
00171 gzReal u,v;
00172 };
00173 };
00174 };
00175
00176 inline gzVec2 operator * (const gzReal &val , const gzVec2 &vector)
00177 {
00178 return gzVec2(val*vector.v1,val*vector.v2);
00179 }
00180
00181 class gzVec4;
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 class GZ_BASE_EXPORT gzVec3
00198 {
00199 public:
00200
00201 gzVec3(){};
00202 gzVec3(const gzReal &heading , const gzReal &pitch);
00203 gzVec3( const gzReal &v1_val, const gzReal &v2_val, const gzReal &v3_val):v1(v1_val),v2(v2_val),v3(v3_val){};
00204 gzVec3(const gzVec2 &right , const gzReal &v3_val=GZ_REAL_ONE):v1(right.v1),v2(right.v2),v3(v3_val){};
00205
00206 gzVoid set(const gzReal &v1_val, const gzReal &v2_val, const gzReal &v3_val){ v1=v1_val;v2=v2_val;v3=v3_val;}
00207
00208 gzReal dot(const gzVec3 &vector) const
00209 {
00210 return v1*vector.v1+v2*vector.v2+v3*vector.v3;
00211 }
00212
00213 gzReal length() const
00214 {
00215 return (gzReal)gzSqrt(v1*v1+v2*v2+v3*v3);
00216 }
00217
00218
00219 gzReal magnitude() const
00220 {
00221 return v1*v1+v2*v2+v3*v3;
00222 }
00223
00224
00225 gzVec3 unit() const
00226 {
00227 gzReal len(length());
00228 if(len)
00229 {
00230 gzReal invlen(GZ_REAL_ONE/len);
00231 return gzVec3(v1*invlen,v2*invlen,v3*invlen);
00232 }
00233 else
00234 return gzVec3(0,0,0);
00235 }
00236
00237 gzVec3 abs() const
00238 {
00239 return gzVec3(gzAbs(v1),gzAbs(v2),gzAbs(v3));
00240 }
00241
00242 gzVoid normalize()
00243 {
00244 gzReal len(length());
00245 if(!len)
00246 return;
00247
00248 gzReal invlen(GZ_REAL_ONE/len);
00249
00250 v1=v1*invlen;
00251 v2=v2*invlen;
00252 v3=v3*invlen;
00253 }
00254
00255
00256 gzBool operator==(const gzVec3 &vector) const GZ_NO_THROW { return (v1==vector.v1) && (v2==vector.v2) && (v3==vector.v3); }
00257 gzBool operator!=(const gzVec3 &vector) const GZ_NO_THROW { return (v1!=vector.v1) || (v2!=vector.v2) || (v3!=vector.v3); }
00258
00259 gzVec3 operator-() GZ_NO_THROW
00260 {
00261 return gzVec3(-v1,-v2,-v3);
00262 }
00263
00264 gzVec3 & operator+=(const gzVec3 &vector) GZ_NO_THROW
00265 {
00266 v1+=vector.v1;
00267 v2+=vector.v2;
00268 v3+=vector.v3;
00269 return *this;
00270 }
00271
00272 gzVec3 & operator-=(const gzVec3 &vector) GZ_NO_THROW
00273 {
00274 v1-=vector.v1;
00275 v2-=vector.v2;
00276 v3-=vector.v3;
00277 return *this;
00278 }
00279
00280 gzVec3 operator * (const gzReal &val) const GZ_NO_THROW
00281 {
00282 return gzVec3(v1*val,v2*val,v3*val);
00283 }
00284
00285 gzVec3 & operator *= (const gzReal &val) GZ_NO_THROW
00286 {
00287 v1*=val;
00288 v2*=val;
00289 v3*=val;
00290 return *this;
00291 }
00292
00293 gzVec3 operator / (const gzReal &val) const GZ_NO_THROW
00294 {
00295 gzReal inv=GZ_REAL_ONE/val;
00296 return gzVec3(v1*inv,v2*inv,v3*inv);
00297 }
00298
00299 gzVec3 operator - (const gzVec3 &vector_b) const GZ_NO_THROW
00300 {
00301 return gzVec3(v1-vector_b.v1,v2-vector_b.v2,v3-vector_b.v3);
00302 }
00303
00304 gzVec3 operator + (const gzVec3 &vector_b) const GZ_NO_THROW
00305 {
00306 return gzVec3(v1+vector_b.v1,v2+vector_b.v2,v3+vector_b.v3);
00307 }
00308
00309 gzVec3 cross(const gzVec3 &vector) const GZ_NO_THROW
00310 {
00311 return gzVec3(v2*vector.v3-v3*vector.v2,v3*vector.v1-v1*vector.v3,v1*vector.v2-v2*vector.v1);
00312 }
00313
00314
00315 gzVec2 project(const gzVec3 &normal) const;
00316
00317 gzString asString(const gzString &format="(%lf %lf %lf)") const ;
00318
00319 gzULong hash() const;
00320
00321 public:
00322
00323 union
00324 {
00325 struct
00326 {
00327 gzReal v1,v2,v3;
00328 };
00329 struct
00330 {
00331 gzReal x,y,z;
00332 };
00333 struct
00334 {
00335 gzReal r,g,b;
00336 };
00337 struct
00338 {
00339 gzReal heading,pitch,roll;
00340 };
00341 };
00342 };
00343
00344
00345
00346 inline gzVec3 operator * (const gzReal &val , const gzVec3 &vector)
00347 {
00348 return gzVec3(val*vector.v1,val*vector.v2,val*vector.v3);
00349 }
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367 class GZ_BASE_EXPORT gzVec4
00368 {
00369 public:
00370
00371 gzVec4(){};
00372 gzVec4( const gzReal &v1_val , const gzReal &v2_val, const gzReal &v3_val, const gzReal &v4_val):v1(v1_val),v2(v2_val),v3(v3_val),v4(v4_val){};
00373 gzVec4(const gzVec3 &right , const gzReal &v4_val=GZ_REAL_ONE):v1(right.v1),v2(right.v2),v3(right.v3),v4(v4_val){};
00374
00375 gzVoid set(const gzReal &v1_val, const gzReal &v2_val, const gzReal &v3_val , const gzReal &v4_val){ v1=v1_val;v2=v2_val;v3=v3_val;v4=v4_val;}
00376
00377 gzBool operator==(const gzVec4 &vector) const { return (v1==vector.v1) && (v2==vector.v2) && (v3==vector.v3) && (v4==vector.v4); }
00378 gzBool operator!=(const gzVec4 &vector) const { return (v1!=vector.v1) || (v2!=vector.v2) || (v3!=vector.v3) || (v4!=vector.v4); }
00379
00380
00381 gzVec3 trunc()
00382 {
00383 return gzVec3(v1,v2,v3);
00384 }
00385
00386 gzVec4 abs() const
00387 {
00388 return gzVec4(gzAbs(v1),gzAbs(v2),gzAbs(v3),gzAbs(v4));
00389 }
00390
00391
00392 gzVec4 & operator+=(const gzVec4 &vector)
00393 {
00394 v1+=vector.v1;
00395 v2+=vector.v2;
00396 v3+=vector.v3;
00397 v4+=vector.v4;
00398 return *this;
00399 }
00400
00401 gzVec4 & operator-=(const gzVec4 &vector)
00402 {
00403 v1-=vector.v1;
00404 v2-=vector.v2;
00405 v3-=vector.v3;
00406 v4-=vector.v4;
00407 return *this;
00408 }
00409
00410 gzVec4 & operator*=(const gzReal &factor)
00411 {
00412 v1*=factor;
00413 v2*=factor;
00414 v3*=factor;
00415 v4*=factor;
00416 return *this;
00417 }
00418
00419 gzVec4 operator * (const gzReal &val) const
00420 {
00421 return gzVec4(v1*val,v2*val,v3*val,v4*val);
00422 }
00423
00424 gzVec4 operator / (const gzReal &val) const
00425 {
00426 gzReal inv=GZ_REAL_ONE/val;
00427 return gzVec4(v1*inv,v2*inv,v3*inv,v4*inv);
00428 }
00429
00430 gzVec4 operator - (const gzVec4 &vector_b) const
00431 {
00432 return gzVec4(v1-vector_b.v1,v2-vector_b.v2,v3-vector_b.v3,v4-vector_b.v4);
00433 }
00434
00435 gzVec4 operator + (const gzVec4 &vector_b) const
00436 {
00437 return gzVec4(v1+vector_b.v1,v2+vector_b.v2,v3+vector_b.v3,v4+vector_b.v4);
00438 }
00439
00440 inline operator gzVec3 () const
00441 {
00442 if(v4==GZ_REAL_ONE)
00443 return gzVec3(v1,v2,v3);
00444
00445 gzReal inv4=GZ_REAL_ONE/v4;
00446 return gzVec3(v1*inv4,v2*inv4,v3*inv4);
00447 }
00448
00449 gzULong hash() const;
00450
00451 gzString asString(const gzString &format="(%lf %lf %lf %lf)") const ;
00452
00453 union
00454 {
00455 struct
00456 {
00457 gzReal v1,v2,v3,v4;
00458 };
00459 struct
00460 {
00461 gzReal x,y,z,w;
00462 };
00463 struct
00464 {
00465 gzReal r,g,b,a;
00466 };
00467 };
00468
00469 };
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485 class GZ_BASE_EXPORT gzMatrix2
00486 {
00487 public:
00488
00489 gzMatrix2(){};
00490
00491 gzMatrix2(const gzVec2 &column_1,const gzVec2 &column_2);
00492
00493 gzReal v11,v21;
00494 gzReal v12,v22;
00495 };
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 class GZ_BASE_EXPORT gzMatrix3
00512 {
00513 public:
00514
00515 gzMatrix3(){};
00516
00517 gzMatrix3(const gzVec3 &column_1,const gzVec3 &column_2,const gzVec3 &column_3);
00518
00519 gzReal v11,v21,v31;
00520 gzReal v12,v22,v32;
00521 gzReal v13,v23,v33;
00522 };
00523
00524
00525
00526 enum GZ_MATRIX3_IND { GZ3_V11,GZ3_V21,GZ3_V31,GZ3_V12,GZ3_V22,GZ3_V32,GZ3_V13,GZ3_V23,GZ3_V33};
00527 enum GZ_MATRIX4_IND { GZ4_V11,GZ4_V21,GZ4_V31,GZ4_V41,GZ4_V12,GZ4_V22,GZ4_V32,GZ4_V42,GZ4_V13,GZ4_V23,GZ4_V33,GZ4_V43,GZ4_V14,GZ4_V24,GZ4_V34,GZ4_V44 };
00528
00529 const gzVec2 GZ_ZERO_VEC2 =gzVec2(0,0);
00530 const gzVec3 GZ_ZERO_VEC3 =gzVec3(0,0,0);
00531 const gzVec4 GZ_ZERO_VEC4 =gzVec4(0,0,0,0);
00532
00533 const gzVec2 GZ_ONE_VEC2 =gzVec2(1,1);
00534 const gzVec3 GZ_ONE_VEC3 =gzVec3(1,1,1);
00535 const gzVec4 GZ_ONE_VEC4 =gzVec4(1,1,1,1);
00536
00537 const gzVec3 GZ_X_VEC3 =gzVec3(1,0,0);
00538 const gzVec3 GZ_Y_VEC3 =gzVec3(0,1,0);
00539 const gzVec3 GZ_Z_VEC3 =gzVec3(0,0,1);
00540
00541 const gzVec4 GZ_X_VEC4 =gzVec4(1,0,0,0);
00542 const gzVec4 GZ_Y_VEC4 =gzVec4(0,1,0,0);
00543 const gzVec4 GZ_Z_VEC4 =gzVec4(0,0,1,0);
00544 const gzVec4 GZ_W_VEC4 =gzVec4(0,0,0,1);
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560 class GZ_BASE_EXPORT gzMatrix4
00561 {
00562 public:
00563
00565
00566 gzMatrix4():isDirty(TRUE){};
00567
00569 gzMatrix4(const gzVec4 &column_1,const gzVec4 &column_2,const gzVec4 &column_3,const gzVec4 &column_4);
00570
00572
00573 gzMatrix4(const gzVec3 &column_1,const gzVec3 &column_2,const gzVec3 &column_3,gzEnum faceMatrixMode=GZ_CCW);
00574
00576 gzMatrix4(const gzMatrix3 &matrix,gzEnum faceMatrixMode=GZ_CCW);
00577
00578 gzMatrix4 & operator+=(const gzMatrix4 &matrix);
00579 gzMatrix4 & operator*=(const gzReal &value);
00580 gzMatrix4 & operator/=(const gzReal &value);
00581 gzMatrix4 & operator-=(const gzMatrix4 &matrix);
00582
00584 gzVoid identity();
00585
00587 gzReal determinant() const;
00588
00590
00593 gzBool getInvertedMatrix( gzMatrix4 &to ) const;
00594
00596
00599 gzVoid getTransposedMatrix( gzMatrix4 &to ) const;
00600
00602 gzVoid getVectorRotation( gzVec3 &vec , gzReal &angle , const gzVec3 &base=GZ_ONE_VEC3) const;
00603
00604 gzBool operator==(const gzMatrix4 &matrix) const ;
00605 gzBool operator!=(const gzMatrix4 &matrix) const { return !operator==(matrix); }
00606
00607 gzVoid setRow(gzInt row , const gzVec4 & vec);
00608 gzVoid setCol(gzInt col , const gzVec4 & vec);
00609
00610 gzVoid setRow(gzInt row , const gzVec3 & vec);
00611 gzVoid setCol(gzInt col , const gzVec3 & vec);
00612
00614 gzVoid updateFaceMatrixMode() GZ_NO_THROW ;
00615
00616
00617 gzReal v11,v21,v31,v41,v12,v22,v32,v42,v13,v23,v33,v43,v14,v24,v34,v44;
00618
00620
00621 gzBool isDirty;
00622
00624 gzEnum faceMatrixMode;
00625
00626 };
00627
00628
00629
00630 GZ_BASE_EXPORT gzMatrix4 operator * (const gzMatrix4 &mat1 , const gzMatrix4 &mat2);
00631 GZ_BASE_EXPORT gzMatrix4 operator + (const gzMatrix4 &mat1 , const gzMatrix4 &mat2);
00632 GZ_BASE_EXPORT gzMatrix4 operator - (const gzMatrix4 &mat1 , const gzMatrix4 &mat2);
00633
00634 GZ_BASE_EXPORT gzMatrix4 operator * ( const gzMatrix4 &mat1 , const gzReal &value);
00635 GZ_BASE_EXPORT gzMatrix4 operator / ( const gzMatrix4 &mat1 , const gzReal &value);
00636
00637 GZ_BASE_EXPORT gzVec4 operator * (const gzMatrix4 &mat , const gzVec4 &vec );
00638 GZ_BASE_EXPORT gzVec4 operator * (const gzVec4 &vec , const gzMatrix4 &mat );
00639
00640 GZ_BASE_EXPORT gzVec3 multiply (const gzMatrix4 &mat , const gzVec3 &vec );
00641 GZ_BASE_EXPORT gzVec3 multiply (const gzMatrix4 &mat , const gzVec3 &vec ,const gzReal &w );
00642 GZ_BASE_EXPORT gzVec3 normweight (const gzMatrix4 &mat , const gzVec3 &vec ,const gzReal &w=GZ_REAL_ONE );
00643 GZ_BASE_EXPORT gzVec4 operator * (const gzMatrix4 &mat , const gzVec3 &vec );
00644 GZ_BASE_EXPORT gzVec3 operator * (const gzMatrix3 &mat , const gzVec3 &vec );
00645
00646
00647
00649 GZ_BASE_EXPORT const gzMatrix4 &gzGetUnitMatrix() GZ_NO_THROW ;
00650
00651 GZ_BASE_EXPORT gzVoid gzGetTranslationMatrix( gzMatrix4 &matrix,gzReal dx , gzReal dy , gzReal dz ) GZ_NO_THROW ;
00652 GZ_BASE_EXPORT gzVoid gzGetTranslationMatrix( gzMatrix4 &matrix,const gzVec3 &translation ) GZ_NO_THROW ;
00653
00654 GZ_BASE_EXPORT gzVoid gzGetScaleMatrix( gzMatrix4 &matrix,gzReal dx , gzReal dy , gzReal dz ) GZ_NO_THROW ;
00655 GZ_BASE_EXPORT gzVoid gzGetScaleMatrix( gzMatrix4 &matrix, const gzVec3 &scale ) GZ_NO_THROW ;
00656
00657 GZ_BASE_EXPORT gzVoid gzGetBaseMatrix( gzMatrix4 &matrix , const gzVec3 &base ) GZ_NO_THROW ;
00658 GZ_BASE_EXPORT gzVoid gzGetBaseMatrix( gzMatrix4 &matrix , const gzVec3 &x_base,const gzVec3 &y_base) GZ_NO_THROW;
00659
00660 GZ_BASE_EXPORT gzVoid gzGetRotationMatrix( gzMatrix4 &matrix , const gzVec3 &base , gzReal angle)GZ_NO_THROW ;
00661 GZ_BASE_EXPORT gzVoid gzGetRotationMatrix( gzMatrix4 &matrix , gzReal heading , gzReal pitch , gzReal roll) GZ_NO_THROW ;
00662 GZ_BASE_EXPORT gzVoid gzGetRotationMatrix( gzMatrix4 &matrix , const gzVec3 &orientation) GZ_NO_THROW ;
00663
00664 GZ_BASE_EXPORT gzVoid gzGetBiasMatrix( gzMatrix4 &matrix , gzReal x_factor=1.0f ,gzReal x_offset=0.0f ,
00665 gzReal y_factor=1.0f ,gzReal y_offset=0.0f ,
00666 gzReal z_factor=1.0f ,gzReal z_offset=0.0f );
00667
00668 GZ_BASE_EXPORT gzBool gzIsPureTranslation( const gzMatrix4 &matrix , gzVec3 &translation);
00669
00670 GZ_BASE_EXPORT inline gzReal gzGetNormDot( const gzVec3 & a , const gzVec3 & b, const gzVec3 &c , const gzVec3 &dir) GZ_NO_THROW
00671 {
00672 gzReal x1(b.v1-a.v1);
00673 gzReal y1(c.v1-a.v1);
00674
00675 gzReal x2(b.v2-a.v2);
00676 gzReal y2(c.v2-a.v2);
00677
00678 gzReal x3(b.v3-a.v3);
00679 gzReal y3(c.v3-a.v3);
00680
00681 return (x2*y3-x3*y2)*dir.v1+(x3*y1-x1*y3)*dir.v2+(x1*y2-x2*y1)*dir.v3;
00682 }
00683
00684
00685 GZ_BASE_EXPORT inline gzVoid getExtendedVector(gzVec3 &dest, const gzVec3 &from, const gzVec3 &to , const gzReal &magnitude) GZ_NO_THROW
00686 {
00687 dest.v1=(to.v1-from.v1)*magnitude+to.v1;
00688 dest.v2=(to.v2-from.v2)*magnitude+to.v2;
00689 dest.v3=(to.v3-from.v3)*magnitude+to.v3;
00690 }
00691
00692
00693
00694
00695
00696
00697 template <> inline gzArray<gzVec2> & gzArray<gzVec2>::operator=(const gzArray ©)
00698 {
00699 if(©==this)
00700 return *this;
00701
00702 if(m_size<copy.m_size)
00703 {
00704 if(m_data)
00705 delete [] m_data;
00706
00707 m_size=copy.m_size;
00708
00709 if(copy.m_size)
00710 {
00711 m_data = new gzVec2[copy.m_size];
00712 }
00713 else
00714 m_data=NULL;
00715 }
00716 else
00717 m_size=copy.m_size;
00718
00719 memcpy(m_data,copy.m_data,m_size*sizeof(gzVec2));
00720
00721 return *this;
00722 }
00723
00724 template <> inline gzVoid gzDynamicArray<gzVec2>::transferToArray(gzArray<gzVec2> &array) const
00725 {
00726 array.setSize(m_currentSize);
00727 memcpy(array.getAddress(),m_data,m_currentSize*sizeof(gzVec2));
00728 }
00729
00730
00731
00732
00733 template <> inline gzArray<gzVec3> & gzArray<gzVec3>::operator=(const gzArray ©)
00734 {
00735 if(©==this)
00736 return *this;
00737
00738 if(m_size<copy.m_size)
00739 {
00740 if(m_data)
00741 delete [] m_data;
00742
00743 m_size=copy.m_size;
00744
00745 if(copy.m_size)
00746 {
00747 m_data = new gzVec3[copy.m_size];
00748 }
00749 else
00750 m_data=NULL;
00751 }
00752 else
00753 m_size=copy.m_size;
00754
00755 memcpy(m_data,copy.m_data,m_size*sizeof(gzVec3));
00756
00757 return *this;
00758 }
00759
00760 template <> inline gzVoid gzDynamicArray<gzVec3>::transferToArray(gzArray<gzVec3> &array) const
00761 {
00762 array.setSize(m_currentSize);
00763 memcpy(array.getAddress(),m_data,m_currentSize*sizeof(gzVec3));
00764 }
00765
00766
00767
00768 template <> inline gzArray<gzVec4> & gzArray<gzVec4>::operator=(const gzArray ©)
00769 {
00770 if(©==this)
00771 return *this;
00772
00773 if(m_size<copy.m_size)
00774 {
00775 if(m_data)
00776 delete [] m_data;
00777
00778 m_size=copy.m_size;
00779
00780 if(copy.m_size)
00781 {
00782 m_data = new gzVec4[copy.m_size];
00783 }
00784 else
00785 m_data=NULL;
00786 }
00787 else
00788 m_size=copy.m_size;
00789
00790 memcpy(m_data,copy.m_data,m_size*sizeof(gzVec4));
00791
00792 return *this;
00793 }
00794
00795 template <> inline gzVoid gzDynamicArray<gzVec4>::transferToArray(gzArray<gzVec4> &array) const
00796 {
00797 array.setSize(m_currentSize);
00798 memcpy(array.getAddress(),m_data,m_currentSize*sizeof(gzVec4));
00799 }
00800
00801
00802
00803 #endif