OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Text3D fix


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission
View previous topic :: View next topic  
Author Message
David Callu
Guest





PostPosted: Fri Feb 27, 2009 1:47 pm    Post subject:
Text3D fix
Reply with quote

Hi Robert

Problem:
     osgText::Text and osgText::Text3D use the same font file.
     The first really load the file and obtain an osgText::Font object,
     the second use the cache created during the first load of the
     font file, and so obtain an osgText::Font object instead of
     osgText::Font3D object. To obtain an osgText::Font3D object,
     osgText::Text3D call osgDB::readObjectFile(...) with an option
     to specify the plugin we want an osgText::Font3D instead of
     osgText::Font.

Generalised Problem:
    In osgDB::Registry, loaded file cache is referenced by the name
    of this file, so if I load a file with some options, and the cache
    already contain object for this filename, I obtain an object
    potentially not loaded with my options.

Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.

Text3D solution:
    Postfix the font file name by .text3d or something similar and then have the freetype plugin return
    osgText::Font3D when it detects this.
    This operation is done by osgText::readFont3DFile() which unsure the filename have .text3d as extension.
    This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front and wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the wall face have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af) const
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in testText3D.tgz

Cheers
David Callu

------------------
Post generated by Mail2Forum
Back to top
Robert Osfield
Guest





PostPosted: Tue Mar 10, 2009 10:56 am    Post subject:
Text3D fix
Reply with quote

Thanks for the fixes/improvements David, changes now merged and
submitted to SVN.

On Fri, Feb 27, 2009 at 1:47 PM, David Callu <> wrote:
Quote:
Hi Robert

Problem:
     osgText::Text and osgText::Text3D use the same font file.
     The first really load the file and obtain an osgText::Font object,
     the second use the cache created during the first load of the
     font file, and so obtain an osgText::Font object instead of
     osgText::Font3D object. To obtain an osgText::Font3D object,
     osgText::Text3D call osgDB::readObjectFile(...) with an option
     to specify the plugin we want an osgText::Font3D instead of
     osgText::Font.

Generalised Problem:
    In osgDB::Registry, loaded file cache is referenced by the name
    of this file, so if I load a file with some options, and the cache
    already contain object for this filename, I obtain an object
    potentially not loaded with my options.

Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.

Text3D solution:
    Postfix the font file name by .text3d or something similar and then have
the freetype plugin return
    osgText::Font3D when it detects this.
    This operation is done by osgText::readFont3DFile() which unsure the
filename have .text3d as extension.
    This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front and
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the wall face
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af) const
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu





------------------
Post generated by Mail2Forum
Back to top
James Killian
Guest





PostPosted: Thu Mar 19, 2009 2:40 pm    Post subject:
Text3D fix
Reply with quote

Quote:
Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate the
cache when load a specific file or don't cached the loaded file)
is user's responsibility.

I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in the
readImplementation() we see
else
{
ObjectCache tmpObjectCache
swap
read
swap
return
}

I would dare to submit to remove the swaps, but first ask if they were
removed what would be broken as this has been this way for a long time.

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are cached and
others are not (e.g. cached images but not nodes)... what happens is that
the line 1631 addEntry() adds to the tmpOjectCache, and therefore the real
_objectCache never gets populated. :(

If someone can at least explain why the swaps were added I would be
eternally grateful.



----- Original Message -----
From: "David Callu" <>
To: "OpenSceneGraph Submissions" <>
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
osgText::Text and osgText::Text3D use the same font file.
The first really load the file and obtain an osgText::Font object,
the second use the cache created during the first load of the
font file, and so obtain an osgText::Font object instead of
osgText::Font3D object. To obtain an osgText::Font3D object,
osgText::Text3D call osgDB::readObjectFile(...) with an option
to specify the plugin we want an osgText::Font3D instead of
osgText::Font.

Generalised Problem:
In osgDB::Registry, loaded file cache is referenced by the name
of this file, so if I load a file with some options, and the cache
already contain object for this filename, I obtain an object
potentially not loaded with my options.

Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate the
cache when load a specific file or don't cached the loaded file)
is user's responsibility.

Text3D solution:
Postfix the font file name by .text3d or something similar and then
have
Quote:
the freetype plugin return
osgText::Font3D when it detects this.
This operation is done by osgText::readFont3DFile() which unsure the
filename have .text3d as extension.
This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front and
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the wall face
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af) const
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu



----------------------------------------------------------------------------
----


Quote:
_______________________________________________
osg-submissions mailing list


http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12321

PostPosted: Thu Mar 19, 2009 4:30 pm    Post subject:
Text3D fix
Reply with quote

Hi H

On Thu, Mar 19, 2009 at 2:38 PM, James Killian < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
> Behaviours:
Quote:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.


I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in the
readImplementation() we see
else
{
   ObjectCache tmpObjectCache
   swap
   read
   swap
   return
}

I would dare to submit to remove the swaps, but first ask if they were
removed what would be broken as this has been this way for a long time.

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are cached and
others are not (e.g. cached images but not nodes)... what happens is that
the line 1631 addEntry() adds to the tmpOjectCache, and therefore the real
_objectCache never gets populated.  Sad

If someone can at least explain why the swaps were added I would be
eternally grateful.




----- Original Message -----
From: "David Callu" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
     osgText::Text and osgText::Text3D use the same font file.
     The first really load the file and obtain an osgText::Font object,
     the second use the cache created during the first load of the
     font file, and so obtain an osgText::Font object instead of
     osgText::Font3D object. To obtain an osgText::Font3D object,
     osgText::Text3D call osgDB::readObjectFile(...) with an option
     to specify the plugin we want an osgText::Font3D instead of
     osgText::Font.

Generalised Problem:
    In osgDB::Registry, loaded file cache is referenced by the name
    of this file, so if I load a file with some options, and the cache
    already contain object for this filename, I obtain an object
    potentially not loaded with my options.

Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.

Text3D solution:
    Postfix the font file name by .text3d or something similar and then
have
Quote:
the freetype plugin return
    osgText::Font3D when it detects this.
    This operation is done by osgText::readFont3DFile() which unsure the
filename have .text3d as extension.
    This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front and
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the wall face
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af) const
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu





----------------------------------------------------------------------------
----



Quote:
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12321

PostPosted: Thu Mar 19, 2009 4:35 pm    Post subject:
Text3D fix
Reply with quote

Hi James,

The swaps are in their to prevent the local object cache from being populated for the case when useObjectCache is false.

Reviewing the code now it's clear that the code isn't robust in the presence of multi-threading.  Removing the local cache and the swaps wouldn't solve anything as it would simple may that the cache is used even when you've asked for it not to be used.

As to solution it's not going to be straight forward, it'll require the cache to be managed differently, and most likely attached to the ReaderWriter::Options object.

Robert.

On Thu, Mar 19, 2009 at 2:38 PM, James Killian < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
> Behaviours:
Quote:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.


I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in the
readImplementation() we see
else
{
   ObjectCache tmpObjectCache
   swap
   read
   swap
   return
}

I would dare to submit to remove the swaps, but first ask if they were
removed what would be broken as this has been this way for a long time.

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are cached and
others are not (e.g. cached images but not nodes)... what happens is that
the line 1631 addEntry() adds to the tmpOjectCache, and therefore the real
_objectCache never gets populated.  Sad

If someone can at least explain why the swaps were added I would be
eternally grateful.




----- Original Message -----
From: "David Callu" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
     osgText::Text and osgText::Text3D use the same font file.
     The first really load the file and obtain an osgText::Font object,
     the second use the cache created during the first load of the
     font file, and so obtain an osgText::Font object instead of
     osgText::Font3D object. To obtain an osgText::Font3D object,
     osgText::Text3D call osgDB::readObjectFile(...) with an option
     to specify the plugin we want an osgText::Font3D instead of
     osgText::Font.

Generalised Problem:
    In osgDB::Registry, loaded file cache is referenced by the name
    of this file, so if I load a file with some options, and the cache
    already contain object for this filename, I obtain an object
    potentially not loaded with my options.

Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.

Text3D solution:
    Postfix the font file name by .text3d or something similar and then
have
Quote:
the freetype plugin return
    osgText::Font3D when it detects this.
    This operation is done by osgText::readFont3DFile() which unsure the
filename have .text3d as extension.
    This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front and
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the wall face
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af) const
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu





----------------------------------------------------------------------------
----



Quote:
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
James Killian
Guest





PostPosted: Thu Mar 19, 2009 6:46 pm    Post subject:
Text3D fix
Reply with quote

Is the read implementation's useObjectCache = false suppose to override all
cache hints that were provided by the options? I'm assuming not but just
the cache hint of that type... if so...

Seems like instead of passing a bool we could be passing the
CacheHintOptions type and do an if with that against the readFunctor.options
something like:

readImplementation (readFunctor, CacheHintType)
{
bool useObjectCache= readfunctor._options->getObjectCacheHint() &
CacheHintType;
if (useObjectCache)
{
}
else
{
read();
}
}

That should be thread safe since everything is protected within the
parameters
What do you think?

On a side note it appears all the derived functor types construct the bool
using cachehints & the type they represent.


----- Original Message -----
From: "Robert Osfield" <>
To: "OpenSceneGraph Submissions" <>
Sent: Thursday, March 19, 2009 11:34 AM
Subject: Re: Text3D fix


Quote:
Hi James,

The swaps are in their to prevent the local object cache from being
populated for the case when useObjectCache is false.

Reviewing the code now it's clear that the code isn't robust in the
presence
Quote:
of multi-threading. Removing the local cache and the swaps wouldn't solve
anything as it would simple may that the cache is used even when you've
asked for it not to be used.

As to solution it's not going to be straight forward, it'll require the
cache to be managed differently, and most likely attached to the
ReaderWriter::Options object.

Robert.

On Thu, Mar 19, 2009 at 2:38 PM, James Killian
<>wrote:
Quote:

Quote:
Quote:
Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate the
cache when load a specific file or don't cached the loaded file)
is user's responsibility.

I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in the
readImplementation() we see
else
{
ObjectCache tmpObjectCache
swap
read
swap
return
}

I would dare to submit to remove the swaps, but first ask if they were
removed what would be broken as this has been this way for a long time.

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are cached
and
others are not (e.g. cached images but not nodes)... what happens is
that
Quote:
Quote:
the line 1631 addEntry() adds to the tmpOjectCache, and therefore the
real
Quote:
Quote:
_objectCache never gets populated. :(

If someone can at least explain why the swaps were added I would be
eternally grateful.



----- Original Message -----
From: "David Callu" <>
To: "OpenSceneGraph Submissions"
<
Quote:
Quote:
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
osgText::Text and osgText::Text3D use the same font file.
The first really load the file and obtain an osgText::Font
object,
Quote:
Quote:
Quote:
the second use the cache created during the first load of the
font file, and so obtain an osgText::Font object instead of
osgText::Font3D object. To obtain an osgText::Font3D object,
osgText::Text3D call osgDB::readObjectFile(...) with an option
to specify the plugin we want an osgText::Font3D instead of
osgText::Font.

Generalised Problem:
In osgDB::Registry, loaded file cache is referenced by the name
of this file, so if I load a file with some options, and the cache
already contain object for this filename, I obtain an object
potentially not loaded with my options.

Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate the
cache when load a specific file or don't cached the loaded file)
is user's responsibility.

Text3D solution:
Postfix the font file name by .text3d or something similar and
then
Quote:
Quote:
have
Quote:
the freetype plugin return
osgText::Font3D when it detects this.
This operation is done by osgText::readFont3DFile() which unsure
the
Quote:
Quote:
Quote:
filename have .text3d as extension.
This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front
and
Quote:
Quote:
Quote:
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the wall
face
Quote:
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af) const
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu





