You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/zerodotthreedotone.tex
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -943,7 +943,8 @@ \subsection{Contacts and worlds}
943
943
\item each body satisfies its body invariant,
944
944
\item body ids are strictly increasing in storage order,
945
945
\item every body AABB lies within bounds,
946
-
\item every contact satisfies \code{a < b}.
946
+
\item every contact satisfies \code{a < b},
947
+
\item contacts are strictly increasing in lexicographic key order \code{(a,b)}.
947
948
\end{enumerate}
948
949
949
950
Adding a body requires ascending id order and panics otherwise. After adding or moving a body, clamping is exact: if body half-extents are $h_x,h_y$ and bounds are $[m_x,M_x]\times[m_y,M_y]$, then the center is clamped to
@@ -955,7 +956,7 @@ \subsection{Contacts and worlds}
955
956
956
957
\code{step()} increments the world tick by $1$ and refreshes contacts.
957
958
958
-
\code{has\_contact(a,b)} normalizes the id pair into sorted order and linearly scans the cached contact list.
959
+
\code{has\_contact(a,b)} normalizes the id pair into sorted order and performs membership query over the sorted cached contact vector by key \code{(a,b)}.
When the number of bodies is at most $12$, contact refresh computes AABBs for active bodies, enumerates every active pair, and appends a contact for each intersecting pair in increasing storage-pair order.
968
+
When the number of bodies is at most $12$, contact refresh computes AABBs for active bodies, enumerates every active pair, appends a contact for each intersecting pair in increasing storage-pair order, then sorts the resulting contact vector by key \code{(a,b)}.
968
969
969
970
When the number of bodies exceeds $12$, refresh performs sweep-and-prune on $x$ intervals:
970
971
\begin{enumerate}
@@ -979,7 +980,7 @@ \subsection{Trigger helpers}
979
980
980
981
\code{set\_trigger\_mask\_deferred(world,first\_trigger\_id,trigger\_count,active\_mask)} requires \code{trigger\_count <= 64}. For each index $i$ in $[0,\code{trigger\_count})$ it sets body \code{first\_trigger\_id+i} active iff bit $i$ of \code{active\_mask} is $1$.
981
982
982
-
\code{collect\_actor\_trigger\_contacts(world,actor\_id,first\_trigger\_id,trigger\_count,remaining\_mask)} also requires \code{trigger\_count <= 64}. For each trigger bit still present in \code{remaining\_mask}, if the world has contact between the actor and that trigger body, the helper clears the bit in \code{remaining\_mask} and increments the collected count. It does \emph{not} mutate body activity or refresh contacts during the scan. Caller-visible trigger activity is updated afterward in one batch. It returns the number of collected triggers as \code{u8}.
983
+
\code{collect\_actor\_trigger\_contacts(world,actor\_id,first\_trigger\_id,trigger\_count,remaining\_mask)} also requires \code{trigger\_count <= 64}. It reads the cached contacts, computes which trigger ids in the contiguous range \code{[first\_trigger\_id, first\_trigger\_id + trigger\_count)} are currently in contact with \code{actor\_id}, intersects that set with the bits still present in \code{remaining\_mask}, clears exactly those intersecting bits in \code{remaining\_mask}, and returns the number of cleared bits as \code{u8}. It does \emph{not} mutate body activity or refresh contacts during the scan. Caller-visible trigger activity is updated afterward in one batch.
0 commit comments