[etoys-dev] Etoys: Etoys-kfr.13.mcz

commits at source.squeak.org commits at source.squeak.org
Sat May 29 19:49:05 EDT 2010


Karl Ramberg uploaded a new version of Etoys to project Etoys:
http://source.squeak.org/etoys/Etoys-kfr.13.mcz

==================== Summary ====================

Name: Etoys-kfr.13
Author: kfr
Time: 30 May 2010, 1:48:28 am
UUID: e32a4b21-03d7-7241-b2d1-95997cbec281
Ancestors: Etoys-kfr.12

Fix the overlap logic in Morph>>overlapsShadowForm:bounds:

Fix for not including self in testing for overlaps i Player>>overlapsAny:

Refactor Player>>overlaps: to use Morph>>overlapsShadowForm:bounds:

=============== Diff against Etoys-kfr.12 ===============

Item was changed:
  ----- Method: Player>>overlapsAny: (in category 'scripts-standard') -----
  overlapsAny: aPlayer 
  	"Answer true if my costume overlaps that of aPlayer, or any of its  
  	siblings (if aPlayer is a scripted player)  
  	or if my costume overlaps any morphs of the same class (if aPlayer is  
  	unscripted)."
  	| possibleCostumes itsCostume itsCostumeClass myShadow |
  	(self ~= aPlayer
  			and: [self overlaps: aPlayer])
+ 		ifTrue: [^true].
- 		ifTrue: [^ true].
  	possibleCostumes := IdentitySet new.
  	aPlayer belongsToUniClass
  		ifTrue: [aPlayer class
+ 				allSubInstancesDo: [:anInstance | (anInstance ~~ self
- 				allSubInstancesDo: [:anInstance | (anInstance ~~ aPlayer
  							and: [itsCostume := anInstance costume.
  								(itsCostume bounds intersects: costume bounds)
  									and: [itsCostume world == costume world]])
  						ifTrue: [possibleCostumes add: itsCostume]]]
  		ifFalse: [itsCostumeClass := aPlayer costume class.
  			self costume world presenter allExtantPlayers
+ 				do: [:ep | self ~= ep ifTrue:[ ep costume 
- 				do: [:ep | ep costume
  						ifNotNilDo: [:ea | (ea class == itsCostumeClass
  									and: [ea bounds intersects: costume bounds])
+ 								ifTrue: [possibleCostumes add: ea]]]]].
- 								ifTrue: [possibleCostumes add: ea]]]].
  	possibleCostumes isEmpty
  		ifTrue: [^ false].
  	myShadow := costume shadowForm.
+ 	^possibleCostumes
+ 		anySatisfy: [:m | m overlapsShadowForm: myShadow bounds: costume fullBounds].
+ 	
+ !
- 	^ possibleCostumes
- 		anySatisfy: [:m | m overlapsShadowForm: myShadow bounds: costume fullBounds]!

Item was changed:
  ----- Method: Player>>overlaps: (in category 'misc') -----
  overlaps: aPlayer 
  	"Answer whether my costume overlaps that of another player"
  
+ 	| goalCostume intersection |
- 	| goalCostume intersection myShadow goalShadow bb myRect goalRect |
  	aPlayer ifNil: [^false].
  	goalCostume := aPlayer costume.
  	costume world == goalCostume world ifFalse: [^false].
  
  	"check if the 2 player costumes intersect"
  	intersection := costume bounds intersect: goalCostume bounds.
  	(intersection width = 0 or: [intersection height = 0]) 
  		ifTrue: [^false]
  		ifFalse: 
+ 			[ ^self costume overlapsShadowForm: goalCostume imageForm stencil bounds: goalCostume fullBounds ]!
- 			["check if the overlapping region is non-transparent"
- 
- 			"compute 1-bit, black and white versions (stencils) of the intersecting  
- 			part of each morph's costume"
- 
- 			myRect := intersection translateBy: 0 @ 0 - costume topLeft.
- 			myShadow := (costume imageForm contentsOfArea: myRect) stencil.
- 			goalRect := intersection translateBy: 0 @ 0 - goalCostume topLeft.
- 			goalShadow := (goalCostume imageForm contentsOfArea: goalRect) stencil.
- 
- 			"compute a pixel-by-pixel AND of the two stencils.  Result will be black 
- 			(pixel value = 1) where black parts of the stencils overlap"
- 			bb := BitBlt toForm: myShadow.
- 			bb 
- 				copyForm: goalShadow
- 				to: 0 @ 0
- 				rule: Form and.
- 
- 			"return TRUE if resulting form contains any black pixels"
- 			^(bb destForm tallyPixelValues second) > 0]!



More information about the etoys-dev mailing list