dymokomi/luced-3d
Source of release 0.11.6
0.11.6 / src / render_geometry.luc
## Render the CAD surfaces already used by the viewport, alongside the
## authored set. Analytic models stay in the graph; only these shared preview
## meshes cross to the path tracer. Existing meshes and scene objects occur
## once, with their original materials and instance placements intact.
from geometry_data import GeometryData
from luce_geocore.geocore import GeometrySet, Vector3
pub func render_geometry(data: GeometryData, quick: bool = false, divisions: int = 16) -> GeometrySet!:
let surfaces = cad_surfaces(data, quick, divisions)
if surfaces.is_empty():
return data.geometry
let zero = Vector3()
let one = Vector3(1.0, 1.0, 1.0)
return GeometrySet().with_instance(data.geometry, zero, zero, one).with_instance(surfaces, zero, zero, one)
func cad_surfaces(data: GeometryData, quick: bool, divisions: int) -> GeometrySet!:
var surfaces = GeometrySet()
if data.has_cad():
for mesh in data.preview(quick = quick, divisions = divisions).meshes:
surfaces = surfaces.with_instance(GeometrySet.of_mesh(mesh), Vector3(), Vector3(), Vector3(1.0, 1.0, 1.0))
for at in 0..<data.instance_count():
if not data.instance_visible(at):
continue
let child = cad_surfaces(data.instance(at), quick, divisions)
if not child.is_empty():
surfaces = surfaces.with_instance(child, data.instance_translation(at), data.instance_rotation(at), data.instance_scale(at))
return surfaces