Add type information, don't return self most of the time

Start "modernizing" the code base; old code is based heavily in the
Smalltalk style, where everything that doesn't return a different object
returns self. This can be useful, but it isn't what is usually done these
days. Also, add type information (which didn't exist in "the old days" --
an object was an "id", not a "Foo *") to help with debugging.
This commit is contained in:
Jeff Teunissen 2010-09-28 15:43:35 -04:00
parent 7db4cefb2c
commit ec0c37ee82
13 changed files with 280 additions and 348 deletions

View file

@ -63,8 +63,8 @@ angle:(float)angle;
-homeView:sender;
-XYDrawSelf; // for drawing viewpoint in XY view
-ZDrawSelf; // for drawing viewpoint in XY view
- (void) XYDrawSelf; // for drawing viewpoint in XY view
- (void) ZDrawSelf; // for drawing viewpoint in XY view
-(BOOL) XYmouseDown:(NSPoint *)pt flags:(int)flags;// return YES if brush handled
-(BOOL) ZmouseDown:(NSPoint *)pt flags:(int)flags;// return YES if brush handled

View file

@ -492,7 +492,7 @@ drawWire
drawSelf
===================
*/
-drawRect:(NSRect)rect
- (void) drawRect:(NSRect)rect
{
float drawtime = 0;
@ -511,8 +511,6 @@ drawSelf
drawtime = Sys_DoubleTime () - drawtime;
printf ("CameraView drawtime: %5.3f\n", drawtime);
}
return self;
}
@ -521,7 +519,7 @@ drawSelf
XYDrawSelf
=============
*/
-XYDrawSelf
- (void) XYDrawSelf
{
NSBezierPath *path;
NSAffineTransform *trans;
@ -542,8 +540,6 @@ XYDrawSelf
[path transformUsingAffineTransform: trans];
[path stroke];
[path release];
return self;
}
/*
@ -551,7 +547,7 @@ XYDrawSelf
ZDrawSelf
=============
*/
-ZDrawSelf
- (void) ZDrawSelf
{
NSBezierPath *path;
NSAffineTransform *trans;
@ -565,8 +561,6 @@ ZDrawSelf
[path transformUsingAffineTransform: trans];
[path stroke];
[path release];
return self;
}

View file

@ -21,12 +21,12 @@ extern id clipper_i;
-(BOOL) XYDrag:(NSPoint *) pt;
-ZClick:(NSPoint) pt;
-carve;
-flipNormal;
- (void) flipNormal;
-(BOOL) getFace:(face_t *) pl;
-cameraDrawSelf;
-XYDrawSelf;
-ZDrawSelf;
- (void) cameraDrawSelf;
- (void) XYDrawSelf;
- (void) ZDrawSelf;
@end
#endif // Clipper_h

View file

@ -28,7 +28,7 @@ extern NSBezierPath *path;
return (oldnum > 0);
}
-flipNormal
- (void) flipNormal
{
vec3_t temp;
@ -44,8 +44,6 @@ extern NSBezierPath *path;
Sys_Printf ("no clipplane\n");
NSBeep ();
}
return self;
}
-(BOOL) getFace:(face_t *) f
@ -143,7 +141,7 @@ XYDrag
//=============================================================================
-carve
- (id) carve
{
[map_i makeSelectedPerform:@selector (carveByClipper)];
num = 0;
@ -151,7 +149,7 @@ XYDrag
}
-cameraDrawSelf
- (void) cameraDrawSelf
{
vec3_t mid;
int i;
@ -175,11 +173,9 @@ XYDrag
mid[1] -= 16;
CameraLineto (mid);
}
return self;
}
-XYDrawSelf
- (void) XYDrawSelf
{
int i;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
@ -202,10 +198,9 @@ XYDrag
endAngle: 360];
}
[path stroke];
return self;
}
-ZDrawSelf
- (void) ZDrawSelf
{
int i;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
@ -228,7 +223,6 @@ XYDrag
endAngle: 360];
}
[path stroke];
return self;
}
@end

View file

@ -20,26 +20,27 @@ typedef struct epair_s {
BOOL modifiable;
}
-initClass:(const char *) classname;
-initFromScript:(struct script_s *) script;
- (Entity *) initClass:(const char *) classname;
- (Entity *) initFromScript: (struct script_s *) script;
-(void) dealloc;
- (oneway void) dealloc;
-(BOOL) modifiable;
-setModifiable:(BOOL) m;
- (void) setModifiable:(BOOL) m;
-(const char *) targetname;
-writeToFILE:(FILE *)f region:(BOOL) reg;
- (void) writeToFILE:(FILE *)f region:(BOOL) reg;
-(const char *) valueForQKey:(const char *) k;
-getVector:(vec3_t)v forKey:(const char *) k;
- (void) getVector:(vec3_t)v forKey:(const char *) k;
-setKey:(const char *) k toValue:(const char *) v;
- (void) setKey:(const char *)k
toValue:(const char *)v;
-(int) numPairs;
-(epair_t *) epairs;
-removeKeyPair:(const char *) key;
- (void) removeKeyPair:(const char *) key;
@end
#endif // Entity_h