--------------------------------------------------------------------------
--
Quote:
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list




http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:

_______________________________________________
osg-submissions mailing list



http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org


----------------------------------------------------------------------------
----


Quote:
_______________________________________________
osg-submissions mailing list


http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
James Killian
Guest





PostPosted: Mon Mar 23, 2009 2:00 pm    Post subject:
Text3D fix
Reply with quote

Robert,
Is there enough information in the previous email to know what direction I
wanted to address this issue?

If you want I can make the fixes and submit it... Ideally I'd like to know
if this sounds like it should work or if you wanted to pursue managing the
cache differently (i.e. attached to the ReaderWriter::Options object).

Please let me know when you have a chance... Thanks.


----- Original Message -----
From: "James Killian" <>
To: "OpenSceneGraph Submissions" <>
Sent: Thursday, March 19, 2009 1:44 PM
Subject: Re: Text3D fix


Quote:
Is the read implementation's useObjectCache = false suppose to override
all
Quote:
cache hints that were provided by the options? I'm assuming not but just
the cache hint of that type... if so...

Seems like instead of passing a bool we could be passing the
CacheHintOptions type and do an if with that against the
readFunctor.options
Quote:
something like:

readImplementation (readFunctor, CacheHintType)
{
bool useObjectCache= readfunctor._options->getObjectCacheHint() &
CacheHintType;
if (useObjectCache)
{
}
else
{
read();
}
}

That should be thread safe since everything is protected within the
parameters
What do you think?

On a side note it appears all the derived functor types construct the bool
using cachehints & the type they represent.


----- Original Message -----
From: "Robert Osfield" <>
To: "OpenSceneGraph Submissions"
<>
Quote:
Sent: Thursday, March 19, 2009 11:34 AM
Subject: Re: Text3D fix


Quote:
Hi James,

The swaps are in their to prevent the local object cache from being
populated for the case when useObjectCache is false.

Reviewing the code now it's clear that the code isn't robust in the
presence
Quote:
of multi-threading. Removing the local cache and the swaps wouldn't
solve
Quote:
Quote:
anything as it would simple may that the cache is used even when you've
asked for it not to be used.

As to solution it's not going to be straight forward, it'll require the
cache to be managed differently, and most likely attached to the
ReaderWriter::Options object.

Robert.

On Thu, Mar 19, 2009 at 2:38 PM, James Killian
<>wrote:
Quote:

Quote:
Quote:
Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate the
cache when load a specific file or don't cached the loaded file)
is user's responsibility.

I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in the
readImplementation() we see
else
{
ObjectCache tmpObjectCache
swap
read
swap
return
}

I would dare to submit to remove the swaps, but first ask if they were
removed what would be broken as this has been this way for a long
time.
Quote:
Quote:
Quote:

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are
cached
Quote:
Quote:
Quote:
and
others are not (e.g. cached images but not nodes)... what happens is
that
Quote:
Quote:
the line 1631 addEntry() adds to the tmpOjectCache, and therefore the
real
Quote:
Quote:
_objectCache never gets populated. :(

If someone can at least explain why the swaps were added I would be
eternally grateful.



----- Original Message -----
From: "David Callu" <>
To: "OpenSceneGraph Submissions"
<
Quote:
Quote:
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
osgText::Text and osgText::Text3D use the same font file.
The first really load the file and obtain an osgText::Font
object,
Quote:
Quote:
Quote:
the second use the cache created during the first load of the
font file, and so obtain an osgText::Font object instead of
osgText::Font3D object. To obtain an osgText::Font3D object,
osgText::Text3D call osgDB::readObjectFile(...) with an option
to specify the plugin we want an osgText::Font3D instead of
osgText::Font.

Generalised Problem:
In osgDB::Registry, loaded file cache is referenced by the name
of this file, so if I load a file with some options, and the
cache
Quote:
Quote:
Quote:
Quote:
already contain object for this filename, I obtain an object
potentially not loaded with my options.

Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate the
cache when load a specific file or don't cached the loaded file)
is user's responsibility.

Text3D solution:
Postfix the font file name by .text3d or something similar and
then
Quote:
Quote:
have
Quote:
the freetype plugin return
osgText::Font3D when it detects this.
This operation is done by osgText::readFont3DFile() which unsure
the
Quote:
Quote:
Quote:
filename have .text3d as extension.
This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front
and
Quote:
Quote:
Quote:
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the
wall
Quote:
Quote:
Quote:
face
Quote:
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af)
const
Quote:
Quote:
Quote:
Quote:
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu






--------------------------------------------------------------------------
--
Quote:
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list





http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:
Quote:

_______________________________________________
osg-submissions mailing list




http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:


--------------------------------------------------------------------------
--
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list



http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:

_______________________________________________
osg-submissions mailing list


http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12321

PostPosted: Mon Mar 23, 2009 2:07 pm    Post subject:
Text3D fix
Reply with quote

Hi James,

You are welcome to dive and look a full solution.  Exactly what this might look like I can't say right now, my hunch is that we'll need to refactor the cache management such as making it state of ReaderWriter::Options object.  If you don't feel comfortable with having a bash then you'll need to wait for me to have a free slot in which to tackle it.

Robert.

On Mon, Mar 23, 2009 at 1:58 PM, James Killian < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

Robert,
Is there enough information in the previous email to know what direction I
wanted to address this issue?

If you want I can make the fixes and submit it... Ideally I'd like to know
if this sounds like it should work or if you wanted to pursue managing the
cache differently (i.e. attached to the ReaderWriter::Options object).

Please let me know when you have a chance... Thanks.


----- Original Message -----
From: "James Killian" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>


