Structural Integrity Demo using a Graph Based System (vertices + edges)
Quick showcase of the structural integrity system in our current iteration of Throw It.
The naive implementation of structural integrity would be to continously check what is under the current brick to detect whether or not it is stable or not, however this implementation is different than that.
This implementation instead uses a graph to calculate the structural integrity of each brick / actor. When a brick is placed on the terrain ground (which is assumed to always be fully structurally stable), this creates an edge between the "ground" node and the newly place "brick" node. The weight of the edge states how "stable" the connection is. The nodes in this case are the "vertices" of the graph, and the connection between them are the edges.
This allows us to place bricks and create overhangs (as you can write a rule that allows those type of connection to happen) but at the compromise of a "weaker" connection (by lowering the edge weight)
Every time the graph is updated, we run a Dijkstra path-finding prefix-sum like algorithm to sum up the total "structural stabililty" weights of all nodes, starting from the root nodes (which are the ground). The brick always picks the "stablest" score because, well, that makes more sense.
If you have a brick that is an overhang, it wouldn't be very stable. But if there was a supporting brick underneath it then it no longer is an overhang, and it thus more stable.
This is implemented naively in C# and performance is great. No performance problems yet. If, down the line, we need to optimize it, we will need to splt up the graph into multiple islands"and compute those in parallel. Also dynamically integrating / recalculating the structural stability of pieces can be an interesting optimization to avoid having to re-integrate upon every graph change.
Science & Technology