View file

@ -51,7 +51,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
return self;
}
-initClass:(const char *) classname
- (Entity *) initClass: (const char *)classname
{
id new;
esize_t esize;
@ -64,33 +64,32 @@ vec3_t bad_maxs = { 8, 8, 8 };
modifiable = YES;
[self setKey: "classname" toValue:classname];
[self setKey: "classname" toValue: classname];
// get class
new =[entity_classes_i classForName: [self valueForQKey:"classname"]];
// get class
new = [entity_classes_i classForName: [self valueForQKey:"classname"]];
if (!new)
esize = esize_model;
else
esize =[new esize];
esize = [new esize];
// create a brush if needed
// create a brush if needed
if (esize == esize_fixed) {
v =[new mins];
v = [new mins];
[[map_i selectedBrush] getMins: min maxs:max];
VectorSubtract (min, v, min);
VectorCopy (min, org); // convert to integer
[self setKey:"origin" toValue:va ("%i %i %i", org[0], org[1], org[2])];
[self createFixedBrush:min];
[self createFixedBrush: min];
} else
modifiable = YES;
return self;
}
-(void) dealloc
- (oneway void) dealloc
{
epair_t *e, *n;
@ -109,13 +108,13 @@ vec3_t bad_maxs = { 8, 8, 8 };
return modifiable;
}
-setModifiable:(BOOL) m
- (void) setModifiable: (BOOL)m
{
modifiable = m;
return self;
return;
}
-(void) removeObject:o
-(void) removeObject: (id)o
{
[super removeObject:o];
if ([self count])
@ -139,7 +138,8 @@ vec3_t bad_maxs = { 8, 8, 8 };
return "";
}
-getVector:(vec3_t) v forKey:(const char *) k
- (void) getVector: (vec3_t)v
forKey: (const char *)k
{
const char *c;
@ -148,8 +148,6 @@ vec3_t bad_maxs = { 8, 8, 8 };
v[0] = v[1] = v[2] = 0;
sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]);
return self;
}
-print
@ -162,21 +160,20 @@ vec3_t bad_maxs = { 8, 8, 8 };
return self;
}
-setKey:(const char *)
k toValue:(const char *) v
- (void) setKey:(const char *)k
toValue:(const char *) v
{
epair_t *e;
while (*k && *k <= ' ')
k++;
if (!*k)
return self; // don't set NULL values
return; // don't set NULL values
for (e = epairs; e; e = e->next) {
if (!strcmp (k, e->key)) {
free (e->value);
e->value = strdup (v);
return self;
}
}
@ -186,8 +183,6 @@ k toValue:(const char *) v
e->value = strdup (v);
e->next = epairs;
epairs = e;
return self;
}
-(int) numPairs
@ -206,17 +201,18 @@ k toValue:(const char *) v
return epairs;
}
-removeKeyPair:(char *) key
- (void) removeKeyPair:(char *) key
{
epair_t *e, *e2;
if (!epairs)
return self;
return;
e = epairs;
if (!strcmp (e->key, key)) {
epairs = e->next;
free (e);
return self;
return;
}
for (; e; e = e->next) {
@ -224,12 +220,12 @@ k toValue:(const char *) v
e2 = e->next;
e->next = e2->next;
free (e2);
return self;
return;
}
}
printf ("WARNING: removeKeyPair: %s not found\n", key);
return self;
return;
}
@ -279,7 +275,7 @@ FILE METHODS
int nument;
-initFromScript:(script_t *) script
- (Entity *) initFromScript:(script_t *) script
{
char *key;
id eclass, brush;
@ -364,8 +360,8 @@ int nument;
}
-writeToFILE:(FILE *)
f region:(BOOL) reg;
- (void) writeToFILE:(FILE *)f
region:(BOOL) reg;
{
epair_t *e;
int ang;
@ -384,7 +380,7 @@ f region:(BOOL) reg;
[self setKey: "angle" toValue: va ("%i", ang)];
} else if (self != [map_i objectAtIndex:0]
&& [[self objectAtIndex:0] regioned]) {
return self; // skip the entire entity definition
return; // skip the entire entity definition
}
}
@ -427,7 +423,7 @@ f region:(BOOL) reg;
free (oldang);
}
return self;
return;
}
/*

View file

@ -3,7 +3,7 @@
#include <AppKit/AppKit.h>
#define MINIWINICON "DoomEdIcon"
#define MINIWINICON "DoomEdIcon"
typedef enum {
i_project,
@ -14,66 +14,69 @@ typedef enum {
i_output,
i_help,
i_end
} insp_e;
} insp_e;
extern id inspcontrol_i;
@class InspectorControl;
@interface InspectorControl:NSObject
extern InspectorControl *inspcontrol_i;
@interface InspectorControl: NSObject
{
id inspectorView_i; // inspector view
id inspectorSubview_i; // inspector view's current subview
// (gets replaced)
IBOutlet NSView *inspectorView_i; // inspector view
IBOutlet NSView *inspectorSubview_i; // inspector view's current subview
// (gets replaced)
id contentList; // List of contentviews (corresponds to
// insp_e enum order)
id contentList; // List of contentviews (corresponds to
// insp_e enum order)
id windowList; // List of Windows (corresponds to
// insp_e enum order)
id windowList; // List of Windows (corresponds to
// insp_e enum order)
id obj_textures_i; // TexturePalette object (for
// delegating)
id obj_genkeypair_i; // GenKeyPair object
id obj_textures_i; // TexturePalette object (for
// delegating)
id obj_genkeypair_i; // GenKeyPair object
id popUpButton_i; // PopUpList title button
id popUpMatrix_i; // PopUpList matrix
id itemList; // List of popUp buttons
NSPopUpButton *popUpButton_i; // PopUpList title button
NSMatrix *popUpMatrix_i; // PopUpList matrix
NSMutableArray *itemList; // List of popUp buttons
id helpView;
IBOutlet NSTextView *helpView;
insp_e currentInspectorType; // keep track of current inspector
insp_e currentInspectorType; // keep track of current inspector
//
//
// Add id's here for new inspectors
// **NOTE: Make sure PopUpList has correct TAG value that
// corresponds to the enums above!
// Windows
id win_project_i; // project
id win_textures_i; // textures
id win_things_i; // things
id win_prefs_i; // preferences
id win_settings_i; // project settings
id win_output_i; // bsp output
id win_help_i; // documentation
IBOutlet NSWindow *win_project_i; // project
IBOutlet NSWindow *win_textures_i; // textures
IBOutlet NSWindow *win_things_i; // things
IBOutlet NSWindow *win_prefs_i; // preferences
IBOutlet NSWindow *win_settings_i; // project settings
IBOutlet NSWindow *win_output_i; // bsp output
IBOutlet NSWindow *win_help_i; // documentation
// PopUpList objs
id itemProject_i; // project
id itemTextures_i; // textures
id itemThings_i; // things
id itemPrefs_i; // preferences
id itemSettings_i; // project settings
id itemOutput_i; // bsp output
id itemHelp_i; // docs
IBOutlet id <NSMenuItem> itemProject_i; // project
IBOutlet id <NSMenuItem> itemTextures_i; // textures
IBOutlet id <NSMenuItem> itemThings_i; // things
IBOutlet id <NSMenuItem> itemPrefs_i; // preferences
IBOutlet id <NSMenuItem> itemSettings_i; // project settings
IBOutlet id <NSMenuItem> itemOutput_i; // bsp output
IBOutlet id <NSMenuItem> itemHelp_i; // docs
}
- (void) changeInspector:sender;
- (void) changeInspectorTo:(insp_e) which;
-(insp_e) getCurrentInspector;
- (IBAction) changeInspector: (id)sender;
- (void) setCurrentInspector: (insp_e)which;
- (insp_e) currentInspector;
@end
@protocol InspectorControl
-windowResized;
- (void) windowResized;
@end
#endif // InspectorControl_h

View file

@ -3,25 +3,25 @@
#include "InspectorControl.h"
// Add .h-files here for new inspectors
#include "Things.h"
#include "TexturePalette.h"
#include "Preferences.h"
#include "Things.h"
#include "TexturePalette.h"
#include "Preferences.h"
id inspcontrol_i;
InspectorControl *inspcontrol_i;
@interface CustomView:NSView
@interface CustomView: NSView
@end
@implementation CustomView
@end
@implementation InspectorControl
-(void)awakeFromNib
- (void) awakeFromNib
{
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *path = [mainBundle pathForResource:@"help" ofType:@"txt"
inDirectory:nil];
NSString *help = [NSString stringWithContentsOfFile: path];
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *path = [mainBundle pathForResource: @"help" ofType: @"txt"
inDirectory: nil];
NSString *help = [NSString stringWithContentsOfFile: path];
[helpView setString: help];
@ -29,107 +29,106 @@ id inspcontrol_i;
currentInspectorType = -1;
contentList =[[NSMutableArray alloc] init];
windowList =[[NSMutableArray alloc] init];
itemList =[[NSMutableArray alloc] init];
contentList = [[NSMutableArray alloc] init];
windowList = [[NSMutableArray alloc] init];
itemList = [[NSMutableArray alloc] init];
// ADD NEW INSPECTORS HERE...
[windowList addObject:win_project_i];
[contentList addObject:[win_project_i contentView]];
[itemProject_i setKeyEquivalent:@"1"];
[itemList addObject:itemProject_i];
[windowList addObject: win_project_i];
[contentList addObject: [win_project_i contentView]];
[itemProject_i setKeyEquivalent: @"1"];
[itemList addObject: itemProject_i];
[windowList addObject:win_textures_i];
[contentList addObject:[win_textures_i contentView]];
[itemTextures_i setKeyEquivalent:@"2"];
[itemList addObject:itemTextures_i];
[windowList addObject: win_textures_i];
[contentList addObject: [win_textures_i contentView]];
[itemTextures_i setKeyEquivalent: @"2"];
[itemList addObject: itemTextures_i];
[windowList addObject:win_things_i];
[contentList addObject:[win_things_i contentView]];
[itemThings_i setKeyEquivalent:@"3"];
[itemList addObject:itemThings_i];
[windowList addObject: win_things_i];
[contentList addObject: [win_things_i contentView]];
[itemThings_i setKeyEquivalent: @"3"];
[itemList addObject: itemThings_i];
[windowList addObject:win_prefs_i];
[contentList addObject:[win_prefs_i contentView]];
[itemPrefs_i setKeyEquivalent:@"4"];
[itemList addObject:itemPrefs_i];
[windowList addObject: win_prefs_i];
[contentList addObject: [win_prefs_i contentView]];
[itemPrefs_i setKeyEquivalent: @"4"];
[itemList addObject: itemPrefs_i];
[windowList addObject:win_settings_i];
[contentList addObject:[win_settings_i contentView]];
[itemSettings_i setKeyEquivalent:@"5"];
[itemList addObject:itemSettings_i];
[windowList addObject: win_settings_i];
[contentList addObject: [win_settings_i contentView]];
[itemSettings_i setKeyEquivalent: @"5"];
[itemList addObject: itemSettings_i];
[windowList addObject:win_output_i];
[contentList addObject:[win_output_i contentView]];
[itemOutput_i setKeyEquivalent:@"6"];
[itemList addObject:itemOutput_i];
[windowList addObject: win_output_i];
[contentList addObject: [win_output_i contentView]];
[itemOutput_i setKeyEquivalent: @"6"];
[itemList addObject: itemOutput_i];
[windowList addObject:win_help_i];
[contentList addObject:[win_help_i contentView]];
[itemHelp_i setKeyEquivalent:@"7"];
[itemList addObject:itemHelp_i];
[windowList addObject: win_help_i];
[contentList addObject: [win_help_i contentView]];
[itemHelp_i setKeyEquivalent: @"7"];
[itemList addObject: itemHelp_i];
// Setup inspector window with project subview first
[inspectorView_i setAutoresizesSubviews:YES];
[inspectorView_i setAutoresizesSubviews: YES];
inspectorSubview_i =[contentList objectAtIndex:i_project];
inspectorSubview_i = [contentList objectAtIndex: i_project];
[inspectorView_i addSubview:inspectorSubview_i];
[inspectorView_i addSubview: inspectorSubview_i];
currentInspectorType = -1;
[self changeInspectorTo:i_project];
[self setCurrentInspector: i_project];
}
//
// Sent by the PopUpList in the Inspector
// Each cell in the PopUpList must have the correct tag
//
- (void) changeInspector:sender
- (IBAction) changeInspector: sender
{
[self changeInspectorTo:[sender selectedTag]];
[self setCurrentInspector: [sender selectedTag]];
}
//
// Change to specific Inspector
//
- (void) changeInspectorTo:(insp_e) which
- (void) setCurrentInspector: (insp_e)which
{
id newView;
NSRect r;
NSRect f;
id newView;
NSRect r;
NSRect f;
if (which == currentInspectorType)
if (which == currentInspectorType) {
return;
}
currentInspectorType = which;
newView =[contentList objectAtIndex:which];
newView = [contentList objectAtIndex: which];
[popUpButton_i selectItemAtIndex:which];
[popUpButton_i selectItemAtIndex: which];
[inspectorView_i replaceSubview: inspectorSubview_i with:newView];
r =[inspectorView_i frame];
[inspectorView_i replaceSubview: inspectorSubview_i with: newView];
r = [inspectorView_i frame];
inspectorSubview_i = newView;
[inspectorSubview_i setAutoresizingMask:NSViewWidthSizable |
[inspectorSubview_i setAutoresizingMask: NSViewWidthSizable |
NSViewHeightSizable];
r.size.width -= 4;
r.size.height -= 4;
[inspectorSubview_i setFrameSize:r.size];
[inspectorSubview_i setFrameSize: r.size];
[inspectorSubview_i lockFocus];
f =[inspectorSubview_i bounds];
[[NSColor lightGrayColor] set];
f = [inspectorSubview_i bounds];
[[NSColor windowBackgroundColor] set];
NSRectFill (f);
[inspectorSubview_i unlockFocus];
[inspectorView_i display];
[inspectorView_i setNeedsDisplay: YES];
}
-(insp_e) getCurrentInspector
- (insp_e) currentInspector
{
return currentInspectorType;
}
@end

View file

@ -119,7 +119,7 @@ FILE METHODS
currentEntity = ent;
if (old != ent) {
[things_i newCurrentEntity]; // update inspector
[inspcontrol_i changeInspectorTo:i_things];
[inspcontrol_i setCurrentInspector: i_things];
}
return self;
@ -325,7 +325,7 @@ DRAWING
==============================================================================
*/
-ZDrawSelf
-(void)ZDrawSelf
{
int i, count;
@ -333,11 +333,9 @@ DRAWING
for (i = 0; i < count; i++)
[[self objectAtIndex:i] ZDrawSelf];
return self;
}
-RenderSelf:(void (*)(face_t *)) callback
-(void)RenderSelf:(void (*)(face_t *)) callback
{
int i, count;
@ -345,8 +343,6 @@ DRAWING
for (i = 0; i < count; i++)
[[self objectAtIndex: i] RenderSelf:callback];
return self;
}

View file

@ -79,7 +79,7 @@ DisplayCmdOutput (void)
free (buffer);
if ([preferences_i getShowBSP])
[inspcontrol_i changeInspectorTo:i_output];
[inspcontrol_i setCurrentInspector:i_output];
[preferences_i playBspSound];
@ -720,7 +720,7 @@ saveBSP
[project_i addToOutput:expandedcmd];
if ([preferences_i getShowBSP])
[inspcontrol_i changeInspectorTo:i_output];
[inspcontrol_i setCurrentInspector:i_output];
if (wt) {
id panel;

View file

@ -75,18 +75,18 @@ winding_t *NewWinding (int points);
-calcWindings;
-writeToFILE:(FILE *)f region:(BOOL)reg;
- (void) writeToFILE:(FILE *)f region:(BOOL)reg;
-(BOOL) selected;
-(BOOL) regioned;
-setSelected:(BOOL) s;
-setRegioned:(BOOL) s;
- (void) setSelected: (BOOL)s;
- (void) setRegioned: (BOOL)s;
-getMins:(vec3_t)mins maxs:(vec3_t)maxs;
- (void) getMins: (vec3_t)mins maxs: (vec3_t)maxs;
-(BOOL) containsPoint:(vec3_t) pt;
-freeWindings;
- (void) freeWindings;
-removeIfInvalid;
extern vec3_t region_min, region_max;
@ -95,16 +95,16 @@ extern vec3_t region_min, region_max;
-(texturedef_t *) texturedef;
-(texturedef_t *) texturedefForFace:(int) f;
-setTexturedef:(texturedef_t *) tex;
-setTexturedef:(texturedef_t *) tex forFace:(int) f;
- (void) setTexturedef:(texturedef_t *) tex;
- (void) setTexturedef:(texturedef_t *) tex forFace:(int) f;
-XYDrawSelf;
-ZDrawSelf;
-CameraDrawSelf;
-XYRenderSelf;
-CameraRenderSelf;
- (void) XYDrawSelf;
- (void) ZDrawSelf;
- (void) CameraDrawSelf;
- (void) XYRenderSelf;
- (void) CameraRenderSelf;
-hitByRay: (vec3_t) p1: (vec3_t) p2: (float *) time:(int *) face;
- (void) hitByRay: (vec3_t)p1: (vec3_t)p2: (float *)time: (int *)face;
//
// single brush actions
@ -112,61 +112,61 @@ extern vec3_t region_min, region_max;
extern int numcontrolpoints;
extern float *controlpoints[MAX_FACES * 3];
-getZdragface:(vec3_t) dragpoint;
-getXYdragface:(vec3_t) dragpoint;
-getXYShearPoints:(vec3_t) dragpoint;
- (void) getZdragface: (vec3_t)dragpoint;
- (void) getXYdragface: (vec3_t)dragpoint;
- (void) getXYShearPoints: (vec3_t)dragpoint;
-addFace:(face_t *) f;
//
// multiple brush actions
//
-carveByClipper;
- (void) carveByClipper;
extern vec3_t sb_translate;
-translate;
- (void) translate;
extern id carve_in, carve_out;
-select;
-deselect;
-remove;
-flushTextures;
- (void) select;
- (void) deselect;
- (void) remove;
- (void) flushTextures;
extern vec3_t sb_mins, sb_maxs;
-addToBBox;
- (void) addToBBox;
extern vec3_t sel_x, sel_y, sel_z;
extern vec3_t sel_org;
-transform;
- (void) transform;
-flipNormals;
- (void) flipNormals;
-carve;
-setCarveVars;
- (void) setCarveVars;
extern id sb_newowner;
-moveToEntity;
- (void) moveToEntity;
-takeCurrentTexture;
- (void) takeCurrentTexture;
extern vec3_t select_min, select_max;
-selectPartial;
-selectComplete;
-regionPartial;
-regionComplete;
- (void) selectPartial;
- (void) selectComplete;
- (void) regionPartial;
- (void) regionComplete;
extern float sb_floor_dir, sb_floor_dist;
-feetToFloor;
- (void) feetToFloor;
-(int) getNumBrushFaces;
-(face_t *) getBrushFace:(int) which;
- (int) getNumBrushFaces;
- (face_t *) getBrushFace: (int)which;
@end
#endif // SetBrush_h

View file

@ -486,9 +486,9 @@ can be removed.
initOwner:::
===========
*/
-initOwner: own mins:(float *)
mins maxs:(float *)
maxs texture:(texturedef_t *) tex
- (SetBrush *)initOwner: own mins:(float *)mins
maxs:(float *)maxs
texture:(texturedef_t *) tex
{
[super init];
@ -597,7 +597,7 @@ mins maxs:(float *) maxs
return self;
}
-freeWindings
-(void)freeWindings
{
int i;
@ -606,7 +606,6 @@ mins maxs:(float *) maxs
free (faces[i].w);
faces[i].w = NULL;
}
return self;
}
-(void) dealloc
@ -709,8 +708,8 @@ int numsb;
writeToFILE
===========
*/
-writeToFILE:(FILE *)
f region:(BOOL) reg
- (void) writeToFILE:(FILE *)f
region:(BOOL) reg
{
int i, j;
face_t *fa;
@ -718,7 +717,7 @@ f region:(BOOL) reg
if (reg && regioned)
return self;
return;
fprintf (f, "{\n");
for (i = 0; i < numfaces; i++) {
@ -733,7 +732,7 @@ f region:(BOOL) reg
}
fprintf (f, "}\n");
return self;
return;
}
@ -746,12 +745,11 @@ INTERACTION
==============================================================================
*/
-getMins:(vec3_t)
- (void)getMins:(vec3_t)
mins maxs:(vec3_t) maxs
{
VectorCopy (bmins, mins);
VectorCopy (bmaxs, maxs);
return self;
}
@ -760,10 +758,9 @@ mins maxs:(vec3_t) maxs
return selected;
}
-setSelected:(BOOL) s
- (void) setSelected:(BOOL) s
{
selected = s;
return self;
}
-(BOOL) regioned
@ -771,10 +768,9 @@ mins maxs:(vec3_t) maxs
return regioned;
}
-setRegioned:(BOOL) s
- (void)setRegioned:(BOOL) s
{
regioned = s;
return self;
}
@ -783,7 +779,7 @@ mins maxs:(vec3_t) maxs
setTexturedef
===========
*/
-setTexturedef:(texturedef_t *) tex
- (void) setTexturedef: (texturedef_t *)tex
{
int i;
@ -793,11 +789,9 @@ setTexturedef
}
[self calcWindings]; // in case texture coords changed
return self;
}
-setTexturedef:(texturedef_t *)
tex forFace:(int) f
- (void) setTexturedef: (texturedef_t *)tex forFace: (int)f
{
if (f > numfaces)
Sys_Error ("setTexturedef:forFace: bad face number %i", f);
@ -806,7 +800,6 @@ tex forFace:(int) f
faces[f].qtexture = NULL; // recache next render
[self calcWindings]; // in case texture coords changed
return self;
}
/*
@ -931,7 +924,7 @@ hitByRay
===========
*/
-hitByRay: (vec3_t) p1: (vec3_t) p2: (float *) time:(int *) face
- (void) hitByRay: (vec3_t) p1: (vec3_t) p2: (float *) time:(int *) face
{
vec3_t frontpoint, backpoint, dir;
int frontface, backface;
@ -939,7 +932,6 @@ hitByRay
if (regioned) {
*time = -1;
*face = -1;
return self;
}
[self clipRay: p1: p2: frontpoint: &frontface: backpoint:&backface];
@ -948,7 +940,6 @@ hitByRay
// brush, select first face
*time = 0;
*face = 0;
return self;
}
@ -956,7 +947,6 @@ hitByRay
// don't select it
*time = -1;
*face = -1;
return self;
}
VectorSubtract (p2, p1, dir);
@ -968,8 +958,6 @@ hitByRay
Sys_Error ("hitByRay: negative t");
*face = frontface;
return self;
}
@ -1072,7 +1060,7 @@ BOOL fakebrush;
XYDrawSelf
===========
*/
-XYDrawSelf
- (void) XYDrawSelf
{
int i, j;
winding_t *w;
@ -1083,7 +1071,7 @@ XYDrawSelf
BOOL keybrush;
if ([self fakeBrush:@selector (XYDrawSelf)])
return self;
return;
[xyview_i addToScrollRange: bmins[0]:bmins[1]];
[xyview_i addToScrollRange: bmaxs[0]:bmaxs[1]];
@ -1113,7 +1101,7 @@ XYDrawSelf
|| bmaxs[1] < xy_draw_rect.origin.y
|| bmins[0] > xy_draw_rect.origin.x + xy_draw_rect.size.width
|| bmins[1] > xy_draw_rect.origin.y + xy_draw_rect.size.height))
return self; // off view, don't bother
return; // off view, don't bother
for (i = 0; i < numfaces; i++) {
w = faces[i].w;
@ -1155,7 +1143,7 @@ XYDrawSelf
}
}
return self;
return;
}
/*
@ -1163,7 +1151,7 @@ XYDrawSelf
ZDrawSelf
===========
*/
-ZDrawSelf
- (void) ZDrawSelf
{
int i;
NSPoint p;
@ -1173,7 +1161,7 @@ ZDrawSelf
qtexture_t *q;
if ([self fakeBrush:@selector (ZDrawSelf)])
return self;
return;
[zview_i addToHeightRange:bmins[2]];
[zview_i addToHeightRange:bmaxs[2]];
@ -1188,7 +1176,7 @@ ZDrawSelf
p1[1] = p.y;
for (i = 0; i < 2; i++)
if (bmins[i] >= p1[i] || bmaxs[i] <= p1[i])
return self;
return;
p1[2] = 4096;
p2[0] = p1[0];
@ -1198,7 +1186,7 @@ ZDrawSelf
[self clipRay: p1: p2: frontpoint: &frontface: backpoint:&backface];
if (frontface == -1 || backface == -1)
return self;
return;
q = TEX_ForName (faces[frontface].texture.texture);
@ -1212,7 +1200,7 @@ ZDrawSelf
NSFrameRect (NSMakeRect (-12, backpoint[2],
25, frontpoint[2] - backpoint[2] + 1));
return self;
return;
}
/*
@ -1220,14 +1208,14 @@ ZDrawSelf
CameraDrawSelf
===========
*/
-CameraDrawSelf
- (void) CameraDrawSelf
{
int i, j;
winding_t *w;
id worldent, currentent;
if ([self fakeBrush:@selector (CameraDrawSelf)])
return self;
return;
worldent =[map_i objectAtIndex:0];
currentent =[map_i currentEntity];
@ -1249,7 +1237,7 @@ CameraDrawSelf
for (j = 0; j < w->numpoints; j++)
CameraLineto (w->points[j]);
}
return self;
return;
}
@ -1258,17 +1246,17 @@ CameraDrawSelf
XYRenderSelf
===========
*/
-XYRenderSelf
- (void) XYRenderSelf
{
int i;
if ([self fakeBrush:@selector (XYRenderSelf)])
return self;
return;
for (i = 0; i < numfaces; i++)
REN_DrawXYFace (&faces[i]);
return self;
return;
}
/*
@ -1276,7 +1264,7 @@ XYRenderSelf
CameraRenderSelf
===========
*/
-CameraRenderSelf
-(void)CameraRenderSelf
{
int i;
BOOL olddraw;
@ -1284,7 +1272,7 @@ CameraRenderSelf
pixel32_t p;
if ([self fakeBrush:@selector (CameraRenderSelf)])
return self;
return;
// hack to draw entity boxes as single flat color
if (![parent modifiable]) {
olddraw = r_drawflat;
@ -1306,7 +1294,7 @@ CameraRenderSelf
REN_DrawCameraFace (&faces[i]);
}
return self;
return;
}
/*
@ -1339,14 +1327,14 @@ float *controlpoints[MAX_FACES * 3];
return NO;
}
-getZdragface:(vec3_t) dragpoint
- (void) getZdragface:(vec3_t) dragpoint
{
int i, j;
float d;
if (![self checkModifiable])
return self;
return;
numcontrolpoints = 0;
@ -1368,11 +1356,9 @@ float *controlpoints[MAX_FACES * 3];
numcontrolpoints++;
}
}
return self;
}
-getXYdragface:(vec3_t) dragpoint
- (void) getXYdragface:(vec3_t) dragpoint
{
int i, j;
float d;
@ -1380,7 +1366,7 @@ float *controlpoints[MAX_FACES * 3];
numcontrolpoints = 0;
if (![self checkModifiable])
return self;
return;
for (i = 0; i < numfaces; i++) {
if (!faces[i].w)
@ -1397,11 +1383,9 @@ float *controlpoints[MAX_FACES * 3];
numcontrolpoints++;
}
}
return self;
}
-getXYShearPoints:(vec3_t) dragpoint
- (void) getXYShearPoints:(vec3_t) dragpoint
{
int i, j, k;
int facectl;
@ -1414,7 +1398,7 @@ float *controlpoints[MAX_FACES * 3];
if (![self checkModifiable])
return self;
return;
numcontrolpoints = 0;
numdragplanes = 0;
@ -1515,15 +1499,13 @@ float *controlpoints[MAX_FACES * 3];
if (k != 3) {
// Sys_Error ("getXYShearPoints: didn't get three points on plane");
numcontrolpoints = 0;
return self;
return;
}
for (j = 0; j < 3; j++)
for (k = 0; k < 3; k++)
f->planepts[j][k] = rint (f->planepts[j][k]);
}
return self;
}
/*
@ -1592,7 +1574,28 @@ Set the regioned flag based on if the object is containted in region_min/max
vec3_t select_min, select_max;
-selectPartial
- (void) selectPartial
{
int i;
for (i = 0; i < 3; i++)
if (select_min[i] >= bmaxs[i] || select_max[i] <= bmins[i])
return;
selected = YES;
}
-(void)selectComplete
{
int i;
for (i = 0; i < 3; i++)
if (select_min[i] > bmins[i] || select_max[i] < bmaxs[i])
return;
selected = YES;
}
-(void)regionPartial
{
int i;
@ -1600,47 +1603,22 @@ vec3_t select_min, select_max;
if (select_min[i] >= bmaxs[i] || select_max[i] <= bmins[i])
return self;
selected = YES;
return self;
}
-selectComplete
-(void)regionComplete
{
int i;
for (i = 0; i < 3; i++)
if (select_min[i] > bmins[i] || select_max[i] < bmaxs[i])
return self;
return;
selected = YES;
return self;
}
-regionPartial
{
int i;
for (i = 0; i < 3; i++)
if (select_min[i] >= bmaxs[i] || select_max[i] <= bmins[i])
return self;
selected = YES;
return self;
}
-regionComplete
{
int i;
for (i = 0; i < 3; i++)
if (select_min[i] > bmins[i] || select_max[i] < bmaxs[i])
return self;
selected = YES;
return self;
}
id sb_newowner;
-moveToEntity
- (void) moveToEntity
{
id eclass;
float *c;
@ -1656,12 +1634,11 @@ id sb_newowner;
}
[parent addObject:self];
return self;
}
vec3_t sb_translate;
-translate
- (void) translate
{
int i, j;
@ -1673,18 +1650,16 @@ vec3_t sb_translate;
}
[self calcWindings];
return self;
}
vec3_t sb_mins, sb_maxs;
-addToBBox
- (void) addToBBox
{
int k;
if (numfaces < 4)
return self;
return;
for (k = 0; k < 3; k++) {
if (bmins[k] < sb_mins[k])
@ -1692,11 +1667,9 @@ vec3_t sb_mins, sb_maxs;
if (bmaxs[k] > sb_maxs[k])
sb_maxs[k] = bmaxs[k];
}
return self;
}
-flushTextures
-(void)flushTextures
{ // call when texture palette changes
int i;
@ -1704,18 +1677,15 @@ vec3_t sb_mins, sb_maxs;
faces[i].qtexture = NULL;
[self calcWindings];
return self;
}
-select
-(void)select
{
[map_i setCurrentEntity:parent];
selected = YES;
return self;
}
-deselect
-(void)deselect
{
selected = NO;
@ -1724,11 +1694,9 @@ vec3_t sb_mins, sb_maxs;
printf ("WARNING: deselected invalid brush\n");
[map_i setCurrentMinZ:bmins[2]];
[map_i setCurrentMaxZ:bmaxs[2]];
return self;
}
-remove
-(void)remove
{
// the last selected brush determines
if (!invalid) {
@ -1737,16 +1705,14 @@ vec3_t sb_mins, sb_maxs;
}
[parent removeObject:self];
[self dealloc];
return nil;
[self release];
}
vec3_t sel_x, sel_y, sel_z;
vec3_t sel_org;
-transform
- (void) transform
{
int i, j;
vec3_t old;
@ -1764,11 +1730,9 @@ vec3_t sel_org;
}
[self calcWindings];
return self;
}
-flipNormals // used after an inside-out transform
-(void)flipNormals // used after an inside-out transform
// (flip x/y/z)
{
int i;
@ -1780,36 +1744,30 @@ vec3_t sel_org;
VectorCopy (temp, faces[i].planepts[2]);
}
[self calcWindings];
return self;
}
-carveByClipper
- (void) carveByClipper
{
face_t face;
if (![clipper_i getFace:&face])
return self;
return;
[self addFace:&face];
return self;
}
-takeCurrentTexture
- (void) takeCurrentTexture
{
texturedef_t td;
[texturepalette_i getTextureDef:&td];
[self setTexturedef:&td];
return self;
}
float sb_floor_dir, sb_floor_dist;
-feetToFloor
- (void) feetToFloor
{
float oldz;
vec3_t p1, p2;
@ -1826,7 +1784,7 @@ float sb_floor_dir, sb_floor_dist;
[self clipRay: p1: p2: frontpoint: &frontface: backpoint:&backface];
if (frontface == -1)
return self;
return;
dist = frontpoint[2] - oldz;
@ -1837,7 +1795,6 @@ float sb_floor_dir, sb_floor_dist;
if (dist < 0 && dist > sb_floor_dist)
sb_floor_dist = dist;
}
return self;
}
@ -1872,9 +1829,9 @@ id carve_in, carve_out;
return[self removeIfInvalid];
}
-clipByFace:(face_t *)
fa front:(id *)
f back:(id *) b
- (void) clipByFace:(face_t *) fa
front:(id *)f
back:(id *) b
{
id front, back;
face_t fb;
@ -1890,8 +1847,6 @@ f back:(id *) b
*b =[back addFace:fa];
*f =[front addFace:&fb];
return self;
}
-carve
@ -1929,14 +1884,12 @@ f back:(id *) b
setCarveVars
==================
*/
-setCarveVars
- (void) setCarveVars
{
VectorCopy (bmins, carvemin);
VectorCopy (bmaxs, carvemax);
numcarvefaces = numfaces;
carvefaces = faces;
return self;
}
-(int) getNumBrushFaces

View file

@ -429,7 +429,7 @@ drawSelf
===============================================================================
*/
-drawRect: (NSRect) rect
- (void) drawRect: (NSRect) rect
{
//NSRect visRect;
//Sys_Printf("ZView:drawRect\n");
@ -456,8 +456,6 @@ drawSelf
// possibly resize the view
[self newRealBounds];
return self;
}
/*
@ -465,7 +463,7 @@ drawSelf
XYDrawSelf
==============
*/
-XYDrawSelf
- (void) XYDrawSelf
{
NSBezierPath *path;
NSAffineTransform *trans;
@ -479,8 +477,6 @@ XYDrawSelf
[path transformUsingAffineTransform: trans];
[path stroke];
[path release];
return self;
}