Sent: Thursday, March 19, 2009 1:44 PM
Subject: Re: Text3D fix


Quote:
Is the read implementation's useObjectCache = false suppose to override
all
Quote:
cache hints that were provided by the options?  I'm assuming not but just
the cache hint of that type... if so...

Seems like instead of passing a bool we could be passing the
CacheHintOptions type and do an if with that against the
readFunctor.options
Quote:
something like:

readImplementation (readFunctor, CacheHintType)
{
    bool useObjectCache= readfunctor._options->getObjectCacheHint() &
CacheHintType;
    if (useObjectCache)
    {
    }
    else
    {
        read();
    }
}

    That should be thread safe since everything is protected within the
parameters
What do you think?

On a side note it appears all the derived functor types construct the bool
using cachehints & the type they represent.


----- Original Message -----
From: "Robert Osfield" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions"
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Quote:
Sent: Thursday, March 19, 2009 11:34 AM
Subject: Re: Text3D fix


Quote:
Hi James,

The swaps are in their to prevent the local object cache from being
populated for the case when useObjectCache is false.

Reviewing the code now it's clear that the code isn't robust in the
presence
Quote:
of multi-threading.  Removing the local cache and the swaps wouldn't
solve
Quote:
Quote:
anything as it would simple may that the cache is used even when you've
asked for it not to be used.

As to solution it's not going to be straight forward, it'll require the
cache to be managed differently, and most likely attached to the
ReaderWriter::Options object.

Robert.

On Thu, Mar 19, 2009 at 2:38 PM, James Killian
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>wrote:
Quote:

Quote:
Quote:
Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.

I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in the
readImplementation() we see
else
{
   ObjectCache tmpObjectCache
   swap
   read
   swap
   return
}

I would dare to submit to remove the swaps, but first ask if they were
removed what would be broken as this has been this way for a long
time.
Quote:
Quote:
Quote:

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are
cached
Quote:
Quote:
Quote:
and
others are not (e.g. cached images but not nodes)... what happens is
that
Quote:
Quote:
the line 1631 addEntry() adds to the tmpOjectCache, and therefore the
real
Quote:
Quote:
_objectCache never gets populated.  Sad

If someone can at least explain why the swaps were added I would be
eternally grateful.



----- Original Message -----
From: "David Callu" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions"
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
Quote:
Quote:
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
     osgText::Text and osgText::Text3D use the same font file.
     The first really load the file and obtain an osgText::Font
object,
Quote:
Quote:
Quote:
     the second use the cache created during the first load of the
     font file, and so obtain an osgText::Font object instead of
     osgText::Font3D object. To obtain an osgText::Font3D object,
     osgText::Text3D call osgDB::readObjectFile(...) with an option
     to specify the plugin we want an osgText::Font3D instead of
     osgText::Font.

Generalised Problem:
    In osgDB::Registry, loaded file cache is referenced by the name
    of this file, so if I load a file with some options, and the
cache
Quote:
Quote:
Quote:
Quote:
    already contain object for this filename, I obtain an object
    potentially not loaded with my options.

Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.

Text3D solution:
    Postfix the font file name by .text3d or something similar and
then
Quote:
Quote:
have
Quote:
the freetype plugin return
    osgText::Font3D when it detects this.
    This operation is done by osgText::readFont3DFile() which unsure
the
Quote:
Quote:
Quote:
filename have .text3d as extension.
    This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front
and
Quote:
Quote:
Quote:
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the
wall
Quote:
Quote:
Quote:
face
Quote:
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af)
const
Quote:
Quote:
Quote:
Quote:
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu






--------------------------------------------------------------------------
--
Quote:
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)




http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:
Quote:

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)



http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:


--------------------------------------------------------------------------
--
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)


http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
James Killian
Guest





PostPosted: Mon Mar 23, 2009 2:17 pm    Post subject:
Text3D fix
Reply with quote

Ok I'll go ahead and try this simpler fix first since I feel it is low risk,
and hopefully it may be good enough to get us by for now.

----- Original Message -----
From: "Robert Osfield" <>
To: "OpenSceneGraph Submissions" <>
Sent: Monday, March 23, 2009 9:07 AM
Subject: Re: Text3D fix


Quote:
Hi James,

You are welcome to dive and look a full solution. Exactly what this might
look like I can't say right now, my hunch is that we'll need to refactor
the
Quote:
cache management such as making it state of ReaderWriter::Options object.
If you don't feel comfortable with having a bash then you'll need to wait
for me to have a free slot in which to tackle it.

Robert.

On Mon, Mar 23, 2009 at 1:58 PM, James Killian
<>wrote:
Quote:

Quote:

Robert,
Is there enough information in the previous email to know what direction
I
Quote:
Quote:
wanted to address this issue?

If you want I can make the fixes and submit it... Ideally I'd like to
know
Quote:
Quote:
if this sounds like it should work or if you wanted to pursue managing
the
Quote:
Quote:
cache differently (i.e. attached to the ReaderWriter::Options object).

Please let me know when you have a chance... Thanks.


----- Original Message -----
From: "James Killian" <>
To: "OpenSceneGraph Submissions"
<
Quote:
Quote:
Sent: Thursday, March 19, 2009 1:44 PM
Subject: Re: Text3D fix


Quote:
Is the read implementation's useObjectCache = false suppose to
override
Quote:
Quote:
all
Quote:
cache hints that were provided by the options? I'm assuming not but
just
Quote:
Quote:
Quote:
the cache hint of that type... if so...

Seems like instead of passing a bool we could be passing the
CacheHintOptions type and do an if with that against the
readFunctor.options
Quote:
something like:

readImplementation (readFunctor, CacheHintType)
{
bool useObjectCache= readfunctor._options->getObjectCacheHint() &
CacheHintType;
if (useObjectCache)
{
}
else
{
read();
}
}

