Search in sources :

Example 1 with SpaceWidget

use of spacegraph.space3d.widget.SpaceWidget in project narchy by automenta.

the class EdgeDirected method solve.

@Override
public void solve(Broadphase b, List<Collidable> objects, float timeStep) {
    float a = attraction.floatValue();
    for (int i = 0, objectsSize = objects.size(); i < objectsSize; i++) {
        Collidable c = objects.get(i);
        Spatial A = ((Spatial) c.data());
        // TODO abstract the Edges as a feature to optionally add to a TermWidget, not just for ConceptWidgets
        if (A instanceof SpaceWidget) {
            ((SpaceWidget<?>) A).edges().forEach(e -> {
                float attraction = e.attraction;
                if (attraction > 0) {
                    SimpleSpatial B = e.tgt();
                    if ((B.body != null)) {
                        attract(c, B.body, a * attraction, e.attractionDist);
                    }
                }
            });
        }
    }
    super.solve(b, objects, timeStep);
}
Also used : Collidable(spacegraph.space3d.phys.Collidable) SpaceWidget(spacegraph.space3d.widget.SpaceWidget) SimpleSpatial(spacegraph.space3d.SimpleSpatial) Spatial(spacegraph.space3d.Spatial) SimpleSpatial(spacegraph.space3d.SimpleSpatial)

Aggregations

SimpleSpatial (spacegraph.space3d.SimpleSpatial)1 Spatial (spacegraph.space3d.Spatial)1 Collidable (spacegraph.space3d.phys.Collidable)1 SpaceWidget (spacegraph.space3d.widget.SpaceWidget)1