Jump to content

Wierdest VEX struct issue


Kino

Recommended Posts

Hey Guys, I asked this in the sidefx forums in hope of an answer from a developer. But I though I ask it here as well since I'm going absolutely mental over this

 

I have a couple of structs declared in a .h header file. My problem started that whenever I include the header file in an AttribWrangle node and then use a specific function from one of the structs, it seems like Houdini can recognize the array kind of another struct I have in the same file. 

I narrowed down the bug and here's a shortened header file which reproduces the error (I know the code is nonsense and won't do anything in the shortened state but my problem is the iritating error the wrangle node produces): 

This is the header file (Test.h): 

 

Code:

struct StructManager 

    string      mTags[]; 
    int         mIds[]; 
    string      mAllTags; // workaround: there is a bug with string arrays on detail with my version of houdini 15.0.274 

    int         mGeometry; //after a manager is opened or gotten, it'll know the geometry who owns it 

    void close() 
    { 

        string tagList[]; 
        int count = len(tagList); 
        for (int i=0; i<count; i++){ 
        } 
    } 

    void open(int aGeometry) 
    { 
        mGeometry = aGeometry; 
        mIds = attrib(mGeometry, "detail", "mIds", 0); 
        mTags = attrib(mGeometry, "detail", "mTags", 0); 
        mAllTags = attrib(mGeometry, "detail", "mAllTags", 0); 
    } 



struct Point 

   int mNumber; 
   vector mPos; 


struct EndPoint 

   int mNumber; 
   vector mPos; 
   int mOppositePoint; 


now if I write this in a wrangle node: 

Code:
#include <Test.h> 

StructManager manager; 

Point points[]; 

int count = len(points); 
manager -> close(); 


The error is "No matching function for int len(Point[])" . Now If I replace this line from the "close" method of the "StructManager" no error is produced!!!! 

Code:
int count = len(tagList);   ------> int count = 10; 


It seems the problem lies with calling len() inside close() 
Can anyone reproduce it ? Any ideas why this is happening?[/code]


 

Link to comment
Share on other sites

I don't know the answer but I can guess.

 

len() is a predefined function that operates on type array. Obviously it would work for native data types. You created a custom data type called Point. len() is not defined for data type Point, so it casts an error saying it cannot find an appropriate definition for function len(). You could either add a custom definition for len() inside of your Point struct or cast your Point struct to a supported type. 

 

I do not know the syntax but I guess it would be something like:

int count = len((string)point);

 

Someone else is going to have to chime in and correct me...

Link to comment
Share on other sites

Thanks for the answer loopyllama but I know that in Houdini arrays are supported for arbitary types, I think it's doable since version 13 I think, I know I read somewhere on the SESI forums that actually the reason function definitions with array return types don't work in wrangle nodes is related to this fact. Anyways as I said above if you replace the line I mentioned, len(Point[]) is accepted by the compiler

Link to comment
Share on other sites

Unfortunately reordering won't work since in my actual scenario Point needs to know about StructManager.
I went through the source and changed the for loops with len(structName[]) to foreach loops but still the wrangle gives out the same error, it's like it's internally it's using len() itself. It detects Point[] so it knows an array of Point can exist but at the same time can not perform the same functions on it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...