|
38 | 38 | #include <geode/basic/pimpl_impl.hpp> |
39 | 39 | #include <geode/basic/uuid.hpp> |
40 | 40 |
|
| 41 | +#include <geode/geometry/angle.hpp> |
41 | 42 | #include <geode/geometry/basic_objects/infinite_line.hpp> |
42 | 43 | #include <geode/geometry/basic_objects/polygon.hpp> |
43 | 44 | #include <geode/geometry/basic_objects/segment.hpp> |
@@ -1205,9 +1206,25 @@ namespace geode |
1205 | 1206 | Vector3D normal; |
1206 | 1207 | for( const auto& polygon : polygons_around_vertex( vertex_id ) ) |
1207 | 1208 | { |
1208 | | - if( const auto p_normal = polygon_normal( polygon.polygon_id ) ) |
| 1209 | + const auto polygon_id = polygon.polygon_id; |
| 1210 | + if( const auto p_normal = polygon_normal( polygon_id ) ) |
1209 | 1211 | { |
1210 | | - normal = normal + p_normal.value(); |
| 1212 | + const auto local_id = |
| 1213 | + this->vertex_in_polygon( polygon_id, vertex_id ); |
| 1214 | + const auto polygon_vertex = |
| 1215 | + PolygonVertex( polygon_id, local_id.value() ); |
| 1216 | + const auto previous_vertex = |
| 1217 | + this->previous_polygon_vertex( polygon_vertex ); |
| 1218 | + const auto next_vertex = |
| 1219 | + this->next_polygon_vertex( polygon_vertex ); |
| 1220 | + const Vector3D prev{ this->point( this->polygon_vertex( |
| 1221 | + previous_vertex ) ), |
| 1222 | + this->point( vertex_id ) }; |
| 1223 | + const Vector3D next{ this->point( |
| 1224 | + this->polygon_vertex( next_vertex ) ), |
| 1225 | + this->point( vertex_id ) }; |
| 1226 | + const auto angle = Angle::create_from_vectors( prev, next ); |
| 1227 | + normal = normal + p_normal.value() * angle.radians(); |
1211 | 1228 | } |
1212 | 1229 | } |
1213 | 1230 | try |
|
0 commit comments