Skip to content

Commit ae82b6b

Browse files
committed
add attr5..7, add mapmodel pitch and roll
Keys 5, 6 and 7 (in combination with the scrollwheel) can be used to alter the new entity attributes. Pressing editmeta (LCTRL by default) speeds up the scrolling. (Parts of the roll code are borrowed from Alejandro V. Garcia's commit "Model rotations, experimental" from January 2013) Note: coop edit is now broken between "next" and older clients, but I don't want to bump the protocol just yet.
1 parent ab10f6b commit ae82b6b

18 files changed

+82
-56
lines changed

config/resetbinds.cfg

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,20 @@ editbind PERIOD [ equalize 2 ]
5555
bind SLASH key_commandline
5656
bind 0 []
5757
bind 1 primary
58-
editbind 1 [ domodifier 5 ]
58+
editbind 1 [ domodifier attr1 ]
5959
bind 2 secondary
60-
editbind 2 [ domodifier 7 ]
60+
editbind 2 [ domodifier attr2 ]
6161
bind 3 grenades
62-
editbind 3 [ domodifier 8 ]
62+
editbind 3 [ domodifier attr3 ]
6363
bind 4 melee
64-
editbind 4 [ domodifier 9 ]
64+
editbind 4 [ domodifier attr4 ]
6565
bind 5 []
66+
editbind 5 [ domodifier attr5 ]
6667
bind 6 []
68+
editbind 6 [ domodifier attr6 ]
6769
bind 7 []
68-
editbind 7 nextclosestent
70+
editbind 7 [ domodifier attr7 ]
71+
//editbind 7 nextclosestent
6972
bind 8 []
7073
editbind 8 [ vdelta -1 ]
7174
bind 9 []

config/scripts.cfg

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ const universaldelta [
229229
if $editing [ s = edit ] [
230230
if (player1 alive) [ s = game ] [ s = spect ]
231231
]
232-
(concatword delta _ (pop s) _ $modifier)
232+
(concatword delta _ (pop s) _ $modifier) (* $arg1 (at "1 3" $editmetakeydown)) (* $arg1 (at "1 10" $editmetakeydown))
233233
]
234234
// To utilize the below, you will need to bind "domodifier X"
235235
// (replace X with the number of the delta_edit) to a key. To
@@ -241,13 +241,16 @@ delta_edit_1 = [ if $flrceil [ vdelta $arg1 ] [ vdelta (- 0 $arg1) ] ] // Change
241241
delta_edit_2 = [ edittex $flrceil $arg1 ] // Change floor/ceiling textures...
242242
delta_edit_3 = [ edittex (+ $flrceil 1) $arg1 ] // Change wall/upper-wall textures...
243243
delta_edit_4 = [ equalize $flrceil ] // Equalize floor/ceiling...
244-
delta_edit_5 = [ entproperty 0 (* $arg1 (at "1 10" $editmetakeydown)) ] // Changes the first value on entities...
245244
delta_edit_6 = [ entproperty $editaxis $arg1 ] // Move map entity...
246-
delta_edit_7 = [ entproperty 1 $arg1 ] // Changes the second value on entities...
247-
delta_edit_8 = [ entproperty 2 $arg1 ] // Changes the third value on entities...
248-
delta_edit_9 = [ entproperty 3 $arg1 ] // Changes the fourth value on entities...
249245
delta_edit_10 = [ if (checkrange (+f $flyspeed (divf $arg1 4)) 1 5) [ flyspeed (+f $flyspeed (divf $arg1 4)); echo $flyspeed ] ] // Tweak flyspeed
250246
delta_edit_11 = [ if (> $arg1 0) [ expandselection 1 ] [ shrinkselection 1 ] ] // Expand/shrink the current selection
247+
delta_edit_attr1 = [ entproperty 0 $arg2 ] // Changes the first value on entities...
248+
delta_edit_attr2 = [ entproperty 1 $arg2 ] // Changes the second value on entities...
249+
delta_edit_attr3 = [ entproperty 2 $arg2 ] // Changes the third value on entities...
250+
delta_edit_attr4 = [ entproperty 3 $arg2 ] // Changes the fourth value on entities...
251+
delta_edit_attr5 = [ entproperty 4 $arg2 ] // Changes the fifth value on entities...
252+
delta_edit_attr6 = [ entproperty 5 $arg2 ] // Changes the sixth value on entities...
253+
delta_edit_attr7 = [ entproperty 6 $arg2 ] // Changes the seventh value on entities...
251254

252255
// HUD toggles
253256
const toggleshowmap [ showmap 1; onrelease [ showmap 0 ] ]

source/src/clients2c.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,9 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
965965
ents[i].attr2 = getint(p);
966966
ents[i].attr3 = getint(p);
967967
ents[i].attr4 = getint(p);
968+
ents[i].attr5 = getint(p);
969+
ents[i].attr6 = getint(p);
970+
ents[i].attr7 = getint(p);
968971
ents[i].spawned = false;
969972
if(ents[i].type==LIGHT || to==LIGHT) calclight();
970973
if(ents[i].type==SOUND) audiomgr.preloadmapsound(ents[i]);

source/src/editing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ char *editinfo()
105105
if(e >= 0)
106106
{
107107
entity &c = ents[e];
108-
formatstring(info)("closest entity = %s (%d, %d, %d, %d), ", entnames[c.type], c.attr1, c.attr2, c.attr3, c.attr4);
108+
formatstring(info)("closest entity = %s (%d, %d, %d, %d, %d, %d, %d), ", entnames[c.type], c.attr1, c.attr2, c.attr3, c.attr4, c.attr5, c.attr6, c.attr7);
109109
}
110110
if(selset()) concatformatstring(info, "selection = (%d, %d)", (sels.last()).xs, (sels.last()).ys);
111111
else concatformatstring(info, "no selection");

source/src/entities.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const char *entmdlnames[] =
2222
entmdlnames[e.type-I_CLIPS+(m_lss && e.type==I_GRENADE ? 5:0)]);
2323

2424
float z = (float)(1+sinf(lastmillis/100.0f+e.x+e.y)/20), yaw = lastmillis/10.0f;
25-
rendermodel(mdlname, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor+e.attr1), yaw, 0);
25+
rendermodel(mdlname, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor+e.attr1), 0, yaw, 0);
2626
}
2727

2828
void renderclip(entity &e)
@@ -67,7 +67,7 @@ void rendermapmodels()
6767
{
6868
mapmodelinfo &mmi = getmminfo(e.attr2);
6969
if(!&mmi) continue;
70-
rendermodel(mmi.name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, 0, vec(e.x, e.y, (float)S(e.x, e.y)->floor+mmi.zoff+e.attr3), e.attr1 / 4.0f, 0, 10.0f);
70+
rendermodel(mmi.name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, 0, vec(e.x, e.y, (float)S(e.x, e.y)->floor+mmi.zoff+e.attr3), e.attr6, e.attr1 / 4.0f, e.attr5 / 4.0f, 10.0f);
7171
}
7272
}
7373
}
@@ -218,7 +218,7 @@ void renderentities()
218218
if(e.type==CTF_FLAG)
219219
{
220220
defformatstring(path)("pickups/flags/%s", team_basestring(e.attr2));
221-
rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(e.x, e.y, (float)S(e.x, e.y)->floor), e.attr1 / 4.0f, 0, 120.0f);
221+
rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(e.x, e.y, (float)S(e.x, e.y)->floor), 0, e.attr1 / 4.0f, 0, 120.0f);
222222
}
223223
else if((e.type == CLIP || e.type == PLCLIP) && showclips && !stenciling) renderclip(e);
224224
else if(e.type == MAPMODEL && showclips && showmodelclipping && !stenciling)
@@ -261,7 +261,7 @@ void renderentities()
261261
{
262262
if(OUTBORD(f.actor->o.x, f.actor->o.y)) break;
263263
defformatstring(path)("pickups/flags/small_%s%s", m_ktf ? "" : team_basestring(i), m_htf ? "_htf" : m_ktf ? "ktf" : "");
264-
rendermodel(path, ANIM_FLAG|ANIM_START|ANIM_DYNALLOC, 0, 0, vec(f.actor->o).add(vec(0, 0, 0.3f+(sinf(lastmillis/100.0f)+1)/10)), lastmillis/2.5f, 0, 120.0f);
264+
rendermodel(path, ANIM_FLAG|ANIM_START|ANIM_DYNALLOC, 0, 0, vec(f.actor->o).add(vec(0, 0, 0.3f+(sinf(lastmillis/100.0f)+1)/10)), 0, lastmillis/2.5f, 0, 120.0f);
265265
}
266266
break;
267267
case CTFF_INBASE:
@@ -271,7 +271,7 @@ void renderentities()
271271
if(OUTBORD(f.pos.x, f.pos.y)) break;
272272
entity &e = *f.flagent;
273273
defformatstring(path)("pickups/flags/%s%s", m_ktf ? "" : team_basestring(i), m_htf ? "_htf" : m_ktf ? "ktf" : "");
274-
if(f.flagent->spawned) rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(f.pos.x, f.pos.y, f.state==CTFF_INBASE ? (float)S(int(f.pos.x), int(f.pos.y))->floor : f.pos.z), e.attr1 / 4.0f, 0, 120.0f);
274+
if(f.flagent->spawned) rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(f.pos.x, f.pos.y, f.state==CTFF_INBASE ? (float)S(int(f.pos.x), int(f.pos.y))->floor : f.pos.z), 0, e.attr1 / 4.0f, 0, 120.0f);
275275
break;
276276
}
277277
case CTFF_IDLE:
@@ -657,7 +657,7 @@ void syncentchanges(bool force)
657657
loopv(changedents) if(ents.inrange(changedents[i]))
658658
{
659659
entity &e = ents[changedents[i]];
660-
addmsg(SV_EDITENT, "ri9", changedents[i], e.type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4);
660+
addmsg(SV_EDITENT, "ri9i3", changedents[i], e.type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4, e.attr5, e.attr6, e.attr7);
661661
}
662662
changedents.setsize(0);
663663
lastentsync = lastmillis;

source/src/entity.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
enum // static entity types
22
{
33
NOTUSED = 0, // entity slot not in use in map (usually seen at deleted entities)
4-
LIGHT, // lightsource, attr1 = radius, attr2 = intensity
4+
LIGHT, // lightsource, attr1 = radius, attr2 = intensity (or attr2..4 = r-g-b)
55
PLAYERSTART, // attr1 = angle, attr2 = team
6-
I_CLIPS, I_AMMO, I_GRENADE,
6+
I_CLIPS, I_AMMO, I_GRENADE, // attr1 = elevation
77
I_HEALTH, I_HELMET, I_ARMOUR, I_AKIMBO,
8-
// (helmet since mapversion 8)
9-
MAPMODEL, // attr1 = angle, attr2 = idx, attr3 = elevation, attr4 = texture
8+
MAPMODEL, // attr1 = angle, attr2 = idx, attr3 = elevation, attr4 = texture, attr5 = pitch, attr6 = roll
109
CARROT, // attr1 = tag, attr2 = type
1110
LADDER, // attr1 = height
1211
CTF_FLAG, // attr1 = angle, attr2 = red/blue
@@ -27,7 +26,10 @@ struct persistent_entity // map entity
2726
short attr1;
2827
uchar type; // type is one of the above
2928
uchar attr2, attr3, attr4;
30-
persistent_entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : x(x), y(y), z(z), attr1(attr1), type(type), attr2(attr2), attr3(attr3), attr4(attr4) {}
29+
short attr5;
30+
char attr6;
31+
unsigned char attr7;
32+
persistent_entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : x(x), y(y), z(z), attr1(attr1), type(type), attr2(attr2), attr3(attr3), attr4(attr4), attr5(0), attr6(0), attr7(0) {}
3133
persistent_entity() {}
3234
};
3335

source/src/md2.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ struct md2 : vertmodel
177177
}
178178
};
179179

180-
void render(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, float pitch, dynent *d, modelattach *a, float scale)
180+
void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a, float scale)
181181
{
182182
if(!loaded) return;
183183

@@ -194,10 +194,12 @@ struct md2 : vertmodel
194194
shadowdir = vec(0, 1/SQRT2, -1/SQRT2);
195195
shadowdir.rotate_around_z((-shadowyaw-yaw-180.0f)*RAD);
196196
shadowdir.rotate_around_y(-pitch*RAD);
197+
shadowdir.rotate_around_x(-roll*RAD);
197198
(shadowpos = shadowdir).mul(shadowdist);
198199
}
199200

200201
modelpos = o;
202+
modelroll = roll;
201203
modelyaw = yaw;
202204
modelpitch = pitch;
203205

@@ -206,6 +208,7 @@ struct md2 : vertmodel
206208
matrixstack[0].translate(o);
207209
matrixstack[0].rotate_around_z((yaw+180)*RAD);
208210
matrixstack[0].rotate_around_y(-pitch*RAD);
211+
matrixstack[0].rotate_around_x(roll*RAD);
209212
if(anim&ANIM_MIRROR || scale!=1) matrixstack[0].scale(scale, anim&ANIM_MIRROR ? -scale : scale, scale);
210213
parts[0]->render(anim, varseed, speed, basetime, d);
211214

@@ -220,7 +223,7 @@ struct md2 : vertmodel
220223
if(!m) continue;
221224
m->parts[0]->index = parts.length()+i;
222225
m->setskin();
223-
m->render(anim, varseed, speed, basetime, o, yaw, pitch, d, NULL, scale);
226+
m->render(anim, varseed, speed, basetime, o, roll, yaw, pitch, d, NULL, scale);
224227
}
225228

226229
if(d) d->lastrendered = lastmillis;

source/src/md3.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct md3 : vertmodel
153153
}
154154
};
155155

156-
void render(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, float pitch, dynent *d, modelattach *a, float scale)
156+
void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a, float scale)
157157
{
158158
if(!loaded) return;
159159

@@ -177,10 +177,12 @@ struct md3 : vertmodel
177177
shadowdir = vec(0, 1/SQRT2, -1/SQRT2);
178178
shadowdir.rotate_around_z((-shadowyaw-yaw-180.0f)*RAD);
179179
shadowdir.rotate_around_y(-pitch*RAD);
180+
shadowdir.rotate_around_x(-roll*RAD);
180181
(shadowpos = shadowdir).mul(shadowdist);
181182
}
182183

183184
modelpos = o;
185+
modelroll = roll;
184186
modelyaw = yaw;
185187
modelpitch = pitch;
186188

@@ -189,6 +191,7 @@ struct md3 : vertmodel
189191
matrixstack[0].translate(o);
190192
matrixstack[0].rotate_around_z((yaw+180)*RAD);
191193
matrixstack[0].rotate_around_y(-pitch*RAD);
194+
matrixstack[0].rotate_around_x(roll*RAD);
192195
if(anim&ANIM_MIRROR || scale!=1) matrixstack[0].scale(scale, anim&ANIM_MIRROR ? -scale : scale, scale);
193196
parts[0]->render(anim, varseed, speed, basetime, d);
194197

source/src/menus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ void rendermenumdl()
12081208
a[0].name = "weapons/subgun/world";
12091209
a[0].tag = "tag_weapon";
12101210
}
1211-
rendermodel(isplayermodel ? "playermodels" : m.mdl, m.anim|ANIM_DYNALLOC, tex, -1, pos, yaw, 0, 0, 0, NULL, a, m.scale ? m.scale/25.0f : 1.0f);
1211+
rendermodel(isplayermodel ? "playermodels" : m.mdl, m.anim|ANIM_DYNALLOC, tex, -1, pos, 0, yaw, 0, 0, 0, NULL, a, m.scale ? m.scale/25.0f : 1.0f);
12121212

12131213
glPopMatrix();
12141214
}

source/src/model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct model
5656

5757
virtual void cleanup() = 0;
5858

59-
virtual void render(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, float pitch, dynent *d, modelattach *a = NULL, float scale = 1.0f) = 0;
59+
virtual void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a = NULL, float scale = 1.0f) = 0;
6060
virtual void setskin(int tex = 0) = 0;
6161

6262
virtual void genshadows(float height, float rad) {}

0 commit comments

Comments
 (0)