1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "nel/pacs/exterior_mesh.h"
20 #include "nel/pacs/local_retriever.h"
21 #include "nel/pacs/collision_desc.h"
25 using namespace NLMISC
;
29 // Functions for vertices comparison.
30 // total order relation
31 static inline bool isStrictlyLess(const CVector
&a
, const CVector
&b
)
33 if (a
.x
< b
.x
) return true;
34 if (a
.x
> b
.x
) return false;
35 if (a
.y
< b
.y
) return true;
36 if (a
.y
> b
.y
) return false;
37 if (a
.z
< b
.y
) return true;
41 static inline bool isStrictlyGreater(const CVector
&a
, const CVector
&b
)
43 if (a
.x
> b
.x
) return true;
44 if (a
.x
< b
.x
) return false;
45 if (a
.y
> b
.y
) return true;
46 if (a
.y
< b
.y
) return false;
47 if (a
.z
> b
.y
) return true;
51 CExteriorMesh::CExteriorMesh() { }
53 void CExteriorMesh::setEdges(const vector
<CExteriorMesh::CEdge
> &edges
)
56 _OrderedEdges
.clear();
59 for (i
=0; i
+1<_Edges
.size(); )
61 _OrderedEdges
.resize(_OrderedEdges
.size()+1);
62 COrderedEdges
&edges
= _OrderedEdges
.back();
64 if (isStrictlyLess(_Edges
[i
].Start
, _Edges
[i
+1].Start
))
71 while (i
+1<_Edges
.size() && _Edges
[i
].Link
!= -2 && isStrictlyLess(_Edges
[i
].Start
, _Edges
[i
+1].Start
));
75 edges
.Forward
= false;
80 while (i
+1<_Edges
.size() && _Edges
[i
].Link
!= -2 && isStrictlyGreater(_Edges
[i
].Start
, _Edges
[i
+1].Start
));
84 if (_Edges
[i
].Link
== -2)
89 void CExteriorMesh::serial(NLMISC::IStream
&f
)
95 (void)f
.serialVersion(0);
98 f
.serialCont(_OrderedEdges
);