示例#1
0
文件: scene.go 项目: skyview059/vu
// snapshot fills a frame with draw requests. All transforms are expected
// to have been updated before calling this method.
// Snapshot flattens the POV hierarchy in the following manner:
//   o depth first traversal of the POV hiearchy.
//   o light/camera replace the previous light/camera.
//   o layer adds a pre-render pass for the child hierarchy.
//
// The frame memory is recycled in that the Draw records are lazy allocated
// and reused each update.  Note len(frame) is the number of draw calls
// for the most recently prepared frame.
func (sm *scene) snapshot(eng *engine, frame []render.Draw) []render.Draw {
	frame = frame[:0]       // resize keeping underlying memory.
	sm.scene = sm.scene[:0] // ditto.
	if root := eng.root(); root != nil {
		cam, _ := eng.cams[root.eid]
		sm.renDraws, sm.renVerts = 0, 0
		sm.scene = sm.updateScene(eng, 0, cam, root, sm.scene)
		frame = sm.updateFrame(eng, sm.scene, frame)
	}
	render.SortDraws(frame)
	return frame
}
示例#2
0
文件: eng.go 项目: toophy/vu
// render creates a new render frame. All of the transforms are
// expected to have been placed (updated) before calling this method.
// A frame is rendered using each of the views in creation order.
//
// The frame memory is preserved through the method calls in
// that the Draw records are grown and reused across updates.
func (eng *engine) render(frame []render.Draw) []render.Draw {
	frame = frame[:0] // resize keeping underlying memory.
	eng.renDraws, eng.renVerts = 0, 0
	light := eng.l
	for _, eid := range eng.vorder {
		if view, ok := eng.views[eid]; ok && view.visible {
			if pv, ok := eng.povs[eid]; ok { // expected to be true.
				light, frame = eng.snapshot(pv, view, light, frame)
			}
		}
	}
	render.SortDraws(frame)
	return frame // Note len(frame) is the number of draw calls.
}