QPickPointEvent when mouse cursor do something above points in Python Qt 3D? - pyqt5

I have a QEntity with a mesh which is set as a primitive type (Points). Beside that I also initialized QObjectPicker and connect four basic signals to functions (clicked, moved, pressed, and released). When I run application and do some mouse events, none of these events is QPickPointEvent. Only QPickEvents occur. Is it possible in Python to trigger a QPickPointEvent?
I also set pick method to PointPicking.

You need to enable point picking using the pick method on the QPickSettings property of the instance of QRenderSettings.
In that case, the QPickEvent will actually be an instance of QPointPickEvent. I'm not sure how you "downcast" that in python though.
But if you entity is indeed using point primitives, then the coordinates of the picked point and the point itself should be the same. The only information you would be missing is the index of the point in it's parent list of primitives.

Related

Variable increasing by 3 instead of 1

In Scratch I have a variable that is supposed to change by one every time a broadcast is recieved, however in testing it changes by three per broadcast and I can't find why. The button used to send the broadcast has 3 clones of it but each have a different function and sending the broadcast depends on the "button selected" variable being set to "fight" so don't think that would effect the outcome.
I looked through all my code and it's not duplicated, theres nothing else changing the variable, and the broadcast is only being sent once at a time. It even works perfectly fine if I click the blocks to run them myself, but when it does it as the function in-game it changes it by three and I can't understand why.
The code for changing the variable is:
When I recieve "attack"
Change "attacktimes" by 1
The code for sending the broadcast is this:
When key "z" pressed
if "enemy turn" = "0"
if "button type" = "fight"
broadcast "fight"
Does anybody know a solution?
Also here is the shared project, it is incomplete though.
My project
Steps for recreating the bug are listed in the instructions
Broadcasts are a powerful mechanism, but they can be hard to control,
especially in a project that uses clones.
I looked through all my code and it's not duplicated
That's irrelevant. It's all in the name: broadcasts go everywhere.
What may seem like a single action when looking at the (static) code, may explode in all directions at runtime.
In general, be very careful when cloning a sprite that has a 'when I receive' message handler.
The message handler will be triggered for every clone, as well as the original sprite.
In your case, sprite 'Error404 Sans' has two clones. Together with the original sprite, that's a total of three objects.
When message 'Attack' comes in, the 'when I receive Attack' script will be executed for each of the three objects.
Since variable 'AttackTimes' is a global variable, it will be incremented three times.
So how to fix this? In this case, the easiest way is to move the whole 'when I receive Attack' script to the stage, to a dummy sprite or any other sprite that is not cloned.
It's cute to have a Sans sprite made up of three parts, giving him that 'breathing' look.
But that is already a big responsibility for a sprite; better implement the 'attacking' part elsewhere.
Otherwise, you'll find yourself being attacked independently by Sans's head, torso and legs.
A more clumsy solution would be use an 'if-then' block to ensure only one specific clone will proceed with the attack.
For the 'if' condition, you will need a 'for this sprite only' variable or anything else that is clone-specific (e.g. position, costume name).

Exploding only some part of an object in Blender 2.82a (using Explode modifier with Vertex Group?)

I am trying to explode/destroy only some part of an object.
Following Blender 2.82 manual page
https://docs.blender.org/manual/en/2.82/physics/particles/emitter/emission.html
says "You may use vertex groups to confine the emission, that is done in the Vertex Groups panel."
So, it must be possible.
As a test, I created a Blender file, attempting to explode/destroy only the left ear of Suzanne, using Explode modifier.
I tried the following:
Added a monkey object ("Suzanne").
Applied "Subdivision Modifier" with "Simple" subdivision algorithm.
Created a vertex group named "VtxGroup_Suzanne__All_vertices_in_left_ear", which contains all vertices in Suzanne's left ear.
enter image description here
Created particle system setting.
Enabled Rotation.
In "Density" field under "Vertex Groups", entered "VtxGroup_Suzanne__All_vertices_in_left_ear".
In "Render As" filed under "Render", chose "Object".
Added "Explode" modifier.
This modifier has "Vertex Group" field, but it seems it does not make any difference in the result (probably because I do not know how to use it properly???)
At this point, when I play the animation, particles erupt out of Suzanne's left ear, breaking down Suzanne little by little.
However, the destruction is not limited to the left year. Entire Suzanne starts breaking down.
Some destruction pieces are really big or unnaturally long, such as almost half of Suzanne's face shown in the screenshot.
enter image description here
Is there any way I can limit the destruction only to the left ear (which is vertex group "VtxGroup_Suzanne__All_vertices_in_left_ear".
Also, can I adjust the sizes of destruction particles, so that some of them would not be too big, nor too long?
I tried setting a whole bunch of settings, but I could not find the solution. Maybe I am attempting this completely wrong? Is there some way to accomplish this in a completely different way?
This test file is found here (zipped):
Test file for Explode modifier with Vertex Group
Thank you in advance for help.
Try splitting the object? If you want to animate the object beforehand, construct the object out of two separate objects grouped, and then ungroup them at or before the keyframe you want them to explode. I hope this helps!
:)

How can I test if an item is anchored?

