Skip to content

Instantly share code, notes, and snippets.

@andybak
Created February 10, 2021 16:39
Show Gist options
  • Save andybak/4bad9d7e5912f181148d97187d299368 to your computer and use it in GitHub Desktop.
Save andybak/4bad9d7e5912f181148d97187d299368 to your computer and use it in GitHub Desktop.
// Not working.
// Creates a batch that appears to have geometry but nothing is visible in the scene
override public void UpdateTool()
{
base.UpdateTool();
Transform rAttachPoint = InputManager.Brush.Geometry.ToolAttachPoint;
Vector3 pos = rAttachPoint.position;
Quaternion rot = rAttachPoint.rotation;
m_toolDirectionIndicator.transform.localRotation = Quaternion.Euler(PointerManager.m_Instance.FreePaintPointerAngle, 0f, 0f);
uint time = 0;
if (InputManager.m_Instance.GetCommandDown(InputManager.SketchCommands.Activate))
{
float pressure = 10;
var stroke = new Stroke
{
m_Type = Stroke.Type.NotCreated,
m_IntendedCanvas = App.Scene.ActiveCanvas,
m_BrushGuid = PointerManager.m_Instance.MainPointer.CurrentBrush.m_Guid,
m_BrushScale = 1f,
m_BrushSize = PointerManager.m_Instance.MainPointer.BrushSize01,
m_Color = PointerManager.m_Instance.MainPointer.GetCurrentColor(),
m_Seed = 0,
m_ControlPoints = new[]
{
new PointerManager.ControlPoint {m_Pos=pos, m_Orient=rot, m_Pressure=pressure, m_TimestampMs=time++},
new PointerManager.ControlPoint {m_Pos=pos + new Vector3(1f, 0, 0), m_Orient=rot, m_Pressure=pressure, m_TimestampMs=time++},
new PointerManager.ControlPoint {m_Pos=pos + new Vector3(0, 1, 0), m_Orient=rot, m_Pressure=pressure, m_TimestampMs=time++},
new PointerManager.ControlPoint {m_Pos=pos, m_Orient=rot, m_Pressure=pressure, m_TimestampMs=time++}
}
};
stroke.m_ControlPointsToDrop = Enumerable.Repeat<bool>(false, stroke.m_ControlPoints.Length).ToArray();
stroke.Recreate(App.Scene.ActiveCanvas.AsCanvas[rAttachPoint], App.Scene.ActiveCanvas);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment