void IManipulator.Render(ViewControl vc) { TerrainGob terrain = m_terrainEditor.TerrainEditorControl.SelectedTerrain; TerrainBrush brush = m_terrainEditor.TerrainEditorControl.SelectedBrush; TerrainMap terrainMap = m_terrainEditor.TerrainEditorControl.SelectedTerrainMap; if (brush == null || (!brush.CanApplyTo(terrain) && !brush.CanApplyTo(terrainMap))) { return; } Vec2F drawscale = new Vec2F(1.0f, 1.0f); if (brush.CanApplyTo(terrainMap)) { ImageData mapImg = terrainMap.GetSurface(); ImageData hmImg = terrain.GetSurface(); drawscale.X = (float)hmImg.Width / (float)mapImg.Width; drawscale.Y = (float)hmImg.Height / (float)mapImg.Height; } Point scrPt = vc.PointToClient(Control.MousePosition); if (!vc.ClientRectangle.Contains(scrPt)) { return; } Ray3F rayw = vc.GetWorldRay(scrPt); TerrainGob.RayPickRetVal retval; if (terrain.RayPick(rayw, out retval)) { terrain.DrawBrush(brush, drawscale, retval.hitpos); } }
private void ApplyBrush(ViewControl vc, System.Drawing.Point scrPt) { TerrainGob terrain = m_terrainEditor.TerrainEditorControl.SelectedTerrain; TerrainBrush brush = m_terrainEditor.TerrainEditorControl.SelectedBrush; TerrainMap terrainMap = m_terrainEditor.TerrainEditorControl.SelectedTerrainMap; if (brush == null || (!brush.CanApplyTo(terrain) && !brush.CanApplyTo(terrainMap))) { return; } Ray3F rayw = vc.GetWorldRay(scrPt); TerrainGob.RayPickRetVal retval; if (terrain.RayPick(rayw, out retval)) { TerrainOp op = null; if (brush.CanApplyTo(terrain)) { Point pt = terrain.WorldToSurfaceSpace(retval.hitpos); brush.Apply(terrain, pt.X, pt.Y, out op); } else if (brush.CanApplyTo(terrainMap)) { Point pt = terrainMap.WorldToSurfaceSpace(retval.hitpos); brush.Apply(terrainMap, pt.X, pt.Y, out op); } m_tmpOps.Add(op); m_terrainOpList.Add(new WeakReference(op)); m_memUsage += op.SizeInBytes; } }