B3DMatrix hack #3
Alan Grimes
alangrimes at starpower.net
Thu Oct 13 16:04:47 UTC 2005
I don't know about speed but the attached can change:
""""
xform multiplyAndDiscard: (B3DMatrix4x4 identity setScale: s).
""""
into:
"""""
xform scaleBy: s.
"""""
--
Friends don't let friends use GCC 3.4.4
GCC 3.3.6 produces code that's twice as fast on x86!
http://users.rcn.com/alangrimes/
-------------- next part --------------
'From Jasmine-rc1 of 7 October 2004 [latest update: #280] on 13 October 2005 at 11:02:24 am'!
!B3DMatrix4x4 methodsFor: 'transforming' stamp: 'atg 10/13/2005 10:34'!
scaleBy: aVector
self a11: self a11 * aVector x.
self a21: self a21 * aVector x.
self a31: self a31 * aVector x.
self a41: self a41 * aVector x.
" "
self a12: self a12 * aVector y.
self a22: self a22 * aVector y.
self a32: self a32 * aVector y.
self a42: self a42 * aVector y.
" "
self a13: self a13 * aVector z.
self a23: self a23 * aVector z.
self a33: self a33 * aVector z.
self a43: self a43 * aVector z! !
!B3DVertexTransformer methodsFor: 'modifying' stamp: 'atg 10/13/2005 10:46'!
scaleBy: aVector
self scaleBy: aVector.! !
!VRMLCroquetBuilder methodsFor: 'enumerating nodes' stamp: 'atg 10/13/2005 10:47'!
doTransform: node
| attr c r s sr t xform |
attr _ node attributeValueNamed: 'center'.
attr notNil ifTrue:[c _ self positionFrom: attr].
attr _ node attributeValueNamed: 'rotation'.
attr notNil ifTrue:[r _ self rotationFrom: attr].
attr _ node attributeValueNamed: 'scale'.
attr notNil ifTrue:[s _ self scaleFrom: attr].
attr _ node attributeValueNamed: 'scaleOrientation'.
attr notNil ifTrue:[sr _ self rotationFrom: attr].
attr _ node attributeValueNamed: 'translation'.
attr notNil ifTrue:[t _ self positionFrom: attr].
xform _ B3DMatrix4x4 identity.
xform translation: t+c.
xform multiplyAndDiscard: r asMatrix4x4.
xform multiplyAndDiscard: sr asMatrix4x4.
xform scaleBy: s.
xform multiplyAndDiscard: sr negated asMatrix4x4.
xform multiplyAndDiscard: (B3DMatrix4x4 identity translation: c negated).
attributes at: #transform put: xform.
super doTransform: node.
! !
!VRMLWonderlandBuilder methodsFor: 'enumerating nodes' stamp: 'atg 10/13/2005 10:37'!
doTransform: node
| attr c r s sr t xform oldActor |
attr _ node attributeValueNamed: 'center'.
attr notNil ifTrue:[c _ self positionFrom: attr].
attr _ node attributeValueNamed: 'rotation'.
attr notNil ifTrue:[r _ self rotationFrom: attr].
attr _ node attributeValueNamed: 'scale'.
attr notNil ifTrue:[s _ self scaleFrom: attr].
attr _ node attributeValueNamed: 'scaleOrientation'.
attr notNil ifTrue:[sr _ self rotationFrom: attr].
attr _ node attributeValueNamed: 'translation'.
attr notNil ifTrue:[t _ self positionFrom: attr].
xform _ B3DMatrix4x4 identity.
xform translation: t+c.
xform multiplyAndDiscard: r asMatrix4x4.
xform multiplyAndDiscard: sr asMatrix4x4.
xform scaleBy: s.
xform multiplyAndDiscard: sr negated asMatrix4x4.
xform multiplyAndDiscard: (B3DMatrix4x4 identity translation: c negated).
oldActor _ currentActor.
currentActor _ self createActorFor: nil.
currentActor setComposite: xform.
super doTransform: node.
currentActor _ oldActor.! !
B3DMatrix4x4 removeSelector: #scaling:!
More information about the Squeak-dev
mailing list
|