RegionField

A region's field, compiled, that answers "is this world point inside?" on any thread (construct-project-space §PSR-4 step 2).

Inherits study::IRegionField

In the namespace construct::region. Declared in src/libs/libconstruct/construct/region/RegionField.hpp.

Detailed description

This is libconstruct's answer to `study::IRegionField`, the seam libstudy declares so it does not depend on libconstruct.

How it is built

compile() places the region's primitive in a SCRATCH logical scene, with the document's varset, named varsets and own definitions copied in, and compiles it through the same `LogicalSceneCompiler`, expression pass and `SDFLayer` the model uses. The nodes go to a `CPUFieldEvaluator` over a frozen `registry::DefinitionSnapshot`. Two things follow:

  • A parameter written `=span` reads the value the model reads, so the region moves when the geometry moves (§PSR-2).
  • The field never becomes model geometry: it never enters the document's scene.

Every scratch object is gone when compile() returns. What stays is the nodes, the snapshot and the world-to-field matrix: plain data.

Threads

compile() reads the document, so it runs on the GUI thread, or on the thread that owns the scene. It is cheap: it builds the field's nodes and stops there. build() turns the nodes into machine code, which takes tens to hundreds of milliseconds, and runs once, on the first thread that asks: call it from the pool, or let the first evaluate() do it there. build(), evaluate(), contains() and valueAt() are safe on any thread, from several threads at once: the evaluator gives each calling thread its own copy of the compiled program. The object can be destroyed on any thread.

A field is a snapshot

The varset and the item's placement are read when compile() runs. A field compiled before a variable or the item changes evaluates the old values. Compile again after a change; a solve compiles once per solve.

In this section