Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Metadata interpolation
#1
I have segment Metadata that represent the starting 'width' of a Spline's segment. If this 'width' changes from segment to segment, the width is linearly interpolated using a "Variable Mixed Shape" CG module. The resulting extrusion is what is desired.

In the Spline's Controller (and other places), I need to to know the 'width' at any Position along the Spline. The general implementation of Metadata interpolation is a problem.

Code:
public override float Interpolate( CurvyInterpolatableMetadataBase<float> nextMetadata, float interpolationTime ) {
return (nextMetadata is not null) ? Mathf.Lerp( MetaDataValue, nextMetadata.MetaDataValue, interpolationTime ) : MetaDataValue;
}


The value passed into this method are 'local F' space. This is not the uniformly spaced linear values needed for Lerp to go from width to the next.

The following convert 'local F' space to linear segment space:
Code:
var ld = seg.LocalFToDistance( lf ) / seg.Length;
var widthAtLf = seg.GetInterpolatedMetadata<TrackMetadata, float>( ld );

But it needs access to the segment, which isn't passed into the Metadata's Interpolate routine.

In some places I can do this where I'm accessing the Metadata for a specific segment. But other places, like the Controller, it is preferable to use the Spline.InterpolateMetadata<>( Position ). I cad get the segment of the Position myself and do the conversion:
Code:
var seg = Spline.TFToSegment( Position, out float lf );
var ld = seg.LocalFToDistance( lf ) / seg.Length;
var trackWidthScaled = seg.GetInterpolatedMetadata<TrackMetadata, float>( ld );
But this seem expensive to do in a Controller. Plus a bit contorted and seemingly wrong.

What would you suggest as optimal?
Reply


Messages In This Thread
Metadata interpolation - by tairoark - 10-16-2022, 06:09 PM
RE: Metadata interpolation - by _Aka_ - 10-17-2022, 10:07 AM
RE: Metadata interpolation - by tairoark - 10-17-2022, 11:47 AM
RE: Metadata interpolation - by _Aka_ - 10-17-2022, 01:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  "MetaData" Of Entire Spline Heightmap SAMYTHEBIGJUICY 3 6 10-16-2023, 08:42 AM
Last Post: _Aka_
  Proper metadata usage tairoark 2 8 10-01-2022, 12:04 PM
Last Post: _Aka_
  Accessing Metadata from CG hucota7 1 8 02-16-2022, 08:49 PM
Last Post: _Aka_
  Metadata warnings Josenildo 4 740 07-13-2021, 12:19 AM
Last Post: p30better

Forum Jump: