Browse Source

pushing buggy code is a thing I do deal with it this is devel not stable

devel
Ludovic 'Archivist' Lagouardette 4 years ago
parent
commit
946ace445d
3 changed files with 16 additions and 15 deletions
  1. +1
    -1
      Makefile
  2. +7
    -6
      include/gp/function.hpp
  3. +8
    -8
      tests/math.cpp

+ 1
- 1
Makefile View File

@ -1,6 +1,6 @@
CXX= clang++-8
CXXFLAGS= --std=c++17 -O0 -pthread -DGP_TESTS -DFUZZ_STRENGTH=500 -pedantic -Werror \
-Wno-unknown-attributes \
-Wno-unknown-attributes -frtti \
-g -fprofile-instr-generate -fcoverage-mapping
# -fsanitize=address -fno-omit-frame-pointer
all: tests

+ 7
- 6
include/gp/function.hpp View File

@ -30,6 +30,7 @@ namespace gp{
}
};
// tweak a way to store a size in there for trivial copy
enum state_t : uint8_t{
INACTIVE = 0,
ACTIVE = 1,
@ -51,7 +52,7 @@ namespace gp{
{
if(state & SOO)
{
((virtual_callable*)o">&self)->~virtual_callable();
((virtual_callable*)n">self.inplace)->~virtual_callable();
}
else
{
@ -60,12 +61,12 @@ namespace gp{
}
if constexpr (sizeof(callable<T>) <= sizeof(self))
{
new((void*)o">&self) callable(t);
new((void*)n">self.inplace) callable(t);
state = (state_t)(ACTIVE | SOO);
}
else
{
self = new callable(t);
self.functor = new callable<T>(t);
state = (state_t)(ACTIVE | NO_SOO);
}
}
@ -80,12 +81,12 @@ namespace gp{
{
if constexpr (sizeof(callable<T>) <= sizeof(self))
{
new((void*)o">&self) callable<T>(t);
new((void*)n">self.inplace) callable<T>(t);
state = (state_t)(ACTIVE | SOO);
}
else
{
self = new callable<T>(t);
self.functor = new callable<T>(t);
state = (state_t)(ACTIVE | NO_SOO);
}
}
@ -119,7 +120,7 @@ namespace gp{
}
else
{
return (*p">(self.functor))(arg_list...);
return (*self.functor)(arg_list...);
}
}

+ 8
- 8
tests/math.cpp View File

@ -78,24 +78,24 @@ struct render_test : public test_scaffold {
}
);
auto l_sdf = gp::difference_sdf<float>(
gp::sphere_sdf<float>({0.0,0.0,0.0}, 1.0),
gp::sphere_sdf<float>({-0.75,0.0,0.0}, 1.0)
);
auto sphere = a.scene_elements.push(
[=](vec3 pos) -> render_point {
[&](vec3 pos) -> render_point {
render_point ret;
const auto l_sdf = gp::difference_sdf<float>(
gp::sphere_sdf<float>({0.0,0.0,0.0}, 1.0),
gp::sphere_sdf<float>({-0.75,0.0,0.0}, 1.0)
);
ret.distance = l_sdf(pos);
ret.material = red;
return ret;
}
);
auto l_sdf_b = gp::sphere_sdf<float>({-0.75,0.0,0.0}, 1.0);
auto sphere2 = a.scene_elements.push(
[=](vec3 pos) -> render_point {
[&](vec3 pos) -> render_point {
render_point ret;
const auto l_sdf = gp::sphere_sdf<float>({-0.75,0.0,0.0}, 1.0);
ret.distance = l_sdf(pos);
ret.distance = l_sdf_b(pos);
ret.material = green;
return ret;
}

Loading…
Cancel
Save