2006-03-20 16:43:15 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
2010-12-24 04:26:24 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
2006-03-20 16:43:15 +00:00
|
|
|
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
2008-04-06 20:23:28 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
/*
|
|
|
|
*
|
2008-01-23 17:25:09 +00:00
|
|
|
* Routines stripped from med.c for segment selection
|
2006-03-20 16:43:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "gr.h"
|
|
|
|
#include "ui.h"
|
|
|
|
#include "key.h"
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "u_mem.h"
|
|
|
|
#include "inferno.h"
|
2013-12-26 04:18:28 +00:00
|
|
|
#include "gameseg.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "editor.h"
|
2013-03-16 03:10:55 +00:00
|
|
|
#include "editor/esegment.h"
|
2013-09-24 01:59:09 +00:00
|
|
|
#include "editor/medmisc.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "segment.h"
|
|
|
|
#include "object.h"
|
2012-11-17 06:14:09 +00:00
|
|
|
#include "medsel.h"
|
|
|
|
#include "kdefs.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-12-11 23:59:36 +00:00
|
|
|
#include "dxxsconf.h"
|
|
|
|
#include "compiler-range_for.h"
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//find the distance between a segment and a point
|
2014-10-02 03:02:37 +00:00
|
|
|
static fix compute_dist(const segment *seg,const vms_vector &pos)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
vms_vector delta;
|
|
|
|
|
|
|
|
compute_segment_center(&delta,seg);
|
2014-10-02 03:02:37 +00:00
|
|
|
vm_vec_sub2(delta,pos);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2014-09-28 21:11:03 +00:00
|
|
|
return vm_vec_mag(delta);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:02:37 +00:00
|
|
|
void sort_seg_list(count_segment_array_t &segnumlist,const vms_vector &pos)
|
2013-12-11 23:59:36 +00:00
|
|
|
{
|
|
|
|
array<fix, MAX_SEGMENTS> dist;
|
|
|
|
range_for (const auto &ss, segnumlist)
|
|
|
|
dist[ss] = compute_dist(&Segments[ss],pos);
|
|
|
|
auto predicate = [&dist](count_segment_array_t::const_reference a, count_segment_array_t::const_reference b) {
|
|
|
|
return dist[a] < dist[b];
|
|
|
|
};
|
|
|
|
std::sort(segnumlist.begin(), segnumlist.end(), predicate);
|
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
int SortSelectedList(void)
|
|
|
|
{
|
2014-10-02 03:02:37 +00:00
|
|
|
sort_seg_list(Selected_segs,ConsoleObject->pos);
|
2013-12-11 23:59:36 +00:00
|
|
|
editor_status_fmt("%i element selected list sorted.",Selected_segs.count());
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SelectNextFoundSeg(void)
|
|
|
|
{
|
2013-12-11 23:59:36 +00:00
|
|
|
if (++Found_seg_index >= Found_segs.count())
|
2006-03-20 16:43:15 +00:00
|
|
|
Found_seg_index = 0;
|
|
|
|
|
|
|
|
Cursegp = &Segments[Found_segs[Found_seg_index]];
|
|
|
|
med_create_new_segment_from_cursegp();
|
|
|
|
|
|
|
|
Update_flags |= UF_WORLD_CHANGED;
|
|
|
|
|
|
|
|
if (Lock_view_to_cursegp)
|
|
|
|
set_view_target_from_segment(Cursegp);
|
|
|
|
|
|
|
|
editor_status("Curseg assigned to next found segment.");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SelectPreviousFoundSeg(void)
|
|
|
|
{
|
|
|
|
if (Found_seg_index > 0)
|
|
|
|
Found_seg_index--;
|
|
|
|
else
|
2013-12-11 23:59:36 +00:00
|
|
|
Found_seg_index = Found_segs.count()-1;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
Cursegp = &Segments[Found_segs[Found_seg_index]];
|
|
|
|
med_create_new_segment_from_cursegp();
|
|
|
|
|
|
|
|
Update_flags |= UF_WORLD_CHANGED;
|
|
|
|
|
|
|
|
if (Lock_view_to_cursegp)
|
|
|
|
set_view_target_from_segment(Cursegp);
|
|
|
|
|
|
|
|
editor_status("Curseg assigned to previous found segment.");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|