Search found 27 matches

by Starterz
Mon Mar 28, 2011 12:31 am
Forum: Code Snippets
Topic: My randomizer faster than yours :)
Replies: 14
Views: 5803

Hm.. interesting mutation hint
(rSeed>>16)&0x7FFF
can You explain this?
About licensing :) I do understand it as a REDDemon's joke, don't You..
And ofcourse LCG haven't be more quality rng than xorshift (see wiki).
May be faster. May be.. But too simple for some applications, you know it.
Well as ...
by Starterz
Thu Mar 24, 2011 1:26 pm
Forum: Code Snippets
Topic: My randomizer faster than yours :)
Replies: 14
Views: 5803

REDDemon wrote:
Are you going to release it under zlib license ?
Sure ;)
by Starterz
Thu Mar 24, 2011 5:15 am
Forum: Code Snippets
Topic: My randomizer faster than yours :)
Replies: 14
Views: 5803

:\

O'k people thanks for preaching. Just show your faster code.
by Starterz
Thu Mar 24, 2011 1:08 am
Forum: Code Snippets
Topic: My randomizer faster than yours :)
Replies: 14
Views: 5803

Well

randomMesh wrote:
Make it const-correct and it would be even faster!
Nothing. But if I wrong. Show us Your wonderful fast code. I take my words back then and sorry.
by Starterz
Wed Mar 23, 2011 9:13 pm
Forum: Code Snippets
Topic: My randomizer faster than yours :)
Replies: 14
Views: 5803

My randomizer faster than yours :)

Hi, friends!
The subject is:

//!========XORSHIFT RANDOMIZER========
//! A class using George Marsaglia's "Xorshift-128" algorithm.
//! Provides very fast and quality sequence
//! of 2^{128}-1 32-bit random numbers.
class htRandomizer
{
unsigned long seed,x,y,z,w;
public:
htRandomizer ...
by Starterz
Tue Mar 22, 2011 2:33 pm
Forum: Code Snippets
Topic: Usefull tiny snippet
Replies: 5
Views: 2139

Special drops

We can use this:

#define SAFE_DELETE(x) {if(x) delete(x),x=NULL;}
#define IRR_SAFE_REMOVE(x) {if(x) while(!x->remove());x=NULL;}
#define IRR_SAFE_DROP(x) {if(x->drop()) x=NULL;}

/// Special drops:
/// As we can see drop() method just delete an object when ref. counter is 0.
/// But this method DO ...
by Starterz
Sun Nov 21, 2010 12:06 am
Forum: Code Snippets
Topic: Simulation of videosignal lost.
Replies: 10
Views: 3515

@Starterz: You forgot to call srand function.
I don't know what to say to you... Do you really think it should be called here?

What about screenshots. This code simulates electronic noise on the screen,
when videosignal is lost. You can try call my function into any Irr standart example (Hallo ...
by Starterz
Sat Nov 20, 2010 1:22 am
Forum: Code Snippets
Topic: Simulation of videosignal lost.
Replies: 10
Views: 3515

Simulation of videosignal lost.

Hi, friends! Here it is:

//! Simulation of videosignal lost. Call this fun. inside main loop.
//! Returns true if videosignal from camera is 'lost'.
//! NOTE: MUST NOT use if() before itself
//! or after 'if(smth) emulCamDamage()' use:
//! '..else device->getSceneManager()->getRootSceneNode ...
by Starterz
Wed Nov 17, 2010 5:39 pm
Forum: Code Snippets
Topic: Killing reference counted objects
Replies: 31
Views: 11296


Just know that Irrlicht maintains references to things like textures, shader callbacks, etc., and killing those with your KILL macro ...

Nop.

Such "things like textures, shader callbacks" hasn't no remove() metod!
So no one can "killing those with (my) KILL macro"..

Candidates for KILLing are ...
by Starterz
Wed Nov 17, 2010 4:28 am
Forum: Code Snippets
Topic: Killing reference counted objects
Replies: 31
Views: 11296


In Soviet Russia, references count you!
You'll don't believe but You 2 is counted by KGB

NO I NEVER IGNOR YOU!
Just can you explain to me please where (what concretaly structure what string?)
"Irrlicht has other references to it internally" if an object
complitly removed from Scene Graph ...
by Starterz
Wed Nov 17, 2010 2:54 am
Forum: Code Snippets
Topic: Killing reference counted objects
Replies: 31
Views: 11296

Correct:
If you drop an object more times than you grab it, the program will almost certainly crash later..

Uncorrect:
"You should still never mess with the reference count."

Why? I do what I want..
"since another object will be unaware of this and call drop()"

Why do you believe that MY ...
by Starterz
Wed Nov 17, 2010 1:24 am
Forum: Code Snippets
Topic: Killing reference counted objects
Replies: 31
Views: 11296


But you mix up 2 concepts there. drop() is about memory management. remove() on the other hand is not about memory management...


Hope I'm not

O'k let us see why I don't use only string:
while(ref-->0) irrobject->drop();


but use two strings:
while(--ref>0) irrobject->drop();
irrobject ...
by Starterz
Tue Nov 16, 2010 11:58 pm
Forum: Code Snippets
Topic: Killing reference counted objects
Replies: 31
Views: 11296

... But the following line is a guarantee for disaster:


while(--ref>0) irrobject->drop();\

and that following this line by a 'remove' even works without crash rather surprises me.

Don't be surprised!
while(--ref>0) irrobject->drop();
//! Here ref. counter is exactly 1.
irrobject ...
by Starterz
Tue Nov 16, 2010 11:01 pm
Forum: Code Snippets
Topic: Killing reference counted objects
Replies: 31
Views: 11296

Killing reference counted objects

//! As you can see this code will fail:
SomeType* obj->createSomeObj(); //! It mean 'new' or 'smgr->add' etc..
obj->delete();
if(obj) obj->doSmth()...

You can remove() of course instead delete and it's correct, then add obj=0;
That code will not fails but...
If our object have ...
by Starterz
Mon Nov 15, 2010 7:11 pm
Forum: Code Snippets
Topic: Terrain pager
Replies: 24
Views: 22167

Safe deletion of node.

Hi friends!


UPDATE: Note, this does fix the CRASH problem!

/*delete zoneList[i]->getObjectInside();


If we just comment this line we'll have memory overhead.
Pager MUST delete unused node (why pager is exist ?)


See the decision:

void CTerrainPager::loadTerrain(u16 index)
{
CTerrain ...