What is the proper way to test if an item has been anchored? For example, take the left side, I have tried:
property bool isAnchored: parent.anchors.left != undefined
But that does not seem to work? I also tried:
property bool isAnchored: !!parent.anchors.left
which also does not seem to work, I also tried:
property bool isAnchored: parent.anchors.left ? true : false
Any other ideas? There has to be a way to check if an item is anchored but I can not find it?
Unfortunately I don't see any way to do it using the provided/exposed properties. The only thing that determines a valid anchor is the Anchors flag type which is defined in the QQuickAnchorLine::anchorLine member, but that's not exposed to QML anywhere (eg. anchors.left.anchorLine is always undefined). Or in the public C++ API for that matter. The actual QQuickAnchorLines attached to each object are always valid/non-null, as you've discovered.
I think you will need to implement your own flags in whatever routine(s) which set or remove the anchors in your code (I assume that has to be determined somewhere). That is, whenever an anchor changes, set a custom property value. There are also the anchor change signals (leftChanged() etc.) which could be connected to.
Alternatively, you could re-implement your own attached Anchors object in C++ and track whatever properties you want (basically same as the above suggestion but centralized in a C++ class). Here is a good example (I think, not my code) of defining your own anchors lines using a custom attached object. With something like this it would be pretty easy to track/query what is anchored to what.

LabVIEW and OOP through .NET assembly

I would like to reuse an instance created with the constructor node. Say once I create an instance of Camera as seen in the diagram below, how do I reuse it other places ? For variables and buttons I know that I can create a local variable or a reference and update, but I can't find a way to reuse instances. Could anyone please shed some light ?
Thank you,
The cyan wire coming out of the constructor node is a reference to an object. You can fork that wire to anywhere else in your program that you want to use it. Your Event Structure is probably inside a While Loop. It's likely that you want to create a shift register on the border of the loop and wire the object reference wire to the right-hand shift register so you can reuse the reference in other frames on later events. Here's an image to explain...
You can reuse the reference to the instance. Wire a reference to an indicator from the camera constructor node and then use that reference via local variables the same way as you would normally do.

EXC_BAD_ACCESS on animationForKey:

I'm trying to use a recent feature of the Scintilla component, which provides OSX-like text-highlighting effect (the yellow animated bouncing box), and I'm stuck with an error that pops up intermittently :
EXC_BAD_ACCESS
pointing to this particular line :
if (layerFindIndicator!=nil)
if ([layerFindIndicator animationForKey:#"animateFound"])
[layerFindIndicator removeAnimationForKey:#"animateFound"];
(the ifs are mine; just in case I caught the object layerFindIndicator being nil, or deallocated or whatever... Unfortunately, it doesn't help...)
layerFindIndicator is seemingly a subclass of CAGradientLayer. (You may see the full code for layerFindIndicator, here).
Since, I'm an absolute newbie to Quartz Core, could please give me any hint as to HOW this could be debugged?
Since, I'm an absolute newbie to Quartz Core, could please give me any hint as to HOW this could be debugged?
This doesn't have anything to do with QuartzCore specifically (at least, I hope not)—it's general this-object-has-been-killed-before-its-time-how-do-I-find-the-killer stuff.
In Xcode:
Edit your current scheme.
For the Profile action, set it to use the Debug build configuration.
Dismiss that and then hit the Profile command.
Xcode will build for that action and then launch Instruments.
Instruments will prompt you to choose a template; you want the Zombies template. Once you've chosen it, Instruments will create a trace document and run your application. Switch to your application (if it isn't already frontmost), then do whatever causes the crash.
If the crash really is a dead-object crash, Zombies will reveal it. You'll get a flag in Instruments's timeline saying something like “message sent to zombie object 0xd3c2b1a0”, and your program will probably exit shortly thereafter.
In that flag is a tiny little button that looks like this: ➲ except it'll be gray. Click on it.
That takes you to the history of that object (actually of that address, including any previous objects or other allocations that have started at that address). Show your Extended Detail Pane (the one that appears on the right showing a stack trace), then scroll down to the end and then move backward (upward) step by step through time, looking at releases and autoreleases, looking for the one that isn't balancing out the object's allocation or a retain.
The solution will probably involve one or more of:
Changing a property to be strong or weak rather than assign/unsafe_unretained
Adding a property where you previously did not strongly own an object
Rearchitecting some things, if it's not clear which of the above you need to do or if either one of them seems like a filthy hack
Switching to ARC to get weak properties and __weak instance variables (both of which get set to nil automatically when the referenced object dies) and to get local variables being implicitly initialized to nil
But it'll depend on what you find in Instruments. And, of course, there's the chance that your problem—the bad access—isn't a dead object at all and all of the above will not help you.
Try this:
if (layerFindIndicator!=nil){
if ([layerFindIndicator animationForKey:#"animateFound"]){
[layerFindIndicator removeAnimationForKey:#"animateFound"];
}
}
Also check to see if it is released else were.
EDIT:
Another thing I found was you didn't have an white space in the if. Your code should now look like this:
if (layerFindIndicator != nil){
if ([layerFindIndicator animationForKey:#"animateFound"]){
[layerFindIndicator removeAnimationForKey:#"animateFound"];
}
}