Beispiel #1
0
CubicClipVolume calculateCubicClipVolume( const Matrix4& viewproj ){
	CubicClipVolume clip;
	clip.cam = vector4_projected(
		matrix4_transformed_vector4(
			matrix4_full_inverse( viewproj ),
			Vector4( 0, 0, -1, 1 )
			)
		);
	clip.min[0] = clip.cam[0] + ( portals.clip_range * 64.0f );
	clip.min[1] = clip.cam[1] + ( portals.clip_range * 64.0f );
	clip.min[2] = clip.cam[2] + ( portals.clip_range * 64.0f );
	clip.max[0] = clip.cam[0] - ( portals.clip_range * 64.0f );
	clip.max[1] = clip.cam[1] - ( portals.clip_range * 64.0f );
	clip.max[2] = clip.cam[2] - ( portals.clip_range * 64.0f );
	return clip;
}
/* greebo: This is called by the ManipulateObserver class on the mouseDown event. It checks, if a manipulator
 * can be selected where the mouse is pointing to.
 */
bool RadiantSelectionSystem::SelectManipulator(const View& view, const float device_point[2], const float device_epsilon[2]) {
	if (!nothingSelected() || (ManipulatorMode() == eDrag && Mode() == eComponent)) {
#if defined (DEBUG_SELECTION)
		g_render_clipped.destroy();
#endif

		// Unselect any currently selected manipulators to be sure
		_manipulator->setSelected(false);

		// Test, if the current manipulator can be selected
		if (!nothingSelected() || (ManipulatorMode() == eDrag && Mode() == eComponent)) {
			View scissored(view);
			ConstructSelectionTest(scissored, SelectionBoxForPoint(device_point, device_epsilon));

			// The manipulator class checks on its own, if any of its components can be selected
			_manipulator->testSelect(scissored, GetPivot2World());
		}

		// Save the pivot2world matrix
		startMove();

		// This is true, if a manipulator could be selected
		_pivotMoving = _manipulator->isSelected();

		// is a manipulator selected / the pivot moving?
		if (_pivotMoving) {
			Pivot2World pivot;
			pivot.update(GetPivot2World(), view.GetModelview(), view.GetProjection(), view.GetViewport());

			_manip2pivotStart = matrix4_multiplied_by_matrix4(matrix4_full_inverse(_pivot2worldStart), pivot.m_worldSpace);

			Matrix4 device2manip;
			ConstructDevice2Manip(device2manip, _pivot2worldStart, view.GetModelview(), view.GetProjection(), view.GetViewport());
			_manipulator->GetManipulatable()->Construct(device2manip, device_point[0], device_point[1]);

			_undoBegun = false;
		}

		SceneChangeNotify();
	}

	return _pivotMoving;
}