chiark / gitweb /
Introduce "inert" terminology for images for occultation
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 11 Apr 2022 09:03:27 +0000 (10:03 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 11 Apr 2022 09:08:15 +0000 (10:08 +0100)
This is much less confusing.  In particular, I'm trying to distinguish
the occulted piece from the piece (or trait object) which the occulted
piece provides (to the caller of `load`) for its occulted image.

No functional change other than wording in an error message.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
src/hidden.rs
src/occultilks.rs
src/pcaliases.rs
src/pcrender.rs
src/shapelib.rs
src/spec.rs

index 8e8a78b5cef33dcaa3b4fa3919843adf7abc4b50..fe167c478c158ca79e61659a63dbdfc202abd8b0 100644 (file)
@@ -236,7 +236,7 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static {
 }
 
 #[typetag::serde]
-pub trait OccultedPieceTrait: OutlineTrait {
+pub trait InertPieceTrait: OutlineTrait {
   fn svg(&self, f: &mut Html, id: VisiblePieceId) -> Result<(),IE>;
   fn describe_html(&self) -> Result<Html,IE>;
 }
@@ -261,7 +261,7 @@ pub struct PieceSpecLoaded {
   pub occultable: PieceSpecLoadedOccultable,
 }
 pub type PieceSpecLoadedOccultable =
-  Option<(OccultIlkName, Arc<dyn OccultedPieceTrait>)>;
+  Option<(OccultIlkName, Arc<dyn InertPieceTrait>)>;
 
 #[typetag::serde(tag="type")]
 pub trait PieceSpec: Debug + Sync + Send + 'static {
@@ -269,9 +269,10 @@ pub trait PieceSpec: Debug + Sync + Send + 'static {
   fn count(&self, _pcaliases: &PieceAliases) -> usize { 1 }
   fn load(&self, i: usize, gpc: &mut GPiece, ig: &Instance, depth: SpecDepth)
           -> Result<PieceSpecLoaded, SpecError>;
-  fn load_occult(&self, _ig: &Instance, _:SpecDepth)
-                 -> Result<Box<dyn OccultedPieceTrait>, SpecError> {
-    throw!(SpE::ComplexPieceWhereSimpleRequired)
+  /// Used when a piece wants to use another for its occulted form
+  fn load_inert(&self, _ig: &Instance, _:SpecDepth)
+                -> Result<Box<dyn InertPieceTrait>, SpecError> {
+    throw!(SpE::ComplexPieceWhereInertRequired)
   }
 }
 
index b3e22917de58606cb1b024d6fc7a1d7132930653..d86fef3c7cd13d9d4a8905bbd0e76cce5d7121df 100644 (file)
@@ -402,7 +402,7 @@ impl IPiece {
   #[throws(IE)]
   pub fn show_or_instead<'p>(&self, ioccults: &'p IOccults,
                          y: Option<ShowUnocculted>)
-          -> Either<ShowUnocculted, &'p dyn OccultedPieceTrait> {
+          -> Either<ShowUnocculted, /*occulted*/ &'p dyn InertPieceTrait> {
     match y {
       Some(y) => Left(y),
       None => Right({
index e871f972dedf2f4e012d04a734d0b69faeaeaa50..0c63c53ca00bacf6c996bcd0335763a935d40b35 100644 (file)
@@ -18,7 +18,7 @@ pub struct OccultIlkName(pub Arc<GoodItemName>);
 
 #[derive(Debug,Serialize,Deserialize)]
 pub struct OccultIlkData {
-  pub p_occ: Arc<dyn OccultedPieceTrait>,
+  pub p_occ: Arc<dyn InertPieceTrait>,
 }
 
 type Id = OccultIlkId;
index 3bf7c6324c2954a81cfc5dc8337c06a81576c141..25bf7b756d257c1da2f15175a32463b04fcd02dc 100644 (file)
@@ -71,9 +71,9 @@ impl PieceSpec for Alias {
     r
   }
   #[throws(SpecError)]
-  fn load_occult(&self, ig: &Instance, depth: SpecDepth)
-                 -> Box<dyn OccultedPieceTrait> {
-    self.resolve(&ig.pcaliases)?.load_occult(ig, self.new_depth(depth)?)?
+  fn load_inert(&self, ig: &Instance, depth: SpecDepth)
+                 -> Box<dyn InertPieceTrait> {
+    self.resolve(&ig.pcaliases)?.load_inert(ig, self.new_depth(depth)?)?
   }
 }
 
index 9d3910b954cb43a440597f85958c7eda66babb5e..3a65dc450c6b33f516fc5d528a2f30a85a13c3ef 100644 (file)
@@ -47,7 +47,7 @@ impl VisiblePieceAngle {
 impl<P,Z> PriOccultedGeneral<P,Z> {
   #[throws(IE)]
   pub fn instead<'p>(&self, ioccults: &'p IOccults, p: &'p IPiece)
-                 -> Either<ShowUnocculted, &'p dyn OccultedPieceTrait>
+                 -> Either<ShowUnocculted, /*occulted*/ &'p dyn InertPieceTrait>
   {
     p.show_or_instead(ioccults, self.fully_visible())?
   }
index c635733d548270e480c8a1f02f0f174511ddf2e5..eca18a237452a5380850665c359b063f77032c0f 100644 (file)
@@ -173,11 +173,11 @@ pub struct Item {
   descs: IndexVec<DescId, Html>,
   outline: Outline,
   #[serde(default)]
-  back: Option<Arc<dyn OccultedPieceTrait>>,
+  back: Option<Arc<dyn InertPieceTrait>>,
 }
 
 #[derive(Debug,Serialize,Deserialize)]
-struct ItemOccultable {
+struct ItemInertForOcculted {
   desc: Html,
   svgd: Arc<Html>,
   xform: FaceTransform,
@@ -218,13 +218,13 @@ impl<T> SvgBaseName<T> where T: Borrow<GoodItemName> {
 }
 
 #[dyn_upcast]
-impl OutlineTrait for ItemOccultable { delegate! { to self.outline {
+impl OutlineTrait for ItemInertForOcculted { delegate! { to self.outline {
   fn outline_path(&self, scale: f64) -> Result<Html, IE>;
   fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
   fn bbox_approx(&self) -> Result<Rect, IE>;
 }}}
 #[typetag::serde(name="Lib")]
-impl OccultedPieceTrait for ItemOccultable {
+impl InertPieceTrait for ItemInertForOcculted {
   #[throws(IE)]
   fn svg(&self, f: &mut Html, _: VisiblePieceId) {
     self.xform.write_svgd(f, &self.svgd)?;
@@ -382,7 +382,7 @@ impl PieceTrait for Item {
 }
 
 #[typetag::serde(name="LibItem")]
-impl OccultedPieceTrait for Item {
+impl InertPieceTrait for Item {
   #[throws(IE)]
   fn svg(&self, f: &mut Html, id: VisiblePieceId) {
     self.svg_face(f, default(), id)?;
@@ -546,12 +546,12 @@ impl Contents {
       .map_err(|e| SpE::InternalError(format!("reckoning transform: {}",&e)))?;
     let mut face = ItemFace { svg, desc, xform };
     let mut faces = index_vec![ face ];
-    let mut back = None::<Arc<dyn OccultedPieceTrait>>;
+    let mut back = None::<Arc<dyn InertPieceTrait>>;
     if idata.group.d.flip {
       face.xform.scale[0] *= -1.;
       faces.push(face);
     } else if let Some(back_spec) = &idata.group.d.back {
-      match back_spec.load_occult(ig, depth) {
+      match back_spec.load_inert(ig, depth) {
         Err(SpecError::AliasNotFound) => { },
         Err(e) => throw!(e),
         Ok(p) => {
@@ -581,12 +581,12 @@ impl Contents {
           )?;
           Ok(Arc::new(occ_data))
         }).clone()?;
-        let it = Arc::new(ItemOccultable {
+        let it = Arc::new(ItemInertForOcculted {
           svgd,
           xform: occ.xform.clone(),
           desc: occ.desc.clone(),
           outline: occ.outline.clone(),
-        }) as Arc<dyn OccultedPieceTrait>;
+        }) as Arc<dyn InertPieceTrait>;
         Some((OccultIlkName(occ_name.into_inner()), it))
       },
     };
@@ -641,9 +641,9 @@ impl PieceSpec for ItemSpec {
     self.find_load(ig,depth)?.into()
   }
   #[throws(SpecError)]
-  fn load_occult(&self, ig: &Instance, depth: SpecDepth)
-                 -> Box<dyn OccultedPieceTrait> {
-    self.find_load(ig,depth)?.0 as Box<dyn OccultedPieceTrait>
+  fn load_inert(&self, ig: &Instance, depth: SpecDepth)
+                 -> Box<dyn InertPieceTrait> {
+    self.find_load(ig,depth)?.0 as Box<dyn InertPieceTrait>
   }
 }
 
index 20f63fbf5fcf66771d037c5fa475c0103c4c55b2..162a72f6931f04514313b862946edcb18ac555c6 100644 (file)
@@ -78,7 +78,7 @@ pub enum SpecError {
   #[error("specified with of edges, but no edges")] SpecifiedWidthOfNoEdges,
   #[error("shape not supported")]            UnsupportedShape,
   #[error("negative timeout")]               NegativeTimeout,
-  #[error("complex piece where simple needed")] ComplexPieceWhereSimpleRequired,
+  #[error("complex piece where inert needed")] ComplexPieceWhereInertRequired,
   #[error("piece alias not found")]          AliasNotFound,
   #[error("piece alias target is multi spec")] AliasTargetMultiSpec,
   #[error("piece alias loop")]               AliasLoop(String),