That should be thread safe since everything is protected within
the
Quote:
Quote:
Quote:
parameters
What do you think?

On a side note it appears all the derived functor types construct the
bool
Quote:
using cachehints & the type they represent.


----- Original Message -----
From: "Robert Osfield" <>
To: "OpenSceneGraph Submissions"
<>
Quote:
Sent: Thursday, March 19, 2009 11:34 AM
Subject: Re: Text3D fix


Quote:
Hi James,

The swaps are in their to prevent the local object cache from being
populated for the case when useObjectCache is false.

Reviewing the code now it's clear that the code isn't robust in the
presence
Quote:
of multi-threading. Removing the local cache and the swaps wouldn't
solve
Quote:
Quote:
anything as it would simple may that the cache is used even when
you've
Quote:
Quote:
Quote:
Quote:
asked for it not to be used.

As to solution it's not going to be straight forward, it'll require
the
Quote:
Quote:
Quote:
Quote:
cache to be managed differently, and most likely attached to the
ReaderWriter::Options object.

Robert.

On Thu, Mar 19, 2009 at 2:38 PM, James Killian
<>wrote:
Quote:

Quote:
Quote:
Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate
the
Quote:
Quote:
Quote:
Quote:
cache when load a specific file or don't cached the loaded
file)
Quote:
Quote:
Quote:
Quote:
is user's responsibility.

I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in
the
Quote:
Quote:
Quote:
readImplementation() we see
else
{
ObjectCache tmpObjectCache
swap
read
swap
return
}

I would dare to submit to remove the swaps, but first ask if they
were
Quote:
Quote:
Quote:
removed what would be broken as this has been this way for a long
time.
Quote:
Quote:
Quote:

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are
cached
Quote:
Quote:
Quote:
and
others are not (e.g. cached images but not nodes)... what happens
is
Quote:
Quote:
Quote:
that
Quote:
Quote:
the line 1631 addEntry() adds to the tmpOjectCache, and therefore
the
Quote:
Quote:
Quote:
real
Quote:
Quote:
_objectCache never gets populated. :(

If someone can at least explain why the swaps were added I would
be
Quote:
Quote:
Quote:
Quote:
Quote:
eternally grateful.



----- Original Message -----
From: "David Callu" <>
To: "OpenSceneGraph Submissions"
<
Quote:
Quote:
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
osgText::Text and osgText::Text3D use the same font file.
The first really load the file and obtain an osgText::Font
object,
Quote:
Quote:
Quote:
the second use the cache created during the first load of
the
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
font file, and so obtain an osgText::Font object instead of
osgText::Font3D object. To obtain an osgText::Font3D
object,
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
osgText::Text3D call osgDB::readObjectFile(...) with an
option
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
to specify the plugin we want an osgText::Font3D instead of
osgText::Font.

Generalised Problem:
In osgDB::Registry, loaded file cache is referenced by the
name
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
of this file, so if I load a file with some options, and the
cache
Quote:
Quote:
Quote:
Quote:
already contain object for this filename, I obtain an object
potentially not loaded with my options.

Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate
the
Quote:
Quote:
Quote:
Quote:
cache when load a specific file or don't cached the loaded
file)
Quote:
Quote:
Quote:
Quote:
is user's responsibility.

Text3D solution:
Postfix the font file name by .text3d or something similar
and
Quote:
Quote:
Quote:
then
Quote:
Quote:
have
Quote:
the freetype plugin return
osgText::Font3D when it detects this.
This operation is done by osgText::readFont3DFile() which
unsure
Quote:
the
Quote:
Quote:
Quote:
filename have .text3d as extension.
This is totaly transparent for user, and backward
compatible.
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:


BTW, I fix the bug about the Normal of 3D text. Currently, the
front
Quote:
and
Quote:
Quote:
Quote:
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the
wall
Quote:
Quote:
Quote:
face
Quote:
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af)
const
Quote:
Quote:
Quote:
Quote:
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu








--------------------------------------------------------------------------
Quote:
Quote:
--
Quote:
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list







http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:
Quote:
Quote:
Quote:

_______________________________________________
osg-submissions mailing list






http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:

--------------------------------------------------------------------------
Quote:
--
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list





http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:
Quote:

_______________________________________________
osg-submissions mailing list




http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:

_______________________________________________
osg-submissions mailing list



http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org


----------------------------------------------------------------------------
----


Quote:
_______________________________________________
osg-submissions mailing list


http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
James Killian
Guest





PostPosted: Tue Mar 24, 2009 3:28 am    Post subject:
Text3D fix
Reply with quote

