optimize cam ray calculation