• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Razakhel / RaZ / 14911398753

08 May 2025 04:28PM UTC coverage: 74.465% (-0.1%) from 74.578%
14911398753

push

github

Razakhel
[Data/MeshDistanceField] Made use of the Grid3 type for the MDF

5 of 5 new or added lines in 2 files covered. (100.0%)

3 existing lines in 3 files now uncovered.

8206 of 11020 relevant lines covered (74.46%)

1786.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.74
/src/RaZ/Script/LuaData.cpp
1
#include "RaZ/Data/Bitset.hpp"
2
#include "RaZ/Data/BoundingVolumeHierarchy.hpp"
3
#include "RaZ/Data/BoundingVolumeHierarchySystem.hpp"
4
#include "RaZ/Data/Color.hpp"
5
#include "RaZ/Data/Image.hpp"
6
#include "RaZ/Data/MeshDistanceField.hpp"
7
#include "RaZ/Script/LuaWrapper.hpp"
8
#include "RaZ/Utils/TypeUtils.hpp"
9

10
#define SOL_ALL_SAFETIES_ON 1
11
#include "sol/sol.hpp"
12

13
namespace Raz {
14

15
using namespace TypeUtils;
16

17
void LuaWrapper::registerDataTypes() {
2✔
18
  sol::state& state = getState();
2✔
19

20
  {
21
    sol::usertype<Bitset> bitset = state.new_usertype<Bitset>("Bitset",
22
                                                              sol::constructors<Bitset(),
×
23
                                                                                Bitset(std::size_t),
24
                                                                                Bitset(std::size_t, bool)>());
2✔
25
    bitset["getSize"]             = &Bitset::getSize;
2✔
26
    bitset["isEmpty"]             = &Bitset::isEmpty;
2✔
27
    bitset["getEnabledBitCount"]  = &Bitset::getEnabledBitCount;
2✔
28
    bitset["getDisabledBitCount"] = &Bitset::getDisabledBitCount;
2✔
29
    bitset["setBit"]              = sol::overload([] (Bitset& b, std::size_t p) { b.setBit(p); },
2✔
30
                                                  PickOverload<std::size_t, bool>(&Bitset::setBit));
4✔
31
    bitset["resize"]              = &Bitset::resize;
2✔
32
    bitset["reset"]               = &Bitset::reset;
2✔
33
    bitset["clear"]               = &Bitset::clear;
2✔
34
    bitset.set_function(sol::meta_function::bitwise_not, &Bitset::operator~);
2✔
35
    bitset.set_function(sol::meta_function::bitwise_and, &Bitset::operator&);
2✔
36
    bitset.set_function(sol::meta_function::bitwise_or, &Bitset::operator|);
2✔
37
    bitset.set_function(sol::meta_function::bitwise_xor, &Bitset::operator^);
2✔
38
    bitset.set_function(sol::meta_function::bitwise_left_shift, &Bitset::operator<<);
2✔
39
    bitset.set_function(sol::meta_function::bitwise_right_shift, &Bitset::operator>>);
2✔
40
    bitset.set_function(sol::meta_function::index, &Bitset::operator[]);
2✔
41
  }
2✔
42

43
  {
44
    {
45
      sol::usertype<BoundingVolumeHierarchyNode> bvhNode = state.new_usertype<BoundingVolumeHierarchyNode>("BoundingVolumeHierarchyNode",
46
                                                                                                           sol::constructors<BoundingVolumeHierarchyNode()>());
2✔
47
      bvhNode["getBoundingBox"] = &BoundingVolumeHierarchyNode::getBoundingBox;
2✔
48
      bvhNode["hasLeftChild"]   = &BoundingVolumeHierarchyNode::hasLeftChild;
2✔
49
      bvhNode["getLeftChild"]   = [] (const BoundingVolumeHierarchyNode& n) { return &n.getLeftChild(); };
2✔
50
      bvhNode["hasRightChild"]  = &BoundingVolumeHierarchyNode::hasRightChild;
2✔
51
      bvhNode["getRightChild"]  = [] (const BoundingVolumeHierarchyNode& n) { return &n.getRightChild(); };
2✔
52
      bvhNode["getTriangle"]    = &BoundingVolumeHierarchyNode::getTriangle;
2✔
53
      bvhNode["isLeaf"]         = &BoundingVolumeHierarchyNode::isLeaf;
2✔
54
      bvhNode["query"]          = sol::overload([] (const BoundingVolumeHierarchyNode& n, const Ray& r) { return n.query(r); },
3✔
55
                                                PickOverload<const Ray&, RayHit*>(&BoundingVolumeHierarchyNode::query));
4✔
56
    }
2✔
57

58
    {
59
      sol::usertype<BoundingVolumeHierarchy> bvh = state.new_usertype<BoundingVolumeHierarchy>("BoundingVolumeHierarchy",
60
                                                                                               sol::constructors<BoundingVolumeHierarchy()>());
2✔
61
      bvh["getRootNode"] = [] (const BoundingVolumeHierarchy& b) { return &b.getRootNode(); };
3✔
62
      // Sol doesn't seem to be able to bind a constant reference to std::vector; leaving a copy here as it is "cheap"
63
      bvh["build"]       = [] (BoundingVolumeHierarchy& b, std::vector<Entity*> e) { b.build(e); };
3✔
64
      bvh["query"]       = sol::overload([] (const BoundingVolumeHierarchy& b, const Ray& r) { return b.query(r); },
3✔
65
                                         PickOverload<const Ray&, RayHit*>(&BoundingVolumeHierarchy::query));
4✔
66
    }
2✔
67

68
    {
69
      sol::usertype<BoundingVolumeHierarchySystem> bvhSystem = state.new_usertype<BoundingVolumeHierarchySystem>("BoundingVolumeHierarchySystem",
70
                                                                                                                 sol::constructors<
×
71
                                                                                                                   BoundingVolumeHierarchySystem()
72
                                                                                                                 >(),
73
                                                                                                                 sol::base_classes, sol::bases<System>());
2✔
74
      bvhSystem["getBvh"] = [] (BoundingVolumeHierarchySystem& s) { return &s.getBvh(); };
3✔
75
    }
2✔
76
  }
77

78
  {
79
    sol::usertype<Color> color = state.new_usertype<Color>("Color",
80
                                                           sol::constructors<Color(),
×
81
                                                                             Color(const Vec3f&),
82
                                                                             Color(float, float, float),
83
                                                                             Color(const Vec3b&),
84
                                                                             Color(uint32_t)>());
2✔
85
    color["red"]   = PickConstOverload<>(&Color::red);
2✔
86
    color["green"] = PickConstOverload<>(&Color::green);
2✔
87
    color["blue"]  = PickConstOverload<>(&Color::blue);
2✔
88
    color["toVec"] = &Color::operator const Vec3f&;
2✔
89

90
    sol::table colorPreset     = state["ColorPreset"].get_or_create<sol::table>();
2✔
91
    colorPreset["Black"]       = ColorPreset::Black;
2✔
92
    colorPreset["Gray"]        = ColorPreset::Gray;
2✔
93
    colorPreset["Red"]         = ColorPreset::Red;
2✔
94
    colorPreset["Green"]       = ColorPreset::Green;
2✔
95
    colorPreset["Blue"]        = ColorPreset::Blue;
2✔
96
    colorPreset["MediumRed"]   = ColorPreset::MediumRed;
2✔
97
    colorPreset["MediumGreen"] = ColorPreset::MediumGreen;
2✔
98
    colorPreset["MediumBlue"]  = ColorPreset::MediumBlue;
2✔
99
    colorPreset["Cyan"]        = ColorPreset::Cyan;
2✔
100
    colorPreset["Magenta"]     = ColorPreset::Magenta;
2✔
101
    colorPreset["Yellow"]      = ColorPreset::Yellow;
2✔
102
    colorPreset["White"]       = ColorPreset::White;
2✔
103
  }
2✔
104

105
  {
106
    sol::usertype<Grid3b> grid3b = state.new_usertype<Grid3b>("Grid3b",
107
                                                              sol::constructors<Grid3b(unsigned int, unsigned int, unsigned int)>());
2✔
108
    grid3b["getValue"] = &Grid3b::getValue;
2✔
109
    grid3b["setValue"] = &Grid3b::setValue;
2✔
110

111
    sol::usertype<Grid3f> grid3f = state.new_usertype<Grid3f>("Grid3f",
112
                                                              sol::constructors<Grid3f(unsigned int, unsigned int, unsigned int)>());
2✔
113
    grid3f["getValue"] = &Grid3f::getValue;
2✔
114
    grid3f["setValue"] = &Grid3f::setValue;
2✔
115
  }
2✔
116

117
  {
118
    sol::usertype<MeshDistanceField> mdf = state.new_usertype<MeshDistanceField>("MeshDistanceField",
UNCOV
119
                                                                                 sol::constructors<
×
120
                                                                                   MeshDistanceField(const AABB&, unsigned int, unsigned int, unsigned int)
121
                                                                                 >(),
122
                                                                                 sol::base_classes, sol::bases<Grid3f>());
2✔
123
    mdf["setBvh"]        = &MeshDistanceField::setBvh;
2✔
124
    mdf["compute"]       = &MeshDistanceField::compute;
2✔
125
    mdf["recoverSlices"] = &MeshDistanceField::recoverSlices;
2✔
126
  }
2✔
127
}
2✔
128

129
} // namespace Raz
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc