// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Align child top to root plane // Not compiled or tested in-world // Setup: Set TOP_HEIGHT. Use a nonphysical child with meaningful bounding-box dimensions. Owner-touch applies/restores. // Stop / restore: Owner-touch again to restore the startup snapshot before removal or reset, unless setup describes a different cycle. Do not relink during a preview. // Notes: Use a spare modifiable build. Saved state lives only in script memory. Useful for aligning shelf undersides or ceiling details. It uses projected bounding-box height, not exact mesh geometry. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer preview; float TOP_HEIGHT=1.0; vector home; default { state_entry() { home=llGetLocalPos(); } touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(llGetLinkNumber()<2||llGetStatus(STATUS_PHYSICS))return; preview=!preview; if(preview) { vector size=llGetScale(); rotation r=llGetLocalRot(); vector x=<1.0,0.0,0.0>*r; vector y=<0.0,1.0,0.0>*r; vector z=<0.0,0.0,1.0>*r; float half=(llFabs(x.z)*size.x+llFabs(y.z)*size.y+llFabs(z.z)*size.z)*0.5; vector p=home; p.z=TOP_HEIGHT-half; llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL,p]); } else { llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL,home]); } } }