| 1 |
/* |
| 2 |
* Portions of this file are copyright Rebirth contributors and licensed as |
| 3 |
* described in COPYING.txt. |
| 4 |
* Portions of this file are copyright Parallax Software and licensed |
| 5 |
* according to the Parallax license below. |
| 6 |
* See COPYING.txt for license details. |
| 7 |
|
| 8 |
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
| 9 |
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
| 10 |
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
| 11 |
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
| 12 |
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
| 13 |
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
| 14 |
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
| 15 |
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
| 16 |
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
| 17 |
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* |
| 22 |
* Functions for curve stuff. |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
|
| 27 |
#include <string.h> |
| 28 |
|
| 29 |
#include "editor.h" |
| 30 |
#include "editor/esegment.h" |
| 31 |
#include "kdefs.h" |
| 32 |
|
| 33 |
static fix r1scale, r4scale; |
| 34 |
static int curve; |
| 35 |
|
| 36 |
int InitCurve() |
| 37 |
{ |
| 38 |
curve = 0; |
| 39 |
return 1; |
| 40 |
} |
| 41 |
|
| 42 |
int GenerateCurve() |
| 43 |
{ |
| 44 |
if (Markedsegp != segment_none && !IS_CHILD(Markedsegp->children[Markedside])) |
| 45 |
{ |
| 46 |
r1scale = r4scale = F1_0*20; |
| 47 |
autosave_mine( mine_filename ); |
| 48 |
diagnostic_message("Curve Generated."); |
| 49 |
Update_flags |= UF_WORLD_CHANGED; |
| 50 |
curve = generate_curve(r1scale, r4scale); |
| 51 |
mine_changed = 1; |
| 52 |
if (curve == 1) { |
| 53 |
undo_status[Autosave_count] = "Curve Generation UNDONE."; |
| 54 |
} |
| 55 |
if (curve == 0) diagnostic_message("Cannot generate curve -- check Current segment."); |
| 56 |
} |
| 57 |
else diagnostic_message("Cannot generate curve -- check Marked segment."); |
| 58 |
warn_if_concave_segments(); |
| 59 |
|
| 60 |
return 1; |
| 61 |
} |
| 62 |
|
| 63 |
int DecreaseR4() |
| 64 |
{ |
| 65 |
if (curve) { |
| 66 |
Update_flags |= UF_WORLD_CHANGED; |
| 67 |
delete_curve(); |
| 68 |
r4scale -= F1_0; |
| 69 |
generate_curve(r1scale, r4scale); |
| 70 |
diagnostic_message("R4 vector decreased."); |
| 71 |
mine_changed = 1; |
| 72 |
warn_if_concave_segments(); |
| 73 |
} |
| 74 |
return 1; |
| 75 |
} |
| 76 |
|
| 77 |
int IncreaseR4() |
| 78 |
{ |
| 79 |
if (curve) { |
| 80 |
Update_flags |= UF_WORLD_CHANGED; |
| 81 |
delete_curve(); |
| 82 |
r4scale += F1_0; |
| 83 |
generate_curve(r1scale, r4scale); |
| 84 |
diagnostic_message("R4 vector increased."); |
| 85 |
mine_changed = 1; |
| 86 |
warn_if_concave_segments(); |
| 87 |
} |
| 88 |
return 1; |
| 89 |
} |
| 90 |
|
| 91 |
int DecreaseR1() |
| 92 |
{ |
| 93 |
if (curve) { |
| 94 |
Update_flags |= UF_WORLD_CHANGED; |
| 95 |
delete_curve(); |
| 96 |
r1scale -= F1_0; |
| 97 |
generate_curve(r1scale, r4scale); |
| 98 |
diagnostic_message("R1 vector decreased."); |
| 99 |
mine_changed = 1; |
| 100 |
warn_if_concave_segments(); |
| 101 |
} |
| 102 |
return 1; |
| 103 |
} |
| 104 |
|
| 105 |
int IncreaseR1() |
| 106 |
{ |
| 107 |
if (curve) { |
| 108 |
Update_flags |= UF_WORLD_CHANGED; |
| 109 |
delete_curve(); |
| 110 |
r1scale += F1_0; |
| 111 |
generate_curve(r1scale, r4scale); |
| 112 |
diagnostic_message("R1 vector increased."); |
| 113 |
mine_changed = 1; |
| 114 |
warn_if_concave_segments(); |
| 115 |
} |
| 116 |
return 1; |
| 117 |
} |
| 118 |
|
| 119 |
int DeleteCurve() |
| 120 |
{ |
| 121 |
// fix_bogus_uvs_all(); |
| 122 |
set_average_light_on_curside(); |
| 123 |
|
| 124 |
if (curve) { |
| 125 |
Update_flags |= UF_WORLD_CHANGED; |
| 126 |
delete_curve(); |
| 127 |
curve = 0; |
| 128 |
mine_changed = 1; |
| 129 |
diagnostic_message("Curve Deleted."); |
| 130 |
warn_if_concave_segments(); |
| 131 |
} |
| 132 |
return 1; |
| 133 |
} |
| 134 |
|
| 135 |
int SetCurve() |
| 136 |
{ |
| 137 |
if (curve) curve = 0; |
| 138 |
//autosave_mine( mine_filename ); |
| 139 |
//strcpy(undo_status[Autosave_count], "Curve Generation UNDONE.\n"); |
| 140 |
return 1; |
| 141 |
} |
| 142 |
|