Fix llRot2Fwd/llRot2Left/llRot2Up and add regression tests.

This commit is contained in:
Sei Lisa 2016-12-22 03:06:56 +01:00
parent a8231586c1
commit 91fd9734c8
2 changed files with 19 additions and 3 deletions

View file

@ -1568,21 +1568,21 @@ def llRot2Euler(r):
def llRot2Fwd(r):
assert isrotation(r)
v = (1., 0., 0.)
v = Vector((1., 0., 0.))
if r == (0., 0., 0., 0.):
return v
return llVecNorm(mul(v, r, f32=False))
def llRot2Left(r):
assert isrotation(r)
v = (0., 1., 0.)
v = Vector((0., 1., 0.))
if r == (0., 0., 0., 0.):
return v
return llVecNorm(mul(v, r, f32=False))
def llRot2Up(r):
assert isrotation(r)
v = (0., 0., 1.)
v = Vector((0., 0., 1.))
if r == (0., 0., 0., 0.):
return v
return llVecNorm(mul(v, r, f32=False))

View file

@ -924,6 +924,22 @@ def do_tests():
test('llFrand(F32(1.4e-45))', 0.0)
test('llFrand(F32(1.1754942106924411e-38))', 0.0)
test('llRot2Fwd(Quaternion((1.,0.,0.,0.)))', Vector((1.,0.,0.)))
test('llRot2Fwd(Quaternion((0.,1.,0.,0.)))', Vector((-1.,0.,0.)))
test('llRot2Fwd(Quaternion((0.,0.,1.,0.)))', Vector((-1.,0.,0.)))
test('llRot2Fwd(Quaternion((0.,0.,0.,1.)))', Vector((1.,0.,0.)))
test('llRot2Fwd(Quaternion((0.,0.,0.,0.)))', Vector((1.,0.,0.)))
test('llRot2Left(Quaternion((1.,0.,0.,0.)))', Vector((0.,-1.,0.)))
test('llRot2Left(Quaternion((0.,1.,0.,0.)))', Vector((0.,1.,0.)))
test('llRot2Left(Quaternion((0.,0.,1.,0.)))', Vector((0.,-1.,0.)))
test('llRot2Left(Quaternion((0.,0.,0.,1.)))', Vector((0.,1.,0.)))
test('llRot2Left(Quaternion((0.,0.,0.,0.)))', Vector((0.,1.,0.)))
test('llRot2Up(Quaternion((1.,0.,0.,0.)))', Vector((0.,0.,-1.)))
test('llRot2Up(Quaternion((0.,1.,0.,0.)))', Vector((0.,0.,-1.)))
test('llRot2Up(Quaternion((0.,0.,1.,0.)))', Vector((0.,0.,1.)))
test('llRot2Up(Quaternion((0.,0.,0.,1.)))', Vector((0.,0.,1.)))
test('llRot2Up(Quaternion((0.,0.,0.,0.)))', Vector((0.,0.,1.)))
lslcommon.IsCalc = True
test('cond(llGenerateKey())', True)
lslcommon.IsCalc = False