Skip to content
Snippets Groups Projects
Commit 5c4a44fc authored by Alexander Rose's avatar Alexander Rose
Browse files

fixed intra link referencePosition

parent a162f6e4
No related branches found
No related tags found
No related merge requests found
......@@ -40,12 +40,18 @@ function createIntraUnitLinkCylinderMesh(ctx: VisualContext, unit: Unit, structu
linkCount: edgeCount * 2,
referencePosition: (edgeIndex: number) => {
let aI = a[edgeIndex], bI = b[edgeIndex];
if (aI > bI) [aI, bI] = [bI, aI]
if (offset[aI + 1] - offset[aI] === 1) [aI, bI] = [bI, aI]
// TODO prefer reference atoms in rings
for (let i = offset[aI], il = offset[aI + 1]; i < il; ++i) {
if (b[i] !== bI) return pos(elements[b[i]], vRef)
const _bI = b[i]
if (_bI !== bI && _bI !== aI) return pos(elements[_bI], vRef)
}
for (let i = offset[bI], il = offset[bI + 1]; i < il; ++i) {
if (a[i] !== aI) return pos(elements[a[i]], vRef)
const _aI = a[i]
if (_aI !== aI && _aI !== bI) return pos(elements[_aI], vRef)
}
return null
},
......
......@@ -29,7 +29,6 @@ const tmpShiftV13 = Vec3.zero()
/** Calculate 'shift' direction that is perpendiculat to v1 - v2 and goes through v3 */
export function calculateShiftDir (out: Vec3, v1: Vec3, v2: Vec3, v3: Vec3 | null) {
Vec3.normalize(tmpShiftV12, Vec3.sub(tmpShiftV12, v1, v2))
if (v3 !== null) {
Vec3.sub(tmpShiftV13, v1, v3)
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment