mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Adds multiple entity selection to Atlas (including move/delete). Fixes #678.
Makes all actors selectable in Atlas and gives them selection rings (an EditorOnly flag is used in the template for Atlas-only selectables). Adds player colors to Atlas selection rings. Fixes decal selection by falling back to old-style AABBs. Refs #1032. Replaces UnitManager selections with EntitySelection helpers. Adds DrawOverlays to Atlas views, for Atlas-specific rendering. Fixes bug where selection rings conflicted with Move/rotate tool in Atlas simulation test. This was SVN commit r11177.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -85,42 +85,6 @@ void CUnitManager::DeleteAll()
|
||||
m_Units.clear();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PickUnit: iterate through units testing given ray against bounds of each
|
||||
// unit; return the closest unit, or null if everything missed
|
||||
CUnit* CUnitManager::PickUnit(const CVector3D& origin, const CVector3D& dir) const
|
||||
{
|
||||
// closest object found so far
|
||||
CUnit* hit = 0;
|
||||
// closest approach offset (easier to pick small stuff in forests than standard ScEd style selection)
|
||||
float minrel = FLT_MAX;
|
||||
|
||||
for (size_t i=0; i<m_Units.size(); i++) {
|
||||
CUnit* unit = m_Units[i];
|
||||
float tmin, tmax;
|
||||
|
||||
const CBoundingBoxOriented& selectionBox = unit->GetModel().GetSelectionBox();
|
||||
if (selectionBox.RayIntersect(origin, dir, tmin, tmax))
|
||||
{
|
||||
// Point of closest approach
|
||||
// TODO: this next bit is virtually identical to Selection::PickEntitiesAtPoint; might be useful to factor it out and
|
||||
// reuse it
|
||||
CVector3D delta = selectionBox.m_Center - origin;
|
||||
float distance = delta.Dot(dir);
|
||||
CVector3D closest = origin + dir * distance;
|
||||
CVector3D offset = selectionBox.m_Center - closest;
|
||||
|
||||
float rel = offset.Length();
|
||||
if (rel < minrel) {
|
||||
hit = unit;
|
||||
minrel = rel;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hit;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CreateUnit: create a new unit and add it to the world
|
||||
CUnit* CUnitManager::CreateUnit(const CStrW& actorName, uint32_t seed, const std::set<CStr8>& selections)
|
||||
|
||||
Reference in New Issue
Block a user