3Dickulus / FragM

Derived from https://github.com/Syntopia/Fragmentarium/
GNU General Public License v3.0
349 stars 30 forks source link

crash in keyframe parsing #98

Closed claudeha closed 4 years ago

claudeha commented 4 years ago

Describe the bug Loading this frag crashes:

#include "MathUtils.frag"
#include "DE-Raytracer.frag" 

#group Crash

uniform float Radius; slider[0,1,10]

float DE(vec3 pos) {
  return length(pos) - Radius;
}

#preset KeyFrame.001
Radius = 1
#endpreset

#preset KeyFrame.002
Radius = 2
#endpreset

crash.frag.txt

To Reproduce Steps to reproduce the behavior:

  1. Load the frag
  2. Segmentation fault

Expected behavior No crash. Maybe an error message if the keyframe syntax is incorrect.

Backtrace

#0  0x00007ffff5b46bf8 in QString::split(QString const&, QString::SplitBehavior, Qt::CaseSensitivity) const () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#1  0x000055555560510f in Fragmentarium::GUI::KeyFrameInfo::KeyFrameInfo(QStringList) ()
#2  0x00005555555f33dd in Fragmentarium::GUI::MainWindow::addKeyFrame(QStringList) ()
#3  0x00005555555f3736 in Fragmentarium::GUI::MainWindow::initKeyFrameControl() ()
#4  0x000055555562019a in Fragmentarium::GUI::VariableEditor::setPresets(QMap<QString, QString>) ()
#5  0x0000555555622af4 in Fragmentarium::GUI::VariableEditor::updateFromFragmentSource(Fragmentarium::Parser::FragmentSource*) ()
#6  0x00005555555f93c3 in Fragmentarium::GUI::MainWindow::initializeFragment() ()
#7  0x00005555555fa8cd in Fragmentarium::GUI::MainWindow::tabChanged(int) ()
#8  0x0000555555659796 in Fragmentarium::GUI::MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) ()
#9  0x00007ffff5c99906 in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007ffff6b3ccfe in QTabBar::currentChanged(int) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#11 0x00007ffff6b412fd in QTabBar::setCurrentIndex(int) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007ffff6b45b22 in QTabBar::insertTab(int, QIcon const&, QString const&) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007ffff6b45d8f in QTabBar::insertTab(int, QString const&) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00005555555fd57f in Fragmentarium::GUI::MainWindow::insertTabPage(QString) ()
#15 0x00005555555fd9c1 in Fragmentarium::GUI::MainWindow::loadFragFile(QString const&) ()
#16 0x00005555555b738c in main ()

Desktop:

3Dickulus commented 4 years ago

of course it does, those aren't key frames so expected behavior is undefined, like a crash or something.

a "key frame" preset consists of only the following settings...

#preset KeyFrame.001
FOV = 0.62536
Eye = 2.42106,0.501576,0.263686
Target = -6.2468,-0.836125,-0.622262
Up = 0,1,0
#endpreset

...these are used as control points on the spline paths, this is also the absolute minimum settings required for a non-key frame preset

if these are already set then non-key frame presets other than Default may be able to have fewer settings because Camera,Target,Up and FOV are already setup, but Default preset must have them. I haven't tested extensively along this line for adverse conditions though, a proper test and error message would definitely be preferable to a segfault that comes from uninitialized variables.

Key Frame presets are for camera. Easing Curves control any FLOAT sliders. fqScript controls BOOL INT SAMPLER widgets

These features are separate because they were each "proof of concept" experiments to illustrate some ideas.

BOOL INT and SAMPLER are not good candidates for varying control unless the user rrreeeeaaallllyyy knows what they are doing or trying to do and has the brains to code it in fqScript. At this stage of animating the user has total control, the gui is basically for set up and testing before rendering that 8000 frame animation.

claudeha commented 4 years ago

Noted. I checked that adding presets from the GUI does the right thing (2D doesn't suggest keyframe, 3D Keyframe.nnn saves only camera, 3D OtherName saves everything).

presets other than Default may be able to have fewer setting

It may indeed be useful to allow presets without camera settings, to switch only colouring for example..

3Dickulus commented 4 years ago

It may indeed be useful to allow presets without camera settings, to switch only colouring for example..

it already does :D try this...

  1. create a preset called "Colouring" ( it will have everything )
  2. in the text editor block-mark the contents of the preset ( not the head and tail just the body )
  3. goto the Color tab, scroll to the bottom and select "Copy Group"
  4. select "Paste" (RMB on the text editor = popup menu)
  5. Build! the "Colouring" preset now has only the contents of the Color tab

You can trim out the settings you're not interested in and just keep the ones you want. No errors when used but the user must bear in mind that this preset affects only the Color tab.

There is also a preferences flag to save easingcurve infos in the normal presets with all settings or not, when not, then easingcurve infos can be saved alone in a preset, just use the name prefix "Range-" and add the range of frames that the easing curve(s) cover, like 10-100.

Background Detail: how this works right now is that the prefix, "Range-", when creating a preset tells FragM to save only easingcurve infos while the suffix, "10-100", would be a reminder for the human, nothing more ;) it doesn't have to be frame numbers, it can be any indicative name. Why not actually use the frame numbers? Because this preset can contain many easingcurves that may not represent a contiguous range, so it's up to the user to keep things organized in a way that makes sense.

and for some more fun, after adding a few easing curves, RMB on the time slider ;)

3Dickulus commented 4 years ago

2D doesn't suggest keyframe

Why?

3D camera position is controlled by catmull-rom splines (modified IQ code) and as such easing curves can not be applied to Camera,Target or Up

2D Camera is not controlled by splines so you can apply an easing curve to Center and Zoom coords

Lets face it, for 2D it's just zoom and pan, easing curves can handle that quite elegantly if one takes the time to get to know how to use them. No fancy user paths for 2D until the last curve slot in the EasingCurveDialog gets coded, that one is reserved for user created curves ;) see QEasingCurve::addCubicBezierSegment and QEasingCurve::addTCBSegment for more info.

3Dickulus commented 4 years ago

oh! ... this is an idea ... add to the bottom of each tab, with the "group" buttons, a button that creates a preset using tab name and contents!