|
2 | 2 | #define _ITTERATE_ADJACENTS_STATIC_H_
|
3 | 3 | #include "common/face_smoth_flags.h"
|
4 | 4 |
|
| 5 | +extern XRLC_LIGHT_API bool g_using_smooth_groups; |
| 6 | +extern XRLC_LIGHT_API bool g_smooth_groups_by_faces; |
| 7 | + |
5 | 8 | template<typename typeVertex>
|
6 | 9 | struct itterate_adjacents_params_static
|
7 | 10 | {
|
8 |
| - typedef typeVertex type_vertex; |
9 |
| - typedef typename typeVertex::type_face type_face; |
10 |
| - typedef xr_vector<type_face*> vecFace; |
| 11 | + typedef typeVertex type_vertex; |
| 12 | + typedef typename typeVertex::type_face type_face; |
| 13 | + typedef xr_vector<type_face*> vecFace; |
11 | 14 |
|
12 | 15 | private:
|
13 |
| - |
14 |
| - const type_vertex* pTestVertex; |
15 |
| - vecFace& new_adj_vec; |
16 |
| - const float sm_cos; |
| 16 | + |
| 17 | + const type_vertex* pTestVertex; |
| 18 | + vecFace& new_adj_vec; |
| 19 | + const float sm_cos; |
17 | 20 | public:
|
18 |
| - itterate_adjacents_params_static( |
19 |
| - const type_vertex* _pTestVertex, |
20 |
| - vecFace& _new_adj_vec, |
21 |
| - float _sm_cos |
22 |
| - ): |
23 |
| - pTestVertex (_pTestVertex) , |
24 |
| - new_adj_vec (_new_adj_vec) , |
25 |
| - sm_cos (_sm_cos) |
26 |
| - {} |
| 21 | + itterate_adjacents_params_static( |
| 22 | + const type_vertex* _pTestVertex, |
| 23 | + vecFace& _new_adj_vec, |
| 24 | + float _sm_cos |
| 25 | + ): |
| 26 | + pTestVertex (_pTestVertex) , |
| 27 | + new_adj_vec (_new_adj_vec) , |
| 28 | + sm_cos (_sm_cos) |
| 29 | + {} |
27 | 30 |
|
28 | 31 | private:
|
29 |
| - IC static bool has_same_edge(const type_face* F1, const type_face* F2, u16 &F1_edge_index, u16 &F2_edge_index ) |
30 |
| - { |
31 |
| - F1_edge_index = u16(-1); |
32 |
| - F2_edge_index = u16(-1); |
33 |
| - |
34 |
| - for (int e=0; e<3; e++) |
35 |
| - { |
36 |
| - type_vertex *v1_a, *v1_b; |
37 |
| - F1->EdgeVerts(e,&v1_a,&v1_b); |
38 |
| - if (v1_a>v1_b) |
39 |
| - swap(v1_a,v1_b); |
40 |
| - |
41 |
| - for (int r=0; r<3; ++r) |
42 |
| - { |
43 |
| - type_vertex *v2_a, *v2_b; |
44 |
| - F2->EdgeVerts(r,&v2_a,&v2_b); |
45 |
| - if (v2_a>v2_b) |
46 |
| - swap(v2_a,v2_b); |
47 |
| - |
48 |
| - if ((v1_a==v2_a)&&(v1_b==v2_b)) |
49 |
| - { |
50 |
| - F1_edge_index = e; |
51 |
| - F2_edge_index = r; |
52 |
| - return true; |
53 |
| - } |
54 |
| - } |
55 |
| - } |
56 |
| - return false; |
57 |
| - } |
| 32 | + IC static bool has_same_edge(const type_face* F1, const type_face* F2, u16 &F1_edge_index, u16 &F2_edge_index ) |
| 33 | + { |
| 34 | + F1_edge_index = u16(-1); |
| 35 | + F2_edge_index = u16(-1); |
| 36 | + |
| 37 | + for (int e=0; e<3; e++) |
| 38 | + { |
| 39 | + type_vertex *v1_a, *v1_b; |
| 40 | + F1->EdgeVerts(e,&v1_a,&v1_b); |
| 41 | + if (v1_a>v1_b) |
| 42 | + swap(v1_a,v1_b); |
| 43 | + |
| 44 | + for (int r=0; r<3; ++r) |
| 45 | + { |
| 46 | + type_vertex *v2_a, *v2_b; |
| 47 | + F2->EdgeVerts(r,&v2_a,&v2_b); |
| 48 | + if (v2_a>v2_b) |
| 49 | + swap(v2_a,v2_b); |
| 50 | + |
| 51 | + if ((v1_a==v2_a)&&(v1_b==v2_b)) |
| 52 | + { |
| 53 | + F1_edge_index = e; |
| 54 | + F2_edge_index = r; |
| 55 | + return true; |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | + return false; |
| 60 | + } |
58 | 61 |
|
59 | 62 |
|
60 | 63 | IC static bool do_connect_faces( const type_face &start, const type_face &test, u16 start_common_edge_idx, u16 test_common_edge_idx, float sm_cos )
|
61 |
| - { |
62 |
| - if( g_using_smooth_groups ) |
63 |
| - { |
64 |
| - if( g_smooth_groups_by_faces ) |
65 |
| - return ( start.sm_group != u32(-1) && |
66 |
| - start.sm_group == test.sm_group ); |
67 |
| - else |
68 |
| - return do_connect_faces_by_faces_edge_flags( start.sm_group, test.sm_group, start_common_edge_idx, test_common_edge_idx ); |
69 |
| - } |
70 |
| - else |
71 |
| - { |
72 |
| - float cosa = start.N.dotproduct(test.N); |
73 |
| - return ( cosa>sm_cos ) ; |
74 |
| - } |
75 |
| - } |
| 64 | + { |
| 65 | + if( g_using_smooth_groups ) |
| 66 | + { |
| 67 | + if( g_smooth_groups_by_faces ) |
| 68 | + return ( start.sm_group != u32(-1) && |
| 69 | + start.sm_group == test.sm_group ); |
| 70 | + else |
| 71 | + return do_connect_faces_by_faces_edge_flags( start.sm_group, test.sm_group, start_common_edge_idx, test_common_edge_idx ); |
| 72 | + } |
| 73 | + else |
| 74 | + { |
| 75 | + float cosa = start.N.dotproduct(test.N); |
| 76 | + return ( cosa>sm_cos ) ; |
| 77 | + } |
| 78 | + } |
76 | 79 |
|
77 | 80 | public:
|
78 | 81 |
|
79 | 82 |
|
80 |
| - IC const u32 current_adjacents_size( ) const |
81 |
| - { |
82 |
| - VERIFY(pTestVertex); |
83 |
| - return u32( pTestVertex->m_adjacents.size() ); |
84 |
| - } |
85 |
| - |
86 |
| - IC type_face* current_adjacents_face( u32 i ) const |
87 |
| - { |
88 |
| - VERIFY( pTestVertex ); |
89 |
| - return pTestVertex->m_adjacents[i]; |
90 |
| - } |
91 |
| - |
92 |
| - IC bool is_processed( const type_face &f ) const |
93 |
| - { |
94 |
| - return f.flags.bSplitted; |
95 |
| - } |
96 |
| - |
97 |
| - IC bool add_adjacents( u32 start_face_idx, u32 test_face_idx ) |
98 |
| - { |
99 |
| - const type_face *start_face = current_adjacents_face( start_face_idx ); |
100 |
| - type_face *test_face = current_adjacents_face( test_face_idx ); |
101 |
| - if(is_processed(*test_face)) |
102 |
| - return false; |
103 |
| - u16 StartFace_common_edge_index = u16(-1); |
104 |
| - u16 TestFace_common_edge_index = u16(-1); |
105 |
| - if ( has_same_edge( start_face, test_face, StartFace_common_edge_index, TestFace_common_edge_index ) ) |
106 |
| - { |
107 |
| - if ( (start_face==test_face) || do_connect_faces( *start_face, *test_face, StartFace_common_edge_index, TestFace_common_edge_index, sm_cos ) ) |
108 |
| - { |
109 |
| - new_adj_vec.push_back ( test_face ); |
110 |
| - test_face->flags.bSplitted = true; |
111 |
| - return true; |
112 |
| - } |
113 |
| - } |
114 |
| - return false; |
115 |
| - } |
| 83 | + IC const u32 current_adjacents_size( ) const |
| 84 | + { |
| 85 | + VERIFY(pTestVertex); |
| 86 | + return u32( pTestVertex->m_adjacents.size() ); |
| 87 | + } |
| 88 | + |
| 89 | + IC type_face* current_adjacents_face( u32 i ) const |
| 90 | + { |
| 91 | + VERIFY( pTestVertex ); |
| 92 | + return pTestVertex->m_adjacents[i]; |
| 93 | + } |
| 94 | + |
| 95 | + IC bool is_processed( const type_face &f ) const |
| 96 | + { |
| 97 | + return f.flags.bSplitted; |
| 98 | + } |
| 99 | + |
| 100 | + IC bool add_adjacents( u32 start_face_idx, u32 test_face_idx ) |
| 101 | + { |
| 102 | + const type_face *start_face = current_adjacents_face( start_face_idx ); |
| 103 | + type_face *test_face = current_adjacents_face( test_face_idx ); |
| 104 | + if(is_processed(*test_face)) |
| 105 | + return false; |
| 106 | + u16 StartFace_common_edge_index = u16(-1); |
| 107 | + u16 TestFace_common_edge_index = u16(-1); |
| 108 | + if ( has_same_edge( start_face, test_face, StartFace_common_edge_index, TestFace_common_edge_index ) ) |
| 109 | + { |
| 110 | + if ( (start_face==test_face) || do_connect_faces( *start_face, *test_face, StartFace_common_edge_index, TestFace_common_edge_index, sm_cos ) ) |
| 111 | + { |
| 112 | + new_adj_vec.push_back ( test_face ); |
| 113 | + test_face->flags.bSplitted = true; |
| 114 | + return true; |
| 115 | + } |
| 116 | + } |
| 117 | + return false; |
| 118 | + } |
116 | 119 |
|
117 | 120 | };
|
118 | 121 |
|
|
0 commit comments