Ok here is something that should work. This was built with 9943 (since I couldn't use 9944).
I've tested with our game and now the cache is properly populating once again. Smile


James Killian
Quote:
----- Original Message -----
From: Robert Osfield (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
To: OpenSceneGraph Submissions (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
Sent: Monday, March 23, 2009 9:07 AM
Subject: Re: Text3D fix


Hi James,

You are welcome to dive and look a full solution. Exactly what this might look like I can't say right now, my hunch is that we'll need to refactor the cache management such as making it state of ReaderWriter::Options object. If you don't feel comfortable with having a bash then you'll need to wait for me to have a free slot in which to tackle it.

Robert.

On Mon, Mar 23, 2009 at 1:58 PM, James Killian < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

Robert,
Is there enough information in the previous email to know what direction I
wanted to address this issue?

If you want I can make the fixes and submit it... Ideally I'd like to know
if this sounds like it should work or if you wanted to pursue managing the
cache differently (i.e. attached to the ReaderWriter::Options object).

Please let me know when you have a chance... Thanks.


----- Original Message -----
From: "James Killian" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>


Sent: Thursday, March 19, 2009 1:44 PM
Subject: Re: Text3D fix


Quote:
Is the read implementation's useObjectCache = false suppose to override
all
Quote:
cache hints that were provided by the options? I'm assuming not but just
the cache hint of that type... if so...

Seems like instead of passing a bool we could be passing the
CacheHintOptions type and do an if with that against the
readFunctor.options
Quote:
something like:

readImplementation (readFunctor, CacheHintType)
{
bool useObjectCache= readfunctor._options->getObjectCacheHint() &
CacheHintType;
if (useObjectCache)
{
}
else
{
read();
}
}

That should be thread safe since everything is protected within the
parameters
What do you think?

On a side note it appears all the derived functor types construct the bool
using cachehints & the type they represent.


----- Original Message -----
From: "Robert Osfield" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions"
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Quote:
Sent: Thursday, March 19, 2009 11:34 AM
Subject: Re: Text3D fix


Quote:
Hi James,

The swaps are in their to prevent the local object cache from being
populated for the case when useObjectCache is false.

Reviewing the code now it's clear that the code isn't robust in the
presence
Quote:
of multi-threading. Removing the local cache and the swaps wouldn't
solve
Quote:
Quote:
anything as it would simple may that the cache is used even when you've
asked for it not to be used.

As to solution it's not going to be straight forward, it'll require the
cache to be managed differently, and most likely attached to the
ReaderWriter::Options object.

Robert.

On Thu, Mar 19, 2009 at 2:38 PM, James Killian
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>wrote:
Quote:

Quote:
Quote:
Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate the
cache when load a specific file or don't cached the loaded file)
is user's responsibility.

I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in the
readImplementation() we see
else
{
ObjectCache tmpObjectCache
swap
read
swap
return
}

I would dare to submit to remove the swaps, but first ask if they were
removed what would be broken as this has been this way for a long
time.
Quote:
Quote:
Quote:

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are
cached
Quote:
Quote:
Quote:
and
others are not (e.g. cached images but not nodes)... what happens is
that
Quote:
Quote:
the line 1631 addEntry() adds to the tmpOjectCache, and therefore the
real
Quote:
Quote:
_objectCache never gets populated. Sad

If someone can at least explain why the swaps were added I would be
eternally grateful.



----- Original Message -----
From: "David Callu" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions"
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
Quote:
Quote:
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
osgText::Text and osgText::Text3D use the same font file.
The first really load the file and obtain an osgText::Font
object,
Quote:
Quote:
Quote:
the second use the cache created during the first load of the
font file, and so obtain an osgText::Font object instead of
osgText::Font3D object. To obtain an osgText::Font3D object,
osgText::Text3D call osgDB::readObjectFile(...) with an option
to specify the plugin we want an osgText::Font3D instead of
osgText::Font.

Generalised Problem:
In osgDB::Registry, loaded file cache is referenced by the name
of this file, so if I load a file with some options, and the
cache
Quote:
Quote:
Quote:
Quote:
already contain object for this filename, I obtain an object
potentially not loaded with my options.

Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate the
cache when load a specific file or don't cached the loaded file)
is user's responsibility.

Text3D solution:
Postfix the font file name by .text3d or something similar and
then
Quote:
Quote:
have
Quote:
the freetype plugin return
osgText::Font3D when it detects this.
This operation is done by osgText::readFont3DFile() which unsure
the
Quote:
Quote:
Quote:
filename have .text3d as extension.
This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front
and
Quote:
Quote:
Quote:
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the
wall
Quote:
Quote:
Quote:
face
Quote:
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af)
const
Quote:
Quote:
Quote:
Quote:
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu






--------------------------------------------------------------------------
--
Quote:
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)




http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:
Quote:

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)



http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:


--------------------------------------------------------------------------
--
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)


http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org









------------------
Post generated by Mail2Forum
Back to top
James Killian
Guest





PostPosted: Thu Apr 02, 2009 4:35 pm    Post subject:
Text3D fix
Reply with quote

Robert,
I thought I'd ping this email... the change is very small and should be easy
to know right away if it is safe or not.

----- Original Message -----
From: "James Killian" <>
To: "OpenSceneGraph Submissions" <>
Sent: Monday, March 23, 2009 10:28 PM
Subject: Re: Text3D fix



Ok here is something that should work. This was built with 9943 (since I
couldn't use 9944).
I've tested with our game and now the cache is properly populating once
again. :)


James Killian
----- Original Message -----
From: Robert Osfield
To: OpenSceneGraph Submissions
Sent: Monday, March 23, 2009 9:07 AM
Subject: Re: Text3D fix


Hi James,

You are welcome to dive and look a full solution. Exactly what this might
look like I can't say right now, my hunch is that we'll need to refactor the
cache management such as making it state of ReaderWriter::Options object.
If you don't feel comfortable with having a bash then you'll need to wait
for me to have a free slot in which to tackle it.

Robert.


On Mon, Mar 23, 2009 at 1:58 PM, James Killian <>
wrote:


Robert,
Is there enough information in the previous email to know what direction
I
wanted to address this issue?

If you want I can make the fixes and submit it... Ideally I'd like to
know
if this sounds like it should work or if you wanted to pursue managing
the
cache differently (i.e. attached to the ReaderWriter::Options object).

Please let me know when you have a chance... Thanks.



----- Original Message -----
From: "James Killian" <>
To: "OpenSceneGraph Submissions"
<>

Sent: Thursday, March 19, 2009 1:44 PM
Subject: Re: Text3D fix


Quote:
Is the read implementation's useObjectCache = false suppose to
override
all
Quote:
cache hints that were provided by the options? I'm assuming not but
just
Quote:
the cache hint of that type... if so...

Seems like instead of passing a bool we could be passing the
CacheHintOptions type and do an if with that against the
readFunctor.options
Quote:
something like:

readImplementation (readFunctor, CacheHintType)
{
bool useObjectCache= readfunctor._options->getObjectCacheHint() &
CacheHintType;
if (useObjectCache)
{
}
else
{
read();
}
}

That should be thread safe since everything is protected within
the
Quote:
parameters
What do you think?

