A mobile robot must have the ability of building a representation of its environment and the objects in it. To build a three-dimensional (3D) model of a physical object, several scans must be taken at different locations. Selecting each location is the next-best-view problem. Search based methods, where candidate views are generated and evaluated by a utility function, are a solution. However, such methods are slow for high resolution models given that the evaluation requires visibility computation in 3D. We propose a scene representation by octrees with a hierarchical ray tracing that reduces the visibility computation time. Such method performs a coarse ray tracing, except for the interesting volumes where a finer resolution is applied. The method decreases the computation time at least one order of magnitude. Saving time with this method leads to evaluate more constraints and more candidate views in high resolution models.