Don't save empty sections when saving scenes.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2586 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2003-05-16 17:26:07 +00:00
parent 4d19964e46
commit 7071f2e0da
2 changed files with 23 additions and 2 deletions
@@ -1,5 +1,5 @@
//
// $Id: SparseMisoSceneModel.java,v 1.6 2003/04/25 22:26:25 mdb Exp $
// $Id: SparseMisoSceneModel.java,v 1.7 2003/05/16 17:26:07 ray Exp $
package com.threerings.miso.data;
@@ -172,6 +172,24 @@ public class SparseMisoSceneModel extends MisoSceneModel
}
}
/**
* Returns true if this section contains no data beyond the default.
* Used when saving a sparse scene: we omit blank sections.
*/
public boolean isBlank ()
{
if ((objectTileIds.length != 0) || (objectInfo.length != 0)) {
return false;
}
for (int ii=0, nn=baseTileIds.length; ii < nn; ii++) {
if (baseTileIds[ii] != 0) {
return false;
}
}
return true;
}
public Object clone () {
try {
Section section = (Section)super.clone();
@@ -1,5 +1,5 @@
//
// $Id: SparseMisoSceneWriter.java,v 1.2 2003/04/21 17:08:57 mdb Exp $
// $Id: SparseMisoSceneWriter.java,v 1.3 2003/05/16 17:26:07 ray Exp $
package com.threerings.miso.tools.xml;
@@ -50,6 +50,9 @@ public class SparseMisoSceneWriter implements NestableWriter
writer.startElement("sections");
for (Iterator iter = model.getSections(); iter.hasNext(); ) {
Section sect = (Section)iter.next();
if (sect.isBlank()) {
continue;
}
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "x", "", "", String.valueOf(sect.x));
attrs.addAttribute("", "y", "", "", String.valueOf(sect.y));