-
Notifications
You must be signed in to change notification settings - Fork 31
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
Splines #71
base: development
Are you sure you want to change the base?
Splines #71
Conversation
LINEAR, | ||
CUBIC, | ||
CUBIC_USER | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing newline, at EOF
@@ -0,0 +1,264 @@ | |||
class CF_Spline : Managed /*CF_ObservableCollection*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment if no longer needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently not needed yes.
Will be in the future once CF_ObservableCollection
is implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if things like this should BE a CF_ObservableCollection
, maybe HAVE one for the points list?
class CF_Math | ||
{ | ||
// https://en.wikipedia.org/wiki/Cubic_Hermite_spline | ||
static vector CubicInterp(vector p0, vector p1, vector m0, vector m1, float t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better name would be HermiteSpline()
/CublicSpline()
since this is not intended for linear interpolation and the suffix Interp
sounds odd.
Or call it HermiteInterpolation()
if it can be used for lerps as well.
|
||
private float m_Tension; | ||
|
||
void CF_Spline() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to
void CF_Spline(array<vector> points = NULL) {}
so we can do
auto spline = new CF_Spline({"0 0 0", "0 0 1", "0 1 1"});
@@ -0,0 +1,264 @@ | |||
class CF_Spline : Managed /*CF_ObservableCollection*/ | |||
{ | |||
autoptr ScriptInvoker Update = new ScriptInvoker(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe OnUpdate
? Is this maybe worth a CF_EventHandler
?
What is this for? Not documented inline or in docs/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for updating every point (node) in the spline. As one position change can affect the neighbors, and that affects its neighbors and so on, and so on.
Tangents all need to be recalculated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, still think it should be renamed to OnUpdate
* | ||
* @param imd Updates the spline immediately | ||
*/ | ||
CF_SplinePoint Remove(int index, bool imd = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename imd
, see comments above
} | ||
} | ||
|
||
void LinInterp(float delta, out vector position, out vector orientation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename LinInterp
to the commonly used term Lerp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name the other one Cerp
?
Named it like that to keep the name similar to CubicInterp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented on the other name: #71 (comment)
Linear interpolation is either written out or Lerp
, no matter which language/framework/engine.
spline.InsertAt(new CF_SplinePoint("10 3 0"), 0); | ||
``` | ||
|
||
## Applying the spline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "Using the spline"?
spline.Tick(pDt); | ||
if (spline.Completed()) spline.SetTime(0); | ||
|
||
SetPosition(spline.GetPosition()); | ||
SetOrientation(spline.GetOrientation()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mixes advancing the spline and using the current pos/orient in one example ... maybe change the bottom code to this:
vector currentSplinePos = spline.GetPosition();
vectoe currentSplineOrientation = spline.GetOrientation();
SetPosition(spline.GetPosition()); | ||
SetOrientation(spline.GetOrientation()); | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No example of how to use the CF_SplineViewer
/ CF_SplineDebug
people who try to use this will want to make use out of that instead of having to make their own ...
Also, this could be a good way to demonstrate a full example people can copy-paste into their code and see if it working. Might help to explain all the concepts a bit better.
No description provided.