What is that? It's used in this script that Joachim Ante wrote. Code (csharp): // Storage for all active visibility culling areas static var areas = ArrayList(); var alwaysEnabledLayers : LayerMask = 1; function OnPreCull () { // Calculate the culling mask // Go through all areas and take the union of all visible layers var layerMask = 0; var cameraPos = transform.position; for (var area : VisibilityCullingArea in areas) { var areaTransform : Transform = area.transform; var relative = areaTransform.InverseTransformPoint(cameraPos); var bounds = new Bounds (Vector3.zero, transform.localScale); if (bounds.Contains(relative)) { layerMask |= area.visibleLayers.value; } } // If we are not in a visibility area. We render everything layerMask |= alwaysEnabledLayers.value; camera.cullingMask = layerMask; }
I believe it is a binary operator. The | operator computes the bitwise or logical OR of its operands depending on if the types are integral or boolean. Bitwise OR is: Code (csharp): 0101 OR 0011 = 0111 In this case, it makes a lot of sense for the masks.
I took a class in discrete logic about 8 years ago, and remember a smattering of what I learned there, so I understand what is going on in your equations. Thanks for the info. However, the class didn't actually involve computers, just logic theory, so I don't know when I might find these operators useful.
if you want to store 8 binary states in a single byte for example to be used in a network viewed environment.