forked from KolibriOS/kolibrios
fix in function 'glopRotate'
git-svn-id: svn://kolibrios.org@5415 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
f1da9761f0
commit
6426f75928
@ -187,7 +187,7 @@ proc glopPopMatrix uses eax ebx, context:dword, p:dword
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc glopRotate uses eax ebx ecx, context:dword, p:dword
|
proc glopRotate uses eax ebx ecx edx, context:dword, p:dword
|
||||||
locals
|
locals
|
||||||
u0 dd ?
|
u0 dd ?
|
||||||
u1 dd ?
|
u1 dd ?
|
||||||
@ -209,73 +209,86 @@ endl
|
|||||||
fst dword[angle] ;angle = p[1].f * M_PI / 180.0
|
fst dword[angle] ;angle = p[1].f * M_PI / 180.0
|
||||||
;st0 = angle
|
;st0 = angle
|
||||||
|
|
||||||
fldz
|
|
||||||
fild dword[ebx+8]
|
|
||||||
fstp dword[u0]
|
|
||||||
fild dword[ebx+12]
|
|
||||||
fstp dword[u1]
|
|
||||||
fild dword[ebx+16]
|
|
||||||
fst dword[u2]
|
|
||||||
|
|
||||||
; simple case detection
|
; simple case detection
|
||||||
xor ebx,ebx
|
xor edx,edx
|
||||||
fcomp st1 ;u2 ... 0
|
fld dword[ebx+16]
|
||||||
|
ftst
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
je @f
|
je @f
|
||||||
inc ebx
|
inc edx
|
||||||
@@:
|
@@:
|
||||||
fcom dword[u1] ;0 ... u1
|
fstp dword[u2]
|
||||||
|
fld dword[ebx+12]
|
||||||
|
ftst
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
je @f
|
je @f
|
||||||
or ebx,2
|
or edx,2
|
||||||
@@:
|
@@:
|
||||||
fcom dword[u0] ;0 ... u0
|
fstp dword[u1]
|
||||||
|
fld dword[ebx+8]
|
||||||
|
ftst
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
je @f
|
je @f
|
||||||
or ebx,4
|
or edx,4
|
||||||
@@:
|
@@:
|
||||||
;st0 = 0, st1 = angle
|
fstp dword[u0]
|
||||||
|
|
||||||
|
;st0 = angle
|
||||||
;ebx = ((u0 != 0)<<2) | ((u1 != 0)<<1) | (u2 != 0)
|
;ebx = ((u0 != 0)<<2) | ((u1 != 0)<<1) | (u2 != 0)
|
||||||
cmp ebx,0
|
or edx,edx
|
||||||
je .end_f ;если нет поворотов выход из функции
|
jz .end_f ;если нет поворотов выход из функции
|
||||||
cmp ebx,4
|
cmp edx,4
|
||||||
jne @f
|
jne @f
|
||||||
fcomp dword[u0] ;0 ... u0
|
fld dword[u0]
|
||||||
|
ftst
|
||||||
fstsw ax
|
fstsw ax
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
sahf
|
sahf
|
||||||
jae .u0ch
|
jae .u0ch
|
||||||
fchs
|
fchs ;if (u0 < 0) angle *= -1
|
||||||
fstp dword[angle] ;if (u0 < 0) angle *= -1
|
|
||||||
.u0ch:
|
.u0ch:
|
||||||
stdcall gl_M4_Rotate, ecx,[angle],0
|
push dword 0
|
||||||
|
fstp dword[esp-4]
|
||||||
|
sub esp,4
|
||||||
|
stdcall gl_M4_Rotate, ecx
|
||||||
jmp .end_sw
|
jmp .end_sw
|
||||||
@@:
|
@@:
|
||||||
cmp ebx,2
|
cmp edx,2
|
||||||
jne @f
|
jne @f
|
||||||
fcomp dword[u1] ;0 ... u1
|
fld dword[u1]
|
||||||
|
ftst
|
||||||
fstsw ax
|
fstsw ax
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
sahf
|
sahf
|
||||||
jae .u1ch
|
jae .u1ch
|
||||||
fchs
|
fchs ;if (u1 < 0) angle *= -1
|
||||||
fstp dword[angle] ;if (u1 < 0) angle *= -1
|
|
||||||
.u1ch:
|
.u1ch:
|
||||||
stdcall gl_M4_Rotate, ecx,[angle],1
|
push dword 1
|
||||||
|
fstp dword[esp-4]
|
||||||
|
sub esp,4
|
||||||
|
stdcall gl_M4_Rotate, ecx
|
||||||
jmp .end_sw
|
jmp .end_sw
|
||||||
@@:
|
@@:
|
||||||
cmp ebx,1
|
cmp edx,1
|
||||||
jne @f
|
jne @f
|
||||||
fcomp dword[u2] ;0 ... u2
|
fld dword[u2]
|
||||||
|
ftst
|
||||||
fstsw ax
|
fstsw ax
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
sahf
|
sahf
|
||||||
jae .u2ch
|
jae .u2ch
|
||||||
fchs
|
fchs ;if (u2 < 0) angle *= -1
|
||||||
fstp dword[angle] ;if (u2 < 0) angle *= -1
|
|
||||||
.u2ch:
|
.u2ch:
|
||||||
stdcall gl_M4_Rotate, ecx,[angle],2
|
push dword 2
|
||||||
|
fstp dword[esp-4]
|
||||||
|
sub esp,4
|
||||||
|
stdcall gl_M4_Rotate, ecx
|
||||||
jmp .end_sw
|
jmp .end_sw
|
||||||
@@: ;default:
|
@@: ;default:
|
||||||
if DEBUG ;glopRotete
|
if DEBUG ;glopRotete
|
||||||
@ -287,19 +300,20 @@ end if
|
|||||||
fmul st0,st0
|
fmul st0,st0
|
||||||
fld dword[u1]
|
fld dword[u1]
|
||||||
fmul st0,st0
|
fmul st0,st0
|
||||||
|
faddp
|
||||||
fld dword[u2]
|
fld dword[u2]
|
||||||
fmul st0,st0
|
fmul st0,st0
|
||||||
fadd st0,st1
|
faddp
|
||||||
fadd st0,st2
|
|
||||||
; fst dword[len] ;len = u0*u0+u1*u1+u2*u2
|
; fst dword[len] ;len = u0*u0+u1*u1+u2*u2
|
||||||
fcom st1
|
ftst
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
je .end_f ;if (len == 0.0f) return
|
je .f2 ;if (len == 0.0f) return
|
||||||
fsqrt
|
fsqrt
|
||||||
fld1
|
fld1
|
||||||
fdiv st0,st1
|
fxch
|
||||||
; fst dword[len] ;len = 1.0f / sqrt(len)
|
fdivp ;len = 1.0f / sqrt(len)
|
||||||
|
; fst dword[len]
|
||||||
fld dword[u0]
|
fld dword[u0]
|
||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fstp dword[u0] ;u0 *= len
|
fstp dword[u0] ;u0 *= len
|
||||||
@ -309,11 +323,11 @@ end if
|
|||||||
fld dword[u2]
|
fld dword[u2]
|
||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fstp dword[u2] ;u2 *= len
|
fstp dword[u2] ;u2 *= len
|
||||||
;st0 = len, st1=..., st2=..., st3 = 0, st4 = angle
|
;st0 = len, st1 = angle
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
|
||||||
; store cos and sin values
|
; store cos and sin values
|
||||||
finit
|
|
||||||
fld dword[angle]
|
|
||||||
fcos
|
fcos
|
||||||
fst dword[cost] ;cost=cos(angle)
|
fst dword[cost] ;cost=cos(angle)
|
||||||
fld dword[angle]
|
fld dword[angle]
|
||||||
@ -332,15 +346,91 @@ end if
|
|||||||
mov [ecx+3*16+12],ebx ;m[3][3]
|
mov [ecx+3*16+12],ebx ;m[3][3]
|
||||||
|
|
||||||
; do the math
|
; do the math
|
||||||
; m.m[0][0]=u[0]*u[0]+cost*(1-u[0]*u[0]);
|
fld dword[u0]
|
||||||
; m.m[1][0]=u[0]*u[1]*(1-cost)-u[2]*sint;
|
fmul st0,st0
|
||||||
; m.m[2][0]=u[2]*u[0]*(1-cost)+u[1]*sint;
|
fld1
|
||||||
; m.m[0][1]=u[0]*u[1]*(1-cost)+u[2]*sint;
|
fsub st0,st1
|
||||||
; m.m[1][1]=u[1]*u[1]+cost*(1-u[1]*u[1]);
|
fmul st0,st3 ;st0 = cost*(1-u0^2)
|
||||||
; m.m[2][1]=u[1]*u[2]*(1-cost)-u[0]*sint;
|
faddp
|
||||||
; m.m[0][2]=u[2]*u[0]*(1-cost)-u[1]*sint;
|
fstp dword[ecx] ;m[0][0] = u0*u0+cost*(1-u0*u0)
|
||||||
; m.m[1][2]=u[1]*u[2]*(1-cost)+u[0]*sint;
|
|
||||||
; m.m[2][2]=u[2]*u[2]+cost*(1-u[2]*u[2]);
|
fld1
|
||||||
|
fsub st0,st2 ;st0 = 1-cost
|
||||||
|
|
||||||
|
fld st0
|
||||||
|
fmul dword[u0]
|
||||||
|
fmul dword[u1]
|
||||||
|
fld dword[u2]
|
||||||
|
fmul st0,st3 ;st0 = u2*sint
|
||||||
|
fchs
|
||||||
|
faddp
|
||||||
|
fstp dword[ecx+16] ;m[1][0] = u0*u1*(1-cost)-u2*sint
|
||||||
|
|
||||||
|
fld st0
|
||||||
|
fmul dword[u0]
|
||||||
|
fmul dword[u2]
|
||||||
|
fld dword[u1]
|
||||||
|
fmul st0,st3 ;st0 = u1*sint
|
||||||
|
faddp
|
||||||
|
fstp dword[ecx+32] ;m.m[2][0]=u[2]*u[0]*(1-cost)+u[1]*sint
|
||||||
|
|
||||||
|
fld st0
|
||||||
|
fmul dword[u0]
|
||||||
|
fmul dword[u1]
|
||||||
|
fld dword[u2]
|
||||||
|
fmul st0,st3 ;st0 = u2*sint
|
||||||
|
faddp
|
||||||
|
fstp dword[ecx+4] ;m.m[0][1]=u[0]*u[1]*(1-cost)+u[2]*sint
|
||||||
|
|
||||||
|
fld dword[u1]
|
||||||
|
fmul st0,st0
|
||||||
|
fld1
|
||||||
|
fsub st0,st1
|
||||||
|
fmul st0,st4 ;st0 = cost*(1-u1^2)
|
||||||
|
faddp
|
||||||
|
fstp dword[ecx+20] ;m.m[1][1]=u[1]*u[1]+cost*(1-u[1]*u[1])
|
||||||
|
|
||||||
|
fld st0
|
||||||
|
fmul dword[u1]
|
||||||
|
fmul dword[u2]
|
||||||
|
fld dword[u0]
|
||||||
|
fmul st0,st3 ;st0 = u0*sint
|
||||||
|
fchs
|
||||||
|
faddp
|
||||||
|
fstp dword[ecx+36] ;m.m[2][1]=u[1]*u[2]*(1-cost)-u[0]*sint
|
||||||
|
|
||||||
|
fld st0
|
||||||
|
fmul dword[u0]
|
||||||
|
fmul dword[u2]
|
||||||
|
fld dword[u1]
|
||||||
|
fmul st0,st3 ;st0 = u1*sint
|
||||||
|
fchs
|
||||||
|
faddp
|
||||||
|
fstp dword[ecx+8] ;m.m[0][2]=u[2]*u[0]*(1-cost)-u[1]*sint
|
||||||
|
|
||||||
|
fld st0
|
||||||
|
fmul dword[u1]
|
||||||
|
fmul dword[u2]
|
||||||
|
fld dword[u0]
|
||||||
|
fmul st0,st3 ;st0 = u0*sint
|
||||||
|
faddp
|
||||||
|
fstp dword[ecx+24] ;m.m[1][2]=u[1]*u[2]*(1-cost)+u[0]*sint
|
||||||
|
|
||||||
|
ffree st0 ;1-cost
|
||||||
|
fincstp
|
||||||
|
|
||||||
|
fld dword[u2]
|
||||||
|
fmul st0,st0
|
||||||
|
fld1
|
||||||
|
fsub st0,st1
|
||||||
|
fmul st0,st3 ;st0 = cost*(1-u2^2)
|
||||||
|
faddp
|
||||||
|
fstp dword[ecx+40] ;m[2][2] = u2*u2+cost*(1-u2*u2)
|
||||||
|
|
||||||
|
ffree st0 ;sint
|
||||||
|
fincstp
|
||||||
|
ffree st0 ;cost
|
||||||
|
fincstp
|
||||||
.end_sw:
|
.end_sw:
|
||||||
|
|
||||||
mov eax,[context]
|
mov eax,[context]
|
||||||
@ -352,6 +442,12 @@ if DEBUG ;glopRotete
|
|||||||
stdcall gl_print_matrix,ecx,4
|
stdcall gl_print_matrix,ecx,4
|
||||||
end if
|
end if
|
||||||
gl_matrix_update eax,ebx
|
gl_matrix_update eax,ebx
|
||||||
|
jmp .end_f
|
||||||
|
.f2:
|
||||||
|
ffree st0 ;len
|
||||||
|
fincstp
|
||||||
|
ffree st0 ;angle
|
||||||
|
fincstp
|
||||||
.end_f:
|
.end_f:
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
@ -382,6 +478,12 @@ proc glopScale uses eax ebx ecx, context:dword, p:dword
|
|||||||
fstp dword[ebx+8];m[2] *= z
|
fstp dword[ebx+8];m[2] *= z
|
||||||
add ebx,16
|
add ebx,16
|
||||||
loop @b
|
loop @b
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
|
||||||
if DEBUG ;glopScale
|
if DEBUG ;glopScale
|
||||||
pushad
|
pushad
|
||||||
|
@ -530,18 +530,17 @@ locals
|
|||||||
endl
|
endl
|
||||||
mov eax,[u]
|
mov eax,[u]
|
||||||
inc eax
|
inc eax
|
||||||
mov dword [v],eax
|
cmp eax,2
|
||||||
cmp dword [v],2
|
|
||||||
jle @f
|
jle @f
|
||||||
mov dword [v],0
|
xor eax,eax
|
||||||
@@:
|
@@:
|
||||||
mov eax,[v]
|
mov [v],eax
|
||||||
inc eax
|
inc eax
|
||||||
mov dword [w],eax
|
cmp eax,2
|
||||||
cmp dword [w],2
|
|
||||||
jle @f
|
jle @f
|
||||||
mov dword [w],0
|
xor eax,eax
|
||||||
@@:
|
@@:
|
||||||
|
mov [w],eax
|
||||||
fld dword [t]
|
fld dword [t]
|
||||||
fsin
|
fsin
|
||||||
fstp dword [s]
|
fstp dword [s]
|
||||||
|
@ -18,7 +18,7 @@ include 'vox_3d.inc'
|
|||||||
include '../trunk/str.inc'
|
include '../trunk/str.inc'
|
||||||
|
|
||||||
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||||
caption db 'Voxel viewer 11.02.15',0 ;¯®¤¯¨áì ®ª
|
caption db 'Voxel viewer 17.02.15',0 ;¯®¤¯¨áì ®ª
|
||||||
|
|
||||||
struct FileInfoBlock
|
struct FileInfoBlock
|
||||||
Function dd ?
|
Function dd ?
|
||||||
@ -371,7 +371,7 @@ button:
|
|||||||
|
|
||||||
align 4
|
align 4
|
||||||
but_new_file:
|
but_new_file:
|
||||||
mov dword[angle_x], 30.0
|
mov dword[angle_x], -30.0
|
||||||
mov dword[angle_y], 180.0
|
mov dword[angle_y], 180.0
|
||||||
mov dword[angle_z], 180.0
|
mov dword[angle_z], 180.0
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user