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

Splines #71

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open

Splines #71

wants to merge 1 commit into from

Conversation

Jacob-Mango
Copy link
Collaborator

No description provided.

LINEAR,
CUBIC,
CUBIC_USER
};
Copy link
Owner

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*/
Copy link
Owner

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?

Copy link
Collaborator Author

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.

Copy link
Owner

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)
Copy link
Owner

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()
Copy link
Owner

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();
Copy link
Owner

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/

Copy link
Collaborator Author

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

Copy link
Owner

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)
Copy link
Owner

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)
Copy link
Owner

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

Copy link
Collaborator Author

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

Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Using the spline"?

Comment on lines +30 to +34
spline.Tick(pDt);
if (spline.Completed()) spline.SetTime(0);

SetPosition(spline.GetPosition());
SetOrientation(spline.GetOrientation());
Copy link
Owner

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());
}
```
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants