Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to Animation Editor and others #1193

Merged
merged 102 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
9d2536c
Merge branch 'master' into anim-editor
reinago May 31, 2023
5f7c90a
crash fix
reinago May 31, 2023
fb6c050
arrow fix plus no more old-style attribs
reinago May 31, 2023
825328d
remember the pos and orient source
reinago May 31, 2023
cde13b4
legacy paranoia
reinago May 31, 2023
f76380b
some more commands for the AnimationEditor
reinago May 31, 2023
08da1c3
Merge branch 'master' into anim-editor
reinago Jun 1, 2023
0a7e360
bit of cleanup here and there
reinago Jun 1, 2023
7e6af47
I think this is what we wanted to do
reinago Jun 1, 2023
fa2edc9
Format fix.
Jun 1, 2023
b5f7ba1
Merge remote-tracking branch 'reinago/anim-editor' into anim-editor
reinago Jun 1, 2023
f6db0d7
typo
reinago Jun 2, 2023
59e1e8b
fixed idiom
reinago Jun 2, 2023
e3ed2a2
enable Frame ID in screenshots
reinago Jun 2, 2023
4c854d9
reminder for debug heap
reinago Jun 2, 2023
9708973
moved the offset to the correct place
reinago Jun 6, 2023
711810a
paranoia fix
reinago Jun 21, 2023
9c8e80b
more perf analysis
reinago Jun 21, 2023
f146eae
ponder_log changes
reinago Jun 22, 2023
91ce6fc
stay paranoid, be compatible with profiling
reinago Jun 22, 2023
43aed21
cleaned the analyzer
reinago Jun 22, 2023
d975787
Merge branch 'master' into anim-editor
reinago Jun 26, 2023
8050685
Merge remote-tracking branch 'origin/vcpkg' into anim-editor
reinago Jun 26, 2023
7be9ecd
leftover bugs and missing tracy utils
reinago Jun 26, 2023
5a0290d
Merge remote-tracking branch 'origin/master' into anim-editor
reinago Jun 27, 2023
1ac9e9e
Format fix.
Jun 27, 2023
b70ed19
Merge branch 'master' into anim-editor
reinago Jun 28, 2023
ab30013
Renamed TimeMultiplier to TimeManipulator
reinago Jul 6, 2023
ab71ae3
improved TimeManipulator
reinago Jul 7, 2023
6740d12
scriptable keys, renamable animations
reinago Jul 7, 2023
632562a
expert button gives access to param Fullname as well
reinago Jul 11, 2023
6de691e
Animation editor compact view (nice for docking)
reinago Jul 11, 2023
fdc6756
at least try to avoid explosions in lua anim expressions
reinago Jul 13, 2023
71975ea
forgot the dep...
reinago Jul 13, 2023
01f3c67
Merge branch 'master' into anim-editor
reinago Jul 14, 2023
9f818b5
fixed clipbox for OSPRay spheres and ls1 particles
reinago Jul 14, 2023
d9f12bd
fix clip box when changing particle radius
reinago Jul 14, 2023
42c1a06
Merge branch 'master' into anim-editor
reinago Jul 17, 2023
719645c
Optix updated...
reinago Jul 18, 2023
ed6da8c
several hash and TF fixes
reinago Jul 24, 2023
b5f6a61
more hashing...
reinago Jul 25, 2023
b0f5ea9
Merge branch 'master' into anim-editor
reinago Jul 25, 2023
90384b3
unique requires sorting...
reinago Jul 25, 2023
f3982c7
Merge branch 'master' into anim-editor
reinago Jul 27, 2023
37210ac
Format fix.
Jul 27, 2023
abd6679
Performance shortcut
reinago Jul 27, 2023
6febc2b
compile fix
reinago Jul 27, 2023
033b06d
Merge branch 'master' into anim-editor
reinago Jul 28, 2023
6c823a6
possible fix for components in ls1ParticleFormat
reinago Jul 28, 2023
99be7b8
TableColumnFilter default value makes no sense
reinago Aug 1, 2023
48d73f9
major refactoring and double buffering for gl timers
reinago Aug 1, 2023
2462c8e
fixes for double-buffered timers
reinago Aug 3, 2023
d875bcc
fixes for zlib being weird
reinago Aug 3, 2023
c65486b
fixes for animation and scripting
reinago Aug 3, 2023
aca3175
Merge branch 'master' into anim-editor
reinago Aug 4, 2023
1b2c94d
Format fix.
Aug 4, 2023
7b81c14
Paranoia: truncate Tracy Zone Names to 1000 chars
reinago Aug 9, 2023
eaba9ff
Merge branch 'master' into anim-editor
reinago Aug 9, 2023
253efeb
clearing of regions was wrong
reinago Aug 9, 2023
98e9918
better clearing for even less weird effects
reinago Aug 9, 2023
14b294e
choosing an appropriate data type helps
reinago Aug 10, 2023
b691674
the dang resetview from outside a frame...
reinago Aug 10, 2023
4fe65ab
better output
reinago Aug 10, 2023
e35376b
pretty tables and such
reinago Aug 10, 2023
c89204f
util script for CellVis data
reinago Sep 7, 2023
2d2a327
resurrecting global particle colors after a filter made easy
reinago Oct 13, 2023
0d6be59
CI fixes
reinago Oct 16, 2023
529c3bc
more CI fixes
reinago Oct 16, 2023
41c1c0d
Merge branch 'master' into anim-editor
reinago Oct 16, 2023
157c8e1
de-explodify compilation
reinago Oct 16, 2023
dbe9838
C has no min
reinago Oct 17, 2023
43ed7b2
added caps to spawn timers for compositing
reinago Oct 30, 2023
fa97080
Merge branch 'master' into anim-editor
reinago Nov 15, 2023
bbc35d8
Merge remote-tracking branch 'reinago/sol' into anim-editor
reinago Nov 15, 2023
5067a5a
Merge remote-tracking branch 'reinago/sol' into anim-editor
reinago Nov 15, 2023
3686598
Merge remote-tracking branch 'reinago/sol' into anim-editor
reinago Nov 16, 2023
b99d99d
Merge remote-tracking branch 'reinago/sol' into anim-editor
reinago Nov 16, 2023
96a9f29
Merge remote-tracking branch 'reinago/sol' into anim-editor
reinago Nov 17, 2023
1cfbfbb
Merge remote-tracking branch 'reinago/anim-editor' into anim-editor
reinago Nov 21, 2023
9883f10
Merge remote-tracking branch 'reinago/sol' into anim-editor
reinago Nov 21, 2023
eb1590d
wip frame stats refactoring
gralkapk Dec 19, 2023
4b10ffc
wip frame stats refactoring
gralkapk Dec 19, 2023
231f39d
I propose a moving sum
reinago Dec 20, 2023
84741cb
Moved the performance markers around to be clearer
reinago Dec 20, 2023
6e6b8e4
InnerFrame cleanup
reinago Dec 20, 2023
0c7d90e
mini-cleanup and formatting
reinago Dec 20, 2023
65c41dc
small cleanup
reinago Dec 21, 2023
cc70363
more paranoia...
reinago Jan 12, 2024
ed52d13
refactored gl timer
gralkapk Jan 13, 2024
3a078bc
enforce end to end timing
gralkapk Jan 15, 2024
3ae30ad
cleanup
gralkapk Jan 15, 2024
e236a55
fixed frame stats log entry
gralkapk Jan 15, 2024
303be46
cleanup
gralkapk Jan 15, 2024
5d7e2f2
cleanup
gralkapk Jan 15, 2024
1e426c8
can we make the timers the same?
reinago Jan 31, 2024
66e1f9d
timers and queries overhaul #42
reinago Feb 1, 2024
c2d06e0
Format fix.
Apr 12, 2024
b97e3ec
fix includes
moritz-h Apr 12, 2024
2928267
Merge remote-tracking branch 'reinago/sol' into anim-editor
reinago Apr 17, 2024
beb41e3
fix CallGetTransferFunctionGL caps
reinago Apr 17, 2024
ba2b0de
cleanup
reinago Apr 17, 2024
f48d2bb
Merge branch 'master' into anim-editor
moritz-h Apr 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/include/mmcore/Call.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class Call : public std::enable_shared_from_this<Call> {
// and thereby linking the frontend service headers into the core
// so make the perf queries public when profiling is active...
public:
frontend_resources::PerformanceManager* perf_man = nullptr;
frontend_resources::PerformanceManager::handle_vector cpu_queries, gl_queries;
frontend_resources::performance::PerformanceManager* perf_man = nullptr;
frontend_resources::performance::handle_vector cpu_queries, gl_queries;
#endif // MEGAMOL_USE_PROFILING
#ifdef MEGAMOL_USE_OPENGL_DEBUGGROUPS
public:
Expand Down
55 changes: 54 additions & 1 deletion core/include/mmcore/utility/animation/AnimationData.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <imgui.h>
#include <sol/sol.hpp>

#include "mmcore/MegaMolGraph.h"

Expand All @@ -20,10 +21,30 @@ using KeyTimeType = int32_t;

enum class InterpolationType : int32_t { Step = 0, Linear = 1, Hermite = 2, CubicBezier = 3, SLERP = 4 };

class ExpressionInterpreter {
public:
static ExpressionInterpreter& getInstance() {
static ExpressionInterpreter instance;
return instance;
}
ExpressionInterpreter(ExpressionInterpreter const&) = delete;
void operator=(ExpressionInterpreter const&) = delete;

float EvaluateFloat(const std::string& script, KeyTimeType t);

std::string EvaluateString(const std::string& script, KeyTimeType t);

private:
ExpressionInterpreter() {
lua.open_libraries(sol::lib::base, sol::lib::math, sol::lib::string);
}
sol::state lua;
};

struct FloatKey {
using ValueType = float;
KeyTimeType time;
ValueType value;
ValueType value = ValueType();
InterpolationType interpolation = InterpolationType::Linear;
bool tangents_linked = true;
ImVec2 in_tangent{-1.0f, 0.0f};
Expand Down Expand Up @@ -61,6 +82,20 @@ struct StringKey {
ValueType value;
};

struct ScriptedStringKey {
using ValueType = std::string;
KeyTimeType time;
ValueType value;
std::string script;
};

struct ScriptedFloatKey {
using ValueType = float;
KeyTimeType time;
ValueType value;
std::string script;
};

template<class KeyType>
class GenericAnimation {
public:
Expand Down Expand Up @@ -98,6 +133,9 @@ class GenericAnimation {
const std::string& GetName() const {
return param_name;
}
void SetName(std::string param) {
param_name = param;
}
typename KeyMap::size_type GetSize() const {
return keys.size();
}
Expand Down Expand Up @@ -218,6 +256,21 @@ float GenericAnimation<FloatKey>::GetMinValue() const;
template<>
float GenericAnimation<FloatKey>::GetMaxValue() const;

using ScriptedStringAnimation = GenericAnimation<ScriptedStringKey>;

// Scripted Strings do everything differently
template<>
GenericAnimation<ScriptedStringKey>::ValueType::ValueType GenericAnimation<ScriptedStringKey>::GetValue(
KeyTimeType time) const;

using ScriptedFloatAnimation = GenericAnimation<ScriptedFloatKey>;

// Scripted Floats as well
template<>
GenericAnimation<ScriptedFloatKey>::ValueType::ValueType GenericAnimation<ScriptedFloatKey>::GetValue(
KeyTimeType time) const;


// same goes for vec keys, plus some more specialization
template<class C>
class VectorAnimation : public GenericAnimation<VectorKey<C>> {
Expand Down
10 changes: 9 additions & 1 deletion core/include/mmcore/utility/animation/AnimationUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ void to_json(nlohmann::json& j, const StringKey& k);
void from_json(const nlohmann::json& j, StringKey& k);
void to_json(nlohmann::json& j, const VectorKey<FloatKey>& k);
void from_json(const nlohmann::json& j, VectorKey<FloatKey>& k);
void to_json(nlohmann::json& j, const ScriptedFloatKey& k);
void from_json(const nlohmann::json& j, ScriptedFloatKey& k);
void to_json(nlohmann::json& j, const ScriptedStringKey& k);
void from_json(const nlohmann::json& j, ScriptedStringKey& k);

void to_json(nlohmann::json& j, const FloatAnimation& f);
void from_json(const nlohmann::json& j, FloatAnimation& f);
void to_json(nlohmann::json& j, const StringAnimation& s);
void from_json(const nlohmann::json& j, StringAnimation& s);
void to_json(nlohmann::json& j, const FloatVectorAnimation& v);
void from_json(const nlohmann::json& j, FloatVectorAnimation& s);
void from_json(const nlohmann::json& j, FloatVectorAnimation& v);

void to_json(nlohmann::json& j, const ScriptedFloatAnimation& f);
void from_json(const nlohmann::json& j, ScriptedFloatAnimation& f);
void to_json(nlohmann::json& j, const ScriptedStringAnimation& s);
void from_json(const nlohmann::json& j, ScriptedStringAnimation& s);

// this does not seem okay
// PD code from https://github.com/ocornut/imgui/issues/1496#issuecomment-1287772456
Expand Down
9 changes: 5 additions & 4 deletions core/src/Call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,18 @@ bool Call::operator()(unsigned int func) {
}
#endif
#ifdef MEGAMOL_USE_PROFILING
perf_man->start_timer(cpu_queries[func]);
auto& cpu_region = perf_man->start_timer(cpu_queries[func]);
frontend_resources::performance::timer_region* gpu_region = nullptr;
if (caps.OpenGLRequired()) {
perf_man->start_timer(gl_queries[func]);
gpu_region = &perf_man->start_timer(gl_queries[func]);
}
#endif
res = this->callee->InCall(this->funcMap[func], *this);
#ifdef MEGAMOL_USE_PROFILING
if (caps.OpenGLRequired()) {
perf_man->stop_timer(gl_queries[func]);
gpu_region->end_region();
}
perf_man->stop_timer(cpu_queries[func]);
cpu_region.end_region();
#endif
#ifdef MEGAMOL_USE_OPENGL_DEBUGGROUPS
if (caps.OpenGLRequired()) {
Expand Down
51 changes: 45 additions & 6 deletions core/src/utility/animation/AnimationData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,33 @@ std::ostream& megamol::core::utility::operator<<(
return outs << ss.str();
}

float ExpressionInterpreter::EvaluateFloat(const std::string& script, KeyTimeType t) {
lua.set("time", t);
// I think this makes it too complicated
//sol::table in_t = lua["in_tangent"];
//in_t.clear();
//in_t.add(in_tangent[0], in_tangent[1]);
//sol::table out_t = lua["out_tangent"];
//out_t.clear();
//out_t.add(in_tangent[0], in_tangent[1]);
try {
const float res = lua.script(script);
return res;
} catch (sol::error& e) {
return 0.0f;
}
}

std::string ExpressionInterpreter::EvaluateString(const std::string& script, KeyTimeType t) {
lua.set("time", t);
try {
std::string res = lua.script(script);
return res;
} catch (sol::error& e) {
return "";
}
}

FloatKey::ValueType FloatKey::InterpolateForTime(FloatKey first, FloatKey second, KeyTimeType time) {
FloatKey my_first = first;
FloatKey my_second = second;
Expand Down Expand Up @@ -264,13 +291,13 @@ GenericAnimation<FloatKey>::ValueType::ValueType GenericAnimation<FloatKey>::Get
if (keys.empty()) {
return ValueType::ValueType();
}
return keys.begin()->second.value;
return FloatKey::InterpolateForTime(keys.begin()->second, keys.begin()->second, time);
}
FloatKey before_key = keys.begin()->second, after_key = keys.begin()->second;
bool ok = false;
for (auto it = keys.begin(); it != keys.end(); ++it) {
if (it->second.time == time) {
return it->second.value;
return FloatKey::InterpolateForTime(it->second, it->second, time);
}
if (it->second.time < time) {
before_key = it->second;
Expand All @@ -284,7 +311,7 @@ GenericAnimation<FloatKey>::ValueType::ValueType GenericAnimation<FloatKey>::Get
if (ok) {
return FloatKey::InterpolateForTime(before_key, after_key, time);
} else {
return before_key.value;
return FloatKey::InterpolateForTime(before_key, before_key, time);
}
}

Expand All @@ -293,7 +320,7 @@ template<>
ImVec2 GenericAnimation<FloatKey>::GetTangent(KeyTimeType time) const {
if (keys.size() < 2) {
if (keys.empty()) {
return ImVec2();
return ImVec2(1.0, 0.0);
}
return keys.begin()->second.out_tangent;
}
Expand Down Expand Up @@ -339,7 +366,7 @@ InterpolationType GenericAnimation<FloatKey>::GetInterpolation(KeyTimeType time)


template<>
float GenericAnimation<FloatKey>::GetMinValue() const {
GenericAnimation<FloatKey>::ValueType::ValueType GenericAnimation<FloatKey>::GetMinValue() const {
if (!keys.empty()) {
auto min = std::numeric_limits<float>::max();
for (auto& k : keys) {
Expand All @@ -352,7 +379,7 @@ float GenericAnimation<FloatKey>::GetMinValue() const {
}

template<>
float GenericAnimation<FloatKey>::GetMaxValue() const {
GenericAnimation<FloatKey>::ValueType::ValueType GenericAnimation<FloatKey>::GetMaxValue() const {
if (!keys.empty()) {
auto max = std::numeric_limits<float>::lowest();
for (auto& k : keys) {
Expand All @@ -363,3 +390,15 @@ float GenericAnimation<FloatKey>::GetMaxValue() const {
return 1.0f;
}
}

template<>
GenericAnimation<ScriptedStringKey>::ValueType::ValueType GenericAnimation<ScriptedStringKey>::GetValue(
KeyTimeType time) const {
return ExpressionInterpreter::getInstance().EvaluateString(keys.begin()->second.script, time);
}

template<>
GenericAnimation<ScriptedFloatKey>::ValueType::ValueType GenericAnimation<ScriptedFloatKey>::GetValue(
KeyTimeType time) const {
return ExpressionInterpreter::getInstance().EvaluateFloat(keys.begin()->second.script, time);
}
58 changes: 58 additions & 0 deletions core/src/utility/animation/AnimationUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ void animation::from_json(const nlohmann::json& j, VectorKey<FloatKey>& k) {
}
}

void animation::to_json(nlohmann::json& j, const ScriptedFloatKey& k) {
j = nlohmann::json{{"time", k.time}, {"value", k.value}, {"script", k.script}};
}

void animation::from_json(const nlohmann::json& j, ScriptedFloatKey& k) {
j["time"].get_to(k.time);
j["value"].get_to(k.value);
j["script"].get_to(k.script);
}

void animation::to_json(nlohmann::json& j, const ScriptedStringKey& k) {
j = nlohmann::json{{"time", k.time}, {"value", k.value}, {"script", k.script}};
}

void animation::from_json(const nlohmann::json& j, ScriptedStringKey& k) {
j["time"].get_to(k.time);
j["value"].get_to(k.value);
j["script"].get_to(k.script);
}


void animation::to_json(nlohmann::json& j, const FloatAnimation& f) {
j = nlohmann::json{{"name", f.GetName()}, {"type", "float"}};
Expand Down Expand Up @@ -116,6 +136,44 @@ void animation::from_json(const nlohmann::json& j, FloatVectorAnimation& v) {
}
}

void animation::to_json(nlohmann::json& j, const ScriptedFloatAnimation& f) {
j = nlohmann::json{{"name", f.GetName()}, {"type", "scripted_float"}};
auto v_array = nlohmann::json::array();
for (auto& k : f.GetAllKeys()) {
v_array.push_back(f[k]);
}
j["keys"] = v_array;
}

void animation::from_json(const nlohmann::json& j, ScriptedFloatAnimation& f) {
f = ScriptedFloatAnimation{j.at("name")};
assert(j.at("type") == "scripted_float");
for (auto& j : j["keys"]) {
ScriptedFloatKey k;
j.get_to(k);
f.AddKey(k);
}
}

void animation::to_json(nlohmann::json& j, const ScriptedStringAnimation& s) {
j = nlohmann::json{{"name", s.GetName()}, {"type", "scripted_string"}};
auto v_array = nlohmann::json::array();
for (auto& k : s.GetAllKeys()) {
v_array.push_back(s[k]);
}
j["keys"] = v_array;
}

void animation::from_json(const nlohmann::json& j, ScriptedStringAnimation& s) {
s = ScriptedStringAnimation{j.at("name")};
assert(j.at("type") == "scripted_string");
for (auto& j : j["keys"]) {
ScriptedStringKey k;
j.get_to(k);
s.AddKey(k);
}
}

// this does not seem okay
#if 0
static ImVector<ImRect> s_GroupPanelLabelStack;
Expand Down
6 changes: 1 addition & 5 deletions frontend/main/src/CLIConfigParsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <cstdio>
#include <cstdlib>
#include <filesystem>
#include <fstream>

#define CXXOPTS_VECTOR_DELIMITER '\0'
#include <cxxopts.hpp>
#include <fstream>

// find user home
static std::filesystem::path getHomeDir() {
Expand Down Expand Up @@ -809,8 +809,6 @@ megamol::frontend_resources::RuntimeConfig megamol::frontend::handle_config(
accepted_log_level_strings,
make_option_callback(echolevel_option));

//lua.AddCallbacks(lua_config_callbacks);

for (auto& file : config.configuration_files) {
cli_options_from_configs.clear();
std::ifstream stream(file);
Expand Down Expand Up @@ -868,8 +866,6 @@ megamol::frontend_resources::RuntimeConfig megamol::frontend::handle_config(
[](std::string const& init, std::string const& elem) { return init + elem + " "; }));
}

//lua.ClearCallbacks();

return config;
}

Expand Down
Loading
Loading