Suppose you have some state questions that give answers, such as "taller than six foot", "have brown hair", "weighs under 100kg", "is married"

these questions can be asked of a large population, and if you represent the answers on a bit field, you get a simple to scan list of ints for answers to questions.

e.g. b1101 is a brown haired heavy tall person that is married, and b0000 is a typical coder with non-brown hair ;)

if you want to find all the people with brown hair that weigh under 100kg, then you can just use a simple mask: b0110, and check for equality.

answer is the bitfield for the answers for one element / person

question is the question bit field

if( answer&question==question )

{

// is what I am looking for.

}

this is okay for sitations where you want all positive answers, but what about negative ones? how do you find the single people under six foot?

if( answer&question == 0 )

{

// is what I'm looking for.

}

this is okay, but what about combining the two? say you want to know how many people are unmarried brown-hairs?

if( answer&interest == question )

{

// is what I'm looking for.

}

what's interest? its the bit field of question bits I'm interested in. so, for the last question, unmarried-brown-haired : Interest b0101 Question b0100

this effectively gives you tri state checking on binary bit fields of information.

One more example:

Q:IsSkinned,IsAnimated,IsLit

put in "preCalcSkinningList" I110 Q110 // don't skin calc for unchanging meshes

put in "doLightingList" I101 Q001 // don't pre-light skinned meshes

put in "renderStaticList" I110 Q100 // render non-animated skins as statics

put in "renderStaticList" I100 Q000 // everything else is static

put in "renderSkinnedListUnlit" I111 Q110 // and skinned rendering too

put in "renderSkinnedListLLit" I111 Q111

## No comments:

Post a Comment