"""Emit state-only LSTP event descriptors for both native lowering paths.""" from .compiler import _number def contact_table(contacts): """Rows: velocity indices, gap, stiffness, damping, depth, force option, subtract-first flag. Keep the force expression's floating operation order. Position follows velocity in each reviewed mechanical state pair. """ rows = [] for v1, v2, gap, stiffness, damping, depth, option, subtract_first in contacts: rows.append('{' + ','.join((str(v1), str(v2), _number(gap), _number(stiffness), _number(damping), _number(depth), str(option), str(subtract_first))) + '}') count = len(rows) header = f'''#define NCONTACTS {count} typedef struct {{ int velocity1, velocity2; double gap0, stiffness, damping, depth; int signed_force, subtract_first; }} NativeContact; extern const NativeContact model_contacts[{max(1, count)}];''' source = f'const NativeContact model_contacts[{max(1, count)}] = {{' + (','.join(rows) or '{0,0,0,0,0,0,0,0}') + '};' return source, header