Hi! I am trying to use the Occlusion function to detect if the edges of two procedurally created objects touch.
A simple example I made for a cube worked flawlessly, then I moved to my actual objects.
The query I am using for the cylinder-like object is just an extrusion and for the developing upside-down cone is this:
@StartRule
Lot-->
extrude(0.2)
center(xz)
comp(f) {bottom : Root}
Root-->
case(scope.sx > 0.5):
s('0.97, '0.97, 0)
center(xy)
color(0,0.4,0.7)
extrude(0.5)Facades
X
comp(f){top : Root}
else: NIL
Facades-->
comp(f){side:OcclusionDetection | bottom:OcclusionDetection | top:OcclusionDetection}
OcclusionDetection -->
case overlaps (inter):
color("#ff0000")
X
else: color("#c3ff00")<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>The result is on the image:

Image assessment:
1. there is a "ghost" touch, 2. this is my aim accomplished and 3. that interaction is not registered this time (although earlier it was registering). I move around the yellow-green object to make it re-render and register the overlaps.
Problem:
Inconsistent behaviour of the occlusion function. The script worked fine the first time I compiled it and after a minute it stopped working. By not working I mean, registering all the time that there is no overlap or having a problem to display the OcclusionDetection colours on-top of the Root colour. It took a lot of time fiddling around with it, although practically staying the same, to make it work again.All these in addition to the issues 1 and 3 from the picture.
Is there a way to improve my script and make it work consistently?
(The City Engine version used is 2015.2, on a Win 10 system, with Intel Core i5 M520, 6GB RAM, GT320M, SSD)