On a side note it appears all the derived functor types construct the
bool
Quote:
using cachehints & the type they represent.


----- Original Message -----
From: "Robert Osfield" <>
To: "OpenSceneGraph Submissions"
<>
Quote:
Sent: Thursday, March 19, 2009 11:34 AM
Subject: Re: Text3D fix


Quote:
Hi James,

The swaps are in their to prevent the local object cache from being
populated for the case when useObjectCache is false.

Reviewing the code now it's clear that the code isn't robust in the
presence
Quote:
of multi-threading. Removing the local cache and the swaps wouldn't
solve
Quote:
Quote:
anything as it would simple may that the cache is used even when
you've
Quote:
Quote:
asked for it not to be used.

As to solution it's not going to be straight forward, it'll require
the
Quote:
Quote:
cache to be managed differently, and most likely attached to the
ReaderWriter::Options object.

Robert.

On Thu, Mar 19, 2009 at 2:38 PM, James Killian
<>wrote:
Quote:

Quote:
Quote:
Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate
the
Quote:
Quote:
Quote:
Quote:
cache when load a specific file or don't cached the loaded
file)
Quote:
Quote:
Quote:
Quote:
is user's responsibility.

I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in
the
Quote:
Quote:
Quote:
readImplementation() we see
else
{
ObjectCache tmpObjectCache
swap
read
swap
return
}

I would dare to submit to remove the swaps, but first ask if they
were
Quote:
Quote:
Quote:
removed what would be broken as this has been this way for a long
time.
Quote:
Quote:
Quote:

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are
cached
Quote:
Quote:
Quote:
and
others are not (e.g. cached images but not nodes)... what happens
is
Quote:
that
Quote:
Quote:
the line 1631 addEntry() adds to the tmpOjectCache, and therefore
the
Quote:
real
Quote:
Quote:
_objectCache never gets populated. :(

If someone can at least explain why the swaps were added I would
be
Quote:
Quote:
Quote:
eternally grateful.



----- Original Message -----
From: "David Callu" <>
To: "OpenSceneGraph Submissions"
<
Quote:
Quote:
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
osgText::Text and osgText::Text3D use the same font file.
The first really load the file and obtain an osgText::Font
object,
Quote:
Quote:
Quote:
the second use the cache created during the first load of
the
Quote:
Quote:
Quote:
Quote:
font file, and so obtain an osgText::Font object instead of
osgText::Font3D object. To obtain an osgText::Font3D
object,
Quote:
Quote:
Quote:
Quote:
osgText::Text3D call osgDB::readObjectFile(...) with an
option
Quote:
Quote:
Quote:
Quote:
to specify the plugin we want an osgText::Font3D instead of
osgText::Font.

Generalised Problem:
In osgDB::Registry, loaded file cache is referenced by the
name
Quote:
Quote:
Quote:
Quote:
of this file, so if I load a file with some options, and the
cache
Quote:
Quote:
Quote:
Quote:
already contain object for this filename, I obtain an object
potentially not loaded with my options.

Behaviours:
Cache management is delegate to osgDB::Registry, but cache
coherence (load a file with option then reuse it, deactivate
the
Quote:
Quote:
Quote:
Quote:
cache when load a specific file or don't cached the loaded
file)
Quote:
Quote:
Quote:
Quote:
is user's responsibility.

Text3D solution:
Postfix the font file name by .text3d or something similar
and
Quote:
then
Quote:
Quote:
have
Quote:
the freetype plugin return
osgText::Font3D when it detects this.
This operation is done by osgText::readFont3DFile() which
unsure
Quote:
the
Quote:
Quote:
Quote:
filename have .text3d as extension.
This is totaly transparent for user, and backward
compatible.
Quote:
Quote:
Quote:
Quote:


BTW, I fix the bug about the Normal of 3D text. Currently, the
front
Quote:
and
Quote:
Quote:
Quote:
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the
wall
Quote:
Quote:
Quote:
face
Quote:
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af)
const
Quote:
Quote:
Quote:
Quote:
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu










Quote:
--------------------------------------------------------------------------
--
Quote:
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list






http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:
Quote:

_______________________________________________
osg-submissions mailing list





http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org




Quote:
--------------------------------------------------------------------------
--
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list




http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:

_______________________________________________
osg-submissions mailing list



http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org







----------------------------------------------------------------------------
--






----------------------------------------------------------------------------
----


Quote:
_______________________________________________
osg-submissions mailing list


http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12321

PostPosted: Wed Apr 08, 2009 2:04 pm    Post subject:
Text3D fix
Reply with quote

Hi James,

I've now reviewed your changes and they an improvement over the old code, still not perfect but certainly better.  I'm not 100% happy with not hiding the local object cache as was attempted in the previous code - this swap code existed for a reason, if it was buggy.  Still I believe your code will be more reliable and not have the same thread issues that original code had so I'll check it in and let us see how things pan out.

Cheers,
Robert.

On Tue, Mar 24, 2009 at 4:28 AM, James Killian < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
 
