Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
pull submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
椎名深雪 committed Jan 4, 2020
1 parent 9dbc09f commit ceb8f21
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 81 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,26 @@ ENDIF()
#ENDIF()

add_library(core ${MiyukiAPI} ${libcoreSource})
target_link_libraries(core foundation ${CXX_FS_LIBS} ${OIDN_LIBRARIES})
target_link_libraries(core foundation ${CXX_FS_LIBS} ${OIDN_LIBRARIES} ${EMBREE_LIBRARY})

add_executable(myk.cli src/standalone-renderer/main.cpp ${MiyukiAPI})
target_link_libraries(myk.cli core ${EMBREE_LIBRARY})
target_link_libraries(myk.cli core)


add_executable(mesh-importer src/mesh-importer/importer.cpp ${MiyukiAPI})
target_link_libraries(mesh-importer core ${EMBREE_LIBRARY})
target_link_libraries(mesh-importer core)

file(GLOB serverSRC src/miyuki.server/*.*)
add_executable(miyuki.server ${serverSRC} ${MiyukiAPI})
if (WIN32)
target_compile_definitions(miyuki.server PUBLIC _WIN32_WINNT=0x0601)
endif ()
target_include_directories(miyuki.server PRIVATE external/cpp-httplib)
target_link_libraries(miyuki.server asio wsock32 ws2_32 core ${EMBREE_LIBRARY})
target_link_libraries(miyuki.server asio wsock32 ws2_32 core)


add_executable(test-sdtree tests/test-sdtree.cpp)
target_link_libraries(test-sdtree core)

add_executable(test-adt tests/test-adt.cpp )
target_link_libraries(test-adt foundation)
Binary file modified data/living_room/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion external/pybind11
4 changes: 4 additions & 0 deletions include/miyuki.renderer/atmoicfloat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ namespace miyuki {
explicit operator float() const {
return value();
}

void set(Float v){
bits = floatBitsToUint(v);
}
};
}
#endif //MIYUKIRENDERER_ATMOICFLOAT_HPP
75 changes: 0 additions & 75 deletions tests/mori_knob/imgui.ini

This file was deleted.

49 changes: 49 additions & 0 deletions tests/test-adt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// MIT License
//
// Copyright (c) 2019 椎名深雪
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include <variant>
#include <miyuki.foundation/vectorize.hpp>

#define MYK_DECL_METHOD(Ret, Name, ...) \
template<class T, class... Args> \
struct InvokeMember{ \
using type = decltype(std::declval<T&>().Name(std::declval<Args>()...)); \
}; \
template<class T, typename = void> \
struct has_##Name : std::false_type { \
}; \
template<class T> \
struct has_##Name <T, std::void_t<typename InvokeMember<T, __VA_ARGS__>::type>> : std::true_type { \
};

struct Foo {
MYK_DECL_METHOD(void, f, int)
};

struct Bar {
void g(int) {}
};

int main() {
// static_assert(std::is_same_v<std::invoke_result_t<Foo::f, Foo, void>, void>);

}
134 changes: 134 additions & 0 deletions tests/test-sdtree.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// MIT License
//
// Copyright (c) 2019 椎名深雪
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include <miyuki.renderer/atmoicfloat.hpp>

namespace miyuki {
class QTreeNode {
public:
struct Index {
int i;

explicit Index(int i) : i(i) {}

QTreeNode *get() const;
};

Bounds2f box;
std::array<AtomicFloat, 4> _means;
std::array<Index, 4> _children;


QTreeNode(const QTreeNode &node) : box(node.box), _children(node._children) {
for (int i = 0; i < 4; i++) {
_means[i].set(float(node._means[i]));
}
}

int childIndex(const Point2f &p) const {
int x, y;
if (p.x < box.centroid().x) {
x = 0;
} else {
x = 1;
}
if (p.y < box.centroid().y) {
y = 0;
} else {
y = 1;
}
return x + 2 * y;
}

bool isLeaf(const Index &idx) const {
return idx.get() == nullptr;
}

float eval(const Point2f &p) const {
auto idx = childIndex(p);
if(isLeaf(_children[idx])){
return float(_means[idx]);
}else{

}
}

Point2f sample(Point2f u, Float *pdf) const {
std::array<float, 4> m = {
float(_means[0]),
float(_means[1]),
float(_means[2]),
float(_means[3])
};
auto left = m[0] + m[2];
auto right = m[1] + m[3];
auto total = left + right;
int x, y;
float p = 1;
if (u[0] < left / total) {
x = 0;
p *= left / total;
u[0] /= left / total;
} else {
x = 1;
p *= right / total;
u[0] /= right / total;
}
auto up = m[x];
auto down = m[2 + x];
total = up + down;
if (u[1] < up / total) {
y = 0;
p *= up / total;
u[1] /= up / total;
} else {
y = 1;
p *= down / total;
u[1] /= down / total;
}
int child = x + 2 * y;
if (_children[child].get()) {
float p0;
auto sampled = sample(u, &p0);
*pdf = p0 * p;
return sampled;
} else {
*pdf = p;
return Point2f(lerp(box.pMin, box.pMax, u));
}
}


void subdivide(const std::vector<QTreeNode> &nodes) {

}
};

class QTree {
public:
};
}


int main() {

}

0 comments on commit ceb8f21

Please sign in to comment.