Commit 58714ae1 authored by Florian Oetke's avatar Florian Oetke
Browse files

added antipodality handling for DQS

parent 4a146e26
......@@ -39,7 +39,7 @@ build_clang:
- cmake -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=../bin -DCMAKE_BUILD_TYPE=Release -DMIRRAGE_EXPORT_EXECUTABLE=ON ..
- cmake --build . --target src/install
- cmake --build . --target test
- wget -N https://github.com/lowkey42/mirrage/releases/download/v0.2/model_data_lbs.tar.xz || true
- wget https://github.com/lowkey42/mirrage/releases/download/v0.2/model_data_lbs.tar.xz || true
- cd bin/bin
- tar xf ../../model_data_lbs.tar.xz
artifacts:
......
......@@ -47,10 +47,25 @@ void main() {
float unused_weight = 1.0 - dot(bone_weights, vec4(1.0));
mat3x4 identity_dqs = mat3x4(vec4(1,0,0,0), vec4(0,0,0,0), vec4(1,1,1,1));
mat3x4 bone = bones.offset[bone_ids[0]] * bone_weights[0]
+ bones.offset[bone_ids[1]] * bone_weights[1]
+ bones.offset[bone_ids[2]] * bone_weights[2]
+ bones.offset[bone_ids[3]] * bone_weights[3]
mat3x4[] dq = mat3x4[](
bones.offset[bone_ids[0]],
bones.offset[bone_ids[1]],
bones.offset[bone_ids[2]],
bones.offset[bone_ids[3]]
);
// antipodality handling
for(uint i=1; i<=3; i++) {
if (dot(dq[0][0], dq[i][0]) < 0.0) {
dq[i][0] *= -1.0;
dq[i][1] *= -1.0;
}
}
mat3x4 bone = dq[0] * bone_weights[0]
+ dq[1] * bone_weights[1]
+ dq[2] * bone_weights[2]
+ dq[3] * bone_weights[3]
+ identity_dqs * unused_weight;
float dq_len = length(bone[0]);
bone[0] /= dq_len;
......@@ -59,8 +74,6 @@ void main() {
vec3 p = transform_position(position, bone);
vec3 n = transform_normal (normal, bone);
//vec3 p = position;
//vec3 n = normal;
vec4 view_pos = model_uniforms.model_to_view * vec4(p, 1.0);
......
......@@ -89,13 +89,13 @@ namespace mirrage {
[](auto& anim) { anim.animation("dance"_strid); });
auto rotation_test = _meta_system.entities().emplace("rotation_test");
rotation_test.get<Transform_comp>().process([](auto& transform) {
_animation_test2_dqs = _meta_system.entities().emplace("rotation_test");
_animation_test2_dqs.get<Transform_comp>().process([](auto& transform) {
transform.position = {-4, 0, -0.5f - 1.f};
});
auto rotation_test_lbs = _meta_system.entities().emplace("rotation_test_lbs");
rotation_test_lbs.get<Transform_comp>().process([](auto& transform) {
_animation_test2_lbs = _meta_system.entities().emplace("rotation_test_lbs");
_animation_test2_lbs.get<Transform_comp>().process([](auto& transform) {
transform.position = {-4, 0, -0.5f + 1.f};
});
......@@ -814,6 +814,17 @@ namespace mirrage {
}
}
nk_label(ctx, "Rotation Test", NK_TEXT_LEFT);
_animation_test2_dqs.get<renderer::Animation_comp>().process([&](auto& anim) {
if(anim.paused())
anim.pause(!nk_button_label(ctx, "Continue"));
else
anim.pause(nk_button_label(ctx, "Pause"));
_animation_test2_lbs.get<renderer::Animation_comp>().process(
[&](auto& anim_lbs) { anim_lbs.time(anim.time()); });
});
nk_end(ctx);
}
......
......@@ -46,6 +46,8 @@ namespace mirrage {
ecs::Entity_facet _sun;
ecs::Entity_facet _animation_test_dqs;
ecs::Entity_facet _animation_test_lbs;
ecs::Entity_facet _animation_test2_dqs;
ecs::Entity_facet _animation_test2_lbs;
float _sun_elevation = 0.92f;
float _sun_azimuth = 1.22f;
......
......@@ -23,8 +23,6 @@ namespace mirrage::renderer {
auto is_visible(const Culling_viewer& viewer, glm::vec3 position, float radius)
{
return true;
/*
const auto p = glm::vec4(position, 1.f);
auto result = true;
......@@ -32,7 +30,6 @@ namespace mirrage::renderer {
result = result & (glm::dot(plane, p) > -radius);
return result;
*/
}
auto norm_plane(glm::vec4 p) { return p / glm::length(glm::vec3(p.x, p.y, p.z)); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment