remove restrictions on mapmodel rotation

Until now, the angles of mapmodels (and ctf-flags) were rounded to the
nearest 15-degree-step during rendering. This patch moves the rounding
to the time of placement of the model. Now the angle can be changed freely
after the model has been placed.

This commit also changes the angle resolution to 0.25 degree.

When changing the angle (press "1" + scrollwheel), additionally pressing
editmeta (a.k.a. LCTRL) changes the increments of the wheel from 1 to 10.

During a savemap with format 9, the angle resolution is reduced again, to
keep compatibility. Therefore, this features is only for testing right now.
It won't be preserved during a save (at least, as long as format 9 is used)
This commit is contained in:
ac-stef
2014-10-22 12:08:42 +02:00
parent 3bbe1f9555
commit e2ac8efadd
6 changed files with 23 additions and 10 deletions
+1 -1
View File
@@ -224,7 +224,7 @@ delta_edit_1 = [ if $flrceil [ vdelta $arg1 ] [ vdelta (- 0 $arg1) ] ] // Change
delta_edit_2 = [ edittex $flrceil $arg1 ] // Change floor/ceiling textures...
delta_edit_3 = [ edittex (+ $flrceil 1) $arg1 ] // Change wall/upper-wall textures...
delta_edit_4 = [ equalize $flrceil ] // Equalize floor/ceiling...
delta_edit_5 = [ entproperty 0 $arg1 ] // Changes the first value on entities...
delta_edit_5 = [ entproperty 0 (* $arg1 (at "1 10" $editmetakeydown)) ] // Changes the first value on entities...
delta_edit_6 = [ entproperty $editaxis $arg1 ] // Move map entity...
delta_edit_7 = [ entproperty 1 $arg1 ] // Changes the second value on entities...
delta_edit_8 = [ entproperty 2 $arg1 ] // Changes the third value on entities...
+2 -2
View File
@@ -26,8 +26,8 @@ sqr rtex;
VAR(editing, 1, 0, 0);
VAR(unsavededits, 1, 0, 0);
bool editmetakeydown = false;
COMMANDF(editmeta, "d", (bool on) { editmetakeydown = on; } );
VAR(editmetakeydown, 1, 0, 0);
COMMANDF(editmeta, "d", (bool on) { editmetakeydown = on ? 1 : 0; } );
void toggleedit(bool force)
{
+3 -3
View File
@@ -67,7 +67,7 @@ void rendermapmodels()
{
mapmodelinfo &mmi = getmminfo(e.attr2);
if(!&mmi) continue;
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), (float)((e.attr1+7)-(e.attr1+7)%15), 0, 10.0f);
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);
}
}
}
@@ -218,7 +218,7 @@ void renderentities()
if(e.type==CTF_FLAG)
{
defformatstring(path)("pickups/flags/%s", team_basestring(e.attr2));
rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(e.x, e.y, (float)S(e.x, e.y)->floor), (float)((e.attr1+7)-(e.attr1+7)%15), 0, 120.0f);
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);
}
else if((e.type == CLIP || e.type == PLCLIP) && showclips && !stenciling) renderclip(e);
else if(e.type == MAPMODEL && showclips && showmodelclipping && !stenciling)
@@ -271,7 +271,7 @@ void renderentities()
if(OUTBORD(f.pos.x, f.pos.y)) break;
entity &e = *f.flagent;
defformatstring(path)("pickups/flags/%s%s", m_ktf ? "" : team_basestring(i), m_htf ? "_htf" : m_ktf ? "ktf" : "");
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), (float)((e.attr1+7)-(e.attr1+7)%15), 0, 120.0f);
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);
break;
}
case CTFF_IDLE:
+3 -3
View File
@@ -6,13 +6,13 @@ enum // static entity types
I_CLIPS, I_AMMO, I_GRENADE,
I_HEALTH, I_HELMET, I_ARMOUR, I_AKIMBO,
// helmet : 2010may16 -> mapversion:8
MAPMODEL, // attr1 = angle, attr2 = idx
MAPMODEL, // attr1 = angle, attr2 = idx, attr3 = elevation, attr4 = texture
CARROT, // attr1 = tag, attr2 = type
LADDER,
CTF_FLAG, // attr1 = angle, attr2 = red/blue
SOUND,
CLIP,
PLCLIP,
CLIP, // attr1 = elevation, attr2 = xradius, attr3 = yradius, attr4 = height
PLCLIP, // attr1 = elevation, attr2 = xradius, attr3 = yradius, attr4 = height
MAXENTTYPES
};
+1 -1
View File
@@ -286,11 +286,11 @@ entity *newentity(int index, int x, int y, int z, char *what, int v1, int v2, in
case MAPMODEL:
e.attr4 = e.attr3;
e.attr3 = e.attr2;
e.attr2 = (uchar)e.attr1;
case PLAYERSTART:
case CTF_FLAG:
e.attr2 = v1;
e.attr1 = (int)camera1->yaw;
if(type != PLAYERSTART) e.attr1 = (e.attr1 + 7 - (e.attr1 + 7) % 15) * 4;
break;
}
syncentchanges(true);
+13
View File
@@ -486,6 +486,7 @@ void save_world(char *mname, bool skipoptimise, bool addcomfort)
int writeextra = 0;
if(hx.maxlen) tmp.headersize += writeextra = clamp(hx.maxlen, 0, MAXHEADEREXTRA);
if(writeextra || skipoptimise) tmp.version = 10; // 9 and 10 are the same, but in 10 the headersize is reliable - if we don't need it, stick to 9
bool oldmapmodelscaling = tmp.version < 10;
tmp.maprevision += advancemaprevision;
DEBUG("version " << tmp.version << " headersize " << tmp.headersize << " entities " << tmp.numents << " factor " << tmp.sfactor << " revision " << tmp.maprevision);
lilswap(&tmp.version, 4);
@@ -501,6 +502,7 @@ void save_world(char *mname, bool skipoptimise, bool addcomfort)
{
if(!ne--) break;
persistent_entity tmp = ents[i];
if(oldmapmodelscaling && tmp.type == MAPMODEL) tmp.attr1 = tmp.attr1 / 4;
lilswap((short *)&tmp, 4);
f->write(&tmp, sizeof(persistent_entity));
}
@@ -638,6 +640,17 @@ bool load_world(char *mname) // still supports all map formats that have
if(e.attr1>32) e.attr1 = 32; // 12_03 and below
}
transformoldentities(hdr.version, e.type);
if(hdr.version < 10)
{
switch(e.type)
{
case CTF_FLAG:
case MAPMODEL:
e.attr1 = e.attr1 + 7 - (e.attr1 + 7) % 15; // round the angle to the nearest 15-degree-step
e.attr1 = (e.attr1 % 360) * 4; // cut down to less that one rotation and set resolution to 0.25 degree
break;
}
}
if(e.type == PLAYERSTART && (e.attr2 == 0 || e.attr2 == 1 || e.attr2 == 100))
{
if(e.attr2 == 100)