void UpdatePath(ref InstanceData instance, List <Transform> path, ref PathProps path_props) { var dirty = path_props.Update(path, this.p, this.m); if (dirty) { this.p.UpdatePath(ref path_props._cached_path); // send updated path to gpu if path changed } // optional debug path drawing if (path_props.draw_path) { // Draw path Pathing.DebugDrawPath(path_props._cached_path, path: p.path.Array, path_up: p.path_up.Array, path_t: p.path_t.Array, start_index: p.StartIndexOfPath(path_props._cached_path), n_samples: 100); // Draw orientation of instance Vector3 position, direction, up; p.CalculatePathPositionDirection(path_props._cached_path, instance, out position, out direction, out up); Debug.DrawLine(position, position + direction * 1.5f, Color.blue); Debug.DrawLine(position, position + up * 1.5f, Color.green); Debug.DrawLine(position, position + Vector3.Cross(up, direction).normalized * 1.5f, Color.red); } // update instance if speed was changed or the path changed if (instance.props_pathSpeed != path_props.speed || dirty) { instance.SetPath(path_props._cached_path, this.m, path_props.speed); this.m.Append(ref instance); path_props.speed = instance.props_pathSpeed; } }
void InitInstance(ref InstanceData instance, List <Transform> path, ref PathProps path_props, in Color color)