MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / HandleScrollSelect

Method HandleScrollSelect

Source/Editors/map_editor.cpp:1914–1997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1912}
1913
1914bool MapEditor::HandleScrollSelect(const vec3& start, const vec3& end) {
1915 bool something_happened = false;
1916
1917 // Check scroll direction
1918 int scrolled = 0;
1919 if (Input::Instance()->getMouse().wheel_delta_y_ < 0) {
1920 scrolled = -1;
1921 } else if (Input::Instance()->getMouse().wheel_delta_y_ > 0) {
1922 scrolled = 1;
1923 }
1924 if (scrolled == 0) {
1925 return false;
1926 }
1927
1928 // Get sorted list of collisions with mouse ray
1929 std::vector<Collision> collisions;
1930 GetEditorLineCollisions(scenegraph_, start, end, collisions, type_enable_);
1931 if (collisions.empty()) {
1932 return false;
1933 }
1934 std::sort(collisions.begin(), collisions.end(), CollisionCompare(start));
1935
1936 for (int i = 0; i < (int)collisions.size();) {
1937 if (collisions[i].hit_what->GetType() == _group || collisions[i].hit_what->GetType() == _prefab) {
1938 collisions.erase(collisions.begin() + i);
1939 } else if (collisions[i].hit_what->parent &&
1940 (collisions[i].hit_what->parent->GetType() == _group ||
1941 collisions[i].hit_what->parent->GetType() == _prefab)) {
1942 int depth = 1;
1943 while (collisions[i].hit_what->parent &&
1944 (collisions[i].hit_what->parent->GetType() == _group ||
1945 collisions[i].hit_what->parent->GetType() == _prefab)
1946
1947 ) {
1948 bool is_duplicate = false;
1949 for (int j = 0; j < i; ++j) { // Don't allow same group to be in list twice
1950 if (collisions[i].hit_what->parent == collisions[j].hit_what) {
1951 is_duplicate = true;
1952 break;
1953 }
1954 }
1955 if (!is_duplicate) {
1956 ++depth;
1957 collisions.insert(collisions.begin() + i, collisions[i]);
1958 collisions[i].hit_what = collisions[i].hit_what->parent;
1959 } else {
1960 break;
1961 }
1962 }
1963 i += depth;
1964 } else {
1965 ++i;
1966 }
1967 }
1968
1969 // Get selected item in collision list
1970 int selected_item = -1;
1971 for (int i = 0, len = (int)collisions.size(); i < len; ++i) {

Callers

nothing calls this directly

Calls 13

GetEditorLineCollisionsFunction · 0.85
CollisionCompareClass · 0.85
DrawObjInfoFunction · 0.85
SelectedMethod · 0.80
sortFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
GetTypeMethod · 0.45
eraseMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected