Predicting and optimizing the performance of ray shooting is a very important problem in computer graphics due to the severe computational demands of ray tracing and other applications, e.g., radio propagation simulation. Aronov and Fortune were the first to guarantee an overall performance within a constant factor of optimal in the following model of computation: build a triangulation compatible with the scene, and shoot rays by locating origin and traversing until hit is found. Triangulations are not a very popular model in computer graphics, but space decompositions like kd-trees and octrees are used routinely. Aronov and coll. [1] developed a cost measure for such decompositions, and proved it to reliably predict the average cost of ray shooting. In this paper, we address the corresponding optimization problem on octrees with the same cost measure as the optimizing criterion. More generally, we solve the generalization for generalized octrees in any d dimensions with scenes made u...