internal

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDevRendererService

func NewDevRendererService(impl DevRendererImpl, done chan os.Signal) *rpc.Server

NewDevRendererService see RendererService

Types

type DevRendererImpl

type DevRendererImpl interface {
	// Dimensions are 2 for SDF2 and 3 for SDF3
	Dimensions() int
	// BoundingBox returns the full bounding box of the surface (Z is ignored for SDF2)
	BoundingBox() sdf.Box3
	// ReflectTree returns the main reflection-based metadata structure for handling the SDF hierarchy
	ReflectTree() *ReflectTree
	// ColorModes returns the number of color modes supported
	ColorModes() int
	// Render performs a full render, given the screen size (it may be cancelled using the given context).
	// Returns partially rendered images as progress is made through PartialRenders (if non-nil, channel closed).
	Render(args *RenderArgs) error
}

DevRendererImpl is the interface implemented by the SDF2 and SDF3 renderers. Note that the implementation is independent of the graphics backend used and renders CPU images.

type ReflectTree

type ReflectTree struct {
	Info     *SDFNodeMeta
	Children []*ReflectTree
}

ReflectTree is internal: do not use outside this project

func (*ReflectTree) GetBoundingBoxes2

func (r *ReflectTree) GetBoundingBoxes2() []sdf.Box2

GetBoundingBoxes2 is internal: do not use outside this project

func (*ReflectTree) GetBoundingBoxes3

func (r *ReflectTree) GetBoundingBoxes3() []sdf.Box3

GetBoundingBoxes3 is internal: do not use outside this project

type ReflectionSDF

type ReflectionSDF struct {
	// contains filtered or unexported fields
}

ReflectionSDF provides reflect-based metadata about the SDF hierarchy with the provided root: bounding boxes, etc. Remember that reflect is relatively slow and results should be cached.

func NewReflectionSDF

func NewReflectionSDF(sdf interface{}) *ReflectionSDF

NewReflectionSDF is internal: do not use outside this project

func (*ReflectionSDF) GetReflectSDFTree2

func (r *ReflectionSDF) GetReflectSDFTree2() *ReflectTree

GetReflectSDFTree2 is internal: do not use outside this project

func (*ReflectionSDF) GetReflectSDFTree3

func (r *ReflectionSDF) GetReflectSDFTree3() *ReflectTree

GetReflectSDFTree3 is internal: do not use outside this project

func (*ReflectionSDF) GetReflectTree

func (r *ReflectionSDF) GetReflectTree(targetTypes ...reflect.Type) *ReflectTree

GetReflectTree is internal: do not use outside this project

type RemoteRenderArgs

type RemoteRenderArgs struct {
	RenderSize v2i.Vec
	State      *RendererState
}

RemoteRenderArgs is an internal struct that has to be exported for RPC.

type RemoteRenderResults

type RemoteRenderResults struct {
	IsPartial   bool
	RenderedImg *image.RGBA
	NewState    *RendererState
}

RemoteRenderResults is an internal struct that has to be exported for RPC.

type RenderArgs

type RenderArgs struct {
	Ctx                         context.Context
	State                       *RendererState
	StateLock, CachedRenderLock *sync.RWMutex
	PartialRenders              chan<- *image.RGBA
	FullRender                  *image.RGBA
}

RenderArgs is internal: do not use outside this project

type RendererService

type RendererService struct {
	// contains filtered or unexported fields
}

RendererService is an internal struct that has to be exported for RPC. is the server counterpart to rendererClient. It provides remote access to a devRendererImpl.

func (*RendererService) BoundingBox

func (d *RendererService) BoundingBox(_ sdf.Box3, out *sdf.Box3) error

BoundingBox is an internal method that has to be exported for RPC.

func (*RendererService) ColorModes

func (d *RendererService) ColorModes(_ int, out *int) error

ColorModes is an internal method that has to be exported for RPC.

func (*RendererService) Dimensions

func (d *RendererService) Dimensions(_ int, out *int) error

Dimensions is an internal method that has to be exported for RPC.

func (*RendererService) ReflectTree

func (d *RendererService) ReflectTree(_ sdf.Box3, out *ReflectTree) error

ReflectTree is an internal method that has to be exported for RPC.

func (*RendererService) RenderCancel

func (d *RendererService) RenderCancel(_ int, _ *int) error

RenderCancel is an internal struct that has to be exported for RPC. RenderCancel cancels the current rendering. It will always succeed with no error.

func (*RendererService) RenderGet

func (d *RendererService) RenderGet(_ int, out *RemoteRenderResults) error

RenderGet is an internal struct that has to be exported for RPC. RenderGet gets the next partial or full render available (partial renders might be lost if not called, but not the full render). It will return an error if no render is running (or it was cancelled before returning the next result)

func (*RendererService) RenderStart

func (d *RendererService) RenderStart(args RemoteRenderArgs, _ *int) error

RenderStart is an internal method that has to be exported for RPC. RenderStart starts a new render (cancelling the previous one)

func (*RendererService) Shutdown

func (d *RendererService) Shutdown(t time.Duration, _ *int) error

Shutdown is an internal struct that has to be exported for RPC. Shutdown sends a signal on the configured channel (with a timeout)

type RendererState

type RendererState struct {
	// SHARED
	ResInv      int          // How detailed is the image: number screen pixels for each pixel rendered (SDF2: use a power of two)
	DrawBbs     bool         // Whether to show all bounding boxes (useful for debugging subtraction/intersection of SDFs)
	ColorMode   int          // The color mode (each render may support multiple modes)
	ReflectTree *ReflectTree // Cached read-only reflection metadata to have some insight into the SDF hierarchy
	// SDF2
	Bb sdf.Box2 // Controls the scale and displacement
	// SDF3
	CamCenter                 v3.Vec  // Arc-Ball camera center (the point we are looking at)
	CamYaw, CamPitch, CamDist float64 // Arc-Ball rotation angles (around CamCenter) and distance from CamCenter
}

RendererState is an internal struct that has to be exported for RPC.

type SDFNodeMeta

type SDFNodeMeta struct {
	ID    int      // An unique ID for this node (unique for the current tree)
	Level int      // The fake level (it is not consistent across different branches)
	Bb    sdf.Box3 // The cached bounding box (as it can be sent through the network)
	// The following are only available in main renderer mode (can't be sent through the network and needs a code restart to use)
	SDF   interface{}   // The SDF (2D/3D)
	Value reflect.Value // The Value (can be modified!)
}

SDFNodeMeta is internal: do not use outside this project

func (*SDFNodeMeta) GobDecode

func (s *SDFNodeMeta) GobDecode(bs []byte) error

GobDecode is internal: do not use outside this project

func (*SDFNodeMeta) GobEncode

func (s *SDFNodeMeta) GobEncode() ([]byte, error)

GobEncode is internal: do not use outside this project

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL