2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
#include "qedefs.h"
|
2001-10-14 05:55:21 +00:00
|
|
|
#import "Project.h"
|
|
|
|
|
|
|
|
extern Project *project;
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
id map_i;
|
|
|
|
|
|
|
|
@implementation Map
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
FILE METHODS
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (id) init
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
[super init];
|
|
|
|
map_i = self;
|
|
|
|
minz = 0;
|
|
|
|
maxz = 80;
|
|
|
|
|
2001-02-09 06:50:40 +00:00
|
|
|
oldselection = [[NSMutableArray alloc] init];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) saveSelected
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
int i, c;
|
|
|
|
id o, w;
|
|
|
|
|
2001-02-09 06:50:40 +00:00
|
|
|
[oldselection removeAllObjects];
|
|
|
|
w = [self objectAtIndex: 0];
|
2001-02-09 01:52:44 +00:00
|
|
|
c = [w count];
|
|
|
|
sb_newowner = oldselection;
|
2001-05-07 09:43:25 +00:00
|
|
|
for (i = 0; i < c; i++) {
|
2001-02-09 06:50:40 +00:00
|
|
|
o = [w objectAtIndex: 0];
|
2001-05-07 09:43:25 +00:00
|
|
|
if ([o selected]) {
|
2001-02-09 01:52:44 +00:00
|
|
|
[o moveToEntity];
|
2001-05-07 09:43:25 +00:00
|
|
|
} else {
|
2001-02-09 06:50:40 +00:00
|
|
|
[w removeObjectAtIndex: 0];
|
2001-05-07 09:43:25 +00:00
|
|
|
[o release];
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c = [self count];
|
2001-05-07 09:43:25 +00:00
|
|
|
for (i = 0; i < c; i++) {
|
2001-02-09 06:50:40 +00:00
|
|
|
o = [self objectAtIndex: 0];
|
|
|
|
[self removeObjectAtIndex: 0];
|
2001-05-07 09:43:25 +00:00
|
|
|
[o removeAllObjects];
|
|
|
|
[o release];
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) addSelected
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
int i, c;
|
|
|
|
id n, w;
|
|
|
|
|
|
|
|
c = [oldselection count];
|
2001-02-09 06:50:40 +00:00
|
|
|
w = [self objectAtIndex: 0]; // world object
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
sb_newowner = w;
|
2001-05-07 09:43:25 +00:00
|
|
|
for (i = 0; i < c; i++) {
|
|
|
|
n = [oldselection objectAtIndex: i--];
|
2001-02-09 01:52:44 +00:00
|
|
|
[n moveToEntity];
|
|
|
|
c--;
|
|
|
|
}
|
2001-02-09 06:50:40 +00:00
|
|
|
[oldselection removeAllObjects];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) newMap
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
id ent;
|
|
|
|
|
|
|
|
[self saveSelected];
|
|
|
|
ent = [[Entity alloc] initClass: "worldspawn"];
|
|
|
|
[self addObject: ent];
|
|
|
|
currentEntity = NULL;
|
|
|
|
[self setCurrentEntity: ent];
|
|
|
|
[self addSelected];
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (id) currentEntity
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
return currentEntity;
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) setCurrentEntity: ent
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
id old;
|
|
|
|
|
|
|
|
old = currentEntity;
|
|
|
|
currentEntity = ent;
|
2001-05-07 09:43:25 +00:00
|
|
|
if (old != ent) {
|
2001-02-09 01:52:44 +00:00
|
|
|
[things_i newCurrentEntity]; // update inspector
|
|
|
|
[inspcontrol_i changeInspectorTo:i_things];
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (float) currentMinZ
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
float grid;
|
|
|
|
|
|
|
|
grid = [xyview_i gridsize];
|
|
|
|
minz = grid * rint(minz/grid);
|
|
|
|
return minz;
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) setCurrentMinZ: (float) m
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
if (m > -2048)
|
|
|
|
minz = m;
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (float) currentMaxZ
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
float grid;
|
|
|
|
|
|
|
|
[self currentMinZ]; // grid align
|
|
|
|
|
|
|
|
grid = [xyview_i gridsize];
|
|
|
|
maxz = grid * rint(maxz/grid);
|
|
|
|
|
|
|
|
if (maxz <= minz)
|
|
|
|
maxz = minz + grid;
|
|
|
|
return maxz;
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) setCurrentMaxZ: (float) m
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
if (m < 2048)
|
|
|
|
maxz = m;
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) removeObject: (id) o
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
[super removeObject: o];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
if (o == currentEntity) { // select the world
|
2001-02-09 06:50:40 +00:00
|
|
|
[self setCurrentEntity: [self objectAtIndex: 0]];
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) writeStats
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
2001-05-07 09:43:25 +00:00
|
|
|
FILE *f;
|
|
|
|
extern int c_updateall;
|
|
|
|
struct timeval tp;
|
2001-02-09 01:52:44 +00:00
|
|
|
struct timezone tzp;
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
gettimeofday (&tp, &tzp);
|
2001-02-09 01:52:44 +00:00
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
f = fopen ([developerLogFile cString], "a");
|
|
|
|
fprintf (f,"%i %i\n", (int) tp.tv_sec, c_updateall);
|
2001-02-09 01:52:44 +00:00
|
|
|
c_updateall = 0;
|
|
|
|
fclose (f);
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (int) numSelected
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
int i, c;
|
2001-05-07 09:43:25 +00:00
|
|
|
int num = 0;
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
c = [currentEntity count];
|
2001-05-07 09:43:25 +00:00
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
if ([[currentEntity objectAtIndex: i] selected])
|
2001-02-09 01:52:44 +00:00
|
|
|
num++;
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
- (id) selectedBrush
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
int i, c;
|
|
|
|
|
|
|
|
c = [currentEntity count];
|
|
|
|
for (i=0 ; i<c ; i++)
|
2001-02-09 06:50:40 +00:00
|
|
|
if ( [[currentEntity objectAtIndex: i] selected] )
|
|
|
|
return [currentEntity objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
readMapFile
|
|
|
|
=================
|
|
|
|
*/
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) readMapFile: (NSString *) fname
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
2001-10-14 05:55:21 +00:00
|
|
|
NSString *dat;
|
|
|
|
char *cl;
|
2001-02-09 01:52:44 +00:00
|
|
|
id new;
|
|
|
|
id ent;
|
|
|
|
int i, c;
|
|
|
|
vec3_t org;
|
|
|
|
float angle;
|
|
|
|
|
|
|
|
[self saveSelected];
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
NSLog (@"loading %s\n", fname);
|
2001-02-09 01:52:44 +00:00
|
|
|
|
2001-10-14 05:55:21 +00:00
|
|
|
LoadFile ((char *) [fname lossyCString], (void **) &dat);
|
|
|
|
StartTokenParsing ((char *) [dat lossyCString]);
|
2001-02-09 01:52:44 +00:00
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
do {
|
2001-02-09 01:52:44 +00:00
|
|
|
new = [[Entity alloc] initFromTokens];
|
|
|
|
if (!new)
|
|
|
|
break;
|
|
|
|
[self addObject: new];
|
|
|
|
} while (1);
|
|
|
|
|
|
|
|
free (dat);
|
|
|
|
|
2001-02-09 06:50:40 +00:00
|
|
|
[self setCurrentEntity: [self objectAtIndex: 0]];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
[self addSelected];
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
// load the apropriate texture wad
|
2001-10-14 05:55:21 +00:00
|
|
|
if ((dat = [currentEntity objectForKey: @"wad"])) {
|
|
|
|
if ([dat hasPrefix: @"/"]) { // remove old style fullpaths
|
|
|
|
[currentEntity removeObjectForKey: @"wad"];
|
2001-05-07 09:43:25 +00:00
|
|
|
} else {
|
2001-10-14 05:55:21 +00:00
|
|
|
if (!([[texturepalette_i currentWad] isEqualToString: dat]))
|
|
|
|
[project setTextureWad: dat];
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
// center the camera and XY view on the playerstart
|
2001-02-09 01:52:44 +00:00
|
|
|
c = [self count];
|
2001-05-07 09:43:25 +00:00
|
|
|
for (i=1 ; i<c ; i++) {
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
cl = [ent valueForQKey: "classname"];
|
2001-05-07 09:43:25 +00:00
|
|
|
if (cl && !strcasecmp (cl,"info_player_start")) {
|
2001-02-09 01:52:44 +00:00
|
|
|
angle = atof( [ent valueForQKey: "angle"] );
|
|
|
|
angle = angle/180*M_PI;
|
|
|
|
[ent getVector: org forKey: "origin"];
|
|
|
|
[cameraview_i setOrigin: org angle:angle];
|
|
|
|
[xyview_i centerOn: org];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
writeMapFile
|
|
|
|
=================
|
|
|
|
*/
|
2001-05-07 09:43:25 +00:00
|
|
|
- (void) writeMapFile: (NSString *) fname useRegion: (BOOL) reg
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
int i;
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
NSLog (@"writeMapFile: %s", fname);
|
2001-02-09 01:52:44 +00:00
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
if (!(f = fopen ([fname cString], "w")))
|
|
|
|
NSLog (@"couldn't write %s", fname);
|
|
|
|
|
|
|
|
for (i = 0; i < [self count]; i++)
|
2001-02-09 06:50:40 +00:00
|
|
|
[[self objectAtIndex: i] writeToFILE: f region: reg];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
fclose (f);
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
return;
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
DRAWING
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
- ZDrawSelf
|
|
|
|
{
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
count = [self count];
|
|
|
|
|
|
|
|
for (i=0 ; i<count ; i++)
|
2001-02-09 06:50:40 +00:00
|
|
|
[[self objectAtIndex: i] ZDrawSelf];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- RenderSelf: (void (*) (face_t *))callback
|
|
|
|
{
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
count = [self count];
|
|
|
|
|
|
|
|
for (i=0 ; i<count ; i++)
|
2001-02-09 06:50:40 +00:00
|
|
|
[[self objectAtIndex: i] RenderSelf: callback];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
entityConnect
|
|
|
|
|
|
|
|
A command-shift-click on an entity while an entity is selected will
|
|
|
|
make a target connection from the original entity.
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
- entityConnect: (vec3_t)p1 : (vec3_t)p2
|
|
|
|
{
|
|
|
|
id oldent, ent;
|
|
|
|
|
|
|
|
oldent = [self currentEntity];
|
2001-02-09 06:50:40 +00:00
|
|
|
if (oldent == [self objectAtIndex: 0])
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
qprintf ("Must have a non-world entity selected to connect");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
[self selectRay: p1 : p2 : YES];
|
|
|
|
ent = [self currentEntity];
|
|
|
|
if (ent == oldent)
|
|
|
|
{
|
|
|
|
qprintf ("Must click on a different entity to connect");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2001-02-09 06:50:40 +00:00
|
|
|
if (ent == [self objectAtIndex: 0])
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
qprintf ("Must click on a non-world entity to connect");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
[oldent setKey:"target" toValue: [ent targetname]];
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
selectRay
|
|
|
|
|
|
|
|
If ef is true, any entity brush along the ray will be selected in preference
|
|
|
|
to intervening world brushes
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
- selectRay: (vec3_t)p1 : (vec3_t)p2 : (BOOL)ef
|
|
|
|
{
|
|
|
|
int i, j, c, c2;
|
|
|
|
id ent, bestent;
|
|
|
|
id brush, bestbrush;
|
|
|
|
int face, bestface;
|
|
|
|
float time, besttime;
|
|
|
|
texturedef_t *td;
|
|
|
|
|
|
|
|
bestent = nil;
|
|
|
|
bestface = -1;
|
|
|
|
bestbrush = nil;
|
|
|
|
besttime = 99999;
|
|
|
|
|
|
|
|
c = [self count];
|
2001-05-07 09:43:25 +00:00
|
|
|
for (i = c - 1; i >= 0; i--) {
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
c2 = [ent count];
|
2001-05-07 09:43:25 +00:00
|
|
|
for (j = 0; j < c2; j++) {
|
2001-02-09 06:50:40 +00:00
|
|
|
brush = [ent objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
[brush hitByRay: p1 : p2 : &time : &face];
|
|
|
|
if (time < 0 || time >besttime)
|
|
|
|
continue;
|
|
|
|
bestent = ent;
|
|
|
|
besttime = time;
|
|
|
|
bestbrush = brush;
|
|
|
|
bestface = face;
|
|
|
|
}
|
|
|
|
if (i == 1 && ef && bestbrush)
|
|
|
|
break; // found an entity, so don't check the world
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
if (besttime == 99999) {
|
2001-02-09 01:52:44 +00:00
|
|
|
qprintf ("trace missed");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
if ( [bestbrush regioned] ) {
|
2001-02-09 01:52:44 +00:00
|
|
|
qprintf ("WANRING: clicked on regioned brush");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
if (bestent != currentEntity) {
|
2001-02-09 01:52:44 +00:00
|
|
|
[self makeSelectedPerform: @selector(deselect)];
|
|
|
|
[self setCurrentEntity: bestent];
|
|
|
|
}
|
|
|
|
|
|
|
|
[quakeed_i disableFlushWindow];
|
2001-05-07 09:43:25 +00:00
|
|
|
if (![bestbrush selected]) {
|
|
|
|
if ([map_i numSelected] == 0) { // don't grab texture if others are selected
|
2001-02-09 01:52:44 +00:00
|
|
|
td = [bestbrush texturedefForFace: bestface];
|
|
|
|
[texturepalette_i setTextureDef: td];
|
|
|
|
}
|
|
|
|
|
|
|
|
[bestbrush setSelected: YES];
|
2001-02-09 06:50:40 +00:00
|
|
|
qprintf ("selected entity %i brush %i face %i", [self indexOfObject:bestent], [bestent indexOfObject: bestbrush], bestface);
|
2001-05-07 09:43:25 +00:00
|
|
|
} else {
|
2001-02-09 01:52:44 +00:00
|
|
|
[bestbrush setSelected: NO];
|
2001-02-09 06:50:40 +00:00
|
|
|
qprintf ("deselected entity %i brush %i face %i", [self indexOfObject:bestent], [bestent indexOfObject: bestbrush], bestface);
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
2001-05-07 09:43:25 +00:00
|
|
|
[quakeed_i enableFlushWindow];
|
2001-02-09 01:52:44 +00:00
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
grabRay
|
|
|
|
|
|
|
|
only checks the selected brushes
|
|
|
|
Returns the brush hit, or nil if missed.
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
- grabRay: (vec3_t)p1 : (vec3_t)p2
|
|
|
|
{
|
|
|
|
int i, j, c, c2;
|
|
|
|
id ent;
|
|
|
|
id brush, bestbrush;
|
|
|
|
int face;
|
|
|
|
float time, besttime;
|
|
|
|
|
|
|
|
bestbrush = nil;
|
|
|
|
besttime = 99999;
|
|
|
|
|
|
|
|
c = [self count];
|
|
|
|
for (i=0 ; i<c ; i++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
c2 = [ent count];
|
|
|
|
for (j=0 ; j<c2 ; j++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
brush = [ent objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
if (![brush selected])
|
|
|
|
continue;
|
|
|
|
[brush hitByRay: p1 : p2 : &time : &face];
|
|
|
|
if (time < 0 || time >besttime)
|
|
|
|
continue;
|
|
|
|
besttime = time;
|
|
|
|
bestbrush = brush;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (besttime == 99999)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
return bestbrush;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
getTextureRay
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
- getTextureRay: (vec3_t)p1 : (vec3_t)p2
|
|
|
|
{
|
|
|
|
int i, j, c, c2;
|
|
|
|
id ent, bestent;
|
|
|
|
id brush, bestbrush;
|
|
|
|
int face, bestface;
|
|
|
|
float time, besttime;
|
|
|
|
texturedef_t *td;
|
|
|
|
vec3_t mins, maxs;
|
|
|
|
|
|
|
|
|
|
|
|
bestbrush = nil;
|
|
|
|
bestent = nil;
|
|
|
|
besttime = 99999;
|
|
|
|
bestface = -1;
|
|
|
|
c = [self count];
|
|
|
|
for (i=0 ; i<c ; i++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
c2 = [ent count];
|
|
|
|
for (j=0 ; j<c2 ; j++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
brush = [ent objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
[brush hitByRay: p1 : p2 : &time : &face];
|
|
|
|
if (time < 0 || time >besttime)
|
|
|
|
continue;
|
|
|
|
bestent = ent;
|
|
|
|
bestface = face;
|
|
|
|
besttime = time;
|
|
|
|
bestbrush = brush;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (besttime == 99999)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
if ( ![bestent modifiable])
|
|
|
|
{
|
|
|
|
qprintf ("can't modify spawned entities");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
td = [bestbrush texturedefForFace: bestface];
|
|
|
|
[texturepalette_i setTextureDef: td];
|
|
|
|
|
|
|
|
qprintf ("grabbed texturedef and sizes");
|
|
|
|
|
|
|
|
[bestbrush getMins: mins maxs: maxs];
|
|
|
|
|
|
|
|
minz = mins[2];
|
|
|
|
maxz = maxs[2];
|
|
|
|
|
|
|
|
return bestbrush;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
setTextureRay
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
- setTextureRay: (vec3_t)p1 : (vec3_t)p2 : (BOOL)allsides;
|
|
|
|
{
|
|
|
|
int i, j, c, c2;
|
|
|
|
id ent, bestent;
|
|
|
|
id brush, bestbrush;
|
|
|
|
int face, bestface;
|
|
|
|
float time, besttime;
|
|
|
|
texturedef_t td;
|
|
|
|
|
|
|
|
bestent = nil;
|
|
|
|
bestface = -1;
|
|
|
|
bestbrush = nil;
|
|
|
|
besttime = 99999;
|
|
|
|
|
|
|
|
c = [self count];
|
|
|
|
for (i=0 ; i<c ; i++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
c2 = [ent count];
|
|
|
|
for (j=0 ; j<c2 ; j++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
brush = [ent objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
[brush hitByRay: p1 : p2 : &time : &face];
|
|
|
|
if (time < 0 || time >besttime)
|
|
|
|
continue;
|
|
|
|
bestent = ent;
|
|
|
|
besttime = time;
|
|
|
|
bestbrush = brush;
|
|
|
|
bestface = face;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (besttime == 99999)
|
|
|
|
{
|
|
|
|
qprintf ("trace missed");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ![bestent modifiable])
|
|
|
|
{
|
|
|
|
qprintf ("can't modify spawned entities");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( [bestbrush regioned] )
|
|
|
|
{
|
|
|
|
qprintf ("WANRING: clicked on regioned brush");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2001-10-14 05:55:21 +00:00
|
|
|
[texturepalette_i setTextureDef: &td];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
[quakeed_i disableFlushWindow];
|
|
|
|
if (allsides)
|
|
|
|
{
|
|
|
|
[bestbrush setTexturedef: &td];
|
2001-02-09 06:50:40 +00:00
|
|
|
qprintf ("textured entity %i brush %i", [self indexOfObject:bestent], [bestent indexOfObject: bestbrush]);
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[bestbrush setTexturedef: &td forFace: bestface];
|
2001-02-09 06:50:40 +00:00
|
|
|
qprintf ("deselected entity %i brush %i face %i", [self indexOfObject:bestent], [bestent indexOfObject: bestbrush], bestface);
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
2001-05-07 09:43:25 +00:00
|
|
|
[quakeed_i enableFlushWindow];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
OPERATIONS ON SELECTIONS
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
- makeSelectedPerform: (SEL)sel
|
|
|
|
{
|
|
|
|
int i,j, c, c2;
|
|
|
|
id ent, brush;
|
|
|
|
int total;
|
|
|
|
|
|
|
|
total = 0;
|
|
|
|
c = [self count];
|
|
|
|
for (i=c-1 ; i>=0 ; i--)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
c2 = [ent count];
|
|
|
|
for (j = c2-1 ; j >=0 ; j--)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
brush = [ent objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
if (! [brush selected] )
|
|
|
|
continue;
|
|
|
|
if ([brush regioned])
|
|
|
|
continue;
|
|
|
|
total++;
|
|
|
|
[brush perform:sel];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (!total)
|
|
|
|
// qprintf ("nothing selected");
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- makeUnselectedPerform: (SEL)sel
|
|
|
|
{
|
|
|
|
int i,j, c, c2;
|
|
|
|
id ent, brush;
|
|
|
|
|
|
|
|
c = [self count];
|
|
|
|
for (i=c-1 ; i>=0 ; i--)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
c2 = [ent count];
|
|
|
|
for (j = c2-1 ; j >=0 ; j--)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
brush = [ent objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
if ( [brush selected] )
|
|
|
|
continue;
|
|
|
|
if ([brush regioned])
|
|
|
|
continue;
|
|
|
|
[brush perform:sel];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- makeAllPerform: (SEL)sel
|
|
|
|
{
|
|
|
|
int i,j, c, c2;
|
|
|
|
id ent, brush;
|
|
|
|
|
|
|
|
c = [self count];
|
|
|
|
for (i=c-1 ; i>=0 ; i--)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
c2 = [ent count];
|
|
|
|
for (j = c2-1 ; j >=0 ; j--)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
brush = [ent objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
if ([brush regioned])
|
|
|
|
continue;
|
|
|
|
[brush perform:sel];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- makeGlobalPerform: (SEL)sel // in and out of region
|
|
|
|
{
|
|
|
|
int i,j, c, c2;
|
|
|
|
id ent, brush;
|
|
|
|
|
|
|
|
c = [self count];
|
|
|
|
for (i=c-1 ; i>=0 ; i--)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
ent = [self objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
c2 = [ent count];
|
|
|
|
for (j = c2-1 ; j >=0 ; j--)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
brush = [ent objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
[brush perform:sel];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sel_identity (void)
|
|
|
|
{
|
|
|
|
sel_x[0]=1; sel_x[1]=0; sel_x[2]=0;
|
|
|
|
sel_y[0]=0; sel_y[1]=1; sel_y[2]=0;
|
|
|
|
sel_z[0]=0; sel_z[1]=0; sel_z[2]=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
- transformSelection
|
|
|
|
{
|
|
|
|
if ( ![currentEntity modifiable])
|
|
|
|
{
|
|
|
|
qprintf ("can't modify spawned entities");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find an origin to apply the transformation to
|
|
|
|
sb_mins[0] = sb_mins[1] = sb_mins[2] = 99999;
|
|
|
|
sb_maxs[0] = sb_maxs[1] = sb_maxs[2] = -99999;
|
|
|
|
[self makeSelectedPerform: @selector(addToBBox)];
|
|
|
|
sel_org[0] = [xyview_i snapToGrid: (sb_mins[0] + sb_maxs[0])/2];
|
|
|
|
sel_org[1] = [xyview_i snapToGrid: (sb_mins[1] + sb_maxs[1])/2];
|
|
|
|
sel_org[2] = [xyview_i snapToGrid: (sb_mins[2] + sb_maxs[2])/2];
|
|
|
|
|
|
|
|
// do it!
|
|
|
|
[self makeSelectedPerform: @selector(transform)];
|
|
|
|
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void swapvectors (vec3_t a, vec3_t b)
|
|
|
|
{
|
|
|
|
vec3_t temp;
|
|
|
|
|
|
|
|
VectorCopy (a, temp);
|
|
|
|
VectorCopy (b, a);
|
|
|
|
VectorSubtract (vec3_origin, temp, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
UI operations
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
- rotate_x: sender
|
|
|
|
{
|
|
|
|
sel_identity ();
|
|
|
|
swapvectors(sel_y, sel_z);
|
|
|
|
[self transformSelection];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- rotate_y: sender
|
|
|
|
{
|
|
|
|
sel_identity ();
|
|
|
|
swapvectors(sel_x, sel_z);
|
|
|
|
[self transformSelection];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- rotate_z: sender
|
|
|
|
{
|
|
|
|
sel_identity ();
|
|
|
|
swapvectors(sel_x, sel_y);
|
|
|
|
[self transformSelection];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- flip_x: sender
|
|
|
|
{
|
|
|
|
sel_identity ();
|
|
|
|
sel_x[0] = -1;
|
|
|
|
[self transformSelection];
|
|
|
|
[map_i makeSelectedPerform: @selector(flipNormals)];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- flip_y: sender
|
|
|
|
{
|
|
|
|
sel_identity ();
|
|
|
|
sel_y[1] = -1;
|
|
|
|
[self transformSelection];
|
|
|
|
[map_i makeSelectedPerform: @selector(flipNormals)];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- flip_z: sender
|
|
|
|
{
|
|
|
|
sel_identity ();
|
|
|
|
sel_z[2] = -1;
|
|
|
|
[self transformSelection];
|
|
|
|
[map_i makeSelectedPerform: @selector(flipNormals)];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- cloneSelection: sender
|
|
|
|
{
|
|
|
|
int i,j , c, originalElements;
|
|
|
|
id o, b;
|
|
|
|
id new;
|
|
|
|
|
|
|
|
sb_translate[0] = sb_translate[1] = [xyview_i gridsize];
|
|
|
|
sb_translate[2] = 0;
|
|
|
|
|
|
|
|
// copy individual brushes in the world entity
|
2001-02-09 06:50:40 +00:00
|
|
|
o = [self objectAtIndex: 0];
|
2001-02-09 01:52:44 +00:00
|
|
|
c = [o count];
|
|
|
|
for (i=0 ; i<c ; i++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
b = [o objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
if (![b selected])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// copy the brush, then translate the original
|
|
|
|
new = [b copy];
|
|
|
|
[new setSelected: YES];
|
|
|
|
[new translate];
|
|
|
|
[b setSelected: NO];
|
|
|
|
[o addObject: new];
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy entire entities otherwise
|
2001-02-09 06:50:40 +00:00
|
|
|
originalElements = [self count]; // don't copy the new ones
|
2001-02-09 01:52:44 +00:00
|
|
|
for (i=1 ; i<originalElements ; i++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
o = [self objectAtIndex: i];
|
|
|
|
if (![[o objectAtIndex: 0] selected])
|
2001-02-09 01:52:44 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
new = [o copy];
|
|
|
|
[self addObject: new];
|
|
|
|
|
|
|
|
c = [o count];
|
|
|
|
for (j=0 ; j<c ; j++)
|
2001-02-09 06:50:40 +00:00
|
|
|
[[o objectAtIndex: j] setSelected: NO];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
c = [new count];
|
|
|
|
for (j=0 ; j<c ; j++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
b = [new objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
[b translate];
|
|
|
|
[b setSelected: YES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- selectCompleteEntity: sender
|
|
|
|
{
|
|
|
|
id o;
|
|
|
|
int i, c;
|
|
|
|
|
|
|
|
o = [self selectedBrush];
|
|
|
|
if (!o)
|
|
|
|
{
|
|
|
|
qprintf ("nothing selected");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
o = [o parent];
|
|
|
|
c = [o count];
|
|
|
|
for (i=0 ; i<c ; i++)
|
2001-02-09 06:50:40 +00:00
|
|
|
[[o objectAtIndex: i] setSelected: YES];
|
2001-02-09 01:52:44 +00:00
|
|
|
qprintf ("%i brushes selected", c);
|
|
|
|
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- makeEntity: sender
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
if (currentEntity != [self objectAtIndex: 0])
|
2001-02-09 01:52:44 +00:00
|
|
|
{
|
|
|
|
qprintf ("ERROR: can't makeEntity inside an entity");
|
2001-05-07 09:43:25 +00:00
|
|
|
NSBeep ();
|
2001-02-09 01:52:44 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( [self numSelected] == 0)
|
|
|
|
{
|
|
|
|
qprintf ("ERROR: must have a seed brush to make an entity");
|
2001-05-07 09:43:25 +00:00
|
|
|
NSBeep ();
|
2001-02-09 01:52:44 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sb_newowner = [[Entity alloc] initClass: [things_i spawnName]];
|
|
|
|
|
|
|
|
if ( [sb_newowner modifiable] )
|
|
|
|
[self makeSelectedPerform: @selector(moveToEntity)];
|
|
|
|
else
|
|
|
|
{ // throw out seed brush and select entity fixed brush
|
|
|
|
[self makeSelectedPerform: @selector(remove)];
|
2001-02-09 06:50:40 +00:00
|
|
|
[[sb_newowner objectAtIndex: 0] setSelected: YES];
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[self addObject: sb_newowner];
|
|
|
|
[self setCurrentEntity: sb_newowner];
|
|
|
|
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- selbox: (SEL)selector
|
|
|
|
{
|
|
|
|
id b;
|
|
|
|
|
|
|
|
if ([self numSelected] != 1)
|
|
|
|
{
|
|
|
|
qprintf ("must have a single brush selected");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
b = [self selectedBrush];
|
|
|
|
[b getMins: select_min maxs: select_max];
|
|
|
|
[b remove];
|
|
|
|
|
|
|
|
[self makeUnselectedPerform: selector];
|
|
|
|
|
|
|
|
qprintf ("identified contents");
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- selectCompletelyInside: sender
|
|
|
|
{
|
|
|
|
return [self selbox: @selector(selectComplete)];
|
|
|
|
}
|
|
|
|
|
|
|
|
- selectPartiallyInside: sender
|
|
|
|
{
|
|
|
|
return [self selbox: @selector(selectPartial)];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- tallBrush: sender
|
|
|
|
{
|
|
|
|
id b;
|
|
|
|
vec3_t mins, maxs;
|
|
|
|
texturedef_t td;
|
|
|
|
|
|
|
|
if ([self numSelected] != 1)
|
|
|
|
{
|
|
|
|
qprintf ("must have a single brush selected");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
b = [self selectedBrush];
|
|
|
|
td = *[b texturedef];
|
|
|
|
[b getMins: mins maxs: maxs];
|
|
|
|
[b remove];
|
|
|
|
|
|
|
|
mins[2] = -2048;
|
|
|
|
maxs[2] = 2048;
|
|
|
|
|
2001-02-09 06:50:40 +00:00
|
|
|
b = [[SetBrush alloc] initOwner: [map_i objectAtIndex:0] mins: mins maxs: maxs texture: &td];
|
|
|
|
[[map_i objectAtIndex: 0] addObject: b];
|
2001-02-09 01:52:44 +00:00
|
|
|
[b setSelected: YES];
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- shortBrush: sender
|
|
|
|
{
|
|
|
|
id b;
|
|
|
|
vec3_t mins, maxs;
|
|
|
|
texturedef_t td;
|
|
|
|
|
|
|
|
if ([self numSelected] != 1)
|
|
|
|
{
|
|
|
|
qprintf ("must have a single brush selected");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
b = [self selectedBrush];
|
|
|
|
td = *[b texturedef];
|
|
|
|
[b getMins: mins maxs: maxs];
|
|
|
|
[b remove];
|
|
|
|
|
|
|
|
mins[2] = 0;
|
|
|
|
maxs[2] = 16;
|
|
|
|
|
2001-02-09 06:50:40 +00:00
|
|
|
b = [[SetBrush alloc] initOwner: [map_i objectAtIndex:0] mins: mins maxs: maxs texture: &td];
|
|
|
|
[[map_i objectAtIndex: 0] addObject: b];
|
2001-02-09 01:52:44 +00:00
|
|
|
[b setSelected: YES];
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
subtractSelection
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
- subtractSelection: semder
|
|
|
|
{
|
|
|
|
int i, j, c, c2;
|
|
|
|
id o, o2;
|
|
|
|
id sellist, sourcelist;
|
|
|
|
|
|
|
|
qprintf ("performing brush subtraction...");
|
|
|
|
|
2001-02-09 06:50:40 +00:00
|
|
|
sourcelist = [[NSMutableArray alloc] init];
|
|
|
|
sellist = [[NSMutableArray alloc] init];
|
|
|
|
carve_in = [[NSMutableArray alloc] init];
|
|
|
|
carve_out = [[NSMutableArray alloc] init];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
c = [currentEntity count];
|
|
|
|
for (i=0 ; i<c ; i++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
o = [currentEntity objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
if ([o selected])
|
|
|
|
[sellist addObject: o];
|
|
|
|
else
|
|
|
|
[sourcelist addObject: o];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
c = [sellist count];
|
|
|
|
for (i=0 ; i<c ; i++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
o = [sellist objectAtIndex: i];
|
2001-02-09 01:52:44 +00:00
|
|
|
[o setCarveVars];
|
|
|
|
|
|
|
|
c2 = [sourcelist count];
|
|
|
|
for (j=0 ; j<c2 ; j++)
|
|
|
|
{
|
2001-02-09 06:50:40 +00:00
|
|
|
o2 = [sourcelist objectAtIndex: j];
|
2001-02-09 01:52:44 +00:00
|
|
|
[o2 carve];
|
2001-05-07 09:43:25 +00:00
|
|
|
[carve_in removeAllObjects];
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[sourcelist free]; // the individual have been moved/freed
|
|
|
|
sourcelist = carve_out;
|
2001-02-09 06:50:40 +00:00
|
|
|
carve_out = [[NSMutableArray alloc] init];
|
2001-02-09 01:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add the selection back to the remnants
|
2001-02-09 06:50:40 +00:00
|
|
|
[currentEntity removeAllObjects];
|
2001-05-07 09:43:25 +00:00
|
|
|
[currentEntity addObjectsFromArray: sourcelist];
|
|
|
|
[currentEntity addObjectsFromArray: sellist];
|
2001-02-09 01:52:44 +00:00
|
|
|
|
|
|
|
[sourcelist free];
|
|
|
|
[sellist free];
|
|
|
|
[carve_in free];
|
|
|
|
[carve_out free];
|
|
|
|
|
|
|
|
if (![currentEntity count])
|
|
|
|
{
|
|
|
|
o = currentEntity;
|
|
|
|
[self removeObject: o];
|
|
|
|
[o free];
|
|
|
|
}
|
|
|
|
|
|
|
|
qprintf ("subtracted selection");
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|