func (ins *Instance) Trace(ray *core.Ray, sg *core.ShaderContext) bool {
	var Rp, Rd, Rdinv m.Vec3
	var S [3]float32
	var Kx, Ky, Kz int32
	var transform, invTransform m.Matrix4
	Rp = ray.P
	Rd = ray.D
	Rdinv = ray.Dinv
	S = ray.S
	Kx = ray.Kx
	Ky = ray.Ky
	Kz = ray.Kz
	transform = m.TransformDecompToMatrix4(ins.transformSRT.TimeKey(ray.Time))
	invTransform, _ = m.Matrix4Inverse(transform)
	ray.P = m.Matrix4MulPoint(invTransform, Rp)
	ray.D = m.Matrix4MulVec(invTransform, Rd)
	ray.Setup()
	hit := ins.geom.Trace(ray, sg)
	ray.P = Rp
	ray.D = Rd
	ray.Dinv = Rdinv
	ray.S = S
	ray.Kx = Kx
	ray.Ky = Ky
	ray.Kz = Kz
	if hit {
		sg.Transform = transform
		sg.InvTransform = invTransform
	}
	return hit
}
Trace implements core.Primitive.
package instance
import (
	"fmt"
	"github.com/jamiec7919/vermeer/core"
	"github.com/jamiec7919/vermeer/core/param"
	m "github.com/jamiec7919/vermeer/math"
	"github.com/jamiec7919/vermeer/nodes"
)
type TransformSRTArray []m.TransformDecomp
func (t *TransformSRTArray) TimeKey(time float32) m.TransformDecomp {
	if len(*t) > 1 {
		k := time * float32(len(*t)-1)
		timeFrac := k - m.Floor(k)
		key := int(m.Floor(k))
		key2 := int(m.Ceil(k))
		if key > len(*t)-1 || key2 > len(*t)-1 {
			panic(fmt.Sprintf("TransformSRTArray.TimeKey: %v %v %v", time, key, key2))
		}
		return m.TransformDecompLerp((*t)[key], (*t)[key2], timeFrac)
	}
	return (*t)[0]
}
type Instance struct {
	NodeDef  core.NodeDef `node:"-"`
	NodeName string       `node:"Name"`
	Geom string
	BMin param.PointArray
	BMax param.PointArray
	Transform    param.MatrixArray
	transformSRT TransformSRTArray
	geom core.Geom
	bounds []m.BoundingBox
}
var _ core.Node = (*Instance)(nil)
var _ core.Geom = (*Instance)(nil)
func (ins *Instance) Name() string { return ins.NodeName }
func (ins *Instance) Def() core.NodeDef { return ins.NodeDef }
func (ins *Instance) Bounds(time float32) m.BoundingBox {
	return ins.bounds[0]
}