[Verse-dev] Using tags and C++ issues

Emil Brink emil at obsession.se
Mon Apr 25 11:27:47 CEST 2005


On Mon, 25 Apr 2005 11:56:41 +0300 (EEST)
Samuel Siltanen <saasilta at cc.hut.fi> wrote:

> Hi,

Hi Samuel, and welcome to the list and to the (growing, we hope) sphere
of developers using Verse.

> I am working in the Uni-Verse-project at Helsinki University of
> Technology and currently my task is to implement a geometry reducer
> which will be utilized in acoustics simulation. This reducer should be
> able to read geometry and material data from a Verse server, then
> reduce it, and finally write it back to a Verse server. There have
> been a few issues with which I need some advice.

Great!

> 1) I use C++ and Verse is written in C. In theory, this should not be
> a problem, because standard C should be a subset of C++. But in
> practice, there are some difficulties. There are several implicit type
> casts in Verse code, such as casting -1 to "unsigned int" or casting a
> function with arbitrary parameters and return values to "void *".

Do you have to compile the Verse core code as C++, too? If you compile it
separately as C and link to the library, isn't the number of such problems
reduced?

I don't have a good solution for the callback function pointer types, at
the moment. There is no way (that I know) to express "pointer to function
that takes an unknown number of arguments" in C, without making it into
a varargs function. Tips are very welcome.

> The compiler which I use (g++ version 3.3.5) does not accept this. It is
> very frustrating to go through every source code file to make these
> casts explicit. Would it be possible to fix these casts in the code in
> CVS?

Absolutely. To be honest, I haven't built a C++ program using Verse my-
self, but am aware of there being issues. Camilla, who works here at KTH,
has done some work on a C++ wrapper (Ample), but I'm not sure what the
status is there.

If you have patches for the Verse core to remove implicit casts (I try
to use "~0u" rather than "-1" for the invalid/max IDs, it's cleaner I
hope, I'm very interested. Please use diff -pun, and against the R5
branch (release-r5-branch).

If not, I should be able to cook up a 1-line C++ program that includes
verse.h and see what can be fixed.

> 2) I need special parameters for materials such as absorbtion
> and diffuse coefficients in addition to the ordinary color values.
> This is not supported by Verse protocol at the moment. That is why I
> decided to save the materials in tags as strings and then create a
> special material layer in the geometry node. This layer includes the
> tag IDs which can be referred to find out the material of each polygon
> face.
> 
> The problem which I encountered while testing this approach was that I
> got back only a fraction of the materials when reading them back from
> a server. I used Connector to make sure that the tags where written
> correctly to the server. But when I subscribed the tag group which
> included the material tags, I got back only 10-20 % of the tags
> through the callback function. I called verse_callback_update(100000)
> "infinitely" many times and the result was the same. I was wondering
> if anyone has actually tested the tags properly before? (It would be
> nice to know if the problem is in my code or in the Verse code.)

This sounds... Deep. If you see the tags in Connector, they should be
sent out correctly by the Verse host. But that is (I guess) no guarantee,
there could well be bugs that prevent the tag values to be sent to all
clients.

Just as a ballpark figure, could you say how many tag values we're
talking about here?

Sorry for the problems, I hope we can resolve them quickly.

Regards,

/Emil


More information about the Verse-dev mailing list