File: kcurve.c

package info (click to toggle)
d2x-rebirth 0.58.1-1.3
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, bullseye, sid
  • size: 6,540 kB
  • sloc: ansic: 111,473; asm: 1,228; ada: 364; objc: 243; python: 121; makefile: 26
file content (136 lines) | stat: -rw-r--r-- 3,175 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
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
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
*/

/*
 *
 * Functions for curve stuff.
 *
 */


#include <string.h>

#include "inferno.h"
#include "editor.h"
#include "editor/esegment.h"
#include "kdefs.h"

static fix         r1scale, r4scale;
static int         curve;

int InitCurve()
{
	curve = 0;
    return 1;
}

int GenerateCurve()
{
    if ( (Markedsegp != 0) && !IS_CHILD(Markedsegp->children[Markedside])) {
		r1scale = r4scale = F1_0*20;
      autosave_mine( mine_filename );
      diagnostic_message("Curve Generated.");
		Update_flags |= UF_WORLD_CHANGED;
      curve = generate_curve(r1scale, r4scale);
		mine_changed = 1;
        if (curve == 1) {
            strcpy(undo_status[Autosave_count], "Curve Generation UNDONE.\n");
        }
        if (curve == 0) diagnostic_message("Cannot generate curve -- check Current segment.");
    }
    else diagnostic_message("Cannot generate curve -- check Marked segment.");
	warn_if_concave_segments();

	return 1;
}

int DecreaseR4()
{
	if (curve) {
	   Update_flags |= UF_WORLD_CHANGED;
	   delete_curve();
	   r4scale -= F1_0;
	   generate_curve(r1scale, r4scale);
      diagnostic_message("R4 vector decreased.");
	   mine_changed = 1;
		warn_if_concave_segments();
	}
	return 1;
}

int IncreaseR4()
{
	if (curve) {
	   Update_flags |= UF_WORLD_CHANGED;
	   delete_curve();
	   r4scale += F1_0;
	   generate_curve(r1scale, r4scale);
      diagnostic_message("R4 vector increased.");
	   mine_changed = 1;
		warn_if_concave_segments();
	}
	return 1;
}

int DecreaseR1()
{
	if (curve) {
	   Update_flags |= UF_WORLD_CHANGED;
	   delete_curve();
	   r1scale -= F1_0;
	   generate_curve(r1scale, r4scale);
      diagnostic_message("R1 vector decreased.");
	   mine_changed = 1;
		warn_if_concave_segments();
	}
	return 1;
}

int IncreaseR1()
{
	if (curve) {
	   Update_flags |= UF_WORLD_CHANGED;
	   delete_curve();
	   r1scale += F1_0;
	   generate_curve(r1scale, r4scale);
      diagnostic_message("R1 vector increased.");
	   mine_changed = 1;
		warn_if_concave_segments();
	}
	return 1;
}

int DeleteCurve()
{
// fix_bogus_uvs_all();
set_average_light_on_curside();

	if (curve) {
	   Update_flags |= UF_WORLD_CHANGED;
	   delete_curve();
	   curve = 0;
	   mine_changed = 1;
      diagnostic_message("Curve Deleted.");
		warn_if_concave_segments();
	}
	return 1;
}

int SetCurve()
{
	if (curve) curve = 0;
   //autosave_mine( mine_filename );
   //strcpy(undo_status[Autosave_count], "Curve Generation UNDONE.\n");
   return 1;
}