1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  | 
#ifndef G3D_Welder_h
#define G3D_Welder_h
#include "G3D/platform.h"
#include "G3D/Array.h"
#include "G3D/Vector3.h"
#include "G3D/Vector2.h"
namespace G3D {
class Any;
class Welder {
private:
    Welder() {}
public:
    class Settings {
    public:
        /** Surfaces with normals that are within this angle of each
            other are considered to be curved.  Default value is toRadians(70.0f).*/
        float   normalSmoothingAngle;
        /** Default value is 0 */
        float      vertexWeldRadius;
        float      textureWeldRadius;
        float      normalWeldRadius;
        inline Settings(float normalSmoothAngle = toRadians(70.0f)) : 
            normalSmoothingAngle(normalSmoothAngle),
            vertexWeldRadius(0.001f), 
            textureWeldRadius(0.0001f), 
            normalWeldRadius(0.01f) {}
        Settings(const Any& any);
        
        Any toAny() const;
        void serialize(class BinaryOutput& b) const;
        void deserialize(class BinaryInput& b);
    };
/**
     Mutates geometry, texCoord, and indexArray so that the output has
     collocated vertices collapsed (welded).
     @param vertices Input and output
     @param textureCoords Input and output
     @param normals Output only
     @param indices Input and output. This is an array of trilist indices. 
     */
    static void weld(
        Array<Vector3>&     vertices,
        Array<Vector2>&     textureCoords, 
        Array<Vector3>&     normals,
        Array<Array<int>*>& indices,
        const Settings&     settings);
    /**
     Mutates geometry, texCoord, and indexArray so that the output has collocated vertices collapsed (welded).
     @param vertices Input and output
     @param textureCoords Input and output
     @param normals Output only
     @param indices Input and output. This is an array of trilist indices. 
     */
    inline static void weld(
        Array<Vector3>&     vertices,
        Array<Vector2>&     textureCoords, 
        Array<Vector3>&     normals,
        Array<int>&         indices,        
        const Settings&     settings) {
        Array<Array<int>*> meta;
        meta.append(&indices);
        weld(vertices, textureCoords, normals, meta, settings);
    }
};
}
#endif
 
  |