thanks for the reply Brent! using a dirty flag is totally fine, i think it was just late and i couldn't think of such a obvious answer. i dont think an IsValid method is needed for the PickBuffer, i can use IsNavigating() or use the activate callback to set the flag.
i am not at the point where i am thinking about caching multiple views but thanks for the reminder :) i am not familiar with the term 'GAP-like', care to elaborate? steven On Mon, Jul 30, 2012 at 5:13 AM, Brent McPherson < brent.mcpher...@autodesk.com> wrote: > Hi Steven, > > Why don't you keep a dirty flag for the pickbuffer and simply set that in > Activate and then the next time you ask for the pickbuffer (in mouse move > or mouse down) recompute it if it is dirty. > > The pickbuffer is specific to a particular view so you can't generate it > is a callback like Activate which is not tied to any particular view. The > same holds for methods like GetMousePosition. It will return CStatus::Fail > when called from Activate. I guess we should have added an IsValid method > to the pickbuffer but as a workaround you can assume that if GetViewIndex > returns a value greater or equal to zero then it is safe to call > GetPickBuffer. You will also need to decide if you are going to cache a > pickbuffer for each view or just keep one for the last view etc... > > The pickbuffer stuff was designed with this purpose in mind and one of our > consulting devs used it to do a real-time (GAP-like) sculpting tool for a > client. > -- > Brent > > From: softimage-boun...@listproc.autodesk.com [mailto: > softimage-boun...@listproc.autodesk.com] On Behalf Of Steven Caron > Sent: 30 July 2012 04:43 > To: softimage@listproc.autodesk.com > Subject: SDK : caching the tool context pick buffer > > hey guys... (read brent) > > i am trying to cache the PickBuffer each time the user activates this > custom tool (this happens on camera navigation, which is my primary > concern) but not having much luck. the doc suggests if i pass an empty > region i will get the whole view but any subsequent calls i am making to > PickBuffer.GetObjectAtPosition() has returned an invalid reference. is this > doable in the Activate calback? the docs say..."if unavailable in the > current callback or any arguments are invalid then the resulting PickBuffer > will be invalid." > > so, are my arguments incorrect or is this not valid in the this callback? > > // activate callback, called each time the tool comes active again > CStatus Activate(ToolContext& in_ctxt) > { > // get a list of selected meshes > const CString empty; > CStringArray families; > families.Add(siMeshFamily); > Application().GetSelection().GetArray().Filter(empty, families, empty, > m_targets); > > // cache a pick buffer, m_pBuffer is a class member variable where i am > caching it > m_pBuffer = in_ctxt.GetPickBuffer(x, y, width, height, siPolygonFilter, > m_targets, siShaded); > LONG x,y; > in_ctxt.GetMousePosition(x, y); > CRef l_obj = m_pBuffer.GetObjectAtPosition(x, y); > Application().LogMessage(L"Activate : " + l_obj.GetAsText()); > > return CStatus::OK; > }; > > any other tips on caching the PickBuffer each time the camera changes? > > steven >