Ok here is something that should work.  This was built with 9943 (since I couldn't use 9944).
I've tested with our game and now the cache is properly populating once again.  Smile
 
 
James Killian
Quote:
----- Original Message -----
From: Robert Osfield (
Only registered users can see emails on this board!
Get registred or enter the forums!
)


To: OpenSceneGraph Submissions (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
Sent: Monday, March 23, 2009 9:07 AM
Subject: Re: Text3D fix


Hi James,

You are welcome to dive and look a full solution.  Exactly what this might look like I can't say right now, my hunch is that we'll need to refactor the cache management such as making it state of ReaderWriter::Options object.  If you don't feel comfortable with having a bash then you'll need to wait for me to have a free slot in which to tackle it.

Robert.

On Mon, Mar 23, 2009 at 1:58 PM, James Killian < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

Robert,
Is there enough information in the previous email to know what direction I
wanted to address this issue?

If you want I can make the fixes and submit it... Ideally I'd like to know
if this sounds like it should work or if you wanted to pursue managing the
cache differently (i.e. attached to the ReaderWriter::Options object).

Please let me know when you have a chance... Thanks.


----- Original Message -----
From: "James Killian" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>


Sent: Thursday, March 19, 2009 1:44 PM
Subject: Re: Text3D fix


Quote:
Is the read implementation's useObjectCache = false suppose to override
all
Quote:
cache hints that were provided by the options?  I'm assuming not but just
the cache hint of that type... if so...

Seems like instead of passing a bool we could be passing the
CacheHintOptions type and do an if with that against the
readFunctor.options
Quote:
something like:

readImplementation (readFunctor, CacheHintType)
{
    bool useObjectCache= readfunctor._options->getObjectCacheHint() &
CacheHintType;
    if (useObjectCache)
    {
    }
    else
    {
        read();
    }
}

    That should be thread safe since everything is protected within the
parameters
What do you think?

On a side note it appears all the derived functor types construct the bool
using cachehints & the type they represent.


----- Original Message -----
From: "Robert Osfield" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions"
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Quote:
Sent: Thursday, March 19, 2009 11:34 AM
Subject: Re: Text3D fix


Quote:
Hi James,

The swaps are in their to prevent the local object cache from being
populated for the case when useObjectCache is false.

Reviewing the code now it's clear that the code isn't robust in the
presence
Quote:
of multi-threading.  Removing the local cache and the swaps wouldn't
solve
Quote:
Quote:
anything as it would simple may that the cache is used even when you've
asked for it not to be used.

As to solution it's not going to be straight forward, it'll require the
cache to be managed differently, and most likely attached to the
ReaderWriter::Options object.

Robert.

On Thu, Mar 19, 2009 at 2:38 PM, James Killian
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>wrote:
Quote:

Quote:
Quote:
Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.

I actually ran into a similar issue... let me explain here:

Looking at the latest rev 9884 of Registry.cpp around line 1641 in the
readImplementation() we see
else
{
   ObjectCache tmpObjectCache
   swap
   read
   swap
   return
}

I would dare to submit to remove the swaps, but first ask if they were
removed what would be broken as this has been this way for a long
time.
Quote:
Quote:
Quote:

Stress that breaks _objectCache:
As of now if I have 2 threads loading where some object types are
cached
Quote:
Quote:
Quote:
and
others are not (e.g. cached images but not nodes)... what happens is
that
Quote:
Quote:
the line 1631 addEntry() adds to the tmpOjectCache, and therefore the
real
Quote:
Quote:
_objectCache never gets populated.  Sad

If someone can at least explain why the swaps were added I would be
eternally grateful.



----- Original Message -----
From: "David Callu" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
To: "OpenSceneGraph Submissions"
< (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
Quote:
Quote:
Sent: Friday, February 27, 2009 8:47 AM
Subject: Text3D fix


Quote:
Hi Robert

Problem:
     osgText::Text and osgText::Text3D use the same font file.
     The first really load the file and obtain an osgText::Font
object,
Quote:
Quote:
Quote:
     the second use the cache created during the first load of the
     font file, and so obtain an osgText::Font object instead of
     osgText::Font3D object. To obtain an osgText::Font3D object,
     osgText::Text3D call osgDB::readObjectFile(...) with an option
     to specify the plugin we want an osgText::Font3D instead of
     osgText::Font.

Generalised Problem:
    In osgDB::Registry, loaded file cache is referenced by the name
    of this file, so if I load a file with some options, and the
cache
Quote:
Quote:
Quote:
Quote:
    already contain object for this filename, I obtain an object
    potentially not loaded with my options.

Behaviours:
    Cache management is delegate to osgDB::Registry, but cache
    coherence (load a file with option then reuse it, deactivate the
    cache when load a specific file or don't cached the loaded file)
    is user's responsibility.

Text3D solution:
    Postfix the font file name by .text3d or something similar and
then
Quote:
Quote:
have
Quote:
the freetype plugin return
    osgText::Font3D when it detects this.
    This operation is done by osgText::readFont3DFile() which unsure
the
Quote:
Quote:
Quote:
filename have .text3d as extension.
    This is totaly transparent for user, and backward compatible.


BTW, I fix the bug about the Normal of 3D text. Currently, the front
and
Quote:
Quote:
Quote:
wall face have
the same normal (0,0,1) in the Text3D object coordinate. Now the
wall
Quote:
Quote:
Quote:
face
Quote:
have its own
normal array computed by the plugin.

BTW 2, I implement
- void Text3D::accept(osg::Drawable::ConstAttributeFunctor& af)
const
Quote:
Quote:
Quote:
Quote:
- void Text3D::accept(osg::PrimitiveFunctor& pf) const
so now statistics are well reported.

I join modified file in osgText3D.tgz and a the original test in
testText3D.tgz

Cheers
David Callu






--------------------------------------------------------------------------
--
Quote:
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)




http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:
Quote:
Quote:

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)



http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:


--------------------------------------------------------------------------
--
Quote:
----


Quote:
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)


http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
Quote:

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org








_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Text3D fix for OpenSceneGraph 3.4.0 Konstantin Submission 3 Sun Feb 12, 2017 9:34 pm View latest post
No new posts Text3D alignment issue robertosfield Submission 0 Thu Jun 26, 2014 10:54 am View latest post
No new posts Text3D alignment issue Farshid Lashkari Submission 2 Fri Apr 18, 2014 5:02 pm View latest post
No new posts Text3D vertical layout lines count stomach Submission 0 Thu Apr 26, 2012 3:23 pm View latest post
No new posts ostText::Text3D Alignment (Possible C... Jeremy Moles General 2 Thu Jun 02, 2011